@ledgerhq/revault-sdk 0.25.0 → 0.25.1

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.
Files changed (88) hide show
  1. package/lib/bake.cjs +1214 -1359
  2. package/lib/bake.cjs.map +1 -1
  3. package/lib/bake.d.cts +564 -562
  4. package/lib/bake.d.ts +564 -562
  5. package/lib/bake.js +1204 -1359
  6. package/lib/bake.js.map +1 -1
  7. package/lib/chunk-CKQMccvm.cjs +28 -0
  8. package/lib/crypto-BDBF_rfw.cjs +268 -0
  9. package/lib/crypto-BDBF_rfw.cjs.map +1 -0
  10. package/lib/crypto-CPCBrCSZ.js +245 -0
  11. package/lib/crypto-CPCBrCSZ.js.map +1 -0
  12. package/lib/crypto.cjs +5 -11
  13. package/lib/crypto.d.cts +10 -7
  14. package/lib/crypto.d.ts +10 -7
  15. package/lib/crypto.js +2 -11
  16. package/lib/device-0lcfYGHr.cjs +793 -0
  17. package/lib/device-0lcfYGHr.cjs.map +1 -0
  18. package/lib/device-B8Fww8_6.js +719 -0
  19. package/lib/device-B8Fww8_6.js.map +1 -0
  20. package/lib/device.cjs +6 -13
  21. package/lib/device.d.cts +2 -50
  22. package/lib/device.d.ts +2 -50
  23. package/lib/device.js +2 -13
  24. package/lib/engine.cjs +835 -886
  25. package/lib/engine.cjs.map +1 -1
  26. package/lib/engine.d.cts +3 -25
  27. package/lib/engine.d.ts +3 -25
  28. package/lib/engine.js +828 -885
  29. package/lib/engine.js.map +1 -1
  30. package/lib/index--fscLDTT.d.ts +237 -0
  31. package/lib/index-BE7oUpCb.d.cts +237 -0
  32. package/lib/index-C4Xjiv0k.d.cts +23 -0
  33. package/lib/index-CVjhPoZh.d.ts +23 -0
  34. package/lib/index.cjs +0 -1
  35. package/lib/index.d.cts +10 -5
  36. package/lib/index.d.ts +10 -5
  37. package/lib/index.js +1 -1
  38. package/lib/logger-Cme0iL1f.d.cts +10 -0
  39. package/lib/logger-DWLViq7U.d.ts +10 -0
  40. package/lib/onboarding.cjs +179 -181
  41. package/lib/onboarding.cjs.map +1 -1
  42. package/lib/onboarding.d.cts +1751 -1722
  43. package/lib/onboarding.d.ts +1751 -1722
  44. package/lib/onboarding.js +175 -181
  45. package/lib/onboarding.js.map +1 -1
  46. package/lib/trpc-CWGPr8Ox.d.ts +20 -0
  47. package/lib/trpc-C_dUOB1u.d.cts +20 -0
  48. package/lib/types-4CfR5--z.d.ts +203 -0
  49. package/lib/types-Byf9V35t.d.cts +203 -0
  50. package/lib/types-CQROu0nu.d.cts +6 -0
  51. package/lib/types-_QeBv1U4.d.ts +6 -0
  52. package/lib/types.cjs +0 -1
  53. package/lib/types.d.cts +3 -4
  54. package/lib/types.d.ts +3 -4
  55. package/lib/types.js +1 -1
  56. package/lib/utils-BGbdjOP9.js +61 -0
  57. package/lib/utils-BGbdjOP9.js.map +1 -0
  58. package/lib/utils-DbSFXp4c.cjs +86 -0
  59. package/lib/utils-DbSFXp4c.cjs.map +1 -0
  60. package/package.json +6 -6
  61. package/lib/chunk-2WGM7EWA.cjs +0 -282
  62. package/lib/chunk-2WGM7EWA.cjs.map +0 -1
  63. package/lib/chunk-AXI72NFY.js +0 -50
  64. package/lib/chunk-AXI72NFY.js.map +0 -1
  65. package/lib/chunk-DRMYBKL3.cjs +0 -820
  66. package/lib/chunk-DRMYBKL3.cjs.map +0 -1
  67. package/lib/chunk-KV5FO7N5.js +0 -282
  68. package/lib/chunk-KV5FO7N5.js.map +0 -1
  69. package/lib/chunk-LH4QQXUH.cjs +0 -50
  70. package/lib/chunk-LH4QQXUH.cjs.map +0 -1
  71. package/lib/chunk-PFZIW6UP.js +0 -820
  72. package/lib/chunk-PFZIW6UP.js.map +0 -1
  73. package/lib/crypto.cjs.map +0 -1
  74. package/lib/crypto.js.map +0 -1
  75. package/lib/device.cjs.map +0 -1
  76. package/lib/device.js.map +0 -1
  77. package/lib/index.cjs.map +0 -1
  78. package/lib/index.js.map +0 -1
  79. package/lib/logger-C-TPbnjv.d.cts +0 -9
  80. package/lib/logger-C-TPbnjv.d.ts +0 -9
  81. package/lib/types-C-ngtI5m.d.ts +0 -202
  82. package/lib/types-CpGEbAxh.d.cts +0 -19
  83. package/lib/types-CpGEbAxh.d.ts +0 -19
  84. package/lib/types-CryvY9pW.d.cts +0 -202
  85. package/lib/types-DJfbanPz.d.cts +0 -167
  86. package/lib/types-DJfbanPz.d.ts +0 -167
  87. package/lib/types.cjs.map +0 -1
  88. package/lib/types.js.map +0 -1
@@ -0,0 +1,237 @@
1
+ import { t as Logger } from "./logger-Cme0iL1f.cjs";
2
+ import { HsmCertificate, PsdAuthChallengeResponse, PsdPairingData, PubKey } from "@ledgerhq/revault-api";
3
+ import Transport from "@ledgerhq/hw-transport";
4
+ import { Observable } from "rxjs";
5
+
6
+ //#region src/device/types.d.ts
7
+ type Device = {
8
+ /**
9
+ * Authenticate (resolve challenge for login)
10
+ */
11
+ authenticate: (opts: {
12
+ challenge: PsdAuthChallengeResponse;
13
+ workspaceName: string;
14
+ }) => Promise<string>;
15
+ /**
16
+ * Finalize pairing
17
+ */
18
+ finalizePairingHandshake: (opts: {
19
+ handshake: string;
20
+ partitionId: string;
21
+ handshakeAttestation: HsmCertificate;
22
+ }) => Promise<string>;
23
+ /**
24
+ * Generate seed fragment from Shared-Owner device
25
+ */
26
+ generateSeedFragment: () => Promise<string>;
27
+ /**
28
+ * Generate Wrapping Key fragment from Wrapping-Key Owner device
29
+ */
30
+ generateWrappingKeyFragment: () => Promise<string>;
31
+ /**
32
+ * Get device attestation
33
+ */
34
+ getAttestation: () => Promise<{
35
+ attestation: {
36
+ codeHash: string;
37
+ attestationPub: string;
38
+ certificate: string;
39
+ };
40
+ buffer: Buffer;
41
+ }>;
42
+ /**
43
+ * Get device confidentiality key
44
+ */
45
+ getConfidentialityKey: () => Promise<{
46
+ confidentialityKeyCurve25519: string;
47
+ confidentialityKeySignature: string;
48
+ }>;
49
+ /**
50
+ * Get device confidentiality public key
51
+ */
52
+ getConfidentialityPubKey: () => Promise<{
53
+ pubKey: string;
54
+ signature: string;
55
+ }>;
56
+ /**
57
+ * Get device user id (the 16 chars user identifier displayed on Vault app)
58
+ */
59
+ getDeviceUserId: () => Promise<string>;
60
+ /**
61
+ * Get device U2F public key
62
+ */
63
+ getU2FPubKey: () => Promise<{
64
+ pubKey: string;
65
+ signature: string;
66
+ }>;
67
+ /**
68
+ * Get device validation public key
69
+ */
70
+ getValidationPubKey: () => Promise<{
71
+ pubKey: string;
72
+ signature: string;
73
+ }>;
74
+ /**
75
+ * Check is device has partition pairing
76
+ */
77
+ hasPairing: () => Promise<boolean>;
78
+ /**
79
+ * Initialize pairing handshake
80
+ */
81
+ initPairingHandshake: () => Promise<{
82
+ pubKey: string;
83
+ signature: string;
84
+ }>;
85
+ /**
86
+ * Open session
87
+ */
88
+ openSession: (opts: {
89
+ secureChannel: {
90
+ pubKey: PubKey;
91
+ certificate: HsmCertificate;
92
+ };
93
+ }) => Promise<void>;
94
+ /**
95
+ * Register device
96
+ */
97
+ register: (opts: {
98
+ challenge: string;
99
+ u2fRegisterData: string;
100
+ name: string;
101
+ role: "ADMIN" | "SHARED_OWNER" | "OPERATOR";
102
+ }) => Promise<{
103
+ u2fRegister: Buffer;
104
+ keyHandle: Buffer;
105
+ rfu: number;
106
+ pubKey: string;
107
+ }>;
108
+ /**
109
+ * Register data
110
+ */
111
+ registerData: (opts: {
112
+ challenge: string;
113
+ }) => Promise<string>;
114
+ /**
115
+ * Inject partition pairing
116
+ */
117
+ setPairing: (opts: {
118
+ pairing: PsdPairingData;
119
+ }) => Promise<void>;
120
+ /**
121
+ * Start KK pattern (related to noise channel)
122
+ */
123
+ startKKPatternAsResponder: (opts: {
124
+ handshake: string;
125
+ handshakeAttestation: HsmCertificate;
126
+ partitionId: string;
127
+ }) => Promise<{
128
+ handshake: string;
129
+ signature: string;
130
+ }>;
131
+ /**
132
+ * Start K pattern (related to noise channel)
133
+ */
134
+ startKPatternAsResponder: (opts: {
135
+ handshake: string;
136
+ handshakeAttestation: HsmCertificate;
137
+ partitionId: string;
138
+ }) => Promise<void>;
139
+ /**
140
+ * Approve with device
141
+ */
142
+ validateVaultOperation: (opts: {
143
+ actions: string[];
144
+ }) => Promise<string>;
145
+ /**
146
+ * Send arbitrary APDU
147
+ * apduCommand in HEX string format
148
+ */
149
+ sendAPDU: (apduCommand: string) => Promise<string>;
150
+ /**
151
+ * Get app version
152
+ *
153
+ */
154
+ getVersion: () => Promise<string>;
155
+ /**
156
+ * Poll device until it's plugged-on
157
+ *
158
+ */
159
+ poll: (opts?: {
160
+ retryOnError?: (err: Error) => boolean;
161
+ }) => Promise<{
162
+ isAppOpened: boolean;
163
+ }>;
164
+ /**
165
+ * Returned when app is opened
166
+ * appName in string format
167
+ */
168
+ pollApp: (name: string) => Promise<string>;
169
+ };
170
+ //#endregion
171
+ //#region src/device/api-device.d.ts
172
+ type Options = {
173
+ /**
174
+ * device-api URL
175
+ */
176
+ deviceApiUrl: string;
177
+ /**
178
+ * salt used by device-api
179
+ */
180
+ salt: string;
181
+ /**
182
+ * seed generation function used for device-api device spawn
183
+ */
184
+ genSeed: (p: {
185
+ salt: string;
186
+ index: number;
187
+ }) => string | Promise<string>;
188
+ };
189
+ type ApiDevice = {
190
+ /**
191
+ * bind a device to the given device index
192
+ */
193
+ with: (index: number) => Device;
194
+ };
195
+ declare function createApiDevice(options: Options, logger: Logger): ApiDevice;
196
+ //#endregion
197
+ //#region src/device/device-access.d.ts
198
+ type Discovery = Observable<{
199
+ type: "add" | "remove";
200
+ id: string;
201
+ name: string;
202
+ }>;
203
+ type TransportModule = {
204
+ id: string;
205
+ open: (id: string) => Promise<Transport> | null | undefined;
206
+ close?: (transport: Transport, id: string) => Promise<void> | null | undefined;
207
+ disconnect: (id: string) => Promise<void> | null | undefined;
208
+ discovery?: Discovery;
209
+ };
210
+ declare const registerTransportModule: (module: TransportModule) => void;
211
+ //#endregion
212
+ //#region ../../node_modules/.pnpm/@ledgerhq+errors@6.32.0/node_modules/@ledgerhq/errors/lib-es/index.d.ts
213
+ /**
214
+ * Error thrown when a device returned a non success status.
215
+ * the error.statusCode is one of the `StatusCodes` exported by this library.
216
+ */
217
+ declare class TransportStatusError extends Error {
218
+ statusCode: number;
219
+ statusText: string;
220
+ /**
221
+ * @param statusCode The error status code coming from a Transport implementation
222
+ * @param options containing:
223
+ * - canBeMappedToChildError: enable the mapping of TransportStatusError to an error extending/inheriting from it
224
+ * . Ex: LockedDeviceError. Default to true.
225
+ */
226
+ constructor(statusCode: number, {
227
+ canBeMappedToChildError
228
+ }?: {
229
+ canBeMappedToChildError?: boolean;
230
+ });
231
+ }
232
+ //#endregion
233
+ //#region src/device/utils.d.ts
234
+ declare const isTransportStatusError: (error: unknown) => error is TransportStatusError;
235
+ declare const isDeviceCancelError: (error: Error) => boolean;
236
+ //#endregion
237
+ export { createApiDevice as a, ApiDevice as i, isTransportStatusError as n, Device as o, registerTransportModule as r, isDeviceCancelError as t };
@@ -0,0 +1,23 @@
1
+ import { t as Logger } from "./logger-Cme0iL1f.cjs";
2
+ import { a as TRPCContext } from "./trpc-C_dUOB1u.cjs";
3
+ import { d as Engine, p as EngineOptions } from "./types-Byf9V35t.cjs";
4
+ import { CursorPaginated, Paginated } from "@ledgerhq/revault-api";
5
+
6
+ //#region src/utils.d.ts
7
+ /**
8
+ * Utility function that collect results on all pages until there is no more next page
9
+ */
10
+ declare function fetchAll<TData, TQuery extends {
11
+ page?: number;
12
+ }>(queryFn: (query: TQuery, trpcContext?: TRPCContext) => Promise<Paginated<TData>>, query: TQuery, trpcContext?: TRPCContext): Promise<TData[]>;
13
+ /**
14
+ * Utility function that collect results on all cursors until cursor is null
15
+ */
16
+ declare function fetchAllCursor<TData, TQuery extends {
17
+ cursor?: number | string;
18
+ }>(queryFn: (query: TQuery) => Promise<CursorPaginated<TData>>, query: TQuery): Promise<TData[]>;
19
+ //#endregion
20
+ //#region src/engine/index.d.ts
21
+ declare function createEngine(options: EngineOptions, logger: Logger): Engine;
22
+ //#endregion
23
+ export { fetchAll as n, fetchAllCursor as r, createEngine as t };
@@ -0,0 +1,23 @@
1
+ import { t as Logger } from "./logger-DWLViq7U.js";
2
+ import { a as TRPCContext } from "./trpc-CWGPr8Ox.js";
3
+ import { d as Engine, p as EngineOptions } from "./types-4CfR5--z.js";
4
+ import { CursorPaginated, Paginated } from "@ledgerhq/revault-api";
5
+
6
+ //#region src/utils.d.ts
7
+ /**
8
+ * Utility function that collect results on all pages until there is no more next page
9
+ */
10
+ declare function fetchAll<TData, TQuery extends {
11
+ page?: number;
12
+ }>(queryFn: (query: TQuery, trpcContext?: TRPCContext) => Promise<Paginated<TData>>, query: TQuery, trpcContext?: TRPCContext): Promise<TData[]>;
13
+ /**
14
+ * Utility function that collect results on all cursors until cursor is null
15
+ */
16
+ declare function fetchAllCursor<TData, TQuery extends {
17
+ cursor?: number | string;
18
+ }>(queryFn: (query: TQuery) => Promise<CursorPaginated<TData>>, query: TQuery): Promise<TData[]>;
19
+ //#endregion
20
+ //#region src/engine/index.d.ts
21
+ declare function createEngine(options: EngineOptions, logger: Logger): Engine;
22
+ //#endregion
23
+ export { fetchAll as n, fetchAllCursor as r, createEngine as t };
package/lib/index.cjs CHANGED
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=index.cjs.map
package/lib/index.d.cts CHANGED
@@ -1,5 +1,10 @@
1
- export { L as Logger } from './logger-C-TPbnjv.cjs';
2
- export { R as RevaultApiTRPCClient, a as RouterInputs, b as RouterOutputs, T as TRPCContext } from './types-CpGEbAxh.cjs';
3
- export * from '@ledgerhq/revault-api';
4
- import '@trpc/client';
5
- import '@trpc/server';
1
+ import { t as Logger } from "./logger-Cme0iL1f.cjs";
2
+ import { a as TRPCContext, n as RouterInputs, r as RouterOutputs, t as RevaultApiTRPCClient } from "./trpc-C_dUOB1u.cjs";
3
+ export * from "@ledgerhq/revault-api";
4
+
5
+ //#region src/index.d.ts
6
+ declare namespace index_d_exports {
7
+ export { Logger, RevaultApiTRPCClient, RouterInputs, RouterOutputs, TRPCContext };
8
+ }
9
+ //#endregion
10
+ export { type Logger, type RevaultApiTRPCClient, RouterInputs, RouterOutputs, TRPCContext };
package/lib/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
- export { L as Logger } from './logger-C-TPbnjv.js';
2
- export { R as RevaultApiTRPCClient, a as RouterInputs, b as RouterOutputs, T as TRPCContext } from './types-CpGEbAxh.js';
3
- export * from '@ledgerhq/revault-api';
4
- import '@trpc/client';
5
- import '@trpc/server';
1
+ import { t as Logger } from "./logger-DWLViq7U.js";
2
+ import { a as TRPCContext, n as RouterInputs, r as RouterOutputs, t as RevaultApiTRPCClient } from "./trpc-CWGPr8Ox.js";
3
+ export * from "@ledgerhq/revault-api";
4
+
5
+ //#region src/index.d.ts
6
+ declare namespace index_d_exports {
7
+ export { Logger, RevaultApiTRPCClient, RouterInputs, RouterOutputs, TRPCContext };
8
+ }
9
+ //#endregion
10
+ export { type Logger, type RevaultApiTRPCClient, RouterInputs, RouterOutputs, TRPCContext };
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- //# sourceMappingURL=index.js.map
1
+ export {};
@@ -0,0 +1,10 @@
1
+ //#region src/logger.d.ts
2
+ type Logger = {
3
+ info: (msg: string) => void;
4
+ warning: (msg: string) => void;
5
+ error: (msg: string) => void;
6
+ debug: (msg: string) => void;
7
+ output: (msg: string) => void;
8
+ };
9
+ //#endregion
10
+ export { Logger as t };
@@ -0,0 +1,10 @@
1
+ //#region src/logger.d.ts
2
+ type Logger = {
3
+ info: (msg: string) => void;
4
+ warning: (msg: string) => void;
5
+ error: (msg: string) => void;
6
+ debug: (msg: string) => void;
7
+ output: (msg: string) => void;
8
+ };
9
+ //#endregion
10
+ export { Logger as t };