@ledgerhq/revault-sdk 0.21.2 → 0.21.4

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.
package/lib/device.cjs CHANGED
@@ -3,11 +3,11 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkPHC5IG6Pcjs = require('./chunk-PHC5IG6P.cjs');
6
+ var _chunkB5EUR3HTcjs = require('./chunk-B5EUR3HT.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
11
 
12
- exports.createApiDevice = _chunkPHC5IG6Pcjs.createApiDevice; exports.isDeviceCancelError = _chunkPHC5IG6Pcjs.isDeviceCancelError; exports.isTransportStatusError = _chunkPHC5IG6Pcjs.isTransportStatusError; exports.registerTransportModule = _chunkPHC5IG6Pcjs.registerTransportModule;
12
+ exports.createApiDevice = _chunkB5EUR3HTcjs.createApiDevice; exports.isDeviceCancelError = _chunkB5EUR3HTcjs.isDeviceCancelError; exports.isTransportStatusError = _chunkB5EUR3HTcjs.isTransportStatusError; exports.registerTransportModule = _chunkB5EUR3HTcjs.registerTransportModule;
13
13
  //# sourceMappingURL=device.cjs.map
package/lib/device.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  isDeviceCancelError,
4
4
  isTransportStatusError,
5
5
  registerTransportModule
6
- } from "./chunk-VMABO6WZ.js";
6
+ } from "./chunk-7WN7G7BY.js";
7
7
  export {
8
8
  createApiDevice,
9
9
  isDeviceCancelError,
package/lib/engine.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkWVCYFF2Zcjs = require('./chunk-WVCYFF2Z.cjs');
4
+ var _chunkI6B5U4JRcjs = require('./chunk-I6B5U4JR.cjs');
5
5
 
6
6
 
7
7
 
@@ -14,7 +14,7 @@ var _chunkWVCYFF2Zcjs = require('./chunk-WVCYFF2Z.cjs');
14
14
 
15
15
 
16
16
 
17
- var _chunkPHC5IG6Pcjs = require('./chunk-PHC5IG6P.cjs');
17
+ var _chunkB5EUR3HTcjs = require('./chunk-B5EUR3HT.cjs');
18
18
 
19
19
  // src/engine/index.ts
20
20
  var _invariant = require('invariant'); var _invariant2 = _interopRequireDefault(_invariant);
@@ -38,7 +38,7 @@ var splitChunks = (chunk, buffer) => {
38
38
  }
39
39
  return chunks;
40
40
  };
41
- var removeStatus = (result) => result.slice(0, result.length - _chunkPHC5IG6Pcjs.STATUS_LENGTH);
41
+ var removeStatus = (result) => result.slice(0, result.length - _chunkB5EUR3HTcjs.STATUS_LENGTH);
42
42
  var sendByChunk = async (transport, command, data, chunkSize = MAX_CHUNK_LENGTH) => {
43
43
  const chunks = splitChunks(chunkSize, data);
44
44
  let response = Buffer.from([]);
@@ -48,7 +48,7 @@ var sendByChunk = async (transport, command, data, chunkSize = MAX_CHUNK_LENGTH)
48
48
  apdu[2] = i && 128;
49
49
  response = await transport.send(apdu[0], apdu[1], apdu[2], apdu[3], chunk, [
50
50
  36864,
51
- ..._chunkPHC5IG6Pcjs.PAGINATED_STATUS
51
+ ..._chunkB5EUR3HTcjs.PAGINATED_STATUS
52
52
  ]);
53
53
  }
54
54
  return response;
@@ -91,7 +91,7 @@ var buildAttestation = (params) => {
91
91
  };
92
92
  var genericRetryOnError = (err) => {
93
93
  if (err instanceof _errors.LockedDeviceError) return true;
94
- if (_chunkPHC5IG6Pcjs.isTransportStatusError.call(void 0, err) && err.statusCode === 27913) return true;
94
+ if (_chunkB5EUR3HTcjs.isTransportStatusError.call(void 0, err) && err.statusCode === 27913) return true;
95
95
  if (err instanceof _errors.DisconnectedDevice) return true;
96
96
  return false;
97
97
  };
@@ -99,7 +99,7 @@ function createRealDevice(options, logger) {
99
99
  const { transportId } = options;
100
100
  async function run(job, retryOnError = genericRetryOnError) {
101
101
  return _rxjs.lastValueFrom.call(void 0,
102
- _chunkPHC5IG6Pcjs.withDevicePolling.call(void 0, transportId)((transport) => _rxjs.from.call(void 0, job(transport)), retryOnError)
102
+ _chunkB5EUR3HTcjs.withDevicePolling.call(void 0, transportId)((transport) => _rxjs.from.call(void 0, job(transport)), retryOnError)
103
103
  );
104
104
  }
105
105
  const noRetry = () => false;
@@ -112,10 +112,10 @@ function createRealDevice(options, logger) {
112
112
  _nullishCoalesce(opts.retryOnError, () => ( alwaysRetry))
113
113
  );
114
114
  try {
115
- await getPublicKey(_chunkPHC5IG6Pcjs.PATHS.U2F, { secp256k1: true, retryOnError: noRetry });
115
+ await getPublicKey(_chunkB5EUR3HTcjs.PATHS.U2F, { secp256k1: true, retryOnError: noRetry });
116
116
  return { isAppOpened: true };
117
117
  } catch (err) {
118
- if (_chunkPHC5IG6Pcjs.isTransportStatusError.call(void 0, err) && genericRetryOnError(err)) {
118
+ if (_chunkB5EUR3HTcjs.isTransportStatusError.call(void 0, err) && genericRetryOnError(err)) {
119
119
  return { isAppOpened: false };
120
120
  }
121
121
  throw err;
@@ -146,18 +146,18 @@ function createRealDevice(options, logger) {
146
146
  );
147
147
  const pubKeyLength = response.readInt8(0);
148
148
  const pubKey = response.slice(1, pubKeyLength + 1).toString("hex").toUpperCase();
149
- const signature = response.slice(pubKeyLength + 1, response.length - _chunkPHC5IG6Pcjs.STATUS_LENGTH).toString("base64");
149
+ const signature = response.slice(pubKeyLength + 1, response.length - _chunkB5EUR3HTcjs.STATUS_LENGTH).toString("base64");
150
150
  return { pubKey, signature };
151
151
  };
152
152
  const device = {
153
153
  authenticate: async ({ challenge: { challenge, name, role, keyHandle }, workspaceName }) => {
154
154
  logger.info(`[device] Authenticate`);
155
155
  _invariant2.default.call(void 0, role !== "READ_ONLY_API_KEY", "Invalid role for authenticate: READ_ONLY_API_KEY");
156
- const applicationBuffer = Buffer.from(_chunkPHC5IG6Pcjs.APPID_VAULT_ADMINISTRATOR, "hex");
156
+ const applicationBuffer = Buffer.from(_chunkB5EUR3HTcjs.APPID_VAULT_ADMINISTRATOR, "hex");
157
157
  const nameBuffer = Buffer.from(name);
158
158
  const workspaceBuffer = Buffer.from(workspaceName);
159
159
  const keyHandleData = Buffer.concat([
160
- Buffer.from(_chunkPHC5IG6Pcjs.STR_ROLES[role], "hex"),
160
+ Buffer.from(_chunkB5EUR3HTcjs.STR_ROLES[role], "hex"),
161
161
  Buffer.from([nameBuffer.length]),
162
162
  nameBuffer,
163
163
  Buffer.from([workspaceBuffer.length]),
@@ -211,10 +211,10 @@ function createRealDevice(options, logger) {
211
211
  confidentialityKeySignature: sig.toString("hex")
212
212
  };
213
213
  },
214
- getConfidentialityPubKey: () => getPublicKey(_chunkPHC5IG6Pcjs.PATHS.CONFIDENTIALITY, { secp256k1: true }),
214
+ getConfidentialityPubKey: () => getPublicKey(_chunkB5EUR3HTcjs.PATHS.CONFIDENTIALITY, { secp256k1: true }),
215
215
  getDeviceUserId: FIXME_NOT_IMPLEMENTED("getDeviceUserId"),
216
- getU2FPubKey: () => getPublicKey(_chunkPHC5IG6Pcjs.PATHS.U2F, { secp256k1: false }),
217
- getValidationPubKey: () => getPublicKey(_chunkPHC5IG6Pcjs.PATHS.VALIDATION, { secp256k1: true }),
216
+ getU2FPubKey: () => getPublicKey(_chunkB5EUR3HTcjs.PATHS.U2F, { secp256k1: false }),
217
+ getValidationPubKey: () => getPublicKey(_chunkB5EUR3HTcjs.PATHS.VALIDATION, { secp256k1: true }),
218
218
  hasPairing: async () => {
219
219
  logger.info(`[device] hasPairing`);
220
220
  const apdu = [224, 81, 0, 0, 181];
@@ -226,7 +226,7 @@ function createRealDevice(options, logger) {
226
226
  const res = await run((transport) => transport.send(224, 70, 0, 0));
227
227
  const pubKeyLength = res.readInt8(0);
228
228
  const pubKey = res.slice(1, pubKeyLength + 1).toString("hex").toUpperCase();
229
- const signature = res.slice(pubKeyLength + 1, res.length - _chunkPHC5IG6Pcjs.STATUS_LENGTH).toString("base64");
229
+ const signature = res.slice(pubKeyLength + 1, res.length - _chunkB5EUR3HTcjs.STATUS_LENGTH).toString("base64");
230
230
  return { pubKey, signature };
231
231
  },
232
232
  openSession: FIXME_NOT_IMPLEMENTED("openSession"),
@@ -234,11 +234,11 @@ function createRealDevice(options, logger) {
234
234
  const { challenge: strChallenge, u2fRegisterData: _, name, role } = params;
235
235
  const challenge = Buffer.from(strChallenge, "hex");
236
236
  _invariant2.default.call(void 0, challenge.length === 32, "challenge hex is expected to have 32 bytes");
237
- const applicationBuf = Buffer.from(_chunkPHC5IG6Pcjs.APPID_VAULT_ADMINISTRATOR, "hex");
237
+ const applicationBuf = Buffer.from(_chunkB5EUR3HTcjs.APPID_VAULT_ADMINISTRATOR, "hex");
238
238
  _invariant2.default.call(void 0, applicationBuf.length === 32, "application hex is expected to have 32 bytes");
239
239
  const userNameBuff = Buffer.from(name);
240
240
  const keyHandleData = Buffer.concat([
241
- Buffer.from(_chunkPHC5IG6Pcjs.STR_ROLES[role], "hex"),
241
+ Buffer.from(_chunkB5EUR3HTcjs.STR_ROLES[role], "hex"),
242
242
  Buffer.from([userNameBuff.length]),
243
243
  userNameBuff
244
244
  ]);
@@ -280,12 +280,12 @@ function createRealDevice(options, logger) {
280
280
  logger.info(`[device] startKPatternAsResponder`);
281
281
  const data = buildAttestation(params);
282
282
  await run(
283
- (transport) => sendByChunk(transport, [224, 73, 0, _chunkPHC5IG6Pcjs.SCRIPT_IDS.ACCOUNT_MANAGER_SESSION], data)
283
+ (transport) => sendByChunk(transport, [224, 73, 0, _chunkB5EUR3HTcjs.SCRIPT_IDS.ACCOUNT_MANAGER_SESSION], data)
284
284
  );
285
285
  },
286
286
  validateVaultOperation: async (params) => {
287
287
  logger.info(`[device] validateVaultOperation`);
288
- const path = getPathFromPathString(_chunkPHC5IG6Pcjs.PATHS.VALIDATION);
288
+ const path = getPathFromPathString(_chunkB5EUR3HTcjs.PATHS.VALIDATION);
289
289
  const paths = Buffer.concat([
290
290
  Buffer.from([path.length]),
291
291
  ...path.map((derivation) => {
@@ -306,9 +306,9 @@ function createRealDevice(options, logger) {
306
306
  );
307
307
  const responseType = response.readInt8(0);
308
308
  let responseStatus = response.readUInt16BE(response.length - 2);
309
- if (responseType === _chunkPHC5IG6Pcjs.STREAMING_NEXT_ACTION) {
309
+ if (responseType === _chunkB5EUR3HTcjs.STREAMING_NEXT_ACTION) {
310
310
  nextActionId = response.readUIntBE(1, 2);
311
- } else if (responseType === _chunkPHC5IG6Pcjs.STREAMING_RESPONSE) {
311
+ } else if (responseType === _chunkB5EUR3HTcjs.STREAMING_RESPONSE) {
312
312
  finalResponse = response.slice(3, response.length - 2);
313
313
  while (responseStatus !== 36864) {
314
314
  const resp = await run((transport) => transport.send(0, 192, 0, 0));
@@ -426,7 +426,7 @@ function createEngine(options, logger) {
426
426
  baseUrl: options.baseUrl
427
427
  };
428
428
  const client = createClient(clientOptions);
429
- const apiDevice = _chunkPHC5IG6Pcjs.createApiDevice.call(void 0, options, logger);
429
+ const apiDevice = _chunkB5EUR3HTcjs.createApiDevice.call(void 0, options, logger);
430
430
  const base = {
431
431
  client,
432
432
  createClient: (overrides) => createClient({ ...clientOptions, ...overrides })
@@ -770,5 +770,5 @@ function createEngine(options, logger) {
770
770
 
771
771
 
772
772
 
773
- exports.createEngine = createEngine; exports.fetchAll = _chunkWVCYFF2Zcjs.fetchAll; exports.fetchAllCursor = _chunkWVCYFF2Zcjs.fetchAllCursor;
773
+ exports.createEngine = createEngine; exports.fetchAll = _chunkI6B5U4JRcjs.fetchAll; exports.fetchAllCursor = _chunkI6B5U4JRcjs.fetchAllCursor;
774
774
  //# sourceMappingURL=engine.cjs.map
package/lib/engine.d.cts CHANGED
@@ -17,7 +17,7 @@ declare function fetchAll<TData, TQuery extends {
17
17
  * Utility function that collect results on all cursors until cursor is null
18
18
  */
19
19
  declare function fetchAllCursor<TData, TQuery extends {
20
- cursor?: number;
20
+ cursor?: number | string;
21
21
  }>(queryFn: (query: TQuery) => Promise<CursorPaginated<TData>>, query: TQuery): Promise<TData[]>;
22
22
 
23
23
  declare function createEngine(options: EngineOptions, logger: Logger): Engine;
package/lib/engine.d.ts CHANGED
@@ -17,7 +17,7 @@ declare function fetchAll<TData, TQuery extends {
17
17
  * Utility function that collect results on all cursors until cursor is null
18
18
  */
19
19
  declare function fetchAllCursor<TData, TQuery extends {
20
- cursor?: number;
20
+ cursor?: number | string;
21
21
  }>(queryFn: (query: TQuery) => Promise<CursorPaginated<TData>>, query: TQuery): Promise<TData[]>;
22
22
 
23
23
  declare function createEngine(options: EngineOptions, logger: Logger): Engine;
package/lib/engine.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  fetchAll,
3
3
  fetchAllCursor
4
- } from "./chunk-PEHCVOGV.js";
4
+ } from "./chunk-IHGVWOD7.js";
5
5
  import {
6
6
  APPID_VAULT_ADMINISTRATOR,
7
7
  PAGINATED_STATUS,
@@ -14,7 +14,7 @@ import {
14
14
  createApiDevice,
15
15
  isTransportStatusError,
16
16
  withDevicePolling
17
- } from "./chunk-VMABO6WZ.js";
17
+ } from "./chunk-7WN7G7BY.js";
18
18
 
19
19
  // src/engine/index.ts
20
20
  import invariant2 from "invariant";