@cubist-labs/cubesigner-sdk 0.3.13 → 0.3.23
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/README.md +1 -1
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/spec/env/beta.json +2 -1
- package/dist/cjs/spec/env/gamma.json +2 -1
- package/dist/cjs/spec/env/prod.json +2 -1
- package/dist/cjs/src/api.d.ts +53 -6
- package/dist/cjs/src/api.js +75 -22
- package/dist/cjs/src/client.d.ts +15 -2
- package/dist/cjs/src/client.js +5 -3
- package/dist/cjs/src/env.d.ts +1 -0
- package/dist/cjs/src/env.js +1 -1
- package/dist/cjs/src/error.d.ts +2 -0
- package/dist/cjs/src/error.js +7 -2
- package/dist/cjs/src/evm/index.d.ts +74 -0
- package/dist/cjs/src/evm/index.js +165 -0
- package/dist/cjs/src/index.d.ts +4 -0
- package/dist/cjs/src/index.js +5 -1
- package/dist/cjs/src/org.d.ts +20 -1
- package/dist/cjs/src/org.js +11 -1
- package/dist/cjs/src/org_event_processor.d.ts +57 -0
- package/dist/cjs/src/org_event_processor.js +137 -0
- package/dist/cjs/src/schema.d.ts +201 -23
- package/dist/cjs/src/schema.js +1 -1
- package/dist/cjs/src/schema_types.d.ts +6 -1
- package/dist/cjs/src/schema_types.js +1 -1
- package/dist/esm/package.json +2 -2
- package/dist/esm/spec/env/beta.json +2 -1
- package/dist/esm/spec/env/gamma.json +2 -1
- package/dist/esm/spec/env/prod.json +2 -1
- package/dist/esm/src/api.d.ts +53 -6
- package/dist/esm/src/api.js +76 -23
- package/dist/esm/src/client.d.ts +15 -2
- package/dist/esm/src/client.js +5 -3
- package/dist/esm/src/env.d.ts +1 -0
- package/dist/esm/src/env.js +1 -1
- package/dist/esm/src/error.d.ts +2 -0
- package/dist/esm/src/error.js +7 -2
- package/dist/esm/src/evm/index.d.ts +74 -0
- package/dist/esm/src/evm/index.js +161 -0
- package/dist/esm/src/index.d.ts +4 -0
- package/dist/esm/src/index.js +5 -1
- package/dist/esm/src/org.d.ts +20 -1
- package/dist/esm/src/org.js +12 -2
- package/dist/esm/src/org_event_processor.d.ts +57 -0
- package/dist/esm/src/org_event_processor.js +133 -0
- package/dist/esm/src/schema.d.ts +201 -23
- package/dist/esm/src/schema.js +1 -1
- package/dist/esm/src/schema_types.d.ts +6 -1
- package/dist/esm/src/schema_types.js +1 -1
- package/package.json +2 -2
- package/src/api.ts +106 -22
- package/src/client.ts +11 -3
- package/src/env.ts +1 -0
- package/src/error.ts +8 -1
- package/src/evm/index.ts +192 -0
- package/src/index.ts +4 -0
- package/src/org.ts +17 -1
- package/src/org_event_processor.ts +173 -0
- package/src/schema.ts +226 -22
- package/src/schema_types.ts +6 -1
- package/tsconfig.json +3 -3
|
@@ -3,6 +3,7 @@ import { components } from "./schema";
|
|
|
3
3
|
import { JsonMap } from "./util";
|
|
4
4
|
type schemas = components["schemas"];
|
|
5
5
|
export type UserInfo = schemas["UserInfo"];
|
|
6
|
+
export type UserInOrgMembership = schemas["UserInOrgMembership"];
|
|
6
7
|
export type ConfiguredMfa = schemas["ConfiguredMfa"];
|
|
7
8
|
export type RatchetConfig = schemas["RatchetConfig"];
|
|
8
9
|
export type IdentityProof = schemas["IdentityProof"];
|
|
@@ -18,14 +19,18 @@ export type AuthenticatorSelectionCriteria = schemas["AuthenticatorSelectionCrit
|
|
|
18
19
|
export type PublicKeyCredentialUserEntity = schemas["PublicKeyCredentialUserEntity"];
|
|
19
20
|
export type PublicKeyCredential = schemas["PublicKeyCredential"];
|
|
20
21
|
export type OrgInfo = schemas["OrgInfo"];
|
|
21
|
-
export type
|
|
22
|
+
export type UserInOrgInfo = schemas["UserInOrgInfo"];
|
|
22
23
|
export type UpdateOrgRequest = schemas["UpdateOrgRequest"];
|
|
23
24
|
export type UpdateOrgResponse = schemas["UpdateOrgResponse"];
|
|
25
|
+
export type NotificationEndpointConfiguration = schemas["NotificationEndpointConfiguration"];
|
|
26
|
+
export type OrgEvents = schemas["OrgEventDiscriminants"];
|
|
24
27
|
export type OidcIdentity = schemas["OIDCIdentity"];
|
|
25
28
|
export type MemberRole = schemas["MemberRole"];
|
|
26
29
|
export type SchemaKeyType = schemas["KeyType"];
|
|
27
30
|
export type ListKeysResponse = schemas["PaginatedListKeysResponse"];
|
|
28
31
|
export type UpdateKeyRequest = schemas["UpdateKeyRequest"];
|
|
32
|
+
export type UpdateKeyProperties = schemas["UpdateKeyProperties"];
|
|
33
|
+
export type CreateKeyRequest = schemas["CreateKeyRequest"];
|
|
29
34
|
export type KeyInfoApi = schemas["KeyInfo"];
|
|
30
35
|
export type KeyInRoleInfo = schemas["KeyInRoleInfo"];
|
|
31
36
|
export type UserInRoleInfo = schemas["UserInRoleInfo"];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NoZW1hX3R5cGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3NjaGVtYV90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgTWZhUG9saWN5IH0gZnJvbSBcIi4vcm9sZVwiO1xuaW1wb3J0IHsgY29tcG9uZW50cyB9IGZyb20gXCIuL3NjaGVtYVwiO1xuaW1wb3J0IHsgSnNvbk1hcCB9IGZyb20gXCIuL3V0aWxcIjtcblxudHlwZSBzY2hlbWFzID0gY29tcG9uZW50c1tcInNjaGVtYXNcIl07XG5cbmV4cG9ydCB0eXBlIFVzZXJJbmZvID0gc2NoZW1hc1tcIlVzZXJJbmZvXCJdO1xuZXhwb3J0IHR5cGUgVXNlckluT3JnTWVtYmVyc2hpcCA9IHNjaGVtYXNbXCJVc2VySW5PcmdNZW1iZXJzaGlwXCJdO1xuZXhwb3J0IHR5cG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FsaWRhdG9yOiBKc29uTWFwIH1cbiAgfCB7IEFkZFN1Ym5ldFZhbGlkYXRvcjogSnNvbk1hcCB9XG4gIHwgeyBBZGRWYWxpZGF0b3I6IEpzb25NYXAgfVxuICB8IHsgQ3JlYXRlQ2hhaW46IEpzb25NYXAgfVxuICB8IHsgQ3JlYXRlU3VibmV0OiBKc29uTWFwIH1cbiAgfCB7IEV4cG9ydDogSnNvbk1hcCB9XG4gIHwgeyBJbXBvcnQ6IEpzb25NYXAgfTtcblxuLyoqIEF2YSBYLWNoYWluIHRyYW5zYWN0aW9uICovXG5leHBvcnQgdHlwZSBBdmFYQ2hhaW5UeCA9IHsgQmFzZTogSnNvbk1hcCB9IHwgeyBFeHBvcnQ6IEpzb25NYXAgfSB8IHsgSW1wb3J0OiBKc29uTWFwIH07XG4iXX0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubist-labs/cubesigner-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
4
4
|
"description": "CubeSigner TypeScript SDK",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "Cubist, Inc.",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"openapi-fetch": "0.6.1"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@hpke/core": "^1.2.
|
|
33
|
+
"@hpke/core": "^1.2.7"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">=18.0.0"
|
package/src/api.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
UpdateOrgRequest,
|
|
30
30
|
UpdateOrgResponse,
|
|
31
31
|
UpdateRoleRequest,
|
|
32
|
-
|
|
32
|
+
UserInOrgInfo,
|
|
33
33
|
UserInRoleInfo,
|
|
34
34
|
UserInfo,
|
|
35
35
|
SessionInfo,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
Empty,
|
|
65
65
|
ErrorResponse,
|
|
66
66
|
} from "./schema_types";
|
|
67
|
-
import { encodeToBase64 } from "./util";
|
|
67
|
+
import { delay, encodeToBase64 } from "./util";
|
|
68
68
|
import { AddFidoChallenge, MfaFidoChallenge, MfaReceipt, TotpChallenge } from "./mfa";
|
|
69
69
|
import { CubeSignerResponse, mapResponse } from "./response";
|
|
70
70
|
import { ErrResponse } from "./error";
|
|
@@ -74,7 +74,7 @@ import { KeyPolicy } from "./role";
|
|
|
74
74
|
import { EnvInterface } from "./env";
|
|
75
75
|
import { loadSubtleCrypto } from "./user_export";
|
|
76
76
|
import { EventEmitter } from "./events";
|
|
77
|
-
import { NAME, VERSION } from "./index";
|
|
77
|
+
import { NAME, UpdateKeyProperties, VERSION } from "./index";
|
|
78
78
|
|
|
79
79
|
/** @internal */
|
|
80
80
|
export type Client = ReturnType<typeof createClient<paths>>;
|
|
@@ -117,6 +117,24 @@ export type FetchClient<Op extends keyof operations> = ReturnType<typeof createC
|
|
|
117
117
|
*/
|
|
118
118
|
export type FetchResponseSuccessData<T> = Required<FetchResponse<T>>["data"];
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Internal type for a function that returns a promise of a fetch response.
|
|
122
|
+
*/
|
|
123
|
+
type ReqFn<T> = () => Promise<FetchResponse<T>>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Retry settings.
|
|
127
|
+
*
|
|
128
|
+
* By default, {@link OpClient} retries on 5xx codes with delays of
|
|
129
|
+
* 100ms, 200ms, and 400ms between retries.
|
|
130
|
+
*/
|
|
131
|
+
export interface RetrySettings {
|
|
132
|
+
/** HTTP status codes on which to retry */
|
|
133
|
+
codes: number[];
|
|
134
|
+
/** Delays in milliseconds between retries */
|
|
135
|
+
delaysMs: number[];
|
|
136
|
+
}
|
|
137
|
+
|
|
120
138
|
/**
|
|
121
139
|
* Wrapper around an open-fetch client restricted to a single operation.
|
|
122
140
|
* The restriction applies only when type checking, the actual
|
|
@@ -127,16 +145,28 @@ export class OpClient<Op extends keyof operations> {
|
|
|
127
145
|
readonly #op: Op;
|
|
128
146
|
readonly #client: FetchClient<Op>;
|
|
129
147
|
readonly #eventEmitter: EventEmitter;
|
|
148
|
+
readonly #retry: RetrySettings;
|
|
130
149
|
|
|
131
150
|
/**
|
|
132
151
|
* @param {Op} op The operation this client should be restricted to
|
|
133
152
|
* @param {FetchClient<Op> | Client} client open-fetch client (either restricted to {@link Op} or not)
|
|
134
153
|
* @param {EventEmitter} eventEmitter The client-local event dispatcher.
|
|
135
|
-
|
|
136
|
-
|
|
154
|
+
* @param {number[]} retrySettings Retry settings. By default, retries 3 times, sleeping 100ms
|
|
155
|
+
* after the first failed attempt, 200ms after the second, and finally 400ms after the third,
|
|
156
|
+
*/
|
|
157
|
+
constructor(
|
|
158
|
+
op: Op,
|
|
159
|
+
client: FetchClient<Op> | Client,
|
|
160
|
+
eventEmitter: EventEmitter,
|
|
161
|
+
retrySettings?: RetrySettings,
|
|
162
|
+
) {
|
|
137
163
|
this.#op = op;
|
|
138
164
|
this.#client = client as FetchClient<Op>; // either works
|
|
139
165
|
this.#eventEmitter = eventEmitter;
|
|
166
|
+
this.#retry = retrySettings ?? {
|
|
167
|
+
codes: [...Array(100).keys()].map((i) => 500 + i),
|
|
168
|
+
delaysMs: [100, 200, 400],
|
|
169
|
+
};
|
|
140
170
|
}
|
|
141
171
|
|
|
142
172
|
/** The operation this client is restricted to */
|
|
@@ -156,6 +186,7 @@ export class OpClient<Op extends keyof operations> {
|
|
|
156
186
|
const errResp = resp.error as unknown as ErrorResponse | undefined;
|
|
157
187
|
const error = new ErrResponse({
|
|
158
188
|
operation: this.op,
|
|
189
|
+
requestId: errResp?.request_id,
|
|
159
190
|
message: errResp?.message,
|
|
160
191
|
statusText: resp.response?.statusText,
|
|
161
192
|
status: resp.response?.status,
|
|
@@ -171,6 +202,49 @@ export class OpClient<Op extends keyof operations> {
|
|
|
171
202
|
return resp.data;
|
|
172
203
|
}
|
|
173
204
|
|
|
205
|
+
/**
|
|
206
|
+
* @param {number[]} delaysMs Delays in milliseconds between retries.
|
|
207
|
+
* @return {OpClient<Op>} Returns the same client as this except with different retry delays.
|
|
208
|
+
*/
|
|
209
|
+
withRetries(delaysMs: number[]): OpClient<Op> {
|
|
210
|
+
return this.withRetrySettings({
|
|
211
|
+
codes: this.#retry.codes,
|
|
212
|
+
delaysMs,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @param {RetrySettings} retrySettings New retry settings
|
|
218
|
+
* @return {OpClient<Op>} Returns the same client as this except with different retry settings.
|
|
219
|
+
*/
|
|
220
|
+
withRetrySettings(retrySettings: RetrySettings): OpClient<Op> {
|
|
221
|
+
return new OpClient(this.op, this.#client, this.#eventEmitter, retrySettings);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// not private only so that the test can call it
|
|
225
|
+
/**
|
|
226
|
+
* Internal.
|
|
227
|
+
*
|
|
228
|
+
* Executes a given request, potentially retrying on 5xx errors. The
|
|
229
|
+
* retry configuration can be set via the constructor.
|
|
230
|
+
* On all other errors, throws {@link ErrResponse} (as well as after exhausting all retries).
|
|
231
|
+
* On success, returns the response body.
|
|
232
|
+
*
|
|
233
|
+
* @param {ReqFn<T>} req The request to execute and then retry on 5xx errors
|
|
234
|
+
* @return {Promise<FetchResponseSuccessData<T>>}
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
async execute<T>(req: ReqFn<T>): Promise<FetchResponseSuccessData<T>> {
|
|
238
|
+
let resp = await req();
|
|
239
|
+
let i = 0;
|
|
240
|
+
while (this.#retry.codes.includes(resp.response?.status) && i < this.#retry.delaysMs.length) {
|
|
241
|
+
await delay(this.#retry.delaysMs[i]);
|
|
242
|
+
resp = await req();
|
|
243
|
+
i++;
|
|
244
|
+
}
|
|
245
|
+
return await this.assertOk(resp);
|
|
246
|
+
}
|
|
247
|
+
|
|
174
248
|
/* eslint-disable valid-jsdoc */
|
|
175
249
|
|
|
176
250
|
/**
|
|
@@ -180,8 +254,7 @@ export class OpClient<Op extends keyof operations> {
|
|
|
180
254
|
url: PathsWith<Paths<Op>, "get">,
|
|
181
255
|
init: FetchOptions<FilterKeys<Paths<Op>[PathsWith<Paths<Op>, "get">], "get">>,
|
|
182
256
|
) {
|
|
183
|
-
|
|
184
|
-
return await this.assertOk(resp);
|
|
257
|
+
return await this.execute(() => this.#client.get(url, init));
|
|
185
258
|
}
|
|
186
259
|
|
|
187
260
|
/** Invoke HTTP POST */
|
|
@@ -189,8 +262,7 @@ export class OpClient<Op extends keyof operations> {
|
|
|
189
262
|
url: PathsWith<Paths<Op>, "post">,
|
|
190
263
|
init: FetchOptions<FilterKeys<Paths<Op>[PathsWith<Paths<Op>, "post">], "post">>,
|
|
191
264
|
) {
|
|
192
|
-
|
|
193
|
-
return await this.assertOk(resp);
|
|
265
|
+
return await this.execute(() => this.#client.post(url, init));
|
|
194
266
|
}
|
|
195
267
|
|
|
196
268
|
/** Invoke HTTP PATCH */
|
|
@@ -198,8 +270,7 @@ export class OpClient<Op extends keyof operations> {
|
|
|
198
270
|
url: PathsWith<Paths<Op>, "patch">,
|
|
199
271
|
init: FetchOptions<FilterKeys<Paths<Op>[PathsWith<Paths<Op>, "patch">], "patch">>,
|
|
200
272
|
) {
|
|
201
|
-
|
|
202
|
-
return await this.assertOk(resp);
|
|
273
|
+
return await this.execute(() => this.#client.patch(url, init));
|
|
203
274
|
}
|
|
204
275
|
|
|
205
276
|
/** Invoke HTTP DELETE */
|
|
@@ -207,8 +278,7 @@ export class OpClient<Op extends keyof operations> {
|
|
|
207
278
|
url: PathsWith<Paths<Op>, "delete">,
|
|
208
279
|
init: FetchOptions<FilterKeys<Paths<Op>[PathsWith<Paths<Op>, "delete">], "delete">>,
|
|
209
280
|
) {
|
|
210
|
-
|
|
211
|
-
return await this.assertOk(resp);
|
|
281
|
+
return await this.execute(() => this.#client.del(url, init));
|
|
212
282
|
}
|
|
213
283
|
|
|
214
284
|
/** Invoke HTTP PUT */
|
|
@@ -216,8 +286,7 @@ export class OpClient<Op extends keyof operations> {
|
|
|
216
286
|
url: PathsWith<Paths<Op>, "put">,
|
|
217
287
|
init: FetchOptions<FilterKeys<Paths<Op>[PathsWith<Paths<Op>, "put">], "put">>,
|
|
218
288
|
) {
|
|
219
|
-
|
|
220
|
-
return await this.assertOk(resp);
|
|
289
|
+
return await this.execute(() => this.#client.put(url, init));
|
|
221
290
|
}
|
|
222
291
|
|
|
223
292
|
/* eslint-enable valid-jsdoc */
|
|
@@ -250,6 +319,7 @@ export class CubeSignerApi {
|
|
|
250
319
|
readonly #orgId: string;
|
|
251
320
|
readonly #sessionMgr: SignerSessionManager;
|
|
252
321
|
readonly #eventEmitter: EventEmitter;
|
|
322
|
+
readonly #retrySettings?: RetrySettings;
|
|
253
323
|
|
|
254
324
|
/** Underlying session manager */
|
|
255
325
|
get sessionMgr(): SignerSessionManager {
|
|
@@ -265,11 +335,14 @@ export class CubeSignerApi {
|
|
|
265
335
|
* Constructor.
|
|
266
336
|
* @param {SignerSessionManager} sessionMgr The session manager to use
|
|
267
337
|
* @param {string?} orgId Optional organization ID; if omitted, uses the org ID from the session manager.
|
|
338
|
+
* @param {RetrySettings} retrySettings Retry settings. By default, retries 3 times, sleeping 100ms
|
|
339
|
+
* after the first failed attempt, 200ms after the second, and finally 400ms after the third,
|
|
268
340
|
*/
|
|
269
|
-
constructor(sessionMgr: SignerSessionManager, orgId?: string) {
|
|
341
|
+
constructor(sessionMgr: SignerSessionManager, orgId?: string, retrySettings?: RetrySettings) {
|
|
270
342
|
this.#sessionMgr = sessionMgr;
|
|
271
343
|
this.#eventEmitter = new EventEmitter([sessionMgr.events]);
|
|
272
344
|
this.#orgId = orgId ?? sessionMgr.orgId;
|
|
345
|
+
this.#retrySettings = retrySettings;
|
|
273
346
|
}
|
|
274
347
|
|
|
275
348
|
/**
|
|
@@ -296,7 +369,7 @@ export class CubeSignerApi {
|
|
|
296
369
|
*/
|
|
297
370
|
private async client<Op extends keyof operations>(op: Op): Promise<OpClient<Op>> {
|
|
298
371
|
const fetchClient = await this.#sessionMgr.client(op);
|
|
299
|
-
return new OpClient(op, fetchClient, this.#eventEmitter);
|
|
372
|
+
return new OpClient(op, fetchClient, this.#eventEmitter, this.#retrySettings);
|
|
300
373
|
}
|
|
301
374
|
|
|
302
375
|
// #region USERS: userGet, userTotp(ResetInit|ResetComplete|Verify|Delete), userFido(RegisterInit|RegisterComplete|Delete)
|
|
@@ -520,7 +593,7 @@ export class CubeSignerApi {
|
|
|
520
593
|
* List users.
|
|
521
594
|
* @return {User[]} Org users.
|
|
522
595
|
*/
|
|
523
|
-
async orgUsersList(): Promise<
|
|
596
|
+
async orgUsersList(): Promise<UserInOrgInfo[]> {
|
|
524
597
|
const client = await this.client("listUsersInOrg");
|
|
525
598
|
const resp = await client.get("/v0/org/{org_id}/users", {
|
|
526
599
|
params: { path: { org_id: this.orgId } },
|
|
@@ -639,9 +712,15 @@ export class CubeSignerApi {
|
|
|
639
712
|
* @param {KeyType} keyType The type of key to create.
|
|
640
713
|
* @param {number} count The number of keys to create.
|
|
641
714
|
* @param {string?} ownerId The owner of the keys. Defaults to the session's user.
|
|
715
|
+
* @param {UpdateKeyProperties?} props Additional key properties
|
|
642
716
|
* @return {KeyInfoApi[]} The new keys.
|
|
643
717
|
*/
|
|
644
|
-
async keysCreate(
|
|
718
|
+
async keysCreate(
|
|
719
|
+
keyType: KeyType,
|
|
720
|
+
count: number,
|
|
721
|
+
ownerId?: string,
|
|
722
|
+
props?: UpdateKeyProperties,
|
|
723
|
+
): Promise<KeyInfoApi[]> {
|
|
645
724
|
const chain_id = 0; // not used anymore
|
|
646
725
|
const client = await this.client("createKey");
|
|
647
726
|
const data = await client.post("/v0/org/{org_id}/keys", {
|
|
@@ -650,7 +729,8 @@ export class CubeSignerApi {
|
|
|
650
729
|
count,
|
|
651
730
|
chain_id,
|
|
652
731
|
key_type: keyType,
|
|
653
|
-
|
|
732
|
+
...props,
|
|
733
|
+
owner: props?.owner ?? ownerId,
|
|
654
734
|
},
|
|
655
735
|
});
|
|
656
736
|
return data.keys;
|
|
@@ -1593,16 +1673,20 @@ export class OidcClient {
|
|
|
1593
1673
|
readonly #env: EnvInterface;
|
|
1594
1674
|
readonly #orgId: string;
|
|
1595
1675
|
readonly #client: Client;
|
|
1676
|
+
readonly #retrySettings?: RetrySettings;
|
|
1596
1677
|
|
|
1597
1678
|
/**
|
|
1598
1679
|
* @param {EnvInterface} env CubeSigner deployment
|
|
1599
1680
|
* @param {string} orgId Target organization ID
|
|
1600
1681
|
* @param {string} oidcToken User's OIDC token
|
|
1682
|
+
* @param {RetrySettings} retrySettings Retry settings. By default, retries 3 times, sleeping 100ms
|
|
1683
|
+
* after the first failed attempt, 200ms after the second, and finally 400ms after the third.
|
|
1601
1684
|
*/
|
|
1602
|
-
constructor(env: EnvInterface, orgId: string, oidcToken: string) {
|
|
1685
|
+
constructor(env: EnvInterface, orgId: string, oidcToken: string, retrySettings?: RetrySettings) {
|
|
1603
1686
|
this.#orgId = orgId;
|
|
1604
1687
|
this.#env = env;
|
|
1605
1688
|
this.#client = createHttpClient(env.SignerApiRoot, oidcToken);
|
|
1689
|
+
this.#retrySettings = retrySettings;
|
|
1606
1690
|
}
|
|
1607
1691
|
|
|
1608
1692
|
/**
|
|
@@ -1612,7 +1696,7 @@ export class OidcClient {
|
|
|
1612
1696
|
* @return {OpClient<Op>} The client restricted to {@link op}
|
|
1613
1697
|
*/
|
|
1614
1698
|
private client<Op extends keyof operations>(op: Op): OpClient<Op> {
|
|
1615
|
-
return new OpClient(op, this.#client, new EventEmitter([]));
|
|
1699
|
+
return new OpClient(op, this.#client, new EventEmitter([]), this.#retrySettings);
|
|
1616
1700
|
}
|
|
1617
1701
|
|
|
1618
1702
|
/**
|
package/src/client.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { SignerSessionManager, SignerSessionStorage } from "./session/signer_session_manager";
|
|
2
2
|
import { CubeSignerApi, OidcClient } from "./api";
|
|
3
3
|
import { KeyType, Key } from "./key";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
MfaRequestInfo,
|
|
6
|
+
OrgInfo,
|
|
7
|
+
PublicKeyCredential,
|
|
8
|
+
RatchetConfig,
|
|
9
|
+
UpdateKeyProperties,
|
|
10
|
+
} from "./schema_types";
|
|
5
11
|
import { MfaReceipt } from "./mfa";
|
|
6
12
|
import { PageOpts } from "./paginator";
|
|
7
13
|
import { Role } from "./role";
|
|
@@ -68,10 +74,12 @@ export class CubeSignerClient extends CubeSignerApi {
|
|
|
68
74
|
* Create a new signing key.
|
|
69
75
|
* @param {KeyType} type The type of key to create.
|
|
70
76
|
* @param {string?} ownerId The owner of the key. Defaults to the session's user.
|
|
77
|
+
* @param {UpdateKeyProperties?} props Additional key properties
|
|
71
78
|
* @return {Key[]} The new keys.
|
|
72
79
|
*/
|
|
73
|
-
async createKey(type: KeyType, ownerId?: string): Promise<Key> {
|
|
74
|
-
|
|
80
|
+
async createKey(type: KeyType, ownerId?: string, props?: UpdateKeyProperties): Promise<Key> {
|
|
81
|
+
const keys = await this.keysCreate(type, 1, ownerId, props);
|
|
82
|
+
return new Key(this, keys[0]);
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
/**
|
package/src/env.ts
CHANGED
package/src/error.ts
CHANGED
|
@@ -20,7 +20,12 @@ const mfaErrorCodes: CsErrCode[] = [
|
|
|
20
20
|
/**
|
|
21
21
|
* Opcodes corresponding to all different MFA approve/reject requests
|
|
22
22
|
*/
|
|
23
|
-
const mfaOpCodes: (keyof operations)[] = [
|
|
23
|
+
const mfaOpCodes: (keyof operations)[] = [
|
|
24
|
+
"mfaVoteCs",
|
|
25
|
+
"userResetTotpComplete",
|
|
26
|
+
"mfaVoteTotp",
|
|
27
|
+
"mfaVoteFidoComplete",
|
|
28
|
+
];
|
|
24
29
|
|
|
25
30
|
/**
|
|
26
31
|
* Error response type, thrown on non-successful responses.
|
|
@@ -36,6 +41,8 @@ export class ErrResponse extends Error {
|
|
|
36
41
|
readonly url?: string;
|
|
37
42
|
/** CubeSigner error code */
|
|
38
43
|
readonly errorCode?: CsErrCode;
|
|
44
|
+
/** Request ID */
|
|
45
|
+
readonly requestId?: string;
|
|
39
46
|
|
|
40
47
|
/**
|
|
41
48
|
* @param {Partial<ErrResponse>} init Initializer
|
package/src/evm/index.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CubeSignerResponse,
|
|
3
|
+
KeyInfo,
|
|
4
|
+
Eip191SignRequest,
|
|
5
|
+
Eip712SignRequest,
|
|
6
|
+
EvmSignRequest,
|
|
7
|
+
MfaRequestInfo,
|
|
8
|
+
SignerSession,
|
|
9
|
+
EvmSignResponse,
|
|
10
|
+
} from "../index";
|
|
11
|
+
|
|
12
|
+
/** Options for the signer */
|
|
13
|
+
export interface EvmSignerOptions {
|
|
14
|
+
/**
|
|
15
|
+
* The function to call when MFA information is retrieved. If this callback
|
|
16
|
+
* throws, no transaction is broadcast.
|
|
17
|
+
*/
|
|
18
|
+
onMfaPoll?: (arg0: MfaRequestInfo) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The amount of time (in milliseconds) to wait between checks for MFA
|
|
21
|
+
* updates. Default is 1000ms
|
|
22
|
+
*/
|
|
23
|
+
mfaPollIntervalMs?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Signer using CubeSigner, with basic MFA handling.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export class EvmSigner {
|
|
31
|
+
/** The address of the account */
|
|
32
|
+
readonly #address: string;
|
|
33
|
+
|
|
34
|
+
/** The key to use for signing */
|
|
35
|
+
#key?: KeyInfo;
|
|
36
|
+
|
|
37
|
+
/** The underlying session */
|
|
38
|
+
readonly #signerSession: SignerSession;
|
|
39
|
+
|
|
40
|
+
/** Options */
|
|
41
|
+
readonly #options: EvmSignerOptions;
|
|
42
|
+
|
|
43
|
+
/** Returns the key address (NOT checksummed) */
|
|
44
|
+
get address() {
|
|
45
|
+
return this.#address;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Returns the underlying signer session */
|
|
49
|
+
get signerSession() {
|
|
50
|
+
return this.#signerSession;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Options */
|
|
54
|
+
get options() {
|
|
55
|
+
return this.#options;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create new Signer instance
|
|
60
|
+
* @param {KeyInfo | string} address The key or the eth address of the account to use.
|
|
61
|
+
* @param {SignerSession} signerSession The underlying Signer session.
|
|
62
|
+
* @param {EvmSignerOptions} options The options to use for the Signer instance
|
|
63
|
+
*/
|
|
64
|
+
constructor(address: KeyInfo | string, signerSession: SignerSession, options?: EvmSignerOptions) {
|
|
65
|
+
if (typeof address === "string") {
|
|
66
|
+
this.#address = address;
|
|
67
|
+
} else {
|
|
68
|
+
this.#address = address.materialId;
|
|
69
|
+
this.#key = address;
|
|
70
|
+
}
|
|
71
|
+
this.#signerSession = signerSession;
|
|
72
|
+
this.#options = <EvmSignerOptions>{
|
|
73
|
+
onMfaPoll: options?.onMfaPoll,
|
|
74
|
+
mfaPollIntervalMs: options?.mfaPollIntervalMs ?? 1000,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sign a transaction. This method will block if the key requires MFA approval.
|
|
80
|
+
* @param {EvmSignRequest} req The sign request.
|
|
81
|
+
* @return {Promise<string>} Hex-encoded RLP encoding of the transaction and its signature.
|
|
82
|
+
*/
|
|
83
|
+
async signTransaction(req: EvmSignRequest): Promise<string> {
|
|
84
|
+
const res = await this.signEvm(req);
|
|
85
|
+
const data = await this.#handleMfa(res);
|
|
86
|
+
return data.rlp_signed_tx;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Sign a transaction. This method does not block if the key requires MFA approval, i.e.,
|
|
91
|
+
* the returned {@link CubeSignerResponse} object either contains a signature or indicates
|
|
92
|
+
* that MFA is required.
|
|
93
|
+
*
|
|
94
|
+
* @param {EvmSignRequest} req The transaction to sign.
|
|
95
|
+
* @return {CubeSignerResponse<EvmSignResponse>} The response from the CubeSigner remote end.
|
|
96
|
+
*/
|
|
97
|
+
async signEvm(req: EvmSignRequest): Promise<CubeSignerResponse<EvmSignResponse>> {
|
|
98
|
+
return await this.#signerSession.signEvm(this.#address, req);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Signs EIP-712 typed data. This uses CubeSigner's EIP-712 signing endpoint.
|
|
103
|
+
* The key (for this session) must have the `"AllowRawBlobSigning"` or
|
|
104
|
+
* `"AllowEip712Signing"` policy attached.
|
|
105
|
+
* @param {Eip712SignRequest} req The EIP712 sign request.
|
|
106
|
+
* @return {Promise<string>} The signature.
|
|
107
|
+
*/
|
|
108
|
+
async signEip712(req: Eip712SignRequest): Promise<string> {
|
|
109
|
+
const res = await this.#signerSession.signEip712(this.#address, req);
|
|
110
|
+
const data = await this.#handleMfa(res);
|
|
111
|
+
return data.signature;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Signs arbitrary messages. This uses CubeSigner's EIP-191 signing endpoint.
|
|
116
|
+
* The key (for this session) must have the `"AllowRawBlobSigning"` or
|
|
117
|
+
* `"AllowEip191Signing"` policy attached.
|
|
118
|
+
* @param {Eip191SignRequest} req The request to sign.
|
|
119
|
+
* @return {Promise<string>} The signature.
|
|
120
|
+
*/
|
|
121
|
+
async signEip191(req: Eip191SignRequest): Promise<string> {
|
|
122
|
+
const res = await this.#signerSession.signEip191(this.#address, req);
|
|
123
|
+
const data = await this.#handleMfa(res);
|
|
124
|
+
return data.signature;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** @return {KeyInfo} The key corresponding to this address */
|
|
128
|
+
async key(): Promise<KeyInfo> {
|
|
129
|
+
if (this.#key === undefined) {
|
|
130
|
+
const key = (await this.#signerSession.keys()).find((k) => k.material_id === this.#address);
|
|
131
|
+
if (key === undefined) {
|
|
132
|
+
throw new Error(`Cannot access key '${this.#address}'`);
|
|
133
|
+
}
|
|
134
|
+
this.#key = key;
|
|
135
|
+
}
|
|
136
|
+
return this.#key;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Sign a transaction from an approved MFA request. The MFA request contains
|
|
141
|
+
* information about the approved signing request, which this method will execute.
|
|
142
|
+
* @param {MfaRequestInfo} mfaInfo The approved MFA request.
|
|
143
|
+
* @return {Promise<string>} Hex-encoded RLP encoding of the transaction and its signature.
|
|
144
|
+
*/
|
|
145
|
+
async signTransactionMfaApproved(mfaInfo: MfaRequestInfo): Promise<string> {
|
|
146
|
+
if (!mfaInfo.request.path.includes("/eth1/sign/")) {
|
|
147
|
+
throw new Error(`Expected EVM transaction signing request, got ${mfaInfo.request.path}`);
|
|
148
|
+
}
|
|
149
|
+
if (!mfaInfo.request.path.includes(this.#address)) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`Expected signing request for ${this.#address} but got ${mfaInfo.request.path}`,
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
if (!mfaInfo.receipt) {
|
|
155
|
+
throw new Error("MFA request is not approved yet");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const resp = await this.#signerSession.signEvm(
|
|
159
|
+
this.#address,
|
|
160
|
+
mfaInfo.request.body as EvmSignRequest,
|
|
161
|
+
{
|
|
162
|
+
mfaId: mfaInfo.id,
|
|
163
|
+
mfaOrgId: this.#signerSession.orgId,
|
|
164
|
+
mfaConf: mfaInfo.receipt!.confirmation,
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
return resp.data().rlp_signed_tx;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* If the sign request requires MFA, this method waits for approvals
|
|
172
|
+
* @param {CubeSignerResponse<U>} res The response of a sign request
|
|
173
|
+
* @return {Promise<U>} The sign data after MFA approvals
|
|
174
|
+
*/
|
|
175
|
+
async #handleMfa<U>(res: CubeSignerResponse<U>): Promise<U> {
|
|
176
|
+
while (res.requiresMfa()) {
|
|
177
|
+
await new Promise((resolve) => setTimeout(resolve, this.#options.mfaPollIntervalMs));
|
|
178
|
+
|
|
179
|
+
const mfaId = res.mfaId();
|
|
180
|
+
const mfaInfo = await this.#signerSession.getMfaInfo(mfaId);
|
|
181
|
+
this.#options.onMfaPoll?.(mfaInfo);
|
|
182
|
+
if (mfaInfo.receipt) {
|
|
183
|
+
res = await res.signWithMfaApproval({
|
|
184
|
+
mfaId,
|
|
185
|
+
mfaOrgId: this.#signerSession.orgId,
|
|
186
|
+
mfaConf: mfaInfo.receipt.confirmation,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return res.data();
|
|
191
|
+
}
|
|
192
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -298,6 +298,8 @@ export * from "./role";
|
|
|
298
298
|
export * from "./env";
|
|
299
299
|
/** Fido */
|
|
300
300
|
export * from "./mfa";
|
|
301
|
+
/** Utils for processing org events */
|
|
302
|
+
export * from "./org_event_processor";
|
|
301
303
|
/** Pagination */
|
|
302
304
|
export * from "./paginator";
|
|
303
305
|
/** Response */
|
|
@@ -314,6 +316,8 @@ export * from "./session/signer_session_manager";
|
|
|
314
316
|
export * from "./util";
|
|
315
317
|
/** User-export decryption helper */
|
|
316
318
|
export { userExportDecrypt, userExportKeygen } from "./user_export";
|
|
319
|
+
/** Ethers.js helpers */
|
|
320
|
+
export * from "./evm";
|
|
317
321
|
|
|
318
322
|
/** CubeSigner SDK package name */
|
|
319
323
|
export const NAME: string = name;
|
package/src/org.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { CubeSignerClient } from "./client";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
NotificationEndpointConfiguration,
|
|
4
|
+
OrgInfo,
|
|
5
|
+
SignerSessionManager,
|
|
6
|
+
SignerSessionStorage,
|
|
7
|
+
} from ".";
|
|
3
8
|
|
|
4
9
|
/** Organization id */
|
|
5
10
|
export type OrgId = string;
|
|
@@ -120,6 +125,17 @@ export class Org extends CubeSignerClient {
|
|
|
120
125
|
await this.orgUpdate({ policy: p });
|
|
121
126
|
}
|
|
122
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Set the notification endpoints for the org.
|
|
130
|
+
*
|
|
131
|
+
* @param {NotificationEndpointConfiguration[]} notification_endpoints Endpoints.
|
|
132
|
+
*/
|
|
133
|
+
async setNotificationEndpoints(notification_endpoints: NotificationEndpointConfiguration[]) {
|
|
134
|
+
await this.orgUpdate({
|
|
135
|
+
notification_endpoints,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
123
139
|
/**
|
|
124
140
|
* Retrieve the org associated with a session.
|
|
125
141
|
* @param {SessionStorage} storage The session
|