@cubist-labs/cubesigner-sdk 0.1.77 → 0.2.15
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 +68 -0
- package/dist/src/api.d.ts +493 -0
- package/dist/src/api.js +1166 -0
- package/dist/src/client.d.ts +534 -10
- package/dist/src/client.js +355 -19
- package/dist/src/ethers/index.d.ts +34 -9
- package/dist/src/ethers/index.js +63 -19
- package/dist/src/index.d.ts +51 -70
- package/dist/src/index.js +83 -237
- package/dist/src/key.d.ts +35 -64
- package/dist/src/key.js +32 -96
- package/dist/src/mfa.d.ts +85 -14
- package/dist/src/mfa.js +146 -40
- package/dist/src/org.d.ts +42 -194
- package/dist/src/org.js +52 -336
- package/dist/src/paginator.js +1 -1
- package/dist/src/response.d.ts +101 -0
- package/dist/src/response.js +164 -0
- package/dist/src/role.d.ts +87 -83
- package/dist/src/role.js +79 -136
- package/dist/src/schema.d.ts +936 -28
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts +109 -0
- package/dist/src/schema_types.js +3 -0
- package/dist/src/session/cognito_manager.d.ts +15 -3
- package/dist/src/session/cognito_manager.js +23 -5
- package/dist/src/session/session_manager.d.ts +1 -1
- package/dist/src/session/session_manager.js +3 -11
- package/dist/src/session/session_storage.js +1 -1
- package/dist/src/session/signer_session_manager.d.ts +10 -29
- package/dist/src/session/signer_session_manager.js +21 -80
- package/dist/src/signer_session.d.ts +15 -252
- package/dist/src/signer_session.js +25 -424
- package/dist/src/user_export.d.ts +52 -0
- package/dist/src/user_export.js +129 -0
- package/dist/src/util.d.ts +15 -0
- package/dist/src/util.js +33 -11
- package/package.json +13 -11
- package/src/api.ts +1395 -0
- package/src/client.ts +413 -12
- package/src/ethers/index.ts +74 -28
- package/src/index.ts +96 -273
- package/src/key.ts +36 -131
- package/src/{fido.ts → mfa.ts} +62 -38
- package/src/org.ts +54 -405
- package/src/response.ts +196 -0
- package/src/role.ts +113 -184
- package/src/schema.ts +936 -28
- package/src/schema_types.ts +110 -0
- package/src/session/cognito_manager.ts +33 -6
- package/src/session/session_manager.ts +2 -8
- package/src/session/signer_session_manager.ts +29 -110
- package/src/signer_session.ts +22 -597
- package/src/user_export.ts +116 -0
- package/src/util.ts +29 -10
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cubist-labs/cubesigner-sdk",
|
|
3
|
+
"author": "Cubist, Inc.",
|
|
4
|
+
"version": "0.2.15",
|
|
5
|
+
"description": "CubeSigner TypeScript SDK",
|
|
6
|
+
"homepage": "https://github.com/cubist-labs/CubeSigner-TypeScript-SDK",
|
|
7
|
+
"bugs": "https://github.com/cubist-labs/CubeSigner-TypeScript-SDK/issues",
|
|
8
|
+
"license": "MIT OR Apache-2.0",
|
|
9
|
+
"files": [
|
|
10
|
+
"tsconfig.json",
|
|
11
|
+
"src/**",
|
|
12
|
+
"dist/**",
|
|
13
|
+
"NOTICE",
|
|
14
|
+
"LICENSE-APACHE",
|
|
15
|
+
"LICENSE-MIT"
|
|
16
|
+
],
|
|
17
|
+
"main": "dist/src/index.js",
|
|
18
|
+
"types": "dist/src/index.d.ts",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"test": "jest --maxWorkers=1",
|
|
22
|
+
"prepack": "tsc",
|
|
23
|
+
"typedoc": "typedoc",
|
|
24
|
+
"fix": "eslint . --ext .ts --fix",
|
|
25
|
+
"lint": "eslint . --ext .ts",
|
|
26
|
+
"fmt": "prettier --write .",
|
|
27
|
+
"fmt-check": "prettier --check .",
|
|
28
|
+
"gen-schema": "npx openapi-typescript ./spec/openapi.json --output ./src/schema.ts"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"ethers": "6.7.1",
|
|
32
|
+
"openapi-fetch": "0.6.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/chai": "^4.3.5",
|
|
36
|
+
"@types/chai-as-promised": "^7.1.8",
|
|
37
|
+
"@types/jest": "^29.5.10",
|
|
38
|
+
"@types/node": "^20.9.2",
|
|
39
|
+
"@types/node-fetch": "^2.6.9",
|
|
40
|
+
"@types/tmp": "^0.2.3",
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
42
|
+
"@hpke/core": "^1.2.5",
|
|
43
|
+
"chai": "^4.3.7",
|
|
44
|
+
"chai-as-promised": "^7.1.1",
|
|
45
|
+
"dotenv": "^16.3.1",
|
|
46
|
+
"eslint": "^8.54.0",
|
|
47
|
+
"eslint-config-google": "^0.14.0",
|
|
48
|
+
"eslint-config-prettier": "^8.8.0",
|
|
49
|
+
"jest": "^29.7.0",
|
|
50
|
+
"openapi-typescript": "^6.7.1",
|
|
51
|
+
"otplib": "^12.0.1",
|
|
52
|
+
"prettier": "3.1.0",
|
|
53
|
+
"tmp": "^0.2.1",
|
|
54
|
+
"ts-jest": "^29.1.0",
|
|
55
|
+
"ts-node": "^10.9.1",
|
|
56
|
+
"typescript": "^5.3.2"
|
|
57
|
+
},
|
|
58
|
+
"optionalDependencies": {
|
|
59
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.454.0",
|
|
60
|
+
"@hpke/core": "^1.2.5"
|
|
61
|
+
},
|
|
62
|
+
"prettier": {
|
|
63
|
+
"printWidth": 100
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=18.0.0"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import createClient from "openapi-fetch";
|
|
2
|
+
import { paths } from "./schema";
|
|
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, EvmSignRequest, EvmSignResponse, Eth2SignRequest, Eth2SignResponse, Eth2StakeRequest, Eth2StakeResponse, Eth2UnstakeRequest, Eth2UnstakeResponse, BlobSignRequest, BlobSignResponse, BtcSignResponse, BtcSignRequest, SolanaSignRequest, SolanaSignResponse, AvaSignResponse, AvaTx, MfaRequestInfo, MemberRole, UserExportCompleteResponse, UserExportInitResponse, UserExportListResponse } from "./schema_types";
|
|
5
|
+
import { AddFidoChallenge, MfaFidoChallenge, MfaReceipt, TotpChallenge } from "./mfa";
|
|
6
|
+
import { CubeSignerResponse } from "./response";
|
|
7
|
+
import { Key, KeyType } from "./key";
|
|
8
|
+
import { PageOpts, Paginator } from "./paginator";
|
|
9
|
+
import { KeyPolicy } from "./role";
|
|
10
|
+
import { EnvInterface } from "./env";
|
|
11
|
+
/** @internal */
|
|
12
|
+
export type Client = ReturnType<typeof createClient<paths>>;
|
|
13
|
+
export { paths };
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new HTTP client, setting the "User-Agent" header to this package's {name}@{version}.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} baseUrl The base URL of the client (e.g., "https://gamma.signer.cubist.dev")
|
|
18
|
+
* @param {string} authToken The value to send as "Authorization" header.
|
|
19
|
+
* @return {Client} The new HTTP client.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createHttpClient(baseUrl: string, authToken: string): Client;
|
|
22
|
+
/**
|
|
23
|
+
* Client to use to send requests to CubeSigner services
|
|
24
|
+
* when authenticating using a CubeSigner session token.
|
|
25
|
+
*/
|
|
26
|
+
export declare class CubeSignerApi {
|
|
27
|
+
#private;
|
|
28
|
+
/** Underlying session manager */
|
|
29
|
+
get sessionMgr(): SignerSessionManager;
|
|
30
|
+
/** Target environment */
|
|
31
|
+
get env(): EnvInterface;
|
|
32
|
+
/**
|
|
33
|
+
* Constructor.
|
|
34
|
+
* @param {SignerSessionManager} sessionMgr The session manager to use
|
|
35
|
+
* @param {string?} orgId Optional organization ID; if omitted, uses the org ID from the session manager.
|
|
36
|
+
*/
|
|
37
|
+
constructor(sessionMgr: SignerSessionManager, orgId?: string);
|
|
38
|
+
/**
|
|
39
|
+
* Returns a new instance of this class using the same session manager but targeting a different organization.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} orgId The organization ID.
|
|
42
|
+
* @return {CubeSignerApi} A new instance of this class using the same session manager but targeting different organization.
|
|
43
|
+
*/
|
|
44
|
+
withOrg(orgId?: string): CubeSignerApi;
|
|
45
|
+
/** Org id or name */
|
|
46
|
+
get orgId(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Obtain information about the current user.
|
|
49
|
+
*
|
|
50
|
+
* @return {Promise<UserInfo>} Retrieves information about the current user.
|
|
51
|
+
*/
|
|
52
|
+
userGet(): Promise<UserInfo>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a request to change user's TOTP. Returns a {@link TotpChallenge}
|
|
55
|
+
* that must be answered either by calling {@link TotpChallenge.answer} (or
|
|
56
|
+
* {@link CubeSignerApi.userResetTotpComplete}).
|
|
57
|
+
*
|
|
58
|
+
* @param {string} issuer Optional issuer; defaults to "Cubist"
|
|
59
|
+
* @param {MfaReceipt} mfaReceipt MFA receipt to include in HTTP headers
|
|
60
|
+
*/
|
|
61
|
+
userResetTotpInit(issuer?: string, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<TotpChallenge>>;
|
|
62
|
+
/**
|
|
63
|
+
* Answer the TOTP challenge issued by {@link userResetTotpInit}. If successful, user's
|
|
64
|
+
* TOTP configuration will be updated to that of the TOTP challenge.
|
|
65
|
+
*
|
|
66
|
+
* Instead of calling this method directly, prefer {@link TotpChallenge.answer}.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} totpId - The ID of the TOTP challenge
|
|
69
|
+
* @param {string} code - The TOTP code that should verify against the TOTP configuration from the challenge.
|
|
70
|
+
*/
|
|
71
|
+
userResetTotpComplete(totpId: string, code: string): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Verifies a given TOTP code against the current user's TOTP configuration.
|
|
74
|
+
* Throws an error if the verification fails.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} code Current TOTP code
|
|
77
|
+
*/
|
|
78
|
+
userVerifyTotp(code: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Initiate adding a new FIDO device. MFA may be required. This returns a {@link AddFidoChallenge}
|
|
81
|
+
* that must be answered with {@link AddFidoChallenge.answer} or {@link userRegisterFidoComplete}
|
|
82
|
+
* (after MFA approvals).
|
|
83
|
+
*
|
|
84
|
+
* @param {string} name The name of the new device.
|
|
85
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt to include in HTTP headers
|
|
86
|
+
* @return {Promise<CubeSignerResponse<AddFidoChallenge>>} A challenge that must be answered in order to complete FIDO registration.
|
|
87
|
+
*/
|
|
88
|
+
userRegisterFidoInit(name: string, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<AddFidoChallenge>>;
|
|
89
|
+
/**
|
|
90
|
+
* Complete a previously initiated (via {@link userRegisterFidoInit}) request to add a new FIDO device.
|
|
91
|
+
*
|
|
92
|
+
* Instead of calling this method directly, prefer {@link AddFidoChallenge.answer} or
|
|
93
|
+
* {@link AddFidoChallenge.createCredentialAndAnswer}.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} challengeId The ID of the challenge returned by the remote end.
|
|
96
|
+
* @param {PublicKeyCredential} credential The answer to the challenge.
|
|
97
|
+
*/
|
|
98
|
+
userRegisterFidoComplete(challengeId: string, credential: PublicKeyCredential): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Obtain information about the current organization.
|
|
101
|
+
* @return {OrgInfo} Information about the organization.
|
|
102
|
+
*/
|
|
103
|
+
orgGet(): Promise<OrgInfo>;
|
|
104
|
+
/**
|
|
105
|
+
* Update the org.
|
|
106
|
+
* @param {UpdateOrgRequest} request The JSON request to send to the API server.
|
|
107
|
+
* @return {UpdateOrgResponse} Updated org information.
|
|
108
|
+
*/
|
|
109
|
+
orgUpdate(request: UpdateOrgRequest): Promise<UpdateOrgResponse>;
|
|
110
|
+
/**
|
|
111
|
+
* Create a new (first-party) user in the organization and send an email invitation to that user.
|
|
112
|
+
*
|
|
113
|
+
* @param {string} email Email of the user
|
|
114
|
+
* @param {string} name The full name of the user
|
|
115
|
+
* @param {MemberRole} role Optional role. Defaults to "alien".
|
|
116
|
+
*/
|
|
117
|
+
orgUserInvite(email: string, name: string, role?: MemberRole): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* List users.
|
|
120
|
+
* @return {User[]} Org users.
|
|
121
|
+
*/
|
|
122
|
+
orgUsersList(): Promise<UserIdInfo[]>;
|
|
123
|
+
/**
|
|
124
|
+
* Create a new OIDC user. This can be a first-party "Member" or third-party "Alien".
|
|
125
|
+
* @param {OidcIdentity} identity The identity of the OIDC user
|
|
126
|
+
* @param {string} email Email of the OIDC user
|
|
127
|
+
* @param {CreateOidcUserOptions} opts Additional options for new OIDC users
|
|
128
|
+
* @return {string} User id of the new user
|
|
129
|
+
*/
|
|
130
|
+
orgUserCreateOidc(identity: OidcIdentity, email: string, opts?: CreateOidcUserOptions): Promise<string>;
|
|
131
|
+
/**
|
|
132
|
+
* Delete an existing OIDC user.
|
|
133
|
+
* @param {OidcIdentity} identity The identity of the OIDC user
|
|
134
|
+
*/
|
|
135
|
+
orgUserDeleteOidc(identity: OidcIdentity): Promise<{
|
|
136
|
+
status: string;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Get a key by its id.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} keyId The id of the key to get.
|
|
142
|
+
* @return {KeyInfoApi} The key information.
|
|
143
|
+
*/
|
|
144
|
+
keyGet(keyId: string): Promise<KeyInfoApi>;
|
|
145
|
+
/**
|
|
146
|
+
* Update key.
|
|
147
|
+
* @param {string} keyId The ID of the key to update.
|
|
148
|
+
* @param {UpdateKeyRequest} request The JSON request to send to the API server.
|
|
149
|
+
* @return {KeyInfoApi} The JSON response from the API server.
|
|
150
|
+
*/
|
|
151
|
+
keyUpdate(keyId: string, request: UpdateKeyRequest): Promise<KeyInfoApi>;
|
|
152
|
+
/**
|
|
153
|
+
* Deletes a key.
|
|
154
|
+
*
|
|
155
|
+
* @param {string} keyId - Key id
|
|
156
|
+
*/
|
|
157
|
+
keyDelete(keyId: string): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Create new signing keys.
|
|
160
|
+
*
|
|
161
|
+
* @param {KeyType} keyType The type of key to create.
|
|
162
|
+
* @param {number} count The number of keys to create.
|
|
163
|
+
* @param {string?} ownerId The owner of the keys. Defaults to the session's user.
|
|
164
|
+
* @return {KeyInfoApi[]} The new keys.
|
|
165
|
+
*/
|
|
166
|
+
keysCreate(keyType: KeyType, count: number, ownerId?: string): Promise<KeyInfoApi[]>;
|
|
167
|
+
/**
|
|
168
|
+
* Derive a set of keys of a specified type using a supplied derivation path and an existing long-lived mnemonic.
|
|
169
|
+
*
|
|
170
|
+
* The owner of the derived key will be the owner of the mnemonic.
|
|
171
|
+
*
|
|
172
|
+
* @param {KeyType} keyType The type of key to create.
|
|
173
|
+
* @param {string[]} derivationPaths Derivation paths from which to derive new keys.
|
|
174
|
+
* @param {string} mnemonicId materialId of mnemonic key used to derive the new key.
|
|
175
|
+
*
|
|
176
|
+
* @return {KeyInfoApi[]} The newly derived keys.
|
|
177
|
+
*/
|
|
178
|
+
keysDerive(keyType: KeyType, derivationPaths: string[], mnemonicId: string): Promise<KeyInfoApi[]>;
|
|
179
|
+
/**
|
|
180
|
+
* List all keys in the org.
|
|
181
|
+
* @param {KeyType?} type Optional key type to filter list for.
|
|
182
|
+
* @param {PageOpts?} page Pagination options. Defaults to fetching the entire result set.
|
|
183
|
+
* @return {Paginator<ListKeysResponse, KeyInfoApi>} Paginator for iterating over keys.
|
|
184
|
+
*/
|
|
185
|
+
keysList(type?: KeyType, page?: PageOpts): Paginator<ListKeysResponse, KeyInfoApi>;
|
|
186
|
+
/**
|
|
187
|
+
* Create a new role.
|
|
188
|
+
*
|
|
189
|
+
* @param {string?} name The optional name of the role.
|
|
190
|
+
* @return {string} The ID of the new role.
|
|
191
|
+
*/
|
|
192
|
+
roleCreate(name?: string): Promise<string>;
|
|
193
|
+
/**
|
|
194
|
+
* Get a role by its id (or name).
|
|
195
|
+
* @param {string} roleId The id of the role to get.
|
|
196
|
+
* @return {RoleInfo} The role.
|
|
197
|
+
*/
|
|
198
|
+
roleGet(roleId: string): Promise<RoleInfo>;
|
|
199
|
+
/**
|
|
200
|
+
* Update a role.
|
|
201
|
+
*
|
|
202
|
+
* @param {string} roleId The ID of the role to update.
|
|
203
|
+
* @param {UpdateRoleRequest} request The update request.
|
|
204
|
+
* @return {Promise<RoleInfo>} The updated role information.
|
|
205
|
+
*/
|
|
206
|
+
roleUpdate(roleId: string, request: UpdateRoleRequest): Promise<RoleInfo>;
|
|
207
|
+
/**
|
|
208
|
+
* Delete a role by its ID.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} roleId The ID of the role to delete.
|
|
211
|
+
*/
|
|
212
|
+
roleDelete(roleId: string): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* List all roles in the org.
|
|
215
|
+
*
|
|
216
|
+
* @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
|
|
217
|
+
* @return {RoleInfo} Paginator for iterating over roles.
|
|
218
|
+
*/
|
|
219
|
+
rolesList(page?: PageOpts): Paginator<ListRolesResponse, RoleInfo>;
|
|
220
|
+
/**
|
|
221
|
+
* Add existing keys to an existing role.
|
|
222
|
+
*
|
|
223
|
+
* @param {string} roleId The ID of the role
|
|
224
|
+
* @param {string[]} keyIds The IDs of the keys to add to the role.
|
|
225
|
+
* @param {KeyPolicy?} policy The optional policy to apply to each key.
|
|
226
|
+
*/
|
|
227
|
+
roleKeysAdd(roleId: string, keyIds: string[], policy?: KeyPolicy): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* Remove an existing key from an existing role.
|
|
230
|
+
*
|
|
231
|
+
* @param {string} roleId The ID of the role
|
|
232
|
+
* @param {string} keyId The ID of the key to remove from the role
|
|
233
|
+
*/
|
|
234
|
+
roleKeysRemove(roleId: string, keyId: string): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* List all keys in a role.
|
|
237
|
+
*
|
|
238
|
+
* @param {string} roleId The ID of the role whose keys to retrieve.
|
|
239
|
+
* @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
|
|
240
|
+
* @return {Paginator<ListRoleKeysResponse, KeyInRoleInfo>} Paginator for iterating over the keys in the role.
|
|
241
|
+
*/
|
|
242
|
+
roleKeysList(roleId: string, page?: PageOpts): Paginator<ListRoleKeysResponse, KeyInRoleInfo>;
|
|
243
|
+
/**
|
|
244
|
+
* Add an existing user to an existing role.
|
|
245
|
+
*
|
|
246
|
+
* @param {string} roleId The ID of the role.
|
|
247
|
+
* @param {string} userId The ID of the user to add to the role.
|
|
248
|
+
*/
|
|
249
|
+
roleUserAdd(roleId: string, userId: string): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* List all users in a role.
|
|
252
|
+
*
|
|
253
|
+
* @param {string} roleId The ID of the role whose users to retrieve.
|
|
254
|
+
* @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
|
|
255
|
+
* @return {Paginator<ListRoleUsersResponse, UserInRoleInfo>} Paginator for iterating over the users in the role.
|
|
256
|
+
*/
|
|
257
|
+
roleUsersList(roleId: string, page?: PageOpts): Paginator<ListRoleUsersResponse, UserInRoleInfo>;
|
|
258
|
+
/**
|
|
259
|
+
* Create a new signer session for a given role.
|
|
260
|
+
*
|
|
261
|
+
* @param {string} roleId Role ID
|
|
262
|
+
* @param {string} purpose The purpose of the session
|
|
263
|
+
* @param {string[]} scopes Session scopes. Only `sign:*` scopes are allowed.
|
|
264
|
+
* @param {SignerSessionLifetime} lifetimes Lifetime settings
|
|
265
|
+
* @return {Promise<SignerSessionData>} New signer session info.
|
|
266
|
+
*/
|
|
267
|
+
sessionCreateForRole(roleId: string, purpose: string, scopes?: string[], lifetimes?: SignerSessionLifetime): Promise<SignerSessionData>;
|
|
268
|
+
/**
|
|
269
|
+
* Revoke a session.
|
|
270
|
+
*
|
|
271
|
+
* @param {string} sessionId The ID of the session to revoke.
|
|
272
|
+
*/
|
|
273
|
+
sessionRevoke(sessionId: string): Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Returns a paginator for iterating over all signer sessions optionally filtered by a role.
|
|
276
|
+
*
|
|
277
|
+
* @param {string?} roleId If set, limit to sessions for this role only.
|
|
278
|
+
* @param {PageOpts?} page Pagination options. Defaults to fetching the entire result set.
|
|
279
|
+
* @return {Promise<SignerSessionInfo[]>} Signer sessions for this role.
|
|
280
|
+
*/
|
|
281
|
+
sessionsList(roleId?: string, page?: PageOpts): Paginator<SessionsResponse, SessionInfo>;
|
|
282
|
+
/**
|
|
283
|
+
* Returns the list of keys that this session has access to.
|
|
284
|
+
* @return {Key[]} The list of keys.
|
|
285
|
+
*/
|
|
286
|
+
sessionKeysList(): Promise<KeyInfoApi[]>;
|
|
287
|
+
/**
|
|
288
|
+
* Obtain proof of authentication using the current CubeSigner session.
|
|
289
|
+
*
|
|
290
|
+
* @return {Promise<IdentityProof>} Proof of authentication
|
|
291
|
+
*/
|
|
292
|
+
identityProve(): Promise<IdentityProof>;
|
|
293
|
+
/**
|
|
294
|
+
* Checks if a given identity proof is valid.
|
|
295
|
+
*
|
|
296
|
+
* @param {IdentityProof} proof The proof of authentication.
|
|
297
|
+
*/
|
|
298
|
+
identityVerify(proof: IdentityProof): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Retrieves existing MFA request.
|
|
301
|
+
*
|
|
302
|
+
* @param {string} mfaId MFA request ID
|
|
303
|
+
* @return {Promise<MfaRequestInfo>} MFA request information
|
|
304
|
+
*/
|
|
305
|
+
mfaGet(mfaId: string): Promise<MfaRequestInfo>;
|
|
306
|
+
/**
|
|
307
|
+
* List pending MFA requests accessible to the current user.
|
|
308
|
+
*
|
|
309
|
+
* @return {Promise<MfaRequestInfo[]>} The MFA requests.
|
|
310
|
+
*/
|
|
311
|
+
mfaList(): Promise<MfaRequestInfo[]>;
|
|
312
|
+
/**
|
|
313
|
+
* Approve a pending MFA request using the current session.
|
|
314
|
+
*
|
|
315
|
+
* @param {string} mfaId The id of the MFA request
|
|
316
|
+
* @return {Promise<MfaRequestInfo>} The result of the MFA request
|
|
317
|
+
*/
|
|
318
|
+
mfaApprove(mfaId: string): Promise<MfaRequestInfo>;
|
|
319
|
+
/**
|
|
320
|
+
* Approve a pending MFA request using TOTP.
|
|
321
|
+
*
|
|
322
|
+
* @param {string} mfaId The MFA request to approve
|
|
323
|
+
* @param {string} code The TOTP code
|
|
324
|
+
* @return {Promise<MfaRequestInfo>} The current status of the MFA request
|
|
325
|
+
*/
|
|
326
|
+
mfaApproveTotp(mfaId: string, code: string): Promise<MfaRequestInfo>;
|
|
327
|
+
/**
|
|
328
|
+
* Initiate approval of an existing MFA request using FIDO. A challenge is
|
|
329
|
+
* returned which must be answered via {@link MfaFidoChallenge.answer} or {@link mfaApproveFidoComplete}.
|
|
330
|
+
*
|
|
331
|
+
* @param {string} mfaId The MFA request ID.
|
|
332
|
+
* @return {Promise<MfaFidoChallenge>} A challenge that needs to be answered to complete the approval.
|
|
333
|
+
*/
|
|
334
|
+
mfaApproveFidoInit(mfaId: string): Promise<MfaFidoChallenge>;
|
|
335
|
+
/**
|
|
336
|
+
* Complete a previously initiated (via {@link mfaApproveFidoInit}) MFA request approval using FIDO.
|
|
337
|
+
*
|
|
338
|
+
* Instead of calling this method directly, prefer {@link MfaFidoChallenge.answer} or
|
|
339
|
+
* {@link MfaFidoChallenge.createCredentialAndAnswer}.
|
|
340
|
+
*
|
|
341
|
+
* @param {string} mfaId The MFA request ID
|
|
342
|
+
* @param {string} challengeId The ID of the challenge issued by {@link mfaApproveFidoInit}
|
|
343
|
+
* @param {PublicKeyCredential} credential The answer to the challenge
|
|
344
|
+
* @return {Promise<MfaRequestInfo>} The current status of the MFA request.
|
|
345
|
+
*/
|
|
346
|
+
mfaApproveFidoComplete(mfaId: string, challengeId: string, credential: PublicKeyCredential): Promise<MfaRequestInfo>;
|
|
347
|
+
/**
|
|
348
|
+
* Sign an EVM transaction.
|
|
349
|
+
* @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
|
|
350
|
+
* @param {EvmSignRequest} req What to sign.
|
|
351
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt.
|
|
352
|
+
* @return {Promise<EvmSignResponse | AcceptedResponse>} Signature (or MFA approval request).
|
|
353
|
+
*/
|
|
354
|
+
signEvm(key: Key | string, req: EvmSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<EvmSignResponse>>;
|
|
355
|
+
/**
|
|
356
|
+
* Sign an Eth2/Beacon-chain validation message.
|
|
357
|
+
*
|
|
358
|
+
* @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
|
|
359
|
+
* @param {Eth2SignRequest} req What to sign.
|
|
360
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt
|
|
361
|
+
* @return {Promise<Eth2SignResponse | AcceptedResponse>} Signature
|
|
362
|
+
*/
|
|
363
|
+
signEth2(key: Key | string, req: Eth2SignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<Eth2SignResponse>>;
|
|
364
|
+
/**
|
|
365
|
+
* Sign an Eth2/Beacon-chain deposit (or staking) message.
|
|
366
|
+
*
|
|
367
|
+
* @param {Eth2StakeRequest} req The request to sign.
|
|
368
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt
|
|
369
|
+
* @return {Promise<Eth2StakeResponse | AcceptedResponse>} The response.
|
|
370
|
+
*/
|
|
371
|
+
signStake(req: Eth2StakeRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<Eth2StakeResponse>>;
|
|
372
|
+
/**
|
|
373
|
+
* Sign an Eth2/Beacon-chain unstake/exit request.
|
|
374
|
+
*
|
|
375
|
+
* @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
|
|
376
|
+
* @param {Eth2UnstakeRequest} req The request to sign.
|
|
377
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt
|
|
378
|
+
* @return {Promise<Eth2UnstakeResponse | AcceptedResponse>} The response.
|
|
379
|
+
*/
|
|
380
|
+
signUnstake(key: Key | string, req: Eth2UnstakeRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<Eth2UnstakeResponse>>;
|
|
381
|
+
/**
|
|
382
|
+
* Sign an Avalanche P- or X-chain message.
|
|
383
|
+
* @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
|
|
384
|
+
* @param {AvaTx} tx Avalanche message (transaction) to sign
|
|
385
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt
|
|
386
|
+
* @return {Promise<AvaSignResponse | AcceptedResponse>} The response.
|
|
387
|
+
*/
|
|
388
|
+
signAva(key: Key | string, tx: AvaTx, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<AvaSignResponse>>;
|
|
389
|
+
/**
|
|
390
|
+
* Sign a raw blob.
|
|
391
|
+
*
|
|
392
|
+
* This requires the key to have a '"AllowRawBlobSigning"' {@link KeyPolicy}. This is because
|
|
393
|
+
* signing arbitrary messages is, in general, dangerous (and you should instead
|
|
394
|
+
* prefer typed end-points as used by, for example, {@link signEvm}). For Secp256k1 keys,
|
|
395
|
+
* for example, you **must** call this function with a message that is 32 bytes long and
|
|
396
|
+
* the output of a secure hash function.
|
|
397
|
+
*
|
|
398
|
+
* This function returns signatures serialized as;
|
|
399
|
+
*
|
|
400
|
+
* - ECDSA signatures are serialized as big-endian r and s plus recovery-id
|
|
401
|
+
* byte v, which can in general take any of the values 0, 1, 2, or 3.
|
|
402
|
+
*
|
|
403
|
+
* - EdDSA signatures are serialized in the standard format.
|
|
404
|
+
*
|
|
405
|
+
* - BLS signatures are not supported on the blob-sign endpoint.
|
|
406
|
+
*
|
|
407
|
+
* @param {Key | string} key The key to sign with (either {@link Key} or its ID).
|
|
408
|
+
* @param {BlobSignRequest} req What to sign
|
|
409
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt
|
|
410
|
+
* @return {Promise<BlobSignResponse | AcceptedResponse>} The response.
|
|
411
|
+
*/
|
|
412
|
+
signBlob(key: Key | string, req: BlobSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<BlobSignResponse>>;
|
|
413
|
+
/**
|
|
414
|
+
* Sign a Bitcoin message.
|
|
415
|
+
*
|
|
416
|
+
* @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
|
|
417
|
+
* @param {BtcSignRequest} req What to sign
|
|
418
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt
|
|
419
|
+
* @return {Promise<BtcSignResponse | AcceptedResponse>} The response.
|
|
420
|
+
*/
|
|
421
|
+
signBtc(key: Key | string, req: BtcSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<BtcSignResponse>>;
|
|
422
|
+
/**
|
|
423
|
+
* Sign a Solana message.
|
|
424
|
+
*
|
|
425
|
+
* @param {Key | string} key The key to sign with (either {@link Key} or its material ID).
|
|
426
|
+
* @param {SolanaSignRequest} req What to sign
|
|
427
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt
|
|
428
|
+
* @return {Promise<SolanaSignResponse | AcceptedResponse>} The response.
|
|
429
|
+
*/
|
|
430
|
+
signSolana(key: Key | string, req: SolanaSignRequest, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<SolanaSignResponse>>;
|
|
431
|
+
/** HTTPS client */
|
|
432
|
+
private client;
|
|
433
|
+
/**
|
|
434
|
+
* List outstanding user-export requests.
|
|
435
|
+
*
|
|
436
|
+
* @param {string?} keyId Optional key ID. If supplied, list the outstanding request (if any) only for the specified key; otherwise, list all outstanding requests for the specified user.
|
|
437
|
+
* @param {string?} userId Optional user ID. If omtted, uses the current user's ID. Only org owners can list user-export requests for users other than themselves.
|
|
438
|
+
* @param {PageOpts?} page Pagination options. Defaults to fetching the entire result set.
|
|
439
|
+
* @return {Paginator<UserExportListResponse, UserExportInitResponse>} Paginator for iterating over the result set.
|
|
440
|
+
*/
|
|
441
|
+
userExportList(keyId?: string, userId?: string, page?: PageOpts): Paginator<UserExportListResponse, UserExportInitResponse>;
|
|
442
|
+
/**
|
|
443
|
+
* Delete an outstanding user-export request.
|
|
444
|
+
*
|
|
445
|
+
* @param {string} keyId The key-id corresponding to the user-export request to delete.
|
|
446
|
+
* @param {string?} userId Optional user ID. If omitted, uses the current user's ID. Only org owners can delete user-export requests for users other than themselves.
|
|
447
|
+
*/
|
|
448
|
+
userExportDelete(keyId: string, userId?: string): Promise<void>;
|
|
449
|
+
/**
|
|
450
|
+
* Initiate a user-export request.
|
|
451
|
+
*
|
|
452
|
+
* @param {string} keyId The key-id for which to initiate an export.
|
|
453
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt.
|
|
454
|
+
* @return {Promise<UserExportInitResponse | AcceptedResponse>} The response.
|
|
455
|
+
*/
|
|
456
|
+
userExportInit(keyId: string, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<UserExportInitResponse>>;
|
|
457
|
+
/**
|
|
458
|
+
* Complete a user-export request.
|
|
459
|
+
*
|
|
460
|
+
* @param {string} keyId The key-id for which to initiate an export.
|
|
461
|
+
* @param {CryptoKey} publicKey The NIST P-256 public key to which the export will be encrypted. This should be the `publicKey` property of a value returned by `userExportKeygen`.
|
|
462
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt.
|
|
463
|
+
* @return {Promise<UserExportCompleteResponse | AcceptedResponse>} The response.
|
|
464
|
+
*/
|
|
465
|
+
userExportComplete(keyId: string, publicKey: CryptoKey, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<UserExportCompleteResponse>>;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Client to use to send requests to CubeSigner services
|
|
469
|
+
* when authenticating using an OIDC token.
|
|
470
|
+
*/
|
|
471
|
+
export declare class OidcClient {
|
|
472
|
+
#private;
|
|
473
|
+
/**
|
|
474
|
+
* @param {EnvInterface} env CubeSigner deployment
|
|
475
|
+
* @param {string} orgId Target organization ID
|
|
476
|
+
* @param {string} oidcToken User's OIDC token
|
|
477
|
+
*/
|
|
478
|
+
constructor(env: EnvInterface, orgId: string, oidcToken: string);
|
|
479
|
+
/**
|
|
480
|
+
* Exchange an OIDC token for a CubeSigner session token.
|
|
481
|
+
* @param {List<string>} scopes The scopes for the new session
|
|
482
|
+
* @param {RatchetConfig} lifetimes Lifetimes of the new session.
|
|
483
|
+
* @param {MfaReceipt} mfaReceipt Optional MFA receipt (id + confirmation code)
|
|
484
|
+
* @return {Promise<CubeSignerResponse<SignerSessionData>>} The session data.
|
|
485
|
+
*/
|
|
486
|
+
sessionCreate(scopes: Array<string>, lifetimes?: RatchetConfig, mfaReceipt?: MfaReceipt): Promise<CubeSignerResponse<SignerSessionData>>;
|
|
487
|
+
/**
|
|
488
|
+
* Exchange an OIDC token for a proof of authentication.
|
|
489
|
+
*
|
|
490
|
+
* @return {Promise<IdentityProof>} Proof of authentication
|
|
491
|
+
*/
|
|
492
|
+
identityProve(): Promise<IdentityProof>;
|
|
493
|
+
}
|