@cubist-labs/cubesigner-sdk 0.4.270 → 0.4.273
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/dist/package.json +1 -1
- package/dist/src/audit_log.d.ts +3 -3
- package/dist/src/client/api_client.d.ts +40 -3
- package/dist/src/client/api_client.d.ts.map +1 -1
- package/dist/src/client/api_client.js +63 -5
- package/dist/src/client.d.ts +9 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +12 -1
- package/dist/src/key.d.ts +11 -1
- package/dist/src/key.d.ts.map +1 -1
- package/dist/src/key.js +13 -1
- package/dist/src/org.d.ts +11 -1
- package/dist/src/org.d.ts.map +1 -1
- package/dist/src/org.js +16 -3
- package/dist/src/role.d.ts +7 -1
- package/dist/src/role.d.ts.map +1 -1
- package/dist/src/role.js +5 -1
- package/dist/src/schema.d.ts +410 -45
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts +4 -0
- package/dist/src/schema_types.d.ts.map +1 -1
- package/dist/src/schema_types.js +5 -1
- package/dist/src/scopes.d.ts.map +1 -1
- package/dist/src/scopes.js +6 -2
- package/package.json +1 -1
- package/src/client/api_client.ts +88 -6
- package/src/client.ts +14 -0
- package/src/key.ts +18 -0
- package/src/org.ts +16 -2
- package/src/role.ts +11 -1
- package/src/schema.ts +422 -38
- package/src/schema_types.ts +8 -0
- package/src/scopes.ts +5 -1
package/src/client/api_client.ts
CHANGED
|
@@ -74,6 +74,8 @@ import type {
|
|
|
74
74
|
PolicyInfo,
|
|
75
75
|
JsonRpcRequest,
|
|
76
76
|
JsonRpcResult,
|
|
77
|
+
Eip7702SignRequest,
|
|
78
|
+
SignResponse,
|
|
77
79
|
} from "../schema_types.ts";
|
|
78
80
|
import { encodeToBase64 } from "../util.ts";
|
|
79
81
|
import { auditLogEntrySchema } from "../audit_log.ts";
|
|
@@ -723,7 +725,7 @@ export class ApiClient extends BaseClient {
|
|
|
723
725
|
|
|
724
726
|
// #endregion
|
|
725
727
|
|
|
726
|
-
// #region ORG USERS: orgUserInvite, orgUserDelete, orgUsersList, orgUserGet, orgUserGetByEmail, orgUserCreateOidc, orgUserDeleteOidc
|
|
728
|
+
// #region ORG USERS: orgUserInvite, orgUserDelete, orgUsersList, orgUserGet, orgUserGetByEmail, orgUserCreateOidc, orgUserDeleteOidc, resetUserMfaInit, resetUserMfaComplete
|
|
727
729
|
|
|
728
730
|
/**
|
|
729
731
|
* Create a new (first-party) user in the organization and send an email invitation to that user.
|
|
@@ -923,6 +925,55 @@ export class ApiClient extends BaseClient {
|
|
|
923
925
|
});
|
|
924
926
|
}
|
|
925
927
|
|
|
928
|
+
/**
|
|
929
|
+
* Initiate an MFA reset for a user in the org (then the user must call {@link resetUserMfaComplete}).
|
|
930
|
+
*
|
|
931
|
+
* Can only be called by an org owner. The target may be any org user with an
|
|
932
|
+
* email configured; the backend emails them a short-lived reset token, which
|
|
933
|
+
* the user can use to complete the reset.
|
|
934
|
+
*
|
|
935
|
+
* @param userId The id of the user whose MFA should be reset.
|
|
936
|
+
* @returns An empty response
|
|
937
|
+
*/
|
|
938
|
+
async resetUserMfaInit(userId: string): Promise<Empty> {
|
|
939
|
+
const o = op("/v0/org/{org_id}/users/reset_mfa", "post");
|
|
940
|
+
|
|
941
|
+
return this.exec(o, {
|
|
942
|
+
body: { user_id: userId },
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Complete an MFA reset for a user in the org (after an org owner initiates
|
|
948
|
+
* with {@link resetUserMfaInit}).
|
|
949
|
+
*
|
|
950
|
+
* Clears all of the calling user's MFA factors. Authenticated via an OIDC
|
|
951
|
+
* token, since an MFA-locked user cannot complete a session login.
|
|
952
|
+
*
|
|
953
|
+
* @param env The environment to use
|
|
954
|
+
* @param orgId The org the user belongs to
|
|
955
|
+
* @param oidcToken An OIDC token identifying the user whose MFA is being reset
|
|
956
|
+
* @param resetToken The reset token emailed to the user by {@link resetUserMfaInit}
|
|
957
|
+
* @param headers Optional headers to set
|
|
958
|
+
*/
|
|
959
|
+
static async resetUserMfaComplete(
|
|
960
|
+
env: EnvInterface,
|
|
961
|
+
orgId: string,
|
|
962
|
+
oidcToken: string,
|
|
963
|
+
resetToken: string,
|
|
964
|
+
headers?: HeadersInit,
|
|
965
|
+
): Promise<void> {
|
|
966
|
+
const o = op("/v0/org/{org_id}/users/reset_mfa", "patch");
|
|
967
|
+
await retryOn5XX(() =>
|
|
968
|
+
o({
|
|
969
|
+
baseUrl: env.SignerApiRoot,
|
|
970
|
+
params: { path: { org_id: orgId } },
|
|
971
|
+
body: { token: resetToken },
|
|
972
|
+
headers: mergeHeaders(headers, authHeader(oidcToken)),
|
|
973
|
+
}),
|
|
974
|
+
).then(assertOk);
|
|
975
|
+
}
|
|
976
|
+
|
|
926
977
|
// #endregion
|
|
927
978
|
|
|
928
979
|
// #region KEYS: keyGet, keyAttest, keyUpdate, keyDelete, keysCreate, keysDerive, keysList, keyHistory
|
|
@@ -2144,13 +2195,17 @@ export class ApiClient extends BaseClient {
|
|
|
2144
2195
|
/**
|
|
2145
2196
|
* List pending MFA requests accessible to the current user.
|
|
2146
2197
|
*
|
|
2147
|
-
* @
|
|
2198
|
+
* @param page Pagination options. Defaults to fetching the entire result set.
|
|
2199
|
+
* @returns Paginator for iterating over the MFA requests.
|
|
2148
2200
|
*/
|
|
2149
|
-
|
|
2201
|
+
mfaList(page?: PageOpts): Paginator<schemas["PaginatedListMfaResponse"], MfaRequestInfo[]> {
|
|
2150
2202
|
const o = op("/v0/org/{org_id}/mfa", "get");
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2203
|
+
return Paginator.items(
|
|
2204
|
+
page ?? Page.default(),
|
|
2205
|
+
(query) => this.exec(o, { params: { query } }),
|
|
2206
|
+
(r) => r.mfa_requests,
|
|
2207
|
+
(r) => r.last_evaluated_key,
|
|
2208
|
+
);
|
|
2154
2209
|
}
|
|
2155
2210
|
|
|
2156
2211
|
/**
|
|
@@ -2350,6 +2405,33 @@ export class ApiClient extends BaseClient {
|
|
|
2350
2405
|
return await CubeSignerResponse.create(this.env, signFn, mfaReceipt);
|
|
2351
2406
|
}
|
|
2352
2407
|
|
|
2408
|
+
/**
|
|
2409
|
+
* Sign EIP-7702 authorization request.
|
|
2410
|
+
*
|
|
2411
|
+
* This requires the key to have a '"AllowEip7702Signing"' {@link KeyPolicy}.
|
|
2412
|
+
*
|
|
2413
|
+
* @param key The key to sign with (either {@link Key} or its material ID).
|
|
2414
|
+
* @param req What to sign
|
|
2415
|
+
* @param mfaReceipt Optional MFA receipt(s)
|
|
2416
|
+
* @returns Signature (or MFA approval request).
|
|
2417
|
+
*/
|
|
2418
|
+
async signEip7702(
|
|
2419
|
+
key: Key | string,
|
|
2420
|
+
req: Eip7702SignRequest,
|
|
2421
|
+
mfaReceipt?: MfaReceipts,
|
|
2422
|
+
): Promise<CubeSignerResponse<SignResponse>> {
|
|
2423
|
+
const o = op("/v0/org/{org_id}/evm/eip7702/sign/{pubkey}", "post");
|
|
2424
|
+
|
|
2425
|
+
const pubkey = typeof key === "string" ? (key as string) : key.materialId;
|
|
2426
|
+
const signFn = async (headers?: HeadersInit) =>
|
|
2427
|
+
this.exec(o, {
|
|
2428
|
+
params: { path: { pubkey } },
|
|
2429
|
+
body: req,
|
|
2430
|
+
headers,
|
|
2431
|
+
});
|
|
2432
|
+
return await CubeSignerResponse.create(this.env, signFn, mfaReceipt);
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2353
2435
|
/**
|
|
2354
2436
|
* Sign an Eth2/Beacon-chain validation message.
|
|
2355
2437
|
*
|
package/src/client.ts
CHANGED
|
@@ -160,6 +160,20 @@ export class CubeSignerClient {
|
|
|
160
160
|
return await ApiClient.identityProveOidc(...args);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Complete an MFA reset for a user in the org. The reset must first be
|
|
165
|
+
* initiated by an org owner via {@link Org.resetUserMfaInit}.
|
|
166
|
+
*
|
|
167
|
+
* Same as {@link ApiClient.resetUserMfaComplete}, see its documentation for more details.
|
|
168
|
+
*
|
|
169
|
+
* @param args Request arguments
|
|
170
|
+
*/
|
|
171
|
+
static async resetUserMfaComplete(
|
|
172
|
+
...args: Parameters<typeof ApiClient.resetUserMfaComplete>
|
|
173
|
+
): Promise<void> {
|
|
174
|
+
await ApiClient.resetUserMfaComplete(...args);
|
|
175
|
+
}
|
|
176
|
+
|
|
163
177
|
/**
|
|
164
178
|
* Initialize email OTP authentication.
|
|
165
179
|
*
|
package/src/key.ts
CHANGED
|
@@ -30,6 +30,8 @@ import type {
|
|
|
30
30
|
KeyInfoJwt,
|
|
31
31
|
KeyAttestationQuery,
|
|
32
32
|
KeyPropertiesPatch,
|
|
33
|
+
Eip7702SignRequest,
|
|
34
|
+
SignResponse,
|
|
33
35
|
} from "./schema_types.ts";
|
|
34
36
|
import type {
|
|
35
37
|
ApiClient,
|
|
@@ -553,6 +555,22 @@ export class Key {
|
|
|
553
555
|
return await this.#apiClient.signEip712(this, req, mfaReceipt);
|
|
554
556
|
}
|
|
555
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Sign EIP-7702 authorization request.
|
|
560
|
+
*
|
|
561
|
+
* This requires the key to have a '"AllowEip7702Signing"' {@link KeyPolicy}.
|
|
562
|
+
*
|
|
563
|
+
* @param req What to sign
|
|
564
|
+
* @param mfaReceipt Optional MFA receipt(s)
|
|
565
|
+
* @returns Signature (or MFA approval request).
|
|
566
|
+
*/
|
|
567
|
+
async signEip7702(
|
|
568
|
+
req: Eip7702SignRequest,
|
|
569
|
+
mfaReceipt?: MfaReceipts,
|
|
570
|
+
): Promise<CubeSignerResponse<SignResponse>> {
|
|
571
|
+
return await this.#apiClient.signEip7702(this, req, mfaReceipt);
|
|
572
|
+
}
|
|
573
|
+
|
|
556
574
|
/**
|
|
557
575
|
* Sign an Eth2/Beacon-chain validation message.
|
|
558
576
|
*
|
package/src/org.ts
CHANGED
|
@@ -569,6 +569,18 @@ export class Org {
|
|
|
569
569
|
return this.#apiClient.orgUserDeleteOidc.bind(this.#apiClient);
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
+
/**
|
|
573
|
+
* Initiate an MFA reset for a user in the org. The reset is completed by
|
|
574
|
+
* the user via {@link CubeSignerClient.resetUserMfaComplete}.
|
|
575
|
+
*
|
|
576
|
+
* Same as {@link ApiClient.resetUserMfaInit}, see its documentation for more information.
|
|
577
|
+
*
|
|
578
|
+
* @returns A function that initiates an MFA reset for a user
|
|
579
|
+
*/
|
|
580
|
+
get resetUserMfaInit() {
|
|
581
|
+
return this.#apiClient.resetUserMfaInit.bind(this.#apiClient);
|
|
582
|
+
}
|
|
583
|
+
|
|
572
584
|
/**
|
|
573
585
|
* List all users in the organization.
|
|
574
586
|
*
|
|
@@ -997,11 +1009,13 @@ export class Org {
|
|
|
997
1009
|
/**
|
|
998
1010
|
* List pending MFA requests accessible to the current user.
|
|
999
1011
|
*
|
|
1012
|
+
* @param page Pagination options. Defaults to fetching the entire result set.
|
|
1000
1013
|
* @returns The MFA requests.
|
|
1001
1014
|
*/
|
|
1002
|
-
async mfaRequests(): Promise<MfaRequest[]> {
|
|
1015
|
+
async mfaRequests(page?: PageOpts): Promise<MfaRequest[]> {
|
|
1003
1016
|
return await this.#apiClient
|
|
1004
|
-
.mfaList()
|
|
1017
|
+
.mfaList(page)
|
|
1018
|
+
.fetch()
|
|
1005
1019
|
.then((mfaInfos) => mfaInfos.map((mfaInfo) => new MfaRequest(this.#apiClient, mfaInfo)));
|
|
1006
1020
|
}
|
|
1007
1021
|
|
package/src/role.ts
CHANGED
|
@@ -462,16 +462,26 @@ export type AllowEip191Signing = typeof AllowEip191Signing;
|
|
|
462
462
|
export const AllowEip712Signing = "AllowEip712Signing" as const;
|
|
463
463
|
export type AllowEip712Signing = typeof AllowEip712Signing;
|
|
464
464
|
|
|
465
|
+
/** Allow EIP-7702 signing */
|
|
466
|
+
export const AllowEip7702Signing = "AllowEip7702Signing" as const;
|
|
467
|
+
export type AllowEip7702Signing = typeof AllowEip7702Signing;
|
|
468
|
+
|
|
465
469
|
/** Allow BTC message signing */
|
|
466
470
|
export const AllowBtcMessageSigning = "AllowBtcMessageSigning" as const;
|
|
467
471
|
export type AllowBtcMessageSigning = typeof AllowBtcMessageSigning;
|
|
468
472
|
|
|
473
|
+
/** Allow BTC message signing */
|
|
474
|
+
export const AllowAutoSign = "AllowAutoSign" as const;
|
|
475
|
+
export type AllowAutoSign = typeof AllowAutoSign;
|
|
476
|
+
|
|
469
477
|
export type AllowPolicy =
|
|
470
478
|
| AllowRawBlobSigning
|
|
471
479
|
| AllowDiffieHellmanExchange
|
|
472
480
|
| AllowEip191Signing
|
|
473
481
|
| AllowEip712Signing
|
|
474
|
-
|
|
|
482
|
+
| AllowEip7702Signing
|
|
483
|
+
| AllowBtcMessageSigning
|
|
484
|
+
| AllowAutoSign;
|
|
475
485
|
|
|
476
486
|
/** A reference to an org-level named policy, using its name/id and its version */
|
|
477
487
|
export type PolicyReference = `${string}/v${number}` | `${string}/latest`;
|