@polyester/sdk 0.36.0-devnet-20261113022813 → 0.36.0-devnet-20261115165158

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 (289) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/dist/browser-core.js +1 -1
  3. package/dist/catalogs/index.d.ts +2 -2
  4. package/dist/catalogs/readers.d.ts.map +1 -1
  5. package/dist/catalogs/readers.js +1 -1
  6. package/dist/catalogs/readers.js.map +1 -1
  7. package/dist/catalogs/snapshot-validation.js +11 -7
  8. package/dist/catalogs/snapshot-validation.js.map +1 -1
  9. package/dist/catalogs/unknown-asset.d.ts.map +1 -1
  10. package/dist/catalogs/unknown-asset.js +4 -4
  11. package/dist/catalogs/unknown-asset.js.map +1 -1
  12. package/dist/catalogs/zipper-catalog.d.ts +2 -0
  13. package/dist/catalogs/zipper-catalog.d.ts.map +1 -1
  14. package/dist/catalogs/zipper-catalog.js.map +1 -1
  15. package/dist/core-client.d.ts.map +1 -1
  16. package/dist/core-client.js +2 -1
  17. package/dist/core-client.js.map +1 -1
  18. package/dist/gen/ai/v1/assistant_pb.d.ts +1 -1
  19. package/dist/gen/ai/v1/assistant_pb.js +1 -1
  20. package/dist/gen/alerts/v1/price_alerts_pb.d.ts +1 -1
  21. package/dist/gen/auth/v1/address_book_pb.d.ts +1 -1
  22. package/dist/gen/auth/v1/api_keys_pb.d.ts +6 -6
  23. package/dist/gen/auth/v1/api_keys_pb.js +5 -5
  24. package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
  25. package/dist/gen/auth/v1/auth_pb.d.ts +1 -1
  26. package/dist/gen/auth/v1/mfa_pb.d.ts +1 -1
  27. package/dist/gen/auth/v1/policies_pb.d.ts +10 -2
  28. package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
  29. package/dist/gen/auth/v1/policies_pb.js +9 -1
  30. package/dist/gen/auth/v1/policies_pb.js.map +1 -1
  31. package/dist/gen/auth/v1/profile_pb.d.ts +1 -1
  32. package/dist/gen/auth/v1/resolve_pb.d.ts +1 -1
  33. package/dist/gen/auth/v1/social_verification_pb.d.ts +1 -1
  34. package/dist/gen/auth/v1/subaccounts_pb.d.ts +8 -2
  35. package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
  36. package/dist/gen/auth/v1/subaccounts_pb.js +8 -2
  37. package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
  38. package/dist/gen/chain/analytics/v1/analytics_read_pb.d.ts +1 -1
  39. package/dist/gen/chain/deposit/v1/deposit_pb.d.ts +1 -1
  40. package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts +1 -1
  41. package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +1 -1
  42. package/dist/gen/chain/lifecycle/v1/types_pb.d.ts +1 -1
  43. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +1 -1
  44. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +1 -1
  45. package/dist/gen/chain/zipper/v1/reason_pb.d.ts +1 -1
  46. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +48 -3
  47. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts.map +1 -1
  48. package/dist/gen/chain/zipper/v1/zipper_pb.js +36 -2
  49. package/dist/gen/chain/zipper/v1/zipper_pb.js.map +1 -1
  50. package/dist/gen/changelog/v1/changelog_pb.d.ts +7 -4
  51. package/dist/gen/changelog/v1/changelog_pb.d.ts.map +1 -1
  52. package/dist/gen/changelog/v1/changelog_pb.js +2 -1
  53. package/dist/gen/changelog/v1/changelog_pb.js.map +1 -1
  54. package/dist/gen/checkpoints/v1/checkpoints_pb.d.ts +1 -1
  55. package/dist/gen/claims/v1/claims_pb.d.ts +1 -1
  56. package/dist/gen/fees/v1/fees_pb.d.ts +1 -1
  57. package/dist/gen/index.d.ts +2 -1
  58. package/dist/gen/index.js +22 -21
  59. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +126 -3
  60. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
  61. package/dist/gen/ledger/read/v1/ledger_read_pb.js +17 -3
  62. package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
  63. package/dist/gen/marketdata/v1/asset_info_pb.d.ts +178 -0
  64. package/dist/gen/marketdata/v1/asset_info_pb.d.ts.map +1 -0
  65. package/dist/gen/marketdata/v1/asset_info_pb.js +45 -0
  66. package/dist/gen/marketdata/v1/asset_info_pb.js.map +1 -0
  67. package/dist/gen/marketdata/v1/heatmap_pb.d.ts +1 -1
  68. package/dist/gen/marketdata/v1/marketdata_pb.d.ts +13 -1
  69. package/dist/gen/marketdata/v1/marketdata_pb.d.ts.map +1 -1
  70. package/dist/gen/marketdata/v1/marketdata_pb.js +6 -1
  71. package/dist/gen/marketdata/v1/marketdata_pb.js.map +1 -1
  72. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +1 -1
  73. package/dist/gen/notifications/v1/notifications_pb.d.ts +1 -1
  74. package/dist/gen/orderbook/v1/orderbook_pb.d.ts +1 -1
  75. package/dist/gen/orders/v1/orders_pb.d.ts +1 -1
  76. package/dist/gen/orders/v1/orders_read_pb.d.ts +1 -1
  77. package/dist/gen/polyester/ratelimit/v1/types_pb.d.ts +1 -1
  78. package/dist/gen/polyester/type/v1/u128_pb.d.ts +1 -1
  79. package/dist/gen/privatews/v1/private_ws_pb.d.ts +1 -1
  80. package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +1 -1
  81. package/dist/gen/rewards/v1/rewards_pb.d.ts +1 -1
  82. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +13 -1
  83. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
  84. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +12 -0
  85. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
  86. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +14 -10
  87. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
  88. package/dist/gen/swap/quickswap/v1/quickswap_pb.js +10 -7
  89. package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
  90. package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts +3 -3
  91. package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.js.map +1 -1
  92. package/dist/gen/swap/v1/swap_pb.d.ts +1 -1
  93. package/dist/gen/system/v1/system_pb.d.ts +408 -3
  94. package/dist/gen/system/v1/system_pb.d.ts.map +1 -1
  95. package/dist/gen/system/v1/system_pb.js +221 -3
  96. package/dist/gen/system/v1/system_pb.js.map +1 -1
  97. package/dist/gen/tradews/v1/trade_ws_pb.d.ts +1 -1
  98. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +1 -1
  99. package/dist/gen/triggers/v1/triggers_pb.d.ts +7 -5
  100. package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
  101. package/dist/gen/triggers/v1/triggers_pb.js +6 -4
  102. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  103. package/dist/gen/vip/v1/vip_pb.d.ts +1 -1
  104. package/dist/index.d.ts +7 -4
  105. package/dist/index.js +1 -1
  106. package/dist/realtime/private-orders.d.ts +8 -0
  107. package/dist/realtime/private-orders.d.ts.map +1 -1
  108. package/dist/realtime/private-orders.js +38 -5
  109. package/dist/realtime/private-orders.js.map +1 -1
  110. package/dist/realtime/snapshot-then-stream.js +1 -1
  111. package/dist/server-core.js +3 -3
  112. package/dist/services/accounts/accounts.js +1 -1
  113. package/dist/services/accounts/accounts.schemas.js +1 -1
  114. package/dist/services/address-book/address-book.js +1 -1
  115. package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
  116. package/dist/services/address-book/address-book.schemas.js +4 -4
  117. package/dist/services/address-book/address-book.schemas.js.map +1 -1
  118. package/dist/services/api-keys/api-keys.codecs.d.ts +2 -2
  119. package/dist/services/api-keys/api-keys.codecs.js +2 -2
  120. package/dist/services/api-keys/api-keys.codecs.js.map +1 -1
  121. package/dist/services/api-keys/api-keys.js +1 -1
  122. package/dist/services/api-keys/api-keys.schemas.js +1 -1
  123. package/dist/services/assistant/assistant-events.schemas.d.ts +100 -71
  124. package/dist/services/assistant/assistant-events.schemas.d.ts.map +1 -1
  125. package/dist/services/assistant/assistant.js +1 -1
  126. package/dist/services/assistant/assistant.schemas.d.ts +1 -1
  127. package/dist/services/assistant/assistant.schemas.js +1 -1
  128. package/dist/services/auth/account-signer-auth.js +2 -2
  129. package/dist/services/auth/auth.js +1 -1
  130. package/dist/services/auth/profile/profile.js +2 -2
  131. package/dist/services/auto-withdraw/auto-withdraw.js +1 -1
  132. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +13 -13
  133. package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -1
  134. package/dist/services/balances/balances.d.ts +12 -1
  135. package/dist/services/balances/balances.d.ts.map +1 -1
  136. package/dist/services/balances/balances.js +38 -2
  137. package/dist/services/balances/balances.js.map +1 -1
  138. package/dist/services/balances/balances.schemas.d.ts +61 -25
  139. package/dist/services/balances/balances.schemas.d.ts.map +1 -1
  140. package/dist/services/balances/balances.schemas.js +24 -3
  141. package/dist/services/balances/balances.schemas.js.map +1 -1
  142. package/dist/services/balances/balances.types.d.ts +2 -2
  143. package/dist/services/candles/candles.js +2 -2
  144. package/dist/services/chain-analytics/chain-analytics.js +1 -1
  145. package/dist/services/changelog/changelog.js +1 -1
  146. package/dist/services/changelog/changelog.schemas.d.ts +38 -38
  147. package/dist/services/checkpoints/checkpoints.js +1 -1
  148. package/dist/services/checkpoints/checkpoints.schemas.d.ts +2 -2
  149. package/dist/services/claims/claims.js +1 -1
  150. package/dist/services/claims/claims.schemas.d.ts +2 -2
  151. package/dist/services/claims/claims.schemas.js +1 -1
  152. package/dist/services/deposit/deposit.js +1 -1
  153. package/dist/services/fees/fees.js +1 -1
  154. package/dist/services/guard-signer/guard-signer.js +1 -1
  155. package/dist/services/guard-signer/guard-signer.schemas.js +1 -1
  156. package/dist/services/heatmap/heatmap.js +2 -2
  157. package/dist/services/internal-transfers/internal-transfers.js +1 -1
  158. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +3 -3
  159. package/dist/services/lifecycle/lifecycle.js +3 -3
  160. package/dist/services/lifecycle/lifecycle.schemas.d.ts +40 -40
  161. package/dist/services/lifecycle/lifecycle.schemas.js +2 -2
  162. package/dist/services/market-data/market-data.d.ts +7 -1
  163. package/dist/services/market-data/market-data.d.ts.map +1 -1
  164. package/dist/services/market-data/market-data.js +14 -3
  165. package/dist/services/market-data/market-data.js.map +1 -1
  166. package/dist/services/market-data/market-data.schemas.d.ts +108 -1
  167. package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
  168. package/dist/services/market-data/market-data.schemas.js +42 -2
  169. package/dist/services/market-data/market-data.schemas.js.map +1 -1
  170. package/dist/services/market-data/market-data.types.d.ts +2 -2
  171. package/dist/services/market-overview/market-overview.js +2 -2
  172. package/dist/services/market-overview/market-overview.schemas.js +1 -1
  173. package/dist/services/notifications/notifications.js +1 -1
  174. package/dist/services/notifications/notifications.schemas.d.ts +1 -1
  175. package/dist/services/orderbook/orderbook.js +1 -1
  176. package/dist/services/orders/order-errors.schemas.d.ts +2 -2
  177. package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
  178. package/dist/services/orders/order-errors.schemas.js +8 -5
  179. package/dist/services/orders/order-errors.schemas.js.map +1 -1
  180. package/dist/services/orders/orders-batch.schemas.d.ts +48 -48
  181. package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
  182. package/dist/services/orders/orders-batch.schemas.js +5 -4
  183. package/dist/services/orders/orders-batch.schemas.js.map +1 -1
  184. package/dist/services/orders/orders-input.schemas.d.ts +8 -8
  185. package/dist/services/orders/orders-input.schemas.js +3 -3
  186. package/dist/services/orders/orders-modify.schemas.d.ts.map +1 -1
  187. package/dist/services/orders/orders-modify.schemas.js +4 -3
  188. package/dist/services/orders/orders-modify.schemas.js.map +1 -1
  189. package/dist/services/orders/orders-output.schemas.d.ts +17 -17
  190. package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
  191. package/dist/services/orders/orders-output.schemas.js +2 -10
  192. package/dist/services/orders/orders-output.schemas.js.map +1 -1
  193. package/dist/services/orders/orders-risk.schemas.js +3 -3
  194. package/dist/services/orders/orders.d.ts +6 -0
  195. package/dist/services/orders/orders.d.ts.map +1 -1
  196. package/dist/services/orders/orders.js +6 -2
  197. package/dist/services/orders/orders.js.map +1 -1
  198. package/dist/services/policies/api-key-policies/api-key-policies.js +1 -1
  199. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
  200. package/dist/services/policies/shared.codecs.js +7 -4
  201. package/dist/services/policies/shared.codecs.js.map +1 -1
  202. package/dist/services/policies/shared.d.ts +1 -1
  203. package/dist/services/policies/subaccount-policies/subaccount-policies.js +2 -2
  204. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +3 -3
  205. package/dist/services/price-alerts/price-alerts.js +1 -1
  206. package/dist/services/price-alerts/price-alerts.schemas.d.ts +10 -10
  207. package/dist/services/rate-limits/rate-limits.js +1 -1
  208. package/dist/services/rewards/rewards.js +1 -1
  209. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  210. package/dist/services/social-verification/social-verification.js +1 -1
  211. package/dist/services/social-verification/social-verification.schemas.js +1 -1
  212. package/dist/services/subaccounts/subaccounts.codecs.js +2 -1
  213. package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
  214. package/dist/services/subaccounts/subaccounts.js +3 -3
  215. package/dist/services/subaccounts/subaccounts.schemas.d.ts +13 -13
  216. package/dist/services/system/system.codecs.d.ts +20 -0
  217. package/dist/services/system/system.codecs.d.ts.map +1 -0
  218. package/dist/services/system/system.codecs.js +57 -0
  219. package/dist/services/system/system.codecs.js.map +1 -0
  220. package/dist/services/system/system.d.ts +7 -0
  221. package/dist/services/system/system.d.ts.map +1 -1
  222. package/dist/services/system/system.js +14 -1
  223. package/dist/services/system/system.js.map +1 -1
  224. package/dist/services/system/system.schemas.d.ts +234 -0
  225. package/dist/services/system/system.schemas.d.ts.map +1 -0
  226. package/dist/services/system/system.schemas.js +78 -0
  227. package/dist/services/system/system.schemas.js.map +1 -0
  228. package/dist/services/system/system.types.d.ts +4 -0
  229. package/dist/services/trades/trades.js +2 -2
  230. package/dist/services/trades/trades.schemas.d.ts +2 -2
  231. package/dist/services/trading-withdraws/service.js +1 -1
  232. package/dist/services/trading-withdraws/service.js.map +1 -1
  233. package/dist/services/trading-withdraws/trading-withdraws.d.ts +10 -12
  234. package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
  235. package/dist/services/trading-withdraws/trading-withdraws.js +28 -20
  236. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  237. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +0 -5
  238. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
  239. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +1 -5
  240. package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
  241. package/dist/services/trading-withdraws/wallet-message.js +2 -2
  242. package/dist/services/trading-withdraws/wallet-message.js.map +1 -1
  243. package/dist/services/transfers/transfers.js +2 -2
  244. package/dist/services/triggers/trigger-child-order.schemas.js +3 -3
  245. package/dist/services/triggers/trigger-input.schemas.d.ts +3 -3
  246. package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
  247. package/dist/services/triggers/trigger-input.schemas.js +6 -5
  248. package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
  249. package/dist/services/triggers/triggers-output.schemas.d.ts +47 -48
  250. package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
  251. package/dist/services/triggers/triggers-output.schemas.js +1 -1
  252. package/dist/services/triggers/triggers.js +2 -2
  253. package/dist/services/vip/vip.js +1 -1
  254. package/dist/services/vip/vip.schemas.js +1 -1
  255. package/dist/services/zipper/zipper.js +1 -1
  256. package/dist/services/zipper/zipper.schemas.d.ts +2 -2
  257. package/dist/services/zipper/zipper.schemas.d.ts.map +1 -1
  258. package/dist/services/zipper/zipper.schemas.js +10 -3
  259. package/dist/services/zipper/zipper.schemas.js.map +1 -1
  260. package/dist/services/zipper/zipper.types.d.ts +2 -2
  261. package/dist/shared/catalog-config.d.ts +13 -1
  262. package/dist/shared/catalog-config.d.ts.map +1 -1
  263. package/dist/shared/catalog-config.js +6 -1
  264. package/dist/shared/catalog-config.js.map +1 -1
  265. package/dist/shared/error-details/alerts.js +1 -1
  266. package/dist/shared/error-details/assistant.js +1 -1
  267. package/dist/shared/error-details/auth.js +1 -1
  268. package/dist/shared/error-details/claims.js +1 -1
  269. package/dist/shared/error-details/internal-transfer.js +1 -1
  270. package/dist/shared/error-details/ledger.js +1 -1
  271. package/dist/shared/error-details/market-overview.js +1 -1
  272. package/dist/shared/error-details/notifications.js +1 -1
  273. package/dist/shared/error-details/orders.js +1 -1
  274. package/dist/shared/error-details/profile.js +1 -1
  275. package/dist/shared/error-details/rate-limit.js +1 -1
  276. package/dist/shared/error-details/withdraw.js +1 -1
  277. package/dist/shared/rate-limit.schemas.d.ts +1 -1
  278. package/dist/shared/rate-limit.schemas.js +1 -1
  279. package/dist/shared/transports.d.ts +2 -1
  280. package/dist/shared/transports.d.ts.map +1 -1
  281. package/dist/shared/transports.js +52 -9
  282. package/dist/shared/transports.js.map +1 -1
  283. package/dist/utils/base58-id.js +1 -1
  284. package/dist/utils/base58-id.js.map +1 -1
  285. package/dist/utils/cookies.js +1 -1
  286. package/dist/utils/numbers.js +3 -2
  287. package/dist/utils/numbers.js.map +1 -1
  288. package/dist/wired-services.js +17 -17
  289. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { Message } from "@bufbuild/protobuf";
2
1
  import { GenEnum, GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv2";
3
2
  import { Timestamp } from "@bufbuild/protobuf/wkt";
3
+ import { Message } from "@bufbuild/protobuf";
4
4
  declare namespace vip_pb_d_exports {
5
5
  export { GetVIPStatusRequest, GetVIPStatusRequestSchema, GetVIPStatusResponse, GetVIPStatusResponseSchema, ListVIPTiersRequest, ListVIPTiersRequestSchema, ListVIPTiersResponse, ListVIPTiersResponseSchema, NextVIPTierThresholds, NextVIPTierThresholdsSchema, VIPMetricQuality, VIPMetricQualitySchema, VIPMetricStatus, VIPMetricStatusSchema, VIPService, VIPTier, VIPTierSchema, file_vip_v1_vip };
6
6
  }
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { AccountSigner, AccountSignerConfig, AccountSignerFactory, HexAddress }
2
2
  import { CreatePolyesterEnvironmentParams, POLYESTER_DEVNET_ENVIRONMENT, POLYESTER_TESTNET_ENVIRONMENT, PolyesterAccountAbstractionEnvironment, PolyesterContractsEnvironment, PolyesterEntryPointConfig, PolyesterEnvironment, PolyesterSafeDeploymentConfig, createPolyesterEnvironment } from "./environment.js";
3
3
  import { CreatePolyesterAccountSignerParams } from "./account-signer/create-polyester-account-signer.js";
4
4
  import "./account-signer/index.js";
5
- import { AssetConfig, DepositWithdrawConfig, PairConfig, PairStatus, SpotConfig, ZipperAssetChainVariant, ZipperAssetConfig, ZipperChainConfig, ZipperChainContractConfig, ZipperMemoRequirement } from "./shared/catalog-config.js";
5
+ import { AssetConfig, DepositWithdrawConfig, PairConfig, PairStatus, SpotConfig, ZipperAssetChainVariant, ZipperAssetConfig, ZipperChainConfig, ZipperChainContractConfig, ZipperMemoRequirement, ZipperRouteStatus } from "./shared/catalog-config.js";
6
6
  import { OrderErrorCode, OrderErrorDetail } from "./services/orders/order-errors.schemas.js";
7
7
  import { RateLimitDetail, RateLimitFailureReason, RateLimitPolicyClass, RateLimitRefillModel, RateLimitScope } from "./shared/rate-limit.schemas.js";
8
8
  import { PolyesterErrorDetail, loadErrorDetailDecoders } from "./shared/error-detail.js";
@@ -19,11 +19,11 @@ import { ApiKeyPolicy, ApiKeyPolicyApplyInput, ApiKeyPolicyCreateInput, ApiKeyPo
19
19
  import { ApiKey, ApiKeyIdInput, ApiKeyStatus, ApiKeysCreateInput, ApiKeysListInput, ApiKeysUpdateInput, AssistantKeySpecInput, SetAssistantKeysInput } from "./services/api-keys/api-keys.schemas.js";
20
20
  import { SubaccountPolicy, SubaccountPolicyApplyInput, SubaccountPolicyCreateInput, SubaccountPolicyUpdateInput } from "./services/policies/subaccount-policies/subaccount-policies.schemas.js";
21
21
  import { AccountCodeValue, TransferCodeValue } from "./shared/ledger-codes.js";
22
- import { BalanceHistoryInput, BalanceHistoryResponse, BalanceRange, EquityGroupBy, EquityHistoryInput, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, LedgerBalance, PortfolioEquityHistoryInput, PortfolioEquityHistoryResponse, PortfolioEquitySeries, PortfolioEquitySeriesGrouping, PortfolioEquitySnapshotResponse, formatLedgerBalance } from "./services/balances/balances.schemas.js";
22
+ import { BalanceHistoryInput, BalanceHistoryResponse, BalanceRange, EquityGroupBy, EquityHistoryInput, EquityHistoryResponse, EquitySeries, EquitySeriesGrouping, ExportStatementInput, LedgerBalance, PortfolioEquityHistoryInput, PortfolioEquityHistoryResponse, PortfolioEquitySeries, PortfolioEquitySeriesGrouping, PortfolioEquitySnapshotResponse, StatementPage, formatLedgerBalance } from "./services/balances/balances.schemas.js";
23
23
  import { CreateSubaccountChallengeInput, CreateSubaccountInput, CreateSubaccountResult as CreateSubaccountResult$1, EffectiveSubaccountPermissions, GetSubaccountInput, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountChallenge, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput } from "./services/subaccounts/subaccounts.schemas.js";
24
24
  import { Candle, CandleColumnar, CandleColumnarInt, CandleInt, GetCandlesColumnsInput, GetCandlesInput, Timeframe } from "./services/candles/candles.schemas.js";
25
25
  import { ChainAnalyticsRange, GetUnifiedAssetBalancesInput, GetZippedAssetSupplyGroupInput, GetZippedAssetSupplyInput, UnifiedAssetBalancesResponse, ZippedAssetSupplyGroupResponse, ZippedAssetSupplyResponse, ZippedAssetSupplySeries } from "./services/chain-analytics/chain-analytics.schemas.js";
26
- import { GetMarketTradesInput, MarketTrade, TradeBackfill } from "./services/market-data/market-data.schemas.js";
26
+ import { AssetEditorialInfo, AssetInfo, GetMarketTradesInput, ListAssetInfoInput, MarketTrade, TradeBackfill } from "./services/market-data/market-data.schemas.js";
27
27
  import { CurrencyConversionConfig, CurrencyConversionRates, CurrencyMetadata, FiatConversionRate, FiatConversionSnapshot, ListMarketOverviewInput, MarketOverview, MarketOverviewOrderBy, MarketOverviewSort, MarketOverviewSparkline, SparklineIntervalName, SpotPairVolumeSeries, SpotVolumeHistoryInput, SpotVolumeHistoryResponse, StablecoinConversionRate } from "./services/market-overview/market-overview.schemas.js";
28
28
  import { GetOrderbookInput, OrderbookData, OrderbookLevel } from "./services/orderbook/orderbook.schemas.js";
29
29
  import { CreateOrderbookSubscriptionInput, OrderbookStreamHandlers, OrderbookSubscription } from "./services/orderbook/orderbook.js";
@@ -61,6 +61,7 @@ import { BeginMfaChallengeInput, BeginMfaChallengeResult, BeginPasskeyEnrollment
61
61
  import { ClaimCampaign, ClaimDailyRewardInput, ClaimDailyRewardResult, ClaimPayoutDelayReason, DailyClaimReward, DailyClaimStatus, DailyClaimTransfer } from "./services/claims/claims.schemas.js";
62
62
  import { Checkpoint, CheckpointAssetAmount, CheckpointBiggestTrade, CheckpointChainFlow, CheckpointEarnedBadge, CheckpointFlowTotal, CheckpointFundingDay, CheckpointFundingFlowSummary, CheckpointOrderToolCounts, CheckpointOrderTypeCounts, CheckpointPairActivity, CheckpointPortfolioValuePoint, CheckpointTimeInForceCounts, CheckpointVipTierChange, CheckpointVolumePoint, ListCheckpointsInput } from "./services/checkpoints/checkpoints.schemas.js";
63
63
  import { ChangelogChange, ChangelogChangeEntry, ChangelogDeploymentGroup, ChangelogDeploymentGroupSummary, ChangelogPost, ChangelogPostSummary, ChangelogSection, GetChangelogDeploymentGroupInput, GetChangelogPostInput, ListChangelogChangesInput, ListChangelogChangesResult, ListChangelogDeploymentGroupsInput, ListChangelogDeploymentGroupsResult, ListChangelogPostsInput, ListChangelogPostsResult } from "./services/changelog/changelog.schemas.js";
64
+ import { ListStatusEventsInput, ListStatusEventsResult, StatusEvent } from "./services/system/system.schemas.js";
64
65
  import { SystemVersion } from "./services/system/system.js";
65
66
  import { AcknowledgeRewardAwardInput, AcknowledgeRewardAwardResult, ListRewardAwardsInput, ListRewardAwardsResult, RewardAward, SetRewardDestinationInput, SetRewardDestinationResult } from "./services/rewards/rewards.schemas.js";
66
67
  import { NextVipTierThresholds, VipMetricQuality, VipMetricStatus, VipStatus, VipTier, VipTierCatalog } from "./services/vip/vip.schemas.js";
@@ -130,6 +131,8 @@ import { RewardFulfillmentMethod, RewardFulfillmentState } from "./services/rewa
130
131
  import "./services/rewards/rewards.types.js";
131
132
  import "./services/social-verification/social-verification.types.js";
132
133
  import "./services/subaccounts/subaccounts.types.js";
134
+ import { StatusEventImpact, StatusEventKind, StatusEventService, StatusEventState } from "./services/system/system.codecs.js";
135
+ import "./services/system/system.types.js";
133
136
  import "./services/trades/trades.types.js";
134
137
  import "./services/trading-withdraws/trading-withdraws.types.js";
135
138
  import { TransferSideKind } from "./services/transfers/transfers.codecs.js";
@@ -137,4 +140,4 @@ import "./services/transfers/transfers.types.js";
137
140
  import "./services/triggers/triggers.types.js";
138
141
  import "./services/vip/vip.types.js";
139
142
  import "./services/zipper/zipper.types.js";
140
- export { type AccountCodeValue, type AccountIdentity, type AccountNotification, type AccountNotificationDetail, type AccountScope, type AccountScopedInput, type AccountSigner, type AccountSignerAuthEvents, type AccountSignerConfig, type CreateSubaccountResult as AccountSignerCreateSubaccountResult, type AccountSignerFactory, type AcknowledgeRewardAwardInput, type AcknowledgeRewardAwardResult, type ActiveAccountInfo, type AddressBook, type AddressBookAccountScope, type AddressBookEntries, type AddressBookEntriesView, type AddressBookEntry, type AddressBookRecentDestinationsView, type AddressBookTag, type AddressBookTagSummary, type AddressBookView, type AddressBookViewInvalidated, AlreadyExistsError, type ApiKey, type ApiKeyEd25519AuthProvider, type ApiKeyIdInput, type ApiKeyPolicy, type ApiKeyPolicyApplyInput, type ApiKeyPolicyCreateInput, type ApiKeyPolicyUpdateInput, type ApiKeyStatus, type ApiKeysCreateInput, type ApiKeysListInput, type ApiKeysUpdateInput, type AssetConfig, type AssistantApprovalDecision, type AssistantApprovalPreview, type AssistantApprovalStatus, type AssistantConversation, type AssistantDisplaySetting, type AssistantFailureCategory, type AssistantKey, type AssistantKeyPreset, type AssistantKeySpecInput, type AssistantKeyState, type AssistantMemory, type AssistantMemoryKind, type AssistantMessage, type AssistantMessageRole, type AssistantOrderPreview, type AssistantOrderPriceField, type AssistantPriceOffsetDirection, type AssistantPriceRounding, type AssistantReferencePriceSource, type AssistantRunEvent, type AssistantRunIdInput, type AssistantTriggerChangeAction, type AssistantTriggerDirection, type AssistantUnfilledSlicePolicy, type AssistantView, type AuthCookieLocation, type AuthHydrationData, type AuthLoginMethod, type AuthState, type AuthTokenStorage, type AuthTokenStorageSetOptions, AuthenticationError, type AutoWithdrawCadence, type AutoWithdrawDestination, type AutoWithdrawDestinationInput, type AutoWithdrawHoldReason, type AutoWithdrawPause, type AutoWithdrawPauseReason, type AutoWithdrawPreview, type AutoWithdrawPreviewAsset, type AutoWithdrawPreviewStatus, type AutoWithdrawRule, type AutoWithdrawRun, type AutoWithdrawRunReason, type AutoWithdrawRunState, type AutoWithdrawSchedule, type AutoWithdrawScheduleInput, type AutoWithdrawScopedInput, type AutoWithdrawStep, type AutoWithdrawStepReason, type AutoWithdrawStepState, type AutoWithdrawWeekday, type BalanceHistoryInput, type BalanceHistoryResponse, type BalanceRange, type BatchCancelOrderInput, type BatchCancelOrderResult, type BatchCancelOrdersInput, type BatchCancelOrdersResult, type BatchCancelTriggerResult, type BatchCancelTriggersInput, type BatchCancelTriggersResult, type BatchCreateOrderResult, type BatchCreateOrdersInput, type BatchCreateOrdersResult, type BatchGuardApprovals, type BatchReplaceAdmissionItem, type BatchReplaceOrdersInput, type BatchReplaceOrdersResult, type BatchSignProtectedActionInput, type BeginMfaChallengeInput, type BeginMfaChallengeResult, type BeginPasskeyEnrollmentInput, type BeginPasskeyEnrollmentResult, type BeginTotpEnrollmentInput, type BeginTotpEnrollmentResult, type BrokerAllowlistAction, type BrokerAllowlistEvent, type CancelAllAfterInput, type CancelAllAfterResult, type CancelAllOrdersInput, type CancelAllOrdersResponse, type CancelOcoInput, type CancelOcoResult, type CancelOrderInput, type CancelOrderResult, type CancelPriceAlertInput, type CancelTriggerInput, type CancelTriggerResult, type Candle, type CandleColumnar, type CandleColumnarInt, type CandleInt, type ChainAnalyticsRange, type ChangelogAudience, type ChangelogChange, type ChangelogChangeAvailability, type ChangelogChangeCategory, type ChangelogChangeEntry, type ChangelogDeploymentGroup, type ChangelogDeploymentGroupSummary, type ChangelogEnvironment, type ChangelogPost, type ChangelogPostSummary, type ChangelogSection, type ChangelogSort, type ChangelogSurface, type Checkpoint, type CheckpointAssetAmount, type CheckpointBadge, type CheckpointBiggestTrade, type CheckpointChainFlow, type CheckpointEarnedBadge, type CheckpointField, type CheckpointFlowTotal, type CheckpointFundingDay, type CheckpointFundingFlowSummary, type CheckpointOrderToolCounts, type CheckpointOrderTypeCounts, type CheckpointPairActivity, type CheckpointPortfolioValuePoint, type CheckpointTimeInForceCounts, type CheckpointVipTierChange, type CheckpointVolumePoint, type ClaimCampaign, type ClaimDailyRewardInput, type ClaimDailyRewardResult, type ClaimFreshStepUpInput, type ClaimFreshStepUpResult, type ClaimGeneratedUsernameInput, ClaimOutcomeUnknownError, type ClaimOutcomeUnknownErrorOptions, type ClaimPayoutDelayReason, type ClaimPolicy, type ColumnarTimeWindow, type CompleteAssistantKeysInput, type CompleteMfaChallengeResult, ConfigurationError, type ConfirmVerificationInput, type ConnectChannelParams, type ConnectPrivateOrdersParams, type ConsumeFreshStepUpInput, type CookieAuthTokenStorageOptions, type CopyAddressBookEntryInput, type CreateAddressBookEntryInput, type CreateAddressBookTagInput, type CreateDepositAddressInput, type CreateGuardSignerWalletResult, type CreateInternalTransferInput, type CreateInternalTransferResult, type CreateOcoInput, type CreateOcoResult, type CreateOrderResult, type CreateOrderbookSubscriptionInput, type CreatePolyesterAccountSignerParams, type CreatePolyesterEnvironmentParams, type CreatePriceAlertInput, type CreateServerClientFromCookiesParams, type CreateServerClientFromRequestParams, type CreateSubaccountChallengeInput, type CreateSubaccountInput, type CreateSubaccountParams, type CreateSubaccountResult$1 as CreateSubaccountResult, type CreateSubaccountResult$1 as CreateSubaccountServiceResult, type CreateTradingWithdrawResult, type CreateTradingWithdrawToExternalChainInput, type CreateTradingWithdrawToExternalChainServiceInput, type CreateTradingWithdrawToFundingInput, type CreateTradingWithdrawToFundingServiceInput, type CreateTriggerInput, type CreateTriggerResult, type CreateWalletChallengeInput, type CurrencyConversionConfig, type CurrencyConversionRates, type CurrencyMetadata, type DailyClaimReward, type DailyClaimState, type DailyClaimStatus, type DailyClaimTransfer, type DecideAssistantApprovalInput, type DeleteAddressBookEntryInput, type DeleteAddressBookTagInput, type DeleteAssistantMemoryInput, type DeleteMfaFactorInput, type DepositAddress, type DepositWithdrawConfig, type EffectiveSubaccountPermissions, type EquityGroupBy, type EquityHistoryInput, type EquityHistoryResponse, type EquitySeries, type EquitySeriesGrouping, type EvmHex, type ExportGuardSignerWalletResult, type FiatConversionRate, type FiatConversionSnapshot, type FinishPasskeyChallengeInput, type FinishPasskeyEnrollmentInput, type FinishPasskeyEnrollmentResult, type FinishTotpEnrollmentInput, type FinishTotpEnrollmentResult, type GeneratedUsernameOffer, type GetAddressBookViewInput, type GetBatchReplaceStatusInput, type GetBatchReplaceStatusResult, type GetCandlesColumnsInput, type GetCandlesInput, type GetChangelogDeploymentGroupInput, type GetChangelogPostInput, type GetInternalTransferInput, type GetInternalTransferResult, type GetLifecycleFlowInput, type GetLifecycleFlowOutput, type GetMarketTradesInput, type GetNotificationInput, type GetOrderDetailsInput, type GetOrderbookHeatmapInput, type GetOrderbookInput, type GetSpotFeeRatesInput, type GetSubaccountInput, type GetTriggerInput, type GetUnifiedAssetBalancesInput, type GetUserTradesInput, type GetVerificationResponse, type GetWalletBalancesInput, type GetWalletBalancesResult, type GetZippedAssetSupplyGroupInput, type GetZippedAssetSupplyInput, type GuardApproval, type GuardSignerScopedInput, type GuardSignerStatus, type HeatmapDepthValue, type HeatmapIntervalValue, type HeatmapQuantityModeValue, type HexAddress, InternalServerError, type InternalTransferDestination, type InternalTransferStatus, type InternalTransferWhitelistEntries, type InternalTransferWhitelistEntry, type InviteSubaccountMemberInput, type JwtAuthProvider, type LadderDetailsOutput, type LedgerBalance, type LedgerTransfer, type LedgerTransferSide, type LifecycleAssetIds, type LifecycleFlowDetail, type LifecycleFlowState, type LifecycleFlowStep, type LifecycleFlowStepActivity, type LifecycleFlowSummary, type LifecycleFlowSummaryProgress, type LifecycleFlowTimelineItem, type LifecycleFlowTxMatch, type LifecycleListOrderBy, type LifecycleListScope, type LifecycleReason, type LifecycleRequestFee, type LifecycleRequestFeeStatus, type LifecycleSort, type LifecycleTxLookupKind, type LifecycleZipperReason, type LifecycleZipperReasonCode, type ListAddressBookEntriesInput, type ListApiKeyPoliciesResponse, type ListAssistantConversationsInput, type ListAssistantConversationsResult, type ListAssistantMemoriesInput, type ListAssistantMemoriesResult, type ListAssistantMessagesInput, type ListAssistantMessagesResult, type ListAutoWithdrawRunsInput, type ListAutoWithdrawRunsResult, type ListChangelogChangesInput, type ListChangelogChangesResult, type ListChangelogDeploymentGroupsInput, type ListChangelogDeploymentGroupsResult, type ListChangelogPostsInput, type ListChangelogPostsResult, type ListCheckpointsInput, type ListDepositAddressesInput, type ListInternalTransferWhitelistEntriesInput, type ListLifecycleFlowsByTxInput, type ListLifecycleFlowsByTxOutput, type ListLifecycleFlowsInput, type ListLifecycleFlowsOutput, type ListMarketOverviewInput, type ListMfaFactorsResult, type ListNotificationsInput, type ListNotificationsResult, type ListPriceAlertsInput, type ListPriceAlertsResult, type ListRewardAwardsInput, type ListRewardAwardsResult, type ListSubaccountInvitesInput, type ListTransferCounterpartiesInput, type ListTransferDestinationsInput, type ListTransfersInput, type ListTriggerEventsInput, type ListTriggerEventsResult, type ListTriggersInput, type ListTriggersResult, type LoginOptions, type LoginResult, type LoginWithWalletInput, type LoginWithWalletResponse, type MarkAllNotificationsReadInput, type MarkNotificationsInput, type MarketOverview, type MarketOverviewOrderBy, type MarketOverviewSort, type MarketOverviewSparkline, type MarketTrade, type Me, MfaEnrollmentRequiredError, type MfaFactor, MfaLastFactorRequiredError, MfaRequiredError, type MfaSessionInfo, MfaVerificationError, type MfaVerificationFailureReason, type MirroredWithdrawWhitelistEntry, type ModifyOrderInput, type ModifyOrderResult, type ModifyTriggerInput, type ModifyTriggerResult, NetworkError, type NewOrderInput, type NextVipTierThresholds, NotImplementedError, type NotificationCategory, type NotificationCounts, type NotificationReadState, type NotificationType, type OpenOrdersInput, type Order, type OrderDetails, type OrderErrorCode, type OrderErrorDetail, type OrderHistoryInput, type OrderIntentInput, type OrderLineage, type OrderTransfer, type OrderbookData, type OrderbookHeatmapDeltaBucket, type OrderbookHeatmapDeltaChain, type OrderbookHeatmapDeltaLevels, type OrderbookHeatmapKeyframe, type OrderbookHeatmapLevels, type OrderbookHeatmapLiveBucket, type OrderbookHeatmapResponse, type OrderbookLevel, type OrderbookStreamHandlers, type OrderbookSubscription, OutcomeUnknownError, POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_DEVNET_ENVIRONMENT, POLYESTER_SESSION_COOKIE_NAME, POLYESTER_TESTNET_ENVIRONMENT, type PairConfig, type PairStatus, type PauseTriggerInput, type PauseTriggerResult, PermissionError, type PolicyAction, PolicyInUseError, PolicyLockedError, type PolicyMarketScope, PolicyScopeMismatchError, type PolyesterAccountAbstractionEnvironment, PolyesterBrowserClient, type PolyesterBrowserClientConfig, PolyesterBrowserCore, PolyesterClient, type PolyesterClientBaseConfig, type PolyesterClientConfig, type PolyesterContractsEnvironment, PolyesterCore, type PolyesterEntryPointConfig, type PolyesterEnvironment, PolyesterError, type PolyesterErrorCode, type PolyesterErrorDetail, type PolyesterErrorOptions, type PolyesterMutationOptions, type PolyesterRealtime, type PolyesterRealtimeAuthConfig, type PolyesterRequestOptions, type PolyesterSafeDeploymentConfig, PolyesterServerClient, type PolyesterServerClientConfig, PolyesterServerCore, type PolyesterServices, type PortfolioEquityHistoryInput, type PortfolioEquityHistoryResponse, type PortfolioEquitySeries, type PortfolioEquitySeriesGrouping, type PortfolioEquitySnapshotResponse, PreconditionFailedError, type PrepareAssistantKeysInput, type PrepareAssistantKeysResult, type PreparedAssistantKey, type PreparedTradingWithdraw, type PreviewOrderResult, type PriceAlert, type PriceAlertChannel, type PriceAlertDirection, type PriceAlertPriceSource, type PriceAlertStatus, type PriceAlertUpdateOutcome, type PrivateOrdersEvent, type Profile, type RateLimitConfig, type RateLimitDetail, RateLimitError, type RateLimitErrorOptions, type RateLimitFailureReason, type RateLimitPolicyClass, type RateLimitRefillModel, type RateLimitScope, type RealtimeConnection, type RealtimeConnectionState, type RealtimeConnectionStatus, RealtimeError, type RealtimeErrorOptions, type RegenerateRecoveryCodesInput, type RegenerateRecoveryCodesResult, type ReleaseFreshStepUpInput, type RemoveSubaccountMemberInput, RequestDeadlineExceededError, RequestError, RequestTooLargeError, type ResolveAccountInput, type ResolvedAccount, type ResolvedInternalTransferDestination, ResourceNotFoundError, type RespondSubaccountInviteInput, type ResumeTriggerInput, type ResumeTriggerResult, RevisionConflictError, type RewardAward, type RewardFulfillmentMethod, type RewardFulfillmentState, type RiskPolicyInput, type RotateGuardSignerWalletResult, type SdkSubscriptionErrorContext, type SendAssistantMessageInput, type ServerSessionCookieOptions, type ServerSessionSnapshot, ServiceUnavailableError, type SessionData, SessionElevationRequiredError, type SetAssistantKeysInput, type SetAutoWithdrawRuleEnabledInput, type SetAutoWithdrawRuleInput, type SetRewardDestinationInput, type SetRewardDestinationResult, type SetSubaccountMemberMfaRequirementInput, type SetTelegramApprovalLimitsInput, type SignProtectedActionInput, type SocialProvider, type SocialProviderInput, type SocialVerification, type SocialVerificationErrorCode, type SocialVerificationMethod, type SocialVerificationStatus, type SparklineIntervalName, type SpotConfig, type SpotFeeDiscount, type SpotFeeRate, type SpotFeeRateBreakdown, type SpotPairVolumeSeries, type SpotVolumeHistoryInput, type SpotVolumeHistoryResponse, type StablecoinConversionRate, StaleQuoteError, type StartVerificationInput, type StartVerificationResponse, StepUpRequiredError, type StopDetailsOutput, type StopLossInput, type Subaccount, type SubaccountActivityInput, type SubaccountChallenge, SubaccountChallengeInvalidError, type SubaccountEvent, type SubaccountIdInput, type SubaccountInvite, type SubaccountInviteStatus, type SubaccountMember, type SubaccountPermission, type SubaccountPermissionDefinition, type SubaccountPolicy, type SubaccountPolicyApplyInput, type SubaccountPolicyCreateInput, type SubaccountPolicyUpdateInput, type SubaccountRole, type SubaccountRoleCatalog, type SubaccountRoleDefinition, type SubaccountScopedInput, type SubaccountStatus, type SubscribeHandlers, type SubscribeZippedAssetSupplyInput, type SystemVersion, type TakeProfitInput, type TelegramApprovalAction, type TelegramApprovalLimits, type Timeframe, TimeoutError, TimestampSkewError, type Trade, type TradeBackfill, type TradingRateLimitClass, type TradingRateLimitRule, type TradingRateLimits, type TradingWithdrawSigningConfig, type TradingWithdrawWalletSigner, type TrailingDetailsOutput, type TrailingStopInput, type TransferCodeValue, type TransferCounterparties, type TransferCounterparty, type TransferDestination, type TransferDestinations, type TransferSideKind, TransientError, type Transports, type Trigger, type TriggerDetailsOutput, type TriggerEvent, type TwapDetailsOutput, type UnifiedAssetBalancesResponse, type UnlinkSocialAccountInput, type UpdateAddressBookEntryInput, type UpdateAddressBookTagInput, type UpdateMfaFactorInput, type UpdateMfaFactorResult, type UpdatePriceAlertInput, type UpdatePriceAlertResult, type UpdateProfileInput, type UpdateSubaccountInput, type UpdateSubaccountMemberRoleInput, UserOperationAlreadyKnownError, UserOperationNotExecutedError, UserOperationSendTimeoutError, type UsernameHistoryEntry, type ValidateWithdrawDestinationInput, type ValidateWithdrawDestinationResult, ValidationError, type VerificationReadyResponse, type VerifyRecoveryCodeChallengeInput, type VerifyTotpChallengeInput, type VipMetricQuality, type VipMetricStatus, type VipStatus, type VipTier, type VipTierCatalog, type WalletChallenge, type WatchAssistantRunInput, WithdrawDeadlineExpiredError, type WithdrawWhitelistView, type ZippedAssetSupplyBatch, type ZippedAssetSupplyGroupResponse, type ZippedAssetSupplyResponse, type ZippedAssetSupplySeries, type ZippedAssetSupplyUpdate, type ZipperAssetChainVariant, type ZipperAssetConfig, type ZipperChainConfig, type ZipperChainContractConfig, type ZipperMemoRequirement, checksumEvmAddress, columnarTimestampSecAt, compareUnsignedIntegerStrings, connectErrorToPolyesterError, createCookieAuthTokenStorage, createErrorMappingInterceptor, createMemoryAuthTokenStorage, createPolyesterEnvironment, createPolyesterServerClientFromCookies, createPolyesterServerClientFromRequest, createPolyesterServerCoreFromCookies, createPolyesterServerCoreFromRequest, errorFromHttpStatus, evmHexToBytes, evmUtf8ToBytes, evmUtf8ToHex, expandColumnarTimestampsSec, formatConnectError, formatLedgerBalance, formatUserFacingError, isAbortError, isEvmAddress, isEvmAddressStrict, isFreshStepUpRequiredError, isMfaEnrollmentRequiredError, isMfaLastFactorRequiredError, isPolicyInUseError, isPolicyLockedError, isPolicyScopeMismatchError, isResourceNotFoundError, isRetryableError, isRevisionConflictError, isSessionElevationRequiredError, isTimeoutAbortError, keccak256Hex, loadErrorDetailDecoders, mergeLedgerBalances, normalizeErrorMessage, resolveAuthCookieName, shouldApplyReconciliationUpdate, tsObjToNsString as timestampToNanoseconds, toPolyesterError, validateCreateAddressBookEntryInput };
143
+ export { type AccountCodeValue, type AccountIdentity, type AccountNotification, type AccountNotificationDetail, type AccountScope, type AccountScopedInput, type AccountSigner, type AccountSignerAuthEvents, type AccountSignerConfig, type CreateSubaccountResult as AccountSignerCreateSubaccountResult, type AccountSignerFactory, type AcknowledgeRewardAwardInput, type AcknowledgeRewardAwardResult, type ActiveAccountInfo, type AddressBook, type AddressBookAccountScope, type AddressBookEntries, type AddressBookEntriesView, type AddressBookEntry, type AddressBookRecentDestinationsView, type AddressBookTag, type AddressBookTagSummary, type AddressBookView, type AddressBookViewInvalidated, AlreadyExistsError, type ApiKey, type ApiKeyEd25519AuthProvider, type ApiKeyIdInput, type ApiKeyPolicy, type ApiKeyPolicyApplyInput, type ApiKeyPolicyCreateInput, type ApiKeyPolicyUpdateInput, type ApiKeyStatus, type ApiKeysCreateInput, type ApiKeysListInput, type ApiKeysUpdateInput, type AssetConfig, type AssetEditorialInfo, type AssetInfo, type AssistantApprovalDecision, type AssistantApprovalPreview, type AssistantApprovalStatus, type AssistantConversation, type AssistantDisplaySetting, type AssistantFailureCategory, type AssistantKey, type AssistantKeyPreset, type AssistantKeySpecInput, type AssistantKeyState, type AssistantMemory, type AssistantMemoryKind, type AssistantMessage, type AssistantMessageRole, type AssistantOrderPreview, type AssistantOrderPriceField, type AssistantPriceOffsetDirection, type AssistantPriceRounding, type AssistantReferencePriceSource, type AssistantRunEvent, type AssistantRunIdInput, type AssistantTriggerChangeAction, type AssistantTriggerDirection, type AssistantUnfilledSlicePolicy, type AssistantView, type AuthCookieLocation, type AuthHydrationData, type AuthLoginMethod, type AuthState, type AuthTokenStorage, type AuthTokenStorageSetOptions, AuthenticationError, type AutoWithdrawCadence, type AutoWithdrawDestination, type AutoWithdrawDestinationInput, type AutoWithdrawHoldReason, type AutoWithdrawPause, type AutoWithdrawPauseReason, type AutoWithdrawPreview, type AutoWithdrawPreviewAsset, type AutoWithdrawPreviewStatus, type AutoWithdrawRule, type AutoWithdrawRun, type AutoWithdrawRunReason, type AutoWithdrawRunState, type AutoWithdrawSchedule, type AutoWithdrawScheduleInput, type AutoWithdrawScopedInput, type AutoWithdrawStep, type AutoWithdrawStepReason, type AutoWithdrawStepState, type AutoWithdrawWeekday, type BalanceHistoryInput, type BalanceHistoryResponse, type BalanceRange, type BatchCancelOrderInput, type BatchCancelOrderResult, type BatchCancelOrdersInput, type BatchCancelOrdersResult, type BatchCancelTriggerResult, type BatchCancelTriggersInput, type BatchCancelTriggersResult, type BatchCreateOrderResult, type BatchCreateOrdersInput, type BatchCreateOrdersResult, type BatchGuardApprovals, type BatchReplaceAdmissionItem, type BatchReplaceOrdersInput, type BatchReplaceOrdersResult, type BatchSignProtectedActionInput, type BeginMfaChallengeInput, type BeginMfaChallengeResult, type BeginPasskeyEnrollmentInput, type BeginPasskeyEnrollmentResult, type BeginTotpEnrollmentInput, type BeginTotpEnrollmentResult, type BrokerAllowlistAction, type BrokerAllowlistEvent, type CancelAllAfterInput, type CancelAllAfterResult, type CancelAllOrdersInput, type CancelAllOrdersResponse, type CancelOcoInput, type CancelOcoResult, type CancelOrderInput, type CancelOrderResult, type CancelPriceAlertInput, type CancelTriggerInput, type CancelTriggerResult, type Candle, type CandleColumnar, type CandleColumnarInt, type CandleInt, type ChainAnalyticsRange, type ChangelogAudience, type ChangelogChange, type ChangelogChangeAvailability, type ChangelogChangeCategory, type ChangelogChangeEntry, type ChangelogDeploymentGroup, type ChangelogDeploymentGroupSummary, type ChangelogEnvironment, type ChangelogPost, type ChangelogPostSummary, type ChangelogSection, type ChangelogSort, type ChangelogSurface, type Checkpoint, type CheckpointAssetAmount, type CheckpointBadge, type CheckpointBiggestTrade, type CheckpointChainFlow, type CheckpointEarnedBadge, type CheckpointField, type CheckpointFlowTotal, type CheckpointFundingDay, type CheckpointFundingFlowSummary, type CheckpointOrderToolCounts, type CheckpointOrderTypeCounts, type CheckpointPairActivity, type CheckpointPortfolioValuePoint, type CheckpointTimeInForceCounts, type CheckpointVipTierChange, type CheckpointVolumePoint, type ClaimCampaign, type ClaimDailyRewardInput, type ClaimDailyRewardResult, type ClaimFreshStepUpInput, type ClaimFreshStepUpResult, type ClaimGeneratedUsernameInput, ClaimOutcomeUnknownError, type ClaimOutcomeUnknownErrorOptions, type ClaimPayoutDelayReason, type ClaimPolicy, type ColumnarTimeWindow, type CompleteAssistantKeysInput, type CompleteMfaChallengeResult, ConfigurationError, type ConfirmVerificationInput, type ConnectChannelParams, type ConnectPrivateOrdersParams, type ConsumeFreshStepUpInput, type CookieAuthTokenStorageOptions, type CopyAddressBookEntryInput, type CreateAddressBookEntryInput, type CreateAddressBookTagInput, type CreateDepositAddressInput, type CreateGuardSignerWalletResult, type CreateInternalTransferInput, type CreateInternalTransferResult, type CreateOcoInput, type CreateOcoResult, type CreateOrderResult, type CreateOrderbookSubscriptionInput, type CreatePolyesterAccountSignerParams, type CreatePolyesterEnvironmentParams, type CreatePriceAlertInput, type CreateServerClientFromCookiesParams, type CreateServerClientFromRequestParams, type CreateSubaccountChallengeInput, type CreateSubaccountInput, type CreateSubaccountParams, type CreateSubaccountResult$1 as CreateSubaccountResult, type CreateSubaccountResult$1 as CreateSubaccountServiceResult, type CreateTradingWithdrawResult, type CreateTradingWithdrawToExternalChainInput, type CreateTradingWithdrawToExternalChainServiceInput, type CreateTradingWithdrawToFundingInput, type CreateTradingWithdrawToFundingServiceInput, type CreateTriggerInput, type CreateTriggerResult, type CreateWalletChallengeInput, type CurrencyConversionConfig, type CurrencyConversionRates, type CurrencyMetadata, type DailyClaimReward, type DailyClaimState, type DailyClaimStatus, type DailyClaimTransfer, type DecideAssistantApprovalInput, type DeleteAddressBookEntryInput, type DeleteAddressBookTagInput, type DeleteAssistantMemoryInput, type DeleteMfaFactorInput, type DepositAddress, type DepositWithdrawConfig, type EffectiveSubaccountPermissions, type EquityGroupBy, type EquityHistoryInput, type EquityHistoryResponse, type EquitySeries, type EquitySeriesGrouping, type EvmHex, type ExportGuardSignerWalletResult, type ExportStatementInput, type FiatConversionRate, type FiatConversionSnapshot, type FinishPasskeyChallengeInput, type FinishPasskeyEnrollmentInput, type FinishPasskeyEnrollmentResult, type FinishTotpEnrollmentInput, type FinishTotpEnrollmentResult, type GeneratedUsernameOffer, type GetAddressBookViewInput, type GetBatchReplaceStatusInput, type GetBatchReplaceStatusResult, type GetCandlesColumnsInput, type GetCandlesInput, type GetChangelogDeploymentGroupInput, type GetChangelogPostInput, type GetInternalTransferInput, type GetInternalTransferResult, type GetLifecycleFlowInput, type GetLifecycleFlowOutput, type GetMarketTradesInput, type GetNotificationInput, type GetOrderDetailsInput, type GetOrderbookHeatmapInput, type GetOrderbookInput, type GetSpotFeeRatesInput, type GetSubaccountInput, type GetTriggerInput, type GetUnifiedAssetBalancesInput, type GetUserTradesInput, type GetVerificationResponse, type GetWalletBalancesInput, type GetWalletBalancesResult, type GetZippedAssetSupplyGroupInput, type GetZippedAssetSupplyInput, type GuardApproval, type GuardSignerScopedInput, type GuardSignerStatus, type HeatmapDepthValue, type HeatmapIntervalValue, type HeatmapQuantityModeValue, type HexAddress, InternalServerError, type InternalTransferDestination, type InternalTransferStatus, type InternalTransferWhitelistEntries, type InternalTransferWhitelistEntry, type InviteSubaccountMemberInput, type JwtAuthProvider, type LadderDetailsOutput, type LedgerBalance, type LedgerTransfer, type LedgerTransferSide, type LifecycleAssetIds, type LifecycleFlowDetail, type LifecycleFlowState, type LifecycleFlowStep, type LifecycleFlowStepActivity, type LifecycleFlowSummary, type LifecycleFlowSummaryProgress, type LifecycleFlowTimelineItem, type LifecycleFlowTxMatch, type LifecycleListOrderBy, type LifecycleListScope, type LifecycleReason, type LifecycleRequestFee, type LifecycleRequestFeeStatus, type LifecycleSort, type LifecycleTxLookupKind, type LifecycleZipperReason, type LifecycleZipperReasonCode, type ListAddressBookEntriesInput, type ListApiKeyPoliciesResponse, type ListAssetInfoInput, type ListAssistantConversationsInput, type ListAssistantConversationsResult, type ListAssistantMemoriesInput, type ListAssistantMemoriesResult, type ListAssistantMessagesInput, type ListAssistantMessagesResult, type ListAutoWithdrawRunsInput, type ListAutoWithdrawRunsResult, type ListChangelogChangesInput, type ListChangelogChangesResult, type ListChangelogDeploymentGroupsInput, type ListChangelogDeploymentGroupsResult, type ListChangelogPostsInput, type ListChangelogPostsResult, type ListCheckpointsInput, type ListDepositAddressesInput, type ListInternalTransferWhitelistEntriesInput, type ListLifecycleFlowsByTxInput, type ListLifecycleFlowsByTxOutput, type ListLifecycleFlowsInput, type ListLifecycleFlowsOutput, type ListMarketOverviewInput, type ListMfaFactorsResult, type ListNotificationsInput, type ListNotificationsResult, type ListPriceAlertsInput, type ListPriceAlertsResult, type ListRewardAwardsInput, type ListRewardAwardsResult, type ListStatusEventsInput, type ListStatusEventsResult, type ListSubaccountInvitesInput, type ListTransferCounterpartiesInput, type ListTransferDestinationsInput, type ListTransfersInput, type ListTriggerEventsInput, type ListTriggerEventsResult, type ListTriggersInput, type ListTriggersResult, type LoginOptions, type LoginResult, type LoginWithWalletInput, type LoginWithWalletResponse, type MarkAllNotificationsReadInput, type MarkNotificationsInput, type MarketOverview, type MarketOverviewOrderBy, type MarketOverviewSort, type MarketOverviewSparkline, type MarketTrade, type Me, MfaEnrollmentRequiredError, type MfaFactor, MfaLastFactorRequiredError, MfaRequiredError, type MfaSessionInfo, MfaVerificationError, type MfaVerificationFailureReason, type MirroredWithdrawWhitelistEntry, type ModifyOrderInput, type ModifyOrderResult, type ModifyTriggerInput, type ModifyTriggerResult, NetworkError, type NewOrderInput, type NextVipTierThresholds, NotImplementedError, type NotificationCategory, type NotificationCounts, type NotificationReadState, type NotificationType, type OpenOrdersInput, type Order, type OrderDetails, type OrderErrorCode, type OrderErrorDetail, type OrderHistoryInput, type OrderIntentInput, type OrderLineage, type OrderTransfer, type OrderbookData, type OrderbookHeatmapDeltaBucket, type OrderbookHeatmapDeltaChain, type OrderbookHeatmapDeltaLevels, type OrderbookHeatmapKeyframe, type OrderbookHeatmapLevels, type OrderbookHeatmapLiveBucket, type OrderbookHeatmapResponse, type OrderbookLevel, type OrderbookStreamHandlers, type OrderbookSubscription, OutcomeUnknownError, POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_DEVNET_ENVIRONMENT, POLYESTER_SESSION_COOKIE_NAME, POLYESTER_TESTNET_ENVIRONMENT, type PairConfig, type PairStatus, type PauseTriggerInput, type PauseTriggerResult, PermissionError, type PolicyAction, PolicyInUseError, PolicyLockedError, type PolicyMarketScope, PolicyScopeMismatchError, type PolyesterAccountAbstractionEnvironment, PolyesterBrowserClient, type PolyesterBrowserClientConfig, PolyesterBrowserCore, PolyesterClient, type PolyesterClientBaseConfig, type PolyesterClientConfig, type PolyesterContractsEnvironment, PolyesterCore, type PolyesterEntryPointConfig, type PolyesterEnvironment, PolyesterError, type PolyesterErrorCode, type PolyesterErrorDetail, type PolyesterErrorOptions, type PolyesterMutationOptions, type PolyesterRealtime, type PolyesterRealtimeAuthConfig, type PolyesterRequestOptions, type PolyesterSafeDeploymentConfig, PolyesterServerClient, type PolyesterServerClientConfig, PolyesterServerCore, type PolyesterServices, type PortfolioEquityHistoryInput, type PortfolioEquityHistoryResponse, type PortfolioEquitySeries, type PortfolioEquitySeriesGrouping, type PortfolioEquitySnapshotResponse, PreconditionFailedError, type PrepareAssistantKeysInput, type PrepareAssistantKeysResult, type PreparedAssistantKey, type PreparedTradingWithdraw, type PreviewOrderResult, type PriceAlert, type PriceAlertChannel, type PriceAlertDirection, type PriceAlertPriceSource, type PriceAlertStatus, type PriceAlertUpdateOutcome, type PrivateOrdersEvent, type Profile, type RateLimitConfig, type RateLimitDetail, RateLimitError, type RateLimitErrorOptions, type RateLimitFailureReason, type RateLimitPolicyClass, type RateLimitRefillModel, type RateLimitScope, type RealtimeConnection, type RealtimeConnectionState, type RealtimeConnectionStatus, RealtimeError, type RealtimeErrorOptions, type RegenerateRecoveryCodesInput, type RegenerateRecoveryCodesResult, type ReleaseFreshStepUpInput, type RemoveSubaccountMemberInput, RequestDeadlineExceededError, RequestError, RequestTooLargeError, type ResolveAccountInput, type ResolvedAccount, type ResolvedInternalTransferDestination, ResourceNotFoundError, type RespondSubaccountInviteInput, type ResumeTriggerInput, type ResumeTriggerResult, RevisionConflictError, type RewardAward, type RewardFulfillmentMethod, type RewardFulfillmentState, type RiskPolicyInput, type RotateGuardSignerWalletResult, type SdkSubscriptionErrorContext, type SendAssistantMessageInput, type ServerSessionCookieOptions, type ServerSessionSnapshot, ServiceUnavailableError, type SessionData, SessionElevationRequiredError, type SetAssistantKeysInput, type SetAutoWithdrawRuleEnabledInput, type SetAutoWithdrawRuleInput, type SetRewardDestinationInput, type SetRewardDestinationResult, type SetSubaccountMemberMfaRequirementInput, type SetTelegramApprovalLimitsInput, type SignProtectedActionInput, type SocialProvider, type SocialProviderInput, type SocialVerification, type SocialVerificationErrorCode, type SocialVerificationMethod, type SocialVerificationStatus, type SparklineIntervalName, type SpotConfig, type SpotFeeDiscount, type SpotFeeRate, type SpotFeeRateBreakdown, type SpotPairVolumeSeries, type SpotVolumeHistoryInput, type SpotVolumeHistoryResponse, type StablecoinConversionRate, StaleQuoteError, type StartVerificationInput, type StartVerificationResponse, type StatementPage, type StatusEvent, type StatusEventImpact, type StatusEventKind, type StatusEventService, type StatusEventState, StepUpRequiredError, type StopDetailsOutput, type StopLossInput, type Subaccount, type SubaccountActivityInput, type SubaccountChallenge, SubaccountChallengeInvalidError, type SubaccountEvent, type SubaccountIdInput, type SubaccountInvite, type SubaccountInviteStatus, type SubaccountMember, type SubaccountPermission, type SubaccountPermissionDefinition, type SubaccountPolicy, type SubaccountPolicyApplyInput, type SubaccountPolicyCreateInput, type SubaccountPolicyUpdateInput, type SubaccountRole, type SubaccountRoleCatalog, type SubaccountRoleDefinition, type SubaccountScopedInput, type SubaccountStatus, type SubscribeHandlers, type SubscribeZippedAssetSupplyInput, type SystemVersion, type TakeProfitInput, type TelegramApprovalAction, type TelegramApprovalLimits, type Timeframe, TimeoutError, TimestampSkewError, type Trade, type TradeBackfill, type TradingRateLimitClass, type TradingRateLimitRule, type TradingRateLimits, type TradingWithdrawSigningConfig, type TradingWithdrawWalletSigner, type TrailingDetailsOutput, type TrailingStopInput, type TransferCodeValue, type TransferCounterparties, type TransferCounterparty, type TransferDestination, type TransferDestinations, type TransferSideKind, TransientError, type Transports, type Trigger, type TriggerDetailsOutput, type TriggerEvent, type TwapDetailsOutput, type UnifiedAssetBalancesResponse, type UnlinkSocialAccountInput, type UpdateAddressBookEntryInput, type UpdateAddressBookTagInput, type UpdateMfaFactorInput, type UpdateMfaFactorResult, type UpdatePriceAlertInput, type UpdatePriceAlertResult, type UpdateProfileInput, type UpdateSubaccountInput, type UpdateSubaccountMemberRoleInput, UserOperationAlreadyKnownError, UserOperationNotExecutedError, UserOperationSendTimeoutError, type UsernameHistoryEntry, type ValidateWithdrawDestinationInput, type ValidateWithdrawDestinationResult, ValidationError, type VerificationReadyResponse, type VerifyRecoveryCodeChallengeInput, type VerifyTotpChallengeInput, type VipMetricQuality, type VipMetricStatus, type VipStatus, type VipTier, type VipTierCatalog, type WalletChallenge, type WatchAssistantRunInput, WithdrawDeadlineExpiredError, type WithdrawWhitelistView, type ZippedAssetSupplyBatch, type ZippedAssetSupplyGroupResponse, type ZippedAssetSupplyResponse, type ZippedAssetSupplySeries, type ZippedAssetSupplyUpdate, type ZipperAssetChainVariant, type ZipperAssetConfig, type ZipperChainConfig, type ZipperChainContractConfig, type ZipperMemoRequirement, type ZipperRouteStatus, checksumEvmAddress, columnarTimestampSecAt, compareUnsignedIntegerStrings, connectErrorToPolyesterError, createCookieAuthTokenStorage, createErrorMappingInterceptor, createMemoryAuthTokenStorage, createPolyesterEnvironment, createPolyesterServerClientFromCookies, createPolyesterServerClientFromRequest, createPolyesterServerCoreFromCookies, createPolyesterServerCoreFromRequest, errorFromHttpStatus, evmHexToBytes, evmUtf8ToBytes, evmUtf8ToHex, expandColumnarTimestampsSec, formatConnectError, formatLedgerBalance, formatUserFacingError, isAbortError, isEvmAddress, isEvmAddressStrict, isFreshStepUpRequiredError, isMfaEnrollmentRequiredError, isMfaLastFactorRequiredError, isPolicyInUseError, isPolicyLockedError, isPolicyScopeMismatchError, isResourceNotFoundError, isRetryableError, isRevisionConflictError, isSessionElevationRequiredError, isTimeoutAbortError, keccak256Hex, loadErrorDetailDecoders, mergeLedgerBalances, normalizeErrorMessage, resolveAuthCookieName, shouldApplyReconciliationUpdate, tsObjToNsString as timestampToNanoseconds, toPolyesterError, validateCreateAddressBookEntryInput };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_SESSION_COOKIE_NAME, resolveAuthCookieName } from "./services/auth/cookie-constants.js";
1
2
  import { AlreadyExistsError, AuthenticationError, ClaimOutcomeUnknownError, ConfigurationError, InternalServerError, MfaEnrollmentRequiredError, MfaLastFactorRequiredError, MfaRequiredError, MfaVerificationError, NetworkError, NotImplementedError, OutcomeUnknownError, PermissionError, PolicyInUseError, PolicyLockedError, PolicyScopeMismatchError, PolyesterError, PreconditionFailedError, RateLimitError, RealtimeError, RequestDeadlineExceededError, RequestError, RequestTooLargeError, ResourceNotFoundError, RevisionConflictError, ServiceUnavailableError, SessionElevationRequiredError, StaleQuoteError, StepUpRequiredError, SubaccountChallengeInvalidError, TimeoutError, TimestampSkewError, TransientError, UserOperationAlreadyKnownError, UserOperationNotExecutedError, UserOperationSendTimeoutError, ValidationError, WithdrawDeadlineExpiredError, errorFromHttpStatus, isAbortError, isTimeoutAbortError, normalizeErrorMessage } from "./shared/errors.js";
2
3
  import { loadErrorDetailDecoders } from "./shared/error-detail.js";
3
4
  import { connectErrorToPolyesterError, createErrorMappingInterceptor, toPolyesterError } from "./shared/connect-error-mapping.js";
@@ -9,7 +10,6 @@ import { validateCreateAddressBookEntryInput } from "./services/address-book/add
9
10
  import { formatLedgerBalance } from "./services/balances/balances.schemas.js";
10
11
  import { formatConnectError, formatUserFacingError, isPolicyInUseError, isPolicyLockedError, isPolicyScopeMismatchError, isResourceNotFoundError, isRetryableError, isRevisionConflictError } from "./utils/errors.js";
11
12
  import { PolyesterClient } from "./client.js";
12
- import { POLYESTER_AUTH_TOKEN_COOKIE_NAME, POLYESTER_SESSION_COOKIE_NAME, resolveAuthCookieName } from "./services/auth/cookie-constants.js";
13
13
  import { createCookieAuthTokenStorage, createMemoryAuthTokenStorage } from "./services/auth/token-storage.js";
14
14
  import { PolyesterBrowserCore } from "./browser-core.js";
15
15
  import { PolyesterBrowserClient } from "./browser-client.js";
@@ -22,6 +22,14 @@ type PrivateOrdersEvent =
22
22
  type: "stale";
23
23
  stale: boolean;
24
24
  orderIds?: bigint[];
25
+ } |
26
+ /**
27
+ * The stream reflects every order change acknowledged before it subscribed, including
28
+ * every order read made before then. Wait for it before relying on the stream. Sent
29
+ * once per server subscription, so again after each resubscribe or reconnect.
30
+ */
31
+ {
32
+ type: "ready";
25
33
  };
26
34
  interface ConnectPrivateOrdersParams {
27
35
  /** The account's base58 public ID. */
@@ -1 +1 @@
1
- {"version":3,"file":"private-orders.d.ts","names":[],"sources":["../../src/realtime/private-orders.ts"],"mappings":";;;;;KAgCY;;;EAEJ;EAAkB,QAAQ;;;;EAE1B;EAAc,MAAM;;;;;;;EAKpB;EAAe;EAAgB;;UAEtB;;EAEb;EACA,UAAU,OAAO;;EAEjB;;EAEA;EACA,WAAW,KAAK"}
1
+ {"version":3,"file":"private-orders.d.ts","names":[],"sources":["../../src/realtime/private-orders.ts"],"mappings":";;;;;KAkCY;;;EAEJ;EAAkB,QAAQ;;;;EAE1B;EAAc,MAAM;;;;;;;EAKpB;EAAe;EAAgB;;;;;;;;EAM/B;;UAES;;EAEb;EACA,UAAU,OAAO;;EAEjB;;EAEA;EACA,WAAW,KAAK"}
@@ -6,6 +6,8 @@ import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
6
6
  //#region src/realtime/private-orders.ts
7
7
  const PRIVATE_WS_SUBPROTOCOL = "polyester.v1.proto";
8
8
  const HEARTBEAT_TIMEOUT_MS = 3e3;
9
+ /** Heartbeats keep the connection alive without answering a Subscribe, so it gets its own deadline. */
10
+ const SUBSCRIBE_ACK_TIMEOUT_MS = 3e4;
9
11
  const BACKOFF_BASE_MS = 500;
10
12
  const BACKOFF_MAX_MS = 1e4;
11
13
  /** A connection that stayed up this long resets the reconnect backoff. */
@@ -82,6 +84,7 @@ var PrivateOrderStream = class {
82
84
  orders: null,
83
85
  state: "pending",
84
86
  stale: null,
87
+ ready: false,
85
88
  retries: 0,
86
89
  retryTimer: null
87
90
  };
@@ -121,6 +124,7 @@ var PrivateOrderStream = class {
121
124
  type: "snapshot",
122
125
  orders
123
126
  }));
127
+ if (s.ready) this.#deliverTo(s, c, () => params.onEvent({ type: "ready" }));
124
128
  const { stale } = s;
125
129
  if (stale) this.#deliverTo(s, c, () => params.onEvent({
126
130
  type: "stale",
@@ -193,10 +197,11 @@ var PrivateOrderStream = class {
193
197
  async #subscribe(ws, s) {
194
198
  if (!this.#isCurrent(s)) return;
195
199
  const id = this.#nextRequestId();
196
- this.#pending.set(id, {
200
+ const request = {
197
201
  kind: "subscribe",
198
202
  s
199
- });
203
+ };
204
+ this.#pending.set(id, request);
200
205
  let token;
201
206
  try {
202
207
  token = await this.#config.fetchSubscribeToken(s.channel);
@@ -222,6 +227,29 @@ var PrivateOrderStream = class {
222
227
  cursor: s.cursor
223
228
  }
224
229
  });
230
+ request.timer = setTimeout(() => this.#expireSubscribe(ws, id), SUBSCRIBE_ACK_TIMEOUT_MS);
231
+ }
232
+ /**
233
+ * Ends a subscription the server never confirmed; one it confirmed before reports the
234
+ * timeout and subscribes again. A late Subscribed for the expired request is unsubscribed.
235
+ */
236
+ #expireSubscribe(ws, id) {
237
+ const request = this.#settle(id);
238
+ if (!request) return;
239
+ const error = new RealtimeError("Private order subscribe acknowledgement timed out", { retryable: true });
240
+ if (request.s.state === "pending") {
241
+ this.#terminate(request.s, "subscribe", error);
242
+ return;
243
+ }
244
+ this.#report(request.s, "subscribe", error);
245
+ this.#retrySubscribe(ws, request.s);
246
+ }
247
+ /** Forgets a request and its answer deadline. */
248
+ #settle(id) {
249
+ const request = this.#pending.get(id);
250
+ clearTimeout(request?.timer);
251
+ this.#pending.delete(id);
252
+ return request;
225
253
  }
226
254
  /** Subscribes again after a backoff that grows until the subscription delivers data. */
227
255
  #retrySubscribe(ws, s) {
@@ -271,6 +299,7 @@ var PrivateOrderStream = class {
271
299
  s.sub = "";
272
300
  s.seq = 0n;
273
301
  s.staged = null;
302
+ s.ready = false;
274
303
  if (s.retries > 0) this.#retrySubscribe(ws, s);
275
304
  else {
276
305
  s.retries = 1;
@@ -319,7 +348,7 @@ var PrivateOrderStream = class {
319
348
  if (msg.sub) this.#unsubscribe(ws, msg.sub);
320
349
  return;
321
350
  }
322
- this.#pending.delete(frame.value.id);
351
+ this.#settle(frame.value.id);
323
352
  const s = request.s;
324
353
  s.sub = msg.sub;
325
354
  s.seq = 0n;
@@ -411,6 +440,8 @@ var PrivateOrderStream = class {
411
440
  return;
412
441
  case "ready":
413
442
  s.retries = 0;
443
+ s.ready = true;
444
+ this.#deliver(s, (p) => p.onEvent({ type: "ready" }));
414
445
  return;
415
446
  case "unavailable": {
416
447
  const { orderIds } = frame.value;
@@ -444,7 +475,7 @@ var PrivateOrderStream = class {
444
475
  if (error.id && this.#unsubscribing.delete(error.id)) return;
445
476
  const request = error.id ? this.#pending.get(error.id) : void 0;
446
477
  if (error.id && !request) return;
447
- if (request) this.#pending.delete(error.id);
478
+ if (request) this.#settle(error.id);
448
479
  const s = request?.s ?? this.#bySub.get(sub);
449
480
  const realtimeError = new RealtimeError(error.message || `Private order stream request failed: ${RequestError_Code[error.code]}`, { realtimeCode: error.code });
450
481
  if (!s) {
@@ -512,6 +543,7 @@ var PrivateOrderStream = class {
512
543
  this.#authSent = false;
513
544
  if (this.#heartbeatTimer) clearTimeout(this.#heartbeatTimer);
514
545
  this.#heartbeatTimer = null;
546
+ for (const { timer } of this.#pending.values()) clearTimeout(timer);
515
547
  this.#pending.clear();
516
548
  this.#bySub.clear();
517
549
  this.#unsubscribing.clear();
@@ -520,6 +552,7 @@ var PrivateOrderStream = class {
520
552
  s.sub = "";
521
553
  s.seq = 0n;
522
554
  s.staged = null;
555
+ s.ready = false;
523
556
  }
524
557
  if (ws) {
525
558
  ws.onopen = null;
@@ -557,7 +590,7 @@ var PrivateOrderStream = class {
557
590
  this.#unsubscribe(ws, s.sub);
558
591
  }
559
592
  s.sub = "";
560
- for (const [id, request] of this.#pending) if (request.s === s) this.#pending.delete(id);
593
+ for (const [id, request] of this.#pending) if (request.s === s) this.#settle(id);
561
594
  if (this.#subs.size === 0) this.#shutdown();
562
595
  }
563
596
  #terminate(s, type, error) {
@@ -1 +1 @@
1
- {"version":3,"file":"private-orders.js","names":["#config","#subs","#pending","#bySub","#unsubscribing","#catchUp","#remove","#ws","#authSent","#subscribe","#connecting","#reconnectTimer","#open","#clearRetry","#shutdown","#isCurrent","#deliverTo","#terminateAll","#generation","#authenticate","#onFrame","#onClosed","#reportAll","#scheduleReconnect","#send","#authSentAt","#armHeartbeat","#reauthenticate","#nextRequestId","#terminate","#report","#retrySubscribe","#refresh","#unsubscribe","#deliver","#drop","#onRequestError","#resubscribe","#detach","#reconnectAttempt","#heartbeatTimer","#teardown","#call","#requestSeq"],"sources":["../../src/realtime/private-orders.ts"],"sourcesContent":["import { create, fromBinary, toBinary, type MessageInitShape } from \"@bufbuild/protobuf\";\nimport type { Order } from \"../gen/orders/v1/orders_read_pb.js\";\nimport {\n Channel,\n ClientMessageSchema,\n RequestError_Code,\n ServerMessageSchema,\n type Unit,\n} from \"../gen/privatews/v1/private_ws_pb.js\";\nimport { ConfigurationError, PolyesterError, RealtimeError } from \"../shared/errors.js\";\nimport {\n createSdkSubscriptionErrorContext,\n publicationHandlerErrorContext,\n type SdkSubscriptionErrorContext,\n} from \"../shared/subscription-errors.js\";\nimport { idToBigInt } from \"../utils/base58-id.js\";\n\nexport const PRIVATE_WS_SUBPROTOCOL = \"polyester.v1.proto\";\nconst HEARTBEAT_TIMEOUT_MS = 3_000;\nconst BACKOFF_BASE_MS = 500;\nconst BACKOFF_MAX_MS = 10_000;\n/** A connection that stayed up this long resets the reconnect backoff. */\nconst STABLE_CONNECTION_MS = 10_000;\n/** A malformed frame (4400) and a rejected connect token (4403) recur on every reconnect. */\nconst TERMINAL_CLOSE_CODES = new Set([4400, 4403]);\n/** Larger frames are dropped undecoded with the connection; a full 256-order page is far smaller. */\nexport const MAX_PRIVATE_FRAME_BYTES = 4 * 1024 * 1024;\n/** A snapshot staging more pages than this ends its subscription, so a snapshot never ending stays bounded. */\nexport const MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;\nexport const MAX_SNAPSHOT_ORDERS = 100_000;\n\n/** One delivery of an account's order stream. */\nexport type PrivateOrdersEvent =\n /** The account's full live view; replace local state with it. */\n | { type: \"snapshot\"; orders: Order[] }\n /** One change, applied whole. */\n | { type: \"unit\"; unit: Unit }\n /**\n * The account's live view is temporarily behind (`true`) or caught up (`false`).\n * `orderIds`, when set, names the only orders behind; the rest of the view is current.\n */\n | { type: \"stale\"; stale: boolean; orderIds?: bigint[] };\n\nexport interface ConnectPrivateOrdersParams {\n /** The account's base58 public ID. */\n accountId: string;\n onEvent: (event: PrivateOrdersEvent) => void;\n /** Called when the server confirms the subscription, again after each reconnect. */\n onConnected?: () => void;\n /** Called when the connection carrying the subscription drops. */\n onDisconnected?: () => void;\n onError?: (ctx: SdkSubscriptionErrorContext) => void;\n}\n\nexport interface PrivateOrderStreamConfig {\n url: string;\n fetchConnectToken: () => Promise<string>;\n fetchSubscribeToken: (channel: string) => Promise<string>;\n}\n\ntype ClientOp = MessageInitShape<typeof ClientMessageSchema>[\"op\"];\n\ninterface Consumer {\n params: ConnectPrivateOrdersParams;\n /** False until a consumer that joined a running subscription received its current state. */\n caughtUp: boolean;\n}\n\n/** One server subscription per account, shared by every consumer of that account. */\ninterface StreamSubscription {\n consumers: Set<Consumer>;\n channel: string;\n account: bigint;\n /** Server subscription ID; empty until Subscribed. */\n sub: string;\n seq: bigint;\n /** Last applied resume position, carried across resubscribes and reconnects. */\n cursor: string;\n staged: Order[] | null;\n /** Frame bytes of the staged pages. */\n stagedBytes: number;\n /** The account's live view as last applied, for consumers that join later; null before the first snapshot. */\n orders: Map<bigint, Order> | null;\n /** The last connection state consumers were told about. */\n state: \"pending\" | \"connected\" | \"disconnected\";\n /** What consumers were last told is stale, until they are told it caught up. */\n stale: { orderIds?: bigint[] } | null;\n /** Subscribe attempts since the subscription last delivered data; drives retry backoff. */\n retries: number;\n retryTimer: ReturnType<typeof setTimeout> | null;\n}\n\ntype PendingRequest = { kind: \"subscribe\" | \"refresh\"; s: StreamSubscription };\n\n/** 0.5 s doubling to 10 s, jittered over the upper half of each step. */\nfunction backoffMs(attempt: number): number {\n const ceiling = Math.min(BACKOFF_MAX_MS, BACKOFF_BASE_MS * 2 ** (attempt + 1));\n return ceiling / 2 + Math.random() * (ceiling / 2);\n}\n\nfunction isTerminalTokenError(error: unknown): boolean {\n return error instanceof PolyesterError && !error.retryable;\n}\n\n/**\n * Account order streams over the private WebSocket (`/v1/ws/private`). One\n * connection carries every subscription; each resumes from its last cursor\n * after a gap, an expired token, or a reconnect.\n */\nexport class PrivateOrderStream {\n readonly #config: PrivateOrderStreamConfig;\n /** Keyed by channel. A subscription whose last consumer left stays until the next microtask. */\n readonly #subs = new Map<string, StreamSubscription>();\n readonly #pending = new Map<string, PendingRequest>();\n readonly #bySub = new Map<string, StreamSubscription>();\n /** IDs of Unsubscribe requests awaiting their answer. */\n readonly #unsubscribing = new Set<string>();\n #ws: WebSocket | null = null;\n /** A connect token fetch for the next socket is in flight. */\n #connecting = false;\n /** Bumped on shutdown so a token fetch that outlived it opens nothing. */\n #generation = 0;\n #authSent = false;\n #authSentAt = 0;\n #reconnectAttempt = 0;\n #reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n #heartbeatTimer: ReturnType<typeof setTimeout> | null = null;\n #requestSeq = 0;\n\n constructor(config: PrivateOrderStreamConfig) {\n this.#config = config;\n }\n\n /** Throws ValidationError when accountId is not a base58 public ID. */\n connect(params: ConnectPrivateOrdersParams): () => void {\n const channel = `private:spot:orders:${params.accountId}`;\n const account = idToBigInt(params.accountId, \"accountId\");\n const existing = this.#subs.get(channel);\n if (existing) {\n const consumer: Consumer = { params, caughtUp: false };\n existing.consumers.add(consumer);\n queueMicrotask(() => this.#catchUp(existing, consumer));\n return () => this.#remove(existing, consumer);\n }\n const consumer: Consumer = { params, caughtUp: true };\n const s: StreamSubscription = {\n consumers: new Set([consumer]),\n channel,\n account,\n sub: \"\",\n seq: 0n,\n cursor: \"\",\n staged: null,\n stagedBytes: 0,\n orders: null,\n state: \"pending\",\n stale: null,\n retries: 0,\n retryTimer: null,\n };\n this.#subs.set(channel, s);\n if (this.#ws && this.#authSent) void this.#subscribe(this.#ws, s);\n else if (!this.#ws && !this.#connecting && !this.#reconnectTimer) this.#open();\n return () => this.#remove(s, consumer);\n }\n\n /** Closes the connection and drops every subscription without callbacks. */\n disconnect(): void {\n for (const s of this.#subs.values()) {\n this.#clearRetry(s);\n // A consumer that disconnects mid-delivery stops deliveries to the rest.\n s.consumers.clear();\n }\n this.#subs.clear();\n this.#shutdown();\n }\n\n /** Accounts with at least one consumer. */\n get activeChannels(): number {\n let count = 0;\n for (const s of this.#subs.values()) if (s.consumers.size > 0) count++;\n return count;\n }\n\n get totalConsumers(): number {\n let count = 0;\n for (const s of this.#subs.values()) count += s.consumers.size;\n return count;\n }\n\n /** Gives a consumer that joined a running subscription what the others already know. */\n #catchUp(s: StreamSubscription, c: Consumer): void {\n if (!this.#isCurrent(s) || !s.consumers.has(c)) return;\n c.caughtUp = true;\n const { params } = c;\n if (s.state === \"connected\") this.#deliverTo(s, c, () => params.onConnected?.());\n const orders = s.orders && [...s.orders.values()];\n if (orders) this.#deliverTo(s, c, () => params.onEvent({ type: \"snapshot\", orders }));\n const { stale } = s;\n if (stale)\n this.#deliverTo(s, c, () => params.onEvent({ type: \"stale\", stale: true, ...stale }));\n }\n\n /** Fetches the connect token first: the server closes a socket that sends no Auth within 5 seconds. */\n #open(): void {\n const WebSocketCtor = globalThis.WebSocket;\n if (!WebSocketCtor) {\n // Reported after connect() returns, like every other connection failure.\n queueMicrotask(() =>\n this.#terminateAll(\n \"connection_token\",\n new ConfigurationError(\"The private order stream requires a global WebSocket.\"),\n ),\n );\n return;\n }\n const generation = this.#generation;\n this.#connecting = true;\n this.#config.fetchConnectToken().then(\n (token) => {\n if (generation !== this.#generation) return;\n this.#connecting = false;\n let ws: WebSocket;\n try {\n ws = new WebSocketCtor(this.#config.url, PRIVATE_WS_SUBPROTOCOL);\n } catch (error) {\n // A bad URL or a blocked insecure socket fails the same way on every retry.\n this.#terminateAll(\"connection\", error);\n return;\n }\n ws.binaryType = \"arraybuffer\";\n this.#ws = ws;\n this.#authSent = false;\n ws.onopen = () => this.#authenticate(ws, token);\n ws.onmessage = (event: MessageEvent) => this.#onFrame(ws, event.data);\n ws.onclose = (event: CloseEvent) => this.#onClosed(ws, event.code, event.reason);\n },\n (error: unknown) => {\n if (generation !== this.#generation) return;\n this.#connecting = false;\n if (isTerminalTokenError(error)) {\n this.#terminateAll(\"connection_token\", error);\n return;\n }\n this.#reportAll(\"connection_token\", error);\n this.#scheduleReconnect();\n },\n );\n }\n\n #authenticate(ws: WebSocket, token: string): void {\n this.#send(ws, { case: \"auth\", value: { token } });\n this.#authSent = true;\n this.#authSentAt = Date.now();\n this.#armHeartbeat(ws);\n for (const s of this.#subs.values()) void this.#subscribe(ws, s);\n }\n\n async #reauthenticate(ws: WebSocket): Promise<void> {\n try {\n const token = await this.#config.fetchConnectToken();\n if (this.#ws === ws) this.#send(ws, { case: \"auth\", value: { token } });\n } catch (error) {\n if (this.#ws !== ws) return;\n if (isTerminalTokenError(error)) this.#terminateAll(\"connection_token\", error);\n else this.#reportAll(\"connection_token\", error);\n }\n }\n\n #isCurrent(s: StreamSubscription): boolean {\n return this.#subs.get(s.channel) === s;\n }\n\n async #subscribe(ws: WebSocket, s: StreamSubscription): Promise<void> {\n if (!this.#isCurrent(s)) return;\n const id = this.#nextRequestId();\n this.#pending.set(id, { kind: \"subscribe\", s });\n let token: string;\n try {\n token = await this.#config.fetchSubscribeToken(s.channel);\n } catch (error) {\n if (this.#pending.get(id)?.s !== s) return;\n this.#pending.delete(id);\n if (isTerminalTokenError(error)) {\n this.#terminate(s, \"subscription_token\", error);\n return;\n }\n this.#report(s, \"subscription_token\", error);\n this.#retrySubscribe(ws, s);\n return;\n }\n if (this.#ws !== ws || this.#pending.get(id)?.s !== s) return;\n this.#send(ws, {\n case: \"subscribe\",\n value: { id, channel: Channel.ORDERS, account: s.account, token, cursor: s.cursor },\n });\n }\n\n /** Subscribes again after a backoff that grows until the subscription delivers data. */\n #retrySubscribe(ws: WebSocket, s: StreamSubscription): void {\n this.#clearRetry(s);\n s.retryTimer = setTimeout(\n () => {\n s.retryTimer = null;\n if (this.#ws === ws && this.#isCurrent(s) && !s.sub) void this.#subscribe(ws, s);\n },\n backoffMs(s.retries++),\n );\n }\n\n #clearRetry(s: StreamSubscription): void {\n if (s.retryTimer) clearTimeout(s.retryTimer);\n s.retryTimer = null;\n }\n\n async #refresh(ws: WebSocket, s: StreamSubscription): Promise<void> {\n const sub = s.sub;\n let token: string;\n try {\n token = await this.#config.fetchSubscribeToken(s.channel);\n } catch (error) {\n // An unrefreshed subscription ends with TOKEN_EXPIRED and resubscribes.\n if (this.#ws === ws && s.sub === sub) this.#report(s, \"subscription_token\", error);\n return;\n }\n if (this.#ws !== ws || s.sub !== sub) return;\n const id = this.#nextRequestId();\n this.#pending.set(id, { kind: \"refresh\", s });\n this.#send(ws, { case: \"subscribeRefresh\", value: { id, sub, token } });\n }\n\n /**\n * Drops the server subscription and subscribes again from the last applied cursor:\n * at once the first time, then with backoff until the subscription delivers data.\n */\n #resubscribe(ws: WebSocket, s: StreamSubscription): void {\n if (s.sub) {\n this.#bySub.delete(s.sub);\n this.#unsubscribe(ws, s.sub);\n }\n s.sub = \"\";\n s.seq = 0n;\n s.staged = null;\n if (s.retries > 0) {\n this.#retrySubscribe(ws, s);\n } else {\n s.retries = 1;\n void this.#subscribe(ws, s);\n }\n // Consumers see the gap as a close and the replacement's Subscribed as a reopen.\n if (s.state === \"connected\") {\n s.state = \"disconnected\";\n this.#deliver(s, (p) => p.onDisconnected?.());\n }\n }\n\n #unsubscribe(ws: WebSocket, sub: string): void {\n const id = this.#nextRequestId();\n this.#unsubscribing.add(id);\n this.#send(ws, { case: \"unsubscribe\", value: { id, sub } });\n }\n\n #onFrame(ws: WebSocket, data: unknown): void {\n if (this.#ws !== ws) return;\n this.#armHeartbeat(ws);\n if (!(data instanceof ArrayBuffer)) {\n this.#reportAll(\n \"decode\",\n new RealtimeError(\"Expected a binary private WebSocket frame\"),\n );\n return;\n }\n if (data.byteLength > MAX_PRIVATE_FRAME_BYTES) {\n this.#reportAll(\n \"decode\",\n new RealtimeError(\n `Private WebSocket frame of ${data.byteLength} bytes exceeds ${MAX_PRIVATE_FRAME_BYTES}`,\n ),\n );\n // Reconnects with backoff; dropping the socket releases every staged snapshot.\n this.#drop(ws, 1009, \"frame too large\");\n return;\n }\n let msg;\n try {\n msg = fromBinary(ServerMessageSchema, new Uint8Array(data));\n } catch (error) {\n this.#reportAll(\"decode\", error);\n return;\n }\n const frame = msg.frame;\n\n switch (frame.case) {\n case \"subscribed\": {\n const request = this.#pending.get(frame.value.id);\n if (request?.kind !== \"subscribe\") {\n // Its consumer left before the server confirmed it.\n if (msg.sub) this.#unsubscribe(ws, msg.sub);\n return;\n }\n this.#pending.delete(frame.value.id);\n const s = request.s;\n s.sub = msg.sub;\n s.seq = 0n;\n this.#bySub.set(msg.sub, s);\n if (s.state !== \"connected\") {\n s.state = \"connected\";\n this.#deliver(s, (p) => p.onConnected?.());\n }\n // A new subscription reports Unavailable itself if its view is still behind.\n if (s.stale) {\n s.stale = null;\n this.#deliver(s, (p) => p.onEvent({ type: \"stale\", stale: false }));\n }\n return;\n }\n case \"subscribeRefreshed\":\n this.#pending.delete(frame.value.id);\n return;\n case \"unsubscribed\":\n if (this.#unsubscribing.delete(frame.value.id)) return;\n break;\n case \"error\":\n this.#onRequestError(ws, msg.sub, frame.value);\n return;\n case \"tokenExpiring\":\n void this.#reauthenticate(ws);\n return;\n }\n\n const s = this.#bySub.get(msg.sub);\n if (!s) return;\n if (msg.seq > 0n) {\n if (msg.seq !== s.seq + 1n) {\n this.#resubscribe(ws, s);\n return;\n }\n s.seq = msg.seq;\n }\n\n switch (frame.case) {\n case \"snapshotBegin\":\n s.staged = [];\n s.stagedBytes = 0;\n return;\n case \"snapshotPage\": {\n if (!s.staged) return;\n s.stagedBytes += data.byteLength;\n const count = s.staged.length + frame.value.orders.length;\n if (s.stagedBytes > MAX_SNAPSHOT_BYTES || count > MAX_SNAPSHOT_ORDERS) {\n s.staged = null;\n // The same account sends the same snapshot again, so retrying cannot help.\n this.#terminate(\n s,\n \"snapshot\",\n new RealtimeError(\n `Private order snapshot exceeds ${MAX_SNAPSHOT_ORDERS} orders or ${MAX_SNAPSHOT_BYTES} bytes`,\n ),\n );\n return;\n }\n s.staged.push(...frame.value.orders);\n return;\n }\n case \"snapshotEnd\": {\n const orders = s.staged;\n s.staged = null;\n if (!orders || orders.length !== frame.value.count) {\n s.cursor = \"\";\n this.#resubscribe(ws, s);\n return;\n }\n s.cursor = frame.value.cursor;\n s.retries = 0;\n s.orders = new Map(orders.map((o) => [o.orderId, o]));\n this.#deliver(s, (p) => p.onEvent({ type: \"snapshot\", orders }));\n return;\n }\n case \"unit\": {\n const unit = frame.value;\n s.cursor = unit.nextCursor;\n s.retries = 0;\n for (const o of unit.orders) s.orders?.set(o.orderId, o);\n for (const id of unit.removedOrderIds) s.orders?.delete(id);\n this.#deliver(s, (p) => p.onEvent({ type: \"unit\", unit }));\n return;\n }\n case \"covered\":\n s.cursor = frame.value.cursor;\n s.retries = 0;\n return;\n case \"ready\":\n // A resumed subscription on a quiet account delivers no data, only this.\n s.retries = 0;\n return;\n case \"unavailable\": {\n // A later Unavailable replaces the earlier one; order IDs narrow it to those orders.\n const { orderIds } = frame.value;\n const stale = orderIds.length > 0 ? { orderIds } : {};\n s.stale = stale;\n this.#deliver(s, (p) => p.onEvent({ type: \"stale\", stale: true, ...stale }));\n return;\n }\n case \"available\":\n s.stale = null;\n this.#deliver(s, (p) => p.onEvent({ type: \"stale\", stale: false }));\n return;\n case \"subscribeExpiring\":\n void this.#refresh(ws, s);\n return;\n case \"unsubscribed\":\n // The server ended it: its token expired, or for a reason this client does not know.\n this.#bySub.delete(s.sub);\n s.sub = \"\";\n this.#resubscribe(ws, s);\n return;\n }\n }\n\n #onRequestError(\n ws: WebSocket,\n sub: string,\n error: { id: string; code: RequestError_Code; message: string },\n ): void {\n if (error.id && this.#unsubscribing.delete(error.id)) return;\n const request = error.id ? this.#pending.get(error.id) : undefined;\n // The answer to a request already answered, or whose subscription has since gone.\n if (error.id && !request) return;\n if (request) this.#pending.delete(error.id);\n const s = request?.s ?? this.#bySub.get(sub);\n const realtimeError = new RealtimeError(\n error.message ||\n `Private order stream request failed: ${RequestError_Code[error.code]}`,\n { realtimeCode: error.code },\n );\n if (!s) {\n this.#reportAll(\"request\", realtimeError);\n return;\n }\n if (request?.kind === \"subscribe\") {\n if (error.code === RequestError_Code.CURSOR_INVALID) {\n s.cursor = \"\";\n void this.#subscribe(ws, s);\n return;\n }\n this.#terminate(s, \"subscribe\", realtimeError);\n return;\n }\n if (error.code === RequestError_Code.SUBSCRIPTION_UNKNOWN && s.sub === sub) {\n this.#bySub.delete(s.sub);\n s.sub = \"\";\n this.#resubscribe(ws, s);\n return;\n }\n this.#report(s, request?.kind ?? \"request\", realtimeError);\n }\n\n #onClosed(ws: WebSocket, code: number, reason: string): void {\n if (this.#ws !== ws) return;\n const stable = this.#authSent && Date.now() - this.#authSentAt >= STABLE_CONNECTION_MS;\n this.#detach();\n if (stable) this.#reconnectAttempt = 0;\n if (this.#subs.size === 0) return;\n\n if (TERMINAL_CLOSE_CODES.has(code)) {\n const error = new RealtimeError(\n reason || `Private WebSocket closed with code ${code}`,\n {\n realtimeCode: code,\n retryable: false,\n },\n );\n this.#terminateAll(\"disconnected\", error);\n return;\n }\n // Scheduled first, so a subscription opened from onDisconnected waits for it.\n this.#scheduleReconnect();\n // A close that reconnects is not an error, like a Centrifugo reconnect.\n for (const s of this.#subs.values()) {\n if (s.state === \"connected\") {\n s.state = \"disconnected\";\n this.#deliver(s, (p) => p.onDisconnected?.());\n }\n }\n }\n\n #scheduleReconnect(): void {\n this.#reconnectTimer = setTimeout(\n () => {\n this.#reconnectTimer = null;\n if (this.#subs.size > 0 && !this.#ws && !this.#connecting) this.#open();\n },\n backoffMs(this.#reconnectAttempt++),\n );\n }\n\n #armHeartbeat(ws: WebSocket): void {\n if (this.#heartbeatTimer) clearTimeout(this.#heartbeatTimer);\n this.#heartbeatTimer = setTimeout(\n () => this.#drop(ws, 4000, \"heartbeat timeout\"),\n HEARTBEAT_TIMEOUT_MS,\n );\n }\n\n /** Treats the socket as closed now; a stale socket may not emit close for a long time. */\n #drop(ws: WebSocket, code: number, reason: string): void {\n if (this.#ws !== ws) return;\n try {\n ws.close(code, reason);\n } catch {\n // noop\n }\n this.#onClosed(ws, code, reason);\n }\n\n #detach(): void {\n const ws = this.#ws;\n this.#ws = null;\n this.#authSent = false;\n if (this.#heartbeatTimer) clearTimeout(this.#heartbeatTimer);\n this.#heartbeatTimer = null;\n this.#pending.clear();\n this.#bySub.clear();\n this.#unsubscribing.clear();\n for (const s of this.#subs.values()) {\n this.#clearRetry(s);\n s.sub = \"\";\n s.seq = 0n;\n s.staged = null;\n }\n if (ws) {\n ws.onopen = null;\n ws.onmessage = null;\n ws.onclose = null;\n }\n }\n\n #shutdown(): void {\n const ws = this.#ws;\n this.#detach();\n this.#generation++;\n this.#connecting = false;\n if (this.#reconnectTimer) clearTimeout(this.#reconnectTimer);\n this.#reconnectTimer = null;\n this.#reconnectAttempt = 0;\n try {\n ws?.close(1000);\n } catch {\n // noop\n }\n }\n\n /** Drops a consumer; the server subscription goes a microtask later unless another joined. */\n #remove(s: StreamSubscription, c: Consumer): void {\n if (!s.consumers.delete(c) || s.consumers.size > 0) return;\n queueMicrotask(() => {\n if (s.consumers.size === 0) this.#teardown(s);\n });\n }\n\n #teardown(s: StreamSubscription): void {\n if (!this.#isCurrent(s)) return;\n this.#subs.delete(s.channel);\n s.consumers.clear();\n this.#clearRetry(s);\n const ws = this.#ws;\n if (ws && s.sub) {\n this.#bySub.delete(s.sub);\n this.#unsubscribe(ws, s.sub);\n }\n s.sub = \"\";\n for (const [id, request] of this.#pending) {\n if (request.s === s) this.#pending.delete(id);\n }\n if (this.#subs.size === 0) this.#shutdown();\n }\n\n #terminate(s: StreamSubscription, type: string, error: unknown): void {\n if (!this.#isCurrent(s)) return;\n this.#report(s, type, error);\n // Tell every consumer that has not been told it is disconnected.\n const told = s.state === \"disconnected\";\n const consumers = [...s.consumers].filter((c) => !c.caughtUp || !told);\n s.state = \"disconnected\";\n this.#teardown(s);\n for (const c of consumers) this.#call(s.channel, c, () => c.params.onDisconnected?.());\n }\n\n /** Spares subscriptions that consumers open from its callbacks. */\n #terminateAll(type: string, error: unknown): void {\n for (const s of [...this.#subs.values()]) this.#terminate(s, type, error);\n }\n\n #send(ws: WebSocket, op: ClientOp): void {\n if (ws.readyState !== 1) return;\n ws.send(toBinary(ClientMessageSchema, create(ClientMessageSchema, { op })));\n }\n\n #nextRequestId(): string {\n return String(++this.#requestSeq);\n }\n\n #report(s: StreamSubscription, type: string, error: unknown): void {\n const ctx = createSdkSubscriptionErrorContext(s.channel, type, error);\n // Only consumers present when the error happened, and still attached.\n for (const c of [...s.consumers]) {\n if (!s.consumers.has(c)) continue;\n try {\n c.params.onError?.(ctx);\n } catch {\n // Keep consumer error-handler failures isolated from the stream.\n }\n }\n }\n\n #reportAll(type: string, error: unknown): void {\n for (const s of [...this.#subs.values()]) this.#report(s, type, error);\n }\n\n /** Delivers to each caught-up consumer still attached when its turn comes. */\n #deliver(s: StreamSubscription, deliver: (params: ConnectPrivateOrdersParams) => void): void {\n for (const c of s.consumers) {\n if (c.caughtUp) this.#deliverTo(s, c, () => deliver(c.params));\n }\n }\n\n #deliverTo(s: StreamSubscription, c: Consumer, deliver: () => void): void {\n if (s.consumers.has(c)) this.#call(s.channel, c, deliver);\n }\n\n #call(channel: string, c: Consumer, deliver: () => void): void {\n try {\n deliver();\n } catch (error) {\n try {\n c.params.onError?.(publicationHandlerErrorContext(channel, error));\n } catch {\n // noop\n }\n }\n }\n}\n"],"mappings":";;;;;;AAiBA,MAAa,yBAAyB;AACtC,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;;AAEvB,MAAM,uBAAuB;;AAE7B,MAAM,uCAAuB,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;;AAEjD,MAAa,0BAA0B;;AAEvC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AAkEnC,SAAS,UAAU,SAAyB;CACxC,MAAM,UAAU,KAAK,IAAI,gBAAgB,kBAAkB,MAAM,UAAU,EAAE;CAC7E,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,UAAU;AACpD;AAEA,SAAS,qBAAqB,OAAyB;CACnD,OAAO,iBAAiB,kBAAkB,CAAC,MAAM;AACrD;;;;;;AAOA,IAAa,qBAAb,MAAgC;CAC5B;;CAEA,wBAAiB,IAAI,IAAgC;CACrD,2BAAoB,IAAI,IAA4B;CACpD,yBAAkB,IAAI,IAAgC;;CAEtD,iCAA0B,IAAI,IAAY;CAC1C,MAAwB;;CAExB,cAAc;;CAEd,cAAc;CACd,YAAY;CACZ,cAAc;CACd,oBAAoB;CACpB,kBAAwD;CACxD,kBAAwD;CACxD,cAAc;CAEd,YAAY,QAAkC;EAC1C,KAAKA,UAAU;CACnB;;CAGA,QAAQ,QAAgD;EACpD,MAAM,UAAU,uBAAuB,OAAO;EAC9C,MAAM,UAAU,WAAW,OAAO,WAAW,WAAW;EACxD,MAAM,WAAW,KAAKC,M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version":3,"file":"private-orders.js","names":["#config","#subs","#pending","#bySub","#unsubscribing","#catchUp","#remove","#ws","#authSent","#subscribe","#connecting","#reconnectTimer","#open","#clearRetry","#shutdown","#isCurrent","#deliverTo","#terminateAll","#generation","#authenticate","#onFrame","#onClosed","#reportAll","#scheduleReconnect","#send","#authSentAt","#armHeartbeat","#reauthenticate","#nextRequestId","#terminate","#report","#retrySubscribe","#expireSubscribe","#settle","#refresh","#unsubscribe","#deliver","#drop","#onRequestError","#resubscribe","#detach","#reconnectAttempt","#heartbeatTimer","#teardown","#call","#requestSeq"],"sources":["../../src/realtime/private-orders.ts"],"sourcesContent":["import { create, fromBinary, toBinary, type MessageInitShape } from \"@bufbuild/protobuf\";\nimport type { Order } from \"../gen/orders/v1/orders_read_pb.js\";\nimport {\n Channel,\n ClientMessageSchema,\n RequestError_Code,\n ServerMessageSchema,\n type Unit,\n} from \"../gen/privatews/v1/private_ws_pb.js\";\nimport { ConfigurationError, PolyesterError, RealtimeError } from \"../shared/errors.js\";\nimport {\n createSdkSubscriptionErrorContext,\n publicationHandlerErrorContext,\n type SdkSubscriptionErrorContext,\n} from \"../shared/subscription-errors.js\";\nimport { idToBigInt } from \"../utils/base58-id.js\";\n\nexport const PRIVATE_WS_SUBPROTOCOL = \"polyester.v1.proto\";\nconst HEARTBEAT_TIMEOUT_MS = 3_000;\n/** Heartbeats keep the connection alive without answering a Subscribe, so it gets its own deadline. */\nconst SUBSCRIBE_ACK_TIMEOUT_MS = 30_000;\nconst BACKOFF_BASE_MS = 500;\nconst BACKOFF_MAX_MS = 10_000;\n/** A connection that stayed up this long resets the reconnect backoff. */\nconst STABLE_CONNECTION_MS = 10_000;\n/** A malformed frame (4400) and a rejected connect token (4403) recur on every reconnect. */\nconst TERMINAL_CLOSE_CODES = new Set([4400, 4403]);\n/** Larger frames are dropped undecoded with the connection; a full 256-order page is far smaller. */\nexport const MAX_PRIVATE_FRAME_BYTES = 4 * 1024 * 1024;\n/** A snapshot staging more pages than this ends its subscription, so a snapshot never ending stays bounded. */\nexport const MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;\nexport const MAX_SNAPSHOT_ORDERS = 100_000;\n\n/** One delivery of an account's order stream. */\nexport type PrivateOrdersEvent =\n /** The account's full live view; replace local state with it. */\n | { type: \"snapshot\"; orders: Order[] }\n /** One change, applied whole. */\n | { type: \"unit\"; unit: Unit }\n /**\n * The account's live view is temporarily behind (`true`) or caught up (`false`).\n * `orderIds`, when set, names the only orders behind; the rest of the view is current.\n */\n | { type: \"stale\"; stale: boolean; orderIds?: bigint[] }\n /**\n * The stream reflects every order change acknowledged before it subscribed, including\n * every order read made before then. Wait for it before relying on the stream. Sent\n * once per server subscription, so again after each resubscribe or reconnect.\n */\n | { type: \"ready\" };\n\nexport interface ConnectPrivateOrdersParams {\n /** The account's base58 public ID. */\n accountId: string;\n onEvent: (event: PrivateOrdersEvent) => void;\n /** Called when the server confirms the subscription, again after each reconnect. */\n onConnected?: () => void;\n /** Called when the connection carrying the subscription drops. */\n onDisconnected?: () => void;\n onError?: (ctx: SdkSubscriptionErrorContext) => void;\n}\n\nexport interface PrivateOrderStreamConfig {\n url: string;\n fetchConnectToken: () => Promise<string>;\n fetchSubscribeToken: (channel: string) => Promise<string>;\n}\n\ntype ClientOp = MessageInitShape<typeof ClientMessageSchema>[\"op\"];\n\ninterface Consumer {\n params: ConnectPrivateOrdersParams;\n /** False until a consumer that joined a running subscription received its current state. */\n caughtUp: boolean;\n}\n\n/** One server subscription per account, shared by every consumer of that account. */\ninterface StreamSubscription {\n consumers: Set<Consumer>;\n channel: string;\n account: bigint;\n /** Server subscription ID; empty until Subscribed. */\n sub: string;\n seq: bigint;\n /** Last applied resume position, carried across resubscribes and reconnects. */\n cursor: string;\n staged: Order[] | null;\n /** Frame bytes of the staged pages. */\n stagedBytes: number;\n /** The account's live view as last applied, for consumers that join later; null before the first snapshot. */\n orders: Map<bigint, Order> | null;\n /** The last connection state consumers were told about. */\n state: \"pending\" | \"connected\" | \"disconnected\";\n /** What consumers were last told is stale, until they are told it caught up. */\n stale: { orderIds?: bigint[] } | null;\n /** The current server subscription sent Ready. */\n ready: boolean;\n /** Subscribe attempts since the subscription last delivered data; drives retry backoff. */\n retries: number;\n retryTimer: ReturnType<typeof setTimeout> | null;\n}\n\ntype PendingRequest = {\n kind: \"subscribe\" | \"refresh\";\n s: StreamSubscription;\n /** Deadline for the server's answer to a Subscribe. */\n timer?: ReturnType<typeof setTimeout>;\n};\n\n/** 0.5 s doubling to 10 s, jittered over the upper half of each step. */\nfunction backoffMs(attempt: number): number {\n const ceiling = Math.min(BACKOFF_MAX_MS, BACKOFF_BASE_MS * 2 ** (attempt + 1));\n return ceiling / 2 + Math.random() * (ceiling / 2);\n}\n\nfunction isTerminalTokenError(error: unknown): boolean {\n return error instanceof PolyesterError && !error.retryable;\n}\n\n/**\n * Account order streams over the private WebSocket (`/v1/ws/private`). One\n * connection carries every subscription; each resumes from its last cursor\n * after a gap, an expired token, or a reconnect.\n */\nexport class PrivateOrderStream {\n readonly #config: PrivateOrderStreamConfig;\n /** Keyed by channel. A subscription whose last consumer left stays until the next microtask. */\n readonly #subs = new Map<string, StreamSubscription>();\n readonly #pending = new Map<string, PendingRequest>();\n readonly #bySub = new Map<string, StreamSubscription>();\n /** IDs of Unsubscribe requests awaiting their answer. */\n readonly #unsubscribing = new Set<string>();\n #ws: WebSocket | null = null;\n /** A connect token fetch for the next socket is in flight. */\n #connecting = false;\n /** Bumped on shutdown so a token fetch that outlived it opens nothing. */\n #generation = 0;\n #authSent = false;\n #authSentAt = 0;\n #reconnectAttempt = 0;\n #reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n #heartbeatTimer: ReturnType<typeof setTimeout> | null = null;\n #requestSeq = 0;\n\n constructor(config: PrivateOrderStreamConfig) {\n this.#config = config;\n }\n\n /** Throws ValidationError when accountId is not a base58 public ID. */\n connect(params: ConnectPrivateOrdersParams): () => void {\n const channel = `private:spot:orders:${params.accountId}`;\n const account = idToBigInt(params.accountId, \"accountId\");\n const existing = this.#subs.get(channel);\n if (existing) {\n const consumer: Consumer = { params, caughtUp: false };\n existing.consumers.add(consumer);\n queueMicrotask(() => this.#catchUp(existing, consumer));\n return () => this.#remove(existing, consumer);\n }\n const consumer: Consumer = { params, caughtUp: true };\n const s: StreamSubscription = {\n consumers: new Set([consumer]),\n channel,\n account,\n sub: \"\",\n seq: 0n,\n cursor: \"\",\n staged: null,\n stagedBytes: 0,\n orders: null,\n state: \"pending\",\n stale: null,\n ready: false,\n retries: 0,\n retryTimer: null,\n };\n this.#subs.set(channel, s);\n if (this.#ws && this.#authSent) void this.#subscribe(this.#ws, s);\n else if (!this.#ws && !this.#connecting && !this.#reconnectTimer) this.#open();\n return () => this.#remove(s, consumer);\n }\n\n /** Closes the connection and drops every subscription without callbacks. */\n disconnect(): void {\n for (const s of this.#subs.values()) {\n this.#clearRetry(s);\n // A consumer that disconnects mid-delivery stops deliveries to the rest.\n s.consumers.clear();\n }\n this.#subs.clear();\n this.#shutdown();\n }\n\n /** Accounts with at least one consumer. */\n get activeChannels(): number {\n let count = 0;\n for (const s of this.#subs.values()) if (s.consumers.size > 0) count++;\n return count;\n }\n\n get totalConsumers(): number {\n let count = 0;\n for (const s of this.#subs.values()) count += s.consumers.size;\n return count;\n }\n\n /** Gives a consumer that joined a running subscription what the others already know. */\n #catchUp(s: StreamSubscription, c: Consumer): void {\n if (!this.#isCurrent(s) || !s.consumers.has(c)) return;\n c.caughtUp = true;\n const { params } = c;\n if (s.state === \"connected\") this.#deliverTo(s, c, () => params.onConnected?.());\n const orders = s.orders && [...s.orders.values()];\n if (orders) this.#deliverTo(s, c, () => params.onEvent({ type: \"snapshot\", orders }));\n if (s.ready) this.#deliverTo(s, c, () => params.onEvent({ type: \"ready\" }));\n const { stale } = s;\n if (stale)\n this.#deliverTo(s, c, () => params.onEvent({ type: \"stale\", stale: true, ...stale }));\n }\n\n /** Fetches the connect token first: the server closes a socket that sends no Auth within 5 seconds. */\n #open(): void {\n const WebSocketCtor = globalThis.WebSocket;\n if (!WebSocketCtor) {\n // Reported after connect() returns, like every other connection failure.\n queueMicrotask(() =>\n this.#terminateAll(\n \"connection_token\",\n new ConfigurationError(\"The private order stream requires a global WebSocket.\"),\n ),\n );\n return;\n }\n const generation = this.#generation;\n this.#connecting = true;\n this.#config.fetchConnectToken().then(\n (token) => {\n if (generation !== this.#generation) return;\n this.#connecting = false;\n let ws: WebSocket;\n try {\n ws = new WebSocketCtor(this.#config.url, PRIVATE_WS_SUBPROTOCOL);\n } catch (error) {\n // A bad URL or a blocked insecure socket fails the same way on every retry.\n this.#terminateAll(\"connection\", error);\n return;\n }\n ws.binaryType = \"arraybuffer\";\n this.#ws = ws;\n this.#authSent = false;\n ws.onopen = () => this.#authenticate(ws, token);\n ws.onmessage = (event: MessageEvent) => this.#onFrame(ws, event.data);\n ws.onclose = (event: CloseEvent) => this.#onClosed(ws, event.code, event.reason);\n },\n (error: unknown) => {\n if (generation !== this.#generation) return;\n this.#connecting = false;\n if (isTerminalTokenError(error)) {\n this.#terminateAll(\"connection_token\", error);\n return;\n }\n this.#reportAll(\"connection_token\", error);\n this.#scheduleReconnect();\n },\n );\n }\n\n #authenticate(ws: WebSocket, token: string): void {\n this.#send(ws, { case: \"auth\", value: { token } });\n this.#authSent = true;\n this.#authSentAt = Date.now();\n this.#armHeartbeat(ws);\n for (const s of this.#subs.values()) void this.#subscribe(ws, s);\n }\n\n async #reauthenticate(ws: WebSocket): Promise<void> {\n try {\n const token = await this.#config.fetchConnectToken();\n if (this.#ws === ws) this.#send(ws, { case: \"auth\", value: { token } });\n } catch (error) {\n if (this.#ws !== ws) return;\n if (isTerminalTokenError(error)) this.#terminateAll(\"connection_token\", error);\n else this.#reportAll(\"connection_token\", error);\n }\n }\n\n #isCurrent(s: StreamSubscription): boolean {\n return this.#subs.get(s.channel) === s;\n }\n\n async #subscribe(ws: WebSocket, s: StreamSubscription): Promise<void> {\n if (!this.#isCurrent(s)) return;\n const id = this.#nextRequestId();\n const request: PendingRequest = { kind: \"subscribe\", s };\n this.#pending.set(id, request);\n let token: string;\n try {\n token = await this.#config.fetchSubscribeToken(s.channel);\n } catch (error) {\n if (this.#pending.get(id)?.s !== s) return;\n this.#pending.delete(id);\n if (isTerminalTokenError(error)) {\n this.#terminate(s, \"subscription_token\", error);\n return;\n }\n this.#report(s, \"subscription_token\", error);\n this.#retrySubscribe(ws, s);\n return;\n }\n if (this.#ws !== ws || this.#pending.get(id)?.s !== s) return;\n this.#send(ws, {\n case: \"subscribe\",\n value: { id, channel: Channel.ORDERS, account: s.account, token, cursor: s.cursor },\n });\n request.timer = setTimeout(() => this.#expireSubscribe(ws, id), SUBSCRIBE_ACK_TIMEOUT_MS);\n }\n\n /**\n * Ends a subscription the server never confirmed; one it confirmed before reports the\n * timeout and subscribes again. A late Subscribed for the expired request is unsubscribed.\n */\n #expireSubscribe(ws: WebSocket, id: string): void {\n const request = this.#settle(id);\n if (!request) return;\n const error = new RealtimeError(\"Private order subscribe acknowledgement timed out\", {\n retryable: true,\n });\n if (request.s.state === \"pending\") {\n this.#terminate(request.s, \"subscribe\", error);\n return;\n }\n this.#report(request.s, \"subscribe\", error);\n this.#retrySubscribe(ws, request.s);\n }\n\n /** Forgets a request and its answer deadline. */\n #settle(id: string): PendingRequest | undefined {\n const request = this.#pending.get(id);\n clearTimeout(request?.timer);\n this.#pending.delete(id);\n return request;\n }\n\n /** Subscribes again after a backoff that grows until the subscription delivers data. */\n #retrySubscribe(ws: WebSocket, s: StreamSubscription): void {\n this.#clearRetry(s);\n s.retryTimer = setTimeout(\n () => {\n s.retryTimer = null;\n if (this.#ws === ws && this.#isCurrent(s) && !s.sub) void this.#subscribe(ws, s);\n },\n backoffMs(s.retries++),\n );\n }\n\n #clearRetry(s: StreamSubscription): void {\n if (s.retryTimer) clearTimeout(s.retryTimer);\n s.retryTimer = null;\n }\n\n async #refresh(ws: WebSocket, s: StreamSubscription): Promise<void> {\n const sub = s.sub;\n let token: string;\n try {\n token = await this.#config.fetchSubscribeToken(s.channel);\n } catch (error) {\n // An unrefreshed subscription ends with TOKEN_EXPIRED and resubscribes.\n if (this.#ws === ws && s.sub === sub) this.#report(s, \"subscription_token\", error);\n return;\n }\n if (this.#ws !== ws || s.sub !== sub) return;\n const id = this.#nextRequestId();\n this.#pending.set(id, { kind: \"refresh\", s });\n this.#send(ws, { case: \"subscribeRefresh\", value: { id, sub, token } });\n }\n\n /**\n * Drops the server subscription and subscribes again from the last applied cursor:\n * at once the first time, then with backoff until the subscription delivers data.\n */\n #resubscribe(ws: WebSocket, s: StreamSubscription): void {\n if (s.sub) {\n this.#bySub.delete(s.sub);\n this.#unsubscribe(ws, s.sub);\n }\n s.sub = \"\";\n s.seq = 0n;\n s.staged = null;\n s.ready = false;\n if (s.retries > 0) {\n this.#retrySubscribe(ws, s);\n } else {\n s.retries = 1;\n void this.#subscribe(ws, s);\n }\n // Consumers see the gap as a close and the replacement's Subscribed as a reopen.\n if (s.state === \"connected\") {\n s.state = \"disconnected\";\n this.#deliver(s, (p) => p.onDisconnected?.());\n }\n }\n\n #unsubscribe(ws: WebSocket, sub: string): void {\n const id = this.#nextRequestId();\n this.#unsubscribing.add(id);\n this.#send(ws, { case: \"unsubscribe\", value: { id, sub } });\n }\n\n #onFrame(ws: WebSocket, data: unknown): void {\n if (this.#ws !== ws) return;\n this.#armHeartbeat(ws);\n if (!(data instanceof ArrayBuffer)) {\n this.#reportAll(\n \"decode\",\n new RealtimeError(\"Expected a binary private WebSocket frame\"),\n );\n return;\n }\n if (data.byteLength > MAX_PRIVATE_FRAME_BYTES) {\n this.#reportAll(\n \"decode\",\n new RealtimeError(\n `Private WebSocket frame of ${data.byteLength} bytes exceeds ${MAX_PRIVATE_FRAME_BYTES}`,\n ),\n );\n // Reconnects with backoff; dropping the socket releases every staged snapshot.\n this.#drop(ws, 1009, \"frame too large\");\n return;\n }\n let msg;\n try {\n msg = fromBinary(ServerMessageSchema, new Uint8Array(data));\n } catch (error) {\n this.#reportAll(\"decode\", error);\n return;\n }\n const frame = msg.frame;\n\n switch (frame.case) {\n case \"subscribed\": {\n const request = this.#pending.get(frame.value.id);\n if (request?.kind !== \"subscribe\") {\n // Its consumer left before the server confirmed it.\n if (msg.sub) this.#unsubscribe(ws, msg.sub);\n return;\n }\n this.#settle(frame.value.id);\n const s = request.s;\n s.sub = msg.sub;\n s.seq = 0n;\n this.#bySub.set(msg.sub, s);\n if (s.state !== \"connected\") {\n s.state = \"connected\";\n this.#deliver(s, (p) => p.onConnected?.());\n }\n // A new subscription reports Unavailable itself if its view is still behind.\n if (s.stale) {\n s.stale = null;\n this.#deliver(s, (p) => p.onEvent({ type: \"stale\", stale: false }));\n }\n return;\n }\n case \"subscribeRefreshed\":\n this.#pending.delete(frame.value.id);\n return;\n case \"unsubscribed\":\n if (this.#unsubscribing.delete(frame.value.id)) return;\n break;\n case \"error\":\n this.#onRequestError(ws, msg.sub, frame.value);\n return;\n case \"tokenExpiring\":\n void this.#reauthenticate(ws);\n return;\n }\n\n const s = this.#bySub.get(msg.sub);\n if (!s) return;\n if (msg.seq > 0n) {\n if (msg.seq !== s.seq + 1n) {\n this.#resubscribe(ws, s);\n return;\n }\n s.seq = msg.seq;\n }\n\n switch (frame.case) {\n case \"snapshotBegin\":\n s.staged = [];\n s.stagedBytes = 0;\n return;\n case \"snapshotPage\": {\n if (!s.staged) return;\n s.stagedBytes += data.byteLength;\n const count = s.staged.length + frame.value.orders.length;\n if (s.stagedBytes > MAX_SNAPSHOT_BYTES || count > MAX_SNAPSHOT_ORDERS) {\n s.staged = null;\n // The same account sends the same snapshot again, so retrying cannot help.\n this.#terminate(\n s,\n \"snapshot\",\n new RealtimeError(\n `Private order snapshot exceeds ${MAX_SNAPSHOT_ORDERS} orders or ${MAX_SNAPSHOT_BYTES} bytes`,\n ),\n );\n return;\n }\n s.staged.push(...frame.value.orders);\n return;\n }\n case \"snapshotEnd\": {\n const orders = s.staged;\n s.staged = null;\n if (!orders || orders.length !== frame.value.count) {\n s.cursor = \"\";\n this.#resubscribe(ws, s);\n return;\n }\n s.cursor = frame.value.cursor;\n s.retries = 0;\n s.orders = new Map(orders.map((o) => [o.orderId, o]));\n this.#deliver(s, (p) => p.onEvent({ type: \"snapshot\", orders }));\n return;\n }\n case \"unit\": {\n const unit = frame.value;\n s.cursor = unit.nextCursor;\n s.retries = 0;\n for (const o of unit.orders) s.orders?.set(o.orderId, o);\n for (const id of unit.removedOrderIds) s.orders?.delete(id);\n this.#deliver(s, (p) => p.onEvent({ type: \"unit\", unit }));\n return;\n }\n case \"covered\":\n s.cursor = frame.value.cursor;\n s.retries = 0;\n return;\n case \"ready\":\n // A resumed subscription on a quiet account delivers no data, only this.\n s.retries = 0;\n s.ready = true;\n this.#deliver(s, (p) => p.onEvent({ type: \"ready\" }));\n return;\n case \"unavailable\": {\n // A later Unavailable replaces the earlier one; order IDs narrow it to those orders.\n const { orderIds } = frame.value;\n const stale = orderIds.length > 0 ? { orderIds } : {};\n s.stale = stale;\n this.#deliver(s, (p) => p.onEvent({ type: \"stale\", stale: true, ...stale }));\n return;\n }\n case \"available\":\n s.stale = null;\n this.#deliver(s, (p) => p.onEvent({ type: \"stale\", stale: false }));\n return;\n case \"subscribeExpiring\":\n void this.#refresh(ws, s);\n return;\n case \"unsubscribed\":\n // The server ended it: its token expired, or for a reason this client does not know.\n this.#bySub.delete(s.sub);\n s.sub = \"\";\n this.#resubscribe(ws, s);\n return;\n }\n }\n\n #onRequestError(\n ws: WebSocket,\n sub: string,\n error: { id: string; code: RequestError_Code; message: string },\n ): void {\n if (error.id && this.#unsubscribing.delete(error.id)) return;\n const request = error.id ? this.#pending.get(error.id) : undefined;\n // The answer to a request already answered, or whose subscription has since gone.\n if (error.id && !request) return;\n if (request) this.#settle(error.id);\n const s = request?.s ?? this.#bySub.get(sub);\n const realtimeError = new RealtimeError(\n error.message ||\n `Private order stream request failed: ${RequestError_Code[error.code]}`,\n { realtimeCode: error.code },\n );\n if (!s) {\n this.#reportAll(\"request\", realtimeError);\n return;\n }\n if (request?.kind === \"subscribe\") {\n if (error.code === RequestError_Code.CURSOR_INVALID) {\n s.cursor = \"\";\n void this.#subscribe(ws, s);\n return;\n }\n this.#terminate(s, \"subscribe\", realtimeError);\n return;\n }\n if (error.code === RequestError_Code.SUBSCRIPTION_UNKNOWN && s.sub === sub) {\n this.#bySub.delete(s.sub);\n s.sub = \"\";\n this.#resubscribe(ws, s);\n return;\n }\n this.#report(s, request?.kind ?? \"request\", realtimeError);\n }\n\n #onClosed(ws: WebSocket, code: number, reason: string): void {\n if (this.#ws !== ws) return;\n const stable = this.#authSent && Date.now() - this.#authSentAt >= STABLE_CONNECTION_MS;\n this.#detach();\n if (stable) this.#reconnectAttempt = 0;\n if (this.#subs.size === 0) return;\n\n if (TERMINAL_CLOSE_CODES.has(code)) {\n const error = new RealtimeError(\n reason || `Private WebSocket closed with code ${code}`,\n {\n realtimeCode: code,\n retryable: false,\n },\n );\n this.#terminateAll(\"disconnected\", error);\n return;\n }\n // Scheduled first, so a subscription opened from onDisconnected waits for it.\n this.#scheduleReconnect();\n // A close that reconnects is not an error, like a Centrifugo reconnect.\n for (const s of this.#subs.values()) {\n if (s.state === \"connected\") {\n s.state = \"disconnected\";\n this.#deliver(s, (p) => p.onDisconnected?.());\n }\n }\n }\n\n #scheduleReconnect(): void {\n this.#reconnectTimer = setTimeout(\n () => {\n this.#reconnectTimer = null;\n if (this.#subs.size > 0 && !this.#ws && !this.#connecting) this.#open();\n },\n backoffMs(this.#reconnectAttempt++),\n );\n }\n\n #armHeartbeat(ws: WebSocket): void {\n if (this.#heartbeatTimer) clearTimeout(this.#heartbeatTimer);\n this.#heartbeatTimer = setTimeout(\n () => this.#drop(ws, 4000, \"heartbeat timeout\"),\n HEARTBEAT_TIMEOUT_MS,\n );\n }\n\n /** Treats the socket as closed now; a stale socket may not emit close for a long time. */\n #drop(ws: WebSocket, code: number, reason: string): void {\n if (this.#ws !== ws) return;\n try {\n ws.close(code, reason);\n } catch {\n // noop\n }\n this.#onClosed(ws, code, reason);\n }\n\n #detach(): void {\n const ws = this.#ws;\n this.#ws = null;\n this.#authSent = false;\n if (this.#heartbeatTimer) clearTimeout(this.#heartbeatTimer);\n this.#heartbeatTimer = null;\n for (const { timer } of this.#pending.values()) clearTimeout(timer);\n this.#pending.clear();\n this.#bySub.clear();\n this.#unsubscribing.clear();\n for (const s of this.#subs.values()) {\n this.#clearRetry(s);\n s.sub = \"\";\n s.seq = 0n;\n s.staged = null;\n s.ready = false;\n }\n if (ws) {\n ws.onopen = null;\n ws.onmessage = null;\n ws.onclose = null;\n }\n }\n\n #shutdown(): void {\n const ws = this.#ws;\n this.#detach();\n this.#generation++;\n this.#connecting = false;\n if (this.#reconnectTimer) clearTimeout(this.#reconnectTimer);\n this.#reconnectTimer = null;\n this.#reconnectAttempt = 0;\n try {\n ws?.close(1000);\n } catch {\n // noop\n }\n }\n\n /** Drops a consumer; the server subscription goes a microtask later unless another joined. */\n #remove(s: StreamSubscription, c: Consumer): void {\n if (!s.consumers.delete(c) || s.consumers.size > 0) return;\n queueMicrotask(() => {\n if (s.consumers.size === 0) this.#teardown(s);\n });\n }\n\n #teardown(s: StreamSubscription): void {\n if (!this.#isCurrent(s)) return;\n this.#subs.delete(s.channel);\n s.consumers.clear();\n this.#clearRetry(s);\n const ws = this.#ws;\n if (ws && s.sub) {\n this.#bySub.delete(s.sub);\n this.#unsubscribe(ws, s.sub);\n }\n s.sub = \"\";\n for (const [id, request] of this.#pending) {\n if (request.s === s) this.#settle(id);\n }\n if (this.#subs.size === 0) this.#shutdown();\n }\n\n #terminate(s: StreamSubscription, type: string, error: unknown): void {\n if (!this.#isCurrent(s)) return;\n this.#report(s, type, error);\n // Tell every consumer that has not been told it is disconnected.\n const told = s.state === \"disconnected\";\n const consumers = [...s.consumers].filter((c) => !c.caughtUp || !told);\n s.state = \"disconnected\";\n this.#teardown(s);\n for (const c of consumers) this.#call(s.channel, c, () => c.params.onDisconnected?.());\n }\n\n /** Spares subscriptions that consumers open from its callbacks. */\n #terminateAll(type: string, error: unknown): void {\n for (const s of [...this.#subs.values()]) this.#terminate(s, type, error);\n }\n\n #send(ws: WebSocket, op: ClientOp): void {\n if (ws.readyState !== 1) return;\n ws.send(toBinary(ClientMessageSchema, create(ClientMessageSchema, { op })));\n }\n\n #nextRequestId(): string {\n return String(++this.#requestSeq);\n }\n\n #report(s: StreamSubscription, type: string, error: unknown): void {\n const ctx = createSdkSubscriptionErrorContext(s.channel, type, error);\n // Only consumers present when the error happened, and still attached.\n for (const c of [...s.consumers]) {\n if (!s.consumers.has(c)) continue;\n try {\n c.params.onError?.(ctx);\n } catch {\n // Keep consumer error-handler failures isolated from the stream.\n }\n }\n }\n\n #reportAll(type: string, error: unknown): void {\n for (const s of [...this.#subs.values()]) this.#report(s, type, error);\n }\n\n /** Delivers to each caught-up consumer still attached when its turn comes. */\n #deliver(s: StreamSubscription, deliver: (params: ConnectPrivateOrdersParams) => void): void {\n for (const c of s.consumers) {\n if (c.caughtUp) this.#deliverTo(s, c, () => deliver(c.params));\n }\n }\n\n #deliverTo(s: StreamSubscription, c: Consumer, deliver: () => void): void {\n if (s.consumers.has(c)) this.#call(s.channel, c, deliver);\n }\n\n #call(channel: string, c: Consumer, deliver: () => void): void {\n try {\n deliver();\n } catch (error) {\n try {\n c.params.onError?.(publicationHandlerErrorContext(channel, error));\n } catch {\n // noop\n }\n }\n }\n}\n"],"mappings":";;;;;;AAiBA,MAAa,yBAAyB;AACtC,MAAM,uBAAuB;;AAE7B,MAAM,2BAA2B;AACjC,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;;AAEvB,MAAM,uBAAuB;;AAE7B,MAAM,uCAAuB,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;;AAEjD,MAAa,0BAA0B;;AAEvC,MAAa,qBAAqB;AAClC,MAAa,sBAAsB;;AA+EnC,SAAS,UAAU,SAAyB;CACxC,MAAM,UAAU,KAAK,IAAI,gBAAgB,kBAAkB,MAAM,UAAU,EAAE;CAC7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SAAS,GAAG,OAAO;CAC5D;CAEA,MAAM,SAAiB,GAAa,SAA2B;EAC3D,IAAI;GACA,QAAQ;EACZ,SAAS,OAAO;GACZ,IAAI;IACA,EAAE,OAAO,UAAU,+BAA+B,SAAS,KAAK,CAAC;GACrE,QAAQ,CAER;EACJ;CACJ;AACJ"}
@@ -1,6 +1,6 @@
1
+ import { isDev } from "../utils/is-dev.js";
1
2
  import { createSdkSubscriptionErrorContext } from "../shared/subscription-errors.js";
2
3
  import { formatConnectError } from "../utils/errors.js";
3
- import { isDev } from "../utils/is-dev.js";
4
4
  //#region src/realtime/snapshot-then-stream.ts
5
5
  /**
6
6
  * Snapshot-then-stream for feed state. By default, the buffer caps at
@@ -1,9 +1,9 @@
1
- import { AuthenticationError, ConfigurationError } from "./shared/errors.js";
2
- import { toPolyesterError } from "./shared/connect-error-mapping.js";
3
- import { PolyesterCore, parsePolyesterClientConfig, pickPolyesterCatalogConfig } from "./core-client.js";
4
1
  import "./services/auth/cookie-constants.js";
5
2
  import { emptyServerSessionSnapshot, parseServerSessionSnapshot } from "./services/auth/session.js";
6
3
  import { isJwtValid } from "./utils/jwt.js";
4
+ import { AuthenticationError, ConfigurationError } from "./shared/errors.js";
5
+ import { toPolyesterError } from "./shared/connect-error-mapping.js";
6
+ import { PolyesterCore, parsePolyesterClientConfig, pickPolyesterCatalogConfig } from "./core-client.js";
7
7
  //#region src/server-core.ts
8
8
  /**
9
9
  * Parses a serialized session cookie into SDK session data.
@@ -1,6 +1,6 @@
1
+ import { ResolveService } from "../../gen/auth/v1/resolve_pb.js";
1
2
  import { parse } from "../../shared/validation.js";
2
3
  import { toConnectCallOptions } from "../../shared/request-options.js";
3
- import { ResolveService } from "../../gen/auth/v1/resolve_pb.js";
4
4
  import { ResolveAccountInputSchema, ResolvedAccountArraySchema } from "./accounts.schemas.js";
5
5
  import { createClient } from "@connectrpc/connect";
6
6
  //#region src/services/accounts/accounts.ts
@@ -1,6 +1,6 @@
1
+ import "../../gen/auth/v1/resolve_pb.js";
1
2
  import { PublicIdSchema } from "../../shared/schemas.js";
2
3
  import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
3
- import "../../gen/auth/v1/resolve_pb.js";
4
4
  import { ResolveHintCodec, ResolvedAccountKindCodec } from "./accounts.codecs.js";
5
5
  import * as v from "valibot";
6
6
  //#region src/services/accounts/accounts.schemas.ts
@@ -1,7 +1,7 @@
1
+ import { AddressBookService as AddressBookService$1, AddressBookViewInvalidatedSchema } from "../../gen/auth/v1/address_book_pb.js";
1
2
  import { parse } from "../../shared/validation.js";
2
3
  import { removeUndefined } from "../../utils/remove-undefined.js";
3
4
  import { toConnectCallOptions } from "../../shared/request-options.js";
4
- import { AddressBookService as AddressBookService$1, AddressBookViewInvalidatedSchema } from "../../gen/auth/v1/address_book_pb.js";
5
5
  import { resolveAccountScopedInput } from "../subaccount-resolver.js";
6
6
  import { AddressBookEntriesSchema, AddressBookEntrySchema, AddressBookSchema, AddressBookTagSchema, AddressBookViewInvalidatedSchema as AddressBookViewInvalidatedSchema$1, AddressBookViewSchema, CopyAddressBookEntryInputSchema, CreateAddressBookEntryInputSchema, CreateAddressBookTagInputSchema, DeleteAddressBookEntryInputSchema, DeleteAddressBookTagInputSchema, GetAddressBookViewInputSchema, InternalTransferWhitelistEntriesSchema, ListAddressBookEntriesInputSchema, ListInternalTransferWhitelistEntriesInputSchema, ListTransferCounterpartiesInputSchema, ListTransferDestinationsInputSchema, SubaccountScopedInputSchema, TransferCounterpartiesSchema, TransferDestinationsSchema, UpdateAddressBookEntryInputSchema, UpdateAddressBookTagInputSchema, WithdrawWhitelistViewSchema } from "./address-book.schemas.js";
7
7
  import { createClient } from "@connectrpc/connect";
@@ -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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