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

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 (283) hide show
  1. package/CHANGELOG.md +42 -4
  2. package/dist/client.d.ts +4 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +4 -0
  5. package/dist/client.js.map +1 -1
  6. package/dist/gen/ai/v1/assistant_pb.d.ts +82 -4
  7. package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -1
  8. package/dist/gen/ai/v1/assistant_pb.js +66 -10
  9. package/dist/gen/ai/v1/assistant_pb.js.map +1 -1
  10. package/dist/gen/auth/v1/api_keys_pb.d.ts +4 -4
  11. package/dist/gen/auth/v1/api_keys_pb.js +4 -4
  12. package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
  13. package/dist/gen/auth/v1/auth_pb.d.ts +26 -1
  14. package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
  15. package/dist/gen/auth/v1/auth_pb.js +18 -1
  16. package/dist/gen/auth/v1/auth_pb.js.map +1 -1
  17. package/dist/gen/auth/v1/policies_pb.d.ts +18 -1
  18. package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
  19. package/dist/gen/auth/v1/policies_pb.js +18 -1
  20. package/dist/gen/auth/v1/policies_pb.js.map +1 -1
  21. package/dist/gen/auth/v1/profile_pb.d.ts +7 -11
  22. package/dist/gen/auth/v1/profile_pb.d.ts.map +1 -1
  23. package/dist/gen/auth/v1/profile_pb.js +1 -1
  24. package/dist/gen/auth/v1/profile_pb.js.map +1 -1
  25. package/dist/gen/auth/v1/social_verification_pb.d.ts +44 -10
  26. package/dist/gen/auth/v1/social_verification_pb.d.ts.map +1 -1
  27. package/dist/gen/auth/v1/social_verification_pb.js +1 -1
  28. package/dist/gen/auth/v1/social_verification_pb.js.map +1 -1
  29. package/dist/gen/auth/v1/subaccounts_pb.d.ts +17 -1
  30. package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
  31. package/dist/gen/auth/v1/subaccounts_pb.js +15 -1
  32. package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
  33. package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +228 -38
  34. package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts.map +1 -1
  35. package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.js +34 -10
  36. package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.js.map +1 -1
  37. package/dist/gen/chain/lifecycle/v1/types_pb.d.ts +12 -0
  38. package/dist/gen/chain/lifecycle/v1/types_pb.d.ts.map +1 -1
  39. package/dist/gen/chain/lifecycle/v1/types_pb.js +13 -1
  40. package/dist/gen/chain/lifecycle/v1/types_pb.js.map +1 -1
  41. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +6 -3
  42. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts.map +1 -1
  43. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js.map +1 -1
  44. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +10 -1
  45. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
  46. package/dist/gen/chain/withdraw/v1/withdraw_pb.js +10 -1
  47. package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
  48. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +10 -6
  49. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts.map +1 -1
  50. package/dist/gen/chain/zipper/v1/zipper_pb.js +2 -2
  51. package/dist/gen/chain/zipper/v1/zipper_pb.js.map +1 -1
  52. package/dist/gen/index.d.ts +3 -1
  53. package/dist/gen/index.js +4 -2
  54. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +57 -16
  55. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
  56. package/dist/gen/ledger/read/v1/ledger_read_pb.js +32 -1
  57. package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
  58. package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +424 -0
  59. package/dist/gen/ledger/read/v1/statement_export_pb.d.ts.map +1 -0
  60. package/dist/gen/ledger/read/v1/statement_export_pb.js +154 -0
  61. package/dist/gen/ledger/read/v1/statement_export_pb.js.map +1 -0
  62. package/dist/gen/orders/v1/orders_pb.d.ts +28 -4
  63. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  64. package/dist/gen/orders/v1/orders_pb.js +1 -1
  65. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  66. package/dist/gen/orders/v1/orders_read_pb.d.ts +2 -1
  67. package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
  68. package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
  69. package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +12 -7
  70. package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts.map +1 -1
  71. package/dist/gen/ratelimit/v1/ratelimit_pb.js.map +1 -1
  72. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +22 -10
  73. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
  74. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +4 -2
  75. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
  76. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +47 -11
  77. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
  78. package/dist/gen/swap/quickswap/v1/quickswap_pb.js +35 -6
  79. package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
  80. package/dist/gen/transfer/v1/dust_conversion_pb.d.ts +741 -0
  81. package/dist/gen/transfer/v1/dust_conversion_pb.d.ts.map +1 -0
  82. package/dist/gen/transfer/v1/dust_conversion_pb.js +235 -0
  83. package/dist/gen/transfer/v1/dust_conversion_pb.js.map +1 -0
  84. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +367 -3
  85. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
  86. package/dist/gen/transfer/v1/internal_transfer_pb.js +166 -4
  87. package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
  88. package/dist/gen/triggers/v1/triggers_pb.d.ts +10 -5
  89. package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
  90. package/dist/gen/triggers/v1/triggers_pb.js +4 -2
  91. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  92. package/dist/index.d.ts +13 -7
  93. package/dist/services/address-book/address-book.schemas.d.ts +2 -2
  94. package/dist/services/assistant/assistant-events.schemas.d.ts +66 -66
  95. package/dist/services/assistant/assistant.codecs.d.ts +7 -1
  96. package/dist/services/assistant/assistant.codecs.d.ts.map +1 -1
  97. package/dist/services/assistant/assistant.codecs.js +5 -1
  98. package/dist/services/assistant/assistant.codecs.js.map +1 -1
  99. package/dist/services/assistant/assistant.d.ts +4 -3
  100. package/dist/services/assistant/assistant.d.ts.map +1 -1
  101. package/dist/services/assistant/assistant.js +6 -4
  102. package/dist/services/assistant/assistant.js.map +1 -1
  103. package/dist/services/assistant/assistant.schemas.d.ts +40 -3
  104. package/dist/services/assistant/assistant.schemas.d.ts.map +1 -1
  105. package/dist/services/assistant/assistant.schemas.js +18 -4
  106. package/dist/services/assistant/assistant.schemas.js.map +1 -1
  107. package/dist/services/assistant/assistant.types.d.ts +3 -3
  108. package/dist/services/auth/profile/profile.d.ts +1 -1
  109. package/dist/services/auth/profile/profile.js +1 -1
  110. package/dist/services/auth/profile/profile.js.map +1 -1
  111. package/dist/services/auth/profile/profile.schemas.d.ts +0 -1
  112. package/dist/services/auth/profile/profile.schemas.d.ts.map +1 -1
  113. package/dist/services/auth/profile/profile.schemas.js +0 -1
  114. package/dist/services/auth/profile/profile.schemas.js.map +1 -1
  115. package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts +3 -1
  116. package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts.map +1 -1
  117. package/dist/services/auto-withdraw/auto-withdraw.codecs.js.map +1 -1
  118. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +19 -19
  119. package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -1
  120. package/dist/services/balances/balances.d.ts +4 -3
  121. package/dist/services/balances/balances.d.ts.map +1 -1
  122. package/dist/services/balances/balances.js +12 -4
  123. package/dist/services/balances/balances.js.map +1 -1
  124. package/dist/services/balances/balances.schemas.d.ts +30 -5
  125. package/dist/services/balances/balances.schemas.d.ts.map +1 -1
  126. package/dist/services/balances/balances.schemas.js +6 -10
  127. package/dist/services/balances/balances.schemas.js.map +1 -1
  128. package/dist/services/balances/balances.types.d.ts +2 -2
  129. package/dist/services/checkpoints/checkpoints.schemas.d.ts +2 -2
  130. package/dist/services/claims/claims.schemas.js +1 -1
  131. package/dist/services/dust-conversion/dust-conversion.codecs.d.ts +22 -0
  132. package/dist/services/dust-conversion/dust-conversion.codecs.d.ts.map +1 -0
  133. package/dist/services/dust-conversion/dust-conversion.codecs.js +22 -0
  134. package/dist/services/dust-conversion/dust-conversion.codecs.js.map +1 -0
  135. package/dist/services/dust-conversion/dust-conversion.d.ts +59 -0
  136. package/dist/services/dust-conversion/dust-conversion.d.ts.map +1 -0
  137. package/dist/services/dust-conversion/dust-conversion.js +87 -0
  138. package/dist/services/dust-conversion/dust-conversion.js.map +1 -0
  139. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +561 -0
  140. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts.map +1 -0
  141. package/dist/services/dust-conversion/dust-conversion.schemas.js +190 -0
  142. package/dist/services/dust-conversion/dust-conversion.schemas.js.map +1 -0
  143. package/dist/services/dust-conversion/dust-conversion.types.d.ts +3 -0
  144. package/dist/services/dust-conversion/service.d.ts +8 -0
  145. package/dist/services/dust-conversion/service.d.ts.map +1 -0
  146. package/dist/services/dust-conversion/service.js +9 -0
  147. package/dist/services/dust-conversion/service.js.map +1 -0
  148. package/dist/services/heatmap/heatmap.schemas.d.ts +3 -3
  149. package/dist/services/internal-transfers/internal-transfers.codecs.d.ts +13 -1
  150. package/dist/services/internal-transfers/internal-transfers.codecs.d.ts.map +1 -1
  151. package/dist/services/internal-transfers/internal-transfers.codecs.js +22 -2
  152. package/dist/services/internal-transfers/internal-transfers.codecs.js.map +1 -1
  153. package/dist/services/internal-transfers/internal-transfers.d.ts +14 -2
  154. package/dist/services/internal-transfers/internal-transfers.d.ts.map +1 -1
  155. package/dist/services/internal-transfers/internal-transfers.js +29 -3
  156. package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
  157. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +265 -5
  158. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
  159. package/dist/services/internal-transfers/internal-transfers.schemas.js +63 -5
  160. package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
  161. package/dist/services/internal-transfers/internal-transfers.types.d.ts +3 -3
  162. package/dist/services/lifecycle/lifecycle.codecs.d.ts +1 -1
  163. package/dist/services/lifecycle/lifecycle.codecs.d.ts.map +1 -1
  164. package/dist/services/lifecycle/lifecycle.codecs.js +1 -0
  165. package/dist/services/lifecycle/lifecycle.codecs.js.map +1 -1
  166. package/dist/services/lifecycle/lifecycle.d.ts +26 -8
  167. package/dist/services/lifecycle/lifecycle.d.ts.map +1 -1
  168. package/dist/services/lifecycle/lifecycle.js +39 -7
  169. package/dist/services/lifecycle/lifecycle.js.map +1 -1
  170. package/dist/services/lifecycle/lifecycle.schemas.d.ts +160 -136
  171. package/dist/services/lifecycle/lifecycle.schemas.d.ts.map +1 -1
  172. package/dist/services/lifecycle/lifecycle.schemas.js +44 -45
  173. package/dist/services/lifecycle/lifecycle.schemas.js.map +1 -1
  174. package/dist/services/lifecycle/lifecycle.types.d.ts +2 -2
  175. package/dist/services/lifecycle/service.js +1 -1
  176. package/dist/services/lifecycle/service.js.map +1 -1
  177. package/dist/services/orderbook/orderbook.d.ts.map +1 -1
  178. package/dist/services/orderbook/orderbook.js +2 -1
  179. package/dist/services/orderbook/orderbook.js.map +1 -1
  180. package/dist/services/orderbook/orderbook.schemas.d.ts +10 -0
  181. package/dist/services/orderbook/orderbook.schemas.d.ts.map +1 -1
  182. package/dist/services/orderbook/orderbook.schemas.js +4 -1
  183. package/dist/services/orderbook/orderbook.schemas.js.map +1 -1
  184. package/dist/services/orders/order-errors.schemas.d.ts +11 -1
  185. package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
  186. package/dist/services/orders/order-errors.schemas.js +11 -1
  187. package/dist/services/orders/order-errors.schemas.js.map +1 -1
  188. package/dist/services/orders/orders-batch.schemas.d.ts +67 -27
  189. package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
  190. package/dist/services/orders/orders-identifiers.schemas.js +2 -1
  191. package/dist/services/orders/orders-identifiers.schemas.js.map +1 -1
  192. package/dist/services/orders/orders-input.schemas.d.ts +11 -4
  193. package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
  194. package/dist/services/orders/orders-input.schemas.js +1 -0
  195. package/dist/services/orders/orders-input.schemas.js.map +1 -1
  196. package/dist/services/orders/orders-output.schemas.d.ts +17 -17
  197. package/dist/services/orders/orders-output.schemas.js +1 -1
  198. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
  199. package/dist/services/policies/shared.codecs.js +9 -3
  200. package/dist/services/policies/shared.codecs.js.map +1 -1
  201. package/dist/services/policies/shared.d.ts +1 -1
  202. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +5 -5
  203. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
  204. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +2 -3
  205. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
  206. package/dist/services/price-alerts/price-alerts.schemas.d.ts +10 -10
  207. package/dist/services/rate-limits/rate-limits.d.ts +4 -1
  208. package/dist/services/rate-limits/rate-limits.d.ts.map +1 -1
  209. package/dist/services/rate-limits/rate-limits.js +4 -1
  210. package/dist/services/rate-limits/rate-limits.js.map +1 -1
  211. package/dist/services/rate-limits/rate-limits.schemas.d.ts +1 -0
  212. package/dist/services/rate-limits/rate-limits.schemas.d.ts.map +1 -1
  213. package/dist/services/rate-limits/rate-limits.schemas.js +1 -0
  214. package/dist/services/rate-limits/rate-limits.schemas.js.map +1 -1
  215. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  216. package/dist/services/social-verification/social-verification.codecs.js +6 -2
  217. package/dist/services/social-verification/social-verification.codecs.js.map +1 -1
  218. package/dist/services/social-verification/social-verification.d.ts +14 -3
  219. package/dist/services/social-verification/social-verification.d.ts.map +1 -1
  220. package/dist/services/social-verification/social-verification.js +14 -3
  221. package/dist/services/social-verification/social-verification.js.map +1 -1
  222. package/dist/services/social-verification/social-verification.schemas.d.ts +13 -3
  223. package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
  224. package/dist/services/social-verification/social-verification.schemas.js +12 -4
  225. package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
  226. package/dist/services/statement-exports/service.d.ts +8 -0
  227. package/dist/services/statement-exports/service.d.ts.map +1 -0
  228. package/dist/services/statement-exports/service.js +9 -0
  229. package/dist/services/statement-exports/service.js.map +1 -0
  230. package/dist/services/statement-exports/statement-exports.codecs.d.ts +17 -0
  231. package/dist/services/statement-exports/statement-exports.codecs.d.ts.map +1 -0
  232. package/dist/services/statement-exports/statement-exports.codecs.js +19 -0
  233. package/dist/services/statement-exports/statement-exports.codecs.js.map +1 -0
  234. package/dist/services/statement-exports/statement-exports.d.ts +34 -0
  235. package/dist/services/statement-exports/statement-exports.d.ts.map +1 -0
  236. package/dist/services/statement-exports/statement-exports.js +53 -0
  237. package/dist/services/statement-exports/statement-exports.js.map +1 -0
  238. package/dist/services/statement-exports/statement-exports.schemas.d.ts +269 -0
  239. package/dist/services/statement-exports/statement-exports.schemas.d.ts.map +1 -0
  240. package/dist/services/statement-exports/statement-exports.schemas.js +98 -0
  241. package/dist/services/statement-exports/statement-exports.schemas.js.map +1 -0
  242. package/dist/services/statement-exports/statement-exports.types.d.ts +3 -0
  243. package/dist/services/subaccounts/subaccounts.codecs.js +3 -1
  244. package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
  245. package/dist/services/subaccounts/subaccounts.schemas.d.ts +22 -22
  246. package/dist/services/system/system.schemas.d.ts +7 -7
  247. package/dist/services/trades/trades.schemas.d.ts +2 -2
  248. package/dist/services/trades/trades.schemas.js +1 -1
  249. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +1 -1
  250. package/dist/services/transfers/transfers.schemas.js +1 -1
  251. package/dist/services/triggers/trigger-input.schemas.d.ts +5 -4
  252. package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
  253. package/dist/services/triggers/trigger-input.schemas.js +2 -2
  254. package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
  255. package/dist/services/triggers/triggers-output.schemas.d.ts +45 -35
  256. package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
  257. package/dist/services/zipper/zipper.schemas.d.ts.map +1 -1
  258. package/dist/services/zipper/zipper.schemas.js +10 -0
  259. package/dist/services/zipper/zipper.schemas.js.map +1 -1
  260. package/dist/shared/account-scope.js +4 -1
  261. package/dist/shared/account-scope.js.map +1 -1
  262. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  263. package/dist/shared/connect-error-mapping.js +3 -0
  264. package/dist/shared/connect-error-mapping.js.map +1 -1
  265. package/dist/shared/decimal-surface.d.ts.map +1 -1
  266. package/dist/shared/decimal-surface.js +4 -1
  267. package/dist/shared/decimal-surface.js.map +1 -1
  268. package/dist/shared/error-detail.d.ts +5 -0
  269. package/dist/shared/error-detail.d.ts.map +1 -1
  270. package/dist/shared/error-detail.js.map +1 -1
  271. package/dist/shared/error-details/auth.js +7 -2
  272. package/dist/shared/error-details/auth.js.map +1 -1
  273. package/dist/shared/error-details/withdraw.js +1 -1
  274. package/dist/shared/schemas.js +2 -2
  275. package/dist/shared/schemas.js.map +1 -1
  276. package/dist/utils/numbers.js +1 -10
  277. package/dist/utils/numbers.js.map +1 -1
  278. package/dist/utils/u128.js +1 -1
  279. package/dist/utils/u128.js.map +1 -1
  280. package/dist/wired-services.d.ts.map +1 -1
  281. package/dist/wired-services.js +5 -1
  282. package/dist/wired-services.js.map +1 -1
  283. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"subaccount-policies.schemas.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"mappings":";;;;cA0Ca,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;cASjC,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;cAgB9B,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCvB,mBAAmB,EAAE,mBAAmB;cA+DvC,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOlC,8BAA8B,EAAE,kBAAkB;cA6DjD,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BlC,8BAA8B,EAAE,kBAAkB;cASjD,kCAAgC,EAAA;;;;KAQjC,6BAA6B,EAAE,kBAAkB"}
1
+ {"version":3,"file":"subaccount-policies.schemas.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"mappings":";;;;cAyCa,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;cASjC,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;cAgB9B,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCvB,mBAAmB,EAAE,mBAAmB;cA+DvC,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOlC,8BAA8B,EAAE,kBAAkB;cA+DjD,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BlC,8BAA8B,EAAE,kBAAkB;cASjD,kCAAgC,EAAA;;;;KAQjC,6BAA6B,EAAE,kBAAkB"}
@@ -1,6 +1,5 @@
1
1
  import { idToBigInt } from "../../../utils/base58-id.js";
2
2
  import { PROTOBUF_UINT32_MAX } from "../../../shared/wire-bounds.js";
3
- import { toIntOrZero } from "../../../utils/numbers.js";
4
3
  import { tsObjToMs, tsObjToNsString } from "../../../utils/time.js";
5
4
  import { BigIntStringSchema, OptionalNumberToIntOrZeroSchema, OptionalPublicIdSchema, OptionalTimestampMsSchema, PublicIdSchema, TimestampMsSchema, TimestampSchema, idInputSchema, optionalSubaccountIdInputSchema, positiveBigintStringInputSchema } from "../../../shared/schemas.js";
6
5
  import { decimalInputToScaled, scaledToDecimalOutput } from "../../../shared/decimal-surface.js";
@@ -92,7 +91,7 @@ const SubaccountPolicyPatchSchema = v.strictObject({
92
91
  spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),
93
92
  actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),
94
93
  maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),
95
- maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.maxValue(PROTOBUF_UINT32_MAX)))),
94
+ maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX)))),
96
95
  tradingHalted: v.optional(v.boolean()),
97
96
  policyLocked: v.optional(v.boolean()),
98
97
  reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),
@@ -125,7 +124,7 @@ const SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields()({
125
124
  },
126
125
  maxOpenOrders: {
127
126
  path: "max_open_orders",
128
- encode: (value) => ({ maxOpenOrders: toIntOrZero(value) })
127
+ encode: (value) => ({ maxOpenOrders: value ?? 0 })
129
128
  },
130
129
  tradingHalted: {
131
130
  path: "trading_halted",
@@ -1 +1 @@
1
- {"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n SubaccountPolicyActionEnumSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { msToTimestamp } from \"../../../utils/timestamp.js\";\nimport { toIntOrZero } from \"../../../utils/numbers.js\";\nimport {\n QUOTE_NOTIONAL_SCALE,\n decimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../../shared/wire-bounds.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((value) => scaledToDecimalOutput(value, QUOTE_NOTIONAL_SCALE)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\n/**\n * Max spot order notional as a decimal USDT string (e.g. `\"100000.5\"`). The wire\n * field is canonical quote microunits, so `\"100000\"` caps orders at 100,000 USDT.\n * `\"0\"` means no cap.\n */\nconst MaxOrderSizeInputSchema = v.pipe(\n v.string(),\n v.transform((value) => decimalInputToScaled(\"maxOrderSize\", value, QUOTE_NOTIONAL_SCALE)),\n);\n\nconst OptionalMaxOrderSizeInputSchema = v.pipe(\n v.optional(v.nullable(MaxOrderSizeInputSchema), null),\n v.transform((value) => value ?? 0n),\n);\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(SubaccountPolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalMaxOrderSizeInputSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return msToTimestamp(value);\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),\n maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.maxValue(PROTOBUF_UINT32_MAX)))),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: value ?? 0n }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: toIntOrZero(value) }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: \"0\",\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;;;AA0CA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACrD,GAAG;AACP,CAAC,GACD,EAAE,WAAW,EAAE,UAAU,eAAe;CACpC,UAAU,WAAW,UAAU,UAAU;CACzC,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;;;AAOA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,IAAI;CACJ,MAAM,EAAE,OAAO;CACf,aAAa,EAAE,OAAO;CACtB,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,GAAG,CAAC,CAAC;CACzD,iBAAiB,EAAE,KACf,kCACA,EAAE,WAAW,MAAM,0BAA0B,CAAC,CAAC,CACnD;CACA,SAAS,EAAE,KACP,EAAE,SAAS,EAAE,MAAM,2BAA2B,G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KAAA;CACX,UAAU;AACd"}
1
+ {"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n SubaccountPolicyActionEnumSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { msToTimestamp } from \"../../../utils/timestamp.js\";\nimport {\n QUOTE_NOTIONAL_SCALE,\n decimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../../shared/wire-bounds.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((value) => scaledToDecimalOutput(value, QUOTE_NOTIONAL_SCALE)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\n/**\n * Max spot order notional as a decimal USDT string (e.g. `\"100000.5\"`). The wire\n * field is canonical quote microunits, so `\"100000\"` caps orders at 100,000 USDT.\n * `\"0\"` means no cap.\n */\nconst MaxOrderSizeInputSchema = v.pipe(\n v.string(),\n v.transform((value) => decimalInputToScaled(\"maxOrderSize\", value, QUOTE_NOTIONAL_SCALE)),\n);\n\nconst OptionalMaxOrderSizeInputSchema = v.pipe(\n v.optional(v.nullable(MaxOrderSizeInputSchema), null),\n v.transform((value) => value ?? 0n),\n);\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(SubaccountPolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalMaxOrderSizeInputSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return msToTimestamp(value);\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),\n maxOpenOrders: v.optional(\n v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX))),\n ),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: value ?? 0n }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: value ?? 0 }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: \"0\",\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;;AAyCA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACrD,GAAG;AACP,CAAC,GACD,EAAE,WAAW,EAAE,UAAU,eAAe;CACpC,UAAU,WAAW,UAAU,UAAU;CACzC,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;;;AAOA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,IAAI;CACJ,MAAM,EAAE,OAAO;CACf,aAAa,EAAE,OAAO;CACtB,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,GAAG,CAAC,CAAC;CACzD,iBAAiB,EAAE,KACf,kCACA,EAAE,WAAW,MAAM,0BAA0B,CAAC,CAAC,CACnD;CACA,SAAS,EAAE,KACP,EAAE,SAAS,EAAE,MAAM,2BAA2B,GAAG,CAAC,CAAC,GACnD,EAAE,WAAW,MAAM,EAAE,KAAK,WAAW,qBAAqB,MAAM,CAAC,CAAC,CACtE;CACA,YAAY,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CACzC,kBAAkB;CAClB,kBAAkB,EAAE,KAChB,EAAE,OAAO,GACT,EAAE,WAAW,UAAU,sBAAsB,OAAA,CAA2B,CAAC,CAC7E;CACA,eAAe,EAAE,OAAO;CACxB,eAAe,EAAE,QAAQ;CACzB,QAAQ,EAAE,QAAQ;CAClB,UAAU;CAC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AC,CAAC,MAAM,UAAU,UAAU,KAAA,CAAS,GAC5D,uDACJ,GACA,EAAE,WAAW,EAAE,UAAU,kBAAkB,GAAG,YAAY;CACtD,MAAM,EAAE,OAAO,QAAQ,eAAe,gBAClC,OACA,8BACJ;CACA,OAAO;EACH;EACA;EACA;EACA;CACJ;AACJ,CAAC,CACL;AAGA,MAAa,iBAAiB,EAAE,KAC5B,EAAE,OAAO,GACT,EAAE,KAAK,GACP,EAAE,UAAU,CAAC,GACb,EAAE,WAAW,MAAM,WAAW,GAAG,UAAU,CAAC,CAChD;AAEA,MAAa,mCAAmC,EAAE,aAAa;CAC3D,cAAc,cAAc,cAAc;CAC1C,UAAU,EAAE,KACR,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC,GACvC,EAAE,WAAW,UAAW,QAAQ,WAAW,OAAO,UAAU,IAAI,KAAA,CAAU,CAC9E;AACJ,CAAC;AAID,MAAM,uCAAuC,KAAK,IAAI;AAEtD,MAAa,4BAA8C;CACvD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,aAAa,CAAC;CACd,iBAAiB;CACjB,SAAS;EAAC;EAAiB;EAA2B;EAAqB;CAAW;CACtF,cAAc;CACd,eAAe;CACf,eAAe;CACf,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,UAAU;AACd"}
@@ -37,7 +37,7 @@ declare const ListPriceAlertsInputSchema: v.SchemaWithPipe<readonly [v.StrictObj
37
37
  /** Previous `nextPageToken`; reuse only with the same filters. */
38
38
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>;
39
39
  }, undefined>, v.TransformAction<{
40
- statuses?: ("active" | "triggered" | "canceled")[] | undefined;
40
+ statuses?: ("active" | "canceled" | "triggered")[] | undefined;
41
41
  symbolId?: number | undefined;
42
42
  limit?: number | undefined;
43
43
  pageToken?: string | undefined;
@@ -92,7 +92,7 @@ declare const PriceAlertSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
92
92
  readonly priceTicks: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
93
93
  readonly referencePriceTicks: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
94
94
  readonly armed: v.BooleanSchema<undefined>;
95
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "active" | "triggered" | "canceled">]>;
95
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "active" | "canceled" | "triggered">]>;
96
96
  readonly channels: v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "in_app" | "telegram">]>, undefined>;
97
97
  readonly revision: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
98
98
  readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
@@ -125,7 +125,7 @@ declare const PriceAlertSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
125
125
  priceTicks: string;
126
126
  referencePriceTicks: string;
127
127
  armed: boolean;
128
- status: "unspecified" | "active" | "triggered" | "canceled";
128
+ status: "unspecified" | "active" | "canceled" | "triggered";
129
129
  channels: ("unspecified" | "in_app" | "telegram")[];
130
130
  revision: string;
131
131
  createdAt?: number | undefined;
@@ -143,7 +143,7 @@ declare const PriceAlertSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
143
143
  referencePrice: string;
144
144
  /** False while an alert created past its price waits for the price to move back first. */
145
145
  armed: boolean;
146
- status: "unspecified" | "active" | "triggered" | "canceled";
146
+ status: "unspecified" | "active" | "canceled" | "triggered";
147
147
  channels: ("unspecified" | "in_app" | "telegram")[];
148
148
  /** Pass as `expectedRevision` to `update`. */
149
149
  revision: string;
@@ -164,7 +164,7 @@ declare const ListPriceAlertsResultSchema: v.ObjectSchema<{
164
164
  readonly priceTicks: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
165
165
  readonly referencePriceTicks: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
166
166
  readonly armed: v.BooleanSchema<undefined>;
167
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "active" | "triggered" | "canceled">]>;
167
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "active" | "canceled" | "triggered">]>;
168
168
  readonly channels: v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "in_app" | "telegram">]>, undefined>;
169
169
  readonly revision: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
170
170
  readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
@@ -197,7 +197,7 @@ declare const ListPriceAlertsResultSchema: v.ObjectSchema<{
197
197
  priceTicks: string;
198
198
  referencePriceTicks: string;
199
199
  armed: boolean;
200
- status: "unspecified" | "active" | "triggered" | "canceled";
200
+ status: "unspecified" | "active" | "canceled" | "triggered";
201
201
  channels: ("unspecified" | "in_app" | "telegram")[];
202
202
  revision: string;
203
203
  createdAt?: number | undefined;
@@ -215,7 +215,7 @@ declare const ListPriceAlertsResultSchema: v.ObjectSchema<{
215
215
  referencePrice: string;
216
216
  /** False while an alert created past its price waits for the price to move back first. */
217
217
  armed: boolean;
218
- status: "unspecified" | "active" | "triggered" | "canceled";
218
+ status: "unspecified" | "active" | "canceled" | "triggered";
219
219
  channels: ("unspecified" | "in_app" | "telegram")[];
220
220
  /** Pass as `expectedRevision` to `update`. */
221
221
  revision: string;
@@ -239,7 +239,7 @@ declare const UpdatePriceAlertResultSchema: v.ObjectSchema<{
239
239
  readonly priceTicks: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
240
240
  readonly referencePriceTicks: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
241
241
  readonly armed: v.BooleanSchema<undefined>;
242
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "active" | "triggered" | "canceled">]>;
242
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "active" | "canceled" | "triggered">]>;
243
243
  readonly channels: v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "in_app" | "telegram">]>, undefined>;
244
244
  readonly revision: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
245
245
  readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
@@ -272,7 +272,7 @@ declare const UpdatePriceAlertResultSchema: v.ObjectSchema<{
272
272
  priceTicks: string;
273
273
  referencePriceTicks: string;
274
274
  armed: boolean;
275
- status: "unspecified" | "active" | "triggered" | "canceled";
275
+ status: "unspecified" | "active" | "canceled" | "triggered";
276
276
  channels: ("unspecified" | "in_app" | "telegram")[];
277
277
  revision: string;
278
278
  createdAt?: number | undefined;
@@ -290,7 +290,7 @@ declare const UpdatePriceAlertResultSchema: v.ObjectSchema<{
290
290
  referencePrice: string;
291
291
  /** False while an alert created past its price waits for the price to move back first. */
292
292
  armed: boolean;
293
- status: "unspecified" | "active" | "triggered" | "canceled";
293
+ status: "unspecified" | "active" | "canceled" | "triggered";
294
294
  channels: ("unspecified" | "in_app" | "telegram")[];
295
295
  /** Pass as `expectedRevision` to `update`. */
296
296
  revision: string;
@@ -15,7 +15,10 @@ declare class RateLimitService {
15
15
  */
16
16
  getConfig(options?: PolyesterRequestOptions): Promise<RateLimitConfig>;
17
17
  /**
18
- * Returns the effective placement and cancellation limits for the resolved account target, including API-key-scoped rules when the caller authenticated with an API key.
18
+ * Returns the placement and cancellation limits enforced for the resolved account. Limits
19
+ * apply per account: every API key and session that trades for it shares them, so more API
20
+ * keys add no capacity. `apiKeyRules`, present for an API-key caller, are informational
21
+ * only; `rules` are the enforced limits.
19
22
  */
20
23
  getTradingLimits(input?: AccountScopedInput, options?: PolyesterRequestOptions): Promise<TradingRateLimits>;
21
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rate-limits.d.ts","names":[],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"mappings":";;;;;;;;;cAsBa;;EAKG,YAAA,YAAY,4BAA4B,WAAW;;;;EASzD,UAAU,UAAU,0BAA0B,QAAQ;;;;EAQtD,iBACF,QAAO,oBACP,UAAU,0BACX,QAAQ"}
1
+ {"version":3,"file":"rate-limits.d.ts","names":[],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"mappings":";;;;;;;;;cAsBa;;EAKG,YAAA,YAAY,4BAA4B,WAAW;;;;EASzD,UAAU,UAAU,0BAA0B,QAAQ;;;;;;;EAWtD,iBACF,QAAO,oBACP,UAAU,0BACX,QAAQ"}
@@ -26,7 +26,10 @@ var RateLimitService = class {
26
26
  return parse(RateLimitConfigSchema, res);
27
27
  }
28
28
  /**
29
- * Returns the effective placement and cancellation limits for the resolved account target, including API-key-scoped rules when the caller authenticated with an API key.
29
+ * Returns the placement and cancellation limits enforced for the resolved account. Limits
30
+ * apply per account: every API key and session that trades for it shares them, so more API
31
+ * keys add no capacity. `apiKeyRules`, present for an API-key caller, are informational
32
+ * only; `rules` are the enforced limits.
30
33
  */
31
34
  async getTradingLimits(input = {}, options) {
32
35
  const resolvedInput = resolveAccountScopedInput(input, this.#resolver);
@@ -1 +1 @@
1
- {"version":3,"file":"rate-limits.js","names":["#publicClient","Proto.RateLimitService","#authClient","#resolver"],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/ratelimit/v1/ratelimit_pb.js\";\nimport type { AccountScopedInput } from \"../../shared/account-scope.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport {\n GetTradingRateLimitsInputSchema,\n RateLimitConfigSchema,\n TradingRateLimitsSchema,\n type RateLimitConfig,\n type TradingRateLimits,\n} from \"./rate-limits.schemas.js\";\n\n/**\n * Reads public trading quota catalogs and authenticated effective trading limits.\n */\nexport class RateLimitService {\n #publicClient: Client<typeof Proto.RateLimitService>;\n #authClient: Client<typeof Proto.RateLimitService>;\n #resolver?: SubaccountResolver;\n\n constructor(transports: AuthAndPublicApiTransports, resolver?: SubaccountResolver) {\n this.#publicClient = createClient(Proto.RateLimitService, transports.publicApi);\n this.#authClient = createClient(Proto.RateLimitService, transports.authApi);\n this.#resolver = resolver;\n }\n\n /**\n * Returns the complete active placement and cancellation quota catalog for VIP0+.\n */\n async getConfig(options?: PolyesterRequestOptions): Promise<RateLimitConfig> {\n const res = await this.#publicClient.getRateLimitConfig({}, toConnectCallOptions(options));\n return parse(RateLimitConfigSchema, res);\n }\n\n /**\n * Returns the effective placement and cancellation limits for the resolved account target, including API-key-scoped rules when the caller authenticated with an API key.\n */\n async getTradingLimits(\n input: AccountScopedInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<TradingRateLimits> {\n const resolvedInput = resolveAccountScopedInput(input, this.#resolver);\n const res = await this.#authClient.getTradingRateLimits(\n removeUndefined(parse(GetTradingRateLimitsInputSchema, resolvedInput)),\n toConnectCallOptions(options),\n );\n return parse(TradingRateLimitsSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,YAAwC,UAA+B;EAC/E,KAAKA,gBAAgB,aAAaC,oBAAwB,WAAW,SAAS;EAC9E,KAAKC,cAAc,aAAaD,oBAAwB,WAAW,OAAO;EAC1E,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,UAAU,SAA6D;EACzE,MAAM,MAAM,MAAM,KAAKH,cAAc,mBAAmB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACzF,OAAO,MAAM,uBAAuB,GAAG;CAC3C;;;;CAKA,MAAM,iBACF,QAA4B,CAAC,GAC7B,SAC0B;EAC1B,MAAM,gBAAgB,0BAA0B,OAAO,KAAKG,SAAS;EACrE,MAAM,MAAM,MAAM,KAAKD,YAAY,qBAC/B,gBAAgB,MAAM,iCAAiC,aAAa,CAAC,GACrE,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,yBAAyB,GAAG;CAC7C;AACJ"}
1
+ {"version":3,"file":"rate-limits.js","names":["#publicClient","Proto.RateLimitService","#authClient","#resolver"],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/ratelimit/v1/ratelimit_pb.js\";\nimport type { AccountScopedInput } from \"../../shared/account-scope.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport {\n GetTradingRateLimitsInputSchema,\n RateLimitConfigSchema,\n TradingRateLimitsSchema,\n type RateLimitConfig,\n type TradingRateLimits,\n} from \"./rate-limits.schemas.js\";\n\n/**\n * Reads public trading quota catalogs and authenticated effective trading limits.\n */\nexport class RateLimitService {\n #publicClient: Client<typeof Proto.RateLimitService>;\n #authClient: Client<typeof Proto.RateLimitService>;\n #resolver?: SubaccountResolver;\n\n constructor(transports: AuthAndPublicApiTransports, resolver?: SubaccountResolver) {\n this.#publicClient = createClient(Proto.RateLimitService, transports.publicApi);\n this.#authClient = createClient(Proto.RateLimitService, transports.authApi);\n this.#resolver = resolver;\n }\n\n /**\n * Returns the complete active placement and cancellation quota catalog for VIP0+.\n */\n async getConfig(options?: PolyesterRequestOptions): Promise<RateLimitConfig> {\n const res = await this.#publicClient.getRateLimitConfig({}, toConnectCallOptions(options));\n return parse(RateLimitConfigSchema, res);\n }\n\n /**\n * Returns the placement and cancellation limits enforced for the resolved account. Limits\n * apply per account: every API key and session that trades for it shares them, so more API\n * keys add no capacity. `apiKeyRules`, present for an API-key caller, are informational\n * only; `rules` are the enforced limits.\n */\n async getTradingLimits(\n input: AccountScopedInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<TradingRateLimits> {\n const resolvedInput = resolveAccountScopedInput(input, this.#resolver);\n const res = await this.#authClient.getTradingRateLimits(\n removeUndefined(parse(GetTradingRateLimitsInputSchema, resolvedInput)),\n toConnectCallOptions(options),\n );\n return parse(TradingRateLimitsSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,YAAwC,UAA+B;EAC/E,KAAKA,gBAAgB,aAAaC,oBAAwB,WAAW,SAAS;EAC9E,KAAKC,cAAc,aAAaD,oBAAwB,WAAW,OAAO;EAC1E,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,UAAU,SAA6D;EACzE,MAAM,MAAM,MAAM,KAAKH,cAAc,mBAAmB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACzF,OAAO,MAAM,uBAAuB,GAAG;CAC3C;;;;;;;CAQA,MAAM,iBACF,QAA4B,CAAC,GAC7B,SAC0B;EAC1B,MAAM,gBAAgB,0BAA0B,OAAO,KAAKG,SAAS;EACrE,MAAM,MAAM,MAAM,KAAKD,YAAY,qBAC/B,gBAAgB,MAAM,iCAAiC,aAAa,CAAC,GACrE,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,yBAAyB,GAAG;CAC7C;AACJ"}
@@ -28,6 +28,7 @@ declare const RateLimitConfigSchema: v.ObjectSchema<{
28
28
  }, undefined>;
29
29
  type RateLimitConfig = v.InferOutput<typeof RateLimitConfigSchema>;
30
30
  declare const TradingRateLimitsSchema: v.ObjectSchema<{
31
+ /** Rules resolved for the calling API key; informational, not enforced. Only `rules` limit trading. */
31
32
  readonly apiKeyRules: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
32
33
  readonly policyClass: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "trading_place" | "trading_cancel">]>;
33
34
  readonly vipTier: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
@@ -1 +1 @@
1
- {"version":3,"file":"rate-limits.schemas.d.ts","names":[],"sources":["../../../src/services/rate-limits/rate-limits.schemas.ts"],"mappings":";;;cAca,4BAA0B,EAAA;;;;;;;KAQ3B,uBAAuB,EAAE,mBAAmB;cAE3C,uBAAqB,EAAA;;;;;;;;;;;;;;;;;KAMtB,kBAAkB,EAAE,mBAAmB;cAWtC,yBAAuB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;KAKxB,oBAAoB,EAAE,mBAAmB"}
1
+ {"version":3,"file":"rate-limits.schemas.d.ts","names":[],"sources":["../../../src/services/rate-limits/rate-limits.schemas.ts"],"mappings":";;;cAca,4BAA0B,EAAA;;;;;;;KAQ3B,uBAAuB,EAAE,mBAAmB;cAE3C,uBAAqB,EAAA;;;;;;;;;;;;;;;;;KAMtB,kBAAkB,EAAE,mBAAmB;cAWtC,yBAAuB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAMxB,oBAAoB,EAAE,mBAAmB"}
@@ -21,6 +21,7 @@ const RateLimitConfigSchema = v.object({
21
21
  const GetTradingRateLimitsInputSchema = v.pipe(v.strictObject({ ...AccountScopeInputEntries }), v.transform(({ account }) => ({ subaccountId: accountScopeToSubaccountId(account) })));
22
22
  const TradingRateLimitsSchema = v.object({
23
23
  ...RateLimitConfigSchema.entries,
24
+ /** Rules resolved for the calling API key; informational, not enforced. Only `rules` limit trading. */
24
25
  apiKeyRules: v.optional(v.array(TradingRateLimitRuleSchema), [])
25
26
  });
26
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"rate-limits.schemas.js","names":[],"sources":["../../../src/services/rate-limits/rate-limits.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { BigIntStringSchema, TimestampMsSchema } from \"../../shared/schemas.js\";\nimport { VipTierNumberSchema } from \"../vip/vip.schemas.js\";\nimport { TradingRateLimitClassCodec } from \"./rate-limits.codecs.js\";\n\nexport type { TradingRateLimitClass } from \"./rate-limits.codecs.js\";\n\nconst TradingRateLimitClassOutputSchema = enumLabelSchema(TradingRateLimitClassCodec.protoToOutput);\n\nexport const TradingRateLimitRuleSchema = v.object({\n policyClass: TradingRateLimitClassOutputSchema,\n vipTier: VipTierNumberSchema,\n quotaWeight: BigIntStringSchema,\n periodMs: BigIntStringSchema,\n burstWeight: BigIntStringSchema,\n});\n\nexport type TradingRateLimitRule = v.InferOutput<typeof TradingRateLimitRuleSchema>;\n\nexport const RateLimitConfigSchema = v.object({\n policyVersion: BigIntStringSchema,\n effectiveFrom: TimestampMsSchema,\n rules: v.array(TradingRateLimitRuleSchema),\n});\n\nexport type RateLimitConfig = v.InferOutput<typeof RateLimitConfigSchema>;\n\nexport const GetTradingRateLimitsInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport const TradingRateLimitsSchema = v.object({\n ...RateLimitConfigSchema.entries,\n apiKeyRules: v.optional(v.array(TradingRateLimitRuleSchema), []),\n});\n\nexport type TradingRateLimits = v.InferOutput<typeof TradingRateLimitsSchema>;\n"],"mappings":";;;;;;;AAYA,MAAM,oCAAoC,gBAAgB,2BAA2B,aAAa;AAElG,MAAa,6BAA6B,EAAE,OAAO;CAC/C,aAAa;CACb,SAAS;CACT,aAAa;CACb,UAAU;CACV,aAAa;AACjB,CAAC;AAID,MAAa,wBAAwB,EAAE,OAAO;CAC1C,eAAe;CACf,eAAe;CACf,OAAO,EAAE,MAAM,0BAA0B;AAC7C,CAAC;AAID,MAAa,kCAAkC,EAAE,KAC7C,EAAE,aAAa,EACX,GAAG,yBACP,CAAC,GACD,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAEA,MAAa,0BAA0B,EAAE,OAAO;CAC5C,GAAG,sBAAsB;CACzB,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACnE,CAAC"}
1
+ {"version":3,"file":"rate-limits.schemas.js","names":[],"sources":["../../../src/services/rate-limits/rate-limits.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport { BigIntStringSchema, TimestampMsSchema } from \"../../shared/schemas.js\";\nimport { VipTierNumberSchema } from \"../vip/vip.schemas.js\";\nimport { TradingRateLimitClassCodec } from \"./rate-limits.codecs.js\";\n\nexport type { TradingRateLimitClass } from \"./rate-limits.codecs.js\";\n\nconst TradingRateLimitClassOutputSchema = enumLabelSchema(TradingRateLimitClassCodec.protoToOutput);\n\nexport const TradingRateLimitRuleSchema = v.object({\n policyClass: TradingRateLimitClassOutputSchema,\n vipTier: VipTierNumberSchema,\n quotaWeight: BigIntStringSchema,\n periodMs: BigIntStringSchema,\n burstWeight: BigIntStringSchema,\n});\n\nexport type TradingRateLimitRule = v.InferOutput<typeof TradingRateLimitRuleSchema>;\n\nexport const RateLimitConfigSchema = v.object({\n policyVersion: BigIntStringSchema,\n effectiveFrom: TimestampMsSchema,\n rules: v.array(TradingRateLimitRuleSchema),\n});\n\nexport type RateLimitConfig = v.InferOutput<typeof RateLimitConfigSchema>;\n\nexport const GetTradingRateLimitsInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport const TradingRateLimitsSchema = v.object({\n ...RateLimitConfigSchema.entries,\n /** Rules resolved for the calling API key; informational, not enforced. Only `rules` limit trading. */\n apiKeyRules: v.optional(v.array(TradingRateLimitRuleSchema), []),\n});\n\nexport type TradingRateLimits = v.InferOutput<typeof TradingRateLimitsSchema>;\n"],"mappings":";;;;;;;AAYA,MAAM,oCAAoC,gBAAgB,2BAA2B,aAAa;AAElG,MAAa,6BAA6B,EAAE,OAAO;CAC/C,aAAa;CACb,SAAS;CACT,aAAa;CACb,UAAU;CACV,aAAa;AACjB,CAAC;AAID,MAAa,wBAAwB,EAAE,OAAO;CAC1C,eAAe;CACf,eAAe;CACf,OAAO,EAAE,MAAM,0BAA0B;AAC7C,CAAC;AAID,MAAa,kCAAkC,EAAE,KAC7C,EAAE,aAAa,EACX,GAAG,yBACP,CAAC,GACD,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAEA,MAAa,0BAA0B,EAAE,OAAO;CAC5C,GAAG,sBAAsB;;CAEzB,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,GAAG,CAAC,CAAC;AACnE,CAAC"}
@@ -29,7 +29,7 @@ declare const RewardAwardSchema: v.ObjectSchema<{
29
29
  readonly assetId: v.NumberSchema<undefined>;
30
30
  readonly amountBaseUnits: v.StringSchema<undefined>;
31
31
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
32
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
32
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
33
33
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
34
34
  readonly seconds: v.BigintSchema<undefined>;
35
35
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -67,7 +67,7 @@ declare const ListRewardAwardsResultSchema: v.ObjectSchema<{
67
67
  readonly assetId: v.NumberSchema<undefined>;
68
68
  readonly amountBaseUnits: v.StringSchema<undefined>;
69
69
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
70
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
70
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
71
71
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
72
72
  readonly seconds: v.BigintSchema<undefined>;
73
73
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -114,7 +114,7 @@ declare const SetRewardDestinationResultSchema: v.ObjectSchema<{
114
114
  readonly assetId: v.NumberSchema<undefined>;
115
115
  readonly amountBaseUnits: v.StringSchema<undefined>;
116
116
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
117
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
117
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
118
118
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
119
119
  readonly seconds: v.BigintSchema<undefined>;
120
120
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -153,7 +153,7 @@ declare const AcknowledgeRewardAwardResultSchema: v.ObjectSchema<{
153
153
  readonly assetId: v.NumberSchema<undefined>;
154
154
  readonly amountBaseUnits: v.StringSchema<undefined>;
155
155
  readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
156
- readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
156
+ readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
157
157
  readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
158
158
  readonly seconds: v.BigintSchema<undefined>;
159
159
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -102,7 +102,9 @@ const SOCIAL_VERIFICATION_ERROR_CODE_VALUES = [
102
102
  "social_verification_expired",
103
103
  "social_verification_invalid_state",
104
104
  "subaccount_challenge_invalid",
105
- "social_account_already_linked"
105
+ "social_account_already_linked",
106
+ "social_account_cooldown",
107
+ "social_change_limit_reached"
106
108
  ];
107
109
  const SocialVerificationErrorCodeCodec = { protoToOutput: {
108
110
  [0]: "unspecified",
@@ -149,7 +151,9 @@ const SocialVerificationErrorCodeCodec = { protoToOutput: {
149
151
  [42]: "social_verification_expired",
150
152
  [43]: "social_verification_invalid_state",
151
153
  [44]: "subaccount_challenge_invalid",
152
- [45]: "social_account_already_linked"
154
+ [45]: "social_account_already_linked",
155
+ [64]: "social_account_cooldown",
156
+ [65]: "social_change_limit_reached"
153
157
  } };
154
158
  //#endregion
155
159
  export { SOCIAL_PROVIDER_VALUES, SOCIAL_VERIFICATION_ERROR_CODE_VALUES, SOCIAL_VERIFICATION_METHOD_VALUES, SOCIAL_VERIFICATION_STATUS_VALUES, SocialProviderCodec, SocialVerificationErrorCodeCodec, SocialVerificationMethodCodec, SocialVerificationStatusCodec };
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.codecs.js","names":[],"sources":["../../../src/services/social-verification/social-verification.codecs.ts"],"sourcesContent":["import { AuthErrorCode } from \"../../gen/auth/v1/auth_pb.js\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SOCIAL_PROVIDER_VALUES = [\"twitter\", \"discord\", \"telegram\"] as const;\nexport type SocialProviderValue = (typeof SOCIAL_PROVIDER_VALUES)[number];\n\nexport const SOCIAL_VERIFICATION_METHOD_VALUES = [\"profile\", \"channel\", \"dm\"] as const;\nexport type SocialVerificationMethodValue = (typeof SOCIAL_VERIFICATION_METHOD_VALUES)[number];\n\nexport const SOCIAL_VERIFICATION_STATUS_VALUES = [\n \"pending_user_action\",\n \"queued\",\n \"in_progress\",\n \"verified\",\n \"failed\",\n \"expired\",\n \"canceled\",\n \"awaiting_confirmation\",\n] as const;\nexport type SocialVerificationStatusValue = (typeof SOCIAL_VERIFICATION_STATUS_VALUES)[number];\n\nexport const SocialProviderCodec = {\n inputToProto: {\n twitter: Proto.SocialProvider.TWITTER,\n discord: Proto.SocialProvider.DISCORD,\n telegram: Proto.SocialProvider.TELEGRAM,\n } satisfies InputToProto<SocialProviderValue, Proto.SocialProvider>,\n protoToOutput: {\n [Proto.SocialProvider.PROVIDER_UNSPECIFIED]: \"unspecified\",\n [Proto.SocialProvider.TWITTER]: \"twitter\",\n [Proto.SocialProvider.DISCORD]: \"discord\",\n [Proto.SocialProvider.TELEGRAM]: \"telegram\",\n } satisfies ProtoToOutput<Proto.SocialProvider, SocialProviderValue>,\n} as const;\n\nexport const SocialVerificationMethodCodec = {\n inputToProto: {\n profile: Proto.SocialVerificationMethod.METHOD_PROFILE,\n channel: Proto.SocialVerificationMethod.METHOD_CHANNEL,\n dm: Proto.SocialVerificationMethod.METHOD_DM,\n } satisfies InputToProto<SocialVerificationMethodValue, Proto.SocialVerificationMethod>,\n protoToOutput: {\n [Proto.SocialVerificationMethod.METHOD_UNSPECIFIED]: \"unspecified\",\n [Proto.SocialVerificationMethod.METHOD_PROFILE]: \"profile\",\n [Proto.SocialVerificationMethod.METHOD_CHANNEL]: \"channel\",\n [Proto.SocialVerificationMethod.METHOD_DM]: \"dm\",\n } satisfies ProtoToOutput<Proto.SocialVerificationMethod, SocialVerificationMethodValue>,\n} as const;\n\nexport const SocialVerificationStatusCodec = {\n protoToOutput: {\n [Proto.SocialVerificationStatus.STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.SocialVerificationStatus.STATUS_PENDING_USER_ACTION]: \"pending_user_action\",\n [Proto.SocialVerificationStatus.STATUS_QUEUED]: \"queued\",\n [Proto.SocialVerificationStatus.STATUS_IN_PROGRESS]: \"in_progress\",\n [Proto.SocialVerificationStatus.STATUS_VERIFIED]: \"verified\",\n [Proto.SocialVerificationStatus.STATUS_FAILED]: \"failed\",\n [Proto.SocialVerificationStatus.STATUS_EXPIRED]: \"expired\",\n [Proto.SocialVerificationStatus.STATUS_CANCELLED]: \"canceled\",\n [Proto.SocialVerificationStatus.STATUS_AWAITING_CONFIRMATION]: \"awaiting_confirmation\",\n } satisfies ProtoToOutput<Proto.SocialVerificationStatus, SocialVerificationStatusValue>,\n} as const;\n\nexport const SOCIAL_VERIFICATION_ERROR_CODE_VALUES = [\n \"username_invalid\",\n \"username_taken\",\n \"username_cooldown\",\n \"username_feature_locked\",\n \"username_reserved\",\n \"invalid_request\",\n \"authentication_required\",\n \"session_kind_not_allowed\",\n \"wallet_login_failed\",\n \"resource_not_found\",\n \"subaccount_access_denied\",\n \"api_key_access_denied\",\n \"api_key_invalid_status_transition\",\n \"policy_invalid\",\n \"smart_account_already_linked\",\n \"invite_access_denied\",\n \"invite_invalid_state\",\n \"mfa_disabled\",\n \"mfa_not_enrolled\",\n \"mfa_session_invalid\",\n \"mfa_challenge_not_found\",\n \"mfa_challenge_invalid\",\n \"mfa_challenge_locked\",\n \"mfa_otp_invalid\",\n \"mfa_recovery_invalid\",\n \"mfa_passkey_not_available\",\n \"mfa_passkey_credential_invalid\",\n \"mfa_passkey_verify_failed\",\n \"mfa_enrollment_binding_invalid\",\n \"step_up_required\",\n \"step_up_proof_unavailable\",\n \"step_up_already_claimed\",\n \"policy_in_use\",\n \"policy_locked\",\n \"policy_scope_mismatch\",\n \"revision_conflict\",\n \"mfa_elevation_required\",\n \"mfa_last_factor_required\",\n \"internal_error\",\n \"terms_not_accepted\",\n \"social_verification_expired\",\n \"social_verification_invalid_state\",\n \"subaccount_challenge_invalid\",\n \"social_account_already_linked\",\n] as const;\nexport type SocialVerificationErrorCodeValue =\n (typeof SOCIAL_VERIFICATION_ERROR_CODE_VALUES)[number];\n\n// Partial: auth codes added upstream decode to \"unspecified\" until mapped here.\nexport const SocialVerificationErrorCodeCodec = {\n protoToOutput: {\n [AuthErrorCode.AUTH_UNSPECIFIED]: \"unspecified\",\n [AuthErrorCode.AUTH_USERNAME_INVALID]: \"username_invalid\",\n [AuthErrorCode.AUTH_USERNAME_TAKEN]: \"username_taken\",\n [AuthErrorCode.AUTH_USERNAME_COOLDOWN]: \"username_cooldown\",\n [AuthErrorCode.AUTH_USERNAME_FEATURE_LOCKED]: \"username_feature_locked\",\n [AuthErrorCode.AUTH_USERNAME_RESERVED]: \"username_reserved\",\n [AuthErrorCode.AUTH_INVALID_REQUEST]: \"invalid_request\",\n [AuthErrorCode.AUTH_AUTHENTICATION_REQUIRED]: \"authentication_required\",\n [AuthErrorCode.AUTH_SESSION_KIND_NOT_ALLOWED]: \"session_kind_not_allowed\",\n [AuthErrorCode.AUTH_WALLET_LOGIN_FAILED]: \"wallet_login_failed\",\n [AuthErrorCode.AUTH_RESOURCE_NOT_FOUND]: \"resource_not_found\",\n [AuthErrorCode.AUTH_SUBACCOUNT_ACCESS_DENIED]: \"subaccount_access_denied\",\n [AuthErrorCode.AUTH_API_KEY_ACCESS_DENIED]: \"api_key_access_denied\",\n [AuthErrorCode.AUTH_API_KEY_INVALID_STATUS_TRANSITION]: \"api_key_invalid_status_transition\",\n [AuthErrorCode.AUTH_POLICY_INVALID]: \"policy_invalid\",\n [AuthErrorCode.AUTH_SMART_ACCOUNT_ALREADY_LINKED]: \"smart_account_already_linked\",\n [AuthErrorCode.AUTH_INVITE_ACCESS_DENIED]: \"invite_access_denied\",\n [AuthErrorCode.AUTH_INVITE_INVALID_STATE]: \"invite_invalid_state\",\n [AuthErrorCode.AUTH_MFA_DISABLED]: \"mfa_disabled\",\n [AuthErrorCode.AUTH_MFA_NOT_ENROLLED]: \"mfa_not_enrolled\",\n [AuthErrorCode.AUTH_MFA_SESSION_INVALID]: \"mfa_session_invalid\",\n [AuthErrorCode.AUTH_MFA_CHALLENGE_NOT_FOUND]: \"mfa_challenge_not_found\",\n [AuthErrorCode.AUTH_MFA_CHALLENGE_INVALID]: \"mfa_challenge_invalid\",\n [AuthErrorCode.AUTH_MFA_CHALLENGE_LOCKED]: \"mfa_challenge_locked\",\n [AuthErrorCode.AUTH_MFA_OTP_INVALID]: \"mfa_otp_invalid\",\n [AuthErrorCode.AUTH_MFA_RECOVERY_INVALID]: \"mfa_recovery_invalid\",\n [AuthErrorCode.AUTH_MFA_PASSKEY_NOT_AVAILABLE]: \"mfa_passkey_not_available\",\n [AuthErrorCode.AUTH_MFA_PASSKEY_CREDENTIAL_INVALID]: \"mfa_passkey_credential_invalid\",\n [AuthErrorCode.AUTH_MFA_PASSKEY_VERIFY_FAILED]: \"mfa_passkey_verify_failed\",\n [AuthErrorCode.AUTH_MFA_ENROLLMENT_BINDING_INVALID]: \"mfa_enrollment_binding_invalid\",\n [AuthErrorCode.AUTH_STEP_UP_REQUIRED]: \"step_up_required\",\n [AuthErrorCode.AUTH_STEP_UP_PROOF_UNAVAILABLE]: \"step_up_proof_unavailable\",\n [AuthErrorCode.AUTH_STEP_UP_ALREADY_CLAIMED]: \"step_up_already_claimed\",\n [AuthErrorCode.AUTH_POLICY_IN_USE]: \"policy_in_use\",\n [AuthErrorCode.AUTH_POLICY_LOCKED]: \"policy_locked\",\n [AuthErrorCode.AUTH_POLICY_SCOPE_MISMATCH]: \"policy_scope_mismatch\",\n [AuthErrorCode.AUTH_REVISION_CONFLICT]: \"revision_conflict\",\n [AuthErrorCode.AUTH_MFA_ELEVATION_REQUIRED]: \"mfa_elevation_required\",\n [AuthErrorCode.AUTH_MFA_LAST_FACTOR_REQUIRED]: \"mfa_last_factor_required\",\n [AuthErrorCode.AUTH_INTERNAL_ERROR]: \"internal_error\",\n [AuthErrorCode.AUTH_TERMS_NOT_ACCEPTED]: \"terms_not_accepted\",\n [AuthErrorCode.AUTH_SOCIAL_VERIFICATION_EXPIRED]: \"social_verification_expired\",\n [AuthErrorCode.AUTH_SOCIAL_VERIFICATION_INVALID_STATE]: \"social_verification_invalid_state\",\n [AuthErrorCode.AUTH_SUBACCOUNT_CHALLENGE_INVALID]: \"subaccount_challenge_invalid\",\n [AuthErrorCode.AUTH_SOCIAL_ACCOUNT_ALREADY_LINKED]: \"social_account_already_linked\",\n } satisfies Partial<ProtoToOutput<AuthErrorCode, SocialVerificationErrorCodeValue>>,\n} as const;\n"],"mappings":";;;AAIA,MAAa,yBAAyB;CAAC;CAAW;CAAW;AAAU;AAGvE,MAAa,oCAAoC;CAAC;CAAW;CAAW;AAAI;AAG5E,MAAa,oCAAoC;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAGA,MAAa,sBAAsB;CAC/B,cAAc;EACV,SAAA;EACA,SAAA;EACA,UAAA;CACJ;CACA,eAAe;GACkC,IAAA;GACb,IAAA;GACA,IAAA;GACC,IAAA;CACrC;AACJ;AAEA,MAAa,gCAAgC;CACzC,cAAc;EACV,SAAA;EACA,SAAA;EACA,IAAA;CACJ;CACA,eAAe;GAC0C,IAAA;GACJ,IAAA;GACA,IAAA;GACL,IAAA;CAChD;AACJ;AAEA,MAAa,gCAAgC,EACzC,eAAe;EAC0C,IAAA;EACQ,IAAA;EACb,IAAA;EACK,IAAA;EACH,IAAA;EACF,IAAA;EACC,IAAA;EACE,IAAA;EACY,IAAA;AACnE,EACJ;AAEA,MAAa,wCAAwC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAKA,MAAa,mCAAmC,EAC5C,eAAe;EACuB,IAAA;EACK,IAAA;EACF,IAAA;EACG,IAAA;EACM,IAAA;EACN,IAAA;EACF,IAAA;EACQ,IAAA;EACC,IAAA;EACL,IAAA;EACD,KAAA;EACM,KAAA;EACH,KAAA;EACY,KAAA;EACnB,KAAA;EACc,KAAA;EACR,KAAA;EACA,KAAA;EACR,KAAA;EACI,KAAA;EACG,KAAA;EACI,KAAA;EACF,KAAA;EACD,KAAA;EACL,KAAA;EACK,KAAA;EACK,KAAA;EACK,KAAA;EACL,KAAA;EACK,KAAA;EACd,KAAA;EACS,KAAA;EACF,KAAA;EACV,KAAA;EACA,KAAA;EACQ,KAAA;EACJ,KAAA;EACK,KAAA;EACE,KAAA;EACV,KAAA;EACI,KAAA;EACS,KAAA;EACM,KAAA;EACL,KAAA;EACC,KAAA;AACxD,EACJ"}
1
+ {"version":3,"file":"social-verification.codecs.js","names":[],"sources":["../../../src/services/social-verification/social-verification.codecs.ts"],"sourcesContent":["import { AuthErrorCode } from \"../../gen/auth/v1/auth_pb.js\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const SOCIAL_PROVIDER_VALUES = [\"twitter\", \"discord\", \"telegram\"] as const;\nexport type SocialProviderValue = (typeof SOCIAL_PROVIDER_VALUES)[number];\n\nexport const SOCIAL_VERIFICATION_METHOD_VALUES = [\"profile\", \"channel\", \"dm\"] as const;\nexport type SocialVerificationMethodValue = (typeof SOCIAL_VERIFICATION_METHOD_VALUES)[number];\n\nexport const SOCIAL_VERIFICATION_STATUS_VALUES = [\n \"pending_user_action\",\n \"queued\",\n \"in_progress\",\n \"verified\",\n \"failed\",\n \"expired\",\n \"canceled\",\n \"awaiting_confirmation\",\n] as const;\nexport type SocialVerificationStatusValue = (typeof SOCIAL_VERIFICATION_STATUS_VALUES)[number];\n\nexport const SocialProviderCodec = {\n inputToProto: {\n twitter: Proto.SocialProvider.TWITTER,\n discord: Proto.SocialProvider.DISCORD,\n telegram: Proto.SocialProvider.TELEGRAM,\n } satisfies InputToProto<SocialProviderValue, Proto.SocialProvider>,\n protoToOutput: {\n [Proto.SocialProvider.PROVIDER_UNSPECIFIED]: \"unspecified\",\n [Proto.SocialProvider.TWITTER]: \"twitter\",\n [Proto.SocialProvider.DISCORD]: \"discord\",\n [Proto.SocialProvider.TELEGRAM]: \"telegram\",\n } satisfies ProtoToOutput<Proto.SocialProvider, SocialProviderValue>,\n} as const;\n\nexport const SocialVerificationMethodCodec = {\n inputToProto: {\n profile: Proto.SocialVerificationMethod.METHOD_PROFILE,\n channel: Proto.SocialVerificationMethod.METHOD_CHANNEL,\n dm: Proto.SocialVerificationMethod.METHOD_DM,\n } satisfies InputToProto<SocialVerificationMethodValue, Proto.SocialVerificationMethod>,\n protoToOutput: {\n [Proto.SocialVerificationMethod.METHOD_UNSPECIFIED]: \"unspecified\",\n [Proto.SocialVerificationMethod.METHOD_PROFILE]: \"profile\",\n [Proto.SocialVerificationMethod.METHOD_CHANNEL]: \"channel\",\n [Proto.SocialVerificationMethod.METHOD_DM]: \"dm\",\n } satisfies ProtoToOutput<Proto.SocialVerificationMethod, SocialVerificationMethodValue>,\n} as const;\n\nexport const SocialVerificationStatusCodec = {\n protoToOutput: {\n [Proto.SocialVerificationStatus.STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.SocialVerificationStatus.STATUS_PENDING_USER_ACTION]: \"pending_user_action\",\n [Proto.SocialVerificationStatus.STATUS_QUEUED]: \"queued\",\n [Proto.SocialVerificationStatus.STATUS_IN_PROGRESS]: \"in_progress\",\n [Proto.SocialVerificationStatus.STATUS_VERIFIED]: \"verified\",\n [Proto.SocialVerificationStatus.STATUS_FAILED]: \"failed\",\n [Proto.SocialVerificationStatus.STATUS_EXPIRED]: \"expired\",\n [Proto.SocialVerificationStatus.STATUS_CANCELLED]: \"canceled\",\n [Proto.SocialVerificationStatus.STATUS_AWAITING_CONFIRMATION]: \"awaiting_confirmation\",\n } satisfies ProtoToOutput<Proto.SocialVerificationStatus, SocialVerificationStatusValue>,\n} as const;\n\nexport const SOCIAL_VERIFICATION_ERROR_CODE_VALUES = [\n \"username_invalid\",\n \"username_taken\",\n \"username_cooldown\",\n \"username_feature_locked\",\n \"username_reserved\",\n \"invalid_request\",\n \"authentication_required\",\n \"session_kind_not_allowed\",\n \"wallet_login_failed\",\n \"resource_not_found\",\n \"subaccount_access_denied\",\n \"api_key_access_denied\",\n \"api_key_invalid_status_transition\",\n \"policy_invalid\",\n \"smart_account_already_linked\",\n \"invite_access_denied\",\n \"invite_invalid_state\",\n \"mfa_disabled\",\n \"mfa_not_enrolled\",\n \"mfa_session_invalid\",\n \"mfa_challenge_not_found\",\n \"mfa_challenge_invalid\",\n \"mfa_challenge_locked\",\n \"mfa_otp_invalid\",\n \"mfa_recovery_invalid\",\n \"mfa_passkey_not_available\",\n \"mfa_passkey_credential_invalid\",\n \"mfa_passkey_verify_failed\",\n \"mfa_enrollment_binding_invalid\",\n \"step_up_required\",\n \"step_up_proof_unavailable\",\n \"step_up_already_claimed\",\n \"policy_in_use\",\n \"policy_locked\",\n \"policy_scope_mismatch\",\n \"revision_conflict\",\n \"mfa_elevation_required\",\n \"mfa_last_factor_required\",\n \"internal_error\",\n \"terms_not_accepted\",\n \"social_verification_expired\",\n \"social_verification_invalid_state\",\n \"subaccount_challenge_invalid\",\n \"social_account_already_linked\",\n \"social_account_cooldown\",\n \"social_change_limit_reached\",\n] as const;\nexport type SocialVerificationErrorCodeValue =\n (typeof SOCIAL_VERIFICATION_ERROR_CODE_VALUES)[number];\n\n// Partial: auth codes added upstream decode to \"unspecified\" until mapped here.\nexport const SocialVerificationErrorCodeCodec = {\n protoToOutput: {\n [AuthErrorCode.AUTH_UNSPECIFIED]: \"unspecified\",\n [AuthErrorCode.AUTH_USERNAME_INVALID]: \"username_invalid\",\n [AuthErrorCode.AUTH_USERNAME_TAKEN]: \"username_taken\",\n [AuthErrorCode.AUTH_USERNAME_COOLDOWN]: \"username_cooldown\",\n [AuthErrorCode.AUTH_USERNAME_FEATURE_LOCKED]: \"username_feature_locked\",\n [AuthErrorCode.AUTH_USERNAME_RESERVED]: \"username_reserved\",\n [AuthErrorCode.AUTH_INVALID_REQUEST]: \"invalid_request\",\n [AuthErrorCode.AUTH_AUTHENTICATION_REQUIRED]: \"authentication_required\",\n [AuthErrorCode.AUTH_SESSION_KIND_NOT_ALLOWED]: \"session_kind_not_allowed\",\n [AuthErrorCode.AUTH_WALLET_LOGIN_FAILED]: \"wallet_login_failed\",\n [AuthErrorCode.AUTH_RESOURCE_NOT_FOUND]: \"resource_not_found\",\n [AuthErrorCode.AUTH_SUBACCOUNT_ACCESS_DENIED]: \"subaccount_access_denied\",\n [AuthErrorCode.AUTH_API_KEY_ACCESS_DENIED]: \"api_key_access_denied\",\n [AuthErrorCode.AUTH_API_KEY_INVALID_STATUS_TRANSITION]: \"api_key_invalid_status_transition\",\n [AuthErrorCode.AUTH_POLICY_INVALID]: \"policy_invalid\",\n [AuthErrorCode.AUTH_SMART_ACCOUNT_ALREADY_LINKED]: \"smart_account_already_linked\",\n [AuthErrorCode.AUTH_INVITE_ACCESS_DENIED]: \"invite_access_denied\",\n [AuthErrorCode.AUTH_INVITE_INVALID_STATE]: \"invite_invalid_state\",\n [AuthErrorCode.AUTH_MFA_DISABLED]: \"mfa_disabled\",\n [AuthErrorCode.AUTH_MFA_NOT_ENROLLED]: \"mfa_not_enrolled\",\n [AuthErrorCode.AUTH_MFA_SESSION_INVALID]: \"mfa_session_invalid\",\n [AuthErrorCode.AUTH_MFA_CHALLENGE_NOT_FOUND]: \"mfa_challenge_not_found\",\n [AuthErrorCode.AUTH_MFA_CHALLENGE_INVALID]: \"mfa_challenge_invalid\",\n [AuthErrorCode.AUTH_MFA_CHALLENGE_LOCKED]: \"mfa_challenge_locked\",\n [AuthErrorCode.AUTH_MFA_OTP_INVALID]: \"mfa_otp_invalid\",\n [AuthErrorCode.AUTH_MFA_RECOVERY_INVALID]: \"mfa_recovery_invalid\",\n [AuthErrorCode.AUTH_MFA_PASSKEY_NOT_AVAILABLE]: \"mfa_passkey_not_available\",\n [AuthErrorCode.AUTH_MFA_PASSKEY_CREDENTIAL_INVALID]: \"mfa_passkey_credential_invalid\",\n [AuthErrorCode.AUTH_MFA_PASSKEY_VERIFY_FAILED]: \"mfa_passkey_verify_failed\",\n [AuthErrorCode.AUTH_MFA_ENROLLMENT_BINDING_INVALID]: \"mfa_enrollment_binding_invalid\",\n [AuthErrorCode.AUTH_STEP_UP_REQUIRED]: \"step_up_required\",\n [AuthErrorCode.AUTH_STEP_UP_PROOF_UNAVAILABLE]: \"step_up_proof_unavailable\",\n [AuthErrorCode.AUTH_STEP_UP_ALREADY_CLAIMED]: \"step_up_already_claimed\",\n [AuthErrorCode.AUTH_POLICY_IN_USE]: \"policy_in_use\",\n [AuthErrorCode.AUTH_POLICY_LOCKED]: \"policy_locked\",\n [AuthErrorCode.AUTH_POLICY_SCOPE_MISMATCH]: \"policy_scope_mismatch\",\n [AuthErrorCode.AUTH_REVISION_CONFLICT]: \"revision_conflict\",\n [AuthErrorCode.AUTH_MFA_ELEVATION_REQUIRED]: \"mfa_elevation_required\",\n [AuthErrorCode.AUTH_MFA_LAST_FACTOR_REQUIRED]: \"mfa_last_factor_required\",\n [AuthErrorCode.AUTH_INTERNAL_ERROR]: \"internal_error\",\n [AuthErrorCode.AUTH_TERMS_NOT_ACCEPTED]: \"terms_not_accepted\",\n [AuthErrorCode.AUTH_SOCIAL_VERIFICATION_EXPIRED]: \"social_verification_expired\",\n [AuthErrorCode.AUTH_SOCIAL_VERIFICATION_INVALID_STATE]: \"social_verification_invalid_state\",\n [AuthErrorCode.AUTH_SUBACCOUNT_CHALLENGE_INVALID]: \"subaccount_challenge_invalid\",\n [AuthErrorCode.AUTH_SOCIAL_ACCOUNT_ALREADY_LINKED]: \"social_account_already_linked\",\n [AuthErrorCode.AUTH_SOCIAL_ACCOUNT_COOLDOWN]: \"social_account_cooldown\",\n [AuthErrorCode.AUTH_SOCIAL_CHANGE_LIMIT_REACHED]: \"social_change_limit_reached\",\n } satisfies Partial<ProtoToOutput<AuthErrorCode, SocialVerificationErrorCodeValue>>,\n} as const;\n"],"mappings":";;;AAIA,MAAa,yBAAyB;CAAC;CAAW;CAAW;AAAU;AAGvE,MAAa,oCAAoC;CAAC;CAAW;CAAW;AAAI;AAG5E,MAAa,oCAAoC;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAGA,MAAa,sBAAsB;CAC/B,cAAc;EACV,SAAA;EACA,SAAA;EACA,UAAA;CACJ;CACA,eAAe;GACkC,IAAA;GACb,IAAA;GACA,IAAA;GACC,IAAA;CACrC;AACJ;AAEA,MAAa,gCAAgC;CACzC,cAAc;EACV,SAAA;EACA,SAAA;EACA,IAAA;CACJ;CACA,eAAe;GAC0C,IAAA;GACJ,IAAA;GACA,IAAA;GACL,IAAA;CAChD;AACJ;AAEA,MAAa,gCAAgC,EACzC,eAAe;EAC0C,IAAA;EACQ,IAAA;EACb,IAAA;EACK,IAAA;EACH,IAAA;EACF,IAAA;EACC,IAAA;EACE,IAAA;EACY,IAAA;AACnE,EACJ;AAEA,MAAa,wCAAwC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAKA,MAAa,mCAAmC,EAC5C,eAAe;EACuB,IAAA;EACK,IAAA;EACF,IAAA;EACG,IAAA;EACM,IAAA;EACN,IAAA;EACF,IAAA;EACQ,IAAA;EACC,IAAA;EACL,IAAA;EACD,KAAA;EACM,KAAA;EACH,KAAA;EACY,KAAA;EACnB,KAAA;EACc,KAAA;EACR,KAAA;EACA,KAAA;EACR,KAAA;EACI,KAAA;EACG,KAAA;EACI,KAAA;EACF,KAAA;EACD,KAAA;EACL,KAAA;EACK,KAAA;EACK,KAAA;EACK,KAAA;EACL,KAAA;EACK,KAAA;EACd,KAAA;EACS,KAAA;EACF,KAAA;EACV,KAAA;EACA,KAAA;EACQ,KAAA;EACJ,KAAA;EACK,KAAA;EACE,KAAA;EACV,KAAA;EACI,KAAA;EACS,KAAA;EACM,KAAA;EACL,KAAA;EACC,KAAA;EACN,KAAA;EACI,KAAA;AACtD,EACJ"}
@@ -11,6 +11,13 @@ declare class SocialVerificationService {
11
11
  constructor(transports: AuthApiTransports);
12
12
  /**
13
13
  * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.
14
+ *
15
+ * While an X or Discord account is linked, restarting can replace it, so it needs enrolled MFA
16
+ * and a fresh `stepUpToken`; the current link stays until the new verification succeeds, and
17
+ * the replacement counts as the provider's one change per 30 days. A change within 30 days
18
+ * throws with detail `AUTH_SOCIAL_CHANGE_LIMIT_REACHED` and its `retryAfter`; the new
19
+ * verification itself fails with `social_account_cooldown` or `social_change_limit_reached`
20
+ * and a `retryAfter` when the provider account can't be linked yet.
14
21
  */
15
22
  start(input: StartVerificationInput, options?: PolyesterMutationOptions): Promise<StartVerificationResponse>;
16
23
  /**
@@ -31,9 +38,13 @@ declare class SocialVerificationService {
31
38
  */
32
39
  confirm(input: ConfirmVerificationInput, options?: PolyesterMutationOptions): Promise<GetVerificationResponse>;
33
40
  /**
34
- * Unlinks the Telegram account, or cancels a link in progress, and returns the `canceled`
35
- * verification (absent if none was ever started). Repeating it changes nothing; start a new
36
- * verification to link again.
41
+ * Unlinks the X, Discord or Telegram account, or cancels a link in progress, and returns the
42
+ * `canceled` verification (absent if none was ever started). Repeating it changes nothing;
43
+ * start a new verification to link again. Unlinking a linked X or Discord account needs
44
+ * enrolled MFA and a fresh `stepUpToken`, and counts as the provider's one change per 30 days:
45
+ * a change within 30 days throws with detail `AUTH_SOCIAL_CHANGE_LIMIT_REACHED` and its
46
+ * `retryAfter`. For 30 days after, the provider account can be linked again only to this
47
+ * account.
37
48
  */
38
49
  unlink(input: UnlinkSocialAccountInput, options?: PolyesterMutationOptions): Promise<GetVerificationResponse>;
39
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.ts"],"mappings":";;;;;;;;cA6Ba;;EAGG,YAAA,YAAY;;;;EAOlB,MACF,OAAO,wBACP,UAAU,2BACX,QAAQ;;;;EAYL,UACF,OAAO,EAAE,kBAAkB,4BAC3B,UAAU,2BACX,QAAQ;;;;EAYL,IACF,OAAO,EAAE,kBAAkB,4BAC3B,UAAU,0BACX,QAAQ;;;;;;;;;EAiBL,QACF,OAAO,0BACP,UAAU,2BACX,QAAQ;;;;;;EAcL,OACF,OAAO,0BACP,UAAU,2BACX,QAAQ"}
1
+ {"version":3,"file":"social-verification.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.ts"],"mappings":";;;;;;;;cA6Ba;;EAGG,YAAA,YAAY;;;;;;;;;;;EAclB,MACF,OAAO,wBACP,UAAU,2BACX,QAAQ;;;;EAYL,UACF,OAAO,EAAE,kBAAkB,4BAC3B,UAAU,2BACX,QAAQ;;;;EAYL,IACF,OAAO,EAAE,kBAAkB,4BAC3B,UAAU,0BACX,QAAQ;;;;;;;;;EAiBL,QACF,OAAO,0BACP,UAAU,2BACX,QAAQ;;;;;;;;;;EAkBL,OACF,OAAO,0BACP,UAAU,2BACX,QAAQ"}
@@ -14,6 +14,13 @@ var SocialVerificationService = class {
14
14
  }
15
15
  /**
16
16
  * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.
17
+ *
18
+ * While an X or Discord account is linked, restarting can replace it, so it needs enrolled MFA
19
+ * and a fresh `stepUpToken`; the current link stays until the new verification succeeds, and
20
+ * the replacement counts as the provider's one change per 30 days. A change within 30 days
21
+ * throws with detail `AUTH_SOCIAL_CHANGE_LIMIT_REACHED` and its `retryAfter`; the new
22
+ * verification itself fails with `social_account_cooldown` or `social_change_limit_reached`
23
+ * and a `retryAfter` when the provider account can't be linked yet.
17
24
  */
18
25
  async start(input, options) {
19
26
  const validated = parse(StartVerificationInputSchema, input);
@@ -50,9 +57,13 @@ var SocialVerificationService = class {
50
57
  return parse(GetVerificationResponseSchema, res);
51
58
  }
52
59
  /**
53
- * Unlinks the Telegram account, or cancels a link in progress, and returns the `canceled`
54
- * verification (absent if none was ever started). Repeating it changes nothing; start a new
55
- * verification to link again.
60
+ * Unlinks the X, Discord or Telegram account, or cancels a link in progress, and returns the
61
+ * `canceled` verification (absent if none was ever started). Repeating it changes nothing;
62
+ * start a new verification to link again. Unlinking a linked X or Discord account needs
63
+ * enrolled MFA and a fresh `stepUpToken`, and counts as the provider's one change per 30 days:
64
+ * a change within 30 days throws with detail `AUTH_SOCIAL_CHANGE_LIMIT_REACHED` and its
65
+ * `retryAfter`. For 30 days after, the provider account can be linked again only to this
66
+ * account.
56
67
  */
57
68
  async unlink(input, options) {
58
69
  const validated = parse(UnlinkSocialAccountInputSchema, input);
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.js","names":["#client","Proto.SocialVerificationService"],"sources":["../../../src/services/social-verification/social-verification.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n ConfirmVerificationInputSchema,\n UnlinkSocialAccountInputSchema,\n StartVerificationInputSchema,\n StartVerificationResponseSchema,\n VerificationReadyResponseSchema,\n GetVerificationResponseSchema,\n SocialProviderInputSchema,\n type ConfirmVerificationInput,\n type UnlinkSocialAccountInput,\n type StartVerificationInput,\n type StartVerificationResponse,\n type VerificationReadyResponse,\n type GetVerificationResponse,\n} from \"./social-verification.schemas.js\";\n\n/**\n * Verifies ownership of external social accounts for the authenticated caller.\n */\nexport class SocialVerificationService {\n #client: Client<typeof Proto.SocialVerificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.SocialVerificationService, transports.authApi);\n }\n\n /**\n * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.\n */\n async start(\n input: StartVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<StartVerificationResponse> {\n const validated = parse(StartVerificationInputSchema, input);\n const res = await this.#client.startSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(StartVerificationResponseSchema, res);\n }\n\n /**\n * Queues a provider check after the caller has placed the challenge code according to the selected verification method. Not used for Telegram, which links through `confirm`.\n */\n async markReady(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<VerificationReadyResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.socialVerificationReady(\n validated,\n toConnectCallOptions(options),\n );\n return parse(VerificationReadyResponseSchema, res);\n }\n\n /**\n * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp. API keys need `read-social-verification` and must be scoped to the main account.\n */\n async get(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.getSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Links the Telegram account that sent the challenge code. Pass the `providerUserId` shown\n * while the verification is `awaiting_confirmation`, so the user links exactly the account\n * they were shown. Requires enrolled MFA and a fresh `stepUpToken`; a retried confirmation of\n * an existing link needs no new token. A mismatched ID or no account awaiting confirmation\n * fails with `social_verification_invalid_state`; a Telegram account linked elsewhere fails\n * the verification with `social_account_already_linked`.\n */\n async confirm(\n input: ConfirmVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(ConfirmVerificationInputSchema, input);\n const res = await this.#client.confirmSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Unlinks the Telegram account, or cancels a link in progress, and returns the `canceled`\n * verification (absent if none was ever started). Repeating it changes nothing; start a new\n * verification to link again.\n */\n async unlink(\n input: UnlinkSocialAccountInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(UnlinkSocialAccountInputSchema, input);\n const res = await this.#client.unlinkSocialAccount(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,4BAAb,MAAuC;CACnC;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,6BAAiC,WAAW,OAAO;CACnF;;;;CAKA,MAAM,MACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,8BAA8B,KAAK;EAC3D,MAAM,MAAM,MAAM,KAAKD,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,UACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,IACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,sBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;;;;CAUA,MAAM,QACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,0BAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;CAOA,MAAM,OACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,oBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
1
+ {"version":3,"file":"social-verification.js","names":["#client","Proto.SocialVerificationService"],"sources":["../../../src/services/social-verification/social-verification.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n ConfirmVerificationInputSchema,\n UnlinkSocialAccountInputSchema,\n StartVerificationInputSchema,\n StartVerificationResponseSchema,\n VerificationReadyResponseSchema,\n GetVerificationResponseSchema,\n SocialProviderInputSchema,\n type ConfirmVerificationInput,\n type UnlinkSocialAccountInput,\n type StartVerificationInput,\n type StartVerificationResponse,\n type VerificationReadyResponse,\n type GetVerificationResponse,\n} from \"./social-verification.schemas.js\";\n\n/**\n * Verifies ownership of external social accounts for the authenticated caller.\n */\nexport class SocialVerificationService {\n #client: Client<typeof Proto.SocialVerificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.SocialVerificationService, transports.authApi);\n }\n\n /**\n * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.\n *\n * While an X or Discord account is linked, restarting can replace it, so it needs enrolled MFA\n * and a fresh `stepUpToken`; the current link stays until the new verification succeeds, and\n * the replacement counts as the provider's one change per 30 days. A change within 30 days\n * throws with detail `AUTH_SOCIAL_CHANGE_LIMIT_REACHED` and its `retryAfter`; the new\n * verification itself fails with `social_account_cooldown` or `social_change_limit_reached`\n * and a `retryAfter` when the provider account can't be linked yet.\n */\n async start(\n input: StartVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<StartVerificationResponse> {\n const validated = parse(StartVerificationInputSchema, input);\n const res = await this.#client.startSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(StartVerificationResponseSchema, res);\n }\n\n /**\n * Queues a provider check after the caller has placed the challenge code according to the selected verification method. Not used for Telegram, which links through `confirm`.\n */\n async markReady(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<VerificationReadyResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.socialVerificationReady(\n validated,\n toConnectCallOptions(options),\n );\n return parse(VerificationReadyResponseSchema, res);\n }\n\n /**\n * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp. API keys need `read-social-verification` and must be scoped to the main account.\n */\n async get(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.getSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Links the Telegram account that sent the challenge code. Pass the `providerUserId` shown\n * while the verification is `awaiting_confirmation`, so the user links exactly the account\n * they were shown. Requires enrolled MFA and a fresh `stepUpToken`; a retried confirmation of\n * an existing link needs no new token. A mismatched ID or no account awaiting confirmation\n * fails with `social_verification_invalid_state`; a Telegram account linked elsewhere fails\n * the verification with `social_account_already_linked`.\n */\n async confirm(\n input: ConfirmVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(ConfirmVerificationInputSchema, input);\n const res = await this.#client.confirmSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Unlinks the X, Discord or Telegram account, or cancels a link in progress, and returns the\n * `canceled` verification (absent if none was ever started). Repeating it changes nothing;\n * start a new verification to link again. Unlinking a linked X or Discord account needs\n * enrolled MFA and a fresh `stepUpToken`, and counts as the provider's one change per 30 days:\n * a change within 30 days throws with detail `AUTH_SOCIAL_CHANGE_LIMIT_REACHED` and its\n * `retryAfter`. For 30 days after, the provider account can be linked again only to this\n * account.\n */\n async unlink(\n input: UnlinkSocialAccountInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(UnlinkSocialAccountInputSchema, input);\n const res = await this.#client.unlinkSocialAccount(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,4BAAb,MAAuC;CACnC;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,6BAAiC,WAAW,OAAO;CACnF;;;;;;;;;;;CAYA,MAAM,MACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,8BAA8B,KAAK;EAC3D,MAAM,MAAM,MAAM,KAAKD,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,UACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,IACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,sBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;;;;CAUA,MAAM,QACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,0BAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;;;;;CAWA,MAAM,OACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,oBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
@@ -7,7 +7,7 @@ declare const SocialProviderSchema: v.PicklistSchema<readonly ["twitter", "disco
7
7
  type SocialProvider = v.InferInput<typeof SocialProviderSchema>;
8
8
  declare const SocialVerificationMethodSchema: v.PicklistSchema<readonly ["profile", "channel", "dm"], undefined>;
9
9
  type SocialVerificationMethod = v.InferInput<typeof SocialVerificationMethodSchema>;
10
- declare const SocialVerificationErrorCodeSchema: v.PicklistSchema<readonly ["username_invalid", "username_taken", "username_cooldown", "username_feature_locked", "username_reserved", "invalid_request", "authentication_required", "session_kind_not_allowed", "wallet_login_failed", "resource_not_found", "subaccount_access_denied", "api_key_access_denied", "api_key_invalid_status_transition", "policy_invalid", "smart_account_already_linked", "invite_access_denied", "invite_invalid_state", "mfa_disabled", "mfa_not_enrolled", "mfa_session_invalid", "mfa_challenge_not_found", "mfa_challenge_invalid", "mfa_challenge_locked", "mfa_otp_invalid", "mfa_recovery_invalid", "mfa_passkey_not_available", "mfa_passkey_credential_invalid", "mfa_passkey_verify_failed", "mfa_enrollment_binding_invalid", "step_up_required", "step_up_proof_unavailable", "step_up_already_claimed", "policy_in_use", "policy_locked", "policy_scope_mismatch", "revision_conflict", "mfa_elevation_required", "mfa_last_factor_required", "internal_error", "terms_not_accepted", "social_verification_expired", "social_verification_invalid_state", "subaccount_challenge_invalid", "social_account_already_linked"], undefined>;
10
+ declare const SocialVerificationErrorCodeSchema: v.PicklistSchema<readonly ["username_invalid", "username_taken", "username_cooldown", "username_feature_locked", "username_reserved", "invalid_request", "authentication_required", "session_kind_not_allowed", "wallet_login_failed", "resource_not_found", "subaccount_access_denied", "api_key_access_denied", "api_key_invalid_status_transition", "policy_invalid", "smart_account_already_linked", "invite_access_denied", "invite_invalid_state", "mfa_disabled", "mfa_not_enrolled", "mfa_session_invalid", "mfa_challenge_not_found", "mfa_challenge_invalid", "mfa_challenge_locked", "mfa_otp_invalid", "mfa_recovery_invalid", "mfa_passkey_not_available", "mfa_passkey_credential_invalid", "mfa_passkey_verify_failed", "mfa_enrollment_binding_invalid", "step_up_required", "step_up_proof_unavailable", "step_up_already_claimed", "policy_in_use", "policy_locked", "policy_scope_mismatch", "revision_conflict", "mfa_elevation_required", "mfa_last_factor_required", "internal_error", "terms_not_accepted", "social_verification_expired", "social_verification_invalid_state", "subaccount_challenge_invalid", "social_account_already_linked", "social_account_cooldown", "social_change_limit_reached"], undefined>;
11
11
  type SocialVerificationErrorCode = v.InferOutput<typeof SocialVerificationErrorCodeSchema>;
12
12
  declare const SocialVerificationStatusSchema: v.PicklistSchema<readonly ["pending_user_action", "queued", "in_progress", "verified", "failed", "expired", "canceled", "awaiting_confirmation"], undefined>;
13
13
  type SocialVerificationStatus = v.InferOutput<typeof SocialVerificationStatusSchema>;
@@ -17,7 +17,9 @@ declare const SocialVerificationSchema: v.ObjectSchema<{
17
17
  readonly method: v.PicklistSchema<readonly ["profile", "channel", "dm"], undefined>;
18
18
  readonly handle: v.StringSchema<undefined>;
19
19
  /**
20
- * Provider-side user ID, empty until verified. For Telegram in `awaiting_confirmation`, the
20
+ * Provider-side user ID of the linked account, empty while none is linked. A restarted
21
+ * X or Discord verification keeps the current link, and this value, until it succeeds.
22
+ * For Telegram in `awaiting_confirmation`, the
21
23
  * decimal user ID of the account that sent the code: pass it to `confirm` as is.
22
24
  */
23
25
  readonly providerUserId: v.StringSchema<undefined>;
@@ -43,6 +45,14 @@ declare const SocialVerificationSchema: v.ObjectSchema<{
43
45
  readonly seconds: v.BigintSchema<undefined>;
44
46
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
45
47
  }, undefined>, undefined>;
48
+ /**
49
+ * When a new verification may succeed, after this one failed with
50
+ * `social_account_cooldown` or `social_change_limit_reached`; absent otherwise.
51
+ */
52
+ readonly retryAfter: v.OptionalSchema<v.ObjectSchema<{
53
+ readonly seconds: v.BigintSchema<undefined>;
54
+ readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
55
+ }, undefined>, undefined>;
46
56
  }, undefined>;
47
57
  type SocialVerificationBase = v.InferOutput<typeof SocialVerificationSchema>;
48
58
  type SocialVerification = Omit<SocialVerificationBase, "provider" | "method" | "status"> & {
@@ -137,7 +147,7 @@ declare const ConfirmVerificationInputSchema: v.StrictObjectSchema<{
137
147
  }, undefined>;
138
148
  type ConfirmVerificationInput = v.InferInput<typeof ConfirmVerificationInputSchema>;
139
149
  declare const UnlinkSocialAccountInputSchema: v.StrictObjectSchema<{
140
- readonly provider: v.SchemaWithPipe<readonly [v.LiteralSchema<"telegram", undefined>, v.TransformAction<"telegram", SocialProvider$1>]>;
150
+ readonly provider: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["twitter", "discord", "telegram"], undefined>, v.TransformAction<"telegram" | "twitter" | "discord", SocialProvider$1.TWITTER | SocialProvider$1.DISCORD | SocialProvider$1.TELEGRAM>]>;
141
151
  }, undefined>;
142
152
  type UnlinkSocialAccountInput = v.InferInput<typeof UnlinkSocialAccountInputSchema>;
143
153
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.schemas.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"mappings":";;;;;cAuBa,sBAAoB,EAAA;KACrB,iBAAiB,EAAE,kBAAkB;cAEpC,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,kBAAkB;cAE9C,mCAAiC,EAAA;KAClC,8BAA8B,EAAE,mBAAmB;cAElD,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,mBAAmB;cAkC/C,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsBhC,yBAAyB,EAAE,mBAAmB;KACvC,qBAAqB,KAAK;EAClC,UAAU,YAAY;EACtB,QAAQ,YAAY;EACpB,QAAQ,YAAY;;;;;;;EAOpB,WAAW,YAAY;;cAGd,8BAA4B,EAAA,yBAAA,EAAA,2BAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAmC7B,yBAAyB,EAAE,kBAAkB;cAO5C,2BAAyB,EAAA;;;KAI1B,sBAAsB,EAAE,kBAAkB;cAEzC,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBhC,4BAA4B,EAAE,mBAAmB;cAEhD,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;KAShC,4BAA4B,EAAE,mBAAmB;cAEhD,+BAA6B,EAAA,yBAAA,EAAA;;;;;;;KAS9B,0BAA0B,EAAE,mBAAmB;cAQ9C,gCAA8B,EAAA;;;;;KAS/B,2BAA2B,EAAE,kBAAkB;cAE9C,gCAA8B,EAAA;;;KAI/B,2BAA2B,EAAE,kBAAkB"}
1
+ {"version":3,"file":"social-verification.schemas.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.schemas.ts"],"mappings":";;;;;cAuBa,sBAAoB,EAAA;KACrB,iBAAiB,EAAE,kBAAkB;cAEpC,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,kBAAkB;cAE9C,mCAAiC,EAAA;KAClC,8BAA8B,EAAE,mBAAmB;cAElD,gCAA8B,EAAA;KAC/B,2BAA2B,EAAE,mBAAmB;cAmC/C,0BAAwB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BhC,yBAAyB,EAAE,mBAAmB;KACvC,qBAAqB,KAAK;EAClC,UAAU,YAAY;EACtB,QAAQ,YAAY;EACpB,QAAQ,YAAY;;;;;;;EAOpB,WAAW,YAAY;;cAGd,8BAA4B,EAAA,yBAAA,EAAA,2BAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAmC7B,yBAAyB,EAAE,kBAAkB;cAO5C,2BAAyB,EAAA;;;KAI1B,sBAAsB,EAAE,kBAAkB;cAEzC,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KAgBhC,4BAA4B,EAAE,mBAAmB;cAEhD,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;KAShC,4BAA4B,EAAE,mBAAmB;cAEhD,+BAA6B,EAAA,yBAAA,EAAA;;;;;;;KAS9B,0BAA0B,EAAE,mBAAmB;cAQ9C,gCAA8B,EAAA;;;;;KAS/B,2BAA2B,EAAE,kBAAkB;cAE9C,gCAA8B,EAAA;;;KAI/B,2BAA2B,EAAE,kBAAkB"}