@ledgerhq/revault-sdk 0.21.1 → 0.21.3
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/bake.cjs +115 -58
- package/lib/bake.cjs.map +1 -1
- package/lib/bake.d.cts +271 -2502
- package/lib/bake.d.ts +271 -2502
- package/lib/bake.js +110 -53
- package/lib/bake.js.map +1 -1
- package/lib/{chunk-VMABO6WZ.js → chunk-7WN7G7BY.js} +4 -2
- package/lib/chunk-7WN7G7BY.js.map +1 -0
- package/lib/{chunk-PHC5IG6P.cjs → chunk-B5EUR3HT.cjs} +4 -2
- package/lib/chunk-B5EUR3HT.cjs.map +1 -0
- package/lib/device.cjs +2 -2
- package/lib/device.js +1 -1
- package/lib/engine.cjs +21 -21
- package/lib/engine.js +1 -1
- package/lib/onboarding.d.cts +345 -345
- package/lib/onboarding.d.ts +345 -345
- package/package.json +15 -15
- package/lib/chunk-PHC5IG6P.cjs.map +0 -1
- package/lib/chunk-VMABO6WZ.js.map +0 -1
package/lib/engine.cjs
CHANGED
|
@@ -14,7 +14,7 @@ var _chunkWVCYFF2Zcjs = require('./chunk-WVCYFF2Z.cjs');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
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 -
|
|
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
|
-
...
|
|
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 (
|
|
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
|
-
|
|
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(
|
|
115
|
+
await getPublicKey(_chunkB5EUR3HTcjs.PATHS.U2F, { secp256k1: true, retryOnError: noRetry });
|
|
116
116
|
return { isAppOpened: true };
|
|
117
117
|
} catch (err) {
|
|
118
|
-
if (
|
|
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 -
|
|
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(
|
|
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(
|
|
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(
|
|
214
|
+
getConfidentialityPubKey: () => getPublicKey(_chunkB5EUR3HTcjs.PATHS.CONFIDENTIALITY, { secp256k1: true }),
|
|
215
215
|
getDeviceUserId: FIXME_NOT_IMPLEMENTED("getDeviceUserId"),
|
|
216
|
-
getU2FPubKey: () => getPublicKey(
|
|
217
|
-
getValidationPubKey: () => getPublicKey(
|
|
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 -
|
|
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(
|
|
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(
|
|
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,
|
|
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(
|
|
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 ===
|
|
309
|
+
if (responseType === _chunkB5EUR3HTcjs.STREAMING_NEXT_ACTION) {
|
|
310
310
|
nextActionId = response.readUIntBE(1, 2);
|
|
311
|
-
} else if (responseType ===
|
|
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 =
|
|
429
|
+
const apiDevice = _chunkB5EUR3HTcjs.createApiDevice.call(void 0, options, logger);
|
|
430
430
|
const base = {
|
|
431
431
|
client,
|
|
432
432
|
createClient: (overrides) => createClient({ ...clientOptions, ...overrides })
|