@cubist-labs/cubesigner-sdk 0.1.50 → 0.2.2

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 (47) hide show
  1. package/README.md +66 -13
  2. package/dist/src/client.d.ts +434 -7
  3. package/dist/src/client.js +1022 -18
  4. package/dist/src/ethers/index.d.ts +2 -4
  5. package/dist/src/ethers/index.js +11 -9
  6. package/dist/src/fido.d.ts +76 -0
  7. package/dist/src/fido.js +148 -0
  8. package/dist/src/index.d.ts +102 -30
  9. package/dist/src/index.js +126 -72
  10. package/dist/src/key.d.ts +15 -45
  11. package/dist/src/key.js +31 -93
  12. package/dist/src/mfa.d.ts +85 -14
  13. package/dist/src/mfa.js +158 -40
  14. package/dist/src/org.d.ts +237 -123
  15. package/dist/src/org.js +108 -213
  16. package/dist/src/paginator.d.ts +76 -0
  17. package/dist/src/paginator.js +99 -0
  18. package/dist/src/role.d.ts +76 -74
  19. package/dist/src/role.js +79 -136
  20. package/dist/src/schema.d.ts +1672 -520
  21. package/dist/src/schema.js +1 -1
  22. package/dist/src/schema_types.d.ts +103 -0
  23. package/dist/src/schema_types.js +3 -0
  24. package/dist/src/session/session_manager.js +2 -2
  25. package/dist/src/session/session_storage.js +1 -1
  26. package/dist/src/session/signer_session_manager.d.ts +16 -29
  27. package/dist/src/session/signer_session_manager.js +27 -78
  28. package/dist/src/signer_session.d.ts +232 -125
  29. package/dist/src/signer_session.js +149 -250
  30. package/dist/src/util.d.ts +20 -0
  31. package/dist/src/util.js +31 -2
  32. package/package.json +13 -11
  33. package/src/client.ts +1217 -7
  34. package/src/ethers/index.ts +11 -18
  35. package/src/index.ts +149 -101
  36. package/src/key.ts +28 -121
  37. package/src/mfa.ts +202 -0
  38. package/src/org.ts +126 -275
  39. package/src/paginator.ts +122 -0
  40. package/src/role.ts +108 -181
  41. package/src/schema.ts +1673 -520
  42. package/src/schema_types.ts +103 -0
  43. package/src/session/session_manager.ts +2 -2
  44. package/src/session/session_storage.ts +1 -1
  45. package/src/session/signer_session_manager.ts +38 -108
  46. package/src/signer_session.ts +164 -323
  47. package/src/util.ts +41 -0
package/README.md CHANGED
@@ -113,7 +113,8 @@ transaction. For that, we need a key of type `Secp256k1.Evm`.
113
113
  const secpKey = await org.createKey(cs.Secp256k1.Evm);
114
114
  assert((await secpKey.owner()) == me.user_id);
115
115
  assert(await secpKey.enabled());
116
- console.log(`Created '${await secpKey.type()}' key ${secpKey.id}`);
116
+ assert(await secpKey.type(), cs.Secp256k1.Evm);
117
+ console.log(`Created '${cs.Secp256k1.Evm}' key ${secpKey.id}`);
117
118
  ```
118
119
 
119
120
  ### Create a `Role` and a `SignerSession`
@@ -351,12 +352,29 @@ export the underlying token:
351
352
  const oidcToken = await cubesigner.sessionMgr!.token();
352
353
  ```
353
354
 
354
- and then exchange it for either a _signer_ session (i.e., an instance
355
- of `SignerSession`, required by all signing endpoints, e.g.,
356
- `signEvm`)
355
+ Before we can use the OIDC token for authentication, we must add an org policy
356
+ to allow the particular issuer/audience pair from the token.
357
357
 
358
358
  ```typescript
359
- const oidcSession = new cs.SignerSession(await cubesigner.oidcAuth(oidcToken, org.id, ["sign:*"]));
359
+ const oldOrgPolicy = await org.policy();
360
+ const oidcPayload = JSON.parse(atob(oidcToken.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")));
361
+ const oidcAuthSourcesPolicy = {
362
+ OidcAuthSources: {
363
+ [oidcPayload.iss]: [oidcPayload.aud],
364
+ },
365
+ };
366
+ console.log("Setting org policy", oidcAuthSourcesPolicy);
367
+ await org.setPolicy([oidcAuthSourcesPolicy]);
368
+ ```
369
+
370
+ Finally, exchange the OIDC token for either a _signer_ session (i.e., an instance
371
+ of `SignerSession`, required by all signing endpoints, e.g., `signEvm`)
372
+
373
+ ```typescript
374
+ const oidcSession = new cs.SignerSession(
375
+ // we'll use this session for both signing and approving MFA request, hence the following scopes
376
+ await cubesigner.oidcAuth(oidcToken, org.id, ["manage:mfa", "sign:*"]),
377
+ );
360
378
  ```
361
379
 
362
380
  or a _management_ session (i.e., and instance of `CubeSigner`,
@@ -382,26 +400,56 @@ doesn't matter if that user is native to CubeSigner or a third-party
382
400
  OIDC user. For that purpose, in this section we are going to use the
383
401
  previously created `oidcCubeSigner` instance.
384
402
 
385
- To set up TOTP, we call the `resetTotp` method which creates a new
386
- TOTP configuration for the users (overwriting the previous one, if
387
- any) and returns a [TOTP
388
- url](https://github.com/google/google-authenticator/wiki/Key-Uri-Format).
403
+ To set up TOTP, we first call the `resetTotpStart` method to initiate a
404
+ TOTP reset procedure.
389
405
 
390
406
  ```typescript
391
407
  console.log(`Setting up TOTP for user ${me.email}`);
392
- const totpResp = await oidcCubeSigner.resetTotp();
393
- assert(totpResp.totp_url);
408
+ let totpResetResp = await oidcCubeSigner.resetTotpStart();
394
409
  ```
395
410
 
411
+ If the user has already configured TOTP (or any other form of MFA),
412
+ this response will require multi factor authentication. In that case,
413
+ for example, call `approveTotp` and provide the code for the existing
414
+ TOTP to proceed:
415
+
416
+ ```typescript
417
+ import { authenticator } from "otplib"; // npm install otplib@12.0.1
418
+
419
+ let totpSecret = process.env["CS_USER_TOTP_SECRET"]!;
420
+ if (totpResetResp.requiresMfa()) {
421
+ console.log("Resetting TOTP requires MFA");
422
+ const code = authenticator.generate(totpSecret);
423
+ totpResetResp = await totpResetResp.approveTotp(oidcSession, code);
424
+ assert(!totpResetResp.requiresMfa());
425
+ console.log("MFA approved using existing TOTP");
426
+ }
427
+ ```
428
+
429
+ The response contains a TOTP challenge, i.e., a new TOTP
430
+ configuration in the form of the standard
431
+ [TOTP url](https://github.com/google/google-authenticator/wiki/Key-Uri-Format).
396
432
  From that url, we can generate a QR code to present to the user, or
397
433
  create an authenticator for automated testing.
398
434
 
399
435
  ```typescript
400
- import { authenticator } from "otplib"; // npm install otplib@12.0.1
436
+ const totpChallenge = totpResetResp.data();
437
+ assert(totpChallenge.totpUrl);
438
+ ```
401
439
 
402
- const totpSecret = new URL(totpResp.totp_url).searchParams.get("secret");
440
+ To complete the challenge, we must call `resetTotpComplete` and
441
+ provide the TOTP code matching the TOTP configuration from the challenge:
442
+
443
+ ```typescript norun
444
+ totpSecret = new URL(totpChallenge.totp_url).searchParams.get("secret");
403
445
  assert(totpSecret);
446
+ await totpChallenge.answer(authenticator.generate(totpSecret));
447
+ ```
448
+
449
+ After TOTP is configured, we can double check that our authenticator
450
+ is generating the correct code by calling `verifyTotp`
404
451
 
452
+ ```typescript
405
453
  console.log(`Verifying current TOTP code`);
406
454
  let code = authenticator.generate(totpSecret);
407
455
  await oidcCubeSigner.verifyTotp(code);
@@ -461,6 +509,11 @@ we created.
461
509
  console.log("Cleaning up");
462
510
  await session.sessionMgr.revoke();
463
511
  await role.delete();
512
+
513
+ // restore the old policy for the sake of repeatability of this example
514
+ // (normally you'd set your org policies once and leave them be)
515
+ console.log("Restoring org policy", oldOrgPolicy);
516
+ await org.setPolicy(oldOrgPolicy);
464
517
  ```
465
518
 
466
519
  As of now, deleting keys is not supported.
@@ -1,10 +1,437 @@
1
1
  import createClient from "openapi-fetch";
2
2
  import { paths } from "./schema";
3
- /** Type of http client.
4
- * @internal
5
- * */
3
+ import { SignerSessionData, SignerSessionLifetime, SignerSessionManager } from "./session/signer_session_manager";
4
+ import { CreateOidcUserOptions, IdentityProof, KeyInRoleInfo, KeyInfoApi, ListKeysResponse, ListRoleKeysResponse, ListRoleUsersResponse, ListRolesResponse, OidcIdentity, SessionsResponse, PublicKeyCredential, RoleInfo, UpdateKeyRequest, UpdateOrgRequest, UpdateOrgResponse, UpdateRoleRequest, UserIdInfo, UserInRoleInfo, UserInfo, SessionInfo, OrgInfo, RatchetConfig, OidcAuthResponse, EvmSignRequest, EvmSignResponse, Eth2SignRequest, Eth2SignResponse, Eth2StakeRequest, Eth2StakeResponse, Eth2UnstakeRequest, Eth2UnstakeResponse, BlobSignRequest, BlobSignResponse, BtcSignResponse, BtcSignRequest, SolanaSignRequest, SolanaSignResponse, AvaSignResponse, AvaTx, MfaRequestInfo, MemberRole } from "./schema_types";
5
+ import { AddFidoChallenge, MfaFidoChallenge, MfaReceipt, TotpChallenge } from "./mfa";
6
+ import { CubeSignerResponse } from "./signer_session";
7
+ import { Key, KeyType } from "./key";
8
+ import { PageOpts, Paginator } from "./paginator";
9
+ import { KeyPolicy } from "./role";
10
+ import { EnvInterface } from "./env";
11
+ /** @internal */
6
12
  export type Client = ReturnType<typeof createClient<paths>>;
7
- /** Re-export schema.
8
- * @internal
9
- * */
10
- export * from "./schema";
13
+ export { paths };
14
+ /**
15
+ * Client to use to send requests to CubeSigner services
16
+ * when authenticating using a CubeSigner session token.
17
+ */
18
+ export declare class CubeSignerClient {
19
+ #private;
20
+ /** Underlying session manager */
21
+ get sessionMgr(): SignerSessionManager;
22
+ /**
23
+ * Constructor.
24
+ * @param {SignerSessionManager} sessionMgr The session manager to use
25
+ * @param {string?} orgId Optional organization ID; if omitted, uses the org ID from the session manager.
26
+ */
27
+ constructor(sessionMgr: SignerSessionManager, orgId?: string);
28
+ /**
29
+ * Returns a new instance of this class using the same session manager but targeting a different organization.
30
+ *
31
+ * @param {string} orgId The organization ID.
32
+ * @return {CubeSignerClient} A new instance of this class using the same session manager but targeting different organization.
33
+ */
34
+ withOrg(orgId?: string): CubeSignerClient;
35
+ /** Org id */
36
+ get orgId(): string;
37
+ /**
38
+ * Obtain information about the current user.
39
+ *
40
+ * @return {Promise<UserInfo>} Retrieves information about the current user.
41
+ */
42
+ userGet(): Promise<UserInfo>;
43
+ /**
44
+ * Creates a request to change user's TOTP. This request returns a new TOTP challenge
45
+ * that must be answered by calling `userResetTotpComplete`
46
+ *
47
+ * @param {MfaReceipt} mfaReceipt MFA receipt to include in HTTP headers
48
+ */
49
+ userResetTotpInit(mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<TotpChallenge>>;
50
+ /**
51
+ * Answer the TOTP challenge issued by `userResetTotpInit`. If successful, user's
52
+ * TOTP configuration will be updated to that of the TOTP challenge.
53
+ *
54
+ * @param {string} totpId - The ID of the TOTP challenge
55
+ * @param {string} code - The TOTP code that should verify against the TOTP configuration from the challenge.
56
+ */
57
+ userResetTotpComplete(totpId: string, code: string): Promise<void>;
58
+ /**
59
+ * Verifies a given TOTP code against the current user's TOTP configuration.
60
+ * Throws an error if the verification fails.
61
+ *
62
+ * @param {string} code Current TOTP code
63
+ */
64
+ userVerifyTotp(code: string): Promise<void>;
65
+ /**
66
+ * Initiate adding a new FIDO device. MFA may be required. This returns a challenge that must
67
+ * be answered with `userRegisterFidoComplete` (after MFA approvals).
68
+ *
69
+ * @param {string} name The name of the new device.
70
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt to include in HTTP headers
71
+ * @return {Promise<CubeSignerResponse<AddFidoChallenge>>} A challenge that must be answered in order to complete FIDO registration.
72
+ */
73
+ userRegisterFidoInit(name: string, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<AddFidoChallenge>>;
74
+ /**
75
+ * Complete a previously initiated request to add a new FIDO device.
76
+ * @param {string} challengeId The ID of the challenge returned by the remote end.
77
+ * @param {PublicKeyCredential} credential The answer to the challenge.
78
+ */
79
+ userRegisterFidoComplete(challengeId: string, credential: PublicKeyCredential): Promise<void>;
80
+ /**
81
+ * Obtain information about the current organization.
82
+ * @return {Org} Information about the organization.
83
+ */
84
+ orgGet(): Promise<OrgInfo>;
85
+ /**
86
+ * Update the org.
87
+ * @param {UpdateOrgRequest} request The JSON request to send to the API server.
88
+ * @return {UpdateOrgResponse} Updated org information.
89
+ */
90
+ orgUpdate(request: UpdateOrgRequest): Promise<UpdateOrgResponse>;
91
+ /**
92
+ * Create a new (first-party) user in the organization and send an email invitation to that user.
93
+ *
94
+ * @param {string} email Email of the user
95
+ * @param {string} name The full name of the user
96
+ * @param {MemberRole} role Optional role. Defaults to "alien.
97
+ */
98
+ orgUserInvite(email: string, name: string, role?: MemberRole): Promise<void>;
99
+ /**
100
+ * List users.
101
+ * @return {User[]} Org users.
102
+ */
103
+ orgUsersList(): Promise<UserIdInfo[]>;
104
+ /**
105
+ * Create a new OIDC user. This can be a first-party "Member" or third-party "Alien".
106
+ * @param {OidcIdentity} identity The identity of the OIDC user
107
+ * @param {string} email Email of the OIDC user
108
+ * @param {CreateOidcUserOptions} opts Additional options for new OIDC users
109
+ * @return {string} User id of the new user
110
+ */
111
+ orgUserCreateOidc(identity: OidcIdentity, email: string, opts?: CreateOidcUserOptions): Promise<string>;
112
+ /**
113
+ * Delete an existing OIDC user.
114
+ * @param {OidcIdentity} identity The identity of the OIDC user
115
+ */
116
+ orgUserDeleteOidc(identity: OidcIdentity): Promise<{
117
+ status: string;
118
+ }>;
119
+ /**
120
+ * Get a key by its id.
121
+ *
122
+ * @param {string} keyId The id of the key to get.
123
+ * @return {KeyInfoApi} The key information.
124
+ */
125
+ keyGet(keyId: string): Promise<KeyInfoApi>;
126
+ /**
127
+ * Update key.
128
+ * @param {string} keyId The ID of the key to update.
129
+ * @param {UpdateKeyRequest} request The JSON request to send to the API server.
130
+ * @return {KeyInfoApi} The JSON response from the API server.
131
+ */
132
+ keyUpdate(keyId: string, request: UpdateKeyRequest): Promise<KeyInfoApi>;
133
+ /**
134
+ * Deletes a key.
135
+ *
136
+ * @param {string} keyId - Key id
137
+ */
138
+ keyDelete(keyId: string): Promise<void>;
139
+ /**
140
+ * Create new signing keys.
141
+ *
142
+ * @param {KeyType} keyType The type of key to create.
143
+ * @param {number} count The number of keys to create.
144
+ * @param {string?} ownerId The owner of the keys. Defaults to the session's user.
145
+ * @return {KeyInfoApi[]} The new keys.
146
+ */
147
+ keysCreate(keyType: KeyType, count: number, ownerId?: string): Promise<KeyInfoApi[]>;
148
+ /**
149
+ * Derive a set of keys of a specified type using a supplied derivation path and an existing long-lived mnemonic.
150
+ *
151
+ * The owner of the derived key will be the owner of the mnemonic.
152
+ *
153
+ * @param {KeyType} keyType The type of key to create.
154
+ * @param {string[]} derivationPaths Derivation paths from which to derive new keys.
155
+ * @param {string} mnemonicId materialId of mnemonic key used to derive the new key.
156
+ *
157
+ * @return {KeyInfoApi[]} The newly derived keys.
158
+ */
159
+ keysDerive(keyType: KeyType, derivationPaths: string[], mnemonicId: string): Promise<KeyInfoApi[]>;
160
+ /**
161
+ * List all keys in the org.
162
+ * @param {KeyType?} type Optional key type to filter list for.
163
+ * @param {PageOpts?} page Pagination options. Defaults to fetching the entire result set.
164
+ * @return {Paginator<ListKeysResponse, KeyInfoApi>} Paginator for iterating over keys.
165
+ */
166
+ keysList(type?: KeyType, page?: PageOpts): Paginator<ListKeysResponse, KeyInfoApi>;
167
+ /**
168
+ * Create a new role.
169
+ *
170
+ * @param {string?} name The optional name of the role.
171
+ * @return {string} The ID of the new role.
172
+ */
173
+ roleCreate(name?: string): Promise<string>;
174
+ /**
175
+ * Get a role by its id (or name).
176
+ * @param {string} roleId The id of the role to get.
177
+ * @return {RoleInfo} The role.
178
+ */
179
+ roleGet(roleId: string): Promise<RoleInfo>;
180
+ /**
181
+ * Update a role.
182
+ *
183
+ * @param {string} roleId The ID of the role to update.
184
+ * @param {UpdateRoleRequest} request The update request.
185
+ * @return {Promise<RoleInfo>} The updated role information.
186
+ */
187
+ roleUpdate(roleId: string, request: UpdateRoleRequest): Promise<RoleInfo>;
188
+ /**
189
+ * Delete a role by its ID.
190
+ *
191
+ * @param {string} roleId The ID of the role to delete.
192
+ */
193
+ roleDelete(roleId: string): Promise<void>;
194
+ /**
195
+ * List all roles in the org.
196
+ *
197
+ * @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
198
+ * @return {RoleInfo} Paginator for iterating over roles.
199
+ */
200
+ rolesList(page?: PageOpts): Paginator<ListRolesResponse, RoleInfo>;
201
+ /**
202
+ * Add existing keys to an existing role.
203
+ *
204
+ * @param {string} roleId The ID of the role
205
+ * @param {string[]} keyIds The IDs of the keys to add to the role.
206
+ * @param {KeyPolicy?} policy The optional policy to apply to each key.
207
+ */
208
+ roleKeysAdd(roleId: string, keyIds: string[], policy?: KeyPolicy): Promise<void>;
209
+ /**
210
+ * Remove an existing key from an existing role.
211
+ *
212
+ * @param {string} roleId The ID of the role
213
+ * @param {string} keyId The ID of the key to remove from the role
214
+ */
215
+ roleKeysRemove(roleId: string, keyId: string): Promise<void>;
216
+ /**
217
+ * List all keys in a role.
218
+ *
219
+ * @param {string} roleId The ID of the role whose keys to retrieve.
220
+ * @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
221
+ * @return {Paginator<ListRoleKeysResponse, KeyInRoleInfo>} Paginator for iterating over the keys in the role.
222
+ */
223
+ roleKeysList(roleId: string, page?: PageOpts): Paginator<ListRoleKeysResponse, KeyInRoleInfo>;
224
+ /**
225
+ * Add an existing user to an existing role.
226
+ *
227
+ * @param {string} roleId The ID of the role.
228
+ * @param {string} userId The ID of the user to add to the role.
229
+ */
230
+ roleUserAdd(roleId: string, userId: string): Promise<void>;
231
+ /**
232
+ * List all users in a role.
233
+ *
234
+ * @param {string} roleId The ID of the role whose users to retrieve.
235
+ * @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
236
+ * @return {Paginator<ListRoleUsersResponse, UserInRoleInfo>} Paginator for iterating over the users in the role.
237
+ */
238
+ roleUsersList(roleId: string, page?: PageOpts): Paginator<ListRoleUsersResponse, UserInRoleInfo>;
239
+ /**
240
+ * Create a new signer session for a given role.
241
+ *
242
+ * @param {string} roleId Role ID
243
+ * @param {string} purpose The purpose of the session
244
+ * @param {string[]} scopes Session scopes. Only `sign:*` scopes are allowed.
245
+ * @param {SignerSessionLifetime} lifetimes Lifetime settings
246
+ * @return {Promise<SignerSessionData>} New signer session info.
247
+ */
248
+ sessionCreateForRole(roleId: string, purpose: string, scopes?: string[], lifetimes?: SignerSessionLifetime): Promise<SignerSessionData>;
249
+ /**
250
+ * Revoke a session.
251
+ *
252
+ * @param {string} sessionId The ID of the session to revoke.
253
+ */
254
+ sessionRevoke(sessionId: string): Promise<void>;
255
+ /**
256
+ * Returns a paginator for iterating over all signer sessions optionally filtered by a role.
257
+ *
258
+ * @param {string?} roleId If set, limit to sessions for this role only.
259
+ * @param {PageOpts?} page Pagination options. Defaults to fetching the entire result set.
260
+ * @return {Promise<SignerSessionInfo[]>} Signer sessions for this role.
261
+ */
262
+ sessionsList(roleId?: string, page?: PageOpts): Paginator<SessionsResponse, SessionInfo>;
263
+ /**
264
+ * Returns the list of keys that this session has access to.
265
+ * @return {Key[]} The list of keys.
266
+ */
267
+ sessionKeysList(): Promise<KeyInfoApi[]>;
268
+ /**
269
+ * Obtain proof of authentication using the current CubeSigner session.
270
+ *
271
+ * @return {Promise<IdentityProof>} Proof of authentication
272
+ */
273
+ identityProve(): Promise<IdentityProof>;
274
+ /**
275
+ * Checks if a given identity proof is valid.
276
+ *
277
+ * @param {IdentityProof} proof The proof of authentication.
278
+ */
279
+ identityVerify(proof: IdentityProof): Promise<void>;
280
+ /**
281
+ * Retrieves existing MFA request.
282
+ *
283
+ * @param {string} mfaId MFA request ID
284
+ * @return {Promise<MfaRequestInfo>} MFA request information
285
+ */
286
+ mfaGet(mfaId: string): Promise<MfaRequestInfo>;
287
+ /**
288
+ * List pending MFA requests accessible to the current user.
289
+ *
290
+ * @return {Promise<MfaRequestInfo[]>} The MFA requests.
291
+ */
292
+ mfaList(): Promise<MfaRequestInfo[]>;
293
+ /**
294
+ * Approve a pending MFA request using the current session.
295
+ *
296
+ * @param {string} mfaId The id of the MFA request
297
+ * @return {Promise<MfaRequestInfo>} The result of the MFA request
298
+ */
299
+ mfaApprove(mfaId: string): Promise<MfaRequestInfo>;
300
+ /**
301
+ * Approve a pending MFA request using TOTP.
302
+ *
303
+ * @param {string} mfaId The MFA request to approve
304
+ * @param {string} code The TOTP code
305
+ * @return {Promise<MfaRequestInfo>} The current status of the MFA request
306
+ */
307
+ mfaApproveTotp(mfaId: string, code: string): Promise<MfaRequestInfo>;
308
+ /**
309
+ * Initiate approval of an existing MFA request using FIDO.
310
+ *
311
+ * @param {string} mfaId The MFA request ID.
312
+ * @return {Promise<MfaFidoChallenge>} A challenge that needs to be answered to complete the approval.
313
+ */
314
+ mfaApproveFidoInit(mfaId: string): Promise<MfaFidoChallenge>;
315
+ /**
316
+ * Complete a previously initiated MFA request approval using FIDO.
317
+ *
318
+ * @param {string} mfaId The MFA request ID
319
+ * @param {string} challengeId The challenge ID
320
+ * @param {PublicKeyCredential} credential The answer to the challenge
321
+ * @return {Promise<MfaRequestInfo>} The current status of the MFA request.
322
+ */
323
+ mfaApproveFidoComplete(mfaId: string, challengeId: string, credential: PublicKeyCredential): Promise<MfaRequestInfo>;
324
+ /**
325
+ * Sign an EVM transaction.
326
+ * @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
327
+ * @param {EvmSignRequest} req What to sign.
328
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt.
329
+ * @return {Promise<EvmSignResponse | AcceptedResponse>} Signature (or MFA approval request).
330
+ */
331
+ signEvm(key: Key | string, req: EvmSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<EvmSignResponse>>;
332
+ /**
333
+ * Sign an Eth2/Beacon-chain validation message.
334
+ *
335
+ * @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
336
+ * @param {Eth2SignRequest} req What to sign.
337
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt
338
+ * @return {Promise<Eth2SignResponse | AcceptedResponse>} Signature
339
+ */
340
+ signEth2(key: Key | string, req: Eth2SignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<Eth2SignResponse>>;
341
+ /**
342
+ * Sign an Eth2/Beacon-chain deposit (or staking) message.
343
+ *
344
+ * @param {Eth2StakeRequest} req The request to sign.
345
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt
346
+ * @return {Promise<Eth2StakeResponse | AcceptedResponse>} The response.
347
+ */
348
+ signStake(req: Eth2StakeRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<Eth2StakeResponse>>;
349
+ /**
350
+ * Sign an Eth2/Beacon-chain unstake/exit request.
351
+ *
352
+ * @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
353
+ * @param {Eth2UnstakeRequest} req The request to sign.
354
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt
355
+ * @return {Promise<Eth2UnstakeResponse | AcceptedResponse>} The response.
356
+ */
357
+ signUnstake(key: Key | string, req: Eth2UnstakeRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<Eth2UnstakeResponse>>;
358
+ /**
359
+ * Sign an Avalanche P- or X-chain message.
360
+ * @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
361
+ * @param {AvaTx} tx Avalanche message (transaction) to sign
362
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt
363
+ * @return {Promise<AvaSignResponse | AcceptedResponse>} The response.
364
+ */
365
+ signAva(key: Key | string, tx: AvaTx, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<AvaSignResponse>>;
366
+ /**
367
+ * Sign a raw blob.
368
+ *
369
+ * This requires the key to have a '"AllowRawBlobSigning"' policy. This is because
370
+ * signing arbitrary messages is, in general, dangerous (and you should instead
371
+ * prefer typed end-points as used by, for example, `signEvm`). For Secp256k1 keys,
372
+ * for example, you **must** call this function with a message that is 32 bytes long and
373
+ * the output of a secure hash function.
374
+ *
375
+ * This function returns signatures serialized as;
376
+ *
377
+ * - ECDSA signatures are serialized as big-endian r and s plus recovery-id
378
+ * byte v, which can in general take any of the values 0, 1, 2, or 3.
379
+ *
380
+ * - EdDSA signatures are serialized in the standard format.
381
+ *
382
+ * - BLS signatures are not supported on the blob-sign endpoint.
383
+ *
384
+ * @param {Key | string} key The key to sign with (either {@link Key} or its ID).
385
+ * @param {BlobSignRequest} req What to sign
386
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt
387
+ * @return {Promise<BlobSignResponse | AcceptedResponse>} The response.
388
+ */
389
+ signBlob(key: Key | string, req: BlobSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<BlobSignResponse>>;
390
+ /**
391
+ * Sign a Bitcoin message.
392
+ *
393
+ * @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
394
+ * @param {BtcSignRequest} req What to sign
395
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt
396
+ * @return {Promise<BtcSignResponse | AcceptedResponse>} The response.
397
+ */
398
+ signBtc(key: Key | string, req: BtcSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<BtcSignResponse>>;
399
+ /**
400
+ * Sign a Solana message.
401
+ *
402
+ * @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
403
+ * @param {SolanaSignRequest} req What to sign
404
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt
405
+ * @return {Promise<SolanaSignResponse | AcceptedResponse>} The response.
406
+ */
407
+ signSolana(key: Key | string, req: SolanaSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<SolanaSignResponse>>;
408
+ /** HTTPS client */
409
+ private client;
410
+ }
411
+ /**
412
+ * Client to use to send requests to CubeSigner services
413
+ * when authenticating using an OIDC token.
414
+ */
415
+ export declare class OidcClient {
416
+ #private;
417
+ /**
418
+ * @param {EnvInterface} env CubeSigner deployment
419
+ * @param {string} orgId Target organization ID
420
+ * @param {string} oidcToken User's OIDC token
421
+ */
422
+ constructor(env: EnvInterface, orgId: string, oidcToken: string);
423
+ /**
424
+ * Exchange an OIDC token for a CubeSigner session token.
425
+ * @param {List<string>} scopes The scopes for the new session
426
+ * @param {RatchetConfig} lifetimes Lifetimes of the new session.
427
+ * @param {MfaReceipt} mfaReceipt Optional MFA receipt (id + confirmation code)
428
+ * @return {Promise<CubeSignerResponse<OidcAuthResponse>>} The session data.
429
+ */
430
+ sessionCreate(scopes: Array<string>, lifetimes?: RatchetConfig, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<OidcAuthResponse>>;
431
+ /**
432
+ * Exchange an OIDC token for a proof of authentication.
433
+ *
434
+ * @return {Promise<IdentityProof>} Proof of authentication
435
+ */
436
+ identityProve(): Promise<IdentityProof>;
437
+ }