Compare commits
No commits in common. "main" and "hdpath" have entirely different histories.
8
.github/workflows/nodejs.yml
vendored
8
.github/workflows/nodejs.yml
vendored
@ -10,5 +10,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: volta-cli/action@v1
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
- run: npm ci --no-audit
|
||||
- run: npm run lint --if-present
|
||||
- run: npm test
|
||||
- run: npm run build --if-present
|
||||
env:
|
||||
CI: true
|
||||
|
||||
@ -101,7 +101,6 @@ describe('CryptoHDKey', () => {
|
||||
chainCode: node.chainCode,
|
||||
origin: originkeypath
|
||||
})
|
||||
expect(cryptoHDKey.getBip32Key()).toEqual(extendedPublicKey);
|
||||
expect(cryptoHDKey.toCBOR().toString('hex')).toBe(hex.toLowerCase());
|
||||
const ur = cryptoHDKey.toUREncoder(1000).nextPart();
|
||||
expect(ur).toBe("ur:crypto-hdkey/otaxhdclaxpsfswtmnsknejlceuogoqdaelbmhwnptlrecwpeehhfnpsfzbauecatleotsheptaahdcxvsbbhlrpdivdmelovygscttbstjpnllpasmtcaecmyvswpwftssffxrkcabsmdcxamtaaddyoeadlaaocylpgrstlfiewtseje")
|
||||
|
||||
23
build/urlib.min.js
vendored
Normal file
23
build/urlib.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
32
dist/Bytes.js
vendored
32
dist/Bytes.js
vendored
@ -1,32 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Bytes = void 0;
|
||||
const lib_1 = require("./lib");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
class Bytes extends RegistryItem_1.RegistryItem {
|
||||
constructor(bytes) {
|
||||
super();
|
||||
this.bytes = bytes;
|
||||
this.getRegistryType = () => {
|
||||
return RegistryType_1.RegistryTypes.BYTES;
|
||||
};
|
||||
this.getData = () => this.bytes;
|
||||
this.toDataItem = () => {
|
||||
return new lib_1.DataItem(this.bytes);
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.Bytes = Bytes;
|
||||
Bytes.fromDataItem = (dataItem) => {
|
||||
const bytes = dataItem.getData();
|
||||
if (!bytes) {
|
||||
throw new Error(`#[ur-registry][Bytes][fn.fromDataItem]: decoded [dataItem][#data] is undefined: ${dataItem}`);
|
||||
}
|
||||
return new Bytes(bytes);
|
||||
};
|
||||
Bytes.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return Bytes.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=Bytes.js.map
|
||||
1
dist/Bytes.js.map
vendored
1
dist/Bytes.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"Bytes.js","sourceRoot":"","sources":["../src/Bytes.ts"],"names":[],"mappings":";;;AAAA,+BAAmD;AACnD,iDAA8C;AAC9C,iDAA+C;AAE/C,MAAa,KAAM,SAAQ,2BAAY;IAKrC,YAAoB,KAAa;QAC/B,KAAK,EAAE,CAAC;QADU,UAAK,GAAL,KAAK,CAAQ;QAJjC,oBAAe,GAAG,GAAG,EAAE;YACrB,OAAO,4BAAa,CAAC,KAAK,CAAC;QAC7B,CAAC,CAAC;QAMF,YAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;QAE3B,eAAU,GAAG,GAAG,EAAE;YAChB,OAAO,IAAI,cAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC;IANF,CAAC;;AAPH,sBA6BC;AAde,kBAAY,GAAG,CAAC,QAAkB,EAAE,EAAE;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CACb,mFAAmF,QAAQ,EAAE,CAC9F,CAAC;KACH;IACD,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEY,cAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,IAAA,sBAAgB,EAAC,YAAY,CAAC,CAAC;IAChD,OAAO,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
||||
51
dist/CryptoAccount.js
vendored
51
dist/CryptoAccount.js
vendored
@ -1,51 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CryptoAccount = void 0;
|
||||
const _1 = require(".");
|
||||
const lib_1 = require("./lib");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
var Keys;
|
||||
(function (Keys) {
|
||||
Keys[Keys["masterFingerprint"] = 1] = "masterFingerprint";
|
||||
Keys[Keys["outputDescriptors"] = 2] = "outputDescriptors";
|
||||
})(Keys || (Keys = {}));
|
||||
class CryptoAccount extends RegistryItem_1.RegistryItem {
|
||||
constructor(masterFingerprint, outputDescriptors) {
|
||||
super();
|
||||
this.masterFingerprint = masterFingerprint;
|
||||
this.outputDescriptors = outputDescriptors;
|
||||
this.getRegistryType = () => {
|
||||
return RegistryType_1.RegistryTypes.CRYPTO_ACCOUNT;
|
||||
};
|
||||
this.getMasterFingerprint = () => this.masterFingerprint;
|
||||
this.getOutputDescriptors = () => this.outputDescriptors;
|
||||
this.toDataItem = () => {
|
||||
const map = {};
|
||||
if (this.masterFingerprint) {
|
||||
map[Keys.masterFingerprint] = this.masterFingerprint.readUInt32BE(0);
|
||||
}
|
||||
if (this.outputDescriptors) {
|
||||
map[Keys.outputDescriptors] = this.outputDescriptors.map((item) => item.toDataItem());
|
||||
}
|
||||
return new lib_1.DataItem(map);
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.CryptoAccount = CryptoAccount;
|
||||
CryptoAccount.fromDataItem = (dataItem) => {
|
||||
const map = dataItem.getData();
|
||||
const masterFingerprint = Buffer.alloc(4);
|
||||
const _masterFingerprint = map[Keys.masterFingerprint];
|
||||
if (_masterFingerprint) {
|
||||
masterFingerprint.writeUInt32BE(_masterFingerprint, 0);
|
||||
}
|
||||
const outputDescriptors = map[Keys.outputDescriptors];
|
||||
const cryptoOutputs = outputDescriptors.map((item) => _1.CryptoOutput.fromDataItem(item));
|
||||
return new CryptoAccount(masterFingerprint, cryptoOutputs);
|
||||
};
|
||||
CryptoAccount.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return CryptoAccount.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=CryptoAccount.js.map
|
||||
1
dist/CryptoAccount.js.map
vendored
1
dist/CryptoAccount.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"CryptoAccount.js","sourceRoot":"","sources":["../src/CryptoAccount.ts"],"names":[],"mappings":";;;AAAA,wBAAiC;AACjC,+BAAmD;AACnD,iDAA8C;AAC9C,iDAA+C;AAE/C,IAAK,IAGJ;AAHD,WAAK,IAAI;IACP,yDAAqB,CAAA;IACrB,yDAAiB,CAAA;AACnB,CAAC,EAHI,IAAI,KAAJ,IAAI,QAGR;AAED,MAAa,aAAc,SAAQ,2BAAY;IAK7C,YACU,iBAAyB,EACzB,iBAAiC;QAEzC,KAAK,EAAE,CAAC;QAHA,sBAAiB,GAAjB,iBAAiB,CAAQ;QACzB,sBAAiB,GAAjB,iBAAiB,CAAgB;QAN3C,oBAAe,GAAG,GAAG,EAAE;YACrB,OAAO,4BAAa,CAAC,cAAc,CAAC;QACtC,CAAC,CAAC;QASK,yBAAoB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC;QACpD,yBAAoB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAEpD,eAAU,GAAG,GAAG,EAAE;YACvB,MAAM,GAAG,GAAG,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBAC1B,GAA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
vendored
58
dist/CryptoCoinInfo.js
vendored
@ -1,58 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CryptoCoinInfo = exports.Network = exports.Type = void 0;
|
||||
const lib_1 = require("./lib");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
var Keys;
|
||||
(function (Keys) {
|
||||
Keys["type"] = "1";
|
||||
Keys["network"] = "2";
|
||||
})(Keys || (Keys = {}));
|
||||
var Type;
|
||||
(function (Type) {
|
||||
Type[Type["bitcoin"] = 0] = "bitcoin";
|
||||
})(Type = exports.Type || (exports.Type = {}));
|
||||
var Network;
|
||||
(function (Network) {
|
||||
Network[Network["mainnet"] = 0] = "mainnet";
|
||||
Network[Network["testnet"] = 1] = "testnet";
|
||||
})(Network = exports.Network || (exports.Network = {}));
|
||||
class CryptoCoinInfo extends RegistryItem_1.RegistryItem {
|
||||
constructor(type, network) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.network = network;
|
||||
this.getRegistryType = () => {
|
||||
return RegistryType_1.RegistryTypes.CRYPTO_COIN_INFO;
|
||||
};
|
||||
this.getType = () => {
|
||||
return this.type || Type.bitcoin;
|
||||
};
|
||||
this.getNetwork = () => {
|
||||
return this.network || Network.mainnet;
|
||||
};
|
||||
this.toDataItem = () => {
|
||||
const map = {};
|
||||
if (this.type) {
|
||||
map[Keys.type] = this.type;
|
||||
}
|
||||
if (this.network) {
|
||||
map[Keys.network] = this.network;
|
||||
}
|
||||
return new lib_1.DataItem(map);
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.CryptoCoinInfo = CryptoCoinInfo;
|
||||
CryptoCoinInfo.fromDataItem = (dataItem) => {
|
||||
const map = dataItem.getData();
|
||||
const type = map[Keys.type];
|
||||
const network = map[Keys.network];
|
||||
return new CryptoCoinInfo(type, network);
|
||||
};
|
||||
CryptoCoinInfo.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return CryptoCoinInfo.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=CryptoCoinInfo.js.map
|
||||
1
dist/CryptoCoinInfo.js.map
vendored
1
dist/CryptoCoinInfo.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"CryptoCoinInfo.js","sourceRoot":"","sources":["../src/CryptoCoinInfo.ts"],"names":[],"mappings":";;;AAAA,+BAAmD;AACnD,iDAA8C;AAC9C,iDAA+C;AAE/C,IAAK,IAGJ;AAHD,WAAK,IAAI;IACP,kBAAU,CAAA;IACV,qBAAa,CAAA;AACf,CAAC,EAHI,IAAI,KAAJ,IAAI,QAGR;AAED,IAAY,IAEX;AAFD,WAAY,IAAI;IACd,qCAAW,CAAA;AACb,CAAC,EAFW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAEf;AAED,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,2CAAO,CAAA;IACP,2CAAO,CAAA;AACT,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAED,MAAa,cAAe,SAAQ,2BAAY;IAK9C,YAAoB,IAAW,EAAU,OAAiB;QACxD,KAAK,EAAE,CAAC;QADU,SAAI,GAAJ,IAAI,CAAO;QAAU,YAAO,GAAP,OAAO,CAAU;QAJ1D,oBAAe,GAAG,GAAG,EAAE;YACrB,OAAO,4BAAa,CAAC,gBAAgB,CAAC;QACxC,CAAC,CAAC;QAMK,YAAO,GAAG,GAAG,EAAE;YACpB,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC;QACnC,CAAC,CAAC;QAEK,eAAU,GAAG,GAAG,EAAE;YACvB,OAAO,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;QACzC,CAAC,CAAC;QAEK,eAAU,GAAG,GAAG,EAAE;YACvB,MAAM,GAAG,GAAG,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;aAC5B;YACD,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;aAClC;YACD,OAAO,IAAI,cAAQ,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC;IAnBF,CAAC;;AAPH,wCAuCC;AAXe,2BAAY,GAAG,CAAC,QAAkB,EAAE,EAAE;IAClD,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEY,uBAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,IAAA,sBAAgB,EAAC,YAAY,CAAC,CAAC;IAChD,OAAO,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
||||
53
dist/CryptoECKey.js
vendored
53
dist/CryptoECKey.js
vendored
@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CryptoECKey = void 0;
|
||||
const lib_1 = require("./lib");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
var Keys;
|
||||
(function (Keys) {
|
||||
Keys[Keys["curve"] = 1] = "curve";
|
||||
Keys[Keys["private"] = 2] = "private";
|
||||
Keys[Keys["data"] = 3] = "data";
|
||||
})(Keys || (Keys = {}));
|
||||
class CryptoECKey extends RegistryItem_1.RegistryItem {
|
||||
constructor(args) {
|
||||
super();
|
||||
this.getCurve = () => this.curve || 0;
|
||||
this.isPrivateKey = () => this.privateKey || false;
|
||||
this.getData = () => this.data;
|
||||
this.getRegistryType = () => {
|
||||
return RegistryType_1.RegistryTypes.CRYPTO_ECKEY;
|
||||
};
|
||||
this.toDataItem = () => {
|
||||
const map = {};
|
||||
if (this.curve) {
|
||||
map[Keys.curve] = this.curve;
|
||||
}
|
||||
if (this.privateKey !== undefined) {
|
||||
map[Keys.private] = this.privateKey;
|
||||
}
|
||||
map[Keys.data] = this.data;
|
||||
return new lib_1.DataItem(map);
|
||||
};
|
||||
this.data = args.data;
|
||||
this.curve = args.curve;
|
||||
this.privateKey = args.privateKey;
|
||||
}
|
||||
}
|
||||
exports.CryptoECKey = CryptoECKey;
|
||||
CryptoECKey.fromDataItem = (dataItem) => {
|
||||
const map = dataItem.getData();
|
||||
const curve = map[Keys.curve];
|
||||
const privateKey = map[Keys.private];
|
||||
const data = map[Keys.data];
|
||||
if (!data) {
|
||||
throw new Error(`#[ur-registry][CryptoECKey][fn.fromDataItem]: decoded [dataItem][#data.data] is undefined: ${dataItem}`);
|
||||
}
|
||||
return new CryptoECKey({ data, curve, privateKey });
|
||||
};
|
||||
CryptoECKey.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return CryptoECKey.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=CryptoECKey.js.map
|
||||
1
dist/CryptoECKey.js.map
vendored
1
dist/CryptoECKey.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"CryptoECKey.js","sourceRoot":"","sources":["../src/CryptoECKey.ts"],"names":[],"mappings":";;;AAAA,+BAAmD;AACnD,iDAA8C;AAC9C,iDAA+C;AAE/C,IAAK,IAIJ;AAJD,WAAK,IAAI;IACP,iCAAS,CAAA;IACT,qCAAO,CAAA;IACP,+BAAI,CAAA;AACN,CAAC,EAJI,IAAI,KAAJ,IAAI,QAIR;AAED,MAAa,WAAY,SAAQ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MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,8FAA8F,QAAQ,EAAE,CACzG,CAAC;KACH;IACD,OAAO,IAAI,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC;AAEY,oBAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,IAAA,sBAAgB,EAAC,YAAY,CAAC,CAAC;IAChD,OAAO,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC5C,CAAC,CAAC"}
|
||||
180
dist/CryptoHDKey.js
vendored
180
dist/CryptoHDKey.js
vendored
@ -1,180 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CryptoHDKey = void 0;
|
||||
const bs58check_1 = require("bs58check");
|
||||
const CryptoCoinInfo_1 = require("./CryptoCoinInfo");
|
||||
const CryptoKeypath_1 = require("./CryptoKeypath");
|
||||
const lib_1 = require("./lib");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
var Keys;
|
||||
(function (Keys) {
|
||||
Keys[Keys["is_master"] = 1] = "is_master";
|
||||
Keys[Keys["is_private"] = 2] = "is_private";
|
||||
Keys[Keys["key_data"] = 3] = "key_data";
|
||||
Keys[Keys["chain_code"] = 4] = "chain_code";
|
||||
Keys[Keys["use_info"] = 5] = "use_info";
|
||||
Keys[Keys["origin"] = 6] = "origin";
|
||||
Keys[Keys["children"] = 7] = "children";
|
||||
Keys[Keys["parent_fingerprint"] = 8] = "parent_fingerprint";
|
||||
Keys[Keys["name"] = 9] = "name";
|
||||
Keys[Keys["note"] = 10] = "note";
|
||||
})(Keys || (Keys = {}));
|
||||
class CryptoHDKey extends RegistryItem_1.RegistryItem {
|
||||
constructor(args) {
|
||||
super();
|
||||
this.getKey = () => this.key;
|
||||
this.getChainCode = () => this.chainCode;
|
||||
this.isMaster = () => this.master;
|
||||
this.isPrivateKey = () => !!this.privateKey;
|
||||
this.getUseInfo = () => this.useInfo;
|
||||
this.getOrigin = () => this.origin;
|
||||
this.getChildren = () => this.children;
|
||||
this.getParentFingerprint = () => this.parentFingerprint;
|
||||
this.getName = () => this.name;
|
||||
this.getNote = () => this.note;
|
||||
this.getBip32Key = () => {
|
||||
let version;
|
||||
let depth;
|
||||
let index;
|
||||
let parentFingerprint = Buffer.alloc(4).fill(0);
|
||||
if (this.isMaster()) {
|
||||
version = Buffer.from("0488ADE4", "hex");
|
||||
depth = 0;
|
||||
index = 0;
|
||||
}
|
||||
else {
|
||||
depth = this.getOrigin().getComponents().length || this.getOrigin().getDepth();
|
||||
const paths = this.getOrigin().getComponents();
|
||||
const lastPath = paths[paths.length - 1];
|
||||
if (lastPath) {
|
||||
index = lastPath.isHardened() ? lastPath.getIndex() + 0x80000000 : lastPath.getIndex();
|
||||
parentFingerprint = this.getParentFingerprint();
|
||||
}
|
||||
if (this.isPrivateKey()) {
|
||||
version = Buffer.from('0488ADE4', 'hex');
|
||||
}
|
||||
else {
|
||||
version = Buffer.from('0488B21E', 'hex');
|
||||
}
|
||||
}
|
||||
const depthBuffer = Buffer.alloc(1);
|
||||
depthBuffer.writeUInt8(depth, 0);
|
||||
const indexBuffer = Buffer.alloc(4);
|
||||
indexBuffer.writeUInt32BE(index, 0);
|
||||
const chainCode = this.getChainCode();
|
||||
const key = this.getKey();
|
||||
return (0, bs58check_1.encode)(Buffer.concat([version, depthBuffer, parentFingerprint, indexBuffer, chainCode, key]));
|
||||
};
|
||||
this.getRegistryType = () => {
|
||||
return RegistryType_1.RegistryTypes.CRYPTO_HDKEY;
|
||||
};
|
||||
this.setupMasterKey = (args) => {
|
||||
this.master = true;
|
||||
this.key = args.key;
|
||||
this.chainCode = args.chainCode;
|
||||
};
|
||||
this.setupDeriveKey = (args) => {
|
||||
this.master = false;
|
||||
this.privateKey = args.isPrivateKey;
|
||||
this.key = args.key;
|
||||
this.chainCode = args.chainCode;
|
||||
this.useInfo = args.useInfo;
|
||||
this.origin = args.origin;
|
||||
this.children = args.children;
|
||||
this.parentFingerprint = args.parentFingerprint;
|
||||
this.name = args.name;
|
||||
this.note = args.note;
|
||||
};
|
||||
this.toDataItem = () => {
|
||||
const map = {};
|
||||
if (this.master) {
|
||||
map[Keys.is_master] = true;
|
||||
map[Keys.key_data] = this.key;
|
||||
map[Keys.chain_code] = this.chainCode;
|
||||
}
|
||||
else {
|
||||
if (this.privateKey !== undefined) {
|
||||
map[Keys.is_private] = this.privateKey;
|
||||
}
|
||||
map[Keys.key_data] = this.key;
|
||||
if (this.chainCode) {
|
||||
map[Keys.chain_code] = this.chainCode;
|
||||
}
|
||||
if (this.useInfo) {
|
||||
const useInfo = this.useInfo.toDataItem();
|
||||
useInfo.setTag(this.useInfo.getRegistryType().getTag());
|
||||
map[Keys.use_info] = useInfo;
|
||||
}
|
||||
if (this.origin) {
|
||||
const origin = this.origin.toDataItem();
|
||||
origin.setTag(this.origin.getRegistryType().getTag());
|
||||
map[Keys.origin] = origin;
|
||||
}
|
||||
if (this.children) {
|
||||
const children = this.children.toDataItem();
|
||||
children.setTag(this.children.getRegistryType().getTag());
|
||||
map[Keys.children] = children;
|
||||
}
|
||||
if (this.parentFingerprint) {
|
||||
map[Keys.parent_fingerprint] = this.parentFingerprint.readUInt32BE(0);
|
||||
}
|
||||
if (this.name !== undefined) {
|
||||
map[Keys.name] = this.name;
|
||||
}
|
||||
if (this.note !== undefined) {
|
||||
map[Keys.note] = this.note;
|
||||
}
|
||||
}
|
||||
return new lib_1.DataItem(map);
|
||||
};
|
||||
if (args.isMaster) {
|
||||
this.setupMasterKey(args);
|
||||
}
|
||||
else {
|
||||
this.setupDeriveKey(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CryptoHDKey = CryptoHDKey;
|
||||
CryptoHDKey.fromDataItem = (dataItem) => {
|
||||
const map = dataItem.getData();
|
||||
const isMaster = !!map[Keys.is_master];
|
||||
const isPrivateKey = map[Keys.is_private];
|
||||
const key = map[Keys.key_data];
|
||||
const chainCode = map[Keys.chain_code];
|
||||
const useInfo = map[Keys.use_info]
|
||||
? CryptoCoinInfo_1.CryptoCoinInfo.fromDataItem(map[Keys.use_info])
|
||||
: undefined;
|
||||
const origin = map[Keys.origin]
|
||||
? CryptoKeypath_1.CryptoKeypath.fromDataItem(map[Keys.origin])
|
||||
: undefined;
|
||||
const children = map[Keys.children]
|
||||
? CryptoKeypath_1.CryptoKeypath.fromDataItem(map[Keys.children])
|
||||
: undefined;
|
||||
let _parentFingerprint = map[Keys.parent_fingerprint];
|
||||
let parentFingerprint;
|
||||
if (_parentFingerprint) {
|
||||
parentFingerprint = Buffer.alloc(4);
|
||||
parentFingerprint.writeUInt32BE(_parentFingerprint, 0);
|
||||
}
|
||||
const name = map[Keys.name];
|
||||
const note = map[Keys.note];
|
||||
return new CryptoHDKey({
|
||||
isMaster,
|
||||
isPrivateKey,
|
||||
key,
|
||||
chainCode,
|
||||
useInfo,
|
||||
origin,
|
||||
children,
|
||||
parentFingerprint,
|
||||
name,
|
||||
note,
|
||||
});
|
||||
};
|
||||
CryptoHDKey.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return CryptoHDKey.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=CryptoHDKey.js.map
|
||||
1
dist/CryptoHDKey.js.map
vendored
1
dist/CryptoHDKey.js.map
vendored
File diff suppressed because one or more lines are too long
89
dist/CryptoKeypath.js
vendored
89
dist/CryptoKeypath.js
vendored
@ -1,89 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CryptoKeypath = void 0;
|
||||
const lib_1 = require("./lib");
|
||||
const PathComponent_1 = require("./PathComponent");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
var Keys;
|
||||
(function (Keys) {
|
||||
Keys[Keys["components"] = 1] = "components";
|
||||
Keys[Keys["source_fingerprint"] = 2] = "source_fingerprint";
|
||||
Keys[Keys["depth"] = 3] = "depth";
|
||||
})(Keys || (Keys = {}));
|
||||
class CryptoKeypath extends RegistryItem_1.RegistryItem {
|
||||
constructor(components = [], sourceFingerprint, depth) {
|
||||
super();
|
||||
this.components = components;
|
||||
this.sourceFingerprint = sourceFingerprint;
|
||||
this.depth = depth;
|
||||
this.getRegistryType = () => {
|
||||
return RegistryType_1.RegistryTypes.CRYPTO_KEYPATH;
|
||||
};
|
||||
this.getPath = () => {
|
||||
if (this.components.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const components = this.components.map((component) => {
|
||||
return `${component.isWildcard() ? '*' : component.getIndex()}${component.isHardened() ? "'" : ''}`;
|
||||
});
|
||||
return components.join('/');
|
||||
};
|
||||
this.getComponents = () => this.components;
|
||||
this.getSourceFingerprint = () => this.sourceFingerprint;
|
||||
this.getDepth = () => this.depth;
|
||||
this.toDataItem = () => {
|
||||
const map = {};
|
||||
const components = [];
|
||||
this.components &&
|
||||
this.components.forEach((component) => {
|
||||
if (component.isWildcard()) {
|
||||
components.push([]);
|
||||
}
|
||||
else {
|
||||
components.push(component.getIndex());
|
||||
}
|
||||
components.push(component.isHardened() ? true : false);
|
||||
});
|
||||
map[Keys.components] = components;
|
||||
if (this.sourceFingerprint) {
|
||||
map[Keys.source_fingerprint] = this.sourceFingerprint.readUInt32BE(0);
|
||||
}
|
||||
if (this.depth !== undefined) {
|
||||
map[Keys.depth] = this.depth;
|
||||
}
|
||||
return new lib_1.DataItem(map);
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.CryptoKeypath = CryptoKeypath;
|
||||
CryptoKeypath.fromDataItem = (dataItem) => {
|
||||
const map = dataItem.getData();
|
||||
const pathComponents = [];
|
||||
const components = map[Keys.components];
|
||||
if (components) {
|
||||
for (let i = 0; i < components.length; i += 2) {
|
||||
const isHardened = components[i + 1];
|
||||
const path = components[i];
|
||||
if (typeof path === 'number') {
|
||||
pathComponents.push(new PathComponent_1.PathComponent({ index: path, hardened: isHardened }));
|
||||
}
|
||||
else {
|
||||
pathComponents.push(new PathComponent_1.PathComponent({ hardened: isHardened }));
|
||||
}
|
||||
}
|
||||
}
|
||||
const _sourceFingerprint = map[Keys.source_fingerprint];
|
||||
let sourceFingerprint;
|
||||
if (_sourceFingerprint) {
|
||||
sourceFingerprint = Buffer.alloc(4);
|
||||
sourceFingerprint.writeUInt32BE(_sourceFingerprint, 0);
|
||||
}
|
||||
const depth = map[Keys.depth];
|
||||
return new CryptoKeypath(pathComponents, sourceFingerprint, depth);
|
||||
};
|
||||
CryptoKeypath.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return CryptoKeypath.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=CryptoKeypath.js.map
|
||||
1
dist/CryptoKeypath.js.map
vendored
1
dist/CryptoKeypath.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"CryptoKeypath.js","sourceRoot":"","sources":["../src/CryptoKeypath.ts"],"names":[],"mappings":";;;AAAA,+BAAmD;AACnD,mDAAgD;AAChD,iDAA8C;AAC9C,iDAA+C;AAE/C,IAAK,IAIJ;AAJD,WAAK,IAAI;IACP,2CAAc,CAAA;IACd,2DAAkB,CAAA;IAClB,iCAAK,CAAA;AACP,CAAC,EAJI,IAAI,KAAJ,IAAI,QAIR;AAED,MAAa,aAAc,SAAQ,2BAAY;IAK7C,YACU,aAA8B,EAAE,EAChC,iBAA0B,EAC1B,KAAc;QAEtB,KAAK,EAAE,CAAC;QAJA,eAAU,GAAV,UAAU,CAAsB;QAChC,sBAAiB,GAAjB,iBAAiB,CAAS;QAC1B,UAAK,GAAL,KAAK,CAAS;QAPxB,oBAAe,GAAG,GAAG,EAAE;YACrB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B,GAAG,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxD,IAAI,iBAAyB,CAAC;IAC9B,IAAI,kBAAkB,EAAE;QACtB,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpC,iBAAiB,CAAC,aAAa,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;KACxD;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9B,OAAO,IAAI,aAAa,CAAC,cAAc,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAC;AACrE,CAAC,CAAC;AAEY,sBAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,IAAA,sBAAgB,EAAC,YAAY,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC9C,CAAC,CAAC"}
|
||||
109
dist/CryptoOutput.js
vendored
109
dist/CryptoOutput.js
vendored
@ -1,109 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CryptoOutput = void 0;
|
||||
const CryptoECKey_1 = require("./CryptoECKey");
|
||||
const CryptoHDKey_1 = require("./CryptoHDKey");
|
||||
const lib_1 = require("./lib");
|
||||
const MultiKey_1 = require("./MultiKey");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
const ScriptExpression_1 = require("./ScriptExpression");
|
||||
class CryptoOutput extends RegistryItem_1.RegistryItem {
|
||||
constructor(scriptExpressions, cryptoKey) {
|
||||
super();
|
||||
this.scriptExpressions = scriptExpressions;
|
||||
this.cryptoKey = cryptoKey;
|
||||
this.getRegistryType = () => {
|
||||
return RegistryType_1.RegistryTypes.CRYPTO_OUTPUT;
|
||||
};
|
||||
this.getCryptoKey = () => this.cryptoKey;
|
||||
this.getHDKey = () => {
|
||||
if (this.cryptoKey instanceof CryptoHDKey_1.CryptoHDKey) {
|
||||
return this.cryptoKey;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
this.getECKey = () => {
|
||||
if (this.cryptoKey instanceof CryptoECKey_1.CryptoECKey) {
|
||||
return this.cryptoKey;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
this.getMultiKey = () => {
|
||||
if (this.cryptoKey instanceof MultiKey_1.MultiKey) {
|
||||
return this.cryptoKey;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
this.getScriptExpressions = () => this.scriptExpressions;
|
||||
this.toDataItem = () => {
|
||||
let dataItem = this.cryptoKey.toDataItem();
|
||||
if (this.cryptoKey instanceof CryptoECKey_1.CryptoECKey ||
|
||||
this.cryptoKey instanceof CryptoHDKey_1.CryptoHDKey) {
|
||||
dataItem.setTag(this.cryptoKey.getRegistryType().getTag());
|
||||
}
|
||||
const clonedSe = [...this.scriptExpressions];
|
||||
clonedSe.reverse().forEach((se) => {
|
||||
const tagValue = se.getTag();
|
||||
if (dataItem.getTag() === undefined) {
|
||||
dataItem.setTag(tagValue);
|
||||
}
|
||||
else {
|
||||
dataItem = new lib_1.DataItem(dataItem, tagValue);
|
||||
}
|
||||
});
|
||||
return dataItem;
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.CryptoOutput = CryptoOutput;
|
||||
CryptoOutput.fromDataItem = (dataItem) => {
|
||||
const scriptExpressions = [];
|
||||
let _dataItem = dataItem;
|
||||
while (true) {
|
||||
let _tag = _dataItem.getTag() || undefined;
|
||||
const se = ScriptExpression_1.ScriptExpression.fromTag(_tag);
|
||||
if (se) {
|
||||
scriptExpressions.push(se);
|
||||
if (_dataItem.getData() instanceof lib_1.DataItem) {
|
||||
_dataItem = _dataItem.getData();
|
||||
_tag = _dataItem.getTag();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const seLength = scriptExpressions.length;
|
||||
const isMultiKey = seLength > 0 &&
|
||||
(scriptExpressions[seLength - 1].getExpression() ===
|
||||
ScriptExpression_1.ScriptExpressions.MULTISIG.getExpression() ||
|
||||
scriptExpressions[seLength - 1].getExpression() ===
|
||||
ScriptExpression_1.ScriptExpressions.SORTED_MULTISIG.getExpression());
|
||||
if (isMultiKey) {
|
||||
const multiKey = MultiKey_1.MultiKey.fromDataItem(_dataItem);
|
||||
return new CryptoOutput(scriptExpressions, multiKey);
|
||||
}
|
||||
if (_dataItem.getTag() === RegistryType_1.RegistryTypes.CRYPTO_HDKEY.getTag()) {
|
||||
const cryptoHDKey = CryptoHDKey_1.CryptoHDKey.fromDataItem(_dataItem);
|
||||
return new CryptoOutput(scriptExpressions, cryptoHDKey);
|
||||
}
|
||||
else {
|
||||
const cryptoECKey = CryptoECKey_1.CryptoECKey.fromDataItem(_dataItem);
|
||||
return new CryptoOutput(scriptExpressions, cryptoECKey);
|
||||
}
|
||||
};
|
||||
CryptoOutput.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return CryptoOutput.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=CryptoOutput.js.map
|
||||
1
dist/CryptoOutput.js.map
vendored
1
dist/CryptoOutput.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"CryptoOutput.js","sourceRoot":"","sources":["../src/CryptoOutput.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,+CAA4C;AAC5C,+BAAmD;AACnD,yCAAsC;AACtC,iDAA8C;AAC9C,iDAA+C;AAC/C,yDAAyE;AAEzE,MAAa,YAAa,SAAQ,2BAAY;IAK5C,YACU,iBAAqC,EACrC,SAA+C;QAEvD,KAAK,EAAE,CAAC;QAHA,sBAAiB,GAAjB,iBAAiB,CAAoB;QACrC,cAAS,GAAT,SAAS,CAAsC;QANlD,oBAAe,GAAG,GAAG,EAA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,GAAG,mBAAQ,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAClD,OAAO,IAAI,YAAY,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;KACtD;IAED,IAAI,SAAS,CAAC,MAAM,EAAE,KAAK,4BAAa,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE;QAC9D,MAAM,WAAW,GAAG,yBAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACxD,OAAO,IAAI,YAAY,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;KACzD;SAAM;QACL,MAAM,WAAW,GAAG,yBAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACxD,OAAO,IAAI,YAAY,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;KACzD;AACH,CAAC,CAAC;AAEY,qBAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,IAAA,sBAAgB,EAAC,YAAY,CAAC,CAAC;IAChD,OAAO,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC,CAAC"}
|
||||
30
dist/CryptoPSBT.js
vendored
30
dist/CryptoPSBT.js
vendored
@ -1,30 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CryptoPSBT = void 0;
|
||||
const lib_1 = require("./lib");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
class CryptoPSBT extends RegistryItem_1.RegistryItem {
|
||||
constructor(psbt) {
|
||||
super();
|
||||
this.psbt = psbt;
|
||||
this.getRegistryType = () => RegistryType_1.RegistryTypes.CRYPTO_PSBT;
|
||||
this.getPSBT = () => this.psbt;
|
||||
this.toDataItem = () => {
|
||||
return new lib_1.DataItem(this.psbt);
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.CryptoPSBT = CryptoPSBT;
|
||||
CryptoPSBT.fromDataItem = (dataItem) => {
|
||||
const psbt = dataItem.getData();
|
||||
if (!psbt) {
|
||||
throw new Error(`#[ur-registry][CryptoPSBT][fn.fromDataItem]: decoded [dataItem][#data] is undefined: ${dataItem}`);
|
||||
}
|
||||
return new CryptoPSBT(psbt);
|
||||
};
|
||||
CryptoPSBT.fromCBOR = (_cborPayload) => {
|
||||
const dataItem = (0, lib_1.decodeToDataItem)(_cborPayload);
|
||||
return CryptoPSBT.fromDataItem(dataItem);
|
||||
};
|
||||
//# sourceMappingURL=CryptoPSBT.js.map
|
||||
1
dist/CryptoPSBT.js.map
vendored
1
dist/CryptoPSBT.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"CryptoPSBT.js","sourceRoot":"","sources":["../src/CryptoPSBT.ts"],"names":[],"mappings":";;;AAAA,+BAAmD;AACnD,iDAA8C;AAC9C,iDAA+C;AAE/C,MAAa,UAAW,SAAQ,2BAAY;IAG1C,YAAoB,IAAY;QAC9B,KAAK,EAAE,CAAC;QADU,SAAI,GAAJ,IAAI,CAAQ;QAFhC,oBAAe,GAAG,GAAG,EAAE,CAAC,4BAAa,CAAC,WAAW,CAAC;QAM3C,YAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QAE1B,eAAU,GAAG,GAAG,EAAE;YACvB,OAAO,IAAI,cAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC,CAAC;IANF,CAAC;;AALH,gCA2BC;AAde,uBAAY,GAAG,CAAC,QAAkB,EAAE,EAAE;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChC,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,wFAAwF,QAAQ,EAAE,CACnG,CAAC;KACH;IACD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEY,mBAAQ,GAAG,CAAC,YAAoB,EAAE,EAAE;IAChD,MAAM,QAAQ,GAAG,IAAA,sBAAgB,EAAC,YAAY,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC,CAAC"}
|
||||
36
dist/Decoder/index.js
vendored
36
dist/Decoder/index.js
vendored
@ -1,36 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.URRegistryDecoder = void 0;
|
||||
const bc_ur_1 = require("@ngraveio/bc-ur");
|
||||
const __1 = require("..");
|
||||
const RegistryType_1 = require("../RegistryType");
|
||||
class URRegistryDecoder extends bc_ur_1.URDecoder {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.resultRegistryType = () => {
|
||||
const ur = this.resultUR();
|
||||
switch (ur.type) {
|
||||
case RegistryType_1.RegistryTypes.BYTES.getType():
|
||||
return __1.Bytes.fromCBOR(ur.cbor);
|
||||
case RegistryType_1.RegistryTypes.CRYPTO_HDKEY.getType():
|
||||
return __1.CryptoHDKey.fromCBOR(ur.cbor);
|
||||
case RegistryType_1.RegistryTypes.CRYPTO_KEYPATH.getType():
|
||||
return __1.CryptoKeypath.fromCBOR(ur.cbor);
|
||||
case RegistryType_1.RegistryTypes.CRYPTO_COIN_INFO.getType():
|
||||
return __1.CryptoCoinInfo.fromCBOR(ur.cbor);
|
||||
case RegistryType_1.RegistryTypes.CRYPTO_ECKEY.getType():
|
||||
return __1.CryptoECKey.fromCBOR(ur.cbor);
|
||||
case RegistryType_1.RegistryTypes.CRYPTO_OUTPUT.getType():
|
||||
return __1.CryptoOutput.fromCBOR(ur.cbor);
|
||||
case RegistryType_1.RegistryTypes.CRYPTO_PSBT.getType():
|
||||
return __1.CryptoPSBT.fromCBOR(ur.cbor);
|
||||
case RegistryType_1.RegistryTypes.CRYPTO_ACCOUNT.getType():
|
||||
return __1.CryptoAccount.fromCBOR(ur.cbor);
|
||||
default:
|
||||
throw new Error(`#[ur-registry][Decoder][fn.resultRegistryType]: registry type ${ur.type} is not supported now`);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.URRegistryDecoder = URRegistryDecoder;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/Decoder/index.js.map
vendored
1
dist/Decoder/index.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Decoder/index.ts"],"names":[],"mappings":";;;AAAA,2CAA4C;AAC5C,0BASY;AACZ,kDAAgD;AAEhD,MAAa,iBAAkB,SAAQ,iBAAS;IAAhD;;QACS,uBAAkB,GAAG,GAAG,EAAE;YAC/B,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE;gBACf,KAAK,4BAAa,CAAC,KAAK,CAAC,OAAO,EAAE;oBAChC,OAAO,SAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACjC,KAAK,4BAAa,CAAC,YAAY,CAAC,OAAO,EAAE;oBACvC,OAAO,eAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACvC,KAAK,4BAAa,CAAC,cAAc,CAAC,OAAO,EAAE;oBACzC,OAAO,iBAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACzC,KAAK,4BAAa,CAAC,gBAAgB,CAAC,OAAO,EAAE;oBAC3C,OAAO,kBAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC1C,KAAK,4BAAa,CAAC,YAAY,CAAC,OAAO,EAAE;oBACvC,OAAO,eAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACvC,KAAK,4BAAa,CAAC,aAAa,CAAC,OAAO,EAAE;oBACxC,OAAO,gBAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACxC,KAAK,4BAAa,CAAC,WAAW,CAAC,OAAO,EAAE;oBACtC,OAAO,cAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACtC,KAAK,4BAAa,CAAC,cAAc,CAAC,OAAO,EAAE;oBACzC,OAAO,iBAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACzC;oBACE,MAAM,IAAI,KAAK,CACb,iEAAiE,EAAE,CAAC,IAAI,uBAAuB,CAChG,CAAC;aACL;QACH,CAAC,CAAC;IACJ,CAAC;CAAA;AA1BD,8CA0BC"}
|
||||
53
dist/MultiKey.js
vendored
53
dist/MultiKey.js
vendored
@ -1,53 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MultiKey = void 0;
|
||||
const CryptoECKey_1 = require("./CryptoECKey");
|
||||
const CryptoHDKey_1 = require("./CryptoHDKey");
|
||||
const DataItem_1 = require("./lib/DataItem");
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
var Keys;
|
||||
(function (Keys) {
|
||||
Keys[Keys["threshold"] = 1] = "threshold";
|
||||
Keys[Keys["keys"] = 2] = "keys";
|
||||
})(Keys || (Keys = {}));
|
||||
class MultiKey extends RegistryItem_1.RegistryItem {
|
||||
constructor(threshold, ecKeys, hdKeys) {
|
||||
super();
|
||||
this.threshold = threshold;
|
||||
this.ecKeys = ecKeys;
|
||||
this.hdKeys = hdKeys;
|
||||
this.getThreshold = () => this.threshold;
|
||||
this.getEcKeys = () => this.ecKeys;
|
||||
this.getHdKeys = () => this.hdKeys;
|
||||
this.toDataItem = () => {
|
||||
const map = {};
|
||||
map[Keys.threshold] = this.threshold;
|
||||
const keys = [...this.ecKeys, ...this.hdKeys].map((k) => {
|
||||
const dataItem = k.toDataItem();
|
||||
dataItem.setTag(k.getRegistryType().getTag());
|
||||
return dataItem;
|
||||
});
|
||||
map[Keys.keys] = keys;
|
||||
return new DataItem_1.DataItem(map);
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.MultiKey = MultiKey;
|
||||
MultiKey.fromDataItem = (dataItem) => {
|
||||
const map = dataItem.getData();
|
||||
const threshold = map[Keys.threshold];
|
||||
const keys = map[Keys.keys];
|
||||
const ecKeys = [];
|
||||
const hdKeys = [];
|
||||
keys.forEach((k) => {
|
||||
if (k.getTag() === RegistryType_1.RegistryTypes.CRYPTO_HDKEY.getTag()) {
|
||||
hdKeys.push(CryptoHDKey_1.CryptoHDKey.fromDataItem(k));
|
||||
}
|
||||
else if (k.getTag() === RegistryType_1.RegistryTypes.CRYPTO_ECKEY.getTag()) {
|
||||
ecKeys.push(CryptoECKey_1.CryptoECKey.fromDataItem(k));
|
||||
}
|
||||
});
|
||||
return new MultiKey(threshold, ecKeys, hdKeys);
|
||||
};
|
||||
//# sourceMappingURL=MultiKey.js.map
|
||||
1
dist/MultiKey.js.map
vendored
1
dist/MultiKey.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"MultiKey.js","sourceRoot":"","sources":["../src/MultiKey.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,+CAA4C;AAC5C,6CAA0C;AAC1C,iDAA8C;AAC9C,iDAA6D;AAE7D,IAAK,IAGJ;AAHD,WAAK,IAAI;IACP,yCAAa,CAAA;IACb,+BAAI,CAAA;AACN,CAAC,EAHI,IAAI,KAAJ,IAAI,QAGR;AAED,MAAa,QAAS,SAAQ,2BAAY;IAGxC,YACU,SAAiB,EACjB,MAAqB,EACrB,MAAqB;QAE7B,KAAK,EAAE,CAAC;QAJA,cAAS,GAAT,SAAS,CAAQ;QACjB,WAAM,GAAN,MAAM,CAAe;QACrB,WAAM,GAAN,MAAM,CAAe;QAK/B,iBAAY,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;QACpC,cAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAuB,CAAC;QAC/C,cAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAuB,CAAC;QAE/C,eAAU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AC7D,MAAM,CAAC,IAAI,CAAC,yBAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1C;IACH,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
||||
24
dist/PathComponent.js
vendored
24
dist/PathComponent.js
vendored
@ -1,24 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PathComponent = void 0;
|
||||
class PathComponent {
|
||||
constructor(args) {
|
||||
this.getIndex = () => this.index;
|
||||
this.isWildcard = () => this.wildcard;
|
||||
this.isHardened = () => this.hardened;
|
||||
this.index = args.index;
|
||||
this.hardened = args.hardened;
|
||||
if (this.index !== undefined) {
|
||||
this.wildcard = false;
|
||||
}
|
||||
else {
|
||||
this.wildcard = true;
|
||||
}
|
||||
if (this.index && (this.index & PathComponent.HARDENED_BIT) !== 0) {
|
||||
throw new Error(`#[ur-registry][PathComponent][fn.constructor]: Invalid index ${this.index} - most significant bit cannot be set`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.PathComponent = PathComponent;
|
||||
PathComponent.HARDENED_BIT = 0x80000000;
|
||||
//# sourceMappingURL=PathComponent.js.map
|
||||
1
dist/PathComponent.js.map
vendored
1
dist/PathComponent.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"PathComponent.js","sourceRoot":"","sources":["../src/PathComponent.ts"],"names":[],"mappings":";;;AAAA,MAAa,aAAa;IAOxB,YAAY,IAA2C;QAiBhD,aAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5B,eAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;QACjC,eAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;QAlBtC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAE9B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACvB;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACtB;QAED,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YACjE,MAAM,IAAI,KAAK,CACb,gEAAgE,IAAI,CAAC,KAAK,uCAAuC,CAClH,CAAC;SACH;IACH,CAAC;;AAtBH,sCA2BC;AA1BwB,0BAAY,GAAG,UAAU,CAAC"}
|
||||
25
dist/RegistryItem.js
vendored
25
dist/RegistryItem.js
vendored
@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RegistryItem = void 0;
|
||||
const bc_ur_1 = require("@ngraveio/bc-ur");
|
||||
const lib_1 = require("./lib");
|
||||
class RegistryItem {
|
||||
constructor() {
|
||||
this.toCBOR = () => {
|
||||
if (this.toDataItem() === undefined) {
|
||||
throw new Error(`#[ur-registry][RegistryItem][fn.toCBOR]: registry ${this.getRegistryType()}'s method toDataItem returns undefined`);
|
||||
}
|
||||
return (0, lib_1.encodeDataItem)(this.toDataItem());
|
||||
};
|
||||
this.toUR = () => {
|
||||
return new bc_ur_1.UR(this.toCBOR(), this.getRegistryType().getType());
|
||||
};
|
||||
this.toUREncoder = (maxFragmentLength, firstSeqNum, minFragmentLength) => {
|
||||
const ur = this.toUR();
|
||||
const urEncoder = new bc_ur_1.UREncoder(ur, maxFragmentLength, firstSeqNum, minFragmentLength);
|
||||
return urEncoder;
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.RegistryItem = RegistryItem;
|
||||
//# sourceMappingURL=RegistryItem.js.map
|
||||
1
dist/RegistryItem.js.map
vendored
1
dist/RegistryItem.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"RegistryItem.js","sourceRoot":"","sources":["../src/RegistryItem.ts"],"names":[],"mappings":";;;AAAA,2CAAgD;AAChD,+BAAiD;AAGjD,MAAsB,YAAY;IAAlC;QAGS,WAAM,GAAG,GAAG,EAAE;YACnB,IAAI,IAAI,CAAC,UAAU,EAAE,KAAK,SAAS,EAAE;gBACnC,MAAM,IAAI,KAAK,CACb,qDAAqD,IAAI,CAAC,eAAe,EAAE,wCAAwC,CACpH,CAAC;aACH;YACD,OAAO,IAAA,oBAAc,EAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAC3C,CAAC,CAAC;QAEK,SAAI,GAAG,GAAG,EAAE;YACjB,OAAO,IAAI,UAAE,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACjE,CAAC,CAAC;QAEK,gBAAW,GAAG,CACnB,iBAA0B,EAC1B,WAAoB,EACpB,iBAA0B,EAC1B,EAAE;YACF,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACvB,MAAM,SAAS,GAAG,IAAI,iBAAS,CAC7B,EAAE,EACF,iBAAiB,EACjB,WAAW,EACX,iBAAiB,CAClB,CAAC;YACF,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC;CAAA;AA9BD,oCA8BC"}
|
||||
24
dist/RegistryType.js
vendored
24
dist/RegistryType.js
vendored
@ -1,24 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RegistryTypes = exports.RegistryType = void 0;
|
||||
class RegistryType {
|
||||
constructor(type, tag) {
|
||||
this.type = type;
|
||||
this.tag = tag;
|
||||
this.getTag = () => this.tag;
|
||||
this.getType = () => this.type;
|
||||
}
|
||||
}
|
||||
exports.RegistryType = RegistryType;
|
||||
exports.RegistryTypes = {
|
||||
UUID: new RegistryType('uuid', 37),
|
||||
BYTES: new RegistryType('bytes', undefined),
|
||||
CRYPTO_HDKEY: new RegistryType('crypto-hdkey', 303),
|
||||
CRYPTO_KEYPATH: new RegistryType('crypto-keypath', 304),
|
||||
CRYPTO_COIN_INFO: new RegistryType('crypto-coin-info', 305),
|
||||
CRYPTO_ECKEY: new RegistryType('crypto-eckey', 306),
|
||||
CRYPTO_OUTPUT: new RegistryType('crypto-output', 308),
|
||||
CRYPTO_PSBT: new RegistryType('crypto-psbt', 310),
|
||||
CRYPTO_ACCOUNT: new RegistryType('crypto-account', 311),
|
||||
};
|
||||
//# sourceMappingURL=RegistryType.js.map
|
||||
1
dist/RegistryType.js.map
vendored
1
dist/RegistryType.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"RegistryType.js","sourceRoot":"","sources":["../src/RegistryType.ts"],"names":[],"mappings":";;;AAGA,MAAa,YAAY;IACvB,YAAoB,IAAY,EAAU,GAAY;QAAlC,SAAI,GAAJ,IAAI,CAAQ;QAAU,QAAG,GAAH,GAAG,CAAS;QACtD,WAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;QACxB,YAAO,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;IAF+B,CAAC;CAG3D;AAJD,oCAIC;AAEY,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;IAClC,KAAK,EAAE,IAAI,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC;IAC3C,YAAY,EAAE,IAAI,YAAY,CAAC,cAAc,EAAE,GAAG,CAAC;IACnD,cAAc,EAAE,IAAI,YAAY,CAAC,gBAAgB,EAAE,GAAG,CAAC;IACvD,gBAAgB,EAAE,IAAI,YAAY,CAAC,kBAAkB,EAAE,GAAG,CAAC;IAC3D,YAAY,EAAE,IAAI,YAAY,CAAC,cAAc,EAAE,GAAG,CAAC;IACnD,aAAa,EAAE,IAAI,YAAY,CAAC,eAAe,EAAE,GAAG,CAAC;IACrD,WAAW,EAAE,IAAI,YAAY,CAAC,aAAa,EAAE,GAAG,CAAC;IACjD,cAAc,EAAE,IAAI,YAAY,CAAC,gBAAgB,EAAE,GAAG,CAAC;CACxD,CAAC"}
|
||||
29
dist/ScriptExpression.js
vendored
29
dist/ScriptExpression.js
vendored
@ -1,29 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ScriptExpressions = exports.ScriptExpression = void 0;
|
||||
class ScriptExpression {
|
||||
constructor(tag, expression) {
|
||||
this.tag = tag;
|
||||
this.expression = expression;
|
||||
this.getTag = () => this.tag;
|
||||
this.getExpression = () => this.expression;
|
||||
}
|
||||
}
|
||||
exports.ScriptExpression = ScriptExpression;
|
||||
ScriptExpression.fromTag = (tag) => {
|
||||
const se = Object.values(exports.ScriptExpressions).find((se) => se.getTag() === tag);
|
||||
return se;
|
||||
};
|
||||
exports.ScriptExpressions = {
|
||||
SCRIPT_HASH: new ScriptExpression(400, 'sh'),
|
||||
WITNESS_SCRIPT_HASH: new ScriptExpression(401, 'wsh'),
|
||||
PUBLIC_KEY: new ScriptExpression(402, 'pk'),
|
||||
PUBLIC_KEY_HASH: new ScriptExpression(403, 'pkh'),
|
||||
WITNESS_PUBLIC_KEY_HASH: new ScriptExpression(404, 'wpkh'),
|
||||
COMBO: new ScriptExpression(405, 'combo'),
|
||||
MULTISIG: new ScriptExpression(406, 'multi'),
|
||||
SORTED_MULTISIG: new ScriptExpression(407, 'sorted'),
|
||||
ADDRESS: new ScriptExpression(307, 'addr'),
|
||||
RAW_SCRIPT: new ScriptExpression(408, 'raw'),
|
||||
};
|
||||
//# sourceMappingURL=ScriptExpression.js.map
|
||||
1
dist/ScriptExpression.js.map
vendored
1
dist/ScriptExpression.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"ScriptExpression.js","sourceRoot":"","sources":["../src/ScriptExpression.ts"],"names":[],"mappings":";;;AAAA,MAAa,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0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.extend = exports.PathComponent = exports.ScriptExpressions = exports.MultiKey = exports.CryptoPSBT = exports.CryptoOutput = exports.CryptoECKey = exports.CryptoCoinInfoNetwork = exports.CryptoCoinInfoType = exports.CryptoCoinInfo = exports.CryptoKeypath = exports.CryptoHDKey = exports.CryptoAccount = exports.Bytes = exports.URRegistryDecoder = exports.DataItem = void 0;
|
||||
require("./patchCBOR");
|
||||
const CryptoHDKey_1 = require("./CryptoHDKey");
|
||||
Object.defineProperty(exports, "CryptoHDKey", { enumerable: true, get: function () { return CryptoHDKey_1.CryptoHDKey; } });
|
||||
const CryptoKeypath_1 = require("./CryptoKeypath");
|
||||
Object.defineProperty(exports, "CryptoKeypath", { enumerable: true, get: function () { return CryptoKeypath_1.CryptoKeypath; } });
|
||||
const CryptoCoinInfo_1 = require("./CryptoCoinInfo");
|
||||
Object.defineProperty(exports, "CryptoCoinInfo", { enumerable: true, get: function () { return CryptoCoinInfo_1.CryptoCoinInfo; } });
|
||||
Object.defineProperty(exports, "CryptoCoinInfoType", { enumerable: true, get: function () { return CryptoCoinInfo_1.Type; } });
|
||||
Object.defineProperty(exports, "CryptoCoinInfoNetwork", { enumerable: true, get: function () { return CryptoCoinInfo_1.Network; } });
|
||||
const CryptoECKey_1 = require("./CryptoECKey");
|
||||
Object.defineProperty(exports, "CryptoECKey", { enumerable: true, get: function () { return CryptoECKey_1.CryptoECKey; } });
|
||||
const Bytes_1 = require("./Bytes");
|
||||
Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return Bytes_1.Bytes; } });
|
||||
const CryptoOutput_1 = require("./CryptoOutput");
|
||||
Object.defineProperty(exports, "CryptoOutput", { enumerable: true, get: function () { return CryptoOutput_1.CryptoOutput; } });
|
||||
const CryptoPSBT_1 = require("./CryptoPSBT");
|
||||
Object.defineProperty(exports, "CryptoPSBT", { enumerable: true, get: function () { return CryptoPSBT_1.CryptoPSBT; } });
|
||||
const CryptoAccount_1 = require("./CryptoAccount");
|
||||
Object.defineProperty(exports, "CryptoAccount", { enumerable: true, get: function () { return CryptoAccount_1.CryptoAccount; } });
|
||||
const Decoder_1 = require("./Decoder");
|
||||
Object.defineProperty(exports, "URRegistryDecoder", { enumerable: true, get: function () { return Decoder_1.URRegistryDecoder; } });
|
||||
const MultiKey_1 = require("./MultiKey");
|
||||
Object.defineProperty(exports, "MultiKey", { enumerable: true, get: function () { return MultiKey_1.MultiKey; } });
|
||||
const ScriptExpression_1 = require("./ScriptExpression");
|
||||
Object.defineProperty(exports, "ScriptExpressions", { enumerable: true, get: function () { return ScriptExpression_1.ScriptExpressions; } });
|
||||
const PathComponent_1 = require("./PathComponent");
|
||||
Object.defineProperty(exports, "PathComponent", { enumerable: true, get: function () { return PathComponent_1.PathComponent; } });
|
||||
const RegistryItem_1 = require("./RegistryItem");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
const lib_1 = require("./lib");
|
||||
var lib_2 = require("./lib");
|
||||
Object.defineProperty(exports, "DataItem", { enumerable: true, get: function () { return lib_2.DataItem; } });
|
||||
const utils_1 = require("./utils");
|
||||
const URlib = {
|
||||
URRegistryDecoder: Decoder_1.URRegistryDecoder,
|
||||
Bytes: Bytes_1.Bytes,
|
||||
CryptoAccount: CryptoAccount_1.CryptoAccount,
|
||||
CryptoHDKey: CryptoHDKey_1.CryptoHDKey,
|
||||
CryptoKeypath: CryptoKeypath_1.CryptoKeypath,
|
||||
CryptoCoinInfo: CryptoCoinInfo_1.CryptoCoinInfo,
|
||||
CryptoCoinInfoType: CryptoCoinInfo_1.Type,
|
||||
CryptoCoinInfoNetwork: CryptoCoinInfo_1.Network,
|
||||
CryptoECKey: CryptoECKey_1.CryptoECKey,
|
||||
CryptoOutput: CryptoOutput_1.CryptoOutput,
|
||||
CryptoPSBT: CryptoPSBT_1.CryptoPSBT,
|
||||
MultiKey: MultiKey_1.MultiKey,
|
||||
ScriptExpressions: ScriptExpression_1.ScriptExpressions,
|
||||
PathComponent: PathComponent_1.PathComponent,
|
||||
};
|
||||
const cbor = {
|
||||
addReader: lib_1.addReader,
|
||||
addSemanticDecode: lib_1.addSemanticDecode,
|
||||
addSemanticEncode: lib_1.addSemanticEncode,
|
||||
addWriter: lib_1.addWriter,
|
||||
patchTags: utils_1.patchTags,
|
||||
};
|
||||
const extend = {
|
||||
RegistryTypes: RegistryType_1.RegistryTypes,
|
||||
RegistryItem: RegistryItem_1.RegistryItem,
|
||||
RegistryType: RegistryType_1.RegistryType,
|
||||
decodeToDataItem: lib_1.decodeToDataItem,
|
||||
encodeDataItem: lib_1.encodeDataItem,
|
||||
cbor,
|
||||
};
|
||||
exports.extend = extend;
|
||||
exports.default = URlib;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
dist/index.js.map
vendored
1
dist/index.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uBAAqB;AAErB,+CAA4C;AA2E1C,4FA3EO,yBAAW,OA2EP;AA1Eb,mDAAgD;AA2E9C,8FA3EO,6BAAa,OA2EP;AA1Ef,qDAI0B;AAuExB,+FA1EA,+BAAc,OA0EA;AACd,mGA1EQ,qBAAkB,OA0ER;AAClB,sGA1EW,wBAAqB,OA0EX;AAxEvB,+CAA4C;AAyE1C,4FAzEO,yBAAW,OAyEP;AAxEb,mCAAgC;AAiE9B,sFAjEO,aAAK,OAiEP;AAhEP,iDAA8C;AAwE5C,6FAxEO,2BAAY,OAwEP;AAvEd,6CAA0C;AAwExC,2FAxEO,uBAAU,OAwEP;AAvEZ,mDAAgD;AA+D9C,8FA/DO,6BAAa,OA+DP;AA9Df,uCAA8C;AA4D5C,kGA5DO,2BAAiB,OA4DP;AA1DnB,yCAAsC;AAqEpC,yFArEO,mBAAQ,OAqEP;AAnEV,yDAAuD;AAoErD,kGApEO,oCAAiB,OAoEP;AAnEnB,mDAAgD;AAoE9C,8FApEO,6BAAa,OAoEP;AAlEf,iDAA8C;AAC9C,iDAA6D;AAE7D,+BAOe;AAEf,6BAAiC;AAAxB,+FAAA,QAAQ,OAAA;AAEjB,mCAAoC;AAEpC,MAAM,KAAK,GAAG;IACZ,iBAAiB,EAAjB,2BAAiB;IACjB,KAAK,EAAL,aAAK;IACL,aAAa,EAAb,6BAAa;IACb,WAAW,EAAX,yBAAW;IACX,aAAa,EAAb,6BAAa;IACb,cAAc,EAAd,+BAAc;IACd,kBAAkB,EAAlB,qBAAkB;IAClB,qBAAqB,EAArB,wBAAqB;IACrB,WAAW,EAAX,yBAAW;IACX,YAAY,EAAZ,2BAAY;IACZ,UAAU,EAAV,uBAAU;IACV,QAAQ,EAAR,mBAAQ;IACR,iBAAiB,EAAjB,oCAAiB;IACjB,aAAa,EAAb,6BAAa;CACd,CAAC;AAEF,MAAM,IAAI,GAAG;IACX,SAAS,EAAT,eAAS;IACT,iBAAiB,EAAjB,uBAAiB;IACjB,iBAAiB,EAAjB,uBAAiB;IACjB,SAAS,EAAT,eAAS;IACT,SAAS,EAAT,iBAAS;CACV,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,aAAa,EAAb,4BAAa;IACb,YAAY,EAAZ,2BAAY;IACZ,YAAY,EAAZ,2BAAY;IAEZ,gBAAgB,EAAhB,sBAAgB;IAChB,cAAc,EAAd,oBAAc;IAEd,IAAI;CACL,CAAC;AAiBA,wBAAM;AAGR,kBAAe,KAAK,CAAC"}
|
||||
23
dist/lib/DataItem.js
vendored
23
dist/lib/DataItem.js
vendored
@ -1,23 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DataItem = void 0;
|
||||
class DataItem {
|
||||
constructor(data, tag) {
|
||||
this.setTag = (tag) => {
|
||||
this.tag = tag;
|
||||
};
|
||||
this.clearTag = () => {
|
||||
this.tag = undefined;
|
||||
};
|
||||
this.getTag = () => {
|
||||
return this.tag;
|
||||
};
|
||||
this.getData = () => {
|
||||
return this.data;
|
||||
};
|
||||
this.data = data;
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
exports.DataItem = DataItem;
|
||||
//# sourceMappingURL=DataItem.js.map
|
||||
1
dist/lib/DataItem.js.map
vendored
1
dist/lib/DataItem.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"DataItem.js","sourceRoot":"","sources":["../../src/lib/DataItem.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAQ;IAInB,YAAY,IAAS,EAAE,GAAY;QAK5B,WAAM,GAAG,CAAC,GAAY,EAAE,EAAE;YAC/B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACjB,CAAC,CAAC;QAEK,aAAQ,GAAG,GAAG,EAAE;YACrB,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACvB,CAAC,CAAC;QAEK,WAAM,GAAG,GAAG,EAAE;YACnB,OAAO,IAAI,CAAC,GAAG,CAAC;QAClB,CAAC,CAAC;QAEK,YAAO,GAAG,GAAG,EAAE;YACpB,OAAO,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC,CAAC;QAlBA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;CAiBF;AAxBD,4BAwBC"}
|
||||
699
dist/lib/cbor-sync.js
vendored
699
dist/lib/cbor-sync.js
vendored
@ -1,699 +0,0 @@
|
||||
"use strict";
|
||||
(function (global, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([], factory);
|
||||
}
|
||||
else if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = factory();
|
||||
}
|
||||
else {
|
||||
global.CBOR = factory();
|
||||
}
|
||||
})(this, function () {
|
||||
const { DataItem } = require('./DataItem');
|
||||
var CBOR = (function () {
|
||||
function BinaryHex(hex) {
|
||||
this.$hex = hex;
|
||||
}
|
||||
BinaryHex.prototype = {
|
||||
length: function () {
|
||||
return this.$hex.length / 2;
|
||||
},
|
||||
toString: function (format) {
|
||||
if (!format || format === 'hex' || format === 16)
|
||||
return this.$hex;
|
||||
if (format === 'utf-8') {
|
||||
var encoded = '';
|
||||
for (var i = 0; i < this.$hex.length; i += 2) {
|
||||
encoded += '%' + this.$hex.substring(i, i + 2);
|
||||
}
|
||||
return decodeURIComponent(encoded);
|
||||
}
|
||||
if (format === 'latin') {
|
||||
var encoded = [];
|
||||
for (var i = 0; i < this.$hex.length; i += 2) {
|
||||
encoded.push(parseInt(this.$hex.substring(i, i + 2), 16));
|
||||
}
|
||||
return String.fromCharCode.apply(String, encoded);
|
||||
}
|
||||
throw new Error('Unrecognised format: ' + format);
|
||||
},
|
||||
};
|
||||
BinaryHex.fromLatinString = function (latinString) {
|
||||
var hex = '';
|
||||
for (var i = 0; i < latinString.length; i++) {
|
||||
var pair = latinString.charCodeAt(i).toString(16);
|
||||
if (pair.length === 1)
|
||||
pair = '0' + pair;
|
||||
hex += pair;
|
||||
}
|
||||
return new BinaryHex(hex);
|
||||
};
|
||||
BinaryHex.fromUtf8String = function (utf8String) {
|
||||
var encoded = encodeURIComponent(utf8String);
|
||||
var hex = '';
|
||||
for (var i = 0; i < encoded.length; i++) {
|
||||
if (encoded.charAt(i) === '%') {
|
||||
hex += encoded.substring(i + 1, i + 3);
|
||||
i += 2;
|
||||
}
|
||||
else {
|
||||
var hexPair = encoded.charCodeAt(i).toString(16);
|
||||
if (hexPair.length < 2)
|
||||
hexPair = '0' + hexPair;
|
||||
hex += hexPair;
|
||||
}
|
||||
}
|
||||
return new BinaryHex(hex);
|
||||
};
|
||||
var semanticEncoders = [];
|
||||
var semanticDecoders = {};
|
||||
var notImplemented = function (label) {
|
||||
return function () {
|
||||
throw new Error(label + ' not implemented');
|
||||
};
|
||||
};
|
||||
function Reader() { }
|
||||
Reader.prototype = {
|
||||
peekByte: notImplemented('peekByte'),
|
||||
readByte: notImplemented('readByte'),
|
||||
readChunk: notImplemented('readChunk'),
|
||||
readFloat16: function () {
|
||||
var half = this.readUint16();
|
||||
var exponent = (half & 0x7fff) >> 10;
|
||||
var mantissa = half & 0x3ff;
|
||||
var negative = half & 0x8000;
|
||||
if (exponent === 0x1f) {
|
||||
if (mantissa === 0) {
|
||||
return negative ? -Infinity : Infinity;
|
||||
}
|
||||
return NaN;
|
||||
}
|
||||
var magnitude = exponent
|
||||
? Math.pow(2, exponent - 25) * (1024 + mantissa)
|
||||
: Math.pow(2, -24) * mantissa;
|
||||
return negative ? -magnitude : magnitude;
|
||||
},
|
||||
readFloat32: function () {
|
||||
var intValue = this.readUint32();
|
||||
var exponent = (intValue & 0x7fffffff) >> 23;
|
||||
var mantissa = intValue & 0x7fffff;
|
||||
var negative = intValue & 0x80000000;
|
||||
if (exponent === 0xff) {
|
||||
if (mantissa === 0) {
|
||||
return negative ? -Infinity : Infinity;
|
||||
}
|
||||
return NaN;
|
||||
}
|
||||
var magnitude = exponent
|
||||
? Math.pow(2, exponent - 23 - 127) * (8388608 + mantissa)
|
||||
: Math.pow(2, -23 - 126) * mantissa;
|
||||
return negative ? -magnitude : magnitude;
|
||||
},
|
||||
readFloat64: function () {
|
||||
var int1 = this.readUint32(), int2 = this.readUint32();
|
||||
var exponent = (int1 >> 20) & 0x7ff;
|
||||
var mantissa = (int1 & 0xfffff) * 4294967296 + int2;
|
||||
var negative = int1 & 0x80000000;
|
||||
if (exponent === 0x7ff) {
|
||||
if (mantissa === 0) {
|
||||
return negative ? -Infinity : Infinity;
|
||||
}
|
||||
return NaN;
|
||||
}
|
||||
var magnitude = exponent
|
||||
? Math.pow(2, exponent - 52 - 1023) * (4503599627370496 + mantissa)
|
||||
: Math.pow(2, -52 - 1022) * mantissa;
|
||||
return negative ? -magnitude : magnitude;
|
||||
},
|
||||
readUint16: function () {
|
||||
return this.readByte() * 256 + this.readByte();
|
||||
},
|
||||
readUint32: function () {
|
||||
return this.readUint16() * 65536 + this.readUint16();
|
||||
},
|
||||
readUint64: function () {
|
||||
return this.readUint32() * 4294967296 + this.readUint32();
|
||||
},
|
||||
};
|
||||
function Writer() { }
|
||||
Writer.prototype = {
|
||||
writeByte: notImplemented('writeByte'),
|
||||
result: notImplemented('result'),
|
||||
writeFloat16: notImplemented('writeFloat16'),
|
||||
writeFloat32: notImplemented('writeFloat32'),
|
||||
writeFloat64: notImplemented('writeFloat64'),
|
||||
writeUint16: function (value) {
|
||||
this.writeByte((value >> 8) & 0xff);
|
||||
this.writeByte(value & 0xff);
|
||||
},
|
||||
writeUint32: function (value) {
|
||||
this.writeUint16((value >> 16) & 0xffff);
|
||||
this.writeUint16(value & 0xffff);
|
||||
},
|
||||
writeUint64: function (value) {
|
||||
if (value >= 9007199254740992 || value <= -9007199254740992) {
|
||||
throw new Error('Cannot encode Uint64 of: ' +
|
||||
value +
|
||||
' magnitude to big (floating point errors)');
|
||||
}
|
||||
this.writeUint32(Math.floor(value / 4294967296));
|
||||
this.writeUint32(value % 4294967296);
|
||||
},
|
||||
writeString: notImplemented('writeString'),
|
||||
canWriteBinary: function (chunk) {
|
||||
return false;
|
||||
},
|
||||
writeBinary: notImplemented('writeChunk'),
|
||||
};
|
||||
function readHeaderRaw(reader) {
|
||||
var firstByte = reader.readByte();
|
||||
var majorType = firstByte >> 5, value = firstByte & 0x1f;
|
||||
return { type: majorType, value: value };
|
||||
}
|
||||
function valueFromHeader(header, reader) {
|
||||
var value = header.value;
|
||||
if (value < 24) {
|
||||
return value;
|
||||
}
|
||||
else if (value == 24) {
|
||||
return reader.readByte();
|
||||
}
|
||||
else if (value == 25) {
|
||||
return reader.readUint16();
|
||||
}
|
||||
else if (value == 26) {
|
||||
return reader.readUint32();
|
||||
}
|
||||
else if (value == 27) {
|
||||
return reader.readUint64();
|
||||
}
|
||||
else if (value == 31) {
|
||||
return null;
|
||||
}
|
||||
notImplemented('Additional info: ' + value)();
|
||||
}
|
||||
function writeHeaderRaw(type, value, writer) {
|
||||
writer.writeByte((type << 5) | value);
|
||||
}
|
||||
function writeHeader(type, value, writer) {
|
||||
var firstByte = type << 5;
|
||||
if (value < 24) {
|
||||
writer.writeByte(firstByte | value);
|
||||
}
|
||||
else if (value < 256) {
|
||||
writer.writeByte(firstByte | 24);
|
||||
writer.writeByte(value);
|
||||
}
|
||||
else if (value < 65536) {
|
||||
writer.writeByte(firstByte | 25);
|
||||
writer.writeUint16(value);
|
||||
}
|
||||
else if (value < 4294967296) {
|
||||
writer.writeByte(firstByte | 26);
|
||||
writer.writeUint32(value);
|
||||
}
|
||||
else {
|
||||
writer.writeByte(firstByte | 27);
|
||||
writer.writeUint64(value);
|
||||
}
|
||||
}
|
||||
var stopCode = new Error();
|
||||
function decodeReader(reader) {
|
||||
var header = readHeaderRaw(reader);
|
||||
switch (header.type) {
|
||||
case 0:
|
||||
return valueFromHeader(header, reader);
|
||||
case 1:
|
||||
return -1 - valueFromHeader(header, reader);
|
||||
case 2:
|
||||
return reader.readChunk(valueFromHeader(header, reader));
|
||||
case 3:
|
||||
var buffer = reader.readChunk(valueFromHeader(header, reader));
|
||||
return buffer.toString('utf-8');
|
||||
case 4:
|
||||
case 5:
|
||||
var arrayLength = valueFromHeader(header, reader);
|
||||
var result = [];
|
||||
if (arrayLength !== null) {
|
||||
if (header.type === 5) {
|
||||
arrayLength *= 2;
|
||||
}
|
||||
for (var i = 0; i < arrayLength; i++) {
|
||||
result[i] = decodeReader(reader);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var item;
|
||||
while ((item = decodeReader(reader)) !== stopCode) {
|
||||
result.push(item);
|
||||
}
|
||||
}
|
||||
if (header.type === 5) {
|
||||
var objResult = {};
|
||||
for (var i = 0; i < result.length; i += 2) {
|
||||
objResult[result[i]] = result[i + 1];
|
||||
}
|
||||
return objResult;
|
||||
}
|
||||
else {
|
||||
return result;
|
||||
}
|
||||
case 6:
|
||||
var tag = valueFromHeader(header, reader);
|
||||
var decoder = semanticDecoders[tag];
|
||||
var result = decodeReader(reader);
|
||||
return decoder ? decoder(result) : result;
|
||||
case 7:
|
||||
if (header.value === 25) {
|
||||
return reader.readFloat16();
|
||||
}
|
||||
else if (header.value === 26) {
|
||||
return reader.readFloat32();
|
||||
}
|
||||
else if (header.value === 27) {
|
||||
return reader.readFloat64();
|
||||
}
|
||||
switch (valueFromHeader(header, reader)) {
|
||||
case 20:
|
||||
return false;
|
||||
case 21:
|
||||
return true;
|
||||
case 22:
|
||||
return null;
|
||||
case 23:
|
||||
return undefined;
|
||||
case null:
|
||||
return stopCode;
|
||||
default:
|
||||
throw new Error('Unknown fixed value: ' + header.value);
|
||||
}
|
||||
default:
|
||||
throw new Error('Unsupported header: ' + JSON.stringify(header));
|
||||
}
|
||||
throw new Error('not implemented yet');
|
||||
}
|
||||
function encodeWriter(data, writer) {
|
||||
for (var i = 0; i < semanticEncoders.length; i++) {
|
||||
var replacement = semanticEncoders[i].fn(data);
|
||||
if (replacement !== undefined) {
|
||||
writeHeader(6, semanticEncoders[i].tag, writer);
|
||||
return encodeWriter(replacement, writer);
|
||||
}
|
||||
}
|
||||
if (data && typeof data.toCBOR === 'function') {
|
||||
data = data.toCBOR();
|
||||
}
|
||||
if (data === false) {
|
||||
writeHeader(7, 20, writer);
|
||||
}
|
||||
else if (data === true) {
|
||||
writeHeader(7, 21, writer);
|
||||
}
|
||||
else if (data === null) {
|
||||
writeHeader(7, 22, writer);
|
||||
}
|
||||
else if (data === undefined) {
|
||||
writeHeader(7, 23, writer);
|
||||
}
|
||||
else if (typeof data === 'number') {
|
||||
if (Math.floor(data) === data &&
|
||||
data < 9007199254740992 &&
|
||||
data > -9007199254740992) {
|
||||
if (data < 0) {
|
||||
writeHeader(1, -1 - data, writer);
|
||||
}
|
||||
else {
|
||||
writeHeader(0, data, writer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
writeHeaderRaw(7, 27, writer);
|
||||
writer.writeFloat64(data);
|
||||
}
|
||||
}
|
||||
else if (typeof data === 'string') {
|
||||
writer.writeString(data, function (length) {
|
||||
writeHeader(3, length, writer);
|
||||
});
|
||||
}
|
||||
else if (writer.canWriteBinary(data)) {
|
||||
writer.writeBinary(data, function (length) {
|
||||
writeHeader(2, length, writer);
|
||||
});
|
||||
}
|
||||
else if (typeof data === 'object') {
|
||||
if (api.config.useToJSON && typeof data.toJSON === 'function') {
|
||||
data = data.toJSON();
|
||||
}
|
||||
if (Array.isArray(data)) {
|
||||
writeHeader(4, data.length, writer);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
encodeWriter(data[i], writer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var keys = Object.keys(data);
|
||||
writeHeader(5, keys.length, writer);
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
const number = parseInt(keys[i]);
|
||||
if (isNaN(number)) {
|
||||
encodeWriter(keys[i], writer);
|
||||
encodeWriter(data[keys[i]], writer);
|
||||
}
|
||||
else {
|
||||
encodeWriter(number, writer);
|
||||
encodeWriter(data[keys[i]], writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error('CBOR encoding not supported: ' + data);
|
||||
}
|
||||
}
|
||||
var readerFunctions = [];
|
||||
var writerFunctions = [];
|
||||
var api = {
|
||||
config: {
|
||||
useToJSON: true,
|
||||
},
|
||||
addWriter: function (format, writerFunction) {
|
||||
if (typeof format === 'string') {
|
||||
writerFunctions.push(function (f) {
|
||||
if (format === f)
|
||||
return writerFunction(f);
|
||||
});
|
||||
}
|
||||
else {
|
||||
writerFunctions.push(format);
|
||||
}
|
||||
},
|
||||
addReader: function (format, readerFunction) {
|
||||
if (typeof format === 'string') {
|
||||
readerFunctions.push(function (data, f) {
|
||||
if (format === f)
|
||||
return readerFunction(data, f);
|
||||
});
|
||||
}
|
||||
else {
|
||||
readerFunctions.push(format);
|
||||
}
|
||||
},
|
||||
encode: function (data, format) {
|
||||
for (var i = 0; i < writerFunctions.length; i++) {
|
||||
var func = writerFunctions[i];
|
||||
var writer = func(format);
|
||||
if (writer) {
|
||||
encodeWriter(data, writer);
|
||||
return writer.result();
|
||||
}
|
||||
}
|
||||
throw new Error('Unsupported output format: ' + format);
|
||||
},
|
||||
encodeDataItem: function (data, format) {
|
||||
for (var i = 0; i < writerFunctions.length; i++) {
|
||||
var func = writerFunctions[i];
|
||||
var writer = func(format);
|
||||
if (writer) {
|
||||
if (data.getTag() !== undefined) {
|
||||
encodeWriter(data, writer);
|
||||
return writer.result();
|
||||
}
|
||||
else {
|
||||
encodeWriter(data.getData(), writer);
|
||||
return writer.result();
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error('Unsupported output format: ' + format);
|
||||
},
|
||||
decode: function (data, format) {
|
||||
for (var i = 0; i < readerFunctions.length; i++) {
|
||||
var func = readerFunctions[i];
|
||||
var reader = func(data, format);
|
||||
if (reader) {
|
||||
return decodeReader(reader);
|
||||
}
|
||||
}
|
||||
throw new Error('Unsupported input format: ' + format);
|
||||
},
|
||||
decodeToDataItem: function (data, format) {
|
||||
for (var i = 0; i < readerFunctions.length; i++) {
|
||||
var func = readerFunctions[i];
|
||||
var reader = func(data, format);
|
||||
if (reader) {
|
||||
const result = decodeReader(reader);
|
||||
if (result instanceof DataItem) {
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return new DataItem(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error('Unsupported input format: ' + format);
|
||||
},
|
||||
addSemanticEncode: function (tag, fn) {
|
||||
if (typeof tag !== 'number' || tag % 1 !== 0 || tag < 0) {
|
||||
throw new Error('Tag must be a positive integer');
|
||||
}
|
||||
semanticEncoders.push({ tag: tag, fn: fn });
|
||||
return this;
|
||||
},
|
||||
addSemanticDecode: function (tag, fn) {
|
||||
if (typeof tag !== 'number' || tag % 1 !== 0 || tag < 0) {
|
||||
throw new Error('Tag must be a positive integer');
|
||||
}
|
||||
semanticDecoders[tag] = fn;
|
||||
return this;
|
||||
},
|
||||
Reader: Reader,
|
||||
Writer: Writer,
|
||||
};
|
||||
function BufferReader(buffer) {
|
||||
this.buffer = buffer;
|
||||
this.pos = 0;
|
||||
}
|
||||
BufferReader.prototype = Object.create(Reader.prototype);
|
||||
BufferReader.prototype.peekByte = function () {
|
||||
return this.buffer[this.pos];
|
||||
};
|
||||
BufferReader.prototype.readByte = function () {
|
||||
return this.buffer[this.pos++];
|
||||
};
|
||||
BufferReader.prototype.readUint16 = function () {
|
||||
var result = this.buffer.readUInt16BE(this.pos);
|
||||
this.pos += 2;
|
||||
return result;
|
||||
};
|
||||
BufferReader.prototype.readUint32 = function () {
|
||||
var result = this.buffer.readUInt32BE(this.pos);
|
||||
this.pos += 4;
|
||||
return result;
|
||||
};
|
||||
BufferReader.prototype.readFloat32 = function () {
|
||||
var result = this.buffer.readFloatBE(this.pos);
|
||||
this.pos += 4;
|
||||
return result;
|
||||
};
|
||||
BufferReader.prototype.readFloat64 = function () {
|
||||
var result = this.buffer.readDoubleBE(this.pos);
|
||||
this.pos += 8;
|
||||
return result;
|
||||
};
|
||||
BufferReader.prototype.readChunk = function (length) {
|
||||
var result = Buffer.alloc(length);
|
||||
this.buffer.copy(result, 0, this.pos, (this.pos += length));
|
||||
return result;
|
||||
};
|
||||
function BufferWriter(stringFormat) {
|
||||
this.byteLength = 0;
|
||||
this.defaultBufferLength = 16384;
|
||||
this.latestBuffer = Buffer.alloc(this.defaultBufferLength);
|
||||
this.latestBufferOffset = 0;
|
||||
this.completeBuffers = [];
|
||||
this.stringFormat = stringFormat;
|
||||
}
|
||||
BufferWriter.prototype = Object.create(Writer.prototype);
|
||||
BufferWriter.prototype.writeByte = function (value) {
|
||||
this.latestBuffer[this.latestBufferOffset++] = value;
|
||||
if (this.latestBufferOffset >= this.latestBuffer.length) {
|
||||
this.completeBuffers.push(this.latestBuffer);
|
||||
this.latestBuffer = Buffer.alloc(this.defaultBufferLength);
|
||||
this.latestBufferOffset = 0;
|
||||
}
|
||||
this.byteLength++;
|
||||
};
|
||||
BufferWriter.prototype.writeFloat32 = function (value) {
|
||||
var buffer = Buffer.alloc(4);
|
||||
buffer.writeFloatBE(value, 0);
|
||||
this.writeBuffer(buffer);
|
||||
};
|
||||
BufferWriter.prototype.writeFloat64 = function (value) {
|
||||
var buffer = Buffer.alloc(8);
|
||||
buffer.writeDoubleBE(value, 0);
|
||||
this.writeBuffer(buffer);
|
||||
};
|
||||
BufferWriter.prototype.writeString = function (string, lengthFunc) {
|
||||
var buffer = Buffer.from(string, 'utf-8');
|
||||
lengthFunc(buffer.length);
|
||||
this.writeBuffer(buffer);
|
||||
};
|
||||
BufferWriter.prototype.canWriteBinary = function (data) {
|
||||
return data instanceof Buffer;
|
||||
};
|
||||
BufferWriter.prototype.writeBinary = function (buffer, lengthFunc) {
|
||||
lengthFunc(buffer.length);
|
||||
this.writeBuffer(buffer);
|
||||
};
|
||||
BufferWriter.prototype.writeBuffer = function (chunk) {
|
||||
if (!(chunk instanceof Buffer))
|
||||
throw new TypeError('BufferWriter only accepts Buffers');
|
||||
if (!this.latestBufferOffset) {
|
||||
this.completeBuffers.push(chunk);
|
||||
}
|
||||
else if (this.latestBuffer.length - this.latestBufferOffset >=
|
||||
chunk.length) {
|
||||
chunk.copy(this.latestBuffer, this.latestBufferOffset);
|
||||
this.latestBufferOffset += chunk.length;
|
||||
if (this.latestBufferOffset >= this.latestBuffer.length) {
|
||||
this.completeBuffers.push(this.latestBuffer);
|
||||
this.latestBuffer = Buffer.alloc(this.defaultBufferLength);
|
||||
this.latestBufferOffset = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.completeBuffers.push(this.latestBuffer.slice(0, this.latestBufferOffset));
|
||||
this.completeBuffers.push(chunk);
|
||||
this.latestBuffer = Buffer.alloc(this.defaultBufferLength);
|
||||
this.latestBufferOffset = 0;
|
||||
}
|
||||
this.byteLength += chunk.length;
|
||||
};
|
||||
BufferWriter.prototype.result = function () {
|
||||
var result = Buffer.alloc(this.byteLength);
|
||||
var offset = 0;
|
||||
for (var i = 0; i < this.completeBuffers.length; i++) {
|
||||
var buffer = this.completeBuffers[i];
|
||||
buffer.copy(result, offset, 0, buffer.length);
|
||||
offset += buffer.length;
|
||||
}
|
||||
if (this.latestBufferOffset) {
|
||||
this.latestBuffer.copy(result, offset, 0, this.latestBufferOffset);
|
||||
}
|
||||
if (this.stringFormat)
|
||||
return result.toString(this.stringFormat);
|
||||
return result;
|
||||
};
|
||||
if (typeof Buffer === 'function') {
|
||||
api.addReader(function (data, format) {
|
||||
if (data instanceof Buffer) {
|
||||
return new BufferReader(data);
|
||||
}
|
||||
if (format === 'hex' || format === 'base64') {
|
||||
var buffer = Buffer.from(data, format);
|
||||
return new BufferReader(buffer);
|
||||
}
|
||||
});
|
||||
api.addWriter(function (format) {
|
||||
if (!format || format === 'buffer') {
|
||||
return new BufferWriter();
|
||||
}
|
||||
else if (format === 'hex' || format === 'base64') {
|
||||
return new BufferWriter(format);
|
||||
}
|
||||
});
|
||||
}
|
||||
function HexReader(hex) {
|
||||
this.hex = hex;
|
||||
this.pos = 0;
|
||||
}
|
||||
HexReader.prototype = Object.create(Reader.prototype);
|
||||
HexReader.prototype.peekByte = function () {
|
||||
var pair = this.hex.substring(this.pos, 2);
|
||||
return parseInt(pair, 16);
|
||||
};
|
||||
HexReader.prototype.readByte = function () {
|
||||
var pair = this.hex.substring(this.pos, this.pos + 2);
|
||||
this.pos += 2;
|
||||
return parseInt(pair, 16);
|
||||
};
|
||||
HexReader.prototype.readChunk = function (length) {
|
||||
var hex = this.hex.substring(this.pos, this.pos + length * 2);
|
||||
this.pos += length * 2;
|
||||
if (typeof Buffer === 'function')
|
||||
return Buffer.from(hex, 'hex');
|
||||
return new BinaryHex(hex);
|
||||
};
|
||||
function HexWriter(finalFormat) {
|
||||
this.$hex = '';
|
||||
this.finalFormat = finalFormat || 'hex';
|
||||
}
|
||||
HexWriter.prototype = Object.create(Writer.prototype);
|
||||
HexWriter.prototype.writeByte = function (value) {
|
||||
if (value < 0 || value > 255)
|
||||
throw new Error('Byte value out of range: ' + value);
|
||||
var hex = value.toString(16);
|
||||
if (hex.length == 1) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
this.$hex += hex;
|
||||
};
|
||||
HexWriter.prototype.canWriteBinary = function (chunk) {
|
||||
return (chunk instanceof BinaryHex ||
|
||||
(typeof Buffer === 'function' && chunk instanceof Buffer));
|
||||
};
|
||||
HexWriter.prototype.writeBinary = function (chunk, lengthFunction) {
|
||||
if (chunk instanceof BinaryHex) {
|
||||
lengthFunction(chunk.length());
|
||||
this.$hex += chunk.$hex;
|
||||
}
|
||||
else if (typeof Buffer === 'function' && chunk instanceof Buffer) {
|
||||
lengthFunction(chunk.length);
|
||||
this.$hex += chunk.toString('hex');
|
||||
}
|
||||
else {
|
||||
throw new TypeError('HexWriter only accepts BinaryHex or Buffers');
|
||||
}
|
||||
};
|
||||
HexWriter.prototype.result = function () {
|
||||
if (this.finalFormat === 'buffer' && typeof Buffer === 'function') {
|
||||
return Buffer.from(this.$hex, 'hex');
|
||||
}
|
||||
return new BinaryHex(this.$hex).toString(this.finalFormat);
|
||||
};
|
||||
HexWriter.prototype.writeString = function (string, lengthFunction) {
|
||||
var buffer = BinaryHex.fromUtf8String(string);
|
||||
lengthFunction(buffer.length());
|
||||
this.$hex += buffer.$hex;
|
||||
};
|
||||
api.addReader(function (data, format) {
|
||||
if (data instanceof BinaryHex || data.$hex) {
|
||||
return new HexReader(data.$hex);
|
||||
}
|
||||
if (format === 'hex') {
|
||||
return new HexReader(data);
|
||||
}
|
||||
});
|
||||
api.addWriter(function (format) {
|
||||
if (format === 'hex') {
|
||||
return new HexWriter();
|
||||
}
|
||||
});
|
||||
return api;
|
||||
})();
|
||||
CBOR.addSemanticEncode(0, function (data) {
|
||||
if (data instanceof Date) {
|
||||
return data.toISOString();
|
||||
}
|
||||
})
|
||||
.addSemanticDecode(0, function (isoString) {
|
||||
return new Date(isoString);
|
||||
})
|
||||
.addSemanticDecode(1, function (isoString) {
|
||||
return new Date(isoString);
|
||||
});
|
||||
return CBOR;
|
||||
});
|
||||
//# sourceMappingURL=cbor-sync.js.map
|
||||
1
dist/lib/cbor-sync.js.map
vendored
1
dist/lib/cbor-sync.js.map
vendored
File diff suppressed because one or more lines are too long
11
dist/patchCBOR.js
vendored
11
dist/patchCBOR.js
vendored
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("./utils");
|
||||
const RegistryType_1 = require("./RegistryType");
|
||||
const ScriptExpression_1 = require("./ScriptExpression");
|
||||
const registryTags = Object.values(RegistryType_1.RegistryTypes)
|
||||
.filter((r) => !!r.getTag())
|
||||
.map((r) => r.getTag());
|
||||
const scriptExpressionTags = Object.values(ScriptExpression_1.ScriptExpressions).map((se) => se.getTag());
|
||||
(0, utils_1.patchTags)(registryTags.concat(scriptExpressionTags));
|
||||
//# sourceMappingURL=patchCBOR.js.map
|
||||
1
dist/patchCBOR.js.map
vendored
1
dist/patchCBOR.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"patchCBOR.js","sourceRoot":"","sources":["../src/patchCBOR.ts"],"names":[],"mappings":";;AAAA,mCAAoC;AACpC,iDAA+C;AAC/C,yDAAuD;AAEvD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,4BAAa,CAAC;KAC9C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1B,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,oCAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACvE,EAAE,CAAC,MAAM,EAAE,CACZ,CAAC;AACF,IAAA,iBAAS,EAAC,YAAY,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC"}
|
||||
5763
package-lock.json
generated
Normal file
5763
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@ -1,7 +1,10 @@
|
||||
{
|
||||
"name": "@keystonehq/bc-ur-registry",
|
||||
"version": "0.4.3",
|
||||
"version": "0.3.0",
|
||||
"description": "A JS implementation of Uniform Resources(UR) Registry specification from Blockchain Commons",
|
||||
"engines": {
|
||||
"node": ">= 14.16 <15"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@ -26,7 +29,6 @@
|
||||
"@types/bip39": "^3.0.0",
|
||||
"@types/jest": "~26.0.23",
|
||||
"@types/node": "~14.14.44",
|
||||
"@types/uuid": "^8.3.1",
|
||||
"@typescript-eslint/eslint-plugin": "~4.23.0",
|
||||
"@typescript-eslint/parser": "~4.23.0",
|
||||
"babel-loader": "^8.2.2",
|
||||
@ -42,8 +44,7 @@
|
||||
"rimraf": "~3.0.2",
|
||||
"ts-jest": "~26.5.6",
|
||||
"tsutils": "~3.21.0",
|
||||
"typescript": "^4.3.5",
|
||||
"uuid": "^8.3.2",
|
||||
"typescript": "~4.2.4",
|
||||
"webpack": "4.46.0",
|
||||
"webpack-cli": "4.3.1"
|
||||
},
|
||||
@ -55,7 +56,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node dist/index.js",
|
||||
"clean": "rimraf coverage build tmp dist",
|
||||
"clean": "rimraf coverage build tmp",
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"build:watch": "tsc -w -p tsconfig.json",
|
||||
"lint": "eslint . --ext .ts,.tsx",
|
||||
@ -66,8 +67,10 @@
|
||||
"author": "Soralit <soralitria@gmail.com>",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@ngraveio/bc-ur": "https://github.com/BlueWallet/bc-ur",
|
||||
"base58check": "^2.0.0",
|
||||
"tslib": "^2.3.0"
|
||||
"@apocentre/bc-ur": "^1.1.0",
|
||||
"tslib": "~2.2.0"
|
||||
},
|
||||
"volta": {
|
||||
"node": "14.16.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { CryptoOutput } from '.';
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
|
||||
@ -26,7 +27,7 @@ export class CryptoAccount extends RegistryItem {
|
||||
public toDataItem = () => {
|
||||
const map = {};
|
||||
if (this.masterFingerprint) {
|
||||
map[Keys.masterFingerprint] = this.masterFingerprint.readUInt32BE(0);
|
||||
map[Keys.masterFingerprint] = this.masterFingerprint.readUInt32BE();
|
||||
}
|
||||
if (this.outputDescriptors) {
|
||||
map[Keys.outputDescriptors] = this.outputDescriptors.map((item) =>
|
||||
@ -41,7 +42,7 @@ export class CryptoAccount extends RegistryItem {
|
||||
const masterFingerprint = Buffer.alloc(4);
|
||||
const _masterFingerprint = map[Keys.masterFingerprint];
|
||||
if (_masterFingerprint) {
|
||||
masterFingerprint.writeUInt32BE(_masterFingerprint, 0);
|
||||
masterFingerprint.writeUInt32BE(_masterFingerprint);
|
||||
}
|
||||
const outputDescriptors = map[Keys.outputDescriptors] as DataItem[];
|
||||
const cryptoOutputs = outputDescriptors.map((item) =>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { encode } from 'bs58check';
|
||||
import { CryptoCoinInfo } from './CryptoCoinInfo';
|
||||
import { CryptoKeypath } from './CryptoKeypath';
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
|
||||
@ -58,38 +58,6 @@ export class CryptoHDKey extends RegistryItem {
|
||||
public getParentFingerprint = () => this.parentFingerprint;
|
||||
public getName = () => this.name;
|
||||
public getNote = () => this.note;
|
||||
public getBip32Key = () => {
|
||||
let version: Buffer;
|
||||
let depth: number;
|
||||
let index: number;
|
||||
let parentFingerprint: Buffer = Buffer.alloc(4).fill(0);
|
||||
if(this.isMaster()) {
|
||||
// version bytes defined on https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format
|
||||
version = Buffer.from("0488ADE4", "hex")
|
||||
depth = 0;
|
||||
index = 0;
|
||||
} else {
|
||||
depth = this.getOrigin().getComponents().length || this.getOrigin().getDepth();
|
||||
const paths = this.getOrigin().getComponents();
|
||||
const lastPath = paths[paths.length - 1];
|
||||
if(lastPath) {
|
||||
index = lastPath.isHardened() ? lastPath.getIndex()! + 0x80000000 : lastPath.getIndex()!;
|
||||
parentFingerprint = this.getParentFingerprint();
|
||||
}
|
||||
if(this.isPrivateKey()) {
|
||||
version = Buffer.from('0488ADE4', 'hex');
|
||||
} else {
|
||||
version = Buffer.from('0488B21E', 'hex');
|
||||
}
|
||||
}
|
||||
const depthBuffer = Buffer.alloc(1);
|
||||
depthBuffer.writeUInt8(depth, 0);
|
||||
const indexBuffer = Buffer.alloc(4);
|
||||
indexBuffer.writeUInt32BE(index, 0);
|
||||
const chainCode = this.getChainCode();
|
||||
const key = this.getKey();
|
||||
return encode(Buffer.concat([version, depthBuffer, parentFingerprint, indexBuffer, chainCode, key]));
|
||||
}
|
||||
|
||||
public getRegistryType = () => {
|
||||
return RegistryTypes.CRYPTO_HDKEY;
|
||||
@ -153,7 +121,7 @@ export class CryptoHDKey extends RegistryItem {
|
||||
map[Keys.children] = children;
|
||||
}
|
||||
if (this.parentFingerprint) {
|
||||
map[Keys.parent_fingerprint] = this.parentFingerprint.readUInt32BE(0);
|
||||
map[Keys.parent_fingerprint] = this.parentFingerprint.readUInt32BE();
|
||||
}
|
||||
if (this.name !== undefined) {
|
||||
map[Keys.name] = this.name;
|
||||
@ -184,7 +152,7 @@ export class CryptoHDKey extends RegistryItem {
|
||||
let parentFingerprint: Buffer;
|
||||
if (_parentFingerprint) {
|
||||
parentFingerprint = Buffer.alloc(4);
|
||||
parentFingerprint.writeUInt32BE(_parentFingerprint, 0);
|
||||
parentFingerprint.writeUInt32BE(_parentFingerprint);
|
||||
}
|
||||
const name = map[Keys.name];
|
||||
const note = map[Keys.note];
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { PathComponent } from './PathComponent';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
@ -53,7 +54,7 @@ export class CryptoKeypath extends RegistryItem {
|
||||
});
|
||||
map[Keys.components] = components;
|
||||
if (this.sourceFingerprint) {
|
||||
map[Keys.source_fingerprint] = this.sourceFingerprint.readUInt32BE(0);
|
||||
map[Keys.source_fingerprint] = this.sourceFingerprint.readUInt32BE();
|
||||
}
|
||||
if (this.depth !== undefined) {
|
||||
map[Keys.depth] = this.depth;
|
||||
@ -82,7 +83,7 @@ export class CryptoKeypath extends RegistryItem {
|
||||
let sourceFingerprint: Buffer;
|
||||
if (_sourceFingerprint) {
|
||||
sourceFingerprint = Buffer.alloc(4);
|
||||
sourceFingerprint.writeUInt32BE(_sourceFingerprint, 0);
|
||||
sourceFingerprint.writeUInt32BE(_sourceFingerprint);
|
||||
}
|
||||
const depth = map[Keys.depth];
|
||||
return new CryptoKeypath(pathComponents, sourceFingerprint, depth);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { CryptoECKey } from './CryptoECKey';
|
||||
import { CryptoHDKey } from './CryptoHDKey';
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { MultiKey } from './MultiKey';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { decodeToDataItem, DataItem } from './lib';
|
||||
import { decodeToDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { URDecoder } from '@ngraveio/bc-ur';
|
||||
import { URDecoder } from '@apocentre/bc-ur';
|
||||
import {
|
||||
Bytes,
|
||||
CryptoAccount,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { UR, UREncoder } from '@ngraveio/bc-ur';
|
||||
import { encodeDataItem, DataItem } from './lib';
|
||||
import { UR, UREncoder } from '@apocentre/bc-ur';
|
||||
import { encodeDataItem } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryType } from './RegistryType';
|
||||
|
||||
export abstract class RegistryItem {
|
||||
|
||||
@ -8,7 +8,6 @@ export class RegistryType {
|
||||
}
|
||||
|
||||
export const RegistryTypes = {
|
||||
UUID: new RegistryType('uuid', 37),
|
||||
BYTES: new RegistryType('bytes', undefined),
|
||||
CRYPTO_HDKEY: new RegistryType('crypto-hdkey', 303),
|
||||
CRYPTO_KEYPATH: new RegistryType('crypto-keypath', 304),
|
||||
|
||||
36
src/index.ts
36
src/index.ts
@ -19,22 +19,6 @@ import { MultiKey } from './MultiKey';
|
||||
import { ScriptExpressions } from './ScriptExpression';
|
||||
import { PathComponent } from './PathComponent';
|
||||
|
||||
import { RegistryItem } from './RegistryItem';
|
||||
import { RegistryTypes, RegistryType } from './RegistryType';
|
||||
|
||||
import {
|
||||
addReader,
|
||||
addSemanticDecode,
|
||||
addSemanticEncode,
|
||||
addWriter,
|
||||
decodeToDataItem,
|
||||
encodeDataItem,
|
||||
} from './lib';
|
||||
|
||||
export { DataItem } from './lib';
|
||||
|
||||
import { patchTags } from './utils';
|
||||
|
||||
const URlib = {
|
||||
URRegistryDecoder,
|
||||
Bytes,
|
||||
@ -52,25 +36,6 @@ const URlib = {
|
||||
PathComponent,
|
||||
};
|
||||
|
||||
const cbor = {
|
||||
addReader,
|
||||
addSemanticDecode,
|
||||
addSemanticEncode,
|
||||
addWriter,
|
||||
patchTags,
|
||||
};
|
||||
|
||||
const extend = {
|
||||
RegistryTypes,
|
||||
RegistryItem,
|
||||
RegistryType,
|
||||
|
||||
decodeToDataItem,
|
||||
encodeDataItem,
|
||||
|
||||
cbor,
|
||||
};
|
||||
|
||||
export {
|
||||
URRegistryDecoder,
|
||||
Bytes,
|
||||
@ -86,7 +51,6 @@ export {
|
||||
MultiKey,
|
||||
ScriptExpressions,
|
||||
PathComponent,
|
||||
extend,
|
||||
};
|
||||
|
||||
export default URlib;
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
export {
|
||||
encodeDataItem,
|
||||
decodeToDataItem,
|
||||
addSemanticDecode,
|
||||
addSemanticEncode,
|
||||
addReader,
|
||||
addWriter,
|
||||
} from './cbor-sync';
|
||||
export { DataItem } from './DataItem';
|
||||
@ -1,10 +1,28 @@
|
||||
import { patchTags } from './utils';
|
||||
import { addSemanticDecode, addSemanticEncode } from './lib/cbor-sync';
|
||||
import { DataItem } from './lib/DataItem';
|
||||
import { RegistryTypes } from './RegistryType';
|
||||
import { ScriptExpressions } from './ScriptExpression';
|
||||
|
||||
const registryTags = Object.values(RegistryTypes)
|
||||
.filter((r) => !!r.getTag())
|
||||
.map((r) => r.getTag());
|
||||
const alreadyPatchedTag = [];
|
||||
|
||||
const patchTags = (tags: number[]) => {
|
||||
tags.forEach((tag) => {
|
||||
if (alreadyPatchedTag.find((i) => i === tag)) return;
|
||||
addSemanticEncode(tag, (data: any) => {
|
||||
if (data instanceof DataItem) {
|
||||
if (data.getTag() === tag) {
|
||||
return data.getData();
|
||||
}
|
||||
}
|
||||
});
|
||||
addSemanticDecode(tag, (data: any) => {
|
||||
return new DataItem(data, tag);
|
||||
});
|
||||
alreadyPatchedTag.push(tag);
|
||||
});
|
||||
};
|
||||
|
||||
const registryTags = Object.values(RegistryTypes).filter(r => !!r.getTag()).map((r) => r.getTag());
|
||||
const scriptExpressionTags = Object.values(ScriptExpressions).map((se) =>
|
||||
se.getTag(),
|
||||
);
|
||||
|
||||
19
src/utils.ts
19
src/utils.ts
@ -1,19 +0,0 @@
|
||||
import { addSemanticDecode, addSemanticEncode, DataItem } from './lib';
|
||||
|
||||
const alreadyPatchedTag = [];
|
||||
export const patchTags = (tags: number[]) => {
|
||||
tags.forEach((tag) => {
|
||||
if (alreadyPatchedTag.find((i) => i === tag)) return;
|
||||
addSemanticEncode(tag, (data: any) => {
|
||||
if (data instanceof DataItem) {
|
||||
if (data.getTag() === tag) {
|
||||
return data.getData();
|
||||
}
|
||||
}
|
||||
});
|
||||
addSemanticDecode(tag, (data: any) => {
|
||||
return new DataItem(data, tag);
|
||||
});
|
||||
alreadyPatchedTag.push(tag);
|
||||
});
|
||||
};
|
||||
128
yarn.lock
128
yarn.lock
@ -7,6 +7,24 @@
|
||||
resolved "https://registry.nlark.com/@apocentre/alias-sampling/download/@apocentre/alias-sampling-0.5.3.tgz#897ff181b48ad7b2bcb4ecf29400214888244f08"
|
||||
integrity sha1-iX/xgbSK17K8tOzylAAhSIgkTwg=
|
||||
|
||||
"@apocentre/bc-ur@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.nlark.com/@apocentre/bc-ur/download/@apocentre/bc-ur-1.1.0.tgz#7c2d4b379d145ba0293df1c3169f716a73268887"
|
||||
integrity sha1-fC1LN50UW6ApPfHDFp9xanMmiIc=
|
||||
dependencies:
|
||||
"@apocentre/alias-sampling" "^0.5.3"
|
||||
"@ellipticoin/cbor" "^1.0.4"
|
||||
"@iljucha/cbor" "^1.0.10"
|
||||
"@types/crc" "^3.4.0"
|
||||
"@types/sha.js" "^2.4.0"
|
||||
assert "^2.0.0"
|
||||
big-integer "^1.6.48"
|
||||
bignumber.js "^9.0.1"
|
||||
cbor-sync "^1.0.4"
|
||||
cborg "^1.0.4"
|
||||
crc "^3.8.0"
|
||||
sha.js "^2.4.11"
|
||||
|
||||
"@babel/code-frame@7.12.11":
|
||||
version "7.12.11"
|
||||
resolved "https://registry.nlark.com/@babel/code-frame/download/@babel/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f"
|
||||
@ -937,6 +955,13 @@
|
||||
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.3.tgz#90420f9f9c6d3987f176a19a7d8e764271a2f55d"
|
||||
integrity sha512-Fxt+AfXgjMoin2maPIYzFZnQjAXjAL0PHscM5pRTtatFqB+vZxAM9tLp2Optnuw3QOQC40jTNeGYFOMvyf7v9g==
|
||||
|
||||
"@ellipticoin/cbor@^1.0.4":
|
||||
version "1.0.4"
|
||||
resolved "https://registry.nlark.com/@ellipticoin/cbor/download/@ellipticoin/cbor-1.0.4.tgz#de5c5eb2aba9cee93a0a944fae2258171e231dd5"
|
||||
integrity sha1-3lxesqupzuk6CpRPriJYFx4jHdU=
|
||||
dependencies:
|
||||
bigint-buffer "^1.1.5"
|
||||
|
||||
"@eslint/eslintrc@^0.4.1":
|
||||
version "0.4.1"
|
||||
resolved "https://registry.nlark.com/@eslint/eslintrc/download/@eslint/eslintrc-0.4.1.tgz?cache=0&sync_timestamp=1620433726531&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40eslint%2Feslintrc%2Fdownload%2F%40eslint%2Feslintrc-0.4.1.tgz#442763b88cecbe3ee0ec7ca6d6dd6168550cbf14"
|
||||
@ -952,6 +977,11 @@
|
||||
minimatch "^3.0.4"
|
||||
strip-json-comments "^3.1.1"
|
||||
|
||||
"@iljucha/cbor@^1.0.10":
|
||||
version "1.0.10"
|
||||
resolved "https://registry.nlark.com/@iljucha/cbor/download/@iljucha/cbor-1.0.10.tgz#eb8f1cec52b1d7eacd21c721d31e441e87e36696"
|
||||
integrity sha1-648c7FKx1+rNIcch0x5EHofjZpY=
|
||||
|
||||
"@istanbuljs/load-nyc-config@^1.0.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npm.taobao.org/@istanbuljs/load-nyc-config/download/@istanbuljs/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced"
|
||||
@ -1139,21 +1169,6 @@
|
||||
"@types/yargs" "^15.0.0"
|
||||
chalk "^4.0.0"
|
||||
|
||||
"@ngraveio/bc-ur@^1.1.5":
|
||||
version "1.1.5"
|
||||
resolved "https://registry.nlark.com/@ngraveio/bc-ur/download/@ngraveio/bc-ur-1.1.5.tgz#4dc7dc550c5c6eb4a331ead090f9f819731c4fcc"
|
||||
integrity sha1-TcfcVQxcbrSjMerQkPn4GXMcT8w=
|
||||
dependencies:
|
||||
"@apocentre/alias-sampling" "^0.5.3"
|
||||
"@types/crc" "^3.4.0"
|
||||
"@types/sha.js" "^2.4.0"
|
||||
assert "^2.0.0"
|
||||
bignumber.js "^9.0.1"
|
||||
cbor-sync "^1.0.4"
|
||||
crc "^3.8.0"
|
||||
jsbi "^3.1.5"
|
||||
sha.js "^2.4.11"
|
||||
|
||||
"@nodelib/fs.scandir@2.1.4":
|
||||
version "2.1.4"
|
||||
resolved "https://registry.nlark.com/@nodelib/fs.scandir/download/@nodelib/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69"
|
||||
@ -1322,11 +1337,6 @@
|
||||
resolved "https://registry.nlark.com/@types/stack-utils/download/@types/stack-utils-2.0.0.tgz#7036640b4e21cc2f259ae826ce843d277dad8cff"
|
||||
integrity sha1-cDZkC04hzC8lmugmzoQ9J32tjP8=
|
||||
|
||||
"@types/uuid@^8.3.1":
|
||||
version "8.3.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.1.tgz#1a32969cf8f0364b3d8c8af9cc3555b7805df14f"
|
||||
integrity sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==
|
||||
|
||||
"@types/yargs-parser@*":
|
||||
version "20.2.0"
|
||||
resolved "https://registry.nlark.com/@types/yargs-parser/download/@types/yargs-parser-20.2.0.tgz#dd3e6699ba3237f0348cd085e4698780204842f9"
|
||||
@ -1959,11 +1969,6 @@ balanced-match@^1.0.0:
|
||||
resolved "https://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbalanced-match%2Fdownload%2Fbalanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||
integrity sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4=
|
||||
|
||||
base-x@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/base-x/-/base-x-1.1.0.tgz#42d3d717474f9ea02207f6d1aa1f426913eeb7ac"
|
||||
integrity sha1-QtPXF0dPnqAiB/bRqh9CaRPut6w=
|
||||
|
||||
base-x@^3.0.2:
|
||||
version "3.0.8"
|
||||
resolved "https://registry.npm.taobao.org/base-x/download/base-x-3.0.8.tgz#1e1106c2537f0162e8b52474a557ebb09000018d"
|
||||
@ -1971,13 +1976,6 @@ base-x@^3.0.2:
|
||||
dependencies:
|
||||
safe-buffer "^5.0.1"
|
||||
|
||||
base58check@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/base58check/-/base58check-2.0.0.tgz#8046652d14bc87f063bd16be94a39134d3b61173"
|
||||
integrity sha1-gEZlLRS8h/BjvRa+lKORNNO2EXM=
|
||||
dependencies:
|
||||
bs58 "^3.0.0"
|
||||
|
||||
base64-js@^1.0.2, base64-js@^1.3.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.npm.taobao.org/base64-js/download/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
|
||||
@ -2001,11 +1999,23 @@ bech32@^1.1.2:
|
||||
resolved "https://registry.npm.taobao.org/bech32/download/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9"
|
||||
integrity sha1-44yfN78Xm46xauOncrQMNW1IMuk=
|
||||
|
||||
big-integer@^1.6.48:
|
||||
version "1.6.48"
|
||||
resolved "https://registry.nlark.com/big-integer/download/big-integer-1.6.48.tgz#8fd88bd1632cba4a1c8c3e3d7159f08bb95b4b9e"
|
||||
integrity sha1-j9iL0WMsukocjD49cVnwi7lbS54=
|
||||
|
||||
big.js@^5.2.2:
|
||||
version "5.2.2"
|
||||
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
|
||||
integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==
|
||||
|
||||
bigint-buffer@^1.1.5:
|
||||
version "1.1.5"
|
||||
resolved "https://registry.nlark.com/bigint-buffer/download/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442"
|
||||
integrity sha1-0DjzHI5FNMH40AFSCb80tPpt1EI=
|
||||
dependencies:
|
||||
bindings "^1.3.0"
|
||||
|
||||
bignumber.js@^9.0.1:
|
||||
version "9.0.1"
|
||||
resolved "https://registry.npm.taobao.org/bignumber.js/download/bignumber.js-9.0.1.tgz#8d7ba124c882bfd8e43260c67475518d0689e4e5"
|
||||
@ -2033,7 +2043,20 @@ bip174@^2.0.1:
|
||||
resolved "https://registry.npm.taobao.org/bip174/download/bip174-2.0.1.tgz#39cf8ca99e50ce538fb762589832f4481d07c254"
|
||||
integrity sha1-Oc+MqZ5QzlOPt2JYmDL0SB0HwlQ=
|
||||
|
||||
bip32@^2.0.4, bip32@^2.0.6:
|
||||
bip32@^2.0.4:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.npm.taobao.org/bip32/download/bip32-2.0.6.tgz#6a81d9f98c4cd57d05150c60d8f9e75121635134"
|
||||
integrity sha1-aoHZ+YxM1X0FFQxg2PnnUSFjUTQ=
|
||||
dependencies:
|
||||
"@types/node" "10.12.18"
|
||||
bs58check "^2.1.1"
|
||||
create-hash "^1.2.0"
|
||||
create-hmac "^1.1.7"
|
||||
tiny-secp256k1 "^1.1.3"
|
||||
typeforce "^1.11.5"
|
||||
wif "^2.0.6"
|
||||
|
||||
bip32@^2.0.6:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/bip32/-/bip32-2.0.6.tgz#6a81d9f98c4cd57d05150c60d8f9e75121635134"
|
||||
integrity sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==
|
||||
@ -2224,13 +2247,6 @@ bs-logger@0.x:
|
||||
dependencies:
|
||||
fast-json-stable-stringify "2.x"
|
||||
|
||||
bs58@^3.0.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/bs58/-/bs58-3.1.0.tgz#d4c26388bf4804cac714141b1945aa47e5eb248e"
|
||||
integrity sha1-1MJjiL9IBMrHFBQbGUWqR+XrJI4=
|
||||
dependencies:
|
||||
base-x "^1.1.0"
|
||||
|
||||
bs58@^4.0.0:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.npm.taobao.org/bs58/download/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a"
|
||||
@ -2283,8 +2299,8 @@ buffer@^5.1.0:
|
||||
|
||||
buffer@^6.0.3:
|
||||
version "6.0.3"
|
||||
resolved "https://registry.nlark.com/buffer/download/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
|
||||
integrity sha1-Ks5XhFnMj74qcKqo9S7mO2p0xsY=
|
||||
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
|
||||
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
|
||||
dependencies:
|
||||
base64-js "^1.3.1"
|
||||
ieee754 "^1.2.1"
|
||||
@ -2370,6 +2386,11 @@ cbor-sync@^1.0.4:
|
||||
resolved "https://registry.nlark.com/cbor-sync/download/cbor-sync-1.0.4.tgz#5a11a1ab75c2a14d1af1b237fd84aa8c1593662f"
|
||||
integrity sha1-WhGhq3XCoU0a8bI3/YSqjBWTZi8=
|
||||
|
||||
cborg@^1.0.4:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.nlark.com/cborg/download/cborg-1.3.1.tgz#7f8ac75bd09eec60bc6720e9d7cebbdcaa806e4c"
|
||||
integrity sha1-f4rHW9Ce7GC8ZyDp18673KqAbkw=
|
||||
|
||||
chalk@^2.0.0:
|
||||
version "2.4.2"
|
||||
resolved "https://registry.nlark.com/chalk/download/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
|
||||
@ -4509,11 +4530,6 @@ js-yaml@^3.13.1:
|
||||
argparse "^1.0.7"
|
||||
esprima "^4.0.0"
|
||||
|
||||
jsbi@^3.1.5:
|
||||
version "3.1.5"
|
||||
resolved "https://registry.nlark.com/jsbi/download/jsbi-3.1.5.tgz#70c2aaa2f75e1dc7604fed45298061ca23724046"
|
||||
integrity sha1-cMKqovdeHcdgT+1FKYBhyiNyQEY=
|
||||
|
||||
jsdom@^16.4.0:
|
||||
version "16.6.0"
|
||||
resolved "https://registry.nlark.com/jsdom/download/jsdom-16.6.0.tgz#f79b3786682065492a3da6a60a4695da983805ac"
|
||||
@ -6401,10 +6417,10 @@ tslib@^1.8.1:
|
||||
resolved "https://registry.nlark.com/tslib/download/tslib-1.14.1.tgz?cache=0&sync_timestamp=1618846758811&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftslib%2Fdownload%2Ftslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
|
||||
integrity sha1-zy04vcNKE0vK8QkcQfZhni9nLQA=
|
||||
|
||||
tslib@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.nlark.com/tslib/download/tslib-2.3.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftslib%2Fdownload%2Ftslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e"
|
||||
integrity sha1-gDuM2rPhK6WBpMpByIObuw2ssJ4=
|
||||
tslib@~2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.nlark.com/tslib/download/tslib-2.2.0.tgz?cache=0&sync_timestamp=1618846758811&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftslib%2Fdownload%2Ftslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c"
|
||||
integrity sha1-+yxHWXfjXiQTEe3iaTzuHsZpj1w=
|
||||
|
||||
tsutils@^3.17.1, tsutils@~3.21.0:
|
||||
version "3.21.0"
|
||||
@ -6479,10 +6495,10 @@ typeforce@^1.11.3, typeforce@^1.11.5:
|
||||
resolved "https://registry.npm.taobao.org/typeforce/download/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc"
|
||||
integrity sha1-10FqLFhF4IUDTXD8xbbMSpDtv9w=
|
||||
|
||||
typescript@^4.3.5:
|
||||
version "4.3.5"
|
||||
resolved "https://registry.nlark.com/typescript/download/typescript-4.3.5.tgz?cache=0&sync_timestamp=1626247133746&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftypescript%2Fdownload%2Ftypescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
|
||||
integrity sha1-TRw3zBbok5c8RaBohrcRMjTxGfQ=
|
||||
typescript@~4.2.4:
|
||||
version "4.2.4"
|
||||
resolved "https://registry.nlark.com/typescript/download/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
|
||||
integrity sha1-hhC1l0feAo/aiYqK7w4QPxVtCWE=
|
||||
|
||||
unbox-primitive@^1.0.0:
|
||||
version "1.0.1"
|
||||
@ -6615,7 +6631,7 @@ util@^0.12.0, util@^0.12.3:
|
||||
safe-buffer "^5.1.2"
|
||||
which-typed-array "^1.1.2"
|
||||
|
||||
uuid@^8.3.0, uuid@^8.3.2:
|
||||
uuid@^8.3.0:
|
||||
version "8.3.2"
|
||||
resolved "https://registry.npm.taobao.org/uuid/download/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
|
||||
integrity sha1-gNW1ztJxu5r2xEXyGhoExgbO++I=
|
||||
|
||||
Loading…
Reference in New Issue
Block a user