Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@secux/utility

Package Overview
Dependencies
Maintainers
1
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 3.0.17 to 3.0.18

1

lib/communication.d.ts

@@ -31,2 +31,3 @@ /*!

export declare function to_L1_APDU(data: communicationData): communicationData;
export declare function communicationWrapper(instance: object): any;
export declare class TransportStatusError extends Error {

@@ -33,0 +34,0 @@ #private;

2

lib/communication.js

@@ -18,2 +18,2 @@ "use strict";

limitations under the License.
*/var _TransportStatusError_name,_TransportStatusError_message,_TransportStatusError_statusCode,_TransportStatusError_statusText,_TransportStatusError_version,__classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(receiver,state,value,kind,f){if("m"===kind)throw new TypeError("Private method is not writable");if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===kind?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(receiver,state,kind,f){if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===kind?f:"a"===kind?f.call(receiver):f?f.value:state.get(receiver)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StatusCodeV2=exports.StatusCode=exports.ow_communicationData=exports.base64_regexp=exports.TransportStatusError=exports.to_L1_APDU=exports.getBuffer=exports.toAPDUResponse=exports.Send=exports.wrapResult=exports.toCommunicationData=exports.MAX_HEAD_SIZE=exports.ONESIGN_THRESHOLD=void 0;const ow_1=require("ow"),utility_1=require("./utility"),logger=null===utility_1.Logger||void 0===utility_1.Logger?void 0:utility_1.Logger.child({id:"protocol"}),SERVICE="service"===process.env.SECUX_PLATFROM;function getBuffer(data){return"string"==typeof data?Buffer.from(data,"base64"):data}exports.ONESIGN_THRESHOLD=4e3,exports.MAX_HEAD_SIZE=25,exports.toCommunicationData=SERVICE?data=>data.toString("base64"):data=>data,exports.wrapResult=function(data){return SERVICE?"object"!=typeof data?data:JSON.stringify(data):data},exports.Send=function(cla,ins,p1=0,p2=0,data=Buffer.alloc(0)){const dataLengthBuffer=Buffer.alloc(2);dataLengthBuffer.writeUInt16LE(data.length,0);const buf=Buffer.concat([Buffer.from([cla,ins,p1,p2]),dataLengthBuffer,data,Buffer.alloc(2),Buffer.from([0,0,0,0])]);return null==logger||logger.debug(`send data: ${buf.toString("hex")}`),(0,exports.toCommunicationData)(buf)},exports.toAPDUResponse=function(rsp){const dataLength=rsp.readUInt16LE(0),status=rsp.readUInt16BE(2+dataLength);if(dataLength+6>rsp.length)throw null==logger||logger.warn(`Received data missing error: ${rsp.toString("hex")}`),Error(`Received data error: ${rsp.toString("hex")}`);return{data:rsp.slice(2,2+dataLength),dataLength,status}},exports.getBuffer=getBuffer;const APDU_L1_PREFIX=Buffer.from([248,2,0,0]);exports.to_L1_APDU=function(data){const buf=getBuffer(data),apdu_L1=Buffer.concat([APDU_L1_PREFIX,buf]);return(0,exports.toCommunicationData)(apdu_L1)};class TransportStatusError extends Error{constructor(code,version=1){var _a;if(super(),_TransportStatusError_name.set(this,"TransportStatusError"),_TransportStatusError_message.set(this,void 0),_TransportStatusError_statusCode.set(this,void 0),_TransportStatusError_statusText.set(this,void 0),_TransportStatusError_version.set(this,void 0),__classPrivateFieldSet(this,_TransportStatusError_version,version,"f"),2===version)__classPrivateFieldSet(this,_TransportStatusError_statusText,StatusCodeV2[code],"f");else __classPrivateFieldSet(this,_TransportStatusError_statusText,StatusCode[code],"f");__classPrivateFieldSet(this,_TransportStatusError_statusText,null!==(_a=__classPrivateFieldGet(this,_TransportStatusError_statusText,"f"))&&void 0!==_a?_a:"UNKNOWN_ERROR","f"),__classPrivateFieldSet(this,_TransportStatusError_statusCode,code,"f"),__classPrivateFieldSet(this,_TransportStatusError_message,`[SecuX device] ${__classPrivateFieldGet(this,_TransportStatusError_statusText,"f")} (0x${code.toString(16)})`,"f")}get name(){return __classPrivateFieldGet(this,_TransportStatusError_name,"f")}get message(){return __classPrivateFieldGet(this,_TransportStatusError_message,"f")}get statusCode(){return __classPrivateFieldGet(this,_TransportStatusError_statusCode,"f")}get statusText(){return __classPrivateFieldGet(this,_TransportStatusError_statusText,"f")}get version(){return __classPrivateFieldGet(this,_TransportStatusError_version,"f")}}var StatusCode,StatusCodeV2;exports.TransportStatusError=TransportStatusError,_TransportStatusError_name=new WeakMap,_TransportStatusError_message=new WeakMap,_TransportStatusError_statusCode=new WeakMap,_TransportStatusError_statusText=new WeakMap,_TransportStatusError_version=new WeakMap,exports.base64_regexp=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/,exports.ow_communicationData=ow_1.default.any(utility_1.owTool.base64String,ow_1.default.buffer),function(StatusCode){StatusCode[StatusCode.SUCCESS=36864]="SUCCESS",StatusCode[StatusCode.USER_CANCEL=36865]="USER_CANCEL",StatusCode[StatusCode.DATA_ERROR=20481]="DATA_ERROR",StatusCode[StatusCode.CLA_ERROR=20482]="CLA_ERROR",StatusCode[StatusCode.INS_ERROR=20483]="INS_ERROR"}(StatusCode=exports.StatusCode||(exports.StatusCode={})),function(StatusCodeV2){StatusCodeV2[StatusCodeV2.OK=0]="OK",StatusCodeV2[StatusCodeV2.NO_LEADING_PACKET=1]="NO_LEADING_PACKET",StatusCodeV2[StatusCodeV2.COMMAND_OVERLAY=2]="COMMAND_OVERLAY",StatusCodeV2[StatusCodeV2.INVALID_COMMAND=3]="INVALID_COMMAND",StatusCodeV2[StatusCodeV2.INCORRENT_PARAMETER_SIZE=4]="INCORRENT_PARAMETER_SIZE",StatusCodeV2[StatusCodeV2.INVALID_PARAMETER_VALUE=5]="INVALID_PARAMETER_VALUE",StatusCodeV2[StatusCodeV2.NOT_FOUND=6]="NOT_FOUND",StatusCodeV2[StatusCodeV2.ALREADY_EXIST=7]="ALREADY_EXIST",StatusCodeV2[StatusCodeV2.IO_ERROR=8]="IO_ERROR",StatusCodeV2[StatusCodeV2.NOT_SUPPORT=9]="NOT_SUPPORT"}(StatusCodeV2=exports.StatusCodeV2||(exports.StatusCodeV2={}));
*/var _TransportStatusError_name,_TransportStatusError_message,_TransportStatusError_statusCode,_TransportStatusError_statusText,_TransportStatusError_version,__classPrivateFieldSet=this&&this.__classPrivateFieldSet||function(receiver,state,value,kind,f){if("m"===kind)throw new TypeError("Private method is not writable");if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===kind?f.call(receiver,value):f?f.value=value:state.set(receiver,value),value},__classPrivateFieldGet=this&&this.__classPrivateFieldGet||function(receiver,state,kind,f){if("a"===kind&&!f)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof state?receiver!==state||!f:!state.has(receiver))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===kind?f:"a"===kind?f.call(receiver):f?f.value:state.get(receiver)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StatusCodeV2=exports.StatusCode=exports.ow_communicationData=exports.base64_regexp=exports.TransportStatusError=exports.communicationWrapper=exports.to_L1_APDU=exports.getBuffer=exports.toAPDUResponse=exports.Send=exports.wrapResult=exports.toCommunicationData=exports.MAX_HEAD_SIZE=exports.ONESIGN_THRESHOLD=void 0;const ow_1=require("ow"),utility_1=require("./utility"),logger=null===utility_1.Logger||void 0===utility_1.Logger?void 0:utility_1.Logger.child({id:"protocol"}),SERVICE="service"===process.env.SECUX_PLATFROM;function getBuffer(data){return"string"==typeof data?Buffer.from(data,"base64"):data}exports.ONESIGN_THRESHOLD=4e3,exports.MAX_HEAD_SIZE=25,exports.toCommunicationData=SERVICE?data=>data.toString("base64"):data=>data,exports.wrapResult=function(data){return SERVICE?"object"!=typeof data?data:JSON.stringify(data):data},exports.Send=function(cla,ins,p1=0,p2=0,data=Buffer.alloc(0)){const dataLengthBuffer=Buffer.alloc(2);dataLengthBuffer.writeUInt16LE(data.length,0);const buf=Buffer.concat([Buffer.from([cla,ins,p1,p2]),dataLengthBuffer,data,Buffer.alloc(2),Buffer.from([0,0,0,0])]);return null==logger||logger.debug(`send data: ${buf.toString("hex")}`),(0,exports.toCommunicationData)(buf)},exports.toAPDUResponse=function(rsp){const dataLength=rsp.readUInt16LE(0),status=rsp.readUInt16BE(2+dataLength);if(dataLength+6>rsp.length)throw null==logger||logger.warn(`Received data missing error: ${rsp.toString("hex")}`),Error(`Received data error: ${rsp.toString("hex")}`);return{data:rsp.slice(2,2+dataLength),dataLength,status}},exports.getBuffer=getBuffer;const APDU_L1_PREFIX=Buffer.from([248,2,0,0]);exports.to_L1_APDU=function(data){const buf=getBuffer(data),apdu_L1=Buffer.concat([APDU_L1_PREFIX,buf]);return(0,exports.toCommunicationData)(apdu_L1)},exports.communicationWrapper=function(instance){const valueHandler=function(value){return Buffer.isBuffer(value)?value.toString("base64"):"object"==typeof value?JSON.stringify(value):value};return new Proxy(instance,{get(target,prop){const value=target[prop];return"function"==typeof value?function(...args){const execResult=value.apply(target,args);return execResult instanceof Promise?execResult.then((a=>valueHandler(a))):valueHandler(execResult)}:valueHandler(value)}})};class TransportStatusError extends Error{constructor(code,version=1){var _a;if(super(),_TransportStatusError_name.set(this,"TransportStatusError"),_TransportStatusError_message.set(this,void 0),_TransportStatusError_statusCode.set(this,void 0),_TransportStatusError_statusText.set(this,void 0),_TransportStatusError_version.set(this,void 0),__classPrivateFieldSet(this,_TransportStatusError_version,version,"f"),2===version)__classPrivateFieldSet(this,_TransportStatusError_statusText,StatusCodeV2[code],"f");else __classPrivateFieldSet(this,_TransportStatusError_statusText,StatusCode[code],"f");__classPrivateFieldSet(this,_TransportStatusError_statusText,null!==(_a=__classPrivateFieldGet(this,_TransportStatusError_statusText,"f"))&&void 0!==_a?_a:"UNKNOWN_ERROR","f"),__classPrivateFieldSet(this,_TransportStatusError_statusCode,code,"f"),__classPrivateFieldSet(this,_TransportStatusError_message,`[SecuX device] ${__classPrivateFieldGet(this,_TransportStatusError_statusText,"f")} (0x${code.toString(16)})`,"f")}get name(){return __classPrivateFieldGet(this,_TransportStatusError_name,"f")}get message(){return __classPrivateFieldGet(this,_TransportStatusError_message,"f")}get statusCode(){return __classPrivateFieldGet(this,_TransportStatusError_statusCode,"f")}get statusText(){return __classPrivateFieldGet(this,_TransportStatusError_statusText,"f")}get version(){return __classPrivateFieldGet(this,_TransportStatusError_version,"f")}}var StatusCode,StatusCodeV2;exports.TransportStatusError=TransportStatusError,_TransportStatusError_name=new WeakMap,_TransportStatusError_message=new WeakMap,_TransportStatusError_statusCode=new WeakMap,_TransportStatusError_statusText=new WeakMap,_TransportStatusError_version=new WeakMap,exports.base64_regexp=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/,exports.ow_communicationData=ow_1.default.any(utility_1.owTool.base64String,ow_1.default.buffer),function(StatusCode){StatusCode[StatusCode.SUCCESS=36864]="SUCCESS",StatusCode[StatusCode.USER_CANCEL=36865]="USER_CANCEL",StatusCode[StatusCode.DATA_ERROR=20481]="DATA_ERROR",StatusCode[StatusCode.CLA_ERROR=20482]="CLA_ERROR",StatusCode[StatusCode.INS_ERROR=20483]="INS_ERROR"}(StatusCode=exports.StatusCode||(exports.StatusCode={})),function(StatusCodeV2){StatusCodeV2[StatusCodeV2.OK=0]="OK",StatusCodeV2[StatusCodeV2.NO_LEADING_PACKET=1]="NO_LEADING_PACKET",StatusCodeV2[StatusCodeV2.COMMAND_OVERLAY=2]="COMMAND_OVERLAY",StatusCodeV2[StatusCodeV2.INVALID_COMMAND=3]="INVALID_COMMAND",StatusCodeV2[StatusCodeV2.INCORRENT_PARAMETER_SIZE=4]="INCORRENT_PARAMETER_SIZE",StatusCodeV2[StatusCodeV2.INVALID_PARAMETER_VALUE=5]="INVALID_PARAMETER_VALUE",StatusCodeV2[StatusCodeV2.NOT_FOUND=6]="NOT_FOUND",StatusCodeV2[StatusCodeV2.ALREADY_EXIST=7]="ALREADY_EXIST",StatusCodeV2[StatusCodeV2.IO_ERROR=8]="IO_ERROR",StatusCodeV2[StatusCodeV2.NOT_SUPPORT=9]="NOT_SUPPORT"}(StatusCodeV2=exports.StatusCodeV2||(exports.StatusCodeV2={}));

@@ -18,2 +18,2 @@ "use strict";

limitations under the License.
*/Object.defineProperty(exports,"__esModule",{value:!0}),exports.recidFromSignature=exports.validate=void 0;const elliptic_1=require("elliptic"),BN=require("bn.js");exports.validate=function(pubkey){const key=new elliptic_1.ec("secp256k1").keyFromPublic(pubkey),{result,reason}=key.validate();return reason&&console.warn(reason),result},exports.recidFromSignature=function(payload,publicKey,signature){const secp256k1=new elliptic_1.ec("secp256k1"),n=secp256k1.curve.n,G=secp256k1.curve.g,Q=secp256k1.curve.decodePoint(publicKey),r=new BN(signature.slice(0,32)),s=new BN(signature.slice(32,64)),e=new BN(payload),sInv=s.invm(n),u1=e.mul(sInv).umod(n),u2=r.mul(sInv).umod(n),R=G.mulAdd(u1,Q,u2),isOddY=R.y.isOdd();return+(R.x.cmp(n)>=0)<<1|+isOddY<<0};
*/Object.defineProperty(exports,"__esModule",{value:!0}),exports.recidFromSignature=exports.validate=void 0;const elliptic_1=require("elliptic"),BN=require("bn.js");exports.validate=function(pubkey){const key=new elliptic_1.ec("secp256k1").keyFromPublic(pubkey),{result,reason}=key.validate();return reason&&console.warn(reason),result},exports.recidFromSignature=function(payload,publicKey,signature){const secp256k1=new elliptic_1.ec("secp256k1"),n=secp256k1.curve.n,G=secp256k1.curve.g,Q=secp256k1.curve.decodePoint(publicKey),r=new BN(signature.slice(0,32)),s=new BN(signature.slice(32,64)),e=new BN(payload),sInv=s.invm(n),u1=e.mul(sInv).umod(n),u2=r.mul(sInv).umod(n),R=G.mulAdd(u1,Q,u2),isOddY=R.y.isOdd();return+(R.x.cmp(n)>=0)<<1|+isOddY};
{
"name": "@secux/utility",
"version": "3.0.17",
"version": "3.0.18",
"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