@polyester/sdk 0.22.3 → 0.23.1

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 (51) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/account-signer/types.d.ts +1 -1
  3. package/dist/account-signer/types.js.map +1 -1
  4. package/dist/environment.js +4 -4
  5. package/dist/environment.js.map +1 -1
  6. package/dist/gen/auth/v1/auth_pb.d.ts +88 -46
  7. package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
  8. package/dist/gen/auth/v1/auth_pb.js +43 -11
  9. package/dist/gen/auth/v1/auth_pb.js.map +1 -1
  10. package/dist/gen/auth/v1/subaccounts_pb.d.ts +5 -17
  11. package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
  12. package/dist/gen/auth/v1/subaccounts_pb.js +1 -1
  13. package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
  14. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +2 -2
  15. package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
  16. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +2 -1
  17. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts.map +1 -1
  18. package/dist/gen/marketoverview/v1/marketoverview_pb.js.map +1 -1
  19. package/dist/index.d.ts +3 -3
  20. package/dist/services/auth/account-signer-auth.d.ts +7 -3
  21. package/dist/services/auth/account-signer-auth.d.ts.map +1 -1
  22. package/dist/services/auth/account-signer-auth.js +28 -13
  23. package/dist/services/auth/account-signer-auth.js.map +1 -1
  24. package/dist/services/auth/auth.d.ts +19 -14
  25. package/dist/services/auth/auth.d.ts.map +1 -1
  26. package/dist/services/auth/auth.js +24 -14
  27. package/dist/services/auth/auth.js.map +1 -1
  28. package/dist/services/auth/auth.types.d.ts +2 -2
  29. package/dist/services/auth/wallet-challenge.schemas.js +20 -0
  30. package/dist/services/auth/wallet-challenge.schemas.js.map +1 -0
  31. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  32. package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
  33. package/dist/services/orders/orders-batch.schemas.d.ts +14 -14
  34. package/dist/services/orders/orders-input.schemas.d.ts +1 -1
  35. package/dist/services/orders/orders-output.schemas.d.ts +6 -6
  36. package/dist/services/subaccounts/subaccounts.d.ts +1 -1
  37. package/dist/services/subaccounts/subaccounts.js +1 -1
  38. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  39. package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -7
  40. package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
  41. package/dist/services/subaccounts/subaccounts.schemas.js +4 -5
  42. package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
  43. package/dist/services/trading-withdraws/index.d.ts +1 -1
  44. package/dist/services/trading-withdraws/trading-withdraws.d.ts +10 -72
  45. package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
  46. package/dist/services/trading-withdraws/trading-withdraws.js +8 -84
  47. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  48. package/dist/services/trading-withdraws/trading-withdraws.types.d.ts +2 -2
  49. package/dist/services/trading-withdraws/wallet-message.js +43 -0
  50. package/dist/services/trading-withdraws/wallet-message.js.map +1 -0
  51. package/package.json +2 -1
@@ -6,13 +6,20 @@ import "../../realtime/index.js";
6
6
  import { ProfileService } from "./profile/profile.js";
7
7
  import * as v from "valibot";
8
8
  //#region src/services/auth/auth.d.ts
9
+ declare const CreateWalletChallengeInputSchema: v.StrictObjectSchema<{
10
+ readonly smartAccountAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid wallet address.">]>;
11
+ readonly signerAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid wallet address.">]>;
12
+ readonly uri: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2048, undefined>, v.CheckAction<string, "Wallet challenge URI must be an HTTP(S) origin without a path, query, fragment, or user information.">]>;
13
+ readonly purpose: v.PicklistSchema<["login", "create_subaccount"], undefined>;
14
+ }, undefined>;
15
+ type CreateWalletChallengeInput = v.InferInput<typeof CreateWalletChallengeInputSchema>;
16
+ type WalletChallengePurpose = CreateWalletChallengeInput["purpose"];
9
17
  declare const LoginWithWalletInputSchema: v.StrictObjectSchema<{
10
- readonly smartAccountAddress: v.StringSchema<undefined>;
11
- readonly nonce: v.StringSchema<undefined>;
12
- readonly signature: v.StringSchema<undefined>;
18
+ readonly smartAccountAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid wallet address.">]>;
19
+ readonly message: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Wallet challenge message exceeds 4096 UTF-8 bytes.">]>;
20
+ readonly signature: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>;
13
21
  readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, "">;
14
22
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, "">;
15
- readonly primaryWalletAddress: v.OptionalSchema<v.StringSchema<undefined>, "">;
16
23
  readonly walletProvider: v.OptionalSchema<v.StringSchema<undefined>, "">;
17
24
  }, undefined>;
18
25
  type LoginWithWalletInput = v.InferInput<typeof LoginWithWalletInputSchema>;
@@ -54,8 +61,8 @@ declare const LoginWithWalletResponseSchema: v.ObjectSchema<{
54
61
  readonly username: v.StringSchema<undefined>;
55
62
  }, undefined>;
56
63
  type LoginWithWalletResponse = v.InferOutput<typeof LoginWithWalletResponseSchema>;
57
- declare const NonceSchema: v.ObjectSchema<{
58
- readonly nonce: v.StringSchema<undefined>;
64
+ declare const WalletChallengeSchema: v.ObjectSchema<{
65
+ readonly message: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Wallet challenge message exceeds 4096 UTF-8 bytes.">]>;
59
66
  readonly expiresAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
60
67
  readonly seconds: v.BigintSchema<undefined>;
61
68
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -64,7 +71,7 @@ declare const NonceSchema: v.ObjectSchema<{
64
71
  nanos: number;
65
72
  } | undefined, number | undefined>]>;
66
73
  }, undefined>;
67
- type Nonce = v.InferOutput<typeof NonceSchema>;
74
+ type WalletChallenge = v.InferOutput<typeof WalletChallengeSchema>;
68
75
  /**
69
76
  * Handles wallet-based authentication, caller introspection, and authenticated profile operations.
70
77
  */
@@ -84,17 +91,15 @@ declare class AuthService {
84
91
  */
85
92
  acceptTerms(options?: PolyesterMutationOptions): Promise<void>;
86
93
  /**
87
- * Requests a short-lived nonce for the given smart-account EVM address.
88
- * The nonce is single-purpose, replaced by subsequent requests, and expires
89
- * after about five minutes. The optional expiry is milliseconds since the
90
- * Unix epoch.
94
+ * Requests a server-issued SIWE message. Sign its exact UTF-8 bytes with
95
+ * personal_sign; do not hash or reconstruct it. Expiry is epoch milliseconds.
91
96
  */
92
- requestLoginNonce(smartAccountAddress: string, options?: PolyesterRequestOptions): Promise<Nonce>;
97
+ createWalletChallenge(input: CreateWalletChallengeInput, options?: PolyesterRequestOptions): Promise<WalletChallenge>;
93
98
  /**
94
- * Exchanges a signed login nonce for an authenticated session token and account identity returned by the auth API.
99
+ * Exchanges a signed SIWE message for an authenticated session token and account identity returned by the auth API.
95
100
  */
96
101
  protected loginWithWallet(input: LoginWithWalletInput, options?: PolyesterMutationOptions): Promise<LoginWithWalletResponse>;
97
102
  }
98
103
  //#endregion
99
- export { AuthService, LoginWithWalletInput, LoginWithWalletInputSchema, LoginWithWalletResponse, Me, Nonce };
104
+ export { AuthService, CreateWalletChallengeInput, CreateWalletChallengeInputSchema, LoginWithWalletInput, LoginWithWalletInputSchema, LoginWithWalletResponse, Me, WalletChallenge, WalletChallengePurpose };
100
105
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","names":[],"sources":["../../../src/services/auth/auth.ts"],"mappings":";;;;;;;;cAmBa,4BAA0B,EAAA;;;;;;;;;KAU3B,uBAAuB,EAAE,kBAAkB;cAEjD,UAAQ,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOF,KAAK,EAAE,mBAAmB;cAEhC,+BAA6B,EAAA;;;;;;;;;KAOvB,0BAA0B,EAAE,mBAAmB;cAErD,aAAW,EAAA;;;;;;;;;;KAKL,QAAQ,EAAE,mBAAmB;;;;cAK5B;;EAGT,SAAS;EAEG,YAAA,YAAY,4BAA4B,UAAU;;;;EASxD,GAAG,UAAU,0BAA0B,QAAQ;;;;;;;EAW/C,YAAY,UAAU,2BAA2B;;;;;;;EAUjD,kBACF,6BACA,UAAU,0BACX,QAAQ;;;;YAaK,gBACZ,OAAO,sBACP,UAAU,2BACX,QAAQ"}
1
+ {"version":3,"file":"auth.d.ts","names":[],"sources":["../../../src/services/auth/auth.ts"],"mappings":";;;;;;;;cA2Ba,kCAAgC,EAAA;;;;;;KAMjC,6BAA6B,EAAE,kBAAkB;KACjD,yBAAyB;cAExB,4BAA0B,EAAA;;;;;;;;KAS3B,uBAAuB,EAAE,kBAAkB;cAEjD,UAAQ,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOF,KAAK,EAAE,mBAAmB;cAEhC,+BAA6B,EAAA;;;;;;;;;KAOvB,0BAA0B,EAAE,mBAAmB;cAErD,uBAAqB,EAAA;;;;;;;;;;KAKf,kBAAkB,EAAE,mBAAmB;;;;cAKtC;;EAGT,SAAS;EAEG,YAAA,YAAY,4BAA4B,UAAU;;;;EASxD,GAAG,UAAU,0BAA0B,QAAQ;;;;;;;EAW/C,YAAY,UAAU,2BAA2B;;;;;EAQjD,sBACF,OAAO,4BACP,UAAU,0BACX,QAAQ;;;;YA4BK,gBACZ,OAAO,sBACP,UAAU,2BACX,QAAQ"}
@@ -1,19 +1,26 @@
1
+ import { ValidationError } from "../../shared/errors.js";
1
2
  import { AuthService as AuthService$1 } from "../../gen/auth/v1/auth_pb.js";
2
3
  import { OptionalTimestampMsSchema, PublicIdSchema, TimestampSchema } from "../../shared/schemas.js";
3
4
  import { parse } from "../../shared/validation.js";
4
5
  import { toConnectCallOptions } from "../../shared/request-options.js";
5
6
  import { ProfileService } from "./profile/profile.js";
6
7
  import { MfaSessionInfoSchema } from "../mfa/mfa.schemas.js";
8
+ import { WalletAddressSchema, WalletChallengeMessageSchema, WalletChallengeUriSchema, WalletSignatureSchema } from "./wallet-challenge.schemas.js";
7
9
  import { createClient } from "@connectrpc/connect";
8
10
  import * as v from "valibot";
9
11
  //#region src/services/auth/auth.ts
12
+ const CreateWalletChallengeInputSchema = v.strictObject({
13
+ smartAccountAddress: WalletAddressSchema,
14
+ signerAddress: WalletAddressSchema,
15
+ uri: WalletChallengeUriSchema,
16
+ purpose: v.picklist(["login", "create_subaccount"])
17
+ });
10
18
  const LoginWithWalletInputSchema = v.strictObject({
11
- smartAccountAddress: v.string(),
12
- nonce: v.string(),
13
- signature: v.string(),
19
+ smartAccountAddress: WalletAddressSchema,
20
+ message: WalletChallengeMessageSchema,
21
+ signature: WalletSignatureSchema,
14
22
  userAgent: v.optional(v.string(), ""),
15
23
  ip: v.optional(v.string(), ""),
16
- primaryWalletAddress: v.optional(v.string(), ""),
17
24
  walletProvider: v.optional(v.string(), "")
18
25
  });
19
26
  const MeSchema = v.object({
@@ -28,8 +35,8 @@ const LoginWithWalletResponseSchema = v.object({
28
35
  accountId: PublicIdSchema,
29
36
  username: v.string()
30
37
  });
31
- const NonceSchema = v.object({
32
- nonce: v.string(),
38
+ const WalletChallengeSchema = v.object({
39
+ message: WalletChallengeMessageSchema,
33
40
  expiresAt: OptionalTimestampMsSchema
34
41
  });
35
42
  /**
@@ -61,16 +68,19 @@ var AuthService = class {
61
68
  await this.#authClient.acceptTerms({}, toConnectCallOptions(options));
62
69
  }
63
70
  /**
64
- * Requests a short-lived nonce for the given smart-account EVM address.
65
- * The nonce is single-purpose, replaced by subsequent requests, and expires
66
- * after about five minutes. The optional expiry is milliseconds since the
67
- * Unix epoch.
71
+ * Requests a server-issued SIWE message. Sign its exact UTF-8 bytes with
72
+ * personal_sign; do not hash or reconstruct it. Expiry is epoch milliseconds.
68
73
  */
69
- async requestLoginNonce(smartAccountAddress, options) {
70
- return parse(NonceSchema, await this.#publicClient.getNonce({ smartAccountAddress }, toConnectCallOptions(options)));
74
+ async createWalletChallenge(input, options) {
75
+ const validated = parse(CreateWalletChallengeInputSchema, input);
76
+ if (validated.purpose === "create_subaccount" && validated.signerAddress.toLowerCase() !== validated.smartAccountAddress.toLowerCase()) throw new ValidationError("Subaccount challenge signer must equal the smart account address.");
77
+ return parse(WalletChallengeSchema, await this.#publicClient.createWalletChallenge({
78
+ ...validated,
79
+ purpose: validated.purpose === "login" ? 1 : 2
80
+ }, toConnectCallOptions(options)));
71
81
  }
72
82
  /**
73
- * Exchanges a signed login nonce for an authenticated session token and account identity returned by the auth API.
83
+ * Exchanges a signed SIWE message for an authenticated session token and account identity returned by the auth API.
74
84
  */
75
85
  async loginWithWallet(input, options) {
76
86
  const validatedInput = parse(LoginWithWalletInputSchema, input);
@@ -79,6 +89,6 @@ var AuthService = class {
79
89
  }
80
90
  };
81
91
  //#endregion
82
- export { AuthService, LoginWithWalletInputSchema };
92
+ export { AuthService, CreateWalletChallengeInputSchema, LoginWithWalletInputSchema };
83
93
 
84
94
  //# sourceMappingURL=auth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","names":["#publicClient","Proto.AuthService","#authClient"],"sources":["../../../src/services/auth/auth.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/auth_pb.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { ProfileService } from \"./profile/profile.js\";\nimport {\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampSchema,\n} from \"../../shared/schemas.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { MfaSessionInfoSchema } from \"../mfa/mfa.schemas.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\n\nexport const LoginWithWalletInputSchema = v.strictObject({\n smartAccountAddress: v.string(),\n nonce: v.string(),\n signature: v.string(),\n userAgent: v.optional(v.string(), \"\"),\n ip: v.optional(v.string(), \"\"),\n primaryWalletAddress: v.optional(v.string(), \"\"),\n walletProvider: v.optional(v.string(), \"\"),\n});\n\nexport type LoginWithWalletInput = v.InferInput<typeof LoginWithWalletInputSchema>;\n\nconst MeSchema = v.object({\n accountId: PublicIdSchema,\n apiKeyId: v.optional(v.string()),\n username: v.string(),\n session: v.optional(MfaSessionInfoSchema),\n});\n\nexport type Me = v.InferOutput<typeof MeSchema>;\n\nconst LoginWithWalletResponseSchema = v.object({\n accessToken: v.string(),\n expiresAt: v.optional(TimestampSchema),\n accountId: PublicIdSchema,\n username: v.string(),\n});\n\nexport type LoginWithWalletResponse = v.InferOutput<typeof LoginWithWalletResponseSchema>;\n\nconst NonceSchema = v.object({\n nonce: v.string(),\n expiresAt: OptionalTimestampMsSchema,\n});\n\nexport type Nonce = v.InferOutput<typeof NonceSchema>;\n\n/**\n * Handles wallet-based authentication, caller introspection, and authenticated profile operations.\n */\nexport class AuthService {\n #publicClient: Client<typeof Proto.AuthService>;\n #authClient: Client<typeof Proto.AuthService>;\n profile: ProfileService;\n\n constructor(transports: AuthAndPublicApiTransports, realtime: PolyesterRealtime) {\n this.#publicClient = createClient(Proto.AuthService, transports.publicApi);\n this.#authClient = createClient(Proto.AuthService, transports.authApi);\n this.profile = new ProfileService(transports, realtime);\n }\n\n /**\n * Returns the authenticated caller's account context, including account ID, optional API key ID, username, and session assurance details from the presented token or API key.\n */\n async me(options?: PolyesterRequestOptions): Promise<Me> {\n const res = await this.#authClient.me({}, toConnectCallOptions(options));\n return parse(MeSchema, res);\n }\n\n /**\n * Records explicit consent to the current terms for the caller's root account.\n * Call only after the user consents. Requires an interactive JWT session;\n * API keys are not allowed. Repeated acceptance succeeds without changing\n * the first acceptance time. No MFA is required.\n */\n async acceptTerms(options?: PolyesterMutationOptions): Promise<void> {\n await this.#authClient.acceptTerms({}, toConnectCallOptions(options));\n }\n\n /**\n * Requests a short-lived nonce for the given smart-account EVM address.\n * The nonce is single-purpose, replaced by subsequent requests, and expires\n * after about five minutes. The optional expiry is milliseconds since the\n * Unix epoch.\n */\n async requestLoginNonce(\n smartAccountAddress: string,\n options?: PolyesterRequestOptions,\n ): Promise<Nonce> {\n return parse(\n NonceSchema,\n await this.#publicClient.getNonce(\n { smartAccountAddress },\n toConnectCallOptions(options),\n ),\n );\n }\n\n /**\n * Exchanges a signed login nonce for an authenticated session token and account identity returned by the auth API.\n */\n protected async loginWithWallet(\n input: LoginWithWalletInput,\n options?: PolyesterMutationOptions,\n ): Promise<LoginWithWalletResponse> {\n const validatedInput = parse(LoginWithWalletInputSchema, input);\n const res = await this.#publicClient.loginWithWallet(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(LoginWithWalletResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;AAmBA,MAAa,6BAA6B,EAAE,aAAa;CACrD,qBAAqB,EAAE,OAAO;CAC9B,OAAO,EAAE,OAAO;CAChB,WAAW,EAAE,OAAO;CACpB,WAAW,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACpC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CAC7B,sBAAsB,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CAC/C,gBAAgB,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AAC7C,CAAC;AAID,MAAM,WAAW,EAAE,OAAO;CACtB,WAAW;CACX,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAC/B,UAAU,EAAE,OAAO;CACnB,SAAS,EAAE,SAAS,oBAAoB;AAC5C,CAAC;AAID,MAAM,gCAAgC,EAAE,OAAO;CAC3C,aAAa,EAAE,OAAO;CACtB,WAAW,EAAE,SAAS,eAAe;CACrC,WAAW;CACX,UAAU,EAAE,OAAO;AACvB,CAAC;AAID,MAAM,cAAc,EAAE,OAAO;CACzB,OAAO,EAAE,OAAO;CAChB,WAAW;AACf,CAAC;;;;AAOD,IAAa,cAAb,MAAyB;CACrB;CACA;CACA;CAEA,YAAY,YAAwC,UAA6B;EAC7E,KAAKA,gBAAgB,aAAaC,eAAmB,WAAW,SAAS;EACzE,KAAKC,cAAc,aAAaD,eAAmB,WAAW,OAAO;EACrE,KAAK,UAAU,IAAI,eAAe,YAAY,QAAQ;CAC1D;;;;CAKA,MAAM,GAAG,SAAgD;EACrD,MAAM,MAAM,MAAM,KAAKC,YAAY,GAAG,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACvE,OAAO,MAAM,UAAU,GAAG;CAC9B;;;;;;;CAQA,MAAM,YAAY,SAAmD;EACjE,MAAM,KAAKA,YAAY,YAAY,CAAC,GAAG,qBAAqB,OAAO,CAAC;CACxE;;;;;;;CAQA,MAAM,kBACF,qBACA,SACc;EACd,OAAO,MACH,aACA,MAAM,KAAKF,cAAc,SACrB,EAAE,oBAAoB,GACtB,qBAAqB,OAAO,CAChC,CACJ;CACJ;;;;CAKA,MAAgB,gBACZ,OACA,SACgC;EAChC,MAAM,iBAAiB,MAAM,4BAA4B,KAAK;EAC9D,MAAM,MAAM,MAAM,KAAKA,cAAc,gBACjC,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
1
+ {"version":3,"file":"auth.js","names":["#publicClient","Proto.AuthService","#authClient"],"sources":["../../../src/services/auth/auth.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/auth_pb.js\";\nimport * as v from \"valibot\";\nimport { ValidationError } from \"../../shared/errors.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { ProfileService } from \"./profile/profile.js\";\nimport {\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampSchema,\n} from \"../../shared/schemas.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { MfaSessionInfoSchema } from \"../mfa/mfa.schemas.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\n\nimport {\n WalletAddressSchema,\n WalletChallengeUriSchema,\n WalletChallengeMessageSchema,\n WalletSignatureSchema,\n} from \"./wallet-challenge.schemas.js\";\n\nexport const CreateWalletChallengeInputSchema = v.strictObject({\n smartAccountAddress: WalletAddressSchema,\n signerAddress: WalletAddressSchema,\n uri: WalletChallengeUriSchema,\n purpose: v.picklist([\"login\", \"create_subaccount\"]),\n});\nexport type CreateWalletChallengeInput = v.InferInput<typeof CreateWalletChallengeInputSchema>;\nexport type WalletChallengePurpose = CreateWalletChallengeInput[\"purpose\"];\n\nexport const LoginWithWalletInputSchema = v.strictObject({\n smartAccountAddress: WalletAddressSchema,\n message: WalletChallengeMessageSchema,\n signature: WalletSignatureSchema,\n userAgent: v.optional(v.string(), \"\"),\n ip: v.optional(v.string(), \"\"),\n walletProvider: v.optional(v.string(), \"\"),\n});\n\nexport type LoginWithWalletInput = v.InferInput<typeof LoginWithWalletInputSchema>;\n\nconst MeSchema = v.object({\n accountId: PublicIdSchema,\n apiKeyId: v.optional(v.string()),\n username: v.string(),\n session: v.optional(MfaSessionInfoSchema),\n});\n\nexport type Me = v.InferOutput<typeof MeSchema>;\n\nconst LoginWithWalletResponseSchema = v.object({\n accessToken: v.string(),\n expiresAt: v.optional(TimestampSchema),\n accountId: PublicIdSchema,\n username: v.string(),\n});\n\nexport type LoginWithWalletResponse = v.InferOutput<typeof LoginWithWalletResponseSchema>;\n\nconst WalletChallengeSchema = v.object({\n message: WalletChallengeMessageSchema,\n expiresAt: OptionalTimestampMsSchema,\n});\n\nexport type WalletChallenge = v.InferOutput<typeof WalletChallengeSchema>;\n\n/**\n * Handles wallet-based authentication, caller introspection, and authenticated profile operations.\n */\nexport class AuthService {\n #publicClient: Client<typeof Proto.AuthService>;\n #authClient: Client<typeof Proto.AuthService>;\n profile: ProfileService;\n\n constructor(transports: AuthAndPublicApiTransports, realtime: PolyesterRealtime) {\n this.#publicClient = createClient(Proto.AuthService, transports.publicApi);\n this.#authClient = createClient(Proto.AuthService, transports.authApi);\n this.profile = new ProfileService(transports, realtime);\n }\n\n /**\n * Returns the authenticated caller's account context, including account ID, optional API key ID, username, and session assurance details from the presented token or API key.\n */\n async me(options?: PolyesterRequestOptions): Promise<Me> {\n const res = await this.#authClient.me({}, toConnectCallOptions(options));\n return parse(MeSchema, res);\n }\n\n /**\n * Records explicit consent to the current terms for the caller's root account.\n * Call only after the user consents. Requires an interactive JWT session;\n * API keys are not allowed. Repeated acceptance succeeds without changing\n * the first acceptance time. No MFA is required.\n */\n async acceptTerms(options?: PolyesterMutationOptions): Promise<void> {\n await this.#authClient.acceptTerms({}, toConnectCallOptions(options));\n }\n\n /**\n * Requests a server-issued SIWE message. Sign its exact UTF-8 bytes with\n * personal_sign; do not hash or reconstruct it. Expiry is epoch milliseconds.\n */\n async createWalletChallenge(\n input: CreateWalletChallengeInput,\n options?: PolyesterRequestOptions,\n ): Promise<WalletChallenge> {\n const validated = parse(CreateWalletChallengeInputSchema, input);\n if (\n validated.purpose === \"create_subaccount\" &&\n validated.signerAddress.toLowerCase() !== validated.smartAccountAddress.toLowerCase()\n ) {\n throw new ValidationError(\n \"Subaccount challenge signer must equal the smart account address.\",\n );\n }\n return parse(\n WalletChallengeSchema,\n await this.#publicClient.createWalletChallenge(\n {\n ...validated,\n purpose:\n validated.purpose === \"login\"\n ? Proto.WalletChallengePurpose.LOGIN\n : Proto.WalletChallengePurpose.CREATE_SUBACCOUNT,\n },\n toConnectCallOptions(options),\n ),\n );\n }\n\n /**\n * Exchanges a signed SIWE message for an authenticated session token and account identity returned by the auth API.\n */\n protected async loginWithWallet(\n input: LoginWithWalletInput,\n options?: PolyesterMutationOptions,\n ): Promise<LoginWithWalletResponse> {\n const validatedInput = parse(LoginWithWalletInputSchema, input);\n const res = await this.#publicClient.loginWithWallet(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(LoginWithWalletResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;;;AA2BA,MAAa,mCAAmC,EAAE,aAAa;CAC3D,qBAAqB;CACrB,eAAe;CACf,KAAK;CACL,SAAS,EAAE,SAAS,CAAC,SAAS,mBAAmB,CAAC;AACtD,CAAC;AAID,MAAa,6BAA6B,EAAE,aAAa;CACrD,qBAAqB;CACrB,SAAS;CACT,WAAW;CACX,WAAW,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACpC,IAAI,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CAC7B,gBAAgB,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;AAC7C,CAAC;AAID,MAAM,WAAW,EAAE,OAAO;CACtB,WAAW;CACX,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CAC/B,UAAU,EAAE,OAAO;CACnB,SAAS,EAAE,SAAS,oBAAoB;AAC5C,CAAC;AAID,MAAM,gCAAgC,EAAE,OAAO;CAC3C,aAAa,EAAE,OAAO;CACtB,WAAW,EAAE,SAAS,eAAe;CACrC,WAAW;CACX,UAAU,EAAE,OAAO;AACvB,CAAC;AAID,MAAM,wBAAwB,EAAE,OAAO;CACnC,SAAS;CACT,WAAW;AACf,CAAC;;;;AAOD,IAAa,cAAb,MAAyB;CACrB;CACA;CACA;CAEA,YAAY,YAAwC,UAA6B;EAC7E,KAAKA,gBAAgB,aAAaC,eAAmB,WAAW,SAAS;EACzE,KAAKC,cAAc,aAAaD,eAAmB,WAAW,OAAO;EACrE,KAAK,UAAU,IAAI,eAAe,YAAY,QAAQ;CAC1D;;;;CAKA,MAAM,GAAG,SAAgD;EACrD,MAAM,MAAM,MAAM,KAAKC,YAAY,GAAG,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACvE,OAAO,MAAM,UAAU,GAAG;CAC9B;;;;;;;CAQA,MAAM,YAAY,SAAmD;EACjE,MAAM,KAAKA,YAAY,YAAY,CAAC,GAAG,qBAAqB,OAAO,CAAC;CACxE;;;;;CAMA,MAAM,sBACF,OACA,SACwB;EACxB,MAAM,YAAY,MAAM,kCAAkC,KAAK;EAC/D,IACI,UAAU,YAAY,uBACtB,UAAU,cAAc,YAAY,MAAM,UAAU,oBAAoB,YAAY,GAEpF,MAAM,IAAI,gBACN,mEACJ;EAEJ,OAAO,MACH,uBACA,MAAM,KAAKF,cAAc,sBACrB;GACI,GAAG;GACH,SACI,UAAU,YAAY,UAAA,IAAA;EAG9B,GACA,qBAAqB,OAAO,CAChC,CACJ;CACJ;;;;CAKA,MAAgB,gBACZ,OACA,SACgC;EAChC,MAAM,iBAAiB,MAAM,4BAA4B,KAAK;EAC9D,MAAM,MAAM,MAAM,KAAKA,cAAc,gBACjC,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
@@ -1,3 +1,3 @@
1
- import { LoginWithWalletInput, LoginWithWalletResponse, Me, Nonce } from "./auth.js";
1
+ import { CreateWalletChallengeInput, LoginWithWalletInput, LoginWithWalletResponse, Me, WalletChallenge, WalletChallengePurpose } from "./auth.js";
2
2
  import { AccountSignerAuthEvents, CreateSubaccountParams, CreateSubaccountResult, LoginOptions, LoginResult } from "./account-signer-auth.js";
3
- export type { AccountSignerAuthEvents, CreateSubaccountResult as AccountSignerCreateSubaccountResult, CreateSubaccountParams, LoginOptions, LoginResult, LoginWithWalletInput, LoginWithWalletResponse, Me, Nonce };
3
+ export type { AccountSignerAuthEvents, CreateSubaccountResult as AccountSignerCreateSubaccountResult, CreateSubaccountParams, CreateWalletChallengeInput, LoginOptions, LoginResult, LoginWithWalletInput, LoginWithWalletResponse, Me, WalletChallenge, WalletChallengePurpose };
@@ -0,0 +1,20 @@
1
+ import { isEvmAddress } from "../../utils/evm.js";
2
+ import * as v from "valibot";
3
+ //#region src/services/auth/wallet-challenge.schemas.ts
4
+ const WalletAddressSchema = v.pipe(v.string(), v.check(isEvmAddress, "Invalid wallet address."));
5
+ const WalletChallengeUriSchema = v.pipe(v.string(), v.maxLength(2048), v.check((value) => {
6
+ if (!/^https?:\/\/[^/?#\s\\]+$/.test(value)) return false;
7
+ try {
8
+ const url = new URL(value);
9
+ return !url.username && !url.password;
10
+ } catch {
11
+ return false;
12
+ }
13
+ }, "Wallet challenge URI must be an HTTP(S) origin without a path, query, fragment, or user information."));
14
+ /** Preserve the server-issued UTF-8 message exactly as signed. */
15
+ const WalletChallengeMessageSchema = v.pipe(v.string(), v.minLength(1), v.check((value) => new TextEncoder().encode(value).length <= 4096, "Wallet challenge message exceeds 4096 UTF-8 bytes."));
16
+ const WalletSignatureSchema = v.pipe(v.string(), v.minLength(1), v.maxLength(8192));
17
+ //#endregion
18
+ export { WalletAddressSchema, WalletChallengeMessageSchema, WalletChallengeUriSchema, WalletSignatureSchema };
19
+
20
+ //# sourceMappingURL=wallet-challenge.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-challenge.schemas.js","names":[],"sources":["../../../src/services/auth/wallet-challenge.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { isEvmAddress } from \"../../utils/evm.js\";\n\nexport const WalletAddressSchema = v.pipe(\n v.string(),\n v.check(isEvmAddress, \"Invalid wallet address.\"),\n);\n\nexport const WalletChallengeUriSchema = v.pipe(\n v.string(),\n v.maxLength(2048),\n v.check((value) => {\n if (!/^https?:\\/\\/[^/?#\\s\\\\]+$/.test(value)) return false;\n try {\n const url = new URL(value);\n return !url.username && !url.password;\n } catch {\n return false;\n }\n }, \"Wallet challenge URI must be an HTTP(S) origin without a path, query, fragment, or user information.\"),\n);\n\n/** Preserve the server-issued UTF-8 message exactly as signed. */\nexport const WalletChallengeMessageSchema = v.pipe(\n v.string(),\n v.minLength(1),\n v.check(\n (value) => new TextEncoder().encode(value).length <= 4096,\n \"Wallet challenge message exceeds 4096 UTF-8 bytes.\",\n ),\n);\n\nexport const WalletSignatureSchema = v.pipe(v.string(), v.minLength(1), v.maxLength(8192));\n"],"mappings":";;;AAGA,MAAa,sBAAsB,EAAE,KACjC,EAAE,OAAO,GACT,EAAE,MAAM,cAAc,yBAAyB,CACnD;AAEA,MAAa,2BAA2B,EAAE,KACtC,EAAE,OAAO,GACT,EAAE,UAAU,IAAI,GAChB,EAAE,OAAO,UAAU;CACf,IAAI,CAAC,2BAA2B,KAAK,KAAK,GAAG,OAAO;CACpD,IAAI;EACA,MAAM,MAAM,IAAI,IAAI,KAAK;EACzB,OAAO,CAAC,IAAI,YAAY,CAAC,IAAI;CACjC,QAAQ;EACJ,OAAO;CACX;AACJ,GAAG,sGAAsG,CAC7G;;AAGA,MAAa,+BAA+B,EAAE,KAC1C,EAAE,OAAO,GACT,EAAE,UAAU,CAAC,GACb,EAAE,OACG,UAAU,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,UAAU,MACrD,oDACJ,CACJ;AAEA,MAAa,wBAAwB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,IAAI,CAAC"}
@@ -14,7 +14,7 @@ type TimestampInit = {
14
14
  declare const GetOrderbookHeatmapInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
15
15
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
16
16
  readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"1s" | "1m" | "5m" | "1h", HeatmapInterval>]>;
17
- readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 100 | 50, HeatmapDepth>]>;
17
+ readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100, HeatmapDepth>]>;
18
18
  readonly quantityMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["close", "peak"], undefined>, "close">, v.TransformAction<"close" | "peak", HeatmapQuantityMode>]>;
19
19
  readonly limit: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 20000, undefined>]>;
20
20
  readonly startTsSec: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>, v.TransformAction<number, bigint>]>, undefined>;
@@ -227,7 +227,7 @@ type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;
227
227
  declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.ObjectSchema<{
228
228
  readonly symbolId: v.NumberSchema<undefined>;
229
229
  readonly interval: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, DecodedEnum<"1s" | "1m" | "5m" | "1h">>]>;
230
- readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 100 | 50>]>;
230
+ readonly depth: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100>]>;
231
231
  readonly chain: v.OptionalSchema<v.ObjectSchema<{
232
232
  readonly baseKeyframe: v.OptionalSchema<v.ObjectSchema<{
233
233
  readonly tsSec: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, number>]>;
@@ -287,7 +287,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
287
287
  }, undefined>, v.TransformAction<{
288
288
  symbolId: number;
289
289
  interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
290
- depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 100 | 50;
290
+ depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
291
291
  chain?: {
292
292
  baseKeyframe?: {
293
293
  tsSec: number;
@@ -347,7 +347,7 @@ declare function createOrderbookHeatmapResponseSchema(scales: SdkScales): v.Sche
347
347
  }, {
348
348
  symbolId: number;
349
349
  interval: DecodedEnum<"1s" | "1m" | "5m" | "1h">;
350
- depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 100 | 50;
350
+ depth: 5 | 10 | 20 | 1 | "unspecified" | 200 | 1000 | 500 | 50 | 100;
351
351
  chain: {
352
352
  baseKeyframe: {
353
353
  tsSec: number;
@@ -10,7 +10,7 @@ declare const GetOrderbookInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema
10
10
  depth: number;
11
11
  }, {
12
12
  symbolId: number;
13
- depth: 5 | 10 | 20 | 1 | 200 | 1000 | 500 | 100 | 50;
13
+ depth: 5 | 10 | 20 | 1 | 200 | 1000 | 500 | 50 | 100;
14
14
  protoDepth: Depth;
15
15
  }>]>;
16
16
  type GetOrderbookInput = v.InferInput<typeof GetOrderbookInputSchema>;
@@ -3140,18 +3140,18 @@ declare const GetBatchReplaceStatusResultSchema: v.SchemaWithPipe<readonly [v.Ob
3140
3140
  readonly admissionStatus: v.SchemaWithPipe<readonly [v.EnumSchema<typeof BatchReplaceAdmissionStatus, undefined>, v.TransformAction<BatchReplaceAdmissionStatus, "unspecified" | "rejected" | "admitted" | "partially_admitted">]>;
3141
3141
  readonly items: v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
3142
3142
  readonly itemIndex: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
3143
- readonly phase: v.SchemaWithPipe<readonly [v.EnumSchema<typeof BatchReplacePhase, undefined>, v.TransformAction<BatchReplacePhase, "unspecified" | "terminal" | "working" | "rejected" | "admitted">]>;
3143
+ readonly phase: v.SchemaWithPipe<readonly [v.EnumSchema<typeof BatchReplacePhase, undefined>, v.TransformAction<BatchReplacePhase, "unspecified" | "terminal" | "rejected" | "admitted" | "working">]>;
3144
3144
  readonly oldOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
3145
3145
  readonly replacementOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
3146
- readonly orderStatus: v.SchemaWithPipe<readonly [v.EnumSchema<typeof OrderStatus, undefined>, v.TransformAction<OrderStatus, "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected">]>;
3146
+ readonly orderStatus: v.SchemaWithPipe<readonly [v.EnumSchema<typeof OrderStatus, undefined>, v.TransformAction<OrderStatus, "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled">]>;
3147
3147
  readonly code: v.StringSchema<undefined>;
3148
3148
  readonly updatedTsNs: v.BigintSchema<undefined>;
3149
3149
  }, undefined>, v.TransformAction<{
3150
3150
  itemIndex: number;
3151
- phase: "unspecified" | "terminal" | "working" | "rejected" | "admitted";
3151
+ phase: "unspecified" | "terminal" | "rejected" | "admitted" | "working";
3152
3152
  oldOrderId?: string | undefined;
3153
3153
  replacementOrderId?: string | undefined;
3154
- orderStatus: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
3154
+ orderStatus: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
3155
3155
  code: string;
3156
3156
  updatedTsNs: bigint;
3157
3157
  }, {
@@ -3159,10 +3159,10 @@ declare const GetBatchReplaceStatusResultSchema: v.SchemaWithPipe<readonly [v.Ob
3159
3159
  updatedTs: number;
3160
3160
  updatedTsNs: string;
3161
3161
  itemIndex: number;
3162
- phase: "unspecified" | "terminal" | "working" | "rejected" | "admitted";
3162
+ phase: "unspecified" | "terminal" | "rejected" | "admitted" | "working";
3163
3163
  oldOrderId?: string | undefined;
3164
3164
  replacementOrderId?: string | undefined;
3165
- orderStatus: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
3165
+ orderStatus: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
3166
3166
  }>]>, undefined>;
3167
3167
  readonly acceptedCount: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
3168
3168
  readonly rejectedCount: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -3176,10 +3176,10 @@ declare const GetBatchReplaceStatusResultSchema: v.SchemaWithPipe<readonly [v.Ob
3176
3176
  updatedTs: number;
3177
3177
  updatedTsNs: string;
3178
3178
  itemIndex: number;
3179
- phase: "unspecified" | "terminal" | "working" | "rejected" | "admitted";
3179
+ phase: "unspecified" | "terminal" | "rejected" | "admitted" | "working";
3180
3180
  oldOrderId?: string | undefined;
3181
3181
  replacementOrderId?: string | undefined;
3182
- orderStatus: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
3182
+ orderStatus: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
3183
3183
  }[];
3184
3184
  acceptedCount: number;
3185
3185
  rejectedCount: number;
@@ -3193,10 +3193,10 @@ declare const GetBatchReplaceStatusResultSchema: v.SchemaWithPipe<readonly [v.Ob
3193
3193
  updatedTs: number;
3194
3194
  updatedTsNs: string;
3195
3195
  itemIndex: number;
3196
- phase: "unspecified" | "terminal" | "working" | "rejected" | "admitted";
3196
+ phase: "unspecified" | "terminal" | "rejected" | "admitted" | "working";
3197
3197
  oldOrderId?: string | undefined;
3198
3198
  replacementOrderId?: string | undefined;
3199
- orderStatus: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
3199
+ orderStatus: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
3200
3200
  }[];
3201
3201
  acceptedCount: number;
3202
3202
  rejectedCount: number;
@@ -3210,10 +3210,10 @@ declare const GetBatchReplaceStatusResultSchema: v.SchemaWithPipe<readonly [v.Ob
3210
3210
  updatedTs: number;
3211
3211
  updatedTsNs: string;
3212
3212
  itemIndex: number;
3213
- phase: "unspecified" | "terminal" | "working" | "rejected" | "admitted";
3213
+ phase: "unspecified" | "terminal" | "rejected" | "admitted" | "working";
3214
3214
  oldOrderId?: string | undefined;
3215
3215
  replacementOrderId?: string | undefined;
3216
- orderStatus: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
3216
+ orderStatus: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
3217
3217
  }[];
3218
3218
  acceptedCount: number;
3219
3219
  rejectedCount: number;
@@ -3231,10 +3231,10 @@ declare const GetBatchReplaceStatusResultSchema: v.SchemaWithPipe<readonly [v.Ob
3231
3231
  updatedTs: number;
3232
3232
  updatedTsNs: string;
3233
3233
  itemIndex: number;
3234
- phase: "unspecified" | "terminal" | "working" | "rejected" | "admitted";
3234
+ phase: "unspecified" | "terminal" | "rejected" | "admitted" | "working";
3235
3235
  oldOrderId?: string | undefined;
3236
3236
  replacementOrderId?: string | undefined;
3237
- orderStatus: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
3237
+ orderStatus: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
3238
3238
  }[];
3239
3239
  acceptedCount: number;
3240
3240
  rejectedCount: number;
@@ -40,7 +40,7 @@ type OpenOrdersInput = v.InferInput<typeof OpenOrdersInputSchema>;
40
40
  declare const OrderHistoryInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
41
41
  readonly includeAttachedRisk: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
42
42
  readonly includeAttachedRiskState: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
43
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"FILLED" | "CANCELED" | "REJECTED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
43
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["FILLED", "CANCELED", "REJECTED"], undefined>, undefined>, v.TransformAction<"CANCELED" | "FILLED" | "REJECTED" | undefined, OrderStatus.FILLED | OrderStatus.CANCELED | OrderStatus.REJECTED | undefined>]>;
44
44
  readonly startTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
45
45
  readonly endTsNs: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
46
46
  readonly symbolId: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, undefined>;
@@ -9,7 +9,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
9
9
  readonly symbolId: v.NumberSchema<undefined>;
10
10
  readonly clientOrderId: v.StringSchema<undefined>;
11
11
  readonly side: v.EnumSchema<typeof Side, undefined>;
12
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof OrderStatus, undefined>, v.TransformAction<OrderStatus, "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected">]>;
12
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof OrderStatus, undefined>, v.TransformAction<OrderStatus, "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled">]>;
13
13
  readonly orderType: v.NumberSchema<undefined>;
14
14
  readonly timeInForce: v.NumberSchema<undefined>;
15
15
  readonly selfTradePreventionMode: v.NumberSchema<undefined>;
@@ -111,7 +111,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
111
111
  symbolId: number;
112
112
  clientOrderId: string;
113
113
  side: Side;
114
- status: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
114
+ status: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
115
115
  orderType: number;
116
116
  timeInForce: number;
117
117
  selfTradePreventionMode: number;
@@ -224,7 +224,7 @@ declare function createOrderSchema(scales: SdkScales): v.SchemaWithPipe<readonly
224
224
  orderId: string;
225
225
  symbolId: number;
226
226
  clientOrderId: string;
227
- status: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected" | "partial";
227
+ status: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled" | "partial";
228
228
  side: "unspecified" | "buy" | "sell";
229
229
  orderType: "unspecified" | "limit" | "market";
230
230
  timeInForce: "unspecified" | "GTC" | "IOC" | "FOK";
@@ -352,7 +352,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
352
352
  readonly symbolId: v.NumberSchema<undefined>;
353
353
  readonly clientOrderId: v.StringSchema<undefined>;
354
354
  readonly side: v.EnumSchema<typeof Side, undefined>;
355
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof OrderStatus, undefined>, v.TransformAction<OrderStatus, "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected">]>;
355
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof OrderStatus, undefined>, v.TransformAction<OrderStatus, "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled">]>;
356
356
  readonly orderType: v.NumberSchema<undefined>;
357
357
  readonly timeInForce: v.NumberSchema<undefined>;
358
358
  readonly selfTradePreventionMode: v.NumberSchema<undefined>;
@@ -454,7 +454,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
454
454
  symbolId: number;
455
455
  clientOrderId: string;
456
456
  side: Side;
457
- status: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected";
457
+ status: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled";
458
458
  orderType: number;
459
459
  timeInForce: number;
460
460
  selfTradePreventionMode: number;
@@ -567,7 +567,7 @@ declare function createOrderDetailsSchema(scales: SdkScales): v.ObjectSchema<{
567
567
  orderId: string;
568
568
  symbolId: number;
569
569
  clientOrderId: string;
570
- status: "unspecified" | "pending" | "canceled" | "pending_cancel" | "working" | "filled" | "rejected" | "partial";
570
+ status: "unspecified" | "pending" | "canceled" | "rejected" | "working" | "pending_cancel" | "filled" | "partial";
571
571
  side: "unspecified" | "buy" | "sell";
572
572
  orderType: "unspecified" | "limit" | "market";
573
573
  timeInForce: "unspecified" | "GTC" | "IOC" | "FOK";
@@ -42,7 +42,7 @@ declare class SubaccountsService {
42
42
  invites: SubaccountInvite[];
43
43
  }>;
44
44
  /**
45
- * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.
45
+ * Creates a new subaccount under the caller's root account using a smart-account address, server-issued SIWE message, and signature proof.
46
46
  */
47
47
  create(input: v.InferInput<typeof CreateSubaccountInputSchema>, options?: PolyesterMutationOptions): Promise<CreateSubaccountResult>;
48
48
  /**
@@ -63,7 +63,7 @@ var SubaccountsService = class {
63
63
  };
64
64
  }
65
65
  /**
66
- * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.
66
+ * Creates a new subaccount under the caller's root account using a smart-account address, server-issued SIWE message, and signature proof.
67
67
  */
68
68
  async create(input, options) {
69
69
  const validatedInput = parse(CreateSubaccountInputSchema, input);
@@ -1 +1 @@
1
- {"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted count metadata useful for deriving future smart-account salts.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns incoming, outgoing, or all subaccount invitations for the caller, newest first.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;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,IAAI,MAAM;GAChF,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAAkC;EACxC,MAAM,UAAU,4BAA4B,MAAM,UAAU;EAE5D,OAAO,KAAKK,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,aAAa,MAAMF,oBAAkB,IAAI;IAC/C,MAAM,QAAQ,UAAU;GAC5B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted count metadata useful for deriving future smart-account salts.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, server-issued SIWE message, and signature proof.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns incoming, outgoing, or all subaccount invitations for the caller, newest first.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8DA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,0BAA0B,YAAY,UAAU,QAAQ;EAC5E,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,cAAc,aAAaC,uBAA6B,WAAW,OAAO;EAC/E,KAAKC,oBAAoB,aAAaC,uBAA6B,WAAW,SAAS;EACvF,KAAKC,kBAAkB,aAAaD,uBAA6B,WAAW,OAAO;EACnF,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,KAAK,SAGR;EACC,MAAM,MAAM,MAAM,KAAKP,QAAQ,gBAAgB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAChF,OAAO;GACH,cAAc,IAAI;GAClB,aAAa,MAAM,EAAE,MAAMQ,kBAAgB,GAAG,IAAI,WAAW;EACjE;CACJ;;;;CAKA,MAAM,IACF,OACA,SAQF;EACE,MAAM,iBAAiB,MAAM,yBAAyB,KAAK;EAC3D,MAAM,eAAe,SAAS,eAAe,YAAY;EACzD,MAAM,MAAM,MAAM,KAAKN,YAAY,cAC/B;GACI,cAAc,eAAe;GAC7B,gBAAgB;GAChB,iBAAiB;GACjB,gBAAgB;GAChB,gBAAgB;GAChB,eAAe;GACf,kBAAA;EACJ,GACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,IAAI,YAAY,MAAM,IAAI,MAAM,yBAAyB,cAAc;EAE5E,OAAO;GACH,GAAG,MAAMM,oBAAkB,IAAI,UAAU;GACzC,QAAQ,IAA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AAI,MAAM;CACnD;;;;CAKA,MAAM,WACF,OACA,SAC6D;EAC7D,MAAM,iBAAiB,MAAM,+BAA+B,KAAK;EACjE,MAAM,MAAM,MAAM,KAAKE,YAAY,uBAC/B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,QAAQ,MAAM,EAAE,SAAS,EAAE,MAAM,6BAA6B,GAAG,CAAC,CAAC,GAAG,IAAI,MAAM;GAChF,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAAkC;EACxC,MAAM,UAAU,4BAA4B,MAAM,UAAU;EAE5D,OAAO,KAAKK,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,aAAa,MAAMF,oBAAkB,IAAI;IAC/C,MAAM,QAAQ,UAAU;GAC5B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
@@ -47,11 +47,9 @@ declare const CreateSubaccountInputSchema: v.StrictObjectSchema<{
47
47
  readonly label: v.OptionalSchema<v.StringSchema<undefined>, "">;
48
48
  readonly icon: v.OptionalSchema<v.StringSchema<undefined>, "">;
49
49
  readonly color: v.OptionalSchema<v.StringSchema<undefined>, "">;
50
- readonly smartAccountAddress: v.StringSchema<undefined>;
51
- readonly nonce: v.StringSchema<undefined>;
52
- readonly signature: v.StringSchema<undefined>;
53
- readonly primaryWalletAddress: v.OptionalSchema<v.StringSchema<undefined>, "">;
54
- readonly walletProvider: v.OptionalSchema<v.StringSchema<undefined>, "">;
50
+ readonly smartAccountAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid wallet address.">]>;
51
+ readonly message: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.CheckAction<string, "Wallet challenge message exceeds 4096 UTF-8 bytes.">]>;
52
+ readonly signature: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 8192, undefined>]>;
55
53
  }, undefined>;
56
54
  type CreateSubaccountInput = v.InferInput<typeof CreateSubaccountInputSchema>;
57
55
  declare const SubaccountIdInputSchema: v.StrictObjectSchema<{
@@ -279,8 +277,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
279
277
  seconds: bigint;
280
278
  nanos: number;
281
279
  } | undefined, number | undefined>]>;
282
- readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "policy" | "member" | "invite" | "security">]>;
283
- readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "revoked" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "failed" | "blocked" | "hold_placed" | "hold_released">]>;
280
+ readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
281
+ readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "created" | "updated" | "deleted" | "removed" | "role_set" | "received" | "replied" | "failed" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
284
282
  readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
285
283
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
286
284
  readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"subaccounts.schemas.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"mappings":";;;;cAsCa,sBAAoB,EAAA;KAErB,iBAAiB,EAAE,mBAAmB;cAS5C,iCAA+B,EAAA,yBAAA,EAAA,kBAAA,oCAAA,EAAA,gBAAA;KAYzB,uBAAuB,EAAE,mBAAmB;cAE3C,sCAAoC,EAAA;;;;;;KAiBrC,iCAAiC,EAAE,mBACpC;cAGE,gCAA8B,EAAA;;;;;;;KAQ/B,2BAA2B,EAAE,mBAAmB;cAE/C,6BAA2B,EAAA;;;;;;;;;;;;;;;KAK5B,wBAAwB,EAAE,mBAAmB;cAE5C,sCAAoC,EAAA;;;;;KAMrC,iCAAiC,EAAE,mBACpC;cAGE,6BAA2B,EAAA;;;;;;;;;;KAW5B,wBAAwB,EAAE,kBAAkB;cAE3C,yBAAuB,EAAA;;;KAIxB,oBAAoB,EAAE,kBAAkB;cAEvC,8BAA4B,EAAA;;;;;;KAO7B,yBAAyB,EAAE,mBAAmB;cAE7C,gCAA8B,EAAA;KAE/B,2BAA2B,EAAE,mBAAmB;cAmB/C,6BAA2B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4B5B,wBAAwB,EAAE,kBAAkB;cAE3C,mCAAiC,EAAA;;;;;KASlC,8BAA8B,EAAE,kBAAkB;cAEjD,mCAAiC,EAAA;;;;KAKlC,8BAA8B,EAAE,kBAAkB;cAEjD,uCAAqC,EAAA;;;;;KAEtC,kCAAkC,EAAE,kBACrC;cAGE,8CAA4C,E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