New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@secux/utility

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secux/utility - npm Package Compare versions

Comparing version 2.0.6 to 3.0.0

lib/communication.d.ts

3

lib/BIP32Path.d.ts
/// <reference types="node" />
export { buildPathBuffer, splitPath, HARDENED_OFFSET };
export { buildPathBuffer, decodePathBuffer, splitPath, HARDENED_OFFSET };
declare const HARDENED_OFFSET = 2147483648;

@@ -8,2 +8,3 @@ declare function buildPathBuffer(path: string, num?: number): {

};
declare function decodePathBuffer(data: Buffer): string;
declare function splitPath(path: string): pathObjectType;

@@ -10,0 +11,0 @@ declare type pathLevelType = {

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HARDENED_OFFSET=exports.splitPath=exports.buildPathBuffer=void 0;function e(e){const t=e.split("/"),r=t.length;if(r<2||r>6)throw Error("Invalid Path, only support 1 to 5 depth path");const a={};return a.pathNum=r-1,t.forEach(((e,t)=>{if(0===t)return;const r={},s=e.length>1&&"'"===e[e.length-1];switch(r.value=s?parseInt(e.slice(0,-1),10):parseInt(e,10),r.isHardened=s,r.depth=t,t){case 1:a.purpose=r;break;case 2:a.coinType=r;break;case 3:a.accountId=r;break;case 4:a.change=r;break;case 5:a.addressIndex=r}})),a}exports.HARDENED_OFFSET=2147483648,exports.buildPathBuffer=function(t,r){const a=e=>{if(e&&e.isHardened)return e.value+2147483648;if(e&&!e.isHardened)return e.value;throw Error("Build path error")},s=e(t);let n=r&&r>=1&&r<6?r:s.pathNum;const o=Buffer.alloc(4*n),{purpose:c,coinType:i,accountId:p,change:u,addressIndex:d}=s;for(let e=0;e<n;e++)switch(e){case 0:o.writeUInt32LE(a(c),4*e);break;case 1:o.writeUInt32LE(a(i),4*e);break;case 2:o.writeUInt32LE(a(p),4*e);break;case 3:o.writeUInt32LE(a(u),4*e);break;case 4:o.writeUInt32LE(a(d),4*e)}return{pathNum:n,pathBuffer:o}},exports.splitPath=e;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.HARDENED_OFFSET=exports.splitPath=exports.decodePathBuffer=exports.buildPathBuffer=void 0;function e(e){const t=e.split("/"),r=t.length;if(r<2||r>6)throw Error("Invalid Path, only support 1 to 5 depth path");const a={};return a.pathNum=r-1,t.forEach(((e,t)=>{if(0===t)return;const r={},n=e.length>1&&"'"===e[e.length-1];switch(r.value=n?parseInt(e.slice(0,-1),10):parseInt(e,10),r.isHardened=n,r.depth=t,t){case 1:a.purpose=r;break;case 2:a.coinType=r;break;case 3:a.accountId=r;break;case 4:a.change=r;break;case 5:a.addressIndex=r}})),a}exports.HARDENED_OFFSET=2147483648,exports.buildPathBuffer=function(t,r){const a=e=>{if(e&&e.isHardened)return e.value+2147483648;if(e&&!e.isHardened)return e.value;throw Error("Build path error")},n=e(t);let o=r&&r>=1&&r<6?r:n.pathNum;const s=Buffer.alloc(4*o),{purpose:c,coinType:h,accountId:p,change:u,addressIndex:i}=n;for(let e=0;e<o;e++)switch(e){case 0:s.writeUInt32LE(a(c),4*e);break;case 1:s.writeUInt32LE(a(h),4*e);break;case 2:s.writeUInt32LE(a(p),4*e);break;case 3:s.writeUInt32LE(a(u),4*e);break;case 4:s.writeUInt32LE(a(i),4*e)}return{pathNum:o,pathBuffer:s}},exports.decodePathBuffer=function(e){if(e.length%4!=0)throw Error("ArgumentError: each element of path should be 4 bytes");if(e.length<=0||e.length>20)throw Error("ArgumentError: invalid Path, only support 1 to 5 depth path");let t="m";for(let r=0;r<e.length;r+=4){const a=e.readUInt32LE(r);t=a>=2147483648?`${t}/${a-2147483648}'`:`${t}/${a}`}return t},exports.splitPath=e;
/// <reference types="node" />
export { buildPathBuffer, splitPath } from "./BIP32Path";
export { buildPathBuffer, decodePathBuffer, splitPath } from "./BIP32Path";
export { toExtenededPublicKey } from "./xpub";
export { Signature } from "./signature";
export declare const Logger: any;

@@ -18,3 +19,5 @@ export declare const ow_bip32String: import("ow").StringPredicate;

name: string;
module: string;
npm: string;
}[];
export declare function isSupportedCoin(path: string): boolean;

@@ -1,1 +0,1 @@

"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.Logger=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.Logger=process.env.SECUX_LOGGER,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:195,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},process.env.SECUX_LOGGER||Object.defineProperty(process.env,"SECUX_LOGGER",{enumerable:!1,configurable:!1,writable:!1,value:void 0});
"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.Logger=exports.Signature=exports.toExtenededPublicKey=exports.splitPath=exports.decodePathBuffer=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,"decodePathBuffer",{enumerable:!0,get:function(){return o.decodePathBuffer}}),Object.defineProperty(exports,"splitPath",{enumerable:!0,get:function(){return o.splitPath}});var n=require("./xpub");Object.defineProperty(exports,"toExtenededPublicKey",{enumerable:!0,get:function(){return n.toExtenededPublicKey}});var p=require("./signature");function u(e){let t="";return e.map((e=>t+=`${e.toString()}|`)),t=`(${t.substr(0,t.length-1)})`,t}Object.defineProperty(exports,"Signature",{enumerable:!0,get:function(){return p.Signature}}),exports.Logger=process.env.SECUX_LOGGER,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(/^[1-9][0-9]+$/),exports.ow_strictPath=function(e,r){const o=u("number"==typeof e?[e]:e);if(r){const e=u("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=u("number"==typeof e?[e]:e);if(r){const e=u("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 u=Buffer.concat([Buffer.alloc(r-p.length),p]);return o?u.reverse():u},exports.supported_coin=Object.freeze([{purpose:[44,49,84],cointype:0,name:"bitcoin mainnet",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44,49],cointype:1,name:"bitcoin testnet",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44,49],cointype:2,name:"litecoin",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44],cointype:3,name:"dogecoin",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44],cointype:5,name:"dash",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44,49],cointype:17,name:"groestl",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44,49],cointype:20,name:"digibyte",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44],cointype:60,name:"ethereum",module:"SecuxETH",npm:"@secux/app-eth"},{purpose:[44],cointype:144,name:"ripple",module:"SecuxXRP",npm:"@secux/app-xrp"},{purpose:[44],cointype:145,name:"bitcoincash",module:"SecuxBTC",npm:"@secux/app-btc"},{purpose:[44],cointype:148,name:"stellar",module:"SecuxXLM",npm:"@secux/app-xlm"},{purpose:[44],cointype:195,name:"tron",module:"SecuxTRX",npm:"@secux/app-trx"},{purpose:[44],cointype:714,name:"binance",module:"SecuxBNB",npm:"@secux/app-bnb"},{purpose:[1852],cointype:1815,name:"cardano",module:"SecuxADA",npm:"@secux/app-ada"}]),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},process.env.SECUX_LOGGER||Object.defineProperty(process.env,"SECUX_LOGGER",{enumerable:!1,configurable:!1,writable:!1,value:void 0});

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.toExtenededPublicKey=void 0;const e=require("./BIP32Path"),t=require("./bs58"),r=require("hash.js"),a=require("ow"),o=require("./utility"),u=require("groestl-hash-js");exports.toExtenededPublicKey=function(t,r,u,n){var i;(0,a.default)(t,a.default.string.matches(/^m(\/\d+'?){3}/)),(0,a.default)(r,(0,o.ow_checkBufferLength)(4)),(0,a.default)(u,(0,o.ow_checkBufferLength)(32)),(0,a.default)(n,(0,o.ow_checkBufferLength)(33));const d=Buffer.allocUnsafe(78),l=(0,e.splitPath)(t);switch(l.purpose.value){case 44:d.writeUInt32BE(76067358,0);break;case 49:d.writeUInt32BE(77429938,0);break;case 84:d.writeUInt32BE(78792518,0);break;default:throw Error("unsupported purpose of path")}const f=l.pathNum;let h;switch(d.writeUInt8(f,4),(f?r:Buffer.alloc(4)).copy(d,5),f){case 1:h=l.purpose;break;case 2:h=l.coinType;break;case 3:h=l.accountId;break;case 4:h=l.change;break;case 5:h=l.addressIndex;break;default:throw Error("Invalid Path, only support 1 to 5 depth path")}const p=h.isHardened?h.value+e.HARDENED_OFFSET:null==h?void 0:h.value;return d.writeUInt32BE(p,9),u.copy(d,13),n.copy(d,45),17===(null===(i=l.coinType)||void 0===i?void 0:i.value)?c.encode(d):s.encode(d)};const s=new t.bs58Check((function(e){const t=(0,r.sha256)().update(e).digest();return Buffer.from((0,r.sha256)().update(t).digest())})),c=new t.bs58Check((function(e){return Buffer.from(u.groestl_2(e,1,1))}));
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.toExtenededPublicKey=void 0;const e=require("./BIP32Path"),t=require("./bs58"),r=require("hash.js"),o=require("ow"),a=require("./utility"),u=require("groestl-hash-js");exports.toExtenededPublicKey=function(t,r,u,n){var i;(0,o.default)(t,a.ow_bip32String),(0,o.default)(r,(0,a.ow_checkBufferLength)(4)),(0,o.default)(u,(0,a.ow_checkBufferLength)(32)),(0,o.default)(n,(0,a.ow_checkBufferLength)(33));const d=Buffer.allocUnsafe(78),l=(0,e.splitPath)(t);switch(l.purpose.value){case 44:d.writeUInt32BE(76067358,0);break;case 49:d.writeUInt32BE(77429938,0);break;case 84:d.writeUInt32BE(78792518,0);break;default:throw Error("unsupported purpose of path")}const f=l.pathNum;let p;switch(d.writeUInt8(f,4),(f?r:Buffer.alloc(4)).copy(d,5),f){case 1:p=l.purpose;break;case 2:p=l.coinType;break;case 3:p=l.accountId;break;case 4:p=l.change;break;case 5:p=l.addressIndex;break;default:throw Error("Invalid Path, only support 1 to 5 depth path")}const h=p.isHardened?p.value+e.HARDENED_OFFSET:null==p?void 0:p.value;return d.writeUInt32BE(h,9),u.copy(d,13),n.copy(d,45),17===(null===(i=l.coinType)||void 0===i?void 0:i.value)?c.encode(d):s.encode(d)};const s=new t.bs58Check((function(e){const t=(0,r.sha256)().update(e).digest();return Buffer.from((0,r.sha256)().update(t).digest())})),c=new t.bs58Check((function(e){return Buffer.from(u.groestl_2(e,1,1))}));
{
"name": "@secux/utility",
"version": "2.0.6",
"version": "3.0.0",
"description": "SecuX Hardware Wallet internal tools for SDK",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc