@onekeyfe/hd-core 1.1.16-alpha.6 → 1.1.16-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"paramsValidator.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/paramsValidator.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EACD,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,WAAW,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAQF,eAAO,MAAM,cAAc,WAAY,GAAG,UAAU,MAAM,WAAW,CAAC,KAAG,IAgGxE,CAAC;AAEF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,GAAG,EACX,iBAAiB,EAAE,MAAM,EAAE,EAC3B,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC5C,QAwBF"}
1
+ {"version":3,"file":"paramsValidator.d.ts","sourceRoot":"","sources":["../../../src/api/helpers/paramsValidator.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EACD,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,MAAM,GACN,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,WAAW,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAQF,eAAO,MAAM,cAAc,WAAY,GAAG,UAAU,MAAM,WAAW,CAAC,KAAG,IAyGxE,CAAC;AAEF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,GAAG,EACX,iBAAiB,EAAE,MAAM,EAAE,EAC3B,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC5C,QAwBF"}
package/dist/index.js CHANGED
@@ -28064,14 +28064,20 @@ const validateParams = (values, fields) => {
28064
28064
  }
28065
28065
  break;
28066
28066
  case 'buffer': {
28067
+ if (typeof value === 'undefined' || value === null) {
28068
+ throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [buffer].`);
28069
+ }
28067
28070
  const isNodeBuffer = typeof Buffer !== 'undefined' &&
28068
28071
  typeof Buffer.isBuffer === 'function' &&
28069
28072
  Buffer.isBuffer(value);
28070
- const isCustomBuffer = value &&
28071
- value.constructor &&
28073
+ const isCustomBuffer = value.constructor &&
28072
28074
  typeof value.constructor.isBuffer === 'function' &&
28073
28075
  value.constructor.isBuffer(value);
28074
- if (!isNodeBuffer && !isCustomBuffer) {
28076
+ const isArrayBuffer = typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
28077
+ const isArrayBufferView = typeof ArrayBuffer !== 'undefined' &&
28078
+ typeof ArrayBuffer.isView === 'function' &&
28079
+ ArrayBuffer.isView(value);
28080
+ if (!isNodeBuffer && !isCustomBuffer && !isArrayBuffer && !isArrayBufferView) {
28075
28081
  throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [buffer].`);
28076
28082
  }
28077
28083
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.1.16-alpha.6",
3
+ "version": "1.1.16-alpha.7",
4
4
  "description": "Core processes and APIs for communicating with OneKey hardware devices.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "1.1.16-alpha.6",
29
- "@onekeyfe/hd-transport": "1.1.16-alpha.6",
28
+ "@onekeyfe/hd-shared": "1.1.16-alpha.7",
29
+ "@onekeyfe/hd-transport": "1.1.16-alpha.7",
30
30
  "axios": "1.12.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -46,5 +46,5 @@
46
46
  "@types/web-bluetooth": "^0.0.21",
47
47
  "ripple-keypairs": "^1.3.1"
48
48
  },
49
- "gitHead": "0cdb0ec713982b905789cdbab66f07bad8c8c11e"
49
+ "gitHead": "9958a3e9b7de4c270a0fe57cd100ff4b02b6243a"
50
50
  }
@@ -84,17 +84,26 @@ export const validateParams = (values: any, fields: Array<SchemaParam>): void =>
84
84
  break;
85
85
 
86
86
  case 'buffer': {
87
+ if (typeof value === 'undefined' || value === null) {
88
+ throw invalidParameter(
89
+ `Parameter [${field.name}] is of type invalid and should be [buffer].`
90
+ );
91
+ }
87
92
  const isNodeBuffer =
88
93
  typeof Buffer !== 'undefined' &&
89
94
  typeof Buffer.isBuffer === 'function' &&
90
95
  Buffer.isBuffer(value);
91
96
  const isCustomBuffer =
92
- value &&
93
97
  value.constructor &&
94
98
  typeof value.constructor.isBuffer === 'function' &&
95
99
  value.constructor.isBuffer(value);
100
+ const isArrayBuffer = typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
101
+ const isArrayBufferView =
102
+ typeof ArrayBuffer !== 'undefined' &&
103
+ typeof ArrayBuffer.isView === 'function' &&
104
+ ArrayBuffer.isView(value);
96
105
 
97
- if (!isNodeBuffer && !isCustomBuffer) {
106
+ if (!isNodeBuffer && !isCustomBuffer && !isArrayBuffer && !isArrayBufferView) {
98
107
  throw invalidParameter(
99
108
  `Parameter [${field.name}] is of type invalid and should be [buffer].`
100
109
  );