@ledgerhq/revault-sdk 0.25.0 → 0.26.0

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 -1361
  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 +266 -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 +791 -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 +851 -888
  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 +844 -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-DOn7RPPt.d.cts +23 -0
  33. package/lib/index-U0iFMp3g.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 +215 -183
  41. package/lib/onboarding.cjs.map +1 -1
  42. package/lib/onboarding.d.cts +1918 -1722
  43. package/lib/onboarding.d.ts +1918 -1722
  44. package/lib/onboarding.js +211 -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-BXkDuD6i.d.ts +207 -0
  49. package/lib/types-CQROu0nu.d.cts +6 -0
  50. package/lib/types-Ngwgtu_U.d.cts +207 -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 +84 -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,207 @@
1
+ import { o as Device } from "./index--fscLDTT.js";
2
+ import { i as TRPCClientOptions, r as RouterOutputs, t as RevaultApiTRPCClient } from "./trpc-CWGPr8Ox.js";
3
+ import { ApiChallenge, ClaimedRole, OnboardingSeedChallenge, PsdChallenge, UserRegistrationResponse, VaultRequestResponse, WrappingKeyResponse } from "@ledgerhq/revault-api";
4
+
5
+ //#region src/engine/types.d.ts
6
+ type EngineOptions = {
7
+ /**
8
+ * revault-api URL
9
+ */
10
+ baseUrl: string;
11
+ /**
12
+ * device-api URL
13
+ */
14
+ deviceApiUrl: string;
15
+ /**
16
+ * salt used by device-api
17
+ */
18
+ salt: string;
19
+ /**
20
+ * seed generation function used for device-api device spawn
21
+ */
22
+ genSeed: (p: {
23
+ salt: string;
24
+ index: number;
25
+ }) => string | Promise<string>;
26
+ };
27
+ type EngineBase = {
28
+ /**
29
+ * revault-api client
30
+ */
31
+ client: RevaultApiTRPCClient;
32
+ /**
33
+ * Create a new revault-api client with the given options overriding the base ones
34
+ */
35
+ createClient: (opts: Partial<TRPCClientOptions>) => RevaultApiTRPCClient;
36
+ /**
37
+ * Engine options used to create the engine. Can be useful to retrieve them at runtime.
38
+ */
39
+ __options: EngineOptions;
40
+ };
41
+ type EnhanceWithDevice<T> = T extends WithDevice | WithApiUser ? unknown : {
42
+ /**
43
+ * Mark the engine as targeting the given transport id for PSD communication.
44
+ * See `@ledgerhq/hw-transport` for more information.
45
+ *
46
+ * @param string transportId
47
+ */
48
+ withTransportId: (transportId: string) => Engine<T & WithDevice>;
49
+ /**
50
+ * Mark the engine as using device-api (for dev & test purposes) with the given device index.
51
+ *
52
+ * @param number deviceIndex
53
+ */
54
+ withDeviceIndex: (deviceIndex: number) => Engine<T & WithDevice>;
55
+ };
56
+ type EnhanceWithApiUser<T> = T extends WithDevice | WithApiUser | WithOnboarding ? unknown : {
57
+ /**
58
+ * Mark the engine as targeting API user
59
+ */
60
+ withApiUser: () => Engine<T & WithApiUser>;
61
+ };
62
+ type EnhanceWithOnboarding<T> = T extends WithOnboarding | WithWorkspace | WithApiUser ? unknown : {
63
+ /**
64
+ * Target the given onboarding id
65
+ *
66
+ * @param string Onboarding id
67
+ */
68
+ withOnboarding: (onboardingId: string) => Engine<T & WithOnboarding>;
69
+ };
70
+ type EnhanceWithWorkspace<T> = T extends WithWorkspace | WithOnboarding ? unknown : {
71
+ /**
72
+ * Target the given workspace
73
+ *
74
+ * @param string Workspace name
75
+ */
76
+ withWorkspace: (workspaceName: string) => Engine<T & WithWorkspace>;
77
+ };
78
+ type Decorate<T, TCond, TExtend> = T extends TCond ? TExtend : unknown;
79
+ type Engine<T = unknown> = T & EngineBase & EnhanceWithDevice<T> & EnhanceWithApiUser<T> & EnhanceWithOnboarding<T> & EnhanceWithWorkspace<T> & Decorate<T, WithDevice, DecorateWithDevice<T>> & Decorate<T, WithWorkspace, DecorateWithWorkspace<T>> & Decorate<T, WithDevice & WithOnboarding, DecorateWithDeviceAndOnboarding>;
80
+ type WithDevice = {
81
+ device: Device;
82
+ };
83
+ type DecorateWithDevice<T> = T extends WithWorkspace ? unknown : {
84
+ getWorkspaces: () => Promise<string[]>;
85
+ getWorkspacesForSso: () => Promise<RouterOutputs["auth"]["sso"]["findWorkspaces"]["workspaces"]>;
86
+ };
87
+ type WithApiUser = {
88
+ __isApiUser: true;
89
+ };
90
+ type RegisterOnboardingDeviceParams = {
91
+ role: "ADMIN" | "SHARED_OWNER";
92
+ name: string;
93
+ };
94
+ type WithOnboarding = {
95
+ __onboardingId: string;
96
+ };
97
+ type DecorateWithDeviceAndOnboarding = {
98
+ /**
99
+ * Claim the device as part of the onboarding
100
+ */
101
+ claimDevice: (p: {
102
+ role: ClaimedRole;
103
+ deviceName: string;
104
+ }) => Promise<void>;
105
+ /**
106
+ * Collect fragment of wrapping key
107
+ */
108
+ collectWrappingKeyFragment: (wrappingKey: WrappingKeyResponse, params?: OnboardingOperationParams) => Promise<void>;
109
+ /**
110
+ * Register device (either Admin or Shared-Owner)
111
+ */
112
+ registerDevice: (p: RegisterOnboardingDeviceParams, params?: OnboardingOperationParams) => Promise<void>;
113
+ /**
114
+ * Review Shared-Owner with Admin
115
+ */
116
+ reviewSharedOwner: (challenge: PsdChallenge, params?: OnboardingOperationParams) => Promise<void>;
117
+ /**
118
+ * Review external signer with Admin
119
+ */
120
+ reviewExternalSigners: (challenge: PsdChallenge, params?: OnboardingOperationParams) => Promise<void>;
121
+ /**
122
+ * Collect master seed fragment
123
+ */
124
+ collectSeedFragment: (challenge: OnboardingSeedChallenge, params?: OnboardingOperationParams) => Promise<void>;
125
+ };
126
+ type WithWorkspace = {
127
+ __workspaceName: string;
128
+ };
129
+ type DecorateWithWorkspace<T> = T extends WithPsdAuth | WithApiAuth ? DecorateWithWorkspaceAuthenticated<T> : DecorateWithWorkspaceUnauthenticated<T> & (T extends WithDevice ? DecorateWithDeviceAndWorkspaceUnauthenticated<T> : T extends WithApiUser ? DecorateWithApiUserAndWorkspaceUnauthenticated<T> : unknown);
130
+ type DecorateWithWorkspaceUnauthenticated<T> = {
131
+ /**
132
+ * Directly pass a PsdAuth token
133
+ */
134
+ withPsdToken: (token: string) => Engine<T & WithPsdAuth>;
135
+ };
136
+ type DecorateWithWorkspaceAuthenticated<T> = T extends WithDevice ? DecorateWithWorkspacePsdAuthenticated : T extends WithApiUser ? DecorateWithWorkspaceApiAuthenticated : unknown;
137
+ type OnboardingOperationParams = {
138
+ onScreenDisplayed?: () => void | Promise<void>;
139
+ };
140
+ type CorrelationIdOpts = {
141
+ correlationId?: string;
142
+ };
143
+ type ApproveRequestParams = {
144
+ onScreenDisplayed?: () => void | Promise<void>;
145
+ onPsdChallengeSigned?: () => void | Promise<void>;
146
+ } & CorrelationIdOpts;
147
+ type DecorateWithWorkspacePsdAuthenticated = {
148
+ /**
149
+ * Approve the given request
150
+ */
151
+ approve: (request: VaultRequestResponse, params?: ApproveRequestParams) => Promise<VaultRequestResponse>;
152
+ /**
153
+ * Approve the given challenge
154
+ */
155
+ approveChallenge: (challenge: PsdChallenge, params?: ApproveRequestParams) => Promise<string>;
156
+ /**
157
+ * Reject the given request
158
+ */
159
+ reject: (request: VaultRequestResponse) => Promise<VaultRequestResponse>;
160
+ };
161
+ type DecorateWithWorkspaceApiAuthenticated = {
162
+ /**
163
+ * Get API challenge for the given request
164
+ */
165
+ getChallenge: (request: VaultRequestResponse) => Promise<ApiChallenge["payload"]>;
166
+ /**
167
+ * Approve the given request
168
+ */
169
+ approve: (request: VaultRequestResponse, signature: string) => Promise<VaultRequestResponse>;
170
+ /**
171
+ * Reject the given request
172
+ */
173
+ reject: (request: VaultRequestResponse, signature: string) => Promise<VaultRequestResponse>;
174
+ };
175
+ type DecorateWithDeviceAndWorkspaceUnauthenticated<T> = {
176
+ /**
177
+ * Login using the workspace & device that the engine are targeting
178
+ */
179
+ login: (opts?: {
180
+ validityDurationSecs?: number;
181
+ onScreenDisplayed?: () => void | Promise<void>;
182
+ correlationId?: string;
183
+ }) => Promise<Engine<T & WithPsdAuth>>;
184
+ /**
185
+ * Register the current device
186
+ */
187
+ register: (registration: UserRegistrationResponse) => Promise<UserRegistrationResponse>;
188
+ };
189
+ type WithPsdAuth = {
190
+ __psdToken: string;
191
+ };
192
+ type DecorateWithApiUserAndWorkspaceUnauthenticated<T> = {
193
+ /**
194
+ * Login using the workspace that the engine target and the given credentials
195
+ */
196
+ login: (credentials: {
197
+ apiKeyId: string;
198
+ apiKeySecret: string;
199
+ }, options?: {
200
+ correlationId?: string;
201
+ }) => Promise<Engine<T & WithApiAuth>>;
202
+ };
203
+ type WithApiAuth = {
204
+ __apiAuth: RouterOutputs["auth"]["authenticate"];
205
+ };
206
+ //#endregion
207
+ export { WithApiUser as _, DecorateWithDeviceAndOnboarding as a, WithPsdAuth as b, DecorateWithWorkspaceApiAuthenticated as c, Engine as d, EngineBase as f, WithApiAuth as g, RegisterOnboardingDeviceParams as h, DecorateWithDevice as i, DecorateWithWorkspacePsdAuthenticated as l, OnboardingOperationParams as m, CorrelationIdOpts as n, DecorateWithDeviceAndWorkspaceUnauthenticated as o, EngineOptions as p, DecorateWithApiUserAndWorkspaceUnauthenticated as r, DecorateWithWorkspace as s, ApproveRequestParams as t, DecorateWithWorkspaceUnauthenticated as u, WithDevice as v, WithWorkspace as x, WithOnboarding as y };
@@ -0,0 +1,6 @@
1
+ import { a as TRPCContext, n as RouterInputs, r as RouterOutputs } from "./trpc-C_dUOB1u.cjs";
2
+
3
+ //#region \0rolldown/runtime.js
4
+
5
+ //#endregion
6
+ export { __reExport as n, __exportAll as t };
@@ -0,0 +1,207 @@
1
+ import { o as Device } from "./index-BE7oUpCb.cjs";
2
+ import { i as TRPCClientOptions, r as RouterOutputs, t as RevaultApiTRPCClient } from "./trpc-C_dUOB1u.cjs";
3
+ import { ApiChallenge, ClaimedRole, OnboardingSeedChallenge, PsdChallenge, UserRegistrationResponse, VaultRequestResponse, WrappingKeyResponse } from "@ledgerhq/revault-api";
4
+
5
+ //#region src/engine/types.d.ts
6
+ type EngineOptions = {
7
+ /**
8
+ * revault-api URL
9
+ */
10
+ baseUrl: string;
11
+ /**
12
+ * device-api URL
13
+ */
14
+ deviceApiUrl: string;
15
+ /**
16
+ * salt used by device-api
17
+ */
18
+ salt: string;
19
+ /**
20
+ * seed generation function used for device-api device spawn
21
+ */
22
+ genSeed: (p: {
23
+ salt: string;
24
+ index: number;
25
+ }) => string | Promise<string>;
26
+ };
27
+ type EngineBase = {
28
+ /**
29
+ * revault-api client
30
+ */
31
+ client: RevaultApiTRPCClient;
32
+ /**
33
+ * Create a new revault-api client with the given options overriding the base ones
34
+ */
35
+ createClient: (opts: Partial<TRPCClientOptions>) => RevaultApiTRPCClient;
36
+ /**
37
+ * Engine options used to create the engine. Can be useful to retrieve them at runtime.
38
+ */
39
+ __options: EngineOptions;
40
+ };
41
+ type EnhanceWithDevice<T> = T extends WithDevice | WithApiUser ? unknown : {
42
+ /**
43
+ * Mark the engine as targeting the given transport id for PSD communication.
44
+ * See `@ledgerhq/hw-transport` for more information.
45
+ *
46
+ * @param string transportId
47
+ */
48
+ withTransportId: (transportId: string) => Engine<T & WithDevice>;
49
+ /**
50
+ * Mark the engine as using device-api (for dev & test purposes) with the given device index.
51
+ *
52
+ * @param number deviceIndex
53
+ */
54
+ withDeviceIndex: (deviceIndex: number) => Engine<T & WithDevice>;
55
+ };
56
+ type EnhanceWithApiUser<T> = T extends WithDevice | WithApiUser | WithOnboarding ? unknown : {
57
+ /**
58
+ * Mark the engine as targeting API user
59
+ */
60
+ withApiUser: () => Engine<T & WithApiUser>;
61
+ };
62
+ type EnhanceWithOnboarding<T> = T extends WithOnboarding | WithWorkspace | WithApiUser ? unknown : {
63
+ /**
64
+ * Target the given onboarding id
65
+ *
66
+ * @param string Onboarding id
67
+ */
68
+ withOnboarding: (onboardingId: string) => Engine<T & WithOnboarding>;
69
+ };
70
+ type EnhanceWithWorkspace<T> = T extends WithWorkspace | WithOnboarding ? unknown : {
71
+ /**
72
+ * Target the given workspace
73
+ *
74
+ * @param string Workspace name
75
+ */
76
+ withWorkspace: (workspaceName: string) => Engine<T & WithWorkspace>;
77
+ };
78
+ type Decorate<T, TCond, TExtend> = T extends TCond ? TExtend : unknown;
79
+ type Engine<T = unknown> = T & EngineBase & EnhanceWithDevice<T> & EnhanceWithApiUser<T> & EnhanceWithOnboarding<T> & EnhanceWithWorkspace<T> & Decorate<T, WithDevice, DecorateWithDevice<T>> & Decorate<T, WithWorkspace, DecorateWithWorkspace<T>> & Decorate<T, WithDevice & WithOnboarding, DecorateWithDeviceAndOnboarding>;
80
+ type WithDevice = {
81
+ device: Device;
82
+ };
83
+ type DecorateWithDevice<T> = T extends WithWorkspace ? unknown : {
84
+ getWorkspaces: () => Promise<string[]>;
85
+ getWorkspacesForSso: () => Promise<RouterOutputs["auth"]["sso"]["findWorkspaces"]["workspaces"]>;
86
+ };
87
+ type WithApiUser = {
88
+ __isApiUser: true;
89
+ };
90
+ type RegisterOnboardingDeviceParams = {
91
+ role: "ADMIN" | "SHARED_OWNER";
92
+ name: string;
93
+ };
94
+ type WithOnboarding = {
95
+ __onboardingId: string;
96
+ };
97
+ type DecorateWithDeviceAndOnboarding = {
98
+ /**
99
+ * Claim the device as part of the onboarding
100
+ */
101
+ claimDevice: (p: {
102
+ role: ClaimedRole;
103
+ deviceName: string;
104
+ }) => Promise<void>;
105
+ /**
106
+ * Collect fragment of wrapping key
107
+ */
108
+ collectWrappingKeyFragment: (wrappingKey: WrappingKeyResponse, params?: OnboardingOperationParams) => Promise<void>;
109
+ /**
110
+ * Register device (either Admin or Shared-Owner)
111
+ */
112
+ registerDevice: (p: RegisterOnboardingDeviceParams, params?: OnboardingOperationParams) => Promise<void>;
113
+ /**
114
+ * Review Shared-Owner with Admin
115
+ */
116
+ reviewSharedOwner: (challenge: PsdChallenge, params?: OnboardingOperationParams) => Promise<void>;
117
+ /**
118
+ * Review external signer with Admin
119
+ */
120
+ reviewExternalSigners: (challenge: PsdChallenge, params?: OnboardingOperationParams) => Promise<void>;
121
+ /**
122
+ * Collect master seed fragment
123
+ */
124
+ collectSeedFragment: (challenge: OnboardingSeedChallenge, params?: OnboardingOperationParams) => Promise<void>;
125
+ };
126
+ type WithWorkspace = {
127
+ __workspaceName: string;
128
+ };
129
+ type DecorateWithWorkspace<T> = T extends WithPsdAuth | WithApiAuth ? DecorateWithWorkspaceAuthenticated<T> : DecorateWithWorkspaceUnauthenticated<T> & (T extends WithDevice ? DecorateWithDeviceAndWorkspaceUnauthenticated<T> : T extends WithApiUser ? DecorateWithApiUserAndWorkspaceUnauthenticated<T> : unknown);
130
+ type DecorateWithWorkspaceUnauthenticated<T> = {
131
+ /**
132
+ * Directly pass a PsdAuth token
133
+ */
134
+ withPsdToken: (token: string) => Engine<T & WithPsdAuth>;
135
+ };
136
+ type DecorateWithWorkspaceAuthenticated<T> = T extends WithDevice ? DecorateWithWorkspacePsdAuthenticated : T extends WithApiUser ? DecorateWithWorkspaceApiAuthenticated : unknown;
137
+ type OnboardingOperationParams = {
138
+ onScreenDisplayed?: () => void | Promise<void>;
139
+ };
140
+ type CorrelationIdOpts = {
141
+ correlationId?: string;
142
+ };
143
+ type ApproveRequestParams = {
144
+ onScreenDisplayed?: () => void | Promise<void>;
145
+ onPsdChallengeSigned?: () => void | Promise<void>;
146
+ } & CorrelationIdOpts;
147
+ type DecorateWithWorkspacePsdAuthenticated = {
148
+ /**
149
+ * Approve the given request
150
+ */
151
+ approve: (request: VaultRequestResponse, params?: ApproveRequestParams) => Promise<VaultRequestResponse>;
152
+ /**
153
+ * Approve the given challenge
154
+ */
155
+ approveChallenge: (challenge: PsdChallenge, params?: ApproveRequestParams) => Promise<string>;
156
+ /**
157
+ * Reject the given request
158
+ */
159
+ reject: (request: VaultRequestResponse) => Promise<VaultRequestResponse>;
160
+ };
161
+ type DecorateWithWorkspaceApiAuthenticated = {
162
+ /**
163
+ * Get API challenge for the given request
164
+ */
165
+ getChallenge: (request: VaultRequestResponse) => Promise<ApiChallenge["payload"]>;
166
+ /**
167
+ * Approve the given request
168
+ */
169
+ approve: (request: VaultRequestResponse, signature: string) => Promise<VaultRequestResponse>;
170
+ /**
171
+ * Reject the given request
172
+ */
173
+ reject: (request: VaultRequestResponse, signature: string) => Promise<VaultRequestResponse>;
174
+ };
175
+ type DecorateWithDeviceAndWorkspaceUnauthenticated<T> = {
176
+ /**
177
+ * Login using the workspace & device that the engine are targeting
178
+ */
179
+ login: (opts?: {
180
+ validityDurationSecs?: number;
181
+ onScreenDisplayed?: () => void | Promise<void>;
182
+ correlationId?: string;
183
+ }) => Promise<Engine<T & WithPsdAuth>>;
184
+ /**
185
+ * Register the current device
186
+ */
187
+ register: (registration: UserRegistrationResponse) => Promise<UserRegistrationResponse>;
188
+ };
189
+ type WithPsdAuth = {
190
+ __psdToken: string;
191
+ };
192
+ type DecorateWithApiUserAndWorkspaceUnauthenticated<T> = {
193
+ /**
194
+ * Login using the workspace that the engine target and the given credentials
195
+ */
196
+ login: (credentials: {
197
+ apiKeyId: string;
198
+ apiKeySecret: string;
199
+ }, options?: {
200
+ correlationId?: string;
201
+ }) => Promise<Engine<T & WithApiAuth>>;
202
+ };
203
+ type WithApiAuth = {
204
+ __apiAuth: RouterOutputs["auth"]["authenticate"];
205
+ };
206
+ //#endregion
207
+ export { WithApiUser as _, DecorateWithDeviceAndOnboarding as a, WithPsdAuth as b, DecorateWithWorkspaceApiAuthenticated as c, Engine as d, EngineBase as f, WithApiAuth as g, RegisterOnboardingDeviceParams as h, DecorateWithDevice as i, DecorateWithWorkspacePsdAuthenticated as l, OnboardingOperationParams as m, CorrelationIdOpts as n, DecorateWithDeviceAndWorkspaceUnauthenticated as o, EngineOptions as p, DecorateWithApiUserAndWorkspaceUnauthenticated as r, DecorateWithWorkspace as s, ApproveRequestParams as t, DecorateWithWorkspaceUnauthenticated as u, WithDevice as v, WithWorkspace as x, WithOnboarding as y };
@@ -0,0 +1,6 @@
1
+ import { a as TRPCContext, n as RouterInputs, r as RouterOutputs } from "./trpc-CWGPr8Ox.js";
2
+
3
+ //#region \0rolldown/runtime.js
4
+
5
+ //#endregion
6
+ export { __reExport as n, __exportAll as t };
package/lib/types.cjs CHANGED
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=types.cjs.map
package/lib/types.d.cts CHANGED
@@ -1,4 +1,3 @@
1
- export * from '@ledgerhq/revault-api';
2
- export { a as RouterInputs, b as RouterOutputs, T as TRPCContext } from './types-CpGEbAxh.cjs';
3
- import '@trpc/client';
4
- import '@trpc/server';
1
+ import { a as TRPCContext, n as RouterInputs, r as RouterOutputs } from "./trpc-C_dUOB1u.cjs";
2
+ export * from "@ledgerhq/revault-api";
3
+ export { RouterInputs, RouterOutputs, TRPCContext };
package/lib/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from '@ledgerhq/revault-api';
2
- export { a as RouterInputs, b as RouterOutputs, T as TRPCContext } from './types-CpGEbAxh.js';
3
- import '@trpc/client';
4
- import '@trpc/server';
1
+ import { a as TRPCContext, n as RouterInputs, r as RouterOutputs } from "./trpc-CWGPr8Ox.js";
2
+ export * from "@ledgerhq/revault-api";
3
+ export { RouterInputs, RouterOutputs, TRPCContext };
package/lib/types.js CHANGED
@@ -1 +1 @@
1
- //# sourceMappingURL=types.js.map
1
+ export {};
@@ -0,0 +1,61 @@
1
+ import invariant from "invariant";
2
+ //#region src/utils.ts
3
+ /**
4
+ * Utility function that collect results on all pages until there is no more next page
5
+ */
6
+ async function fetchAll(queryFn, query, trpcContext) {
7
+ const res = [];
8
+ let page = 1;
9
+ while (page) {
10
+ const partial = await queryFn({
11
+ ...query,
12
+ page
13
+ }, trpcContext);
14
+ res.push(...partial.results);
15
+ page = partial.next;
16
+ }
17
+ return res;
18
+ }
19
+ /**
20
+ * Utility function that collect results on all cursors until cursor is null
21
+ */
22
+ async function fetchAllCursor(queryFn, query) {
23
+ const res = [];
24
+ let cursor = null;
25
+ do {
26
+ const partial = await queryFn({
27
+ ...query,
28
+ ...cursor === null ? {} : { cursor }
29
+ });
30
+ res.push(...partial.results);
31
+ cursor = partial.next;
32
+ } while (cursor);
33
+ return res;
34
+ }
35
+ /**
36
+ * Return a function that retrieve a device index based on a given deviceUserId
37
+ * Holds a cache of found indexes to avoid spamming device-api
38
+ */
39
+ function createDeviceIndexResolver(engine) {
40
+ const _deviceUserIdByDeviceIndexCache = {};
41
+ return async function findDeviceIndex(deviceUserId) {
42
+ let deviceIndex = null;
43
+ for (let i = 4; i < 50; i++) {
44
+ const promise = i in _deviceUserIdByDeviceIndexCache ? _deviceUserIdByDeviceIndexCache[i] : engine.withDeviceIndex(i).device.getDeviceUserId();
45
+ _deviceUserIdByDeviceIndexCache[i] = promise;
46
+ if ((await promise).toUpperCase() === deviceUserId.toUpperCase()) {
47
+ deviceIndex = i;
48
+ break;
49
+ }
50
+ }
51
+ invariant(deviceIndex, `Could not find index for device user id ${deviceUserId}`);
52
+ return deviceIndex;
53
+ };
54
+ }
55
+ function buildTrpcContext(opts) {
56
+ return opts?.correlationId ? { context: { headers: { "x-correlation-id": opts.correlationId } } } : void 0;
57
+ }
58
+ //#endregion
59
+ export { fetchAllCursor as i, createDeviceIndexResolver as n, fetchAll as r, buildTrpcContext as t };
60
+
61
+ //# sourceMappingURL=utils-BGbdjOP9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-BGbdjOP9.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { CursorPaginated, Paginated } from \"@ledgerhq/revault-api\";\nimport invariant from \"invariant\";\n\nimport type { CorrelationIdOpts, Engine, WithWorkspace } from \"./engine/types\";\nimport type { TRPCContext } from \"./trpc\";\n\n/**\n * Utility function that collect results on all pages until there is no more next page\n */\nexport async function fetchAll<TData, TQuery extends { page?: number }>(\n queryFn: (query: TQuery, trpcContext?: TRPCContext) => Promise<Paginated<TData>>,\n query: TQuery,\n trpcContext?: TRPCContext,\n): Promise<TData[]> {\n const res: TData[] = [];\n let page: number | null = 1;\n while (page) {\n const partial = await queryFn({ ...query, page }, trpcContext);\n res.push(...partial.results);\n page = partial.next;\n }\n return res;\n}\n\n/**\n * Utility function that collect results on all cursors until cursor is null\n */\nexport async function fetchAllCursor<TData, TQuery extends { cursor?: number | string }>(\n queryFn: (query: TQuery) => Promise<CursorPaginated<TData>>,\n query: TQuery,\n): Promise<TData[]> {\n const res: TData[] = [];\n let cursor: number | string | null = null;\n do {\n const partial = await queryFn({ ...query, ...(cursor === null ? {} : { cursor }) });\n res.push(...partial.results);\n cursor = partial.next;\n } while (cursor);\n return res;\n}\n\n/**\n * Return a function that retrieve a device index based on a given deviceUserId\n * Holds a cache of found indexes to avoid spamming device-api\n */\nexport function createDeviceIndexResolver(engine: Engine<WithWorkspace>) {\n // Cache to avoid spamming device-api when seeking for same index multiple times\n const _deviceUserIdByDeviceIndexCache: Record<string, Promise<string>> = {};\n\n return async function findDeviceIndex(deviceUserId: string): Promise<number> {\n let deviceIndex: number | null = null;\n for (let i = 4; i < 50; i++) {\n const promise =\n i in _deviceUserIdByDeviceIndexCache\n ? _deviceUserIdByDeviceIndexCache[i]!\n : engine.withDeviceIndex(i).device.getDeviceUserId();\n _deviceUserIdByDeviceIndexCache[i] = promise;\n const candidate = await promise;\n // /!\\ we need to decide in which casing we want this information\n // -> device-api returns it in uppercase\n // -> we save it in lowercase in revault-api DB\n // -> doing \"safe\" comparison here by always user the uppercase version, but hey!\n if (candidate.toUpperCase() === deviceUserId.toUpperCase()) {\n deviceIndex = i;\n break;\n }\n }\n invariant(deviceIndex, `Could not find index for device user id ${deviceUserId}`);\n return deviceIndex;\n };\n}\n\nexport function buildTrpcContext(opts?: CorrelationIdOpts) {\n return opts?.correlationId\n ? { context: { headers: { \"x-correlation-id\": opts.correlationId } } }\n : undefined;\n}\n"],"mappings":";;;;;AASA,eAAsB,SACpB,SACA,OACA,aACkB;CAClB,MAAM,MAAe,EAAE;CACvB,IAAI,OAAsB;AAC1B,QAAO,MAAM;EACX,MAAM,UAAU,MAAM,QAAQ;GAAE,GAAG;GAAO;GAAM,EAAE,YAAY;AAC9D,MAAI,KAAK,GAAG,QAAQ,QAAQ;AAC5B,SAAO,QAAQ;;AAEjB,QAAO;;;;;AAMT,eAAsB,eACpB,SACA,OACkB;CAClB,MAAM,MAAe,EAAE;CACvB,IAAI,SAAiC;AACrC,IAAG;EACD,MAAM,UAAU,MAAM,QAAQ;GAAE,GAAG;GAAO,GAAI,WAAW,OAAO,EAAE,GAAG,EAAE,QAAQ;GAAG,CAAC;AACnF,MAAI,KAAK,GAAG,QAAQ,QAAQ;AAC5B,WAAS,QAAQ;UACV;AACT,QAAO;;;;;;AAOT,SAAgB,0BAA0B,QAA+B;CAEvE,MAAM,kCAAmE,EAAE;AAE3E,QAAO,eAAe,gBAAgB,cAAuC;EAC3E,IAAI,cAA6B;AACjC,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;GAC3B,MAAM,UACJ,KAAK,kCACD,gCAAgC,KAChC,OAAO,gBAAgB,EAAE,CAAC,OAAO,iBAAiB;AACxD,mCAAgC,KAAK;AAMrC,QALkB,MAAM,SAKV,aAAa,KAAK,aAAa,aAAa,EAAE;AAC1D,kBAAc;AACd;;;AAGJ,YAAU,aAAa,2CAA2C,eAAe;AACjF,SAAO;;;AAIX,SAAgB,iBAAiB,MAA0B;AACzD,QAAO,MAAM,gBACT,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,KAAK,eAAe,EAAE,EAAE,GACpE,KAAA"}
@@ -0,0 +1,84 @@
1
+ const require_chunk = require("./chunk-CKQMccvm.cjs");
2
+ let invariant = require("invariant");
3
+ invariant = require_chunk.__toESM(invariant);
4
+ //#region src/utils.ts
5
+ /**
6
+ * Utility function that collect results on all pages until there is no more next page
7
+ */
8
+ async function fetchAll(queryFn, query, trpcContext) {
9
+ const res = [];
10
+ let page = 1;
11
+ while (page) {
12
+ const partial = await queryFn({
13
+ ...query,
14
+ page
15
+ }, trpcContext);
16
+ res.push(...partial.results);
17
+ page = partial.next;
18
+ }
19
+ return res;
20
+ }
21
+ /**
22
+ * Utility function that collect results on all cursors until cursor is null
23
+ */
24
+ async function fetchAllCursor(queryFn, query) {
25
+ const res = [];
26
+ let cursor = null;
27
+ do {
28
+ const partial = await queryFn({
29
+ ...query,
30
+ ...cursor === null ? {} : { cursor }
31
+ });
32
+ res.push(...partial.results);
33
+ cursor = partial.next;
34
+ } while (cursor);
35
+ return res;
36
+ }
37
+ /**
38
+ * Return a function that retrieve a device index based on a given deviceUserId
39
+ * Holds a cache of found indexes to avoid spamming device-api
40
+ */
41
+ function createDeviceIndexResolver(engine) {
42
+ const _deviceUserIdByDeviceIndexCache = {};
43
+ return async function findDeviceIndex(deviceUserId) {
44
+ let deviceIndex = null;
45
+ for (let i = 4; i < 50; i++) {
46
+ const promise = i in _deviceUserIdByDeviceIndexCache ? _deviceUserIdByDeviceIndexCache[i] : engine.withDeviceIndex(i).device.getDeviceUserId();
47
+ _deviceUserIdByDeviceIndexCache[i] = promise;
48
+ if ((await promise).toUpperCase() === deviceUserId.toUpperCase()) {
49
+ deviceIndex = i;
50
+ break;
51
+ }
52
+ }
53
+ (0, invariant.default)(deviceIndex, `Could not find index for device user id ${deviceUserId}`);
54
+ return deviceIndex;
55
+ };
56
+ }
57
+ function buildTrpcContext(opts) {
58
+ return opts?.correlationId ? { context: { headers: { "x-correlation-id": opts.correlationId } } } : void 0;
59
+ }
60
+ //#endregion
61
+ Object.defineProperty(exports, "buildTrpcContext", {
62
+ enumerable: true,
63
+ get: function() {
64
+ return buildTrpcContext;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, "createDeviceIndexResolver", {
68
+ enumerable: true,
69
+ get: function() {
70
+ return createDeviceIndexResolver;
71
+ }
72
+ });
73
+ Object.defineProperty(exports, "fetchAll", {
74
+ enumerable: true,
75
+ get: function() {
76
+ return fetchAll;
77
+ }
78
+ });
79
+ Object.defineProperty(exports, "fetchAllCursor", {
80
+ enumerable: true,
81
+ get: function() {
82
+ return fetchAllCursor;
83
+ }
84
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-DbSFXp4c.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { CursorPaginated, Paginated } from \"@ledgerhq/revault-api\";\nimport invariant from \"invariant\";\n\nimport type { CorrelationIdOpts, Engine, WithWorkspace } from \"./engine/types\";\nimport type { TRPCContext } from \"./trpc\";\n\n/**\n * Utility function that collect results on all pages until there is no more next page\n */\nexport async function fetchAll<TData, TQuery extends { page?: number }>(\n queryFn: (query: TQuery, trpcContext?: TRPCContext) => Promise<Paginated<TData>>,\n query: TQuery,\n trpcContext?: TRPCContext,\n): Promise<TData[]> {\n const res: TData[] = [];\n let page: number | null = 1;\n while (page) {\n const partial = await queryFn({ ...query, page }, trpcContext);\n res.push(...partial.results);\n page = partial.next;\n }\n return res;\n}\n\n/**\n * Utility function that collect results on all cursors until cursor is null\n */\nexport async function fetchAllCursor<TData, TQuery extends { cursor?: number | string }>(\n queryFn: (query: TQuery) => Promise<CursorPaginated<TData>>,\n query: TQuery,\n): Promise<TData[]> {\n const res: TData[] = [];\n let cursor: number | string | null = null;\n do {\n const partial = await queryFn({ ...query, ...(cursor === null ? {} : { cursor }) });\n res.push(...partial.results);\n cursor = partial.next;\n } while (cursor);\n return res;\n}\n\n/**\n * Return a function that retrieve a device index based on a given deviceUserId\n * Holds a cache of found indexes to avoid spamming device-api\n */\nexport function createDeviceIndexResolver(engine: Engine<WithWorkspace>) {\n // Cache to avoid spamming device-api when seeking for same index multiple times\n const _deviceUserIdByDeviceIndexCache: Record<string, Promise<string>> = {};\n\n return async function findDeviceIndex(deviceUserId: string): Promise<number> {\n let deviceIndex: number | null = null;\n for (let i = 4; i < 50; i++) {\n const promise =\n i in _deviceUserIdByDeviceIndexCache\n ? _deviceUserIdByDeviceIndexCache[i]!\n : engine.withDeviceIndex(i).device.getDeviceUserId();\n _deviceUserIdByDeviceIndexCache[i] = promise;\n const candidate = await promise;\n // /!\\ we need to decide in which casing we want this information\n // -> device-api returns it in uppercase\n // -> we save it in lowercase in revault-api DB\n // -> doing \"safe\" comparison here by always user the uppercase version, but hey!\n if (candidate.toUpperCase() === deviceUserId.toUpperCase()) {\n deviceIndex = i;\n break;\n }\n }\n invariant(deviceIndex, `Could not find index for device user id ${deviceUserId}`);\n return deviceIndex;\n };\n}\n\nexport function buildTrpcContext(opts?: CorrelationIdOpts) {\n return opts?.correlationId\n ? { context: { headers: { \"x-correlation-id\": opts.correlationId } } }\n : undefined;\n}\n"],"mappings":";;;;;;;AASA,eAAsB,SACpB,SACA,OACA,aACkB;CAClB,MAAM,MAAe,EAAE;CACvB,IAAI,OAAsB;AAC1B,QAAO,MAAM;EACX,MAAM,UAAU,MAAM,QAAQ;GAAE,GAAG;GAAO;GAAM,EAAE,YAAY;AAC9D,MAAI,KAAK,GAAG,QAAQ,QAAQ;AAC5B,SAAO,QAAQ;;AAEjB,QAAO;;;;;AAMT,eAAsB,eACpB,SACA,OACkB;CAClB,MAAM,MAAe,EAAE;CACvB,IAAI,SAAiC;AACrC,IAAG;EACD,MAAM,UAAU,MAAM,QAAQ;GAAE,GAAG;GAAO,GAAI,WAAW,OAAO,EAAE,GAAG,EAAE,QAAQ;GAAG,CAAC;AACnF,MAAI,KAAK,GAAG,QAAQ,QAAQ;AAC5B,WAAS,QAAQ;UACV;AACT,QAAO;;;;;;AAOT,SAAgB,0BAA0B,QAA+B;CAEvE,MAAM,kCAAmE,EAAE;AAE3E,QAAO,eAAe,gBAAgB,cAAuC;EAC3E,IAAI,cAA6B;AACjC,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;GAC3B,MAAM,UACJ,KAAK,kCACD,gCAAgC,KAChC,OAAO,gBAAgB,EAAE,CAAC,OAAO,iBAAiB;AACxD,mCAAgC,KAAK;AAMrC,QALkB,MAAM,SAKV,aAAa,KAAK,aAAa,aAAa,EAAE;AAC1D,kBAAc;AACd;;;AAGJ,GAAA,GAAA,UAAA,SAAU,aAAa,2CAA2C,eAAe;AACjF,SAAO;;;AAIX,SAAgB,iBAAiB,MAA0B;AACzD,QAAO,MAAM,gBACT,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,KAAK,eAAe,EAAE,EAAE,GACpE,KAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/revault-sdk",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "files": [
@@ -63,7 +63,7 @@
63
63
  "ts-pattern": "^5.9.0",
64
64
  "uuid": "^13.0.0",
65
65
  "zod": "^4.3.6",
66
- "@ledgerhq/revault-api": "1.55.1"
66
+ "@ledgerhq/revault-api": "1.57.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@eslint/js": "^9.39.4",
@@ -76,17 +76,17 @@
76
76
  "@vitest/ui": "^4.1.3",
77
77
  "eslint": "^9.39.4",
78
78
  "eslint-plugin-unicorn": "^62.0.0",
79
- "tsup": "^8.5.1",
79
+ "tsdown": "^0.21.7",
80
80
  "tsx": "^4.21.0",
81
81
  "typescript": "^5.9.3",
82
82
  "typescript-eslint": "^8.58.1",
83
- "vite-plugin-node-polyfills": "^0.24.0",
83
+ "vite-plugin-node-polyfills": "^0.26.0",
84
84
  "vitest": "^4.1.3",
85
85
  "vitest-mock-extended": "^4.0.0"
86
86
  },
87
87
  "scripts": {
88
- "build": "tsup",
89
- "dev": "tsup --watch",
88
+ "build": "tsdown",
89
+ "dev": "tsdown --watch",
90
90
  "lint": "biome check --error-on-warnings",
91
91
  "lint:fix": "biome check --write --unsafe",
92
92
  "test": "vitest run --coverage --coverage.thresholds.100=true",