@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/org.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { CubeSigner, MfaRequestInfo, IdentityProof, PageOpts } from ".";
2
- import { components } from "./client";
1
+ import { OrgInfo } from "./schema_types";
2
+ import { CubeSignerClient } from "./client";
3
3
  import { KeyType, Key } from "./key";
4
- import { MfaPolicy, Role } from "./role";
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
- /** Set the human-readable name for the org.
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
- /** Create a new signing key.
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
- /** Create new signing keys.
73
+ /**
74
+ * Create new signing keys.
82
75
  * @param {KeyType} type The type of key to create.
83
- * @param {nummber} count The number of keys to create.
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
- * Derives a key of the given type using the given derivation path and mnemonic.
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
- * Derives a set of keys of the given type using the given derivation paths and mnemonic.
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
- * Create a new user in the organization and sends an invitation to that user
113
- * @param {string} email Email of the user
114
- * @param {string} name The full name of the user
115
- */
116
- createUser(email: string, name: string): Promise<void>;
117
- /**
118
- * Create a new OIDC user
119
- * @param {OidcIdentity} identity The identity of the OIDC user
120
- * @param {string} email Email of the OIDC user
121
- * @param {CreateOidcUserOptions} opts Additional options for new OIDC users
122
- * @return {string} User id of the new user
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
- * Checks if a given proof of OIDC authentication is valid.
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
- /** Get all keys in the org.
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
- /** Create a new role.
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
- /** Get a role by id or name.
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
- * @return {User[]} The users.
173
- * */
174
- listUsers(): Promise<UserIdInfo[]>;
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): Promise<MfaRequestInfo>;
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): Promise<MfaRequestInfo>;
192
- /**
193
- * Get a pending MFA request by its id.
194
- * @param {string} mfaId The id of the MFA request.
195
- * @return {Promise<MfaRequestInfo>} The MFA request.
196
- */
197
- getMfaInfo(mfaId: string): Promise<MfaRequestInfo>;
198
- /**
199
- * List pending MFA requests accessible to the current user.
200
- * @return {Promise<MfaRequestInfo[]>} The MFA requests.
201
- */
202
- listMfaInfos(): Promise<MfaRequestInfo[]>;
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
- * Approve a pending MFA request.
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
- static mfaApprove(cs: CubeSigner, orgId: string, mfaId: string): Promise<MfaRequestInfo>;
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 {};