@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,126 @@
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.toTransaction = toTransaction;
21
+ exports.toTransactions = toTransactions;
22
+ const Transaction_1 = require("../models/Transaction");
23
+ const moneyPayload_1 = require("./moneyPayload");
24
+ const payload_1 = require("./payload");
25
+ /**
26
+ * Wire payload -> public `Transaction` model, and the required/optional line.
27
+ *
28
+ * Generic object and string readers come from `wire/payload`; shared money
29
+ * decoding comes from `wire/moneyPayload`. Transaction-specific enum and
30
+ * location decoding remains here.
31
+ */
32
+ const TRANSACTION_TYPES = new Map([
33
+ ['deposit', Object.freeze({ kind: 'deposit' })],
34
+ ['withdrawal', Object.freeze({ kind: 'withdrawal' })],
35
+ ['transfer', Object.freeze({ kind: 'transfer' })],
36
+ ['fx', Object.freeze({ kind: 'fx' })],
37
+ ['fee', Object.freeze({ kind: 'fee' })],
38
+ ['credit', Object.freeze({ kind: 'credit' })],
39
+ ['other', Object.freeze({ kind: 'other' })],
40
+ ]);
41
+ const TRANSACTION_STATUSES = new Map([
42
+ ['pending', Object.freeze({ kind: 'pending' })],
43
+ ['complete', Object.freeze({ kind: 'complete' })],
44
+ ['failed', Object.freeze({ kind: 'failed' })],
45
+ ['returned', Object.freeze({ kind: 'returned' })],
46
+ ]);
47
+ function toTransactionType(raw) {
48
+ return TRANSACTION_TYPES.get(raw) ?? (0, payload_1.unrecognized)(raw);
49
+ }
50
+ function toTransactionStatus(raw) {
51
+ return TRANSACTION_STATUSES.get(raw) ?? (0, payload_1.unrecognized)(raw);
52
+ }
53
+ /**
54
+ * Decode one `Location` hierarchy member.
55
+ *
56
+ * The discriminator is the wire `type` field. `account` and `blockchain` are shared with `Transfer`;
57
+ * `wire`/`ach` are transaction-only. Anything else — including
58
+ * `verified_blockchain`, which the service maps away before serializing — is
59
+ * `unrecognized` rather than a thrown error.
60
+ *
61
+ * Fiat `id` is a UUID on the service; it is still read as a string here,
62
+ * the same way every other response id is. Requiring UUID form on the way in
63
+ * would reject a row the service actually sent.
64
+ */
65
+ function toTransactionLocation(value, field) {
66
+ const payload = (0, payload_1.asObject)(value, field);
67
+ const type = (0, payload_1.requiredString)(payload, 'type', `${field}.type`);
68
+ switch (type) {
69
+ case 'account':
70
+ return Object.freeze({
71
+ kind: 'account',
72
+ accountId: (0, payload_1.requiredString)(payload, 'id', `${field}.id`),
73
+ });
74
+ case 'blockchain':
75
+ return new Transaction_1.TransactionBlockchainLocation({
76
+ chain: (0, payload_1.optionalString)(payload, 'chain'),
77
+ address: (0, payload_1.optionalString)(payload, 'address'),
78
+ addressTag: (0, payload_1.optionalString)(payload, 'addressTag'),
79
+ });
80
+ case 'wire':
81
+ case 'ach':
82
+ return Object.freeze({
83
+ kind: type,
84
+ fiatAccountId: (0, payload_1.requiredString)(payload, 'id', `${field}.id`),
85
+ name: (0, payload_1.optionalString)(payload, 'name'),
86
+ });
87
+ default:
88
+ return (0, payload_1.unrecognized)(type);
89
+ }
90
+ }
91
+ function toOptionalTransactionLocation(value, field) {
92
+ if (value === undefined || value === null) {
93
+ return null;
94
+ }
95
+ return toTransactionLocation(value, field);
96
+ }
97
+ /**
98
+ * Map a decoded `Transaction` payload onto the public model.
99
+ *
100
+ * Unknown additional fields are ignored and an unfamiliar present closed-set
101
+ * or location value degrades to `unrecognized`; a missing guaranteed field
102
+ * throws. Guaranteed fields are `id`, `type`, `status`, `amount`, `createDate`,
103
+ * and `updateDate` — see `models/Transaction.ts`. `source` and `destination`
104
+ * decode to `null` when absent.
105
+ *
106
+ * @throws MalformedPayloadError
107
+ */
108
+ function toTransaction(value) {
109
+ const payload = (0, payload_1.asObject)(value, 'transaction');
110
+ return new Transaction_1.Transaction({
111
+ id: (0, payload_1.requiredString)(payload, 'id'),
112
+ type: toTransactionType((0, payload_1.requiredString)(payload, 'type')),
113
+ status: toTransactionStatus((0, payload_1.requiredString)(payload, 'status')),
114
+ amount: (0, moneyPayload_1.requiredMoney)(payload, 'amount'),
115
+ source: toOptionalTransactionLocation(payload['source'], 'source'),
116
+ destination: toOptionalTransactionLocation(payload['destination'], 'destination'),
117
+ createDate: (0, payload_1.requiredString)(payload, 'createDate'),
118
+ updateDate: (0, payload_1.requiredString)(payload, 'updateDate'),
119
+ });
120
+ }
121
+ function toTransactions(value) {
122
+ if (!Array.isArray(value)) {
123
+ throw new payload_1.MalformedPayloadError('transactions');
124
+ }
125
+ return Object.freeze(value.map(toTransaction));
126
+ }
@@ -0,0 +1,43 @@
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 { Transfer } from '../models/Transfer';
19
+ /**
20
+ * Map a decoded `Transfer` payload onto the public model.
21
+ *
22
+ * Unknown *additional* fields are ignored and an unfamiliar *present*
23
+ * closed-set or location value degrades to `unrecognized`; a missing guaranteed
24
+ * field throws. **Guaranteed fields are only `id`, `amount`, and `status`** —
25
+ * the OpenAPI schema's required marking is a hint, not proof (see
26
+ * `models/Transfer.ts`'s file-level note), and `source`/`destination` both have
27
+ * a real service code path to absent (a fiat leg), so they decode to `null`
28
+ * rather than throwing when missing. `fees`, `transactionHash`, `errorCode`,
29
+ * and `policyEvaluation` are documented as present only in some cases and
30
+ * decode to empty/`null` when absent. `createDate` is not marked required at
31
+ * all — the same kind of gap as `Account.description`, which the service can
32
+ * omit — so it is treated as optional here rather than rejecting an
33
+ * otherwise-readable transfer on a guess.
34
+ *
35
+ * `destinationTransactionHash` follows the same "present only when …" pattern
36
+ * as `transactionHash`: it is the CCTP destination-mint hash, present only
37
+ * once the destination leg of a cross-chain transfer has minted, and decodes
38
+ * to `null` when absent.
39
+ *
40
+ * @throws MalformedPayloadError
41
+ */
42
+ export declare function toTransfer(value: unknown): Transfer;
43
+ export declare function toTransfers(value: unknown): readonly Transfer[];
@@ -0,0 +1,218 @@
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.toTransfer = toTransfer;
21
+ exports.toTransfers = toTransfers;
22
+ const Transfer_1 = require("../models/Transfer");
23
+ const moneyPayload_1 = require("./moneyPayload");
24
+ const payload_1 = require("./payload");
25
+ /**
26
+ * Wire payload -> public `Transfer` model, and the required/optional line.
27
+ *
28
+ * Generic object and string readers come from `wire/payload`; shared money
29
+ * decoding comes from `wire/moneyPayload`; transfer-specific fee, enum, and
30
+ * location decoding remains here.
31
+ */
32
+ // ---- Closed-set tables, one per field, mirroring wire/wireEnums.ts's pattern ----
33
+ //
34
+ // These tables remain resource-specific because their public unions do; they use
35
+ // the same `Map` construction as the account tables. An object literal inherits
36
+ // from `Object.prototype`, so
37
+ // `lookup['constructor']` returns a function instead of `undefined`, and a wire
38
+ // value spelled like a prototype member would be "recognised" as something it
39
+ // is not. Pinned by test, same as the account tables.
40
+ const TRANSFER_STATUSES = new Map([
41
+ ['pending', Object.freeze({ kind: 'pending' })],
42
+ ['complete', Object.freeze({ kind: 'complete' })],
43
+ ['failed', Object.freeze({ kind: 'failed' })],
44
+ ]);
45
+ const TRANSFER_ERROR_CODES = new Map([
46
+ ['transfer_failed', Object.freeze({ kind: 'transfer_failed' })],
47
+ ['transfer_denied', Object.freeze({ kind: 'transfer_denied' })],
48
+ ['blockchain_error', Object.freeze({ kind: 'blockchain_error' })],
49
+ ['insufficient_funds', Object.freeze({ kind: 'insufficient_funds' })],
50
+ ['invalid_crypto_address', Object.freeze({ kind: 'invalid_crypto_address' })],
51
+ ]);
52
+ function toTransferStatus(raw) {
53
+ return TRANSFER_STATUSES.get(raw) ?? (0, payload_1.unrecognized)(raw);
54
+ }
55
+ /** `errorCode` is optional (present only when `status = failed`); absent is `null`, not `unrecognized`. */
56
+ function toTransferErrorCode(raw) {
57
+ if (raw === null) {
58
+ return null;
59
+ }
60
+ return TRANSFER_ERROR_CODES.get(raw) ?? (0, payload_1.unrecognized)(raw);
61
+ }
62
+ // ---- Locations ----
63
+ //
64
+ // The discriminator is the wire `type` field shared by every location. A
65
+ // transfer leg is documented as only ever `account` or `blockchain` (`wire` is
66
+ // not valid on a transfer), but the decoder still has to tolerate anything
67
+ // else — a `verified_blockchain`/`wire`/`ach` leaking through, or a kind
68
+ // invented after this SDK shipped — as `unrecognized` rather than a thrown
69
+ // error.
70
+ //
71
+ // `chain` (both legs) and `address` (destination only) are read with
72
+ // `optionalString`, not `requiredString`, even though the OpenAPI schema marks
73
+ // both required. That marking is a hint, not proof: the service sends no
74
+ // `chain` on any blockchain leg whose metadata has not backfilled, and no
75
+ // `address` on a destination verified-blockchain leg in the same state (a plain
76
+ // destination `blockchain` leg falls back to the leg id, so it never actually
77
+ // sends a null address). Since the wire's `type: "blockchain"` cannot
78
+ // distinguish which kind of leg produced it, this decoder has to accept the
79
+ // nullable case both fields actually have.
80
+ function toTransferSourceLocation(value) {
81
+ const payload = (0, payload_1.asObject)(value, 'source');
82
+ const type = (0, payload_1.requiredString)(payload, 'type', 'source.type');
83
+ switch (type) {
84
+ case 'account':
85
+ return Object.freeze({
86
+ kind: 'account',
87
+ accountId: (0, payload_1.requiredString)(payload, 'id', 'source.id'),
88
+ });
89
+ case 'blockchain':
90
+ return Object.freeze({
91
+ kind: 'blockchain',
92
+ // See the note above `toTransferSourceLocation`: nullable, not required.
93
+ chain: (0, payload_1.optionalString)(payload, 'chain'),
94
+ });
95
+ default:
96
+ return (0, payload_1.unrecognized)(type);
97
+ }
98
+ }
99
+ /**
100
+ * `source` itself is optional on `Transfer` (see `models/Transfer.ts`'s class
101
+ * note): a fiat leg or a stray `verified_blockchain` source both map to a
102
+ * service-side `null`, which the service sends as an absent key rather than an
103
+ * explicit JSON `null` — so both are treated as absence here,
104
+ * consistent with every other optional field in this file.
105
+ */
106
+ function toOptionalTransferSourceLocation(value) {
107
+ if (value === undefined || value === null) {
108
+ return null;
109
+ }
110
+ return toTransferSourceLocation(value);
111
+ }
112
+ function toTransferDestinationLocation(value) {
113
+ const payload = (0, payload_1.asObject)(value, 'destination');
114
+ const type = (0, payload_1.requiredString)(payload, 'type', 'destination.type');
115
+ switch (type) {
116
+ case 'account':
117
+ return new Transfer_1.TransferDestinationAccountLocation({
118
+ accountId: (0, payload_1.requiredString)(payload, 'id', 'destination.id'),
119
+ address: (0, payload_1.optionalString)(payload, 'address'),
120
+ addressTag: (0, payload_1.optionalString)(payload, 'addressTag'),
121
+ });
122
+ case 'blockchain':
123
+ return new Transfer_1.TransferDestinationBlockchainLocation({
124
+ // See the note above `toTransferSourceLocation`: nullable, not required.
125
+ chain: (0, payload_1.optionalString)(payload, 'chain'),
126
+ address: (0, payload_1.optionalString)(payload, 'address'),
127
+ addressTag: (0, payload_1.optionalString)(payload, 'addressTag'),
128
+ });
129
+ default:
130
+ return (0, payload_1.unrecognized)(type);
131
+ }
132
+ }
133
+ /** `destination` itself is optional on `Transfer` — see `toOptionalTransferSourceLocation`; same reasoning, a fiat destination leg. */
134
+ function toOptionalTransferDestinationLocation(value) {
135
+ if (value === undefined || value === null) {
136
+ return null;
137
+ }
138
+ return toTransferDestinationLocation(value);
139
+ }
140
+ /**
141
+ * A single fee entry. All three fields are guaranteed on a `Fee` that is
142
+ * present at all (the OpenAPI schema marks `amount`/`currency`/`type` each
143
+ * required) — it is the `fees` array itself that is
144
+ * optional on `Transfer`, not any field within an entry that does appear.
145
+ */
146
+ function toFee(value) {
147
+ const payload = (0, payload_1.asObject)(value, 'fees[]');
148
+ return Object.freeze({
149
+ amount: (0, moneyPayload_1.toMoney)(payload, 'fees[]'),
150
+ type: (0, payload_1.requiredString)(payload, 'type', 'fees[].type'),
151
+ });
152
+ }
153
+ /**
154
+ * `fees` is present only when at least one non-zero fee exists (per the API
155
+ * contract); absent or `null` decodes to an empty list rather
156
+ * than `null`, since "no fees" and "an empty fee list" are the same fact.
157
+ */
158
+ function toFees(payload) {
159
+ const value = payload['fees'];
160
+ if (value === undefined || value === null) {
161
+ return [];
162
+ }
163
+ if (!Array.isArray(value)) {
164
+ throw new payload_1.MalformedPayloadError('fees');
165
+ }
166
+ return value.map(toFee);
167
+ }
168
+ function toPolicyEvaluation(payload) {
169
+ return Object.freeze({ status: (0, payload_1.requiredString)(payload, 'status', 'policyEvaluation.status') });
170
+ }
171
+ /**
172
+ * Map a decoded `Transfer` payload onto the public model.
173
+ *
174
+ * Unknown *additional* fields are ignored and an unfamiliar *present*
175
+ * closed-set or location value degrades to `unrecognized`; a missing guaranteed
176
+ * field throws. **Guaranteed fields are only `id`, `amount`, and `status`** —
177
+ * the OpenAPI schema's required marking is a hint, not proof (see
178
+ * `models/Transfer.ts`'s file-level note), and `source`/`destination` both have
179
+ * a real service code path to absent (a fiat leg), so they decode to `null`
180
+ * rather than throwing when missing. `fees`, `transactionHash`, `errorCode`,
181
+ * and `policyEvaluation` are documented as present only in some cases and
182
+ * decode to empty/`null` when absent. `createDate` is not marked required at
183
+ * all — the same kind of gap as `Account.description`, which the service can
184
+ * omit — so it is treated as optional here rather than rejecting an
185
+ * otherwise-readable transfer on a guess.
186
+ *
187
+ * `destinationTransactionHash` follows the same "present only when …" pattern
188
+ * as `transactionHash`: it is the CCTP destination-mint hash, present only
189
+ * once the destination leg of a cross-chain transfer has minted, and decodes
190
+ * to `null` when absent.
191
+ *
192
+ * @throws MalformedPayloadError
193
+ */
194
+ function toTransfer(value) {
195
+ const payload = (0, payload_1.asObject)(value, 'transfer');
196
+ return new Transfer_1.Transfer({
197
+ id: (0, payload_1.requiredString)(payload, 'id'),
198
+ source: toOptionalTransferSourceLocation(payload['source']),
199
+ destination: toOptionalTransferDestinationLocation(payload['destination']),
200
+ amount: (0, moneyPayload_1.requiredMoney)(payload, 'amount'),
201
+ fees: toFees(payload),
202
+ transactionHash: (0, payload_1.optionalString)(payload, 'transactionHash'),
203
+ destinationTransactionHash: (0, payload_1.optionalString)(payload, 'destinationTransactionHash'),
204
+ status: toTransferStatus((0, payload_1.requiredString)(payload, 'status')),
205
+ errorCode: toTransferErrorCode((0, payload_1.optionalString)(payload, 'errorCode')),
206
+ policyEvaluation: (() => {
207
+ const policyEvaluation = (0, payload_1.optionalObject)(payload, 'policyEvaluation');
208
+ return policyEvaluation === null ? null : toPolicyEvaluation(policyEvaluation);
209
+ })(),
210
+ createDate: (0, payload_1.optionalString)(payload, 'createDate'),
211
+ });
212
+ }
213
+ function toTransfers(value) {
214
+ if (!Array.isArray(value)) {
215
+ throw new payload_1.MalformedPayloadError('transfers');
216
+ }
217
+ return Object.freeze(value.map(toTransfer));
218
+ }
@@ -0,0 +1,22 @@
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 { AccountPurpose, AccountStatus, AccountType, CustodyType } from '../models/Account';
19
+ export declare function toCustodyType(raw: string | null): CustodyType;
20
+ export declare function toAccountPurpose(raw: string | null): AccountPurpose;
21
+ export declare function toAccountStatus(raw: string | null): AccountStatus;
22
+ export declare function toAccountType(raw: string | null): AccountType;
@@ -0,0 +1,69 @@
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.toCustodyType = toCustodyType;
21
+ exports.toAccountPurpose = toAccountPurpose;
22
+ exports.toAccountStatus = toAccountStatus;
23
+ exports.toAccountType = toAccountType;
24
+ const payload_1 = require("./payload");
25
+ // Wire-string to public-type mapping, in one table per type.
26
+ //
27
+ // One table rather than a `switch` per field, so a wire spelling appears in
28
+ // exactly one place and adding a value is one line here plus one arm on the
29
+ // public type. The spellings are lower snake_case and none of them matches the
30
+ // public `kind` for the multi-word cases, so a mapper written from the type
31
+ // instead of the wire would look right and match nothing.
32
+ //
33
+ // A `Map` rather than an object literal, deliberately: an object literal inherits
34
+ // from `Object.prototype`, so `lookup['constructor']` and `lookup['toString']`
35
+ // return functions instead of `undefined` and a service value spelled like an
36
+ // `Object.prototype` member would be "recognised" as something that is not even a
37
+ // custody type. This is a JavaScript hazard with no Kotlin or Swift equivalent,
38
+ // and it is pinned by test.
39
+ const CUSTODY_TYPES = new Map([
40
+ ['omnibus', Object.freeze({ kind: 'omnibus' })],
41
+ ['segregated', Object.freeze({ kind: 'segregated' })],
42
+ ['self', Object.freeze({ kind: 'self' })],
43
+ ]);
44
+ const ACCOUNT_PURPOSES = new Map([
45
+ ['custody', Object.freeze({ kind: 'custody' })],
46
+ ['payments', Object.freeze({ kind: 'payments' })],
47
+ ]);
48
+ const ACCOUNT_STATUSES = new Map([
49
+ ['active', Object.freeze({ kind: 'active' })],
50
+ ['pending', Object.freeze({ kind: 'pending' })],
51
+ ['rejected', Object.freeze({ kind: 'rejected' })],
52
+ ['archived', Object.freeze({ kind: 'archived' })],
53
+ ]);
54
+ const ACCOUNT_TYPES = new Map([
55
+ ['first_party', Object.freeze({ kind: 'first_party' })],
56
+ ['third_party', Object.freeze({ kind: 'third_party' })],
57
+ ]);
58
+ function toCustodyType(raw) {
59
+ return (raw === null ? undefined : CUSTODY_TYPES.get(raw)) ?? (0, payload_1.unrecognized)(raw);
60
+ }
61
+ function toAccountPurpose(raw) {
62
+ return (raw === null ? undefined : ACCOUNT_PURPOSES.get(raw)) ?? (0, payload_1.unrecognized)(raw);
63
+ }
64
+ function toAccountStatus(raw) {
65
+ return (raw === null ? undefined : ACCOUNT_STATUSES.get(raw)) ?? (0, payload_1.unrecognized)(raw);
66
+ }
67
+ function toAccountType(raw) {
68
+ return (raw === null ? undefined : ACCOUNT_TYPES.get(raw)) ?? (0, payload_1.unrecognized)(raw);
69
+ }
@@ -0,0 +1,29 @@
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 { Wire, WireInstruction, WireSummary } from '../models/Wire';
19
+ /** Decode one `WireSummary` (`GET /v1/banks/wires` collection entry). */
20
+ export declare function toWireSummary(value: unknown): WireSummary;
21
+ /** Decode the wire collection's unpaginated `data` array. */
22
+ export declare function toWireSummaries(value: unknown): readonly WireSummary[];
23
+ /** Decode one `Wire` (`GET /v1/banks/wires/{id}`). */
24
+ export declare function toWire(value: unknown): Wire;
25
+ /**
26
+ * Decode a `WireInstruction` (`GET /v1/banks/wires/{id}/instructions`). Every
27
+ * field is optional in the service's own schema.
28
+ */
29
+ export declare function toWireInstruction(value: unknown): WireInstruction;
@@ -0,0 +1,138 @@
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.toWireSummary = toWireSummary;
21
+ exports.toWireSummaries = toWireSummaries;
22
+ exports.toWire = toWire;
23
+ exports.toWireInstruction = toWireInstruction;
24
+ const Wire_1 = require("../models/Wire");
25
+ const fiatAccountPayload_1 = require("./fiatAccountPayload");
26
+ const payload_1 = require("./payload");
27
+ function toWireInstructionBeneficiary(payload) {
28
+ return Object.freeze({
29
+ name: (0, payload_1.optionalString)(payload, 'name', 'beneficiary.name'),
30
+ address1: (0, payload_1.optionalString)(payload, 'address1', 'beneficiary.address1'),
31
+ address2: (0, payload_1.optionalString)(payload, 'address2', 'beneficiary.address2'),
32
+ });
33
+ }
34
+ function toWireInstructionBeneficiaryBank(payload) {
35
+ return new Wire_1.WireInstructionBeneficiaryBank({
36
+ name: (0, payload_1.optionalString)(payload, 'name', 'beneficiaryBank.name'),
37
+ swiftCode: (0, payload_1.optionalString)(payload, 'swiftCode', 'beneficiaryBank.swiftCode'),
38
+ routingNumber: (0, payload_1.optionalString)(payload, 'routingNumber', 'beneficiaryBank.routingNumber'),
39
+ accountNumber: (0, payload_1.optionalString)(payload, 'accountNumber', 'beneficiaryBank.accountNumber'),
40
+ currency: (0, payload_1.optionalString)(payload, 'currency', 'beneficiaryBank.currency'),
41
+ address: (0, payload_1.optionalString)(payload, 'address', 'beneficiaryBank.address'),
42
+ city: (0, payload_1.optionalString)(payload, 'city', 'beneficiaryBank.city'),
43
+ postalCode: (0, payload_1.optionalString)(payload, 'postalCode', 'beneficiaryBank.postalCode'),
44
+ country: (0, payload_1.optionalString)(payload, 'country', 'beneficiaryBank.country'),
45
+ });
46
+ }
47
+ /**
48
+ * A `transferTypesInfo` entry the service does not describe is ignored rather
49
+ * than rejected — the SDK does not act on this field, only relays it, and a
50
+ * relayed field gets that tolerance throughout.
51
+ */
52
+ function toTransferTypeInfo(value, label) {
53
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
54
+ return null;
55
+ }
56
+ const payload = value;
57
+ const currencies = payload.currencies;
58
+ if (!Array.isArray(currencies) || !currencies.every((entry) => typeof entry === 'string')) {
59
+ throw new payload_1.MalformedPayloadError(`${label}.currencies`);
60
+ }
61
+ return Object.freeze({ currencies: Object.freeze(currencies.slice()) });
62
+ }
63
+ function toTransferTypesInfo(payload) {
64
+ const value = payload.transferTypesInfo;
65
+ if (value === undefined || value === null) {
66
+ return null;
67
+ }
68
+ if (typeof value !== 'object' || Array.isArray(value)) {
69
+ throw new payload_1.MalformedPayloadError('transferTypesInfo');
70
+ }
71
+ const result = Object.create(null);
72
+ for (const [key, entry] of Object.entries(value)) {
73
+ const info = toTransferTypeInfo(entry, `transferTypesInfo.${key}`);
74
+ if (info !== null) {
75
+ result[key] = info;
76
+ }
77
+ }
78
+ return Object.freeze(result);
79
+ }
80
+ /** Decode one `WireSummary` (`GET /v1/banks/wires` collection entry). */
81
+ function toWireSummary(value) {
82
+ const payload = (0, payload_1.asObject)(value, 'wire');
83
+ return new Wire_1.WireSummary({
84
+ id: (0, payload_1.requiredString)(payload, 'id'),
85
+ type: (0, payload_1.optionalString)(payload, 'type'),
86
+ status: (0, fiatAccountPayload_1.toFiatAccountStatus)((0, payload_1.requiredString)(payload, 'status')),
87
+ description: (0, payload_1.requiredString)(payload, 'description'),
88
+ trackingRef: (0, payload_1.requiredString)(payload, 'trackingRef'),
89
+ fingerprint: (0, payload_1.requiredString)(payload, 'fingerprint'),
90
+ billingDetails: (0, fiatAccountPayload_1.requiredBillingDetails)(payload, 'billingDetails'),
91
+ bankAddress: (0, fiatAccountPayload_1.optionalBankAddress)(payload, 'bankAddress'),
92
+ virtualAccountEnabled: (0, fiatAccountPayload_1.optionalBoolean)(payload, 'virtualAccountEnabled'),
93
+ ffcMemo: (0, payload_1.optionalString)(payload, 'ffcMemo'),
94
+ createDate: (0, payload_1.requiredString)(payload, 'createDate'),
95
+ updateDate: (0, payload_1.requiredString)(payload, 'updateDate'),
96
+ });
97
+ }
98
+ /** Decode the wire collection's unpaginated `data` array. */
99
+ function toWireSummaries(value) {
100
+ if (!Array.isArray(value)) {
101
+ throw new payload_1.MalformedPayloadError('wires');
102
+ }
103
+ return Object.freeze(value.map(toWireSummary));
104
+ }
105
+ /** Decode one `Wire` (`GET /v1/banks/wires/{id}`). */
106
+ function toWire(value) {
107
+ const payload = (0, payload_1.asObject)(value, 'wire');
108
+ return new Wire_1.Wire({
109
+ id: (0, payload_1.requiredString)(payload, 'id'),
110
+ type: (0, payload_1.optionalString)(payload, 'type'),
111
+ status: (0, fiatAccountPayload_1.toFiatAccountStatus)((0, payload_1.requiredString)(payload, 'status')),
112
+ description: (0, payload_1.requiredString)(payload, 'description'),
113
+ trackingRef: (0, payload_1.requiredString)(payload, 'trackingRef'),
114
+ fingerprint: (0, payload_1.requiredString)(payload, 'fingerprint'),
115
+ billingDetails: (0, fiatAccountPayload_1.requiredBillingDetails)(payload, 'billingDetails'),
116
+ bankAddress: (0, fiatAccountPayload_1.optionalBankAddress)(payload, 'bankAddress'),
117
+ virtualAccountEnabled: (0, fiatAccountPayload_1.optionalBoolean)(payload, 'virtualAccountEnabled'),
118
+ ffcMemo: (0, payload_1.optionalString)(payload, 'ffcMemo'),
119
+ transferTypesInfo: toTransferTypesInfo(payload),
120
+ createDate: (0, payload_1.requiredString)(payload, 'createDate'),
121
+ updateDate: (0, payload_1.requiredString)(payload, 'updateDate'),
122
+ });
123
+ }
124
+ /**
125
+ * Decode a `WireInstruction` (`GET /v1/banks/wires/{id}/instructions`). Every
126
+ * field is optional in the service's own schema.
127
+ */
128
+ function toWireInstruction(value) {
129
+ const payload = (0, payload_1.asObject)(value, 'wireInstruction');
130
+ const beneficiary = (0, payload_1.optionalObject)(payload, 'beneficiary');
131
+ const beneficiaryBank = (0, payload_1.optionalObject)(payload, 'beneficiaryBank');
132
+ return new Wire_1.WireInstruction({
133
+ trackingRef: (0, payload_1.optionalString)(payload, 'trackingRef'),
134
+ beneficiary: beneficiary === null ? null : toWireInstructionBeneficiary(beneficiary),
135
+ beneficiaryBank: beneficiaryBank === null ? null : toWireInstructionBeneficiaryBank(beneficiaryBank),
136
+ virtualAccountEnabled: (0, fiatAccountPayload_1.optionalBoolean)(payload, 'virtualAccountEnabled'),
137
+ });
138
+ }