@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.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/package.json +2 -2
  3. package/dist/cjs/spec/env/beta.json +2 -1
  4. package/dist/cjs/spec/env/gamma.json +2 -1
  5. package/dist/cjs/spec/env/prod.json +2 -1
  6. package/dist/cjs/src/api.d.ts +53 -6
  7. package/dist/cjs/src/api.js +75 -22
  8. package/dist/cjs/src/client.d.ts +15 -2
  9. package/dist/cjs/src/client.js +5 -3
  10. package/dist/cjs/src/env.d.ts +1 -0
  11. package/dist/cjs/src/env.js +1 -1
  12. package/dist/cjs/src/error.d.ts +2 -0
  13. package/dist/cjs/src/error.js +7 -2
  14. package/dist/cjs/src/evm/index.d.ts +74 -0
  15. package/dist/cjs/src/evm/index.js +165 -0
  16. package/dist/cjs/src/index.d.ts +4 -0
  17. package/dist/cjs/src/index.js +5 -1
  18. package/dist/cjs/src/org.d.ts +20 -1
  19. package/dist/cjs/src/org.js +11 -1
  20. package/dist/cjs/src/org_event_processor.d.ts +57 -0
  21. package/dist/cjs/src/org_event_processor.js +137 -0
  22. package/dist/cjs/src/schema.d.ts +201 -23
  23. package/dist/cjs/src/schema.js +1 -1
  24. package/dist/cjs/src/schema_types.d.ts +6 -1
  25. package/dist/cjs/src/schema_types.js +1 -1
  26. package/dist/esm/package.json +2 -2
  27. package/dist/esm/spec/env/beta.json +2 -1
  28. package/dist/esm/spec/env/gamma.json +2 -1
  29. package/dist/esm/spec/env/prod.json +2 -1
  30. package/dist/esm/src/api.d.ts +53 -6
  31. package/dist/esm/src/api.js +76 -23
  32. package/dist/esm/src/client.d.ts +15 -2
  33. package/dist/esm/src/client.js +5 -3
  34. package/dist/esm/src/env.d.ts +1 -0
  35. package/dist/esm/src/env.js +1 -1
  36. package/dist/esm/src/error.d.ts +2 -0
  37. package/dist/esm/src/error.js +7 -2
  38. package/dist/esm/src/evm/index.d.ts +74 -0
  39. package/dist/esm/src/evm/index.js +161 -0
  40. package/dist/esm/src/index.d.ts +4 -0
  41. package/dist/esm/src/index.js +5 -1
  42. package/dist/esm/src/org.d.ts +20 -1
  43. package/dist/esm/src/org.js +12 -2
  44. package/dist/esm/src/org_event_processor.d.ts +57 -0
  45. package/dist/esm/src/org_event_processor.js +133 -0
  46. package/dist/esm/src/schema.d.ts +201 -23
  47. package/dist/esm/src/schema.js +1 -1
  48. package/dist/esm/src/schema_types.d.ts +6 -1
  49. package/dist/esm/src/schema_types.js +1 -1
  50. package/package.json +2 -2
  51. package/src/api.ts +106 -22
  52. package/src/client.ts +11 -3
  53. package/src/env.ts +1 -0
  54. package/src/error.ts +8 -1
  55. package/src/evm/index.ts +192 -0
  56. package/src/index.ts +4 -0
  57. package/src/org.ts +17 -1
  58. package/src/org_event_processor.ts +173 -0
  59. package/src/schema.ts +226 -22
  60. package/src/schema_types.ts +6 -1
  61. package/tsconfig.json +3 -3
package/README.md CHANGED
@@ -205,7 +205,7 @@ import { ethers } from "ethers";
205
205
 
206
206
  // Create new Signer
207
207
  const ethersSigner = new Signer(secpKey.materialId, session);
208
- assert((await ethersSigner.getAddress()) === secpKey.materialId);
208
+ assert((await ethersSigner.getAddress()) === ethers.getAddress(secpKey.materialId));
209
209
  // sign transaction as usual:
210
210
  console.log(
211
211
  "ethers.js signature:",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubist-labs/cubesigner-sdk",
3
- "version": "0.3.13",
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.5"
33
+ "@hpke/core": "^1.2.7"
34
34
  },
35
35
  "engines": {
36
36
  "node": ">=18.0.0"
@@ -4,6 +4,7 @@
4
4
  "LongLivedClientId": "6he1bnm17s0dv8bb4hjim6fs6i",
5
5
  "Region": "us-east-1",
6
6
  "UserPoolId": "us-east-1_79ljlRRfX",
7
- "SignerApiRoot": "https://beta.signer.cubist.dev"
7
+ "SignerApiRoot": "https://beta.signer.cubist.dev",
8
+ "OrgEventsTopicArn": "arn:aws:sns:us-east-1:819335423237:Beta-CubeSignerStack-OrgEventsTopic4416298A-beobtbku2Wa8"
8
9
  }
9
10
  }
@@ -4,6 +4,7 @@
4
4
  "LongLivedClientId": "4jiuai7mtl5164of3drmvej234",
5
5
  "Region": "us-east-1",
6
6
  "UserPoolId": "us-east-1_RU7HEslOW",
7
- "SignerApiRoot": "https://gamma.signer.cubist.dev"
7
+ "SignerApiRoot": "https://gamma.signer.cubist.dev",
8
+ "OrgEventsTopicArn": "arn:aws:sns:us-east-1:453904756570:Gamma-CubeSignerStack-OrgEventsTopic4416298A-MpV66OYPFQV0"
8
9
  }
9
10
  }
@@ -4,6 +4,7 @@
4
4
  "LongLivedClientId": "79qoe43lbiphd7jv0emqadtoia",
5
5
  "Region": "us-east-1",
6
6
  "UserPoolId": "us-east-1_lLLal8vGd",
7
- "SignerApiRoot": "https://prod.signer.cubist.dev"
7
+ "SignerApiRoot": "https://prod.signer.cubist.dev",
8
+ "OrgEventsTopicArn": "arn:aws:sns:us-east-1:120601948649:Production-0-us-east-1-CubeSignerStack-OrgEventsTopic4416298A-Zf6LzKIIDrvV"
8
9
  }
9
10
  }
@@ -1,7 +1,7 @@
1
1
  import createClient, { FetchOptions, FetchResponse, FilterKeys, HttpMethod, PathsWith } from "openapi-fetch";
2
2
  import { paths, operations } from "./schema";
3
3
  import { SignerSessionData, SignerSessionLifetime, SignerSessionManager } from "./session/signer_session_manager";
4
- import { CreateOidcUserOptions, IdentityProof, KeyInRoleInfo, KeyInfoApi, ListKeysResponse, ListKeyRolesResponse, ListRoleKeysResponse, ListRoleUsersResponse, ListRolesResponse, OidcIdentity, SessionsResponse, PublicKeyCredential, RoleInfo, UpdateKeyRequest, UpdateOrgRequest, UpdateOrgResponse, UpdateRoleRequest, UserIdInfo, UserInRoleInfo, UserInfo, SessionInfo, OrgInfo, RatchetConfig, Eip191SignRequest, Eip712SignRequest, Eip191Or712SignResponse, EvmSignRequest, EvmSignResponse, Eth2SignRequest, Eth2SignResponse, Eth2StakeRequest, Eth2StakeResponse, Eth2UnstakeRequest, Eth2UnstakeResponse, BlobSignRequest, BlobSignResponse, BtcSignResponse, BtcSignRequest, SolanaSignRequest, SolanaSignResponse, AvaSignResponse, AvaTx, MfaRequestInfo, MfaVote, MemberRole, UserExportCompleteResponse, UserExportInitResponse, UserExportListResponse, Empty } from "./schema_types";
4
+ import { CreateOidcUserOptions, IdentityProof, KeyInRoleInfo, KeyInfoApi, ListKeysResponse, ListKeyRolesResponse, ListRoleKeysResponse, ListRoleUsersResponse, ListRolesResponse, OidcIdentity, SessionsResponse, PublicKeyCredential, RoleInfo, UpdateKeyRequest, UpdateOrgRequest, UpdateOrgResponse, UpdateRoleRequest, UserInOrgInfo, UserInRoleInfo, UserInfo, SessionInfo, OrgInfo, RatchetConfig, Eip191SignRequest, Eip712SignRequest, Eip191Or712SignResponse, EvmSignRequest, EvmSignResponse, Eth2SignRequest, Eth2SignResponse, Eth2StakeRequest, Eth2StakeResponse, Eth2UnstakeRequest, Eth2UnstakeResponse, BlobSignRequest, BlobSignResponse, BtcSignResponse, BtcSignRequest, SolanaSignRequest, SolanaSignResponse, AvaSignResponse, AvaTx, MfaRequestInfo, MfaVote, MemberRole, UserExportCompleteResponse, UserExportInitResponse, UserExportListResponse, Empty } from "./schema_types";
5
5
  import { AddFidoChallenge, MfaFidoChallenge, MfaReceipt, TotpChallenge } from "./mfa";
6
6
  import { CubeSignerResponse } from "./response";
7
7
  import { Key, KeyType } from "./key";
@@ -9,6 +9,7 @@ import { PageOpts, Paginator } from "./paginator";
9
9
  import { KeyPolicy } from "./role";
10
10
  import { EnvInterface } from "./env";
11
11
  import { EventEmitter } from "./events";
12
+ import { UpdateKeyProperties } from "./index";
12
13
  /** @internal */
13
14
  export type Client = ReturnType<typeof createClient<paths>>;
14
15
  export { paths, operations };
@@ -38,6 +39,22 @@ export type FetchClient<Op extends keyof operations> = ReturnType<typeof createC
38
39
  * {@link FetchResponse<T>}) when that response is successful.
39
40
  */
40
41
  export type FetchResponseSuccessData<T> = Required<FetchResponse<T>>["data"];
42
+ /**
43
+ * Internal type for a function that returns a promise of a fetch response.
44
+ */
45
+ type ReqFn<T> = () => Promise<FetchResponse<T>>;
46
+ /**
47
+ * Retry settings.
48
+ *
49
+ * By default, {@link OpClient} retries on 5xx codes with delays of
50
+ * 100ms, 200ms, and 400ms between retries.
51
+ */
52
+ export interface RetrySettings {
53
+ /** HTTP status codes on which to retry */
54
+ codes: number[];
55
+ /** Delays in milliseconds between retries */
56
+ delaysMs: number[];
57
+ }
41
58
  /**
42
59
  * Wrapper around an open-fetch client restricted to a single operation.
43
60
  * The restriction applies only when type checking, the actual
@@ -50,8 +67,10 @@ export declare class OpClient<Op extends keyof operations> {
50
67
  * @param {Op} op The operation this client should be restricted to
51
68
  * @param {FetchClient<Op> | Client} client open-fetch client (either restricted to {@link Op} or not)
52
69
  * @param {EventEmitter} eventEmitter The client-local event dispatcher.
70
+ * @param {number[]} retrySettings Retry settings. By default, retries 3 times, sleeping 100ms
71
+ * after the first failed attempt, 200ms after the second, and finally 400ms after the third,
53
72
  */
54
- constructor(op: Op, client: FetchClient<Op> | Client, eventEmitter: EventEmitter);
73
+ constructor(op: Op, client: FetchClient<Op> | Client, eventEmitter: EventEmitter, retrySettings?: RetrySettings);
55
74
  /** The operation this client is restricted to */
56
75
  get op(): Op;
57
76
  /**
@@ -62,6 +81,29 @@ export declare class OpClient<Op extends keyof operations> {
62
81
  * @return {FetchResponseSuccessData<T>} The response data corresponding to response type {@link T}.
63
82
  */
64
83
  private assertOk;
84
+ /**
85
+ * @param {number[]} delaysMs Delays in milliseconds between retries.
86
+ * @return {OpClient<Op>} Returns the same client as this except with different retry delays.
87
+ */
88
+ withRetries(delaysMs: number[]): OpClient<Op>;
89
+ /**
90
+ * @param {RetrySettings} retrySettings New retry settings
91
+ * @return {OpClient<Op>} Returns the same client as this except with different retry settings.
92
+ */
93
+ withRetrySettings(retrySettings: RetrySettings): OpClient<Op>;
94
+ /**
95
+ * Internal.
96
+ *
97
+ * Executes a given request, potentially retrying on 5xx errors. The
98
+ * retry configuration can be set via the constructor.
99
+ * On all other errors, throws {@link ErrResponse} (as well as after exhausting all retries).
100
+ * On success, returns the response body.
101
+ *
102
+ * @param {ReqFn<T>} req The request to execute and then retry on 5xx errors
103
+ * @return {Promise<FetchResponseSuccessData<T>>}
104
+ * @internal
105
+ */
106
+ execute<T>(req: ReqFn<T>): Promise<FetchResponseSuccessData<T>>;
65
107
  /**
66
108
  * Invoke HTTP GET
67
109
  */
@@ -107,8 +149,10 @@ export declare class CubeSignerApi {
107
149
  * Constructor.
108
150
  * @param {SignerSessionManager} sessionMgr The session manager to use
109
151
  * @param {string?} orgId Optional organization ID; if omitted, uses the org ID from the session manager.
152
+ * @param {RetrySettings} retrySettings Retry settings. By default, retries 3 times, sleeping 100ms
153
+ * after the first failed attempt, 200ms after the second, and finally 400ms after the third,
110
154
  */
111
- constructor(sessionMgr: SignerSessionManager, orgId?: string);
155
+ constructor(sessionMgr: SignerSessionManager, orgId?: string, retrySettings?: RetrySettings);
112
156
  /**
113
157
  * Returns a new instance of this class using the same session manager but targeting a different organization.
114
158
  *
@@ -218,7 +262,7 @@ export declare class CubeSignerApi {
218
262
  * List users.
219
263
  * @return {User[]} Org users.
220
264
  */
221
- orgUsersList(): Promise<UserIdInfo[]>;
265
+ orgUsersList(): Promise<UserInOrgInfo[]>;
222
266
  /**
223
267
  * Create a new OIDC user. This can be a first-party "Member" or third-party "Alien".
224
268
  * @param {OidcIdentity} identity The identity of the OIDC user
@@ -268,9 +312,10 @@ export declare class CubeSignerApi {
268
312
  * @param {KeyType} keyType The type of key to create.
269
313
  * @param {number} count The number of keys to create.
270
314
  * @param {string?} ownerId The owner of the keys. Defaults to the session's user.
315
+ * @param {UpdateKeyProperties?} props Additional key properties
271
316
  * @return {KeyInfoApi[]} The new keys.
272
317
  */
273
- keysCreate(keyType: KeyType, count: number, ownerId?: string): Promise<KeyInfoApi[]>;
318
+ keysCreate(keyType: KeyType, count: number, ownerId?: string, props?: UpdateKeyProperties): Promise<KeyInfoApi[]>;
274
319
  /**
275
320
  * Derive a set of keys of a specified type using a supplied derivation path and an existing long-lived mnemonic.
276
321
  *
@@ -626,8 +671,10 @@ export declare class OidcClient {
626
671
  * @param {EnvInterface} env CubeSigner deployment
627
672
  * @param {string} orgId Target organization ID
628
673
  * @param {string} oidcToken User's OIDC token
674
+ * @param {RetrySettings} retrySettings Retry settings. By default, retries 3 times, sleeping 100ms
675
+ * after the first failed attempt, 200ms after the second, and finally 400ms after the third.
629
676
  */
630
- constructor(env: EnvInterface, orgId: string, oidcToken: string);
677
+ constructor(env: EnvInterface, orgId: string, oidcToken: string, retrySettings?: RetrySettings);
631
678
  /**
632
679
  * HTTP client restricted to a single operation.
633
680
  *