@cubist-labs/cubesigner-sdk 0.1.77 → 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.
- package/dist/src/client.d.ts +434 -7
- package/dist/src/client.js +1022 -18
- package/dist/src/ethers/index.d.ts +2 -4
- package/dist/src/ethers/index.js +5 -8
- package/dist/src/index.d.ts +41 -65
- package/dist/src/index.js +58 -231
- package/dist/src/key.d.ts +9 -45
- package/dist/src/key.js +18 -89
- package/dist/src/mfa.d.ts +85 -14
- package/dist/src/mfa.js +158 -40
- package/dist/src/org.d.ts +217 -127
- package/dist/src/org.js +94 -232
- package/dist/src/role.d.ts +76 -74
- package/dist/src/role.js +79 -136
- package/dist/src/schema.d.ts +345 -13
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts +103 -0
- package/dist/src/schema_types.js +3 -0
- package/dist/src/session/session_manager.js +1 -1
- package/dist/src/session/signer_session_manager.d.ts +14 -29
- package/dist/src/session/signer_session_manager.js +26 -79
- package/dist/src/signer_session.d.ts +212 -191
- package/dist/src/signer_session.js +120 -313
- package/package.json +6 -6
- package/src/client.ts +1217 -7
- package/src/ethers/index.ts +5 -17
- package/src/index.ts +69 -262
- package/src/key.ts +19 -121
- package/src/{fido.ts → mfa.ts} +62 -26
- package/src/org.ts +96 -292
- package/src/role.ts +108 -181
- package/src/schema.ts +345 -13
- package/src/schema_types.ts +103 -0
- package/src/session/session_manager.ts +1 -1
- package/src/session/signer_session_manager.ts +35 -109
- package/src/signer_session.ts +115 -442
package/dist/src/org.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { OrgInfo } from "./schema_types";
|
|
2
|
+
import { CubeSignerClient } from "./client";
|
|
3
3
|
import { KeyType, Key } from "./key";
|
|
4
|
-
import {
|
|
4
|
+
import { Role } from "./role";
|
|
5
|
+
import { PageOpts } from "./paginator";
|
|
5
6
|
/** Organization id */
|
|
6
7
|
export type OrgId = string;
|
|
7
8
|
/** Org-wide policy */
|
|
@@ -34,31 +35,21 @@ export interface SourceIpAllowlistPolicy {
|
|
|
34
35
|
export interface MaxDailyUnstakePolicy {
|
|
35
36
|
MaxDailyUnstake: number;
|
|
36
37
|
}
|
|
37
|
-
type OrgInfo = components["schemas"]["OrgInfo"];
|
|
38
|
-
type UserIdInfo = components["schemas"]["UserIdInfo"];
|
|
39
|
-
export type OidcIdentity = components["schemas"]["OIDCIdentity"];
|
|
40
|
-
export type MemberRole = components["schemas"]["MemberRole"];
|
|
41
|
-
/** Options for a new OIDC user */
|
|
42
|
-
export interface CreateOidcUserOptions {
|
|
43
|
-
/** The role of an OIDC user, default is "Alien" */
|
|
44
|
-
memberRole?: MemberRole;
|
|
45
|
-
/** Optional MFA policy to associate with the user account */
|
|
46
|
-
mfaPolicy?: MfaPolicy;
|
|
47
|
-
}
|
|
48
38
|
/** An organization. */
|
|
49
39
|
export declare class Org {
|
|
50
40
|
#private;
|
|
51
41
|
/**
|
|
52
42
|
* @description The org id
|
|
53
43
|
* @example Org#c3b9379c-4e8c-4216-bd0a-65ace53cf98f
|
|
54
|
-
|
|
44
|
+
*/
|
|
55
45
|
get id(): OrgId;
|
|
56
46
|
/** Human-readable name for the org */
|
|
57
47
|
name(): Promise<string | undefined>;
|
|
58
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Set the human-readable name for the org.
|
|
59
50
|
* @param {string} name The new human-readable name for the org (must be alphanumeric).
|
|
60
51
|
* @example my_org_name
|
|
61
|
-
|
|
52
|
+
*/
|
|
62
53
|
setName(name: string): Promise<void>;
|
|
63
54
|
/** Is the org enabled? */
|
|
64
55
|
enabled(): Promise<boolean>;
|
|
@@ -72,21 +63,23 @@ export declare class Org {
|
|
|
72
63
|
* @param {OrgPolicy[]} policy The new policy for the org.
|
|
73
64
|
* */
|
|
74
65
|
setPolicy(policy: OrgPolicy[]): Promise<void>;
|
|
75
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Create a new signing key.
|
|
76
68
|
* @param {KeyType} type The type of key to create.
|
|
77
69
|
* @param {string?} ownerId The owner of the key. Defaults to the session's user.
|
|
78
70
|
* @return {Key[]} The new keys.
|
|
79
|
-
|
|
71
|
+
*/
|
|
80
72
|
createKey(type: KeyType, ownerId?: string): Promise<Key>;
|
|
81
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Create new signing keys.
|
|
82
75
|
* @param {KeyType} type The type of key to create.
|
|
83
|
-
* @param {
|
|
76
|
+
* @param {number} count The number of keys to create.
|
|
84
77
|
* @param {string?} ownerId The owner of the keys. Defaults to the session's user.
|
|
85
78
|
* @return {Key[]} The new keys.
|
|
86
|
-
|
|
79
|
+
*/
|
|
87
80
|
createKeys(type: KeyType, count: number, ownerId?: string): Promise<Key[]>;
|
|
88
81
|
/**
|
|
89
|
-
*
|
|
82
|
+
* Derive a key of the given type using the given derivation path and mnemonic.
|
|
90
83
|
* The owner of the derived key will be the owner of the mnemonic.
|
|
91
84
|
*
|
|
92
85
|
* @param {KeyType} type Type of key to derive from the mnemonic.
|
|
@@ -97,7 +90,7 @@ export declare class Org {
|
|
|
97
90
|
*/
|
|
98
91
|
deriveKey(type: KeyType, derivationPath: string, mnemonicId: string): Promise<Key>;
|
|
99
92
|
/**
|
|
100
|
-
*
|
|
93
|
+
* Derive a set of keys of the given type using the given derivation paths and mnemonic.
|
|
101
94
|
*
|
|
102
95
|
* The owner of the derived keys will be the owner of the mnemonic.
|
|
103
96
|
*
|
|
@@ -108,143 +101,240 @@ export declare class Org {
|
|
|
108
101
|
* @return {Key[]} newly derived keys.
|
|
109
102
|
*/
|
|
110
103
|
deriveKeys(type: KeyType, derivationPaths: string[], mnemonicId: string): Promise<Key[]>;
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*/
|
|
124
|
-
createOidcUser(identity: OidcIdentity, email: string, opts?: CreateOidcUserOptions): Promise<string>;
|
|
125
|
-
/**
|
|
126
|
-
* Delete an existing OIDC user
|
|
127
|
-
* @param {OidcIdentity} identity The identity of the OIDC user
|
|
128
|
-
*/
|
|
129
|
-
deleteOidcUser(identity: OidcIdentity): Promise<{
|
|
104
|
+
/** Create a new user in the organization and sends an invitation to that user. */
|
|
105
|
+
get createUser(): (email: string, name: string, role?: "Alien" | "Member" | "Owner" | undefined) => Promise<void>;
|
|
106
|
+
/** Create a new OIDC user */
|
|
107
|
+
get createOidcUser(): (identity: {
|
|
108
|
+
iss: string;
|
|
109
|
+
sub: string;
|
|
110
|
+
}, email: string, opts?: import("./schema_types").CreateOidcUserOptions) => Promise<string>;
|
|
111
|
+
/** Delete an existing OIDC user */
|
|
112
|
+
get deleteOidcUser(): (identity: {
|
|
113
|
+
iss: string;
|
|
114
|
+
sub: string;
|
|
115
|
+
}) => Promise<{
|
|
130
116
|
status: string;
|
|
131
117
|
}>;
|
|
118
|
+
/** Checks if a given proof of OIDC authentication is valid. */
|
|
119
|
+
get verifyIdentity(): (proof: {
|
|
120
|
+
aud?: string | null | undefined;
|
|
121
|
+
email: string;
|
|
122
|
+
exp_epoch: number;
|
|
123
|
+
identity?: {
|
|
124
|
+
iss: string;
|
|
125
|
+
sub: string;
|
|
126
|
+
} | null | undefined;
|
|
127
|
+
user_info?: {
|
|
128
|
+
configured_mfa: ({
|
|
129
|
+
type: "totp";
|
|
130
|
+
} | {
|
|
131
|
+
id: string;
|
|
132
|
+
name: string;
|
|
133
|
+
type: "fido";
|
|
134
|
+
})[];
|
|
135
|
+
initialized: boolean;
|
|
136
|
+
user_id: string;
|
|
137
|
+
} | null | undefined;
|
|
138
|
+
} & {
|
|
139
|
+
id: string;
|
|
140
|
+
}) => Promise<void>;
|
|
141
|
+
/** List users in the organization */
|
|
142
|
+
get users(): () => Promise<{
|
|
143
|
+
email: string;
|
|
144
|
+
id: string;
|
|
145
|
+
}[]>;
|
|
132
146
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @param {IdentityProof} proof The proof of authentication.
|
|
136
|
-
*/
|
|
137
|
-
verifyIdentity(proof: IdentityProof): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* List users in the organization
|
|
140
|
-
* @return {UserIdInfo[]} List of users
|
|
141
|
-
*/
|
|
142
|
-
users(): Promise<UserIdInfo[]>;
|
|
143
|
-
/** Get a key by id.
|
|
147
|
+
* Get a key by id.
|
|
144
148
|
* @param {string} keyId The id of the key to get.
|
|
145
149
|
* @return {Key} The key.
|
|
146
|
-
|
|
150
|
+
*/
|
|
147
151
|
getKey(keyId: string): Promise<Key>;
|
|
148
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Get all keys in the org.
|
|
149
154
|
* @param {KeyType?} type Optional key type to filter list for.
|
|
150
155
|
* @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
|
|
151
156
|
* @return {Key} The key.
|
|
152
|
-
|
|
157
|
+
*/
|
|
153
158
|
keys(type?: KeyType, page?: PageOpts): Promise<Key[]>;
|
|
154
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Create a new role.
|
|
161
|
+
*
|
|
155
162
|
* @param {string?} name The name of the role.
|
|
156
163
|
* @return {Role} The new role.
|
|
157
|
-
|
|
164
|
+
*/
|
|
158
165
|
createRole(name?: string): Promise<Role>;
|
|
159
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Get a role by id or name.
|
|
168
|
+
*
|
|
160
169
|
* @param {string} roleId The id or name of the role to get.
|
|
161
170
|
* @return {Role} The role.
|
|
162
|
-
|
|
171
|
+
*/
|
|
163
172
|
getRole(roleId: string): Promise<Role>;
|
|
164
173
|
/**
|
|
165
174
|
* List all roles in the org.
|
|
166
175
|
*
|
|
167
176
|
* @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
|
|
168
177
|
* @return {Role[]} The roles.
|
|
169
|
-
|
|
178
|
+
*/
|
|
170
179
|
listRoles(page?: PageOpts): Promise<Role[]>;
|
|
171
|
-
/** List all users in the org.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
180
|
+
/** List all users in the org. */
|
|
181
|
+
get listUsers(): () => Promise<{
|
|
182
|
+
email: string;
|
|
183
|
+
id: string;
|
|
184
|
+
}[]>;
|
|
175
185
|
/**
|
|
176
186
|
* Get a pending MFA request by its id.
|
|
177
|
-
* @param {string} mfaId The id of the MFA request.
|
|
178
|
-
* @return {Promise<MfaRequestInfo>} The MFA request.
|
|
179
187
|
*
|
|
180
188
|
* @deprecated Use {@link getMfaInfo()} instead.
|
|
181
189
|
*/
|
|
182
|
-
mfaGet(mfaId: string)
|
|
190
|
+
get mfaGet(): (mfaId: string) => Promise<{
|
|
191
|
+
expires_at: number;
|
|
192
|
+
id: string;
|
|
193
|
+
receipt?: {
|
|
194
|
+
confirmation: string;
|
|
195
|
+
final_approver: string;
|
|
196
|
+
timestamp: number;
|
|
197
|
+
} | null | undefined;
|
|
198
|
+
request: {
|
|
199
|
+
body?: Record<string, unknown> | null | undefined;
|
|
200
|
+
method: string;
|
|
201
|
+
path: string;
|
|
202
|
+
};
|
|
203
|
+
status: {
|
|
204
|
+
allowed_approvers: string[];
|
|
205
|
+
allowed_mfa_types?: ("CubeSigner" | "Totp" | "Fido")[] | null | undefined;
|
|
206
|
+
approved_by: {
|
|
207
|
+
[key: string]: {
|
|
208
|
+
[key: string]: {
|
|
209
|
+
timestamp: number;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
count: number;
|
|
214
|
+
num_auth_factors: number;
|
|
215
|
+
};
|
|
216
|
+
}>;
|
|
183
217
|
/**
|
|
184
218
|
* Approve a pending MFA request.
|
|
185
219
|
*
|
|
186
|
-
* @param {string} mfaId The id of the MFA request.
|
|
187
|
-
* @return {Promise<MfaRequestInfo>} The MFA request.
|
|
188
|
-
*
|
|
189
220
|
* @deprecated Use {@link approveMfaRequest()} instead.
|
|
190
221
|
*/
|
|
191
|
-
mfaApprove(mfaId: string)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
222
|
+
get mfaApprove(): (mfaId: string) => Promise<{
|
|
223
|
+
expires_at: number;
|
|
224
|
+
id: string;
|
|
225
|
+
receipt?: {
|
|
226
|
+
confirmation: string;
|
|
227
|
+
final_approver: string;
|
|
228
|
+
timestamp: number;
|
|
229
|
+
} | null | undefined;
|
|
230
|
+
request: {
|
|
231
|
+
body?: Record<string, unknown> | null | undefined;
|
|
232
|
+
method: string;
|
|
233
|
+
path: string;
|
|
234
|
+
};
|
|
235
|
+
status: {
|
|
236
|
+
allowed_approvers: string[];
|
|
237
|
+
allowed_mfa_types?: ("CubeSigner" | "Totp" | "Fido")[] | null | undefined;
|
|
238
|
+
approved_by: {
|
|
239
|
+
[key: string]: {
|
|
240
|
+
[key: string]: {
|
|
241
|
+
timestamp: number;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
count: number;
|
|
246
|
+
num_auth_factors: number;
|
|
247
|
+
};
|
|
248
|
+
}>;
|
|
249
|
+
/** Get a pending MFA request by its id. */
|
|
250
|
+
get getMfaInfo(): (mfaId: string) => Promise<{
|
|
251
|
+
expires_at: number;
|
|
252
|
+
id: string;
|
|
253
|
+
receipt?: {
|
|
254
|
+
confirmation: string;
|
|
255
|
+
final_approver: string;
|
|
256
|
+
timestamp: number;
|
|
257
|
+
} | null | undefined;
|
|
258
|
+
request: {
|
|
259
|
+
body?: Record<string, unknown> | null | undefined;
|
|
260
|
+
method: string;
|
|
261
|
+
path: string;
|
|
262
|
+
};
|
|
263
|
+
status: {
|
|
264
|
+
allowed_approvers: string[];
|
|
265
|
+
allowed_mfa_types?: ("CubeSigner" | "Totp" | "Fido")[] | null | undefined;
|
|
266
|
+
approved_by: {
|
|
267
|
+
[key: string]: {
|
|
268
|
+
[key: string]: {
|
|
269
|
+
timestamp: number;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
count: number;
|
|
274
|
+
num_auth_factors: number;
|
|
275
|
+
};
|
|
276
|
+
}>;
|
|
277
|
+
/** List pending MFA requests accessible to the current user. */
|
|
278
|
+
get listMfaInfos(): () => Promise<{
|
|
279
|
+
expires_at: number;
|
|
280
|
+
id: string;
|
|
281
|
+
receipt?: {
|
|
282
|
+
confirmation: string;
|
|
283
|
+
final_approver: string;
|
|
284
|
+
timestamp: number;
|
|
285
|
+
} | null | undefined;
|
|
286
|
+
request: {
|
|
287
|
+
body?: Record<string, unknown> | null | undefined;
|
|
288
|
+
method: string;
|
|
289
|
+
path: string;
|
|
290
|
+
};
|
|
291
|
+
status: {
|
|
292
|
+
allowed_approvers: string[];
|
|
293
|
+
allowed_mfa_types?: ("CubeSigner" | "Totp" | "Fido")[] | null | undefined;
|
|
294
|
+
approved_by: {
|
|
295
|
+
[key: string]: {
|
|
296
|
+
[key: string]: {
|
|
297
|
+
timestamp: number;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
count: number;
|
|
302
|
+
num_auth_factors: number;
|
|
303
|
+
};
|
|
304
|
+
}[]>;
|
|
305
|
+
/** Approve a pending MFA request. */
|
|
306
|
+
get approveMfaRequest(): (mfaId: string) => Promise<{
|
|
307
|
+
expires_at: number;
|
|
308
|
+
id: string;
|
|
309
|
+
receipt?: {
|
|
310
|
+
confirmation: string;
|
|
311
|
+
final_approver: string;
|
|
312
|
+
timestamp: number;
|
|
313
|
+
} | null | undefined;
|
|
314
|
+
request: {
|
|
315
|
+
body?: Record<string, unknown> | null | undefined;
|
|
316
|
+
method: string;
|
|
317
|
+
path: string;
|
|
318
|
+
};
|
|
319
|
+
status: {
|
|
320
|
+
allowed_approvers: string[];
|
|
321
|
+
allowed_mfa_types?: ("CubeSigner" | "Totp" | "Fido")[] | null | undefined;
|
|
322
|
+
approved_by: {
|
|
323
|
+
[key: string]: {
|
|
324
|
+
[key: string]: {
|
|
325
|
+
timestamp: number;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
count: number;
|
|
330
|
+
num_auth_factors: number;
|
|
331
|
+
};
|
|
332
|
+
}>;
|
|
203
333
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @param {string} mfaId The id of the MFA request.
|
|
207
|
-
* @return {Promise<MfaRequestInfo>} The MFA request.
|
|
208
|
-
*/
|
|
209
|
-
approveMfaRequest(mfaId: string): Promise<MfaRequestInfo>;
|
|
210
|
-
/** Create a new org.
|
|
211
|
-
* @param {CubeSigner} cs The CubeSigner instance.
|
|
334
|
+
* Create a new org.
|
|
335
|
+
* @param {CubeSignerClient} csc The CubeSigner instance.
|
|
212
336
|
* @param {OrgInfo} data The JSON response from the API server.
|
|
213
337
|
* @internal
|
|
214
|
-
* */
|
|
215
|
-
constructor(cs: CubeSigner, data: OrgInfo);
|
|
216
|
-
/**
|
|
217
|
-
* Approve a pending MFA request.
|
|
218
|
-
*
|
|
219
|
-
* @param {CubeSigner} cs The CubeSigner instance to use for requests
|
|
220
|
-
* @param {string} orgId The org id of the MFA request
|
|
221
|
-
* @param {string} mfaId The id of the MFA request
|
|
222
|
-
* @return {Promise<MfaRequestInfo>} The result of the MFA request
|
|
223
338
|
*/
|
|
224
|
-
|
|
225
|
-
/** Fetch org info.
|
|
226
|
-
* @return {OrgInfo} The org info.
|
|
227
|
-
* */
|
|
228
|
-
private fetch;
|
|
229
|
-
/** Update the org.
|
|
230
|
-
* @param {UpdateOrgRequest} request The JSON request to send to the API server.
|
|
231
|
-
* @return {UpdateOrgResponse} The JSON response from the API server.
|
|
232
|
-
* */
|
|
233
|
-
private update;
|
|
234
|
-
/** List roles.
|
|
235
|
-
* @param {CubeSigner} cs The CubeSigner instance to use for signing.
|
|
236
|
-
* @param {string} orgId The id of the organization to which the role belongs.
|
|
237
|
-
* @param {PageOpts} page Pagination options. Defaults to fetching the entire result set.
|
|
238
|
-
* @return {Role[]} Org roles.
|
|
239
|
-
* @internal
|
|
240
|
-
* */
|
|
241
|
-
private static roles;
|
|
242
|
-
/** List users.
|
|
243
|
-
* @param {CubeSigner} cs The CubeSigner instance to use for signing.
|
|
244
|
-
* @param {string} orgId The id of the organization to which the role belongs.
|
|
245
|
-
* @return {User[]} Org users.
|
|
246
|
-
* @internal
|
|
247
|
-
* */
|
|
248
|
-
private static users;
|
|
339
|
+
constructor(csc: CubeSignerClient, data: OrgInfo);
|
|
249
340
|
}
|
|
250
|
-
export {};
|