@secux/utility
Advanced tools
Comparing version 3.0.5 to 3.0.6
/// <reference types="node" /> | ||
export declare const toCommunicationData: ((data: Buffer) => Buffer) | ((data: Buffer) => string); | ||
export declare function wrapResult(data: any): any; | ||
export declare function Send(cla: number, ins: number, p1?: number, p2?: number, data?: Buffer): communicationData; | ||
@@ -4,0 +5,0 @@ export declare function toAPDUResponse(rsp: Buffer): { |
@@ -1,1 +0,1 @@ | ||
"use strict";var t,e,r,o,s=this&&this.__classPrivateFieldSet||function(t,e,r,o,s){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?s.call(t,r):s?s.value=r:e.set(t,r),r},a=this&&this.__classPrivateFieldGet||function(t,e,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(t):o?o.value:e.get(t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StatusCode=exports.ow_communicationData=exports.ow_base64String=exports.base64_regexp=exports.TransportStatusError=exports.to_L1_APDU=exports.getBuffer=exports.toAPDUResponse=exports.Send=exports.toCommunicationData=void 0;const n=require("ow"),i=require("./utility"),u=null===i.Logger||void 0===i.Logger?void 0:i.Logger.child({id:"protocol"}),f="service"===process.env.SECUX_PLATFROM;function c(t){return"string"==typeof t?Buffer.from(t,"base64"):t}exports.toCommunicationData=f?t=>t.toString("base64"):t=>t,exports.Send=function(t,e,r=0,o=0,s=Buffer.alloc(0)){const a=Buffer.alloc(2);a.writeUInt16LE(s.length,0);const n=Buffer.concat([Buffer.from([t,e,r,o]),a,s,Buffer.alloc(2),Buffer.from([0,0,0,0])]);return null==u||u.debug(`send data: ${n.toString("hex")}`),(0,exports.toCommunicationData)(n)},exports.toAPDUResponse=function(t){const e=t.readUInt16LE(0),r=t.readUInt16BE(2+e);if(e+6>t.length)throw null==u||u.warn(`Received data missing error: ${t.toString("hex")}`),Error(`Received data error: ${t.toString("hex")}`);return{data:t.slice(2,2+e),dataLength:e,status:r}},exports.getBuffer=c;const p=Buffer.from([248,2,0,0]);exports.to_L1_APDU=function(t){const e=c(t),r=Buffer.concat([p,e]);return(0,exports.toCommunicationData)(r)};class d extends Error{constructor(n){super(),t.set(this,"TransportStatusError"),e.set(this,void 0),r.set(this,void 0),o.set(this,void 0),s(this,o,n in l?l[n]:"UNKNOWN_ERROR","f"),s(this,r,n,"f"),s(this,e,`[SecuX device] ${a(this,o,"f")} (0x${n.toString(16)})`,"f")}get name(){return a(this,t,"f")}get message(){return a(this,e,"f")}get statusCode(){return a(this,r,"f")}get statusText(){return a(this,o,"f")}}var l;exports.TransportStatusError=d,t=new WeakMap,e=new WeakMap,r=new WeakMap,o=new WeakMap,exports.base64_regexp=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/,exports.ow_base64String=n.default.string.matches(exports.base64_regexp),exports.ow_communicationData=n.default.any(exports.ow_base64String,n.default.buffer),function(t){t[t.SUCCESS=36864]="SUCCESS",t[t.DATA_ERROR=20481]="DATA_ERROR",t[t.CLA_ERROR=20482]="CLA_ERROR",t[t.INS_ERROR=20483]="INS_ERROR"}(l=exports.StatusCode||(exports.StatusCode={})); | ||
"use strict";var t,e,r,o,s=this&&this.__classPrivateFieldSet||function(t,e,r,o,s){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?s.call(t,r):s?s.value=r:e.set(t,r),r},a=this&&this.__classPrivateFieldGet||function(t,e,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(t):o?o.value:e.get(t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.StatusCode=exports.ow_communicationData=exports.ow_base64String=exports.base64_regexp=exports.TransportStatusError=exports.to_L1_APDU=exports.getBuffer=exports.toAPDUResponse=exports.Send=exports.wrapResult=exports.toCommunicationData=void 0;const n=require("ow"),i=require("./utility"),u=null===i.Logger||void 0===i.Logger?void 0:i.Logger.child({id:"protocol"}),f="service"===process.env.SECUX_PLATFROM;function c(t){return"string"==typeof t?Buffer.from(t,"base64"):t}exports.toCommunicationData=f?t=>t.toString("base64"):t=>t,exports.wrapResult=function(t){return f?"object"!=typeof t?t:JSON.stringify(t):t},exports.Send=function(t,e,r=0,o=0,s=Buffer.alloc(0)){const a=Buffer.alloc(2);a.writeUInt16LE(s.length,0);const n=Buffer.concat([Buffer.from([t,e,r,o]),a,s,Buffer.alloc(2),Buffer.from([0,0,0,0])]);return null==u||u.debug(`send data: ${n.toString("hex")}`),(0,exports.toCommunicationData)(n)},exports.toAPDUResponse=function(t){const e=t.readUInt16LE(0),r=t.readUInt16BE(2+e);if(e+6>t.length)throw null==u||u.warn(`Received data missing error: ${t.toString("hex")}`),Error(`Received data error: ${t.toString("hex")}`);return{data:t.slice(2,2+e),dataLength:e,status:r}},exports.getBuffer=c;const p=Buffer.from([248,2,0,0]);exports.to_L1_APDU=function(t){const e=c(t),r=Buffer.concat([p,e]);return(0,exports.toCommunicationData)(r)};class d extends Error{constructor(n){super(),t.set(this,"TransportStatusError"),e.set(this,void 0),r.set(this,void 0),o.set(this,void 0),s(this,o,n in l?l[n]:"UNKNOWN_ERROR","f"),s(this,r,n,"f"),s(this,e,`[SecuX device] ${a(this,o,"f")} (0x${n.toString(16)})`,"f")}get name(){return a(this,t,"f")}get message(){return a(this,e,"f")}get statusCode(){return a(this,r,"f")}get statusText(){return a(this,o,"f")}}var l;exports.TransportStatusError=d,t=new WeakMap,e=new WeakMap,r=new WeakMap,o=new WeakMap,exports.base64_regexp=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/,exports.ow_base64String=n.default.string.matches(exports.base64_regexp),exports.ow_communicationData=n.default.any(exports.ow_base64String,n.default.buffer),function(t){t[t.SUCCESS=36864]="SUCCESS",t[t.DATA_ERROR=20481]="DATA_ERROR",t[t.CLA_ERROR=20482]="CLA_ERROR",t[t.INS_ERROR=20483]="INS_ERROR"}(l=exports.StatusCode||(exports.StatusCode={})); |
{ | ||
"name": "@secux/utility", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "SecuX Hardware Wallet internal tools for SDK", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25918
150