UNPKG

apostille-library

Version:

A novel & holistic blockchain notarization and timestamping with transferable, updatable, branded, and conjointly owned notarizations.

50 lines 2.09 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const nemSDK = __importStar(require("nem-sdk")); const nem2_sdk_1 = require("nem2-sdk"); const hash_1 = require("../../hash/hash"); const Initiator_1 = require("../../infrastructure/Initiator"); const ApostillePublicAccount_1 = require("./ApostillePublicAccount"); const nem = nemSDK.default; const fixPrivateKey = (privateKey) => { return ('0000000000000000000000000000000000000000000000000000000000000000' + privateKey.replace(/^00/, '')) .slice(-64); }; class Apostille extends ApostillePublicAccount_1.ApostillePublicAccount { constructor(HDAccount) { super(HDAccount.publicAccount); this.HDAccount = HDAccount; } static initFromSeed(seed, generatorAccount) { const networkType = generatorAccount.address.networkType; const hashSeed = hash_1.SHA256.hash(seed); let privateKey; if (networkType === nem2_sdk_1.NetworkType.MAIN_NET || networkType === nem2_sdk_1.NetworkType.TEST_NET) { const keyPair = nem.crypto.keyPair.create(generatorAccount.privateKey); privateKey = fixPrivateKey(keyPair.sign(hashSeed).toString()); } else { privateKey = fixPrivateKey(generatorAccount.signData(hashSeed)); } const hdAccount = nem2_sdk_1.Account.createFromPrivateKey(privateKey, networkType); return new Apostille(hdAccount); } associate(owners, quorumDelta, minRemovalDelta) { return { initiator: this.initiator, transaction: this.transfer(owners, [], quorumDelta, minRemovalDelta), }; } get initiator() { return new Initiator_1.Initiator(this.HDAccount); } } exports.Apostille = Apostille; //# sourceMappingURL=Apostille.js.map