@polyester/sdk 0.11.0 → 0.13.0

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 (175) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/core-client.d.ts +3 -3
  3. package/dist/core-client.d.ts.map +1 -1
  4. package/dist/core-client.js +35 -50
  5. package/dist/core-client.js.map +1 -1
  6. package/dist/gen/auth/v1/address_book_pb.d.ts +21 -0
  7. package/dist/gen/auth/v1/address_book_pb.d.ts.map +1 -1
  8. package/dist/gen/auth/v1/address_book_pb.js +1 -1
  9. package/dist/gen/auth/v1/address_book_pb.js.map +1 -1
  10. package/dist/gen/auth/v1/mfa_pb.d.ts +39 -3
  11. package/dist/gen/auth/v1/mfa_pb.d.ts.map +1 -1
  12. package/dist/gen/auth/v1/mfa_pb.js +1 -1
  13. package/dist/gen/auth/v1/mfa_pb.js.map +1 -1
  14. package/dist/gen/auth/v1/subaccounts_pb.d.ts +2 -1
  15. package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
  16. package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
  17. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +3 -2
  18. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
  19. package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
  20. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +3 -0
  21. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
  22. package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
  23. package/dist/gen/triggers/v1/triggers_pb.d.ts +347 -5
  24. package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
  25. package/dist/gen/triggers/v1/triggers_pb.js +307 -3
  26. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  27. package/dist/services/accounts/accounts.d.ts +2 -2
  28. package/dist/services/accounts/accounts.d.ts.map +1 -1
  29. package/dist/services/accounts/accounts.js +2 -2
  30. package/dist/services/accounts/accounts.js.map +1 -1
  31. package/dist/services/address-book/address-book.d.ts +5 -3
  32. package/dist/services/address-book/address-book.d.ts.map +1 -1
  33. package/dist/services/address-book/address-book.js +5 -3
  34. package/dist/services/address-book/address-book.js.map +1 -1
  35. package/dist/services/address-book/address-book.schemas.d.ts +6 -0
  36. package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
  37. package/dist/services/address-book/address-book.schemas.js +10 -5
  38. package/dist/services/address-book/address-book.schemas.js.map +1 -1
  39. package/dist/services/api-keys/api-keys.d.ts +2 -2
  40. package/dist/services/api-keys/api-keys.d.ts.map +1 -1
  41. package/dist/services/api-keys/api-keys.js +3 -3
  42. package/dist/services/api-keys/api-keys.js.map +1 -1
  43. package/dist/services/auth/account-signer-auth.d.ts +3 -2
  44. package/dist/services/auth/account-signer-auth.d.ts.map +1 -1
  45. package/dist/services/auth/account-signer-auth.js.map +1 -1
  46. package/dist/services/auth/auth.d.ts +3 -7
  47. package/dist/services/auth/auth.d.ts.map +1 -1
  48. package/dist/services/auth/auth.js +1 -1
  49. package/dist/services/auth/auth.js.map +1 -1
  50. package/dist/services/auth/profile/profile.d.ts +2 -2
  51. package/dist/services/auth/profile/profile.d.ts.map +1 -1
  52. package/dist/services/auth/profile/profile.js +2 -2
  53. package/dist/services/auth/profile/profile.js.map +1 -1
  54. package/dist/services/balances/balances.d.ts +2 -2
  55. package/dist/services/balances/balances.d.ts.map +1 -1
  56. package/dist/services/balances/balances.js +2 -2
  57. package/dist/services/balances/balances.js.map +1 -1
  58. package/dist/services/candles/candles.d.ts +2 -2
  59. package/dist/services/candles/candles.d.ts.map +1 -1
  60. package/dist/services/candles/candles.js +2 -2
  61. package/dist/services/candles/candles.js.map +1 -1
  62. package/dist/services/candles/candles.schemas.d.ts +10 -10
  63. package/dist/services/chain-analytics/chain-analytics.d.ts +2 -2
  64. package/dist/services/chain-analytics/chain-analytics.d.ts.map +1 -1
  65. package/dist/services/chain-analytics/chain-analytics.js +2 -2
  66. package/dist/services/chain-analytics/chain-analytics.js.map +1 -1
  67. package/dist/services/deposit/deposit.d.ts +2 -2
  68. package/dist/services/deposit/deposit.d.ts.map +1 -1
  69. package/dist/services/deposit/deposit.js +2 -2
  70. package/dist/services/deposit/deposit.js.map +1 -1
  71. package/dist/services/fees/fees.d.ts +2 -2
  72. package/dist/services/fees/fees.d.ts.map +1 -1
  73. package/dist/services/fees/fees.js +2 -2
  74. package/dist/services/fees/fees.js.map +1 -1
  75. package/dist/services/guard-signer/guard-signer.d.ts +2 -2
  76. package/dist/services/guard-signer/guard-signer.d.ts.map +1 -1
  77. package/dist/services/guard-signer/guard-signer.js +2 -2
  78. package/dist/services/guard-signer/guard-signer.js.map +1 -1
  79. package/dist/services/heatmap/heatmap.d.ts +2 -2
  80. package/dist/services/heatmap/heatmap.d.ts.map +1 -1
  81. package/dist/services/heatmap/heatmap.js +2 -2
  82. package/dist/services/heatmap/heatmap.js.map +1 -1
  83. package/dist/services/heatmap/heatmap.schemas.d.ts +9 -9
  84. package/dist/services/internal-transfers/internal-transfers.d.ts +2 -2
  85. package/dist/services/internal-transfers/internal-transfers.d.ts.map +1 -1
  86. package/dist/services/internal-transfers/internal-transfers.js +2 -2
  87. package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
  88. package/dist/services/lifecycle/lifecycle.d.ts +2 -2
  89. package/dist/services/lifecycle/lifecycle.d.ts.map +1 -1
  90. package/dist/services/lifecycle/lifecycle.js +2 -2
  91. package/dist/services/lifecycle/lifecycle.js.map +1 -1
  92. package/dist/services/market-data/market-data.d.ts +2 -2
  93. package/dist/services/market-data/market-data.d.ts.map +1 -1
  94. package/dist/services/market-data/market-data.js +2 -2
  95. package/dist/services/market-data/market-data.js.map +1 -1
  96. package/dist/services/market-overview/market-overview.d.ts +2 -2
  97. package/dist/services/market-overview/market-overview.d.ts.map +1 -1
  98. package/dist/services/market-overview/market-overview.js +2 -2
  99. package/dist/services/market-overview/market-overview.js.map +1 -1
  100. package/dist/services/market-overview/market-overview.schemas.d.ts +3 -3
  101. package/dist/services/mfa/mfa.d.ts +4 -4
  102. package/dist/services/mfa/mfa.d.ts.map +1 -1
  103. package/dist/services/mfa/mfa.js +4 -4
  104. package/dist/services/mfa/mfa.js.map +1 -1
  105. package/dist/services/mfa/mfa.schemas.d.ts +132 -4
  106. package/dist/services/mfa/mfa.schemas.d.ts.map +1 -1
  107. package/dist/services/mfa/mfa.schemas.js +13 -7
  108. package/dist/services/mfa/mfa.schemas.js.map +1 -1
  109. package/dist/services/orderbook/orderbook.d.ts +2 -2
  110. package/dist/services/orderbook/orderbook.d.ts.map +1 -1
  111. package/dist/services/orderbook/orderbook.js +2 -2
  112. package/dist/services/orderbook/orderbook.js.map +1 -1
  113. package/dist/services/orders/orders-input.schemas.d.ts +1 -1
  114. package/dist/services/orders/orders-output.schemas.d.ts +6 -6
  115. package/dist/services/orders/orders.d.ts +2 -2
  116. package/dist/services/orders/orders.d.ts.map +1 -1
  117. package/dist/services/orders/orders.js +3 -3
  118. package/dist/services/orders/orders.js.map +1 -1
  119. package/dist/services/policies/api-key-policies/api-key-policies.d.ts +2 -2
  120. package/dist/services/policies/api-key-policies/api-key-policies.d.ts.map +1 -1
  121. package/dist/services/policies/api-key-policies/api-key-policies.js +2 -2
  122. package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
  123. package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +2 -2
  124. package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts.map +1 -1
  125. package/dist/services/policies/subaccount-policies/subaccount-policies.js +2 -2
  126. package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
  127. package/dist/services/rate-limits/rate-limits.d.ts +2 -2
  128. package/dist/services/rate-limits/rate-limits.d.ts.map +1 -1
  129. package/dist/services/rate-limits/rate-limits.js.map +1 -1
  130. package/dist/services/social-verification/social-verification.d.ts +2 -2
  131. package/dist/services/social-verification/social-verification.d.ts.map +1 -1
  132. package/dist/services/social-verification/social-verification.js +2 -2
  133. package/dist/services/social-verification/social-verification.js.map +1 -1
  134. package/dist/services/subaccounts/subaccounts.d.ts +3 -3
  135. package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
  136. package/dist/services/subaccounts/subaccounts.js +11 -9
  137. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  138. package/dist/services/subaccounts/subaccounts.schemas.d.ts +4 -4
  139. package/dist/services/trades/trades.d.ts +2 -2
  140. package/dist/services/trades/trades.d.ts.map +1 -1
  141. package/dist/services/trades/trades.js +2 -2
  142. package/dist/services/trades/trades.js.map +1 -1
  143. package/dist/services/trading-withdraws/trading-withdraws.d.ts +2 -2
  144. package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
  145. package/dist/services/trading-withdraws/trading-withdraws.js +2 -2
  146. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  147. package/dist/services/transfers/transfers.d.ts +2 -2
  148. package/dist/services/transfers/transfers.d.ts.map +1 -1
  149. package/dist/services/transfers/transfers.js +2 -2
  150. package/dist/services/transfers/transfers.js.map +1 -1
  151. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  152. package/dist/services/triggers/triggers-output.schemas.d.ts +365 -18
  153. package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
  154. package/dist/services/triggers/triggers-output.schemas.js +36 -4
  155. package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
  156. package/dist/services/triggers/triggers.codecs.js +51 -1
  157. package/dist/services/triggers/triggers.codecs.js.map +1 -1
  158. package/dist/services/triggers/triggers.d.ts +2 -2
  159. package/dist/services/triggers/triggers.d.ts.map +1 -1
  160. package/dist/services/triggers/triggers.js +2 -2
  161. package/dist/services/triggers/triggers.js.map +1 -1
  162. package/dist/services/vip/vip.d.ts +2 -2
  163. package/dist/services/vip/vip.js.map +1 -1
  164. package/dist/services/whiteboard/whiteboard.d.ts +2 -2
  165. package/dist/services/whiteboard/whiteboard.d.ts.map +1 -1
  166. package/dist/services/whiteboard/whiteboard.js +2 -2
  167. package/dist/services/whiteboard/whiteboard.js.map +1 -1
  168. package/dist/services/zipper/zipper.d.ts +2 -2
  169. package/dist/services/zipper/zipper.d.ts.map +1 -1
  170. package/dist/services/zipper/zipper.js +2 -2
  171. package/dist/services/zipper/zipper.js.map +1 -1
  172. package/dist/shared/transports.d.ts +7 -1
  173. package/dist/shared/transports.d.ts.map +1 -1
  174. package/dist/shared/transports.js.map +1 -1
  175. package/package.json +1 -1
@@ -259,17 +259,21 @@ declare const ListInternalTransferWhitelistEntriesInputSchema: v.SchemaWithPipe<
259
259
  type ListInternalTransferWhitelistEntriesInput = v.InferInput<typeof ListInternalTransferWhitelistEntriesInputSchema>;
260
260
  declare const GetAddressBookViewInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
261
261
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 200, undefined>]>, undefined>;
262
+ /** Minimum `viewRevision` (from an invalidation event) the returned view must reach. */
263
+ readonly minimumViewRevision: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, v.RegexAction<string, `${string} must be a decimal integer`>, v.TransformAction<string, bigint>]>, v.CheckAction<bigint, `${string} must be greater than 0`>]>, undefined>;
262
264
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
263
265
  readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
264
266
  }, undefined>], undefined>, undefined>;
265
267
  }, undefined>, v.TransformAction<{
266
268
  limit?: number | undefined;
269
+ minimumViewRevision?: bigint | undefined;
267
270
  account?: "active" | "main" | {
268
271
  subaccountId: string;
269
272
  } | undefined;
270
273
  }, {
271
274
  subaccountId: bigint | undefined;
272
275
  limit: number | undefined;
276
+ minimumViewRevision: bigint | undefined;
273
277
  }>]>;
274
278
  type GetAddressBookViewInput = v.InferInput<typeof GetAddressBookViewInputSchema>;
275
279
  declare const AddressBookSchema: v.ObjectSchema<{
@@ -1141,6 +1145,7 @@ declare const AddressBookViewSchema: v.ObjectSchema<{
1141
1145
  }, undefined>, undefined>, readonly []>;
1142
1146
  }, undefined>, undefined>;
1143
1147
  readonly recentDestinationsTruncated: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1148
+ readonly viewRevision: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>, 0n>;
1144
1149
  }, undefined>;
1145
1150
  type AddressBookView = v.InferOutput<typeof AddressBookViewSchema>;
1146
1151
  declare const AddressBookViewInvalidatedSchema: v.ObjectSchema<{
@@ -1156,6 +1161,7 @@ declare const AddressBookViewInvalidatedSchema: v.ObjectSchema<{
1156
1161
  seconds: bigint;
1157
1162
  nanos: number;
1158
1163
  }, number>]>;
1164
+ readonly viewRevision: v.OptionalSchema<v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>, 0n>;
1159
1165
  }, undefined>;
1160
1166
  type AddressBookViewInvalidated = v.InferOutput<typeof AddressBookViewInvalidatedSchema>;
1161
1167
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"address-book.schemas.d.ts","names":[],"sources":["../../../src/services/address-book/address-book.schemas.ts"],"mappings":";;;;cAoDa,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;KAelC,8BAA8B,EAAE,kBAAkB;cAEjD,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwClC,8BAA8B,EAAE,kBAAkB;iBAE9C,oCAAoC,OAAO;cAkB9C,mCAAiC,EAAA,yBAAA,EAAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAC3B,uBAAuB,EAAE,mBAAmB;cAE3C,sCAAoC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkCrC,iCAAiC,EAAE,mBACpC;cAGE,wCAAsC,EAAA,YAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAEvC,mCAAmC,EAAE,mBACtC;cAGE,sCAAoC,EAAA;;;;;;;;;;;;KAOrC,iCAAiC,EAAE,mBACpC;cAGE,6BAA2B,EAAA;;;;;;;;;;;;;;;;;;;;;KAO5B,wBAAwB,EAAE,mBAAmB;cAE5C,8BAA4B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqD7B,yBAAyB,EAAE,mBAAmB;cAE7C,yCAAuC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+CxC,oCAAoC,EAAE,mBACvC;cAGE,uBAAqB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAUtB,kBAAkB,EAAE,mBAAmB;cAEtC,kCAAgC,EAAA;;;;;;;;;;;;;;;KAMjC,6BAA6B,EAAE,mBAAmB"}
@@ -150,10 +150,13 @@ const ListInternalTransferWhitelistEntriesInputSchema = v.pipe(v.strictObject({
150
150
  })));
151
151
  const GetAddressBookViewInputSchema = v.pipe(v.strictObject({
152
152
  ...AccountScopeInputEntries,
153
- limit: AddressBookViewLimitSchema
154
- }), v.transform(({ account, limit }) => ({
153
+ limit: AddressBookViewLimitSchema,
154
+ /** Minimum `viewRevision` (from an invalidation event) the returned view must reach. */
155
+ minimumViewRevision: v.optional(positiveBigintStringInputSchema("minimumViewRevision"))
156
+ }), v.transform(({ account, limit, minimumViewRevision }) => ({
155
157
  subaccountId: accountScopeToSubaccountId(account),
156
- limit
158
+ limit,
159
+ minimumViewRevision
157
160
  })));
158
161
  const CountSchema = v.pipe(v.bigint(), v.transform((value) => Number(value)));
159
162
  const AccountScopeSchema = v.object({
@@ -338,11 +341,13 @@ const AddressBookViewSchema = v.object({
338
341
  recentDestinations: v.optional(AddressBookRecentDestinationsViewSchema),
339
342
  tags: v.optional(v.array(AddressBookTagSummarySchema), []),
340
343
  withdrawWhitelist: v.optional(WithdrawWhitelistViewSchema),
341
- recentDestinationsTruncated: v.optional(v.boolean(), false)
344
+ recentDestinationsTruncated: v.optional(v.boolean(), false),
345
+ viewRevision: v.optional(BigIntStringSchema, 0n)
342
346
  });
343
347
  const AddressBookViewInvalidatedSchema = v.object({
344
348
  scope: v.optional(AccountScopeSchema),
345
- invalidatedAt: TimestampMsSchema$1
349
+ invalidatedAt: TimestampMsSchema$1,
350
+ viewRevision: v.optional(BigIntStringSchema, 0n)
346
351
  });
347
352
  //#endregion
348
353
  export { AddressBookEntriesSchema, AddressBookEntriesViewSchema, AddressBookEntrySchema, AddressBookRecentDestinationsViewSchema, AddressBookSchema, AddressBookTagSchema, AddressBookTagSummarySchema, AddressBookViewInvalidatedSchema, AddressBookViewSchema, CopyAddressBookEntryInputSchema, CreateAddressBookEntryInputSchema, CreateAddressBookTagInputSchema, DeleteAddressBookEntryInputSchema, DeleteAddressBookTagInputSchema, GetAddressBookViewInputSchema, InternalTransferWhitelistEntriesSchema, InternalTransferWhitelistEntrySchema, ListAddressBookEntriesInputSchema, ListInternalTransferWhitelistEntriesInputSchema, ListTransferCounterpartiesInputSchema, ListTransferDestinationsInputSchema, MirroredWithdrawWhitelistEntrySchema, SubaccountScopedInputSchema, TransferCounterpartiesSchema, TransferCounterpartySchema, TransferDestinationSchema, TransferDestinationsSchema, UpdateAddressBookEntryInputSchema, UpdateAddressBookTagInputSchema, WithdrawWhitelistViewSchema, validateCreateAddressBookEntryInput };
@@ -1 +1 @@
1
- {"version":3,"file":"address-book.schemas.js","names":["Proto.AccountScopeType","Proto.DestinationWhitelistStatus","Proto.AddressBookEntryKind","Proto.TransferCounterpartyDirection","Proto.InternalWhitelistResolutionStatus","RequiredTimestampMsSchema"],"sources":["../../../src/services/address-book/address-book.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport * as Proto from \"../../gen/auth/v1/address_book_pb.js\";\nimport { SubaccountRole } from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport {\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampMsSchema as RequiredTimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport {\n ADDRESS_BOOK_ENTRY_KIND_VALUES,\n AccountScopeTypeCodec,\n AddressBookEntryKindCodec,\n DestinationWhitelistStatusCodec,\n InternalWhitelistResolutionStatusCodec,\n TRANSFER_COUNTERPARTY_DIRECTION_VALUES,\n TransferCounterpartyDirectionCodec,\n} from \"./address-book.codecs.js\";\nimport { SubaccountRoleCodec } from \"../subaccounts/subaccounts.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst OptionalSubaccountIdSchema = optionalSubaccountIdInputSchema();\nconst IdSchema = idInputSchema;\n\nconst AddressBookLimitSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(500)),\n);\nconst AddressBookCounterpartyLimitSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(200)),\n);\nconst AddressBookViewLimitSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(200)),\n);\nconst PageTokenSchema = v.optional(v.pipe(v.string(), v.trim()), \"\");\n\nconst TimestampMsSchema = OptionalTimestampMsSchema;\n\nconst AddressBookTagInputSchema = v.strictObject({\n name: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(48)),\n color: v.optional(v.pipe(v.string(), v.trim(), v.maxLength(32)), \"\"),\n});\nconst AddressBookTagInputsSchema = v.pipe(v.array(AddressBookTagInputSchema), v.maxLength(10));\n\nexport const ListAddressBookEntriesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n kind: v.optional(v.picklist(ADDRESS_BOOK_ENTRY_KIND_VALUES)),\n limit: AddressBookLimitSchema,\n pageToken: PageTokenSchema,\n }),\n v.transform(({ account, kind, limit, pageToken }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n kind: kind ? AddressBookEntryKindCodec.inputToProto[kind] : undefined,\n limit,\n pageToken,\n })),\n);\n\nexport type ListAddressBookEntriesInput = v.InferInput<typeof ListAddressBookEntriesInputSchema>;\n\nexport const CreateAddressBookEntryInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n label: v.pipe(v.string(), v.trim(), v.minLength(1)),\n note: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n entry: v.variant(\"kind\", [\n v.strictObject({\n kind: v.literal(\"external\"),\n polychainChainId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n address: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.strictObject({\n kind: v.literal(\"internal\"),\n smartAccountAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n ]),\n tagIds: v.optional(v.array(IdSchema(\"tagId\")), []),\n newTags: v.optional(AddressBookTagInputsSchema, []),\n }),\n v.transform(({ account, entry, ...rest }) => ({\n ...rest,\n subaccountId: accountScopeToSubaccountId(account),\n entry:\n entry.kind === \"external\"\n ? {\n case: \"external\" as const,\n value: {\n polychainChainId: entry.polychainChainId,\n address: entry.address,\n },\n }\n : {\n case: \"internal\" as const,\n value: {\n smartAccountAddress: entry.smartAccountAddress,\n },\n },\n })),\n);\n\nexport type CreateAddressBookEntryInput = v.InferInput<typeof CreateAddressBookEntryInputSchema>;\n\nexport function validateCreateAddressBookEntryInput(input: CreateAddressBookEntryInput): void {\n parse(CreateAddressBookEntryInputSchema, input);\n}\n\ntype AddressBookEntryPatch = {\n label?: string;\n note?: string;\n tagIds?: bigint[];\n newTags?: v.InferOutput<typeof AddressBookTagInputSchema>[];\n};\n\nconst ADDRESS_BOOK_ENTRY_PATCH_FIELDS = defineProtoPatchFields<AddressBookEntryPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n note: { path: \"note\", encode: (note) => ({ note }) },\n tagIds: { path: \"tag_ids\", encode: (tagIds) => ({ tagIds }) },\n newTags: { path: \"new_tags\", encode: (newTags) => ({ newTags }) },\n});\n\nexport const UpdateAddressBookEntryInputSchema = v.pipe(\n v.strictObject({\n addressBookEntryId: IdSchema(\"addressBookEntryId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.pipe(v.string(), v.trim())),\n note: v.optional(v.pipe(v.string(), v.trim())),\n tagIds: v.optional(v.array(IdSchema(\"tagId\"))),\n newTags: v.optional(AddressBookTagInputsSchema),\n }),\n v.check(\n ({ label, note, tagIds, newTags }) =>\n label !== undefined ||\n note !== undefined ||\n tagIds !== undefined ||\n newTags !== undefined,\n \"At least one address-book entry field must be provided\",\n ),\n v.transform(({ addressBookEntryId, expectedRevision, ...input }) => {\n const { patch: entry, updateMask } = buildProtoPatch(\n input,\n ADDRESS_BOOK_ENTRY_PATCH_FIELDS,\n );\n return { addressBookEntryId, entry, updateMask, expectedRevision };\n }),\n);\n\nexport type UpdateAddressBookEntryInput = v.InferInput<typeof UpdateAddressBookEntryInputSchema>;\n\nexport const DeleteAddressBookEntryInputSchema = v.strictObject({\n addressBookEntryId: IdSchema(\"addressBookEntryId\"),\n});\n\nexport type DeleteAddressBookEntryInput = v.InferInput<typeof DeleteAddressBookEntryInputSchema>;\n\nexport const CopyAddressBookEntryInputSchema = v.strictObject({\n addressBookEntryId: IdSchema(\"addressBookEntryId\"),\n targetSubaccountId: OptionalSubaccountIdSchema,\n});\n\nexport type CopyAddressBookEntryInput = v.InferInput<typeof CopyAddressBookEntryInputSchema>;\n\nexport const CreateAddressBookTagInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n name: v.pipe(v.string(), v.trim(), v.minLength(1)),\n color: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type CreateAddressBookTagInput = v.InferInput<typeof CreateAddressBookTagInputSchema>;\n\nexport const UpdateAddressBookTagInputSchema = v.pipe(\n v.strictObject({\n tagId: IdSchema(\"tagId\"),\n name: v.optional(v.pipe(v.string(), v.trim(), v.minLength(1))),\n color: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.check(\n ({ name, color }) => name !== undefined || color !== undefined,\n \"At least one address-book tag field must be provided\",\n ),\n);\n\nexport type UpdateAddressBookTagInput = v.InferInput<typeof UpdateAddressBookTagInputSchema>;\n\nexport const DeleteAddressBookTagInputSchema = v.strictObject({\n tagId: IdSchema(\"tagId\"),\n});\n\nexport type DeleteAddressBookTagInput = v.InferInput<typeof DeleteAddressBookTagInputSchema>;\n\nexport const ListTransferCounterpartiesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n direction: v.optional(v.picklist(TRANSFER_COUNTERPARTY_DIRECTION_VALUES)),\n kind: v.optional(v.picklist(ADDRESS_BOOK_ENTRY_KIND_VALUES)),\n limit: AddressBookCounterpartyLimitSchema,\n }),\n v.transform(({ account, direction, kind, limit }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n direction: direction\n ? TransferCounterpartyDirectionCodec.inputToProto[direction]\n : undefined,\n kind: kind ? AddressBookEntryKindCodec.inputToProto[kind] : undefined,\n limit,\n })),\n);\n\nexport type ListTransferCounterpartiesInput = v.InferInput<\n typeof ListTransferCounterpartiesInputSchema\n>;\n\nexport const ListTransferDestinationsInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n kind: v.optional(v.picklist(ADDRESS_BOOK_ENTRY_KIND_VALUES)),\n limit: AddressBookLimitSchema,\n pageToken: PageTokenSchema,\n }),\n v.transform(({ account, kind, limit, pageToken }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n kind: kind ? AddressBookEntryKindCodec.inputToProto[kind] : undefined,\n limit,\n pageToken,\n })),\n);\n\nexport type ListTransferDestinationsInput = v.InferInput<\n typeof ListTransferDestinationsInputSchema\n>;\n\nexport const SubaccountScopedInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type SubaccountScopedInput = v.InferInput<typeof SubaccountScopedInputSchema>;\n\nexport const ListInternalTransferWhitelistEntriesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n limit: AddressBookLimitSchema,\n pageToken: PageTokenSchema,\n }),\n v.transform(({ account, limit, pageToken }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n limit,\n pageToken,\n })),\n);\n\nexport type ListInternalTransferWhitelistEntriesInput = v.InferInput<\n typeof ListInternalTransferWhitelistEntriesInputSchema\n>;\n\nexport const GetAddressBookViewInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n limit: AddressBookViewLimitSchema,\n }),\n v.transform(({ account, limit }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n limit,\n })),\n);\n\nexport type GetAddressBookViewInput = v.InferInput<typeof GetAddressBookViewInputSchema>;\n\nconst CountSchema = v.pipe(\n v.bigint(),\n v.transform((value) => Number(value)),\n);\n\nconst AccountScopeSchema = v.object({\n scopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.AccountScopeSchema\",\n \"scope type\",\n ),\n ),\n ),\n rootAccountId: PublicIdSchema,\n subaccountId: PublicIdSchema,\n});\n\nconst ExternalWithdrawAddressSchema = v.object({\n polychainChainId: v.pipe(v.number(), v.integer()),\n address: v.string(),\n});\n\nconst InternalTransferAccountSchema = v.object({\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.InternalTransferAccountSchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n});\n\nconst AddressBookEntryValueSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"external\"), value: ExternalWithdrawAddressSchema }),\n v.object({ case: v.literal(\"internal\"), value: InternalTransferAccountSchema }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nconst DestinationWhitelistStatusSchema = v.pipe(\n v.enum(Proto.DestinationWhitelistStatus),\n v.transform((value) =>\n requiredEnumLabel(\n DestinationWhitelistStatusCodec.protoToOutput,\n value,\n \"PolyesterClient.DestinationWhitelistStatusSchema\",\n \"whitelist status\",\n ),\n ),\n);\n\nconst AddressBookEntryKindSchema = v.pipe(\n v.enum(Proto.AddressBookEntryKind),\n v.transform((value) =>\n requiredEnumLabel(\n AddressBookEntryKindCodec.protoToOutput,\n value,\n \"PolyesterClient.AddressBookEntryKindSchema\",\n \"entry kind\",\n ),\n ),\n);\n\nconst TransferCounterpartyDirectionSchema = v.pipe(\n v.enum(Proto.TransferCounterpartyDirection),\n v.transform((value) =>\n requiredEnumLabel(\n TransferCounterpartyDirectionCodec.protoToOutput,\n value,\n \"PolyesterClient.TransferCounterpartyDirectionSchema\",\n \"direction\",\n ),\n ),\n);\n\nexport const AddressBookSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n callerRole: v.pipe(\n v.enum(SubaccountRole),\n v.transform((role) =>\n requiredEnumLabel(\n SubaccountRoleCodec.protoToOutput,\n role,\n \"AddressBookEntrySchema\",\n \"caller role\",\n ),\n ),\n ),\n label: v.string(),\n ownerUsername: v.string(),\n smartAccountAddress: v.string(),\n});\n\nexport type AddressBook = v.InferOutput<typeof AddressBookSchema>;\n\nexport const AddressBookTagSummarySchema = v.object({\n tagId: PublicIdSchema,\n name: v.string(),\n color: v.string(),\n});\n\nexport type AddressBookTagSummary = v.InferOutput<typeof AddressBookTagSummarySchema>;\n\nexport const AddressBookTagSchema = v.object({\n tagId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n name: v.string(),\n color: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n});\n\nexport type AddressBookTag = v.InferOutput<typeof AddressBookTagSchema>;\n\nexport const AddressBookEntrySchema = v.object({\n addressBookEntryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n kind: AddressBookEntryKindSchema,\n label: v.string(),\n note: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n entry: AddressBookEntryValueSchema,\n tags: v.array(AddressBookTagSchema),\n revision: BigIntStringSchema,\n});\n\nexport type AddressBookEntry = v.InferOutput<typeof AddressBookEntrySchema>;\n\nexport const AddressBookEntriesSchema = v.array(AddressBookEntrySchema);\nexport type AddressBookEntries = v.InferOutput<typeof AddressBookEntriesSchema>;\n\nexport const TransferCounterpartySchema = v.object({\n counterpartyId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n direction: TransferCounterpartyDirectionSchema,\n kind: AddressBookEntryKindSchema,\n saved: v.boolean(),\n addressBookEntryId: PublicIdSchema,\n useCount: CountSchema,\n firstSeenAt: TimestampMsSchema,\n lastSeenAt: TimestampMsSchema,\n counterparty: AddressBookEntryValueSchema,\n});\n\nexport type TransferCounterparty = v.InferOutput<typeof TransferCounterpartySchema>;\n\nexport const TransferCounterpartiesSchema = v.array(TransferCounterpartySchema);\nexport type TransferCounterparties = v.InferOutput<typeof TransferCounterpartiesSchema>;\n\nexport const TransferDestinationSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n kind: AddressBookEntryKindSchema,\n saved: v.boolean(),\n whitelisted: v.boolean(),\n whitelistStatus: DestinationWhitelistStatusSchema,\n addressBookEntry: v.optional(AddressBookEntrySchema),\n destination: AddressBookEntryValueSchema,\n whitelistEffectiveAt: TimestampMsSchema,\n whitelistUpdatedAt: TimestampMsSchema,\n});\n\nexport type TransferDestination = v.InferOutput<typeof TransferDestinationSchema>;\n\nexport const TransferDestinationsSchema = v.array(TransferDestinationSchema);\nexport type TransferDestinations = v.InferOutput<typeof TransferDestinationsSchema>;\n\nexport const InternalTransferWhitelistEntrySchema = v.object({\n entryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.InternalTransferWhitelistEntrySchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n resolutionStatus: v.pipe(\n v.enum(Proto.InternalWhitelistResolutionStatus),\n v.transform((value) =>\n requiredEnumLabel(\n InternalWhitelistResolutionStatusCodec.protoToOutput,\n value,\n \"PolyesterClient.InternalTransferWhitelistEntrySchema\",\n \"resolution status\",\n ),\n ),\n ),\n});\n\nexport type InternalTransferWhitelistEntry = v.InferOutput<\n typeof InternalTransferWhitelistEntrySchema\n>;\n\nexport const InternalTransferWhitelistEntriesSchema = v.array(InternalTransferWhitelistEntrySchema);\n\nexport type InternalTransferWhitelistEntries = v.InferOutput<\n typeof InternalTransferWhitelistEntriesSchema\n>;\n\nexport const MirroredWithdrawWhitelistEntrySchema = v.object({\n canonicalAddress: v.string(),\n rawAddressHex: v.string(),\n updatedAt: TimestampMsSchema,\n polychainChainId: v.pipe(v.number(), v.integer()),\n});\n\nexport type MirroredWithdrawWhitelistEntry = v.InferOutput<\n typeof MirroredWithdrawWhitelistEntrySchema\n>;\n\nexport const WithdrawWhitelistViewSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n externalWhitelistRequired: v.boolean(),\n internalWhitelistRequired: v.boolean(),\n activeEntries: v.optional(v.array(MirroredWithdrawWhitelistEntrySchema), []),\n});\n\nexport type WithdrawWhitelistView = v.InferOutput<typeof WithdrawWhitelistViewSchema>;\n\nexport const AddressBookEntriesViewSchema = v.object({\n external: v.optional(\n v.array(\n v.object({\n addressBookEntryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n label: v.string(),\n note: v.string(),\n tagIds: v.optional(v.array(PublicIdSchema), []),\n whitelistStatus: DestinationWhitelistStatusSchema,\n polychainChainId: v.pipe(v.number(), v.integer()),\n address: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n revision: BigIntStringSchema,\n }),\n ),\n [],\n ),\n internal: v.optional(\n v.array(\n v.object({\n addressBookEntryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n label: v.string(),\n note: v.string(),\n tagIds: v.optional(v.array(PublicIdSchema), []),\n whitelistStatus: DestinationWhitelistStatusSchema,\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.AddressBookEntriesViewSchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n revision: BigIntStringSchema,\n }),\n ),\n [],\n ),\n});\n\nexport type AddressBookEntriesView = v.InferOutput<typeof AddressBookEntriesViewSchema>;\n\nexport const AddressBookRecentDestinationsViewSchema = v.object({\n external: v.optional(\n v.array(\n v.object({\n scope: v.optional(AccountScopeSchema),\n lastDirection: TransferCounterpartyDirectionSchema,\n saved: v.boolean(),\n addressBookEntryId: PublicIdSchema,\n useCount: CountSchema,\n lastSeenAt: TimestampMsSchema,\n polychainChainId: v.pipe(v.number(), v.integer()),\n address: v.string(),\n }),\n ),\n [],\n ),\n internal: v.optional(\n v.array(\n v.object({\n scope: v.optional(AccountScopeSchema),\n lastDirection: TransferCounterpartyDirectionSchema,\n saved: v.boolean(),\n addressBookEntryId: PublicIdSchema,\n useCount: CountSchema,\n lastSeenAt: TimestampMsSchema,\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.AddressBookRecentDestinationsViewSchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n }),\n ),\n [],\n ),\n});\n\nexport type AddressBookRecentDestinationsView = v.InferOutput<\n typeof AddressBookRecentDestinationsViewSchema\n>;\n\nexport const AddressBookViewSchema = v.object({\n books: v.optional(v.array(AddressBookSchema), []),\n entries: v.optional(AddressBookEntriesViewSchema),\n recentDestinations: v.optional(AddressBookRecentDestinationsViewSchema),\n tags: v.optional(v.array(AddressBookTagSummarySchema), []),\n withdrawWhitelist: v.optional(WithdrawWhitelistViewSchema),\n recentDestinationsTruncated: v.optional(v.boolean(), false),\n});\n\nexport type AddressBookView = v.InferOutput<typeof AddressBookViewSchema>;\n\nexport const AddressBookViewInvalidatedSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n invalidatedAt: RequiredTimestampMsSchema,\n});\n\nexport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,OAAO;CAC5D,UAAU,EAAE,SACR,EAAE,MACE,EAAE,OAAO;EACL,OAAO,EAAE,SAAS,kBAAkB;EACpC,eAAe;EACf,OAAO,EAAE,QAAQ;EACjB,oBAAoB;EACpB,UAAU;EACV,YAAY;EACZ,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;EAChD,SAAS,EAAE,OAAO;CACtB,CAAC,CACL,GACA,CAAC,CACL;CACA,UAAU,EAAE,SACR,EAAE,MACE,EAAE,OAAO;EACL,OAAO,EAAE,SAAS,kBAAkB;EACpC,eAAe;EACf,OAAO,EAAE,QAAQ;EACjB,oBAAoB;EACpB,UAAU;EACV,YAAY;EACZ,eAAe;EACf,iBAAiB;EACjB,iBAAiB,EAAE,KACf,EAAE,KAAKA,gBAAsB,GAC7B,EAAE,WAAW,UACT,kBACI,sBAAsB,eACtB,OACA,2DACA,mBACJ,CACJ,CACJ;EACA,qBAAqB,EAAE,OAAO;EAC9B,cAAc,EAAE,OAAO;EACvB,iBAAiB,EAAE,OAAO;CAC9B,CAAC,CACL,GACA,CAAC,CACL;AACJ,CAAC;AAMD,MAAa,wBAAwB,EAAE,OAAO;CAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,GAAG,CAAC,CAAC;CAChD,SAAS,EAAE,SAAS,4BAA4B;CAChD,oBAAoB,EAAE,SAAS,uCAAuC;CACtE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,GAAG,CAAC,CAAC;CACzD,mBAAmB,EAAE,SAAS,2BAA2B;CACzD,6BAA6B,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;AAC9D,CAAC;AAID,MAAa,mCAAmC,EAAE,OAAO;CACrD,OAAO,EAAE,SAAS,kBAAkB;CACpC,eAAeK;AACnB,CAAC"}
1
+ {"version":3,"file":"address-book.schemas.js","names":["Proto.AccountScopeType","Proto.DestinationWhitelistStatus","Proto.AddressBookEntryKind","Proto.TransferCounterpartyDirection","Proto.InternalWhitelistResolutionStatus","RequiredTimestampMsSchema"],"sources":["../../../src/services/address-book/address-book.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport * as Proto from \"../../gen/auth/v1/address_book_pb.js\";\nimport { SubaccountRole } from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport {\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampMsSchema as RequiredTimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport {\n ADDRESS_BOOK_ENTRY_KIND_VALUES,\n AccountScopeTypeCodec,\n AddressBookEntryKindCodec,\n DestinationWhitelistStatusCodec,\n InternalWhitelistResolutionStatusCodec,\n TRANSFER_COUNTERPARTY_DIRECTION_VALUES,\n TransferCounterpartyDirectionCodec,\n} from \"./address-book.codecs.js\";\nimport { SubaccountRoleCodec } from \"../subaccounts/subaccounts.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst OptionalSubaccountIdSchema = optionalSubaccountIdInputSchema();\nconst IdSchema = idInputSchema;\n\nconst AddressBookLimitSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(500)),\n);\nconst AddressBookCounterpartyLimitSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(200)),\n);\nconst AddressBookViewLimitSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(200)),\n);\nconst PageTokenSchema = v.optional(v.pipe(v.string(), v.trim()), \"\");\n\nconst TimestampMsSchema = OptionalTimestampMsSchema;\n\nconst AddressBookTagInputSchema = v.strictObject({\n name: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(48)),\n color: v.optional(v.pipe(v.string(), v.trim(), v.maxLength(32)), \"\"),\n});\nconst AddressBookTagInputsSchema = v.pipe(v.array(AddressBookTagInputSchema), v.maxLength(10));\n\nexport const ListAddressBookEntriesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n kind: v.optional(v.picklist(ADDRESS_BOOK_ENTRY_KIND_VALUES)),\n limit: AddressBookLimitSchema,\n pageToken: PageTokenSchema,\n }),\n v.transform(({ account, kind, limit, pageToken }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n kind: kind ? AddressBookEntryKindCodec.inputToProto[kind] : undefined,\n limit,\n pageToken,\n })),\n);\n\nexport type ListAddressBookEntriesInput = v.InferInput<typeof ListAddressBookEntriesInputSchema>;\n\nexport const CreateAddressBookEntryInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n label: v.pipe(v.string(), v.trim(), v.minLength(1)),\n note: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n entry: v.variant(\"kind\", [\n v.strictObject({\n kind: v.literal(\"external\"),\n polychainChainId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n address: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.strictObject({\n kind: v.literal(\"internal\"),\n smartAccountAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n ]),\n tagIds: v.optional(v.array(IdSchema(\"tagId\")), []),\n newTags: v.optional(AddressBookTagInputsSchema, []),\n }),\n v.transform(({ account, entry, ...rest }) => ({\n ...rest,\n subaccountId: accountScopeToSubaccountId(account),\n entry:\n entry.kind === \"external\"\n ? {\n case: \"external\" as const,\n value: {\n polychainChainId: entry.polychainChainId,\n address: entry.address,\n },\n }\n : {\n case: \"internal\" as const,\n value: {\n smartAccountAddress: entry.smartAccountAddress,\n },\n },\n })),\n);\n\nexport type CreateAddressBookEntryInput = v.InferInput<typeof CreateAddressBookEntryInputSchema>;\n\nexport function validateCreateAddressBookEntryInput(input: CreateAddressBookEntryInput): void {\n parse(CreateAddressBookEntryInputSchema, input);\n}\n\ntype AddressBookEntryPatch = {\n label?: string;\n note?: string;\n tagIds?: bigint[];\n newTags?: v.InferOutput<typeof AddressBookTagInputSchema>[];\n};\n\nconst ADDRESS_BOOK_ENTRY_PATCH_FIELDS = defineProtoPatchFields<AddressBookEntryPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n note: { path: \"note\", encode: (note) => ({ note }) },\n tagIds: { path: \"tag_ids\", encode: (tagIds) => ({ tagIds }) },\n newTags: { path: \"new_tags\", encode: (newTags) => ({ newTags }) },\n});\n\nexport const UpdateAddressBookEntryInputSchema = v.pipe(\n v.strictObject({\n addressBookEntryId: IdSchema(\"addressBookEntryId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.pipe(v.string(), v.trim())),\n note: v.optional(v.pipe(v.string(), v.trim())),\n tagIds: v.optional(v.array(IdSchema(\"tagId\"))),\n newTags: v.optional(AddressBookTagInputsSchema),\n }),\n v.check(\n ({ label, note, tagIds, newTags }) =>\n label !== undefined ||\n note !== undefined ||\n tagIds !== undefined ||\n newTags !== undefined,\n \"At least one address-book entry field must be provided\",\n ),\n v.transform(({ addressBookEntryId, expectedRevision, ...input }) => {\n const { patch: entry, updateMask } = buildProtoPatch(\n input,\n ADDRESS_BOOK_ENTRY_PATCH_FIELDS,\n );\n return { addressBookEntryId, entry, updateMask, expectedRevision };\n }),\n);\n\nexport type UpdateAddressBookEntryInput = v.InferInput<typeof UpdateAddressBookEntryInputSchema>;\n\nexport const DeleteAddressBookEntryInputSchema = v.strictObject({\n addressBookEntryId: IdSchema(\"addressBookEntryId\"),\n});\n\nexport type DeleteAddressBookEntryInput = v.InferInput<typeof DeleteAddressBookEntryInputSchema>;\n\nexport const CopyAddressBookEntryInputSchema = v.strictObject({\n addressBookEntryId: IdSchema(\"addressBookEntryId\"),\n targetSubaccountId: OptionalSubaccountIdSchema,\n});\n\nexport type CopyAddressBookEntryInput = v.InferInput<typeof CopyAddressBookEntryInputSchema>;\n\nexport const CreateAddressBookTagInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n name: v.pipe(v.string(), v.trim(), v.minLength(1)),\n color: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type CreateAddressBookTagInput = v.InferInput<typeof CreateAddressBookTagInputSchema>;\n\nexport const UpdateAddressBookTagInputSchema = v.pipe(\n v.strictObject({\n tagId: IdSchema(\"tagId\"),\n name: v.optional(v.pipe(v.string(), v.trim(), v.minLength(1))),\n color: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.check(\n ({ name, color }) => name !== undefined || color !== undefined,\n \"At least one address-book tag field must be provided\",\n ),\n);\n\nexport type UpdateAddressBookTagInput = v.InferInput<typeof UpdateAddressBookTagInputSchema>;\n\nexport const DeleteAddressBookTagInputSchema = v.strictObject({\n tagId: IdSchema(\"tagId\"),\n});\n\nexport type DeleteAddressBookTagInput = v.InferInput<typeof DeleteAddressBookTagInputSchema>;\n\nexport const ListTransferCounterpartiesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n direction: v.optional(v.picklist(TRANSFER_COUNTERPARTY_DIRECTION_VALUES)),\n kind: v.optional(v.picklist(ADDRESS_BOOK_ENTRY_KIND_VALUES)),\n limit: AddressBookCounterpartyLimitSchema,\n }),\n v.transform(({ account, direction, kind, limit }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n direction: direction\n ? TransferCounterpartyDirectionCodec.inputToProto[direction]\n : undefined,\n kind: kind ? AddressBookEntryKindCodec.inputToProto[kind] : undefined,\n limit,\n })),\n);\n\nexport type ListTransferCounterpartiesInput = v.InferInput<\n typeof ListTransferCounterpartiesInputSchema\n>;\n\nexport const ListTransferDestinationsInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n kind: v.optional(v.picklist(ADDRESS_BOOK_ENTRY_KIND_VALUES)),\n limit: AddressBookLimitSchema,\n pageToken: PageTokenSchema,\n }),\n v.transform(({ account, kind, limit, pageToken }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n kind: kind ? AddressBookEntryKindCodec.inputToProto[kind] : undefined,\n limit,\n pageToken,\n })),\n);\n\nexport type ListTransferDestinationsInput = v.InferInput<\n typeof ListTransferDestinationsInputSchema\n>;\n\nexport const SubaccountScopedInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type SubaccountScopedInput = v.InferInput<typeof SubaccountScopedInputSchema>;\n\nexport const ListInternalTransferWhitelistEntriesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n limit: AddressBookLimitSchema,\n pageToken: PageTokenSchema,\n }),\n v.transform(({ account, limit, pageToken }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n limit,\n pageToken,\n })),\n);\n\nexport type ListInternalTransferWhitelistEntriesInput = v.InferInput<\n typeof ListInternalTransferWhitelistEntriesInputSchema\n>;\n\nexport const GetAddressBookViewInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n limit: AddressBookViewLimitSchema,\n /** Minimum `viewRevision` (from an invalidation event) the returned view must reach. */\n minimumViewRevision: v.optional(positiveBigintStringInputSchema(\"minimumViewRevision\")),\n }),\n v.transform(({ account, limit, minimumViewRevision }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n limit,\n minimumViewRevision,\n })),\n);\n\nexport type GetAddressBookViewInput = v.InferInput<typeof GetAddressBookViewInputSchema>;\n\nconst CountSchema = v.pipe(\n v.bigint(),\n v.transform((value) => Number(value)),\n);\n\nconst AccountScopeSchema = v.object({\n scopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.AccountScopeSchema\",\n \"scope type\",\n ),\n ),\n ),\n rootAccountId: PublicIdSchema,\n subaccountId: PublicIdSchema,\n});\n\nconst ExternalWithdrawAddressSchema = v.object({\n polychainChainId: v.pipe(v.number(), v.integer()),\n address: v.string(),\n});\n\nconst InternalTransferAccountSchema = v.object({\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.InternalTransferAccountSchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n});\n\nconst AddressBookEntryValueSchema = v.variant(\"case\", [\n v.object({ case: v.literal(\"external\"), value: ExternalWithdrawAddressSchema }),\n v.object({ case: v.literal(\"internal\"), value: InternalTransferAccountSchema }),\n v.object({ case: v.undefined(), value: v.optional(v.undefined()) }),\n]);\n\nconst DestinationWhitelistStatusSchema = v.pipe(\n v.enum(Proto.DestinationWhitelistStatus),\n v.transform((value) =>\n requiredEnumLabel(\n DestinationWhitelistStatusCodec.protoToOutput,\n value,\n \"PolyesterClient.DestinationWhitelistStatusSchema\",\n \"whitelist status\",\n ),\n ),\n);\n\nconst AddressBookEntryKindSchema = v.pipe(\n v.enum(Proto.AddressBookEntryKind),\n v.transform((value) =>\n requiredEnumLabel(\n AddressBookEntryKindCodec.protoToOutput,\n value,\n \"PolyesterClient.AddressBookEntryKindSchema\",\n \"entry kind\",\n ),\n ),\n);\n\nconst TransferCounterpartyDirectionSchema = v.pipe(\n v.enum(Proto.TransferCounterpartyDirection),\n v.transform((value) =>\n requiredEnumLabel(\n TransferCounterpartyDirectionCodec.protoToOutput,\n value,\n \"PolyesterClient.TransferCounterpartyDirectionSchema\",\n \"direction\",\n ),\n ),\n);\n\nexport const AddressBookSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n callerRole: v.pipe(\n v.enum(SubaccountRole),\n v.transform((role) =>\n requiredEnumLabel(\n SubaccountRoleCodec.protoToOutput,\n role,\n \"AddressBookEntrySchema\",\n \"caller role\",\n ),\n ),\n ),\n label: v.string(),\n ownerUsername: v.string(),\n smartAccountAddress: v.string(),\n});\n\nexport type AddressBook = v.InferOutput<typeof AddressBookSchema>;\n\nexport const AddressBookTagSummarySchema = v.object({\n tagId: PublicIdSchema,\n name: v.string(),\n color: v.string(),\n});\n\nexport type AddressBookTagSummary = v.InferOutput<typeof AddressBookTagSummarySchema>;\n\nexport const AddressBookTagSchema = v.object({\n tagId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n name: v.string(),\n color: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n});\n\nexport type AddressBookTag = v.InferOutput<typeof AddressBookTagSchema>;\n\nexport const AddressBookEntrySchema = v.object({\n addressBookEntryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n kind: AddressBookEntryKindSchema,\n label: v.string(),\n note: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n entry: AddressBookEntryValueSchema,\n tags: v.array(AddressBookTagSchema),\n revision: BigIntStringSchema,\n});\n\nexport type AddressBookEntry = v.InferOutput<typeof AddressBookEntrySchema>;\n\nexport const AddressBookEntriesSchema = v.array(AddressBookEntrySchema);\nexport type AddressBookEntries = v.InferOutput<typeof AddressBookEntriesSchema>;\n\nexport const TransferCounterpartySchema = v.object({\n counterpartyId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n direction: TransferCounterpartyDirectionSchema,\n kind: AddressBookEntryKindSchema,\n saved: v.boolean(),\n addressBookEntryId: PublicIdSchema,\n useCount: CountSchema,\n firstSeenAt: TimestampMsSchema,\n lastSeenAt: TimestampMsSchema,\n counterparty: AddressBookEntryValueSchema,\n});\n\nexport type TransferCounterparty = v.InferOutput<typeof TransferCounterpartySchema>;\n\nexport const TransferCounterpartiesSchema = v.array(TransferCounterpartySchema);\nexport type TransferCounterparties = v.InferOutput<typeof TransferCounterpartiesSchema>;\n\nexport const TransferDestinationSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n kind: AddressBookEntryKindSchema,\n saved: v.boolean(),\n whitelisted: v.boolean(),\n whitelistStatus: DestinationWhitelistStatusSchema,\n addressBookEntry: v.optional(AddressBookEntrySchema),\n destination: AddressBookEntryValueSchema,\n whitelistEffectiveAt: TimestampMsSchema,\n whitelistUpdatedAt: TimestampMsSchema,\n});\n\nexport type TransferDestination = v.InferOutput<typeof TransferDestinationSchema>;\n\nexport const TransferDestinationsSchema = v.array(TransferDestinationSchema);\nexport type TransferDestinations = v.InferOutput<typeof TransferDestinationsSchema>;\n\nexport const InternalTransferWhitelistEntrySchema = v.object({\n entryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.InternalTransferWhitelistEntrySchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n resolutionStatus: v.pipe(\n v.enum(Proto.InternalWhitelistResolutionStatus),\n v.transform((value) =>\n requiredEnumLabel(\n InternalWhitelistResolutionStatusCodec.protoToOutput,\n value,\n \"PolyesterClient.InternalTransferWhitelistEntrySchema\",\n \"resolution status\",\n ),\n ),\n ),\n});\n\nexport type InternalTransferWhitelistEntry = v.InferOutput<\n typeof InternalTransferWhitelistEntrySchema\n>;\n\nexport const InternalTransferWhitelistEntriesSchema = v.array(InternalTransferWhitelistEntrySchema);\n\nexport type InternalTransferWhitelistEntries = v.InferOutput<\n typeof InternalTransferWhitelistEntriesSchema\n>;\n\nexport const MirroredWithdrawWhitelistEntrySchema = v.object({\n canonicalAddress: v.string(),\n rawAddressHex: v.string(),\n updatedAt: TimestampMsSchema,\n polychainChainId: v.pipe(v.number(), v.integer()),\n});\n\nexport type MirroredWithdrawWhitelistEntry = v.InferOutput<\n typeof MirroredWithdrawWhitelistEntrySchema\n>;\n\nexport const WithdrawWhitelistViewSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n externalWhitelistRequired: v.boolean(),\n internalWhitelistRequired: v.boolean(),\n activeEntries: v.optional(v.array(MirroredWithdrawWhitelistEntrySchema), []),\n});\n\nexport type WithdrawWhitelistView = v.InferOutput<typeof WithdrawWhitelistViewSchema>;\n\nexport const AddressBookEntriesViewSchema = v.object({\n external: v.optional(\n v.array(\n v.object({\n addressBookEntryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n label: v.string(),\n note: v.string(),\n tagIds: v.optional(v.array(PublicIdSchema), []),\n whitelistStatus: DestinationWhitelistStatusSchema,\n polychainChainId: v.pipe(v.number(), v.integer()),\n address: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n revision: BigIntStringSchema,\n }),\n ),\n [],\n ),\n internal: v.optional(\n v.array(\n v.object({\n addressBookEntryId: PublicIdSchema,\n scope: v.optional(AccountScopeSchema),\n label: v.string(),\n note: v.string(),\n tagIds: v.optional(v.array(PublicIdSchema), []),\n whitelistStatus: DestinationWhitelistStatusSchema,\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.AddressBookEntriesViewSchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n createdAt: TimestampMsSchema,\n updatedAt: TimestampMsSchema,\n revision: BigIntStringSchema,\n }),\n ),\n [],\n ),\n});\n\nexport type AddressBookEntriesView = v.InferOutput<typeof AddressBookEntriesViewSchema>;\n\nexport const AddressBookRecentDestinationsViewSchema = v.object({\n external: v.optional(\n v.array(\n v.object({\n scope: v.optional(AccountScopeSchema),\n lastDirection: TransferCounterpartyDirectionSchema,\n saved: v.boolean(),\n addressBookEntryId: PublicIdSchema,\n useCount: CountSchema,\n lastSeenAt: TimestampMsSchema,\n polychainChainId: v.pipe(v.number(), v.integer()),\n address: v.string(),\n }),\n ),\n [],\n ),\n internal: v.optional(\n v.array(\n v.object({\n scope: v.optional(AccountScopeSchema),\n lastDirection: TransferCounterpartyDirectionSchema,\n saved: v.boolean(),\n addressBookEntryId: PublicIdSchema,\n useCount: CountSchema,\n lastSeenAt: TimestampMsSchema,\n rootAccountId: PublicIdSchema,\n targetAccountId: PublicIdSchema,\n targetScopeType: v.pipe(\n v.enum(Proto.AccountScopeType),\n v.transform((value) =>\n requiredEnumLabel(\n AccountScopeTypeCodec.protoToOutput,\n value,\n \"PolyesterClient.AddressBookRecentDestinationsViewSchema\",\n \"target scope type\",\n ),\n ),\n ),\n smartAccountAddress: v.string(),\n rootUsername: v.string(),\n subaccountLabel: v.string(),\n }),\n ),\n [],\n ),\n});\n\nexport type AddressBookRecentDestinationsView = v.InferOutput<\n typeof AddressBookRecentDestinationsViewSchema\n>;\n\nexport const AddressBookViewSchema = v.object({\n books: v.optional(v.array(AddressBookSchema), []),\n entries: v.optional(AddressBookEntriesViewSchema),\n recentDestinations: v.optional(AddressBookRecentDestinationsViewSchema),\n tags: v.optional(v.array(AddressBookTagSummarySchema), []),\n withdrawWhitelist: v.optional(WithdrawWhitelistViewSchema),\n recentDestinationsTruncated: v.optional(v.boolean(), false),\n viewRevision: v.optional(BigIntStringSchema, 0n),\n});\n\nexport type AddressBookView = v.InferOutput<typeof AddressBookViewSchema>;\n\nexport const AddressBookViewInvalidatedSchema = v.object({\n scope: v.optional(AccountScopeSchema),\n invalidatedAt: RequiredTimestampMsSchema,\n viewRevision: v.optional(BigIntStringSchema, 0n),\n});\n\nexport type AddressBookViewInvalidated = v.InferOutput<typ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 -1,3 +1,4 @@
1
+ import { AuthApiTransports } from "../../shared/transports.js";
1
2
  import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js";
2
3
  import { SubaccountResolver } from "../subaccount-resolver.js";
3
4
  import { PolyesterRealtime } from "../../realtime/types.js";
@@ -6,7 +7,6 @@ import { BaseSubscribeInput } from "../../shared/types.js";
6
7
  import { ApiKeyPoliciesService } from "../policies/api-key-policies/api-key-policies.js";
7
8
  import "../policies/api-key-policies/index.js";
8
9
  import { ApiKey, ApiKeyIdInputSchema, ApiKeysCreateInputSchema, ApiKeysListInputSchema, ApiKeysUpdateInputSchema } from "./api-keys.schemas.js";
9
- import { Transport } from "@connectrpc/connect";
10
10
  import * as v from "valibot";
11
11
  //#region src/services/api-keys/api-keys.d.ts
12
12
  interface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {
@@ -18,7 +18,7 @@ interface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {
18
18
  declare class ApiKeysService {
19
19
  #private;
20
20
  readonly policies: ApiKeyPoliciesService;
21
- constructor(transport: Transport, realtime: PolyesterRealtime, resolver?: SubaccountResolver);
21
+ constructor(transports: AuthApiTransports, realtime: PolyesterRealtime, resolver?: SubaccountResolver);
22
22
  /**
23
23
  * Returns non-revoked API keys owned by the caller, newest first, optionally scoped through an explicit or resolver-provided subaccount ID.
24
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.d.ts","names":[],"sources":["../../../src/services/api-keys/api-keys.ts"],"mappings":";;;;;;;;;;;UA0BU,8BAA8B,mBAAmB;EACvD;;;;;cAMS;;WACA,UAAU;EAMP,YAAA,WAAW,WAAW,UAAU,mBAAmB,WAAW;;;;EAUpE,KACF,SAAQ,EAAE,kBAAkB,yBAC5B,UAAU,0BACX,QAAQ;;;;EAcL,IACF,OAAO,EAAE,kBAAkB,sBAC3B,UAAU,0BACX,QAAQ;;;;EASL,OACF,SAAS,EAAE,kBAAkB,2BAC7B,UAAU,2BACX,QAAQ;;;;EAaL,OACF,OAAO,EAAE,kBAAkB,sBAC3B,UAAU,2BACX;;;;EAQG,OACF,SAAS,EAAE,kBAAkB,2BAC7B,UAAU,2BACX,QAAQ;;;;EAYL,mBAAmB;IACrB;MAAa;MAAa,OAAO;;IACjC;MAAa;MAAa,OAAO;;;;;;EAkBrC,UAAU,OAAO"}
1
+ {"version":3,"file":"api-keys.d.ts","names":[],"sources":["../../../src/services/api-keys/api-keys.ts"],"mappings":";;;;;;;;;;;UA2BU,8BAA8B,mBAAmB;EACvD;;;;;cAMS;;WACA,UAAU;EAOf,YAAA,YAAY,mBACZ,UAAU,mBACV,WAAW;;;;EAWT,KACF,SAAQ,EAAE,kBAAkB,yBAC5B,UAAU,0BACX,QAAQ;;;;EAcL,IACF,OAAO,EAAE,kBAAkB,sBAC3B,UAAU,0BACX,QAAQ;;;;EASL,OACF,SAAS,EAAE,kBAAkB,2BAC7B,UAAU,2BACX,QAAQ;;;;EAaL,OACF,OAAO,EAAE,kBAAkB,sBAC3B,UAAU,2BACX;;;;EAQG,OACF,SAAS,EAAE,kBAAkB,2BAC7B,UAAU,2BACX,QAAQ;;;;EAYL,mBAAmB;IACrB;MAAa;MAAa,OAAO;;IACjC;MAAa;MAAa,OAAO;;;;;;EAkBrC,UAAU,OAAO"}
@@ -17,9 +17,9 @@ var ApiKeysService = class {
17
17
  #client;
18
18
  #realtime;
19
19
  #resolver;
20
- constructor(transport, realtime, resolver) {
21
- this.policies = new ApiKeyPoliciesService(transport);
22
- this.#client = createClient(ApiKeyService, transport);
20
+ constructor(transports, realtime, resolver) {
21
+ this.policies = new ApiKeyPoliciesService(transports);
22
+ this.#client = createClient(ApiKeyService, transports.authApi);
23
23
  this.#realtime = realtime;
24
24
  this.#resolver = resolver;
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api-keys.js","names":["#client","Proto.ApiKeyService","#realtime","#resolver","ApiKeySchema","Proto.ApiKeySchema"],"sources":["../../../src/services/api-keys/api-keys.ts"],"sourcesContent":["import { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/api_keys_pb.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport { bytesToHex } from \"@noble/hashes/utils.js\";\nimport { keygenAsync } from \"@noble/ed25519\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport { ApiKeyPoliciesService } from \"../policies/api-key-policies/index.js\";\nimport {\n ApiKeyIdInputSchema,\n ApiKeysListInputSchema,\n ApiKeysCreateInputSchema,\n ApiKeysUpdateInputSchema,\n ApiKeySchema,\n ApiKeysSchema,\n type ApiKey,\n} from \"./api-keys.schemas.js\";\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Manages API key metadata, client-generated Ed25519 keypairs, policies, and realtime API key updates.\n */\nexport class ApiKeysService {\n readonly policies: ApiKeyPoliciesService;\n\n #client: Client<typeof Proto.ApiKeyService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n\n constructor(transport: Transport, realtime: PolyesterRealtime, resolver?: SubaccountResolver) {\n this.policies = new ApiKeyPoliciesService(transport);\n this.#client = createClient(Proto.ApiKeyService, transport);\n this.#realtime = realtime;\n this.#resolver = resolver;\n }\n\n /**\n * Returns non-revoked API keys owned by the caller, newest first, optionally scoped through an explicit or resolver-provided subaccount ID.\n */\n async list(\n params: v.InferInput<typeof ApiKeysListInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<ApiKey[]> {\n const resolved = resolveAccountScopedInput(params, this.#resolver);\n const validatedParams = parse(ApiKeysListInputSchema, resolved);\n const res = await this.#client.listApiKeys(\n removeUndefined(validatedParams),\n toConnectCallOptions(options),\n );\n\n return parse(ApiKeysSchema, res.apiKeys);\n }\n\n /**\n * Fetches one caller-owned API key by ak_... key ID and returns null when no matching key is returned.\n */\n async get(\n input: v.InferInput<typeof ApiKeyIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<ApiKey | null> {\n const validatedInput = parse(ApiKeyIdInputSchema, input);\n const res = await this.#client.getApiKey(validatedInput, toConnectCallOptions(options));\n return res.apiKey ? parse(ApiKeySchema, res.apiKey) : null;\n }\n\n /**\n * Creates API key metadata using a client-generated Ed25519 public key; security settings may require MFA fresh step-up and retrying with stepUpToken.\n */\n async create(\n payload: v.InferInput<typeof ApiKeysCreateInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<ApiKey | null> {\n const resolved = resolveAccountScopedInput(payload, this.#resolver);\n const validatedPayload = parse(ApiKeysCreateInputSchema, resolved);\n const res = await this.#client.createApiKey(\n removeUndefined(validatedPayload),\n toConnectCallOptions(options),\n );\n return res.apiKey ? parse(ApiKeySchema, res.apiKey) : null;\n }\n\n /**\n * Permanently revokes the specified API key; revoked keys cannot authenticate again.\n */\n async delete(\n input: v.InferInput<typeof ApiKeyIdInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<void> {\n const validatedInput = parse(ApiKeyIdInputSchema, input);\n await this.#client.deleteApiKey(validatedInput, toConnectCallOptions(options));\n }\n\n /**\n * Updates mutable key metadata, ACTIVE/DISABLED status, IP whitelist replacement/clearing, and optional expiry; revocation must use delete.\n */\n async update(\n payload: v.InferInput<typeof ApiKeysUpdateInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<ApiKey | null> {\n const validatedPayload = parse(ApiKeysUpdateInputSchema, payload);\n const res = await this.#client.updateApiKey(\n removeUndefined(validatedPayload),\n toConnectCallOptions(options),\n );\n return res.apiKey ? parse(ApiKeySchema, res.apiKey) : null;\n }\n\n /**\n * Generates an Ed25519 keypair locally and returns public and secret key material as both hex strings and byte arrays; only the public key should be sent to the API.\n */\n async generateKeypair(): Promise<{\n publicKey: { hex: string; bytes: Uint8Array };\n secretKey: { hex: string; bytes: Uint8Array };\n }> {\n const { secretKey, publicKey } = await keygenAsync();\n return {\n publicKey: {\n hex: bytesToHex(publicKey),\n bytes: publicKey,\n },\n secretKey: {\n hex: bytesToHex(secretKey),\n bytes: secretKey,\n },\n };\n }\n\n /**\n * Subscribes to private API key updates for an account and emits normalized API key metadata from realtime protobuf publications.\n */\n subscribe(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.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":";;;;;;;;;;;;;;AAiCA,IAAa,iBAAb,MAA4B;CACxB;CAEA;CACA;CACA;CAEA,YAAY,WAAsB,UAA6B,UAA+B;EAC1F,KAAK,WAAW,IAAI,sBAAsB,SAAS;EACnD,KAAKA,UAAU,aAAaC,eAAqB,SAAS;EAC1D,KAAKC,YAAY;EACjB,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,KACF,SAAsD,CAAC,GACvD,SACiB;EACjB,MAAM,WAAW,0BAA0B,QAAQ,KAAKA,SAAS;EACjE,MAAM,kBAAkB,MAAM,wBAAwB,QAAQ;EAC9D,MAAM,MAAM,MAAM,KAAKH,QAAQ,YAC3B,gBAAgB,eAAe,GAC/B,qBAAqB,OAAO,CAChC;EAEA,OAAO,MAAM,eAAe,IAAI,OAAO;CAC3C;;;;CAKA,MAAM,IACF,OACA,SACsB;EACtB,MAAM,iBAAiB,MAAM,qBAAqB,KAAK;EACvD,MAAM,MAAM,MAAM,KAAKA,QAAQ,UAAU,gBAAgB,qBAAqB,OAAO,CAAC;EACtF,OAAO,IAAI,SAAS,MAAMI,gBAAc,IAAI,MAAM,IAAI;CAC1D;;;;CAKA,MAAM,OACF,SACA,SACsB;EACtB,MAAM,WAAW,0BAA0B,SAAS,KAAKD,SAAS;EAClE,MAAM,mBAAmB,MAAM,0BAA0B,QAAQ;EACjE,MAAM,MAAM,MAAM,KAAKH,QAAQ,aAC3B,gBAAgB,gBAAgB,GAChC,qBAAqB,OAAO,CAChC;EACA,OAAO,IAAI,SAAS,MAAMI,gBAAc,IAAI,MAAM,IAAI;CAC1D;;;;CAKA,MAAM,OACF,OACA,SACa;EACb,MAAM,iBAAiB,MAAM,qBAAqB,KAAK;EACvD,MAAM,KAAKJ,QAAQ,aAAa,gBAAgB,qBAAqB,OAAO,CAAC;CACjF;;;;CAKA,MAAM,OACF,SACA,SACsB;EACtB,MAAM,mBAAmB,MAAM,0BAA0B,OAAO;EAChE,MAAM,MAAM,MAAM,KAAKA,QAAQ,aAC3B,gBAAgB,gBAAgB,GAChC,qBAAqB,OAAO,CAChC;EACA,OAAO,IAAI,SAAS,MAAMI,gBAAc,IAAI,MAAM,IAAI;CAC1D;;;;CAKA,MAAM,kBAGH;EACC,MAAM,EAAE,WAAW,cAAc,MAAM,YAAY;EACnD,OAAO;GACH,WAAW;IACP,KAAK,WAAW,SAAS;IACzB,OAAO;GACX;GACA,WAAW;IACP,KAAK,WAAW,SAAS;IACzB,OAAO;GACX;EACJ;CACJ;;;;CAKA,UAAU,OAA8B;EACpC,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKF,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMD,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":"api-keys.js","names":["#client","Proto.ApiKeyService","#realtime","#resolver","ApiKeySchema","Proto.ApiKeySchema"],"sources":["../../../src/services/api-keys/api-keys.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/api_keys_pb.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport { bytesToHex } from \"@noble/hashes/utils.js\";\nimport { keygenAsync } from \"@noble/ed25519\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport { ApiKeyPoliciesService } from \"../policies/api-key-policies/index.js\";\nimport {\n ApiKeyIdInputSchema,\n ApiKeysListInputSchema,\n ApiKeysCreateInputSchema,\n ApiKeysUpdateInputSchema,\n ApiKeySchema,\n ApiKeysSchema,\n type ApiKey,\n} from \"./api-keys.schemas.js\";\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Manages API key metadata, client-generated Ed25519 keypairs, policies, and realtime API key updates.\n */\nexport class ApiKeysService {\n readonly policies: ApiKeyPoliciesService;\n\n #client: Client<typeof Proto.ApiKeyService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n\n constructor(\n transports: AuthApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new ApiKeyPoliciesService(transports);\n this.#client = createClient(Proto.ApiKeyService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n }\n\n /**\n * Returns non-revoked API keys owned by the caller, newest first, optionally scoped through an explicit or resolver-provided subaccount ID.\n */\n async list(\n params: v.InferInput<typeof ApiKeysListInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<ApiKey[]> {\n const resolved = resolveAccountScopedInput(params, this.#resolver);\n const validatedParams = parse(ApiKeysListInputSchema, resolved);\n const res = await this.#client.listApiKeys(\n removeUndefined(validatedParams),\n toConnectCallOptions(options),\n );\n\n return parse(ApiKeysSchema, res.apiKeys);\n }\n\n /**\n * Fetches one caller-owned API key by ak_... key ID and returns null when no matching key is returned.\n */\n async get(\n input: v.InferInput<typeof ApiKeyIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<ApiKey | null> {\n const validatedInput = parse(ApiKeyIdInputSchema, input);\n const res = await this.#client.getApiKey(validatedInput, toConnectCallOptions(options));\n return res.apiKey ? parse(ApiKeySchema, res.apiKey) : null;\n }\n\n /**\n * Creates API key metadata using a client-generated Ed25519 public key; security settings may require MFA fresh step-up and retrying with stepUpToken.\n */\n async create(\n payload: v.InferInput<typeof ApiKeysCreateInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<ApiKey | null> {\n const resolved = resolveAccountScopedInput(payload, this.#resolver);\n const validatedPayload = parse(ApiKeysCreateInputSchema, resolved);\n const res = await this.#client.createApiKey(\n removeUndefined(validatedPayload),\n toConnectCallOptions(options),\n );\n return res.apiKey ? parse(ApiKeySchema, res.apiKey) : null;\n }\n\n /**\n * Permanently revokes the specified API key; revoked keys cannot authenticate again.\n */\n async delete(\n input: v.InferInput<typeof ApiKeyIdInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<void> {\n const validatedInput = parse(ApiKeyIdInputSchema, input);\n await this.#client.deleteApiKey(validatedInput, toConnectCallOptions(options));\n }\n\n /**\n * Updates mutable key metadata, ACTIVE/DISABLED status, IP whitelist replacement/clearing, and optional expiry; revocation must use delete.\n */\n async update(\n payload: v.InferInput<typeof ApiKeysUpdateInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<ApiKey | null> {\n const validatedPayload = parse(ApiKeysUpdateInputSchema, payload);\n const res = await this.#client.updateApiKey(\n removeUndefined(validatedPayload),\n toConnectCallOptions(options),\n );\n return res.apiKey ? parse(ApiKeySchema, res.apiKey) : null;\n }\n\n /**\n * Generates an Ed25519 keypair locally and returns public and secret key material as both hex strings and byte arrays; only the public key should be sent to the API.\n */\n async generateKeypair(): Promise<{\n publicKey: { hex: string; bytes: Uint8Array };\n secretKey: { hex: string; bytes: Uint8Array };\n }> {\n const { secretKey, publicKey } = await keygenAsync();\n return {\n publicKey: {\n hex: bytesToHex(publicKey),\n bytes: publicKey,\n },\n secretKey: {\n hex: bytesToHex(secretKey),\n bytes: secretKey,\n },\n };\n }\n\n /**\n * Subscribes to private API key updates for an account and emits normalized API key metadata from realtime protobuf publications.\n */\n subscribe(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.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":";;;;;;;;;;;;;;AAkCA,IAAa,iBAAb,MAA4B;CACxB;CAEA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,sBAAsB,UAAU;EACpD,KAAKA,UAAU,aAAaC,eAAqB,WAAW,OAAO;EACnE,KAAKC,YAAY;EACjB,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,KACF,SAAsD,CAAC,GACvD,SACiB;EACjB,MAAM,WAAW,0BAA0B,QAAQ,KAAKA,SAAS;EACjE,MAAM,kBAAkB,MAAM,wBAAwB,QAAQ;EAC9D,MAAM,MAAM,MAAM,KAAKH,QAAQ,YAC3B,gBAAgB,eAAe,GAC/B,qBAAqB,OAAO,CAChC;EAEA,OAAO,MAAM,eAAe,IAAI,OAAO;CAC3C;;;;CAKA,MAAM,IACF,OACA,SACsB;EACtB,MAAM,iBAAiB,MAAM,qBAAqB,KAAK;EACvD,MAAM,MAAM,MAAM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}
@@ -1,8 +1,9 @@
1
1
  import { AccountSigner, AccountSignerConfig } from "../../account-signer/types.js";
2
2
  import { PolyesterEnvironment } from "../../environment.js";
3
+ import { AuthAndPublicApiTransports } from "../../shared/transports.js";
3
4
  import { PolyesterRealtime } from "../../realtime/types.js";
4
5
  import "../../realtime/index.js";
5
- import { AuthService, AuthServiceTransports } from "./auth.js";
6
+ import { AuthService } from "./auth.js";
6
7
  import { SubaccountsService } from "../subaccounts/subaccounts.js";
7
8
  import "../subaccounts/index.js";
8
9
  import { AuthTokenStorage } from "./token-storage.js";
@@ -55,7 +56,7 @@ declare class AccountSignerAuthService extends AuthService {
55
56
  #private;
56
57
  readonly events: EventEmitter<AccountSignerAuthEvents>;
57
58
  constructor({ transports, accountSignerConfig, environment, subaccounts, realtime, tokenStorage, sessionStore }: {
58
- transports: AuthServiceTransports;
59
+ transports: AuthAndPublicApiTransports;
59
60
  accountSignerConfig?: AccountSignerConfig;
60
61
  environment: PolyesterEnvironment;
61
62
  subaccounts: SubaccountsService;
@@ -1 +1 @@
1
- {"version":3,"file":"account-signer-auth.d.ts","names":[],"sources":["../../../src/services/auth/account-signer-auth.ts"],"mappings":";;;;;;;;;;;;UAuBiB;EACb;IAAiB;IAAmB;;EACpC;EACA;IAAS;IAAc;;EACvB;EACA,aAAa;;UAGA;EACb;EACA;EACA,WAAW;;UAGE;;;;EAIb;EACA,cAAc;;UAGD;;EAEb,eAAe;;EAEf;;EAEA;;UAGa;EACb;EACA;EACA;;;;;cAWS,iCAAiC;;WACjC,QAAM,aAAA;EAgBH,cACR,YACA,qBACA,aACA,aACA,UACA,cACA;IAEA,YAAY;IACZ,sBAAsB;IACtB,aAAa;IACb,aAAa;IACb,UAAU;IACV,cAAc;IACd,eAAe;;;;;EAmBnB,sBAAsB,aAAa;;;;EAOnC,iBAAiB,eAAe;;;;EAUhC,oBAAoB;;;;EAOd,MAAM,SAAS,eAAe,QAAQ;;;;EA2F5C,iBAAiB,OAAO;;;;EAwBlB,kBAAkB;IAAU;IAAmB;;;;;EA6D/C,UAAU;;;;EAkChB;;;;EASM,eAAe;IACjB;IACA,cAAc;MACd,QAAQ;;;;EAkBZ,cACI,mBACA;IAAY;IAA8B;;IACzC;IAAmB;;;EAuBxB,oBAAoB;;;;EASd,iBAAiB,QAAQ,yBAAyB,QAAQ;;;;EA+ChE,YAAY"}
1
+ {"version":3,"file":"account-signer-auth.d.ts","names":[],"sources":["../../../src/services/auth/account-signer-auth.ts"],"mappings":";;;;;;;;;;;;;UAwBiB;EACb;IAAiB;IAAmB;;EACpC;EACA;IAAS;IAAc;;EACvB;EACA,aAAa;;UAGA;EACb;EACA;EACA,WAAW;;UAGE;;;;EAIb;EACA,cAAc;;UAGD;;EAEb,eAAe;;EAEf;;EAEA;;UAGa;EACb;EACA;EACA;;;;;cAWS,iCAAiC;;WACjC,QAAM,aAAA;EAgBH,cACR,YACA,qBACA,aACA,aACA,UACA,cACA;IAEA,YAAY;IACZ,sBAAsB;IACtB,aAAa;IACb,aAAa;IACb,UAAU;IACV,cAAc;IACd,eAAe;;;;;EAmBnB,sBAAsB,aAAa;;;;EAOnC,iBAAiB,eAAe;;;;EAUhC,oBAAoB;;;;EAOd,MAAM,SAAS,eAAe,QAAQ;;;;EA2F5C,iBAAiB,OAAO;;;;EAwBlB,kBAAkB;IAAU;IAAmB;;;;;EA6D/C,UAAU;;;;EAkChB;;;;EASM,eAAe;IACjB;IACA,cAAc;MACd,QAAQ;;;;EAkBZ,cACI,mBACA;IAAY;IAA8B;;IACzC;IAAmB;;;EAuBxB,oBAAoB;;;;EASd,iBAAiB,QAAQ,yBAAyB,QAAQ;;;;EA+ChE,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"account-signer-auth.js","names":["#accountSignerConfig","#environmentFingerprint","#subaccounts","#tokenStorage","#realtime","#sessionStore","#assertAccountSignerEnvironment","#accountSigner","#accountIdentity","#identityFromSigner","#notifyStateChange","#login","#resolveAccountSigner","#getEnvironmentSession","#loginMethod","#isAuthenticated","#mainAccountId","#activeAccountId","#walletProvider","#getEnvironmentBoundToken","#clearExpiredSessionState","#getCurrentTokenStorageOptions","#resolveRefreshProvider"],"sources":["../../../src/services/auth/account-signer-auth.ts"],"sourcesContent":["import { AuthService, type AuthServiceTransports } from \"./auth.js\";\nimport { AuthenticationError, ConfigurationError } from \"../../shared/errors.js\";\nimport { AuthSessionStore } from \"./session.js\";\nimport type { AccountSigner, AccountSignerConfig, HexAddress } from \"../../account-signer/types.js\";\nimport { assertAccountSigner, resolveAccountSigner } from \"../../account-signer/types.js\";\nimport { EventEmitter } from \"../../utils/event-emitter.js\";\nimport { isJwtValid, getJwtTimeToExpiry } from \"../../utils/jwt.js\";\nimport type { SubaccountsService } from \"../subaccounts/index.js\";\nimport type {\n AuthState,\n AuthHydrationData,\n AuthLoginMethod,\n SessionData,\n ActiveAccountInfo,\n} from \"./session.types.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport type { PolyesterEnvironment } from \"../../environment.js\";\nimport {\n createAuthTokenStorageSetOptions,\n type AuthTokenStorage,\n type AuthTokenStorageSetOptions,\n} from \"./token-storage.js\";\n\nexport interface AccountSignerAuthEvents {\n authenticated: { accountId: string; username: string };\n loggedOut: void;\n error: { code: string; message: string };\n servicesReady: void;\n stateChange: AuthState;\n}\n\nexport interface LoginResult {\n accountId: string;\n username: string;\n expiresAt: Date;\n}\n\nexport interface LoginOptions {\n /**\n * The wallet provider to use for login.\n */\n provider: \"metamask\" | \"turnkey\" | \"other\";\n loginMethod?: AuthLoginMethod | null;\n}\n\nexport interface CreateSubaccountParams {\n /** The account signer for the new subaccount (caller derives this, e.g. via Turnkey saltNonce) */\n accountSigner: AccountSigner;\n /** Optional human-readable label for this subaccount */\n label?: string;\n /** Wallet provider hint (e.g. \"turnkey\", \"metamask\"). Defaults to \"wallet\" */\n walletProvider?: string;\n}\n\nexport interface CreateSubaccountResult {\n subaccountId: string;\n smartAccountSaltNonce: number;\n revision: string;\n}\n\ninterface AccountIdentity {\n accountAddress: HexAddress;\n ownerAddress?: HexAddress;\n}\n\n/**\n * Coordinates wallet/account-signer authentication, session storage, subaccount selection, and session refresh.\n */\nexport class AccountSignerAuthService extends AuthService {\n readonly events = new EventEmitter<AccountSignerAuthEvents>();\n\n #accountSignerConfig: AccountSignerConfig | undefined;\n #accountSigner: AccountSigner | null = null;\n #accountIdentity: AccountIdentity | null = null;\n #isAuthenticated = false;\n #mainAccountId: string | null = null;\n #activeAccountId: string | null = null;\n #subaccounts: SubaccountsService;\n #walletProvider: \"metamask\" | \"turnkey\" | \"other\" | undefined = undefined;\n #loginMethod: AuthLoginMethod | null = null;\n #environmentFingerprint: string;\n #tokenStorage: AuthTokenStorage;\n #sessionStore: AuthSessionStore;\n #realtime: PolyesterRealtime;\n\n constructor({\n transports,\n accountSignerConfig,\n environment,\n subaccounts,\n realtime,\n tokenStorage,\n sessionStore,\n }: {\n transports: AuthServiceTransports;\n accountSignerConfig?: AccountSignerConfig;\n environment: PolyesterEnvironment;\n subaccounts: SubaccountsService;\n realtime: PolyesterRealtime;\n tokenStorage: AuthTokenStorage;\n sessionStore?: AuthSessionStore;\n }) {\n super(transports, realtime);\n\n this.#accountSignerConfig = accountSignerConfig;\n this.#environmentFingerprint = environment.fingerprint;\n this.#subaccounts = subaccounts;\n this.#tokenStorage = tokenStorage;\n this.#realtime = realtime;\n this.#sessionStore =\n sessionStore ??\n new AuthSessionStore({\n environmentFingerprint: environment.fingerprint,\n });\n }\n\n /**\n * Attaches the subaccounts service used when creating a subaccount during authenticated flows.\n */\n setSubaccountsService(subaccounts: SubaccountsService): void {\n this.#subaccounts = subaccounts;\n }\n\n /**\n * Sets the account signer used to sign login and account-switch challenges.\n */\n setAccountSigner(accountSigner: AccountSigner | null): void {\n if (accountSigner) this.#assertAccountSignerEnvironment(accountSigner);\n this.#accountSigner = accountSigner;\n this.#accountIdentity = accountSigner ? this.#identityFromSigner(accountSigner) : null;\n this.#notifyStateChange();\n }\n\n /**\n * Returns the active account signer, throwing if one has not been configured.\n */\n getAccountSigner(): AccountSigner | null {\n return this.#accountSigner;\n }\n\n /**\n * Signs a short-lived login nonce with the configured account signer, exchanges it for a session token, and stores the hydrated account/subaccount session state.\n */\n async login(options: LoginOptions): Promise<LoginResult> {\n return this.#login(options);\n }\n\n async #login(\n options: LoginOptions,\n previousActiveAccount?: ActiveAccountInfo,\n ): Promise<LoginResult> {\n const { provider, loginMethod } = options;\n\n const accountSigner = await this.#resolveAccountSigner();\n\n if (!accountSigner) {\n throw new ConfigurationError(\n \"No account signer configured. Call setAccountSigner() or pass accountSigner in config.\",\n );\n }\n\n const smartAccountAddress = accountSigner.accountAddress;\n const ownerAddress = accountSigner.ownerAddress ?? accountSigner.accountAddress;\n\n const { nonce } = await this.requestLoginNonce(smartAccountAddress);\n\n const message = `Polyester Login\\n\\nNonce: ${nonce}`;\n const signature = await accountSigner.signMessage(message);\n\n const response = await this.loginWithWallet({\n smartAccountAddress,\n nonce,\n signature,\n primaryWalletAddress: ownerAddress,\n walletProvider: provider,\n });\n\n const environmentSession = this.#getEnvironmentSession();\n const resolvedLoginMethod =\n loginMethod ??\n this.#loginMethod ??\n environmentSession?.loginMethod ??\n (provider === \"metamask\" ? \"metamask\" : null);\n\n const tokenOptions = createAuthTokenStorageSetOptions(response.accessToken);\n const activeAccount =\n previousActiveAccount?.mainAccountId === response.accountId\n ? previousActiveAccount\n : undefined;\n this.#sessionStore.commitLogin(\n {\n accessToken: response.accessToken,\n tokenOptions,\n provider,\n loginMethod: resolvedLoginMethod,\n primaryWallet: ownerAddress,\n smartAccount: smartAccountAddress,\n accountId: response.accountId,\n activeAccount,\n username: response.username ?? undefined,\n },\n this.#tokenStorage,\n );\n this.#isAuthenticated = true;\n this.#mainAccountId = response.accountId;\n this.#activeAccountId = activeAccount?.accountId ?? response.accountId;\n this.#walletProvider = provider;\n this.#loginMethod = resolvedLoginMethod;\n this.#accountIdentity = this.#identityFromSigner(accountSigner);\n\n this.#notifyStateChange();\n\n this.events.emit(\"authenticated\", {\n accountId: response.accountId,\n username: response.username,\n });\n\n const expiresAt = response.expiresAt\n ? new Date(\n Number(response.expiresAt.seconds) * 1000 +\n (response.expiresAt.nanos ?? 0) / 1_000_000,\n )\n : new Date();\n\n return {\n accountId: response.accountId,\n username: response.username,\n expiresAt,\n };\n }\n\n /**\n * Builds auth state from a session token and optional active account override.\n */\n hydrateAuthState(state: AuthHydrationData): void {\n const existingToken = this.#getEnvironmentBoundToken();\n if (!existingToken || !isJwtValid(existingToken)) return;\n\n const existingSession = this.#getEnvironmentSession();\n this.#walletProvider = existingSession?.provider ?? this.#walletProvider;\n this.#loginMethod = existingSession?.loginMethod ?? this.#loginMethod;\n\n this.#isAuthenticated = true;\n this.#mainAccountId = state.mainAccountId;\n this.#activeAccountId = state.activeAccountId ?? state.mainAccountId;\n this.#accountIdentity = state.smartAccountAddress\n ? {\n accountAddress: state.smartAccountAddress,\n ownerAddress: state.ownerAddress,\n }\n : null;\n\n this.#notifyStateChange();\n }\n\n /**\n * Loads the stored token, validates that it still belongs to this environment, and restores auth state when possible.\n */\n async restoreSession(): Promise<{ accountId: string; username: string } | null> {\n const existingToken = this.#getEnvironmentBoundToken();\n\n if (!existingToken || !isJwtValid(existingToken)) {\n this.#clearExpiredSessionState();\n return null;\n }\n\n try {\n const me = await this.me();\n this.#isAuthenticated = true;\n this.#mainAccountId = me.accountId;\n\n // preserve active account if already set (e.g. via hydration), otherwise use main\n const existingSession = this.#getEnvironmentSession();\n this.#walletProvider = existingSession?.provider ?? this.#walletProvider;\n this.#loginMethod = existingSession?.loginMethod ?? this.#loginMethod;\n if (!this.#activeAccountId) {\n this.#activeAccountId = existingSession?.activeAccount?.accountId ?? me.accountId;\n }\n\n // use existing account signer if set, otherwise try to resolve from config\n if (!this.#accountSigner) {\n this.#accountSigner = await resolveAccountSigner(this.#accountSignerConfig);\n if (this.#accountSigner) {\n this.#assertAccountSignerEnvironment(this.#accountSigner);\n this.#accountIdentity = this.#identityFromSigner(this.#accountSigner);\n }\n }\n\n // keep the display session available for SSR hydration\n if (this.#accountSigner?.accountAddress) {\n const session = this.#sessionStore.ensureSession(\n {\n provider: this.#walletProvider ? this.#walletProvider : \"other\",\n loginMethod:\n this.#loginMethod ??\n (this.#walletProvider === \"metamask\" ? \"metamask\" : null),\n primaryWallet:\n this.#accountSigner.ownerAddress ?? this.#accountSigner.accountAddress,\n smartAccount: this.#accountSigner.accountAddress,\n accountId: me.accountId,\n username: me.username ?? undefined,\n },\n { maxAgeSeconds: this.#getCurrentTokenStorageOptions().maxAgeSeconds },\n );\n this.#walletProvider = session.provider;\n this.#loginMethod = session.loginMethod ?? this.#loginMethod;\n }\n\n this.#notifyStateChange();\n return { accountId: me.accountId, username: me.username };\n } catch {\n this.#clearExpiredSessionState();\n return null;\n }\n }\n\n /**\n * Clears stored auth state and removes the persisted auth token.\n */\n async logout(): Promise<void> {\n this.#realtime.disconnectPrivate();\n this.#tokenStorage.clear();\n this.#isAuthenticated = false;\n this.#mainAccountId = null;\n this.#activeAccountId = null;\n this.#loginMethod = null;\n this.#accountIdentity = null;\n\n this.#sessionStore.clear();\n\n this.#notifyStateChange();\n this.events.emit(\"loggedOut\", undefined);\n }\n\n #clearExpiredSessionState(): void {\n const shouldEmitLoggedOut = this.#isAuthenticated;\n this.#realtime.disconnectPrivate();\n this.#tokenStorage.clear();\n this.#sessionStore.clear();\n this.#isAuthenticated = false;\n this.#mainAccountId = null;\n this.#activeAccountId = null;\n this.#loginMethod = null;\n this.#accountIdentity = null;\n this.#notifyStateChange();\n if (shouldEmitLoggedOut) {\n this.events.emit(\"loggedOut\", undefined);\n }\n }\n\n /**\n * Returns the remaining lifetime of the stored session token in milliseconds.\n */\n getSessionTimeToExpiry(): number {\n const token = this.#getEnvironmentBoundToken();\n if (!token) return 0;\n return getJwtTimeToExpiry(token);\n }\n\n /**\n * Refreshes the active account-signer session and updates persisted auth state.\n */\n async refreshSession(params?: {\n provider?: \"metamask\" | \"turnkey\" | \"other\";\n loginMethod?: AuthLoginMethod | null;\n }): Promise<LoginResult> {\n if (!this.#isAuthenticated) {\n throw new AuthenticationError(\"Must be authenticated to refresh session\");\n }\n\n const currentSession = this.#getEnvironmentSession();\n return this.#login(\n {\n provider: this.#resolveRefreshProvider(params?.provider),\n loginMethod: params?.loginMethod ?? this.#loginMethod,\n },\n currentSession?.activeAccount,\n );\n }\n\n /**\n * Switches the active account/subaccount by signing the required account switch flow.\n */\n switchAccount(\n accountId: string,\n options?: { smartAccountAddress?: string; label?: string },\n ): { accountId: string; isMain: boolean } {\n if (!this.#isAuthenticated || !this.#mainAccountId) {\n throw new AuthenticationError(\"Must be authenticated to switch accounts\");\n }\n\n this.#activeAccountId = accountId;\n const isMain = accountId === this.#mainAccountId;\n\n this.#sessionStore.setActiveAccount(\n {\n accountId,\n isMain,\n smartAccountAddress: options?.smartAccountAddress,\n label: options?.label,\n },\n { maxAgeSeconds: this.#getCurrentTokenStorageOptions().maxAgeSeconds },\n );\n this.#notifyStateChange();\n\n return { accountId, isMain };\n }\n\n /** Keeps the display-session identity current for the next server render. */\n syncSessionUsername(username: string | null): void {\n this.#sessionStore.setUsername(username, {\n maxAgeSeconds: this.#getCurrentTokenStorageOptions().maxAgeSeconds,\n });\n }\n\n /**\n * Creates a subaccount for the authenticated account and makes it available to the session state.\n */\n async createSubaccount(params: CreateSubaccountParams): Promise<CreateSubaccountResult> {\n if (!this.#isAuthenticated) {\n throw new AuthenticationError(\"Must be authenticated to create subaccounts\");\n }\n\n if (!this.#subaccounts) {\n throw new ConfigurationError(\n \"SubaccountsService not configured. Pass it to constructor or call setSubaccountsService().\",\n );\n }\n\n const { accountSigner, label = \"\", walletProvider = \"wallet\" } = params;\n this.#assertAccountSignerEnvironment(accountSigner);\n\n // request nonce for the subaccount's smart account address\n const { nonce } = await this.requestLoginNonce(accountSigner.accountAddress);\n\n // sign canonical login message with the subaccount account signer\n const message = `Polyester Login\\n\\nNonce: ${nonce}`;\n const signature = await accountSigner.signMessage(message);\n\n // use main account signer's owner address for primary wallet reference\n const primaryWalletAddress =\n this.#accountSigner?.ownerAddress ??\n accountSigner.ownerAddress ??\n this.#accountSigner?.accountAddress ??\n \"\";\n\n const response = await this.#subaccounts.create({\n label,\n smartAccountAddress: accountSigner.accountAddress,\n nonce,\n signature,\n primaryWalletAddress,\n walletProvider,\n });\n\n return {\n subaccountId: response.subaccountId,\n smartAccountSaltNonce: response.smartAccountSaltNonce,\n revision: response.revision,\n };\n }\n\n /**\n * Returns the current account-signer auth state snapshot.\n */\n getState(): AuthState {\n const accountIdentity = this.#accountSigner ?? this.#accountIdentity;\n\n return {\n isAuthenticated: this.#isAuthenticated,\n accountAddress: accountIdentity?.accountAddress ?? null,\n ownerAddress: accountIdentity?.ownerAddress ?? null,\n mainAccountId: this.#mainAccountId,\n activeAccount:\n this.#activeAccountId && this.#mainAccountId\n ? {\n accountId: this.#activeAccountId,\n isMain: this.#activeAccountId === this.#mainAccountId,\n mainAccountId: this.#mainAccountId,\n smartAccountAddress: accountIdentity?.accountAddress,\n }\n : null,\n };\n }\n\n async #resolveAccountSigner(): Promise<AccountSigner | null> {\n if (this.#accountSigner) {\n this.#assertAccountSignerEnvironment(this.#accountSigner);\n return this.#accountSigner;\n }\n\n const resolved = await resolveAccountSigner(this.#accountSignerConfig);\n if (resolved) {\n this.#assertAccountSignerEnvironment(resolved);\n this.#accountSigner = resolved;\n this.#accountIdentity = this.#identityFromSigner(resolved);\n }\n return this.#accountSigner;\n }\n\n #notifyStateChange(): void {\n this.events.emit(\"stateChange\", this.getState());\n }\n\n #getEnvironmentBoundToken(): string | null {\n return this.#sessionStore.getEnvironmentBoundToken(this.#tokenStorage);\n }\n\n #getCurrentTokenStorageOptions(): AuthTokenStorageSetOptions {\n const token = this.#tokenStorage.get();\n if (!token) return { expiresAt: null, maxAgeSeconds: null };\n return createAuthTokenStorageSetOptions(token);\n }\n\n #resolveRefreshProvider(\n provider?: \"metamask\" | \"turnkey\" | \"other\",\n ): \"metamask\" | \"turnkey\" | \"other\" {\n return (\n provider ?? this.#walletProvider ?? this.#getEnvironmentSession()?.provider ?? \"other\"\n );\n }\n\n #assertAccountSignerEnvironment(accountSigner: AccountSigner): void {\n assertAccountSigner(accountSigner);\n if (accountSigner.environmentFingerprint !== this.#environmentFingerprint) {\n throw new ConfigurationError(\n \"Account signer environment does not match client environment.\",\n );\n }\n }\n\n #identityFromSigner(accountSigner: AccountSigner): AccountIdentity {\n return {\n accountAddress: accountSigner.accountAddress,\n ownerAddress: accountSigner.ownerAddress,\n };\n }\n\n #getEnvironmentSession(): SessionData | null {\n return this.#sessionStore.get();\n }\n}\n"],"mappings":";;;;;;;;;;;AAoEA,IAAa,2BAAb,cAA8C,YAAY;CACtD,SAAkB,IAAI,aAAsC;CAE5D;CACA,iBAAuC;CACvC,mBAA2C;CAC3C,mBAAmB;CACnB,iBAAgC;CAChC,mBAAkC;CAClC;CACA,kBAAgE,KAAA;CAChE,eAAuC;CACvC;CACA;CACA;CACA;CAEA,YAAY,EACR,YACA,qBACA,aACA,aACA,UACA,cACA,gBASD;EACC,MAAM,YAAY,QAAQ;EAE1B,KAAKA,uBAAuB;EAC5B,KAAKC,0BAA0B,YAAY;EAC3C,KAAKC,eAAe;EACpB,KAAKC,gBAAgB;EACrB,KAAKC,YAAY;EACjB,KAAKC,gBACD,gBACA,IAAI,iBAAiB,EACjB,wBAAwB,YAAY,YACxC,CAAC;CACT;;;;CAKA,sBAAsB,aAAuC;EACzD,KAAKH,eAAe;CACxB;;;;CAKA,iBAAiB,eAA2C;EACxD,IAAI,eAAe,KAAKI,gCAAgC,aAAa;EACrE,KAAKC,iBAAiB;EACtB,KAAKC,mBAAmB,gBAAgB,KAAKC,oBAAoB,aAAa,IAAI;EAClF,KAAKC,mBAAmB;CAC5B;;;;CAKA,mBAAyC;EACrC,OAAO,KAAKH;CAChB;;;;CAKA,MAAM,MAAM,SAA6C;EACrD,OAAO,KAAKI,OAAO,OAAO;CAC9B;CAEA,MAAMA,OACF,SACA,uBACoB;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Ac;EAChC;CACJ;CAEA,yBAA6C;EACzC,OAAO,KAAKI,cAAc,IAAI;CAClC;AACJ"}
1
+ {"version":3,"file":"account-signer-auth.js","names":["#accountSignerConfig","#environmentFingerprint","#subaccounts","#tokenStorage","#realtime","#sessionStore","#assertAccountSignerEnvironment","#accountSigner","#accountIdentity","#identityFromSigner","#notifyStateChange","#login","#resolveAccountSigner","#getEnvironmentSession","#loginMethod","#isAuthenticated","#mainAccountId","#activeAccountId","#walletProvider","#getEnvironmentBoundToken","#clearExpiredSessionState","#getCurrentTokenStorageOptions","#resolveRefreshProvider"],"sources":["../../../src/services/auth/account-signer-auth.ts"],"sourcesContent":["import { AuthService } from \"./auth.js\";\nimport { AuthenticationError, ConfigurationError } from \"../../shared/errors.js\";\nimport { AuthSessionStore } from \"./session.js\";\nimport type { AccountSigner, AccountSignerConfig, HexAddress } from \"../../account-signer/types.js\";\nimport { assertAccountSigner, resolveAccountSigner } from \"../../account-signer/types.js\";\nimport { EventEmitter } from \"../../utils/event-emitter.js\";\nimport { isJwtValid, getJwtTimeToExpiry } from \"../../utils/jwt.js\";\nimport type { SubaccountsService } from \"../subaccounts/index.js\";\nimport type {\n AuthState,\n AuthHydrationData,\n AuthLoginMethod,\n SessionData,\n ActiveAccountInfo,\n} from \"./session.types.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport type { PolyesterEnvironment } from \"../../environment.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport {\n createAuthTokenStorageSetOptions,\n type AuthTokenStorage,\n type AuthTokenStorageSetOptions,\n} from \"./token-storage.js\";\n\nexport interface AccountSignerAuthEvents {\n authenticated: { accountId: string; username: string };\n loggedOut: void;\n error: { code: string; message: string };\n servicesReady: void;\n stateChange: AuthState;\n}\n\nexport interface LoginResult {\n accountId: string;\n username: string;\n expiresAt: Date;\n}\n\nexport interface LoginOptions {\n /**\n * The wallet provider to use for login.\n */\n provider: \"metamask\" | \"turnkey\" | \"other\";\n loginMethod?: AuthLoginMethod | null;\n}\n\nexport interface CreateSubaccountParams {\n /** The account signer for the new subaccount (caller derives this, e.g. via Turnkey saltNonce) */\n accountSigner: AccountSigner;\n /** Optional human-readable label for this subaccount */\n label?: string;\n /** Wallet provider hint (e.g. \"turnkey\", \"metamask\"). Defaults to \"wallet\" */\n walletProvider?: string;\n}\n\nexport interface CreateSubaccountResult {\n subaccountId: string;\n smartAccountSaltNonce: number;\n revision: string;\n}\n\ninterface AccountIdentity {\n accountAddress: HexAddress;\n ownerAddress?: HexAddress;\n}\n\n/**\n * Coordinates wallet/account-signer authentication, session storage, subaccount selection, and session refresh.\n */\nexport class AccountSignerAuthService extends AuthService {\n readonly events = new EventEmitter<AccountSignerAuthEvents>();\n\n #accountSignerConfig: AccountSignerConfig | undefined;\n #accountSigner: AccountSigner | null = null;\n #accountIdentity: AccountIdentity | null = null;\n #isAuthenticated = false;\n #mainAccountId: string | null = null;\n #activeAccountId: string | null = null;\n #subaccounts: SubaccountsService;\n #walletProvider: \"metamask\" | \"turnkey\" | \"other\" | undefined = undefined;\n #loginMethod: AuthLoginMethod | null = null;\n #environmentFingerprint: string;\n #tokenStorage: AuthTokenStorage;\n #sessionStore: AuthSessionStore;\n #realtime: PolyesterRealtime;\n\n constructor({\n transports,\n accountSignerConfig,\n environment,\n subaccounts,\n realtime,\n tokenStorage,\n sessionStore,\n }: {\n transports: AuthAndPublicApiTransports;\n accountSignerConfig?: AccountSignerConfig;\n environment: PolyesterEnvironment;\n subaccounts: SubaccountsService;\n realtime: PolyesterRealtime;\n tokenStorage: AuthTokenStorage;\n sessionStore?: AuthSessionStore;\n }) {\n super(transports, realtime);\n\n this.#accountSignerConfig = accountSignerConfig;\n this.#environmentFingerprint = environment.fingerprint;\n this.#subaccounts = subaccounts;\n this.#tokenStorage = tokenStorage;\n this.#realtime = realtime;\n this.#sessionStore =\n sessionStore ??\n new AuthSessionStore({\n environmentFingerprint: environment.fingerprint,\n });\n }\n\n /**\n * Attaches the subaccounts service used when creating a subaccount during authenticated flows.\n */\n setSubaccountsService(subaccounts: SubaccountsService): void {\n this.#subaccounts = subaccounts;\n }\n\n /**\n * Sets the account signer used to sign login and account-switch challenges.\n */\n setAccountSigner(accountSigner: AccountSigner | null): void {\n if (accountSigner) this.#assertAccountSignerEnvironment(accountSigner);\n this.#accountSigner = accountSigner;\n this.#accountIdentity = accountSigner ? this.#identityFromSigner(accountSigner) : null;\n this.#notifyStateChange();\n }\n\n /**\n * Returns the active account signer, throwing if one has not been configured.\n */\n getAccountSigner(): AccountSigner | null {\n return this.#accountSigner;\n }\n\n /**\n * Signs a short-lived login nonce with the configured account signer, exchanges it for a session token, and stores the hydrated account/subaccount session state.\n */\n async login(options: LoginOptions): Promise<LoginResult> {\n return this.#login(options);\n }\n\n async #login(\n options: LoginOptions,\n previousActiveAccount?: ActiveAccountInfo,\n ): Promise<LoginResult> {\n const { provider, loginMethod } = options;\n\n const accountSigner = await this.#resolveAccountSigner();\n\n if (!accountSigner) {\n throw new ConfigurationError(\n \"No account signer configured. Call setAccountSigner() or pass accountSigner in config.\",\n );\n }\n\n const smartAccountAddress = accountSigner.accountAddress;\n const ownerAddress = accountSigner.ownerAddress ?? accountSigner.accountAddress;\n\n const { nonce } = await this.requestLoginNonce(smartAccountAddress);\n\n const message = `Polyester Login\\n\\nNonce: ${nonce}`;\n const signature = await accountSigner.signMessage(message);\n\n const response = await this.loginWithWallet({\n smartAccountAddress,\n nonce,\n signature,\n primaryWalletAddress: ownerAddress,\n walletProvider: provider,\n });\n\n const environmentSession = this.#getEnvironmentSession();\n const resolvedLoginMethod =\n loginMethod ??\n this.#loginMethod ??\n environmentSession?.loginMethod ??\n (provider === \"metamask\" ? \"metamask\" : null);\n\n const tokenOptions = createAuthTokenStorageSetOptions(response.accessToken);\n const activeAccount =\n previousActiveAccount?.mainAccountId === response.accountId\n ? previousActiveAccount\n : undefined;\n this.#sessionStore.commitLogin(\n {\n accessToken: response.accessToken,\n tokenOptions,\n provider,\n loginMethod: resolvedLoginMethod,\n primaryWallet: ownerAddress,\n smartAccount: smartAccountAddress,\n accountId: response.accountId,\n activeAccount,\n username: response.username ?? undefined,\n },\n this.#tokenStorage,\n );\n this.#isAuthenticated = true;\n this.#mainAccountId = response.accountId;\n this.#activeAccountId = activeAccount?.accountId ?? response.accountId;\n this.#walletProvider = provider;\n this.#loginMethod = resolvedLoginMethod;\n this.#accountIdentity = this.#identityFromSigner(accountSigner);\n\n this.#notifyStateChange();\n\n this.events.emit(\"authenticated\", {\n accountId: response.accountId,\n username: response.username,\n });\n\n const expiresAt = response.expiresAt\n ? new Date(\n Number(response.expiresAt.seconds) * 1000 +\n (response.expiresAt.nanos ?? 0) / 1_000_000,\n )\n : new Date();\n\n return {\n accountId: response.accountId,\n username: response.username,\n expiresAt,\n };\n }\n\n /**\n * Builds auth state from a session token and optional active account override.\n */\n hydrateAuthState(state: AuthHydrationData): void {\n const existingToken = this.#getEnvironmentBoundToken();\n if (!existingToken || !isJwtValid(existingToken)) return;\n\n const existingSession = this.#getEnvironmentSession();\n this.#walletProvider = existingSession?.provider ?? this.#walletProvider;\n this.#loginMethod = existingSession?.loginMethod ?? this.#loginMethod;\n\n this.#isAuthenticated = true;\n this.#mainAccountId = state.mainAccountId;\n this.#activeAccountId = state.activeAccountId ?? state.mainAccountId;\n this.#accountIdentity = state.smartAccountAddress\n ? {\n accountAddress: state.smartAccountAddress,\n ownerAddress: state.ownerAddress,\n }\n : null;\n\n this.#notifyStateChange();\n }\n\n /**\n * Loads the stored token, validates that it still belongs to this environment, and restores auth state when possible.\n */\n async restoreSession(): Promise<{ accountId: string; username: string } | null> {\n const existingToken = this.#getEnvironmentBoundToken();\n\n if (!existingToken || !isJwtValid(existingToken)) {\n this.#clearExpiredSessionState();\n return null;\n }\n\n try {\n const me = await this.me();\n this.#isAuthenticated = true;\n this.#mainAccountId = me.accountId;\n\n // preserve active account if already set (e.g. via hydration), otherwise use main\n const existingSession = this.#getEnvironmentSession();\n this.#walletProvider = existingSession?.provider ?? this.#walletProvider;\n this.#loginMethod = existingSession?.loginMethod ?? this.#loginMethod;\n if (!this.#activeAccountId) {\n this.#activeAccountId = existingSession?.activeAccount?.accountId ?? me.accountId;\n }\n\n // use existing account signer if set, otherwise try to resolve from config\n if (!this.#accountSigner) {\n this.#accountSigner = await resolveAccountSigner(this.#accountSignerConfig);\n if (this.#accountSigner) {\n this.#assertAccountSignerEnvironment(this.#accountSigner);\n this.#accountIdentity = this.#identityFromSigner(this.#accountSigner);\n }\n }\n\n // keep the display session available for SSR hydration\n if (this.#accountSigner?.accountAddress) {\n const session = this.#sessionStore.ensureSession(\n {\n provider: this.#walletProvider ? this.#walletProvider : \"other\",\n loginMethod:\n this.#loginMethod ??\n (this.#walletProvider === \"metamask\" ? \"metamask\" : null),\n primaryWallet:\n this.#accountSigner.ownerAddress ?? this.#accountSigner.accountAddress,\n smartAccount: this.#accountSigner.accountAddress,\n accountId: me.accountId,\n username: me.username ?? undefined,\n },\n { maxAgeSeconds: this.#getCurrentTokenStorageOptions().maxAgeSeconds },\n );\n this.#walletProvider = session.provider;\n this.#loginMethod = session.loginMethod ?? this.#loginMethod;\n }\n\n this.#notifyStateChange();\n return { accountId: me.accountId, username: me.username };\n } catch {\n this.#clearExpiredSessionState();\n return null;\n }\n }\n\n /**\n * Clears stored auth state and removes the persisted auth token.\n */\n async logout(): Promise<void> {\n this.#realtime.disconnectPrivate();\n this.#tokenStorage.clear();\n this.#isAuthenticated = false;\n this.#mainAccountId = null;\n this.#activeAccountId = null;\n this.#loginMethod = null;\n this.#accountIdentity = null;\n\n this.#sessionStore.clear();\n\n this.#notifyStateChange();\n this.events.emit(\"loggedOut\", undefined);\n }\n\n #clearExpiredSessionState(): void {\n const shouldEmitLoggedOut = this.#isAuthenticated;\n this.#realtime.disconnectPrivate();\n this.#tokenStorage.clear();\n this.#sessionStore.clear();\n this.#isAuthenticated = false;\n this.#mainAccountId = null;\n this.#activeAccountId = null;\n this.#loginMethod = null;\n this.#accountIdentity = null;\n this.#notifyStateChange();\n if (shouldEmitLoggedOut) {\n this.events.emit(\"loggedOut\", undefined);\n }\n }\n\n /**\n * Returns the remaining lifetime of the stored session token in milliseconds.\n */\n getSessionTimeToExpiry(): number {\n const token = this.#getEnvironmentBoundToken();\n if (!token) return 0;\n return getJwtTimeToExpiry(token);\n }\n\n /**\n * Refreshes the active account-signer session and updates persisted auth state.\n */\n async refreshSession(params?: {\n provider?: \"metamask\" | \"turnkey\" | \"other\";\n loginMethod?: AuthLoginMethod | null;\n }): Promise<LoginResult> {\n if (!this.#isAuthenticated) {\n throw new AuthenticationError(\"Must be authenticated to refresh session\");\n }\n\n const currentSession = this.#getEnvironmentSession();\n return this.#login(\n {\n provider: this.#resolveRefreshProvider(params?.provider),\n loginMethod: params?.loginMethod ?? this.#loginMethod,\n },\n currentSession?.activeAccount,\n );\n }\n\n /**\n * Switches the active account/subaccount by signing the required account switch flow.\n */\n switchAccount(\n accountId: string,\n options?: { smartAccountAddress?: string; label?: string },\n ): { accountId: string; isMain: boolean } {\n if (!this.#isAuthenticated || !this.#mainAccountId) {\n throw new AuthenticationError(\"Must be authenticated to switch accounts\");\n }\n\n this.#activeAccountId = accountId;\n const isMain = accountId === this.#mainAccountId;\n\n this.#sessionStore.setActiveAccount(\n {\n accountId,\n isMain,\n smartAccountAddress: options?.smartAccountAddress,\n label: options?.label,\n },\n { maxAgeSeconds: this.#getCurrentTokenStorageOptions().maxAgeSeconds },\n );\n this.#notifyStateChange();\n\n return { accountId, isMain };\n }\n\n /** Keeps the display-session identity current for the next server render. */\n syncSessionUsername(username: string | null): void {\n this.#sessionStore.setUsername(username, {\n maxAgeSeconds: this.#getCurrentTokenStorageOptions().maxAgeSeconds,\n });\n }\n\n /**\n * Creates a subaccount for the authenticated account and makes it available to the session state.\n */\n async createSubaccount(params: CreateSubaccountParams): Promise<CreateSubaccountResult> {\n if (!this.#isAuthenticated) {\n throw new AuthenticationError(\"Must be authenticated to create subaccounts\");\n }\n\n if (!this.#subaccounts) {\n throw new ConfigurationError(\n \"SubaccountsService not configured. Pass it to constructor or call setSubaccountsService().\",\n );\n }\n\n const { accountSigner, label = \"\", walletProvider = \"wallet\" } = params;\n this.#assertAccountSignerEnvironment(accountSigner);\n\n // request nonce for the subaccount's smart account address\n const { nonce } = await this.requestLoginNonce(accountSigner.accountAddress);\n\n // sign canonical login message with the subaccount account signer\n const message = `Polyester Login\\n\\nNonce: ${nonce}`;\n const signature = await accountSigner.signMessage(message);\n\n // use main account signer's owner address for primary wallet reference\n const primaryWalletAddress =\n this.#accountSigner?.ownerAddress ??\n accountSigner.ownerAddress ??\n this.#accountSigner?.accountAddress ??\n \"\";\n\n const response = await this.#subaccounts.create({\n label,\n smartAccountAddress: accountSigner.accountAddress,\n nonce,\n signature,\n primaryWalletAddress,\n walletProvider,\n });\n\n return {\n subaccountId: response.subaccountId,\n smartAccountSaltNonce: response.smartAccountSaltNonce,\n revision: response.revision,\n };\n }\n\n /**\n * Returns the current account-signer auth state snapshot.\n */\n getState(): AuthState {\n const accountIdentity = this.#accountSigner ?? this.#accountIdentity;\n\n return {\n isAuthenticated: this.#isAuthenticated,\n accountAddress: accountIdentity?.accountAddress ?? null,\n ownerAddress: accountIdentity?.ownerAddress ?? null,\n mainAccountId: this.#mainAccountId,\n activeAccount:\n this.#activeAccountId && this.#mainAccountId\n ? {\n accountId: this.#activeAccountId,\n isMain: this.#activeAccountId === this.#mainAccountId,\n mainAccountId: this.#mainAccountId,\n smartAccountAddress: accountIdentity?.accountAddress,\n }\n : null,\n };\n }\n\n async #resolveAccountSigner(): Promise<AccountSigner | null> {\n if (this.#accountSigner) {\n this.#assertAccountSignerEnvironment(this.#accountSigner);\n return this.#accountSigner;\n }\n\n const resolved = await resolveAccountSigner(this.#accountSignerConfig);\n if (resolved) {\n this.#assertAccountSignerEnvironment(resolved);\n this.#accountSigner = resolved;\n this.#accountIdentity = this.#identityFromSigner(resolved);\n }\n return this.#accountSigner;\n }\n\n #notifyStateChange(): void {\n this.events.emit(\"stateChange\", this.getState());\n }\n\n #getEnvironmentBoundToken(): string | null {\n return this.#sessionStore.getEnvironmentBoundToken(this.#tokenStorage);\n }\n\n #getCurrentTokenStorageOptions(): AuthTokenStorageSetOptions {\n const token = this.#tokenStorage.get();\n if (!token) return { expiresAt: null, maxAgeSeconds: null };\n return createAuthTokenStorageSetOptions(token);\n }\n\n #resolveRefreshProvider(\n provider?: \"metamask\" | \"turnkey\" | \"other\",\n ): \"metamask\" | \"turnkey\" | \"other\" {\n return (\n provider ?? this.#walletProvider ?? this.#getEnvironmentSession()?.provider ?? \"other\"\n );\n }\n\n #assertAccountSignerEnvironment(accountSigner: AccountSigner): void {\n assertAccountSigner(accountSigner);\n if (accountSigner.environmentFingerprint !== this.#environmentFingerprint) {\n throw new ConfigurationError(\n \"Account signer environment does not match client environment.\",\n );\n }\n }\n\n #identityFromSigner(accountSigner: AccountSigner): AccountIdentity {\n return {\n accountAddress: accountSigner.accountAddress,\n ownerAddress: accountSigner.ownerAddress,\n };\n }\n\n #getEnvironmentSession(): SessionData | null {\n return this.#sessionStore.get();\n }\n}\n"],"mappings":";;;;;;;;;;;AAqEA,IAAa,2BAAb,cAA8C,YAAY;CACtD,SAAkB,IAAI,aAAsC;CAE5D;CACA,iBAAuC;CACvC,mBAA2C;CAC3C,mBAAmB;CACnB,iBAAgC;CAChC,mBAAkC;CAClC;CACA,kBAAgE,KAAA;CAChE,eAAuC;CACvC;CACA;CACA;CACA;CAEA,YAAY,EACR,YACA,qBACA,aACA,aACA,UACA,cACA,gBASD;EACC,MAAM,YAAY,QAAQ;EAE1B,KAAKA,uBAAuB;EAC5B,KAAKC,0BAA0B,YAAY;EAC3C,KAAKC,eAAe;EACpB,KAAKC,gBAAgB;EACrB,KAAKC,YAAY;EACjB,KAAKC,gBACD,gBACA,IAAI,iBAAiB,EACjB,wBAAwB,YAAY,YACxC,CAAC;CACT;;;;CAKA,sBAAsB,aAAuC;EACzD,KAAKH,eAAe;CACxB;;;;CAKA,iBAA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O,iCAAiC,KAAK;CACjD;CAEA,wBACI,UACgC;EAChC,OACI,YAAY,KAAKe,mBAAmB,KAAKL,uBAAuB,CAAC,EAAE,YAAY;CAEvF;CAEA,gCAAgC,eAAoC;EAChE,oBAAoB,aAAa;EACjC,IAAI,cAAc,2BAA2B,KAAKZ,yBAC9C,MAAM,IAAI,mBACN,+DACJ;CAER;CAEA,oBAAoB,eAA+C;EAC/D,OAAO;GACH,gBAAgB,cAAc;GAC9B,cAAc,cAAc;EAChC;CACJ;CAEA,yBAA6C;EACzC,OAAO,KAAKI,cAAc,IAAI;CAClC;AACJ"}
@@ -1,9 +1,9 @@
1
1
  import { SessionLevel } from "../../gen/auth/v1/mfa_pb.js";
2
+ import { AuthAndPublicApiTransports } from "../../shared/transports.js";
2
3
  import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js";
3
4
  import { PolyesterRealtime } from "../../realtime/types.js";
4
5
  import "../../realtime/index.js";
5
6
  import { ProfileService } from "./profile/profile.js";
6
- import { Transport } from "@connectrpc/connect";
7
7
  import * as v from "valibot";
8
8
  //#region src/services/auth/auth.d.ts
9
9
  declare const LoginWithWalletInputSchema: v.StrictObjectSchema<{
@@ -16,10 +16,6 @@ declare const LoginWithWalletInputSchema: v.StrictObjectSchema<{
16
16
  readonly walletProvider: v.OptionalSchema<v.StringSchema<undefined>, "">;
17
17
  }, undefined>;
18
18
  type LoginWithWalletInput = v.InferInput<typeof LoginWithWalletInputSchema>;
19
- interface AuthServiceTransports {
20
- publicApi: Transport;
21
- authApi: Transport;
22
- }
23
19
  declare const MeSchema: v.ObjectSchema<{
24
20
  readonly accountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
25
21
  readonly apiKeyId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
@@ -75,7 +71,7 @@ type Nonce = v.InferOutput<typeof NonceSchema>;
75
71
  declare class AuthService {
76
72
  #private;
77
73
  profile: ProfileService;
78
- constructor(transports: AuthServiceTransports, realtime: PolyesterRealtime);
74
+ constructor(transports: AuthAndPublicApiTransports, realtime: PolyesterRealtime);
79
75
  /**
80
76
  * 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.
81
77
  */
@@ -93,5 +89,5 @@ declare class AuthService {
93
89
  protected loginWithWallet(input: LoginWithWalletInput, options?: PolyesterMutationOptions): Promise<LoginWithWalletResponse>;
94
90
  }
95
91
  //#endregion
96
- export { AuthService, AuthServiceTransports, LoginWithWalletInput, LoginWithWalletInputSchema, LoginWithWalletResponse, Me, Nonce };
92
+ export { AuthService, LoginWithWalletInput, LoginWithWalletInputSchema, LoginWithWalletResponse, Me, Nonce };
97
93
  //# 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;UAEtC;EACb,WAAW;EACX,SAAS;;cAGP,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,uBAAuB,UAAU;;;;EASnD,GAAG,UAAU,0BAA0B,QAAQ;;;;;;;EAW/C,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":";;;;;;;;cAoBa,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,kBACF,6BACA,UAAU,0BACX,QAAQ;;;;YAaK,gBACZ,OAAO,sBACP,UAAU,2BACX,QAAQ"}
@@ -42,7 +42,7 @@ var AuthService = class {
42
42
  constructor(transports, realtime) {
43
43
  this.#publicClient = createClient(AuthService$1, transports.publicApi);
44
44
  this.#authClient = createClient(AuthService$1, transports.authApi);
45
- this.profile = new ProfileService(transports.authApi, realtime);
45
+ this.profile = new ProfileService(transports, realtime);
46
46
  }
47
47
  /**
48
48
  * 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.
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","names":["#publicClient","Proto.AuthService","#authClient"],"sources":["../../../src/services/auth/auth.ts"],"sourcesContent":["import { createClient, type Client, type Transport } 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 OptionalPublicIdSchema,\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\";\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\nexport interface AuthServiceTransports {\n publicApi: Transport;\n authApi: Transport;\n}\n\nconst MeSchema = v.object({\n accountId: PublicIdSchema,\n apiKeyId: OptionalPublicIdSchema,\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: AuthServiceTransports, realtime: PolyesterRealtime) {\n this.#publicClient = createClient(Proto.AuthService, transports.publicApi);\n this.#authClient = createClient(Proto.AuthService, transports.authApi);\n this.profile = new ProfileService(transports.authApi, 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 * 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;AASD,MAAM,WAAW,EAAE,OAAO;CACtB,WAAW;CACX,UAAU;CACV,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,YAAmC,UAA6B;EACxE,KAAKA,gBAAgB,aAAaC,eAAmB,WAAW,SAAS;EACzE,KAAKC,cAAc,aAAaD,eAAmB,WAAW,OAAO;EACrE,KAAK,UAAU,IAAI,eAAe,WAAW,SAAS,QAAQ;CAClE;;;;CAKA,MAAM,GAAG,SAAgD;EACrD,MAAM,MAAM,MAAM,KAAKC,YAAY,GAAG,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACvE,OAAO,MAAM,UAAU,GAAG;CAC9B;;;;;;;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 { parse } from \"../../shared/validation.js\";\nimport { ProfileService } from \"./profile/profile.js\";\nimport {\n OptionalPublicIdSchema,\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: OptionalPublicIdSchema,\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 * 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":";;;;;;;;;AAoBA,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;CACV,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,kBACF,qBACA,SACc;EACd,OAAO,MACH,aACA,MAAM,KAAKF,cAAc,SACrB,EAAE,oBAAoB,GACtB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