@circle-fin/daa-react-native-sdk 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/DaaReactNativeSdk.podspec +63 -0
  2. package/LICENSE +176 -0
  3. package/README.md +217 -2
  4. package/android/build.gradle +97 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationExceptions.kt +47 -0
  7. package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +121 -0
  8. package/android/src/main/java/com/circle/daa/reactnative/DaaScaExceptions.kt +60 -0
  9. package/android/src/main/java/com/circle/daa/reactnative/DaaScaModule.kt +179 -0
  10. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +73 -0
  11. package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +185 -0
  12. package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +73 -0
  13. package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
  14. package/build/DaaClient.d.ts +57 -0
  15. package/build/DaaClient.js +158 -0
  16. package/build/api/AccountLimitsClient.d.ts +79 -0
  17. package/build/api/AccountLimitsClient.js +142 -0
  18. package/build/api/AccountsClient.d.ts +95 -0
  19. package/build/api/AccountsClient.js +276 -0
  20. package/build/api/AchFiatAccountsClient.d.ts +92 -0
  21. package/build/api/AchFiatAccountsClient.js +142 -0
  22. package/build/api/AuthClient.d.ts +120 -0
  23. package/build/api/AuthClient.js +257 -0
  24. package/build/api/DaaUserClient.d.ts +124 -0
  25. package/build/api/DaaUserClient.js +245 -0
  26. package/build/api/DepositAddressesClient.d.ts +112 -0
  27. package/build/api/DepositAddressesClient.js +222 -0
  28. package/build/api/DepositsClient.d.ts +106 -0
  29. package/build/api/DepositsClient.js +183 -0
  30. package/build/api/FiatAccountsClient.d.ts +43 -0
  31. package/build/api/FiatAccountsClient.js +46 -0
  32. package/build/api/TransactionsClient.d.ts +64 -0
  33. package/build/api/TransactionsClient.js +120 -0
  34. package/build/api/TransfersClient.d.ts +104 -0
  35. package/build/api/TransfersClient.js +321 -0
  36. package/build/api/WireFiatAccountsClient.d.ts +99 -0
  37. package/build/api/WireFiatAccountsClient.js +156 -0
  38. package/build/api/WithdrawalsClient.d.ts +94 -0
  39. package/build/api/WithdrawalsClient.js +305 -0
  40. package/build/api/loginFailure.d.ts +43 -0
  41. package/build/api/loginFailure.js +64 -0
  42. package/build/api/pagination.d.ts +29 -0
  43. package/build/api/pagination.js +50 -0
  44. package/build/api/queryParameters.d.ts +23 -0
  45. package/build/api/queryParameters.js +77 -0
  46. package/build/api/resourceRequest.d.ts +60 -0
  47. package/build/api/resourceRequest.js +79 -0
  48. package/build/api/signedResource.d.ts +77 -0
  49. package/build/api/signedResource.js +168 -0
  50. package/build/auth/RegistrationFlowKey.d.ts +93 -0
  51. package/build/auth/RegistrationFlowKey.js +203 -0
  52. package/build/auth/daaRegistrationNative.d.ts +80 -0
  53. package/build/auth/daaRegistrationNative.js +184 -0
  54. package/build/auth/deviceAuthorization.d.ts +73 -0
  55. package/build/auth/deviceAuthorization.js +243 -0
  56. package/build/auth/ownerGrant.d.ts +29 -0
  57. package/build/auth/ownerGrant.js +90 -0
  58. package/build/auth/prepareReceipt.d.ts +150 -0
  59. package/build/auth/prepareReceipt.js +357 -0
  60. package/build/auth/registrationAuthorization.d.ts +48 -0
  61. package/build/auth/registrationAuthorization.js +243 -0
  62. package/build/auth/registrationCodeVerifier.d.ts +31 -0
  63. package/build/auth/registrationCodeVerifier.js +75 -0
  64. package/build/config.d.ts +79 -0
  65. package/build/config.js +116 -0
  66. package/build/crypto/base64url.d.ts +26 -0
  67. package/build/crypto/base64url.js +87 -0
  68. package/build/crypto/bytes.d.ts +27 -0
  69. package/build/crypto/bytes.js +32 -0
  70. package/build/crypto/es256Jws.d.ts +56 -0
  71. package/build/crypto/es256Jws.js +196 -0
  72. package/build/crypto/jwkThumbprint.d.ts +32 -0
  73. package/build/crypto/jwkThumbprint.js +49 -0
  74. package/build/crypto/random.d.ts +35 -0
  75. package/build/crypto/random.js +106 -0
  76. package/build/crypto/serialization.d.ts +26 -0
  77. package/build/crypto/serialization.js +43 -0
  78. package/build/crypto/sha256.d.ts +18 -0
  79. package/build/crypto/sha256.js +100 -0
  80. package/build/errors.d.ts +190 -0
  81. package/build/errors.js +252 -0
  82. package/build/index.d.ts +61 -0
  83. package/build/index.js +67 -0
  84. package/build/models/Account.d.ts +201 -0
  85. package/build/models/Account.js +147 -0
  86. package/build/models/AccountLimitsUsage.d.ts +169 -0
  87. package/build/models/AccountLimitsUsage.js +86 -0
  88. package/build/models/Ach.d.ts +135 -0
  89. package/build/models/Ach.js +184 -0
  90. package/build/models/AddressObject.d.ts +128 -0
  91. package/build/models/AddressObject.js +141 -0
  92. package/build/models/BusinessPii.d.ts +84 -0
  93. package/build/models/BusinessPii.js +142 -0
  94. package/build/models/CreateAccountRequest.d.ts +74 -0
  95. package/build/models/CreateAccountRequest.js +19 -0
  96. package/build/models/CreateTransferRequest.d.ts +91 -0
  97. package/build/models/CreateTransferRequest.js +19 -0
  98. package/build/models/CreateWithdrawalRequest.d.ts +99 -0
  99. package/build/models/CreateWithdrawalRequest.js +19 -0
  100. package/build/models/DaaUserContext.d.ts +96 -0
  101. package/build/models/DaaUserContext.js +133 -0
  102. package/build/models/Deposit.d.ts +241 -0
  103. package/build/models/Deposit.js +149 -0
  104. package/build/models/DepositSummary.d.ts +91 -0
  105. package/build/models/DepositSummary.js +114 -0
  106. package/build/models/FiatAccount.d.ts +99 -0
  107. package/build/models/FiatAccount.js +151 -0
  108. package/build/models/GenerateAddressRequest.d.ts +67 -0
  109. package/build/models/GenerateAddressRequest.js +68 -0
  110. package/build/models/Money.d.ts +76 -0
  111. package/build/models/Money.js +99 -0
  112. package/build/models/Page.d.ts +33 -0
  113. package/build/models/Page.js +57 -0
  114. package/build/models/PendingDeviceRegistration.d.ts +90 -0
  115. package/build/models/PendingDeviceRegistration.js +180 -0
  116. package/build/models/PreparedSocialLogin.d.ts +155 -0
  117. package/build/models/PreparedSocialLogin.js +235 -0
  118. package/build/models/Transaction.d.ts +187 -0
  119. package/build/models/Transaction.js +134 -0
  120. package/build/models/Transfer.d.ts +335 -0
  121. package/build/models/Transfer.js +240 -0
  122. package/build/models/Wire.d.ts +213 -0
  123. package/build/models/Wire.js +264 -0
  124. package/build/models/Withdrawal.d.ts +201 -0
  125. package/build/models/Withdrawal.js +156 -0
  126. package/build/models/redaction.d.ts +18 -0
  127. package/build/models/redaction.js +23 -0
  128. package/build/sca/ScaClient.d.ts +105 -0
  129. package/build/sca/ScaClient.js +193 -0
  130. package/build/securekey/InMemorySecureKey.d.ts +23 -0
  131. package/build/securekey/InMemorySecureKey.js +127 -0
  132. package/build/securekey/NativeSecureKey.d.ts +24 -0
  133. package/build/securekey/NativeSecureKey.js +178 -0
  134. package/build/securekey/NativeSecureKeyBridge.d.ts +83 -0
  135. package/build/securekey/NativeSecureKeyBridge.js +19 -0
  136. package/build/securekey/SecureKey.d.ts +137 -0
  137. package/build/securekey/SecureKey.js +19 -0
  138. package/build/securekey/alias.d.ts +88 -0
  139. package/build/securekey/alias.js +175 -0
  140. package/build/securekey/ownerAuthKeyResolver.d.ts +56 -0
  141. package/build/securekey/ownerAuthKeyResolver.js +63 -0
  142. package/build/securekey/resolveNativeBridge.d.ts +30 -0
  143. package/build/securekey/resolveNativeBridge.js +120 -0
  144. package/build/testing.d.ts +18 -0
  145. package/build/testing.js +34 -0
  146. package/build/transport/DaaTransport.d.ts +35 -0
  147. package/build/transport/DaaTransport.js +19 -0
  148. package/build/transport/headers.d.ts +30 -0
  149. package/build/transport/headers.js +45 -0
  150. package/build/validation/requestBody.d.ts +27 -0
  151. package/build/validation/requestBody.js +56 -0
  152. package/build/validation/uuid.d.ts +25 -0
  153. package/build/validation/uuid.js +33 -0
  154. package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
  155. package/build/wire/accountLimitsUsagePayload.js +130 -0
  156. package/build/wire/accountPayload.d.ts +36 -0
  157. package/build/wire/accountPayload.js +100 -0
  158. package/build/wire/achPayload.d.ts +24 -0
  159. package/build/wire/achPayload.js +82 -0
  160. package/build/wire/addressObjectPayload.d.ts +44 -0
  161. package/build/wire/addressObjectPayload.js +64 -0
  162. package/build/wire/daaStatusCodes.d.ts +64 -0
  163. package/build/wire/daaStatusCodes.js +69 -0
  164. package/build/wire/dataEnvelope.d.ts +40 -0
  165. package/build/wire/dataEnvelope.js +79 -0
  166. package/build/wire/depositPayload.d.ts +42 -0
  167. package/build/wire/depositPayload.js +159 -0
  168. package/build/wire/deviceContextPayload.d.ts +33 -0
  169. package/build/wire/deviceContextPayload.js +57 -0
  170. package/build/wire/deviceRegistrationResultPayload.d.ts +32 -0
  171. package/build/wire/deviceRegistrationResultPayload.js +128 -0
  172. package/build/wire/errorEnvelope.d.ts +43 -0
  173. package/build/wire/errorEnvelope.js +85 -0
  174. package/build/wire/fiatAccountPayload.d.ts +37 -0
  175. package/build/wire/fiatAccountPayload.js +93 -0
  176. package/build/wire/instant.d.ts +27 -0
  177. package/build/wire/instant.js +91 -0
  178. package/build/wire/jsonNumber.d.ts +30 -0
  179. package/build/wire/jsonNumber.js +34 -0
  180. package/build/wire/moneyPayload.d.ts +30 -0
  181. package/build/wire/moneyPayload.js +56 -0
  182. package/build/wire/paginationLinks.d.ts +28 -0
  183. package/build/wire/paginationLinks.js +167 -0
  184. package/build/wire/payload.d.ts +60 -0
  185. package/build/wire/payload.js +121 -0
  186. package/build/wire/pendingRegistrationPayload.d.ts +32 -0
  187. package/build/wire/pendingRegistrationPayload.js +54 -0
  188. package/build/wire/socialLoginRequestPayload.d.ts +31 -0
  189. package/build/wire/socialLoginRequestPayload.js +72 -0
  190. package/build/wire/transactionPayload.d.ts +31 -0
  191. package/build/wire/transactionPayload.js +126 -0
  192. package/build/wire/transferPayload.d.ts +43 -0
  193. package/build/wire/transferPayload.js +218 -0
  194. package/build/wire/wireEnums.d.ts +22 -0
  195. package/build/wire/wireEnums.js +69 -0
  196. package/build/wire/wirePayload.d.ts +29 -0
  197. package/build/wire/wirePayload.js +138 -0
  198. package/build/wire/withdrawalPayload.d.ts +27 -0
  199. package/build/wire/withdrawalPayload.js +179 -0
  200. package/expo-module.config.json +14 -0
  201. package/ios/DaaRegistrationExceptions.swift +58 -0
  202. package/ios/DaaRegistrationModule.swift +143 -0
  203. package/ios/DaaScaExceptions.swift +96 -0
  204. package/ios/DaaScaModule.swift +125 -0
  205. package/ios/DaaSecureKeyExceptions.swift +77 -0
  206. package/ios/DaaSecureKeyModule.swift +162 -0
  207. package/ios/InstallationIdentityStore.swift +126 -0
  208. package/ios/UnpaddedBase64URL.swift +42 -0
  209. package/package.json +114 -4
  210. package/src/DaaClient.ts +171 -0
  211. package/src/api/AccountLimitsClient.ts +146 -0
  212. package/src/api/AccountsClient.ts +305 -0
  213. package/src/api/AchFiatAccountsClient.ts +147 -0
  214. package/src/api/AuthClient.ts +331 -0
  215. package/src/api/DaaUserClient.ts +270 -0
  216. package/src/api/DepositAddressesClient.ts +239 -0
  217. package/src/api/DepositsClient.ts +208 -0
  218. package/src/api/FiatAccountsClient.ts +50 -0
  219. package/src/api/TransactionsClient.ts +137 -0
  220. package/src/api/TransfersClient.ts +361 -0
  221. package/src/api/WireFiatAccountsClient.ts +172 -0
  222. package/src/api/WithdrawalsClient.ts +339 -0
  223. package/src/api/loginFailure.ts +75 -0
  224. package/src/api/pagination.ts +63 -0
  225. package/src/api/queryParameters.ts +82 -0
  226. package/src/api/resourceRequest.ts +135 -0
  227. package/src/api/signedResource.ts +267 -0
  228. package/src/auth/RegistrationFlowKey.ts +274 -0
  229. package/src/auth/daaRegistrationNative.ts +236 -0
  230. package/src/auth/deviceAuthorization.ts +302 -0
  231. package/src/auth/ownerGrant.ts +102 -0
  232. package/src/auth/prepareReceipt.ts +522 -0
  233. package/src/auth/registrationAuthorization.ts +306 -0
  234. package/src/auth/registrationCodeVerifier.ts +76 -0
  235. package/src/config.ts +156 -0
  236. package/src/crypto/base64url.ts +88 -0
  237. package/src/crypto/bytes.ts +30 -0
  238. package/src/crypto/es256Jws.ts +240 -0
  239. package/src/crypto/jwkThumbprint.ts +65 -0
  240. package/src/crypto/random.ts +113 -0
  241. package/src/crypto/serialization.ts +42 -0
  242. package/src/crypto/sha256.ts +105 -0
  243. package/src/errors.ts +319 -0
  244. package/src/index.ts +223 -0
  245. package/src/models/Account.ts +264 -0
  246. package/src/models/AccountLimitsUsage.ts +192 -0
  247. package/src/models/Ach.ts +269 -0
  248. package/src/models/AddressObject.ts +169 -0
  249. package/src/models/BusinessPii.ts +154 -0
  250. package/src/models/CreateAccountRequest.ts +109 -0
  251. package/src/models/CreateTransferRequest.ts +114 -0
  252. package/src/models/CreateWithdrawalRequest.ts +120 -0
  253. package/src/models/DaaUserContext.ts +172 -0
  254. package/src/models/Deposit.ts +307 -0
  255. package/src/models/DepositSummary.ts +142 -0
  256. package/src/models/FiatAccount.ts +195 -0
  257. package/src/models/GenerateAddressRequest.ts +101 -0
  258. package/src/models/Money.ts +91 -0
  259. package/src/models/Page.ts +48 -0
  260. package/src/models/PendingDeviceRegistration.ts +197 -0
  261. package/src/models/PreparedSocialLogin.ts +287 -0
  262. package/src/models/Transaction.ts +247 -0
  263. package/src/models/Transfer.ts +459 -0
  264. package/src/models/Wire.ts +405 -0
  265. package/src/models/Withdrawal.ts +283 -0
  266. package/src/models/redaction.ts +22 -0
  267. package/src/sca/ScaClient.ts +289 -0
  268. package/src/securekey/InMemorySecureKey.ts +138 -0
  269. package/src/securekey/NativeSecureKey.ts +179 -0
  270. package/src/securekey/NativeSecureKeyBridge.ts +109 -0
  271. package/src/securekey/SecureKey.ts +149 -0
  272. package/src/securekey/alias.ts +204 -0
  273. package/src/securekey/ownerAuthKeyResolver.ts +96 -0
  274. package/src/securekey/resolveNativeBridge.ts +185 -0
  275. package/src/testing.ts +32 -0
  276. package/src/transport/DaaTransport.ts +42 -0
  277. package/src/transport/headers.ts +46 -0
  278. package/src/validation/requestBody.ts +60 -0
  279. package/src/validation/uuid.ts +31 -0
  280. package/src/wire/accountLimitsUsagePayload.ts +182 -0
  281. package/src/wire/accountPayload.ts +108 -0
  282. package/src/wire/achPayload.ts +98 -0
  283. package/src/wire/addressObjectPayload.ts +64 -0
  284. package/src/wire/daaStatusCodes.ts +69 -0
  285. package/src/wire/dataEnvelope.ts +80 -0
  286. package/src/wire/depositPayload.ts +186 -0
  287. package/src/wire/deviceContextPayload.ts +58 -0
  288. package/src/wire/deviceRegistrationResultPayload.ts +153 -0
  289. package/src/wire/errorEnvelope.ts +87 -0
  290. package/src/wire/fiatAccountPayload.ts +112 -0
  291. package/src/wire/instant.ts +93 -0
  292. package/src/wire/jsonNumber.ts +33 -0
  293. package/src/wire/moneyPayload.ts +55 -0
  294. package/src/wire/paginationLinks.ts +204 -0
  295. package/src/wire/payload.ts +146 -0
  296. package/src/wire/pendingRegistrationPayload.ts +75 -0
  297. package/src/wire/socialLoginRequestPayload.ts +89 -0
  298. package/src/wire/transactionPayload.ts +145 -0
  299. package/src/wire/transferPayload.ts +249 -0
  300. package/src/wire/wireEnums.ts +74 -0
  301. package/src/wire/wirePayload.ts +160 -0
  302. package/src/wire/withdrawalPayload.ts +219 -0
  303. package/testing.d.ts +19 -0
  304. package/testing.js +25 -0
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.FiatAccountsClient = void 0;
21
+ const AchFiatAccountsClient_1 = require("./AchFiatAccountsClient");
22
+ const WireFiatAccountsClient_1 = require("./WireFiatAccountsClient");
23
+ /**
24
+ * Reads over both fiat-account rails, as the SDK contract's
25
+ * `FiatAccountsClient`: `{ wires: WireFiatAccountsClient; ach:
26
+ * AchFiatAccountsClient }`.
27
+ *
28
+ * A thin composing wrapper, the same role `DaaUserClient` itself plays one
29
+ * level up: neither rail needs the other's state, and the SDK contract does
30
+ * not expose a rail selector — wire and ACH use distinct rail-specific
31
+ * collection paths — so nothing is shared here beyond the transport
32
+ * both sub-clients are constructed with.
33
+ *
34
+ * Not constructible by a consumer: exported from `index.ts` as a type only,
35
+ * and `WireFiatAccountsClient`/`AchFiatAccountsClient`'s own `#transport`
36
+ * fields make each nominal.
37
+ */
38
+ class FiatAccountsClient {
39
+ /** @internal Constructed only through `createDaaUserClient`. */
40
+ constructor(transport) {
41
+ this.wires = new WireFiatAccountsClient_1.WireFiatAccountsClient(transport);
42
+ this.ach = new AchFiatAccountsClient_1.AchFiatAccountsClient(transport);
43
+ Object.freeze(this);
44
+ }
45
+ }
46
+ exports.FiatAccountsClient = FiatAccountsClient;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import type { Page } from '../models/Page';
19
+ import type { Transaction } from '../models/Transaction';
20
+ import type { DaaTransport } from '../transport/DaaTransport';
21
+ declare const TRANSACTION_TYPES: readonly ["deposit", "withdrawal", "transfer", "fx", "fee", "credit", "other"];
22
+ declare const TRANSACTION_STATUSES: readonly ["pending", "complete", "failed", "returned"];
23
+ export type TransactionListQuery = Readonly<{
24
+ /** Select a backing source explicitly; omitted derives from `accountId` or defaults to omnibus. */
25
+ custodyType?: 'omnibus' | 'segregated' | 'self';
26
+ /** Match activity for this public account id. */
27
+ accountId?: string;
28
+ /** Match activity for one end-user sub-entity. */
29
+ clientEntityId?: string;
30
+ isAttributed?: boolean;
31
+ type?: readonly (typeof TRANSACTION_TYPES)[number][];
32
+ status?: readonly (typeof TRANSACTION_STATUSES)[number][];
33
+ /** ISO 4217 / crypto currency code; not constrained to a known set. */
34
+ currency?: string;
35
+ /** Inclusive RFC 3339 creation-time lower bound. */
36
+ from?: string;
37
+ /** Inclusive RFC 3339 creation-time upper bound. */
38
+ to?: string;
39
+ /** Initial forward keyset cursor. Link-derived navigation remains opaque. */
40
+ pageAfter?: string;
41
+ /** Initial backward keyset cursor. Link-derived navigation remains opaque. */
42
+ pageBefore?: string;
43
+ pageSize?: number;
44
+ }>;
45
+ /**
46
+ * Reads over DAA unified account activity, as the SDK contract's
47
+ * `TransactionsClient`.
48
+ *
49
+ * Only {@link list} exists. There is no by-id read: the API has none, and
50
+ * this client does not invent a `GET .../{id}`. Listing is an **ordinary typed read
51
+ * with no device signature**. {@link list} retains the API's RFC 8288
52
+ * navigation queries as opaque text.
53
+ *
54
+ * Not constructible by a consumer: exported from `index.ts` as a type only,
55
+ * and the `#transport` field makes the type nominal.
56
+ */
57
+ export declare class TransactionsClient {
58
+ #private;
59
+ /** @internal Constructed only through the internal user-client factory. */
60
+ constructor(transport: DaaTransport, publicApiOrigin: string);
61
+ /** List transactions and retain the API's opaque navigation queries unchanged. */
62
+ list(query?: TransactionListQuery): Promise<Page<Transaction>>;
63
+ }
64
+ export {};
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
20
+ if (kind === "m") throw new TypeError("Private method is not writable");
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
22
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
23
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
24
+ };
25
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
26
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
27
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
28
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
+ };
30
+ var _TransactionsClient_transport, _TransactionsClient_publicApiOrigin;
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.TransactionsClient = void 0;
33
+ const errors_1 = require("../errors");
34
+ const transactionPayload_1 = require("../wire/transactionPayload");
35
+ const pagination_1 = require("./pagination");
36
+ const queryParameters_1 = require("./queryParameters");
37
+ /**
38
+ * `GET /v1/accounts/transactions` — the **public** path, exactly as for
39
+ * transfers.
40
+ */
41
+ const TRANSACTION_COLLECTION_PATH = '/v1/accounts/transactions';
42
+ const TRANSACTION_TYPES = Object.freeze([
43
+ 'deposit',
44
+ 'withdrawal',
45
+ 'transfer',
46
+ 'fx',
47
+ 'fee',
48
+ 'credit',
49
+ 'other',
50
+ ]);
51
+ const TRANSACTION_STATUSES = Object.freeze(['pending', 'complete', 'failed', 'returned']);
52
+ /**
53
+ * Reads over DAA unified account activity, as the SDK contract's
54
+ * `TransactionsClient`.
55
+ *
56
+ * Only {@link list} exists. There is no by-id read: the API has none, and
57
+ * this client does not invent a `GET .../{id}`. Listing is an **ordinary typed read
58
+ * with no device signature**. {@link list} retains the API's RFC 8288
59
+ * navigation queries as opaque text.
60
+ *
61
+ * Not constructible by a consumer: exported from `index.ts` as a type only,
62
+ * and the `#transport` field makes the type nominal.
63
+ */
64
+ class TransactionsClient {
65
+ /** @internal Constructed only through the internal user-client factory. */
66
+ constructor(transport, publicApiOrigin) {
67
+ _TransactionsClient_transport.set(this, void 0);
68
+ _TransactionsClient_publicApiOrigin.set(this, void 0);
69
+ __classPrivateFieldSet(this, _TransactionsClient_transport, transport, "f");
70
+ __classPrivateFieldSet(this, _TransactionsClient_publicApiOrigin, publicApiOrigin, "f");
71
+ Object.freeze(this);
72
+ }
73
+ /** List transactions and retain the API's opaque navigation queries unchanged. */
74
+ async list(query) {
75
+ return (0, pagination_1.readPage)({
76
+ transport: __classPrivateFieldGet(this, _TransactionsClient_transport, "f"),
77
+ publicApiOrigin: __classPrivateFieldGet(this, _TransactionsClient_publicApiOrigin, "f"),
78
+ path: TRANSACTION_COLLECTION_PATH,
79
+ query: transactionListQuery(query),
80
+ decode: transactionPayload_1.toTransactions,
81
+ });
82
+ }
83
+ }
84
+ exports.TransactionsClient = TransactionsClient;
85
+ _TransactionsClient_transport = new WeakMap(), _TransactionsClient_publicApiOrigin = new WeakMap();
86
+ function transactionListQuery(query) {
87
+ if (query === undefined)
88
+ return null;
89
+ if (typeof query !== 'object' || query === null || Array.isArray(query)) {
90
+ throw (0, errors_1.contractViolation)('transaction list query must be an object');
91
+ }
92
+ if (query.pageAfter !== undefined && query.pageBefore !== undefined) {
93
+ throw (0, errors_1.contractViolation)('pageAfter and pageBefore cannot be used together');
94
+ }
95
+ const parts = [];
96
+ (0, queryParameters_1.appendEnum)(parts, 'custodyType', query.custodyType, ['omnibus', 'segregated', 'self']);
97
+ (0, queryParameters_1.appendString)(parts, 'accountId', query.accountId);
98
+ (0, queryParameters_1.appendUuid)(parts, 'clientEntityId', query.clientEntityId);
99
+ if (query.isAttributed !== undefined) {
100
+ if (typeof query.isAttributed !== 'boolean') {
101
+ throw (0, errors_1.contractViolation)('isAttributed must be a boolean');
102
+ }
103
+ (0, queryParameters_1.append)(parts, 'isAttributed', String(query.isAttributed));
104
+ }
105
+ (0, queryParameters_1.appendEnums)(parts, 'type', query.type, TRANSACTION_TYPES);
106
+ (0, queryParameters_1.appendEnums)(parts, 'status', query.status, TRANSACTION_STATUSES);
107
+ (0, queryParameters_1.appendString)(parts, 'currency', query.currency);
108
+ (0, queryParameters_1.appendString)(parts, 'from', query.from);
109
+ (0, queryParameters_1.appendString)(parts, 'to', query.to);
110
+ // The service models transaction cursors as UUID transaction ids.
111
+ (0, queryParameters_1.appendUuid)(parts, 'pageAfter', query.pageAfter);
112
+ (0, queryParameters_1.appendUuid)(parts, 'pageBefore', query.pageBefore);
113
+ if (query.pageSize !== undefined) {
114
+ if (!Number.isInteger(query.pageSize) || query.pageSize < 1) {
115
+ throw (0, errors_1.contractViolation)('pageSize must be a positive integer');
116
+ }
117
+ (0, queryParameters_1.append)(parts, 'pageSize', String(query.pageSize));
118
+ }
119
+ return parts.length === 0 ? null : parts.join('&');
120
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import type { CreateTransferRequest } from '../models/CreateTransferRequest';
19
+ import type { Transfer } from '../models/Transfer';
20
+ import type { Page } from '../models/Page';
21
+ import type { DaaTransport } from '../transport/DaaTransport';
22
+ import { type DaaUserSigning } from './signedResource';
23
+ export type TransferListQuery = Readonly<{
24
+ /** Select a backing source explicitly; omitted derives from `accountId` or defaults to omnibus. */
25
+ custodyType?: 'omnibus' | 'segregated' | 'self';
26
+ /** Match transfers where this public account id is either leg. */
27
+ accountId?: string;
28
+ /** Match this source leg id. Leg ids are strings and are not necessarily UUIDs. */
29
+ sourceAccountId?: string;
30
+ /** Match this destination leg id. Leg ids are strings and are not necessarily UUIDs. */
31
+ destinationAccountId?: string;
32
+ /** Match transfers for one end-user sub-entity. */
33
+ clientEntityId?: string;
34
+ sourceType?: 'account' | 'blockchain';
35
+ destinationType?: 'account' | 'blockchain';
36
+ /** Inclusive RFC 3339 creation-time lower bound. */
37
+ from?: string;
38
+ /** Inclusive RFC 3339 creation-time upper bound. */
39
+ to?: string;
40
+ /** Initial forward keyset cursor. Link-derived navigation remains opaque. */
41
+ pageAfter?: string;
42
+ /** Initial backward keyset cursor. Link-derived navigation remains opaque. */
43
+ pageBefore?: string;
44
+ pageSize?: number;
45
+ }>;
46
+ /**
47
+ * Reads over DAA transfers, plus the signed transfer create, as the SDK
48
+ * contract's `TransfersClient`.
49
+ *
50
+ * {@link list} retains the API's RFC 8288 navigation queries as opaque text.
51
+ * {@link create} is an Owner-authorized write: it carries an
52
+ * `X-Device-Authorization` bound to the exact bytes it sends and cannot happen
53
+ * without the registered AuthKey `forUser` supplies.
54
+ *
55
+ * Not constructible by a consumer: exported from `index.ts` as a type only, and
56
+ * the `#transport` field makes the type nominal.
57
+ */
58
+ export declare class TransfersClient {
59
+ #private;
60
+ /** @internal Constructed only through the internal user-client factory. */
61
+ constructor(transport: DaaTransport, publicApiOrigin: string, signing: DaaUserSigning);
62
+ /** List transfers and retain the API's opaque navigation queries unchanged. */
63
+ list(query?: TransferListQuery): Promise<Page<Transfer>>;
64
+ /**
65
+ * Read one transfer.
66
+ *
67
+ * @param transferId The service-assigned UUID. Values that are not
68
+ * UUID-formatted are rejected locally because they cannot resolve to a
69
+ * transfer on the service side.
70
+ * @throws DaaError with `detail.kind === 'contract_violation'` for a rejected
71
+ * `transferId` or a response the SDK cannot read, and `detail.kind === 'api'`
72
+ * for a status other than the documented `200`; `detail.kind === 'transport'`
73
+ * if the consumer's transport throws, with the thrown value as `err.cause`.
74
+ */
75
+ get(transferId: string): Promise<Transfer>;
76
+ /**
77
+ * Create a transfer, authorized by the registered device key.
78
+ *
79
+ * The body is validated, serialized **once**, and that exact byte slice is
80
+ * both hashed into the authorization's `body_sha256` claim and sent as the
81
+ * request entity. Nothing between here and the transport re-serializes it,
82
+ * which is the whole point: a re-encoding that changed so much as a space
83
+ * would produce a signature over bytes the service never receives.
84
+ *
85
+ * Neither the method nor the path is chosen here. `postSignedResource`
86
+ * resolves both from the registry entry for `transfer`, so a signed write
87
+ * cannot be aimed somewhere the operation does not name.
88
+ *
89
+ * @throws DaaError with `detail.kind === 'contract_violation'` for a request
90
+ * the registry schema would reject, for an AuthKey that is not yet
91
+ * registered — the create is refused locally, before anything is signed or
92
+ * sent — for a rejected or replayed authorization (including a key that is
93
+ * no longer active: DAA has no revoked-credential code, so this never
94
+ * throws `device_revoked`), and for a response the SDK cannot read;
95
+ * `idempotency_conflict`, with the request's key, for a `409` with
96
+ * `IDEMPOTENCY_KEY_REUSED` (`420034`): reconcile the original transfer with
97
+ * the same key; do not mint a new key for it;
98
+ * `detail.kind === 'api'` for a status other than the documented `201`; and
99
+ * `detail.kind === 'transport'` if the consumer's transport throws, with the
100
+ * thrown value as `err.cause` and the request's `idempotencyKey` on the
101
+ * detail.
102
+ */
103
+ create(request: CreateTransferRequest): Promise<Transfer>;
104
+ }
@@ -0,0 +1,321 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
4
+ *
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
20
+ if (kind === "m") throw new TypeError("Private method is not writable");
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
22
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
23
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
24
+ };
25
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
26
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
27
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
28
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
+ };
30
+ var _TransfersClient_transport, _TransfersClient_publicApiOrigin, _TransfersClient_signing;
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.TransfersClient = void 0;
33
+ const serialization_1 = require("../crypto/serialization");
34
+ const errors_1 = require("../errors");
35
+ const requestBody_1 = require("../validation/requestBody");
36
+ const uuid_1 = require("../validation/uuid");
37
+ const jsonNumber_1 = require("../wire/jsonNumber");
38
+ const transferPayload_1 = require("../wire/transferPayload");
39
+ const pagination_1 = require("./pagination");
40
+ const queryParameters_1 = require("./queryParameters");
41
+ const resourceRequest_1 = require("./resourceRequest");
42
+ const signedResource_1 = require("./signedResource");
43
+ /**
44
+ * `GET /v1/accounts/transfers/{transferId}` — the **public** path, exactly as
45
+ * for Accounts (`AccountsClient.ts`). The registry's
46
+ * `"canonical_path": "/v1/accounts/transfers"` and the `Location` header of
47
+ * `/v1/accounts/transfers/<id>` on create both use it.
48
+ */
49
+ const TRANSFER_PATH_PREFIX = '/v1/accounts/transfers/';
50
+ const TRANSFER_COLLECTION_PATH = '/v1/accounts/transfers';
51
+ /**
52
+ * The properties the Owner-authorization registry's `transfer` schema names, in
53
+ * the order it names them, at each level of the body.
54
+ *
55
+ * Order matters because these are the bytes that get signed: the body is
56
+ * serialized once from these shapes and that exact slice is hashed into
57
+ * `body_sha256` and put on the wire. Building it here rather than forwarding
58
+ * the caller's object also means the property order does not vary with how the
59
+ * caller happened to write its literal. Every one of these objects is
60
+ * `additionalProperties: false` in the registry, so each level is checked, not
61
+ * just the top.
62
+ */
63
+ const TRANSFER_PROPERTIES = Object.freeze([
64
+ 'idempotencyKey',
65
+ 'source',
66
+ 'destination',
67
+ 'amount',
68
+ 'riskSignals',
69
+ ]);
70
+ const TRANSFER_LOCATION_PROPERTIES = Object.freeze(['type', 'id']);
71
+ const TRANSFER_VERIFIED_BLOCKCHAIN_PROPERTIES = Object.freeze(['type', 'addressId']);
72
+ const TRANSFER_AMOUNT_PROPERTIES = Object.freeze(['amount', 'currency']);
73
+ const TRANSFER_RISK_SIGNAL_PROPERTIES = Object.freeze(['ipAddress', 'sessionId', 'deviceId']);
74
+ /*
75
+ * A transfer id is a UUID, and is checked as one rather than as a generic path
76
+ * segment.
77
+ *
78
+ * The SDK contract types this parameter `transferId: UUID`. That is
79
+ * deliberately unlike `AccountsClient`, whose signature is
80
+ * `accountId: string`, because public account ids are strings, including
81
+ * numeric IDs. The two guards differ on purpose; applying one rule to
82
+ * both would make one of them wrong.
83
+ *
84
+ * A UUID-formatted identifier contains none of the characters — `/`, `%`, `.`, control
85
+ * bytes — that could redirect the request into a sibling route, so this subsumes
86
+ * the path-segment check rather than merely differing from it.
87
+ */
88
+ /**
89
+ * Reads over DAA transfers, plus the signed transfer create, as the SDK
90
+ * contract's `TransfersClient`.
91
+ *
92
+ * {@link list} retains the API's RFC 8288 navigation queries as opaque text.
93
+ * {@link create} is an Owner-authorized write: it carries an
94
+ * `X-Device-Authorization` bound to the exact bytes it sends and cannot happen
95
+ * without the registered AuthKey `forUser` supplies.
96
+ *
97
+ * Not constructible by a consumer: exported from `index.ts` as a type only, and
98
+ * the `#transport` field makes the type nominal.
99
+ */
100
+ class TransfersClient {
101
+ /** @internal Constructed only through the internal user-client factory. */
102
+ constructor(transport, publicApiOrigin, signing) {
103
+ _TransfersClient_transport.set(this, void 0);
104
+ _TransfersClient_publicApiOrigin.set(this, void 0);
105
+ _TransfersClient_signing.set(this, void 0);
106
+ __classPrivateFieldSet(this, _TransfersClient_transport, transport, "f");
107
+ __classPrivateFieldSet(this, _TransfersClient_publicApiOrigin, publicApiOrigin, "f");
108
+ __classPrivateFieldSet(this, _TransfersClient_signing, signing, "f");
109
+ Object.freeze(this);
110
+ }
111
+ /** List transfers and retain the API's opaque navigation queries unchanged. */
112
+ async list(query) {
113
+ return (0, pagination_1.readPage)({
114
+ transport: __classPrivateFieldGet(this, _TransfersClient_transport, "f"),
115
+ publicApiOrigin: __classPrivateFieldGet(this, _TransfersClient_publicApiOrigin, "f"),
116
+ path: TRANSFER_COLLECTION_PATH,
117
+ query: transferListQuery(query),
118
+ decode: transferPayload_1.toTransfers,
119
+ });
120
+ }
121
+ /**
122
+ * Read one transfer.
123
+ *
124
+ * @param transferId The service-assigned UUID. Values that are not
125
+ * UUID-formatted are rejected locally because they cannot resolve to a
126
+ * transfer on the service side.
127
+ * @throws DaaError with `detail.kind === 'contract_violation'` for a rejected
128
+ * `transferId` or a response the SDK cannot read, and `detail.kind === 'api'`
129
+ * for a status other than the documented `200`; `detail.kind === 'transport'`
130
+ * if the consumer's transport throws, with the thrown value as `err.cause`.
131
+ */
132
+ async get(transferId) {
133
+ if (!(0, uuid_1.isUuid)(transferId)) {
134
+ throw (0, errors_1.contractViolation)('transferId must be a UUID');
135
+ }
136
+ return (0, resourceRequest_1.readResource)({
137
+ transport: __classPrivateFieldGet(this, _TransfersClient_transport, "f"),
138
+ path: TRANSFER_PATH_PREFIX + transferId,
139
+ decode: transferPayload_1.toTransfer,
140
+ });
141
+ }
142
+ /**
143
+ * Create a transfer, authorized by the registered device key.
144
+ *
145
+ * The body is validated, serialized **once**, and that exact byte slice is
146
+ * both hashed into the authorization's `body_sha256` claim and sent as the
147
+ * request entity. Nothing between here and the transport re-serializes it,
148
+ * which is the whole point: a re-encoding that changed so much as a space
149
+ * would produce a signature over bytes the service never receives.
150
+ *
151
+ * Neither the method nor the path is chosen here. `postSignedResource`
152
+ * resolves both from the registry entry for `transfer`, so a signed write
153
+ * cannot be aimed somewhere the operation does not name.
154
+ *
155
+ * @throws DaaError with `detail.kind === 'contract_violation'` for a request
156
+ * the registry schema would reject, for an AuthKey that is not yet
157
+ * registered — the create is refused locally, before anything is signed or
158
+ * sent — for a rejected or replayed authorization (including a key that is
159
+ * no longer active: DAA has no revoked-credential code, so this never
160
+ * throws `device_revoked`), and for a response the SDK cannot read;
161
+ * `idempotency_conflict`, with the request's key, for a `409` with
162
+ * `IDEMPOTENCY_KEY_REUSED` (`420034`): reconcile the original transfer with
163
+ * the same key; do not mint a new key for it;
164
+ * `detail.kind === 'api'` for a status other than the documented `201`; and
165
+ * `detail.kind === 'transport'` if the consumer's transport throws, with the
166
+ * thrown value as `err.cause` and the request's `idempotencyKey` on the
167
+ * detail.
168
+ */
169
+ async create(request) {
170
+ const bodyBytes = (0, serialization_1.serializeBody)(createTransferBody(request));
171
+ return (0, signedResource_1.postSignedResource)({
172
+ transport: __classPrivateFieldGet(this, _TransfersClient_transport, "f"),
173
+ operation: 'transfer',
174
+ authKey: await __classPrivateFieldGet(this, _TransfersClient_signing, "f").resolveAuthKey(),
175
+ authKeyId: __classPrivateFieldGet(this, _TransfersClient_signing, "f").authKeyId,
176
+ bodyBytes,
177
+ // The contract documents exactly 201, with a Location header. Another
178
+ // 2xx is an observable API failure rather than a silently accepted
179
+ // variant, the same rule the by-id reads apply to 200.
180
+ expectedStatus: 201,
181
+ decode: transferPayload_1.toTransfer,
182
+ });
183
+ }
184
+ }
185
+ exports.TransfersClient = TransfersClient;
186
+ _TransfersClient_transport = new WeakMap(), _TransfersClient_publicApiOrigin = new WeakMap(), _TransfersClient_signing = new WeakMap();
187
+ /**
188
+ * Project a validated request onto the registry's `transfer` shape.
189
+ *
190
+ * Returned rather than serialized here so the caller can hold the one byte
191
+ * slice this body becomes; see {@link TransfersClient.create}.
192
+ */
193
+ function createTransferBody(request) {
194
+ (0, requestBody_1.requireBodyObject)(request, 'transfer create request');
195
+ (0, requestBody_1.requireKnownProperties)(request, TRANSFER_PROPERTIES, 'transfer create request');
196
+ const { idempotencyKey, source, destination, amount, riskSignals } = request;
197
+ // The registry types this `format: uuid`, and nothing in the transfer
198
+ // contract narrows it to v4 — unlike the account create, whose own contract
199
+ // text says v4. Requiring more here would reject a key DAA accepts.
200
+ if (typeof idempotencyKey !== 'string' || !(0, uuid_1.isUuid)(idempotencyKey)) {
201
+ throw (0, errors_1.contractViolation)('idempotencyKey must be a UUID');
202
+ }
203
+ return {
204
+ idempotencyKey,
205
+ ...(source === undefined ? {} : { source: transferSource(source) }),
206
+ destination: transferDestination(destination),
207
+ amount: transferAmount(amount),
208
+ ...(riskSignals === undefined ? {} : { riskSignals: transferRiskSignals(riskSignals) }),
209
+ };
210
+ }
211
+ function transferSource(source) {
212
+ (0, requestBody_1.requireBodyObject)(source, 'transfer source');
213
+ (0, requestBody_1.requireKnownProperties)(source, TRANSFER_LOCATION_PROPERTIES, 'transfer source');
214
+ const { type, id } = source;
215
+ if (type !== 'account') {
216
+ throw (0, errors_1.contractViolation)('transfer source type must be account');
217
+ }
218
+ if (typeof id !== 'string' || id.length === 0) {
219
+ throw (0, errors_1.contractViolation)('transfer source id must be a non-empty string');
220
+ }
221
+ return { type, id };
222
+ }
223
+ /**
224
+ * Both `oneOf` arms, kept apart by their discriminator.
225
+ *
226
+ * The registry requires a destination to match exactly one arm, and the two are
227
+ * told apart by `type` alone — their required properties are disjoint (`id`
228
+ * against `addressId`) and neither admits additional ones. So an unfamiliar
229
+ * `type` is rejected here rather than guessed at: guessing would mean picking
230
+ * an arm DAA would not have picked, and signing that.
231
+ */
232
+ function transferDestination(destination) {
233
+ (0, requestBody_1.requireBodyObject)(destination, 'transfer destination');
234
+ const { type } = destination;
235
+ if (type === 'account') {
236
+ (0, requestBody_1.requireKnownProperties)(destination, TRANSFER_LOCATION_PROPERTIES, 'transfer destination');
237
+ const { id } = destination;
238
+ if (typeof id !== 'string' || id.length === 0) {
239
+ throw (0, errors_1.contractViolation)('transfer destination id must be a non-empty string');
240
+ }
241
+ return { type, id };
242
+ }
243
+ if (type === 'verified_blockchain') {
244
+ (0, requestBody_1.requireKnownProperties)(destination, TRANSFER_VERIFIED_BLOCKCHAIN_PROPERTIES, 'transfer destination');
245
+ const { addressId } = destination;
246
+ if (typeof addressId !== 'string' || !(0, uuid_1.isUuid)(addressId)) {
247
+ throw (0, errors_1.contractViolation)('transfer destination addressId must be a UUID');
248
+ }
249
+ return { type, addressId };
250
+ }
251
+ throw (0, errors_1.contractViolation)('transfer destination type must be account or verified_blockchain');
252
+ }
253
+ function transferAmount(amount) {
254
+ (0, requestBody_1.requireBodyObject)(amount, 'transfer amount');
255
+ (0, requestBody_1.requireKnownProperties)(amount, TRANSFER_AMOUNT_PROPERTIES, 'transfer amount');
256
+ const { amount: amountValue, currency } = amount;
257
+ // The registry's `decimal` accepts a JSON string or a JSON number and then
258
+ // parses it as an arbitrary-precision decimal, so it would also take forms
259
+ // JSON itself does not write — a bare leading `.`, a trailing `.`, a leading
260
+ // `+`. This narrows to the RFC 8259 number grammar the SDK already requires
261
+ // of a `Money` on the way in (`wire/jsonNumber.ts`), so the same literal
262
+ // means the same thing in both directions and the signed bytes are never
263
+ // ambiguous.
264
+ if (typeof amountValue !== 'string' || !jsonNumber_1.JSON_NUMBER.test(amountValue)) {
265
+ throw (0, errors_1.contractViolation)('transfer amount must be a decimal string, e.g. "10.25"');
266
+ }
267
+ if (typeof currency !== 'string' || currency.length === 0) {
268
+ throw (0, errors_1.contractViolation)('transfer amount currency must be a non-empty string');
269
+ }
270
+ return { amount: amountValue, currency };
271
+ }
272
+ function transferRiskSignals(riskSignals) {
273
+ (0, requestBody_1.requireBodyObject)(riskSignals, 'transfer risk signals');
274
+ (0, requestBody_1.requireKnownProperties)(riskSignals, TRANSFER_RISK_SIGNAL_PROPERTIES, 'transfer risk signals');
275
+ const { ipAddress, sessionId, deviceId } = riskSignals;
276
+ requireOptionalRiskSignal(ipAddress, 'ipAddress');
277
+ requireOptionalRiskSignal(sessionId, 'sessionId');
278
+ requireOptionalRiskSignal(deviceId, 'deviceId');
279
+ // The registry requires none of these, so an object with none of them is a
280
+ // valid `riskSignals` and is sent as the empty object the caller asked for.
281
+ return {
282
+ ...(ipAddress === undefined ? {} : { ipAddress }),
283
+ ...(sessionId === undefined ? {} : { sessionId }),
284
+ ...(deviceId === undefined ? {} : { deviceId }),
285
+ };
286
+ }
287
+ function requireOptionalRiskSignal(value, name) {
288
+ if (value !== undefined && (typeof value !== 'string' || value.length === 0)) {
289
+ throw (0, errors_1.contractViolation)(`transfer risk signal ${name} must be a non-empty string`);
290
+ }
291
+ }
292
+ function transferListQuery(query) {
293
+ if (query === undefined)
294
+ return null;
295
+ if (typeof query !== 'object' || query === null || Array.isArray(query)) {
296
+ throw (0, errors_1.contractViolation)('transfer list query must be an object');
297
+ }
298
+ if (query.pageAfter !== undefined && query.pageBefore !== undefined) {
299
+ throw (0, errors_1.contractViolation)('pageAfter and pageBefore cannot be used together');
300
+ }
301
+ const parts = [];
302
+ (0, queryParameters_1.appendEnum)(parts, 'custodyType', query.custodyType, ['omnibus', 'segregated', 'self']);
303
+ (0, queryParameters_1.appendString)(parts, 'accountId', query.accountId);
304
+ (0, queryParameters_1.appendString)(parts, 'sourceAccountId', query.sourceAccountId);
305
+ (0, queryParameters_1.appendString)(parts, 'destinationAccountId', query.destinationAccountId);
306
+ (0, queryParameters_1.appendUuid)(parts, 'clientEntityId', query.clientEntityId);
307
+ (0, queryParameters_1.appendEnum)(parts, 'sourceType', query.sourceType, ['account', 'blockchain']);
308
+ (0, queryParameters_1.appendEnum)(parts, 'destinationType', query.destinationType, ['account', 'blockchain']);
309
+ (0, queryParameters_1.appendString)(parts, 'from', query.from);
310
+ (0, queryParameters_1.appendString)(parts, 'to', query.to);
311
+ // Unlike account cursors, the service models transfer cursors as UUID transfer ids.
312
+ (0, queryParameters_1.appendUuid)(parts, 'pageAfter', query.pageAfter);
313
+ (0, queryParameters_1.appendUuid)(parts, 'pageBefore', query.pageBefore);
314
+ if (query.pageSize !== undefined) {
315
+ if (!Number.isInteger(query.pageSize) || query.pageSize < 1) {
316
+ throw (0, errors_1.contractViolation)('pageSize must be a positive integer');
317
+ }
318
+ (0, queryParameters_1.append)(parts, 'pageSize', String(query.pageSize));
319
+ }
320
+ return parts.length === 0 ? null : parts.join('&');
321
+ }