@onekeyfe/hd-core 1.1.16-alpha.5 → 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,IAwFxE,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
@@ -28063,12 +28063,25 @@ const validateParams = (values, fields) => {
28063
28063
  throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
28064
28064
  }
28065
28065
  break;
28066
- case 'buffer':
28067
- if (typeof value === 'undefined' ||
28068
- (typeof value.constructor.isBuffer === 'function' && value.constructor.isBuffer(value))) {
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
+ }
28070
+ const isNodeBuffer = typeof Buffer !== 'undefined' &&
28071
+ typeof Buffer.isBuffer === 'function' &&
28072
+ Buffer.isBuffer(value);
28073
+ const isCustomBuffer = value.constructor &&
28074
+ typeof value.constructor.isBuffer === 'function' &&
28075
+ value.constructor.isBuffer(value);
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) {
28069
28081
  throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [buffer].`);
28070
28082
  }
28071
28083
  break;
28084
+ }
28072
28085
  case 'hexString':
28073
28086
  if (typeof value !== 'string' || !isHexString(addHexPrefix(value))) {
28074
28087
  throw invalidParameter(`Parameter [${field.name}] is of type invalid and should be [${field.type}].`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.1.16-alpha.5",
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.5",
29
- "@onekeyfe/hd-transport": "1.1.16-alpha.5",
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": "336159b5671671a7ff3d741af6d27f53094a0f37"
49
+ "gitHead": "9958a3e9b7de4c270a0fe57cd100ff4b02b6243a"
50
50
  }
@@ -83,16 +83,33 @@ export const validateParams = (values: any, fields: Array<SchemaParam>): void =>
83
83
  }
84
84
  break;
85
85
 
86
- case 'buffer':
87
- if (
88
- typeof value === 'undefined' ||
89
- (typeof value.constructor.isBuffer === 'function' && value.constructor.isBuffer(value))
90
- ) {
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
+ }
92
+ const isNodeBuffer =
93
+ typeof Buffer !== 'undefined' &&
94
+ typeof Buffer.isBuffer === 'function' &&
95
+ Buffer.isBuffer(value);
96
+ const isCustomBuffer =
97
+ value.constructor &&
98
+ typeof value.constructor.isBuffer === 'function' &&
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);
105
+
106
+ if (!isNodeBuffer && !isCustomBuffer && !isArrayBuffer && !isArrayBufferView) {
91
107
  throw invalidParameter(
92
108
  `Parameter [${field.name}] is of type invalid and should be [buffer].`
93
109
  );
94
110
  }
95
111
  break;
112
+ }
96
113
 
97
114
  case 'hexString':
98
115
  if (typeof value !== 'string' || !isHexString(addHexPrefix(value))) {