@secux/utility
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -13,1 +13,7 @@ /// <reference types="node" /> | ||
export declare function BigIntToBuffer(value: number | string, bufferlen: number, isLE?: boolean): Buffer; | ||
export declare const supported_coin: readonly { | ||
purpose: number[]; | ||
cointype: number; | ||
name: string; | ||
}[]; | ||
export declare function isSupportedCoin(path: string): boolean; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BigIntToBuffer=exports.ow_checkBufferLength=exports.ow_accountPath=exports.ow_strictPath=exports.ow_numberString=exports.ow_hashString=exports.ow_prefixedhexString=exports.ow_hexString=exports.ow_bip32String=exports.toExtenededPublicKey=exports.splitPath=exports.buildPathBuffer=void 0;const e=require("bignumber.js"),t=require("ow");var r=require("./BIP32Path");Object.defineProperty(exports,"buildPathBuffer",{enumerable:!0,get:function(){return r.buildPathBuffer}}),Object.defineProperty(exports,"splitPath",{enumerable:!0,get:function(){return r.splitPath}});var n=require("./xpub");function o(e){let t="";return e.map((e=>t+=`${e.toString()}|`)),t=`(${t.substr(0,t.length-1)})`,t}Object.defineProperty(exports,"toExtenededPublicKey",{enumerable:!0,get:function(){return n.toExtenededPublicKey}}),exports.ow_bip32String=t.default.string.matches(/^m(\/\d+'){3}(\/\d+){2}$/),exports.ow_hexString=t.default.string.matches(/^[0-9A-F-a-f]+$/),exports.ow_prefixedhexString=t.default.string.matches(/^0x[0-9A-F-a-f]+$/),exports.ow_hashString=t.default.string.matches(/^[0-9A-Z-a-z]+$/),exports.ow_numberString=t.default.string.matches(/^[0-9]+$/),exports.ow_strictPath=function(e,r){const n=o("number"==typeof e?[e]:e);if(r){const e=o("number"==typeof r?[r]:r);return t.default.string.matches(new RegExp(`^m/${e}'/${n}'/[0-9]+'/[0-9]+/[0-9]+$`))}return t.default.string.matches(new RegExp(`^m/(44|49|84)'/${n}'/[0-9]+'/[0-9]+/[0-9]+$`))},exports.ow_accountPath=function(e,r){const n=o("number"==typeof e?[e]:e);if(r){const e=o("number"==typeof r?[r]:r);return t.default.string.matches(new RegExp(`^m/${e}'/${n}'/[0-9]+'/[0-9]+/[0-9]+$`))}return t.default.string.matches(new RegExp(`^m/(44|49|84)'/${n}'/[0-9]+'$`))},exports.ow_checkBufferLength=function(e){return t.default.buffer.validate((t=>({validator:t.length===e,message:r=>`ArgumentError: Expected length of ${r} is ${e}, got ${t.length}`})))},exports.BigIntToBuffer=function(t,r,n=!0){let o="";"number"==typeof t?o=t.toString(16):"string"==typeof t&&(o=new e.BigNumber(t).toString(16)),o.length%2!=0&&(o="0"+o);const u=Buffer.from(o,"hex");if(u.length>r)throw Error("value is too large");const s=Buffer.concat([Buffer.alloc(r-u.length),u]);return n?s.reverse():s}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSupportedCoin=exports.supported_coin=exports.BigIntToBuffer=exports.ow_checkBufferLength=exports.ow_accountPath=exports.ow_strictPath=exports.ow_numberString=exports.ow_hashString=exports.ow_prefixedhexString=exports.ow_hexString=exports.ow_bip32String=exports.toExtenededPublicKey=exports.splitPath=exports.buildPathBuffer=void 0;const e=require("bignumber.js"),t=require("ow"),r=require("./BIP32Path");var o=require("./BIP32Path");Object.defineProperty(exports,"buildPathBuffer",{enumerable:!0,get:function(){return o.buildPathBuffer}}),Object.defineProperty(exports,"splitPath",{enumerable:!0,get:function(){return o.splitPath}});var n=require("./xpub");function p(e){let t="";return e.map((e=>t+=`${e.toString()}|`)),t=`(${t.substr(0,t.length-1)})`,t}Object.defineProperty(exports,"toExtenededPublicKey",{enumerable:!0,get:function(){return n.toExtenededPublicKey}}),exports.ow_bip32String=t.default.string.matches(/^m(\/\d+'){3}(\/\d+){2}$/),exports.ow_hexString=t.default.string.matches(/^[0-9A-F-a-f]+$/),exports.ow_prefixedhexString=t.default.string.matches(/^0x[0-9A-F-a-f]+$/),exports.ow_hashString=t.default.string.matches(/^[0-9A-Z-a-z]+$/),exports.ow_numberString=t.default.string.matches(/^[0-9]+$/),exports.ow_strictPath=function(e,r){const o=p("number"==typeof e?[e]:e);if(r){const e=p("number"==typeof r?[r]:r);return t.default.string.matches(new RegExp(`^m/${e}'/${o}'/[0-9]+'/[0-9]+/[0-9]+$`))}return t.default.string.matches(new RegExp(`^m/(44|49|84)'/${o}'/[0-9]+'/[0-9]+/[0-9]+$`))},exports.ow_accountPath=function(e,r){const o=p("number"==typeof e?[e]:e);if(r){const e=p("number"==typeof r?[r]:r);return t.default.string.matches(new RegExp(`^m/${e}'/${o}'/[0-9]+'/[0-9]+/[0-9]+$`))}return t.default.string.matches(new RegExp(`^m/(44|49|84)'/${o}'/[0-9]+'$`))},exports.ow_checkBufferLength=function(e){return t.default.buffer.validate((t=>({validator:t.length===e,message:r=>`ArgumentError: Expected length of ${r} is ${e}, got ${t.length}`})))},exports.BigIntToBuffer=function(t,r,o=!0){let n="";"number"==typeof t?n=t.toString(16):"string"==typeof t&&(n=new e.BigNumber(t).toString(16)),n.length%2!=0&&(n="0"+n);const p=Buffer.from(n,"hex");if(p.length>r)throw Error("value is too large");const i=Buffer.concat([Buffer.alloc(r-p.length),p]);return o?i.reverse():i},exports.supported_coin=Object.freeze([{purpose:[44,49,84],cointype:0,name:"bitcoin mainnet"},{purpose:[44,49],cointype:1,name:"bitcoin testnet"},{purpose:[44,49],cointype:2,name:"litecoin"},{purpose:[44],cointype:3,name:"dogecoin"},{purpose:[44],cointype:5,name:"dash"},{purpose:[44,49],cointype:17,name:"groestl"},{purpose:[44,49],cointype:20,name:"digibyte"},{purpose:[44],cointype:60,name:"ethereum"},{purpose:[44],cointype:144,name:"ripple"},{purpose:[44],cointype:145,name:"bitcoincash"},{purpose:[44],cointype:148,name:"stellar"},{purpose:[44],cointype:358,name:"tron"},{purpose:[44],cointype:714,name:"binance"},{purpose:[1852],cointype:1815,name:"cardano"}]),exports.isSupportedCoin=function(e){const t=(0,r.splitPath)(e);for(const e of exports.supported_coin)if(e.purpose.includes(t.purpose.value)&&e.cointype===t.coinType.value)return!0;return!1}; |
{ | ||
"name": "@secux/utility", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "SecuX Hardware Wallet internal tools for SDK", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
12092
59