@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.
- package/DaaReactNativeSdk.podspec +63 -0
- package/LICENSE +176 -0
- package/README.md +217 -2
- package/android/build.gradle +97 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationExceptions.kt +47 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaRegistrationModule.kt +121 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaExceptions.kt +60 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaScaModule.kt +179 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyExceptions.kt +73 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +185 -0
- package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +73 -0
- package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
- package/build/DaaClient.d.ts +57 -0
- package/build/DaaClient.js +158 -0
- package/build/api/AccountLimitsClient.d.ts +79 -0
- package/build/api/AccountLimitsClient.js +142 -0
- package/build/api/AccountsClient.d.ts +95 -0
- package/build/api/AccountsClient.js +276 -0
- package/build/api/AchFiatAccountsClient.d.ts +92 -0
- package/build/api/AchFiatAccountsClient.js +142 -0
- package/build/api/AuthClient.d.ts +120 -0
- package/build/api/AuthClient.js +257 -0
- package/build/api/DaaUserClient.d.ts +124 -0
- package/build/api/DaaUserClient.js +245 -0
- package/build/api/DepositAddressesClient.d.ts +112 -0
- package/build/api/DepositAddressesClient.js +222 -0
- package/build/api/DepositsClient.d.ts +106 -0
- package/build/api/DepositsClient.js +183 -0
- package/build/api/FiatAccountsClient.d.ts +43 -0
- package/build/api/FiatAccountsClient.js +46 -0
- package/build/api/TransactionsClient.d.ts +64 -0
- package/build/api/TransactionsClient.js +120 -0
- package/build/api/TransfersClient.d.ts +104 -0
- package/build/api/TransfersClient.js +321 -0
- package/build/api/WireFiatAccountsClient.d.ts +99 -0
- package/build/api/WireFiatAccountsClient.js +156 -0
- package/build/api/WithdrawalsClient.d.ts +94 -0
- package/build/api/WithdrawalsClient.js +305 -0
- package/build/api/loginFailure.d.ts +43 -0
- package/build/api/loginFailure.js +64 -0
- package/build/api/pagination.d.ts +29 -0
- package/build/api/pagination.js +50 -0
- package/build/api/queryParameters.d.ts +23 -0
- package/build/api/queryParameters.js +77 -0
- package/build/api/resourceRequest.d.ts +60 -0
- package/build/api/resourceRequest.js +79 -0
- package/build/api/signedResource.d.ts +77 -0
- package/build/api/signedResource.js +168 -0
- package/build/auth/RegistrationFlowKey.d.ts +93 -0
- package/build/auth/RegistrationFlowKey.js +203 -0
- package/build/auth/daaRegistrationNative.d.ts +80 -0
- package/build/auth/daaRegistrationNative.js +184 -0
- package/build/auth/deviceAuthorization.d.ts +73 -0
- package/build/auth/deviceAuthorization.js +243 -0
- package/build/auth/ownerGrant.d.ts +29 -0
- package/build/auth/ownerGrant.js +90 -0
- package/build/auth/prepareReceipt.d.ts +150 -0
- package/build/auth/prepareReceipt.js +357 -0
- package/build/auth/registrationAuthorization.d.ts +48 -0
- package/build/auth/registrationAuthorization.js +243 -0
- package/build/auth/registrationCodeVerifier.d.ts +31 -0
- package/build/auth/registrationCodeVerifier.js +75 -0
- package/build/config.d.ts +79 -0
- package/build/config.js +116 -0
- package/build/crypto/base64url.d.ts +26 -0
- package/build/crypto/base64url.js +87 -0
- package/build/crypto/bytes.d.ts +27 -0
- package/build/crypto/bytes.js +32 -0
- package/build/crypto/es256Jws.d.ts +56 -0
- package/build/crypto/es256Jws.js +196 -0
- package/build/crypto/jwkThumbprint.d.ts +32 -0
- package/build/crypto/jwkThumbprint.js +49 -0
- package/build/crypto/random.d.ts +35 -0
- package/build/crypto/random.js +106 -0
- package/build/crypto/serialization.d.ts +26 -0
- package/build/crypto/serialization.js +43 -0
- package/build/crypto/sha256.d.ts +18 -0
- package/build/crypto/sha256.js +100 -0
- package/build/errors.d.ts +190 -0
- package/build/errors.js +252 -0
- package/build/index.d.ts +61 -0
- package/build/index.js +67 -0
- package/build/models/Account.d.ts +201 -0
- package/build/models/Account.js +147 -0
- package/build/models/AccountLimitsUsage.d.ts +169 -0
- package/build/models/AccountLimitsUsage.js +86 -0
- package/build/models/Ach.d.ts +135 -0
- package/build/models/Ach.js +184 -0
- package/build/models/AddressObject.d.ts +128 -0
- package/build/models/AddressObject.js +141 -0
- package/build/models/BusinessPii.d.ts +84 -0
- package/build/models/BusinessPii.js +142 -0
- package/build/models/CreateAccountRequest.d.ts +74 -0
- package/build/models/CreateAccountRequest.js +19 -0
- package/build/models/CreateTransferRequest.d.ts +91 -0
- package/build/models/CreateTransferRequest.js +19 -0
- package/build/models/CreateWithdrawalRequest.d.ts +99 -0
- package/build/models/CreateWithdrawalRequest.js +19 -0
- package/build/models/DaaUserContext.d.ts +96 -0
- package/build/models/DaaUserContext.js +133 -0
- package/build/models/Deposit.d.ts +241 -0
- package/build/models/Deposit.js +149 -0
- package/build/models/DepositSummary.d.ts +91 -0
- package/build/models/DepositSummary.js +114 -0
- package/build/models/FiatAccount.d.ts +99 -0
- package/build/models/FiatAccount.js +151 -0
- package/build/models/GenerateAddressRequest.d.ts +67 -0
- package/build/models/GenerateAddressRequest.js +68 -0
- package/build/models/Money.d.ts +76 -0
- package/build/models/Money.js +99 -0
- package/build/models/Page.d.ts +33 -0
- package/build/models/Page.js +57 -0
- package/build/models/PendingDeviceRegistration.d.ts +90 -0
- package/build/models/PendingDeviceRegistration.js +180 -0
- package/build/models/PreparedSocialLogin.d.ts +155 -0
- package/build/models/PreparedSocialLogin.js +235 -0
- package/build/models/Transaction.d.ts +187 -0
- package/build/models/Transaction.js +134 -0
- package/build/models/Transfer.d.ts +335 -0
- package/build/models/Transfer.js +240 -0
- package/build/models/Wire.d.ts +213 -0
- package/build/models/Wire.js +264 -0
- package/build/models/Withdrawal.d.ts +201 -0
- package/build/models/Withdrawal.js +156 -0
- package/build/models/redaction.d.ts +18 -0
- package/build/models/redaction.js +23 -0
- package/build/sca/ScaClient.d.ts +105 -0
- package/build/sca/ScaClient.js +193 -0
- package/build/securekey/InMemorySecureKey.d.ts +23 -0
- package/build/securekey/InMemorySecureKey.js +127 -0
- package/build/securekey/NativeSecureKey.d.ts +24 -0
- package/build/securekey/NativeSecureKey.js +178 -0
- package/build/securekey/NativeSecureKeyBridge.d.ts +83 -0
- package/build/securekey/NativeSecureKeyBridge.js +19 -0
- package/build/securekey/SecureKey.d.ts +137 -0
- package/build/securekey/SecureKey.js +19 -0
- package/build/securekey/alias.d.ts +88 -0
- package/build/securekey/alias.js +175 -0
- package/build/securekey/ownerAuthKeyResolver.d.ts +56 -0
- package/build/securekey/ownerAuthKeyResolver.js +63 -0
- package/build/securekey/resolveNativeBridge.d.ts +30 -0
- package/build/securekey/resolveNativeBridge.js +120 -0
- package/build/testing.d.ts +18 -0
- package/build/testing.js +34 -0
- package/build/transport/DaaTransport.d.ts +35 -0
- package/build/transport/DaaTransport.js +19 -0
- package/build/transport/headers.d.ts +30 -0
- package/build/transport/headers.js +45 -0
- package/build/validation/requestBody.d.ts +27 -0
- package/build/validation/requestBody.js +56 -0
- package/build/validation/uuid.d.ts +25 -0
- package/build/validation/uuid.js +33 -0
- package/build/wire/accountLimitsUsagePayload.d.ts +30 -0
- package/build/wire/accountLimitsUsagePayload.js +130 -0
- package/build/wire/accountPayload.d.ts +36 -0
- package/build/wire/accountPayload.js +100 -0
- package/build/wire/achPayload.d.ts +24 -0
- package/build/wire/achPayload.js +82 -0
- package/build/wire/addressObjectPayload.d.ts +44 -0
- package/build/wire/addressObjectPayload.js +64 -0
- package/build/wire/daaStatusCodes.d.ts +64 -0
- package/build/wire/daaStatusCodes.js +69 -0
- package/build/wire/dataEnvelope.d.ts +40 -0
- package/build/wire/dataEnvelope.js +79 -0
- package/build/wire/depositPayload.d.ts +42 -0
- package/build/wire/depositPayload.js +159 -0
- package/build/wire/deviceContextPayload.d.ts +33 -0
- package/build/wire/deviceContextPayload.js +57 -0
- package/build/wire/deviceRegistrationResultPayload.d.ts +32 -0
- package/build/wire/deviceRegistrationResultPayload.js +128 -0
- package/build/wire/errorEnvelope.d.ts +43 -0
- package/build/wire/errorEnvelope.js +85 -0
- package/build/wire/fiatAccountPayload.d.ts +37 -0
- package/build/wire/fiatAccountPayload.js +93 -0
- package/build/wire/instant.d.ts +27 -0
- package/build/wire/instant.js +91 -0
- package/build/wire/jsonNumber.d.ts +30 -0
- package/build/wire/jsonNumber.js +34 -0
- package/build/wire/moneyPayload.d.ts +30 -0
- package/build/wire/moneyPayload.js +56 -0
- package/build/wire/paginationLinks.d.ts +28 -0
- package/build/wire/paginationLinks.js +167 -0
- package/build/wire/payload.d.ts +60 -0
- package/build/wire/payload.js +121 -0
- package/build/wire/pendingRegistrationPayload.d.ts +32 -0
- package/build/wire/pendingRegistrationPayload.js +54 -0
- package/build/wire/socialLoginRequestPayload.d.ts +31 -0
- package/build/wire/socialLoginRequestPayload.js +72 -0
- package/build/wire/transactionPayload.d.ts +31 -0
- package/build/wire/transactionPayload.js +126 -0
- package/build/wire/transferPayload.d.ts +43 -0
- package/build/wire/transferPayload.js +218 -0
- package/build/wire/wireEnums.d.ts +22 -0
- package/build/wire/wireEnums.js +69 -0
- package/build/wire/wirePayload.d.ts +29 -0
- package/build/wire/wirePayload.js +138 -0
- package/build/wire/withdrawalPayload.d.ts +27 -0
- package/build/wire/withdrawalPayload.js +179 -0
- package/expo-module.config.json +14 -0
- package/ios/DaaRegistrationExceptions.swift +58 -0
- package/ios/DaaRegistrationModule.swift +143 -0
- package/ios/DaaScaExceptions.swift +96 -0
- package/ios/DaaScaModule.swift +125 -0
- package/ios/DaaSecureKeyExceptions.swift +77 -0
- package/ios/DaaSecureKeyModule.swift +162 -0
- package/ios/InstallationIdentityStore.swift +126 -0
- package/ios/UnpaddedBase64URL.swift +42 -0
- package/package.json +114 -4
- package/src/DaaClient.ts +171 -0
- package/src/api/AccountLimitsClient.ts +146 -0
- package/src/api/AccountsClient.ts +305 -0
- package/src/api/AchFiatAccountsClient.ts +147 -0
- package/src/api/AuthClient.ts +331 -0
- package/src/api/DaaUserClient.ts +270 -0
- package/src/api/DepositAddressesClient.ts +239 -0
- package/src/api/DepositsClient.ts +208 -0
- package/src/api/FiatAccountsClient.ts +50 -0
- package/src/api/TransactionsClient.ts +137 -0
- package/src/api/TransfersClient.ts +361 -0
- package/src/api/WireFiatAccountsClient.ts +172 -0
- package/src/api/WithdrawalsClient.ts +339 -0
- package/src/api/loginFailure.ts +75 -0
- package/src/api/pagination.ts +63 -0
- package/src/api/queryParameters.ts +82 -0
- package/src/api/resourceRequest.ts +135 -0
- package/src/api/signedResource.ts +267 -0
- package/src/auth/RegistrationFlowKey.ts +274 -0
- package/src/auth/daaRegistrationNative.ts +236 -0
- package/src/auth/deviceAuthorization.ts +302 -0
- package/src/auth/ownerGrant.ts +102 -0
- package/src/auth/prepareReceipt.ts +522 -0
- package/src/auth/registrationAuthorization.ts +306 -0
- package/src/auth/registrationCodeVerifier.ts +76 -0
- package/src/config.ts +156 -0
- package/src/crypto/base64url.ts +88 -0
- package/src/crypto/bytes.ts +30 -0
- package/src/crypto/es256Jws.ts +240 -0
- package/src/crypto/jwkThumbprint.ts +65 -0
- package/src/crypto/random.ts +113 -0
- package/src/crypto/serialization.ts +42 -0
- package/src/crypto/sha256.ts +105 -0
- package/src/errors.ts +319 -0
- package/src/index.ts +223 -0
- package/src/models/Account.ts +264 -0
- package/src/models/AccountLimitsUsage.ts +192 -0
- package/src/models/Ach.ts +269 -0
- package/src/models/AddressObject.ts +169 -0
- package/src/models/BusinessPii.ts +154 -0
- package/src/models/CreateAccountRequest.ts +109 -0
- package/src/models/CreateTransferRequest.ts +114 -0
- package/src/models/CreateWithdrawalRequest.ts +120 -0
- package/src/models/DaaUserContext.ts +172 -0
- package/src/models/Deposit.ts +307 -0
- package/src/models/DepositSummary.ts +142 -0
- package/src/models/FiatAccount.ts +195 -0
- package/src/models/GenerateAddressRequest.ts +101 -0
- package/src/models/Money.ts +91 -0
- package/src/models/Page.ts +48 -0
- package/src/models/PendingDeviceRegistration.ts +197 -0
- package/src/models/PreparedSocialLogin.ts +287 -0
- package/src/models/Transaction.ts +247 -0
- package/src/models/Transfer.ts +459 -0
- package/src/models/Wire.ts +405 -0
- package/src/models/Withdrawal.ts +283 -0
- package/src/models/redaction.ts +22 -0
- package/src/sca/ScaClient.ts +289 -0
- package/src/securekey/InMemorySecureKey.ts +138 -0
- package/src/securekey/NativeSecureKey.ts +179 -0
- package/src/securekey/NativeSecureKeyBridge.ts +109 -0
- package/src/securekey/SecureKey.ts +149 -0
- package/src/securekey/alias.ts +204 -0
- package/src/securekey/ownerAuthKeyResolver.ts +96 -0
- package/src/securekey/resolveNativeBridge.ts +185 -0
- package/src/testing.ts +32 -0
- package/src/transport/DaaTransport.ts +42 -0
- package/src/transport/headers.ts +46 -0
- package/src/validation/requestBody.ts +60 -0
- package/src/validation/uuid.ts +31 -0
- package/src/wire/accountLimitsUsagePayload.ts +182 -0
- package/src/wire/accountPayload.ts +108 -0
- package/src/wire/achPayload.ts +98 -0
- package/src/wire/addressObjectPayload.ts +64 -0
- package/src/wire/daaStatusCodes.ts +69 -0
- package/src/wire/dataEnvelope.ts +80 -0
- package/src/wire/depositPayload.ts +186 -0
- package/src/wire/deviceContextPayload.ts +58 -0
- package/src/wire/deviceRegistrationResultPayload.ts +153 -0
- package/src/wire/errorEnvelope.ts +87 -0
- package/src/wire/fiatAccountPayload.ts +112 -0
- package/src/wire/instant.ts +93 -0
- package/src/wire/jsonNumber.ts +33 -0
- package/src/wire/moneyPayload.ts +55 -0
- package/src/wire/paginationLinks.ts +204 -0
- package/src/wire/payload.ts +146 -0
- package/src/wire/pendingRegistrationPayload.ts +75 -0
- package/src/wire/socialLoginRequestPayload.ts +89 -0
- package/src/wire/transactionPayload.ts +145 -0
- package/src/wire/transferPayload.ts +249 -0
- package/src/wire/wireEnums.ts +74 -0
- package/src/wire/wirePayload.ts +160 -0
- package/src/wire/withdrawalPayload.ts +219 -0
- package/testing.d.ts +19 -0
- package/testing.js +25 -0
|
@@ -0,0 +1,459 @@
|
|
|
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
|
+
|
|
19
|
+
import type { Money } from './Money'
|
|
20
|
+
import { REDACTED } from './redaction'
|
|
21
|
+
|
|
22
|
+
// A DAA transfer's closed-set fields and its polymorphic source/destination legs.
|
|
23
|
+
//
|
|
24
|
+
// Same posture as `Account`'s closed-set fields (see `models/Account.ts`): a
|
|
25
|
+
// discriminated union on `kind` rather than a string-literal union, because a
|
|
26
|
+
// string-literal union has no room for a value the service adds later — decoding
|
|
27
|
+
// into one would either throw (making the whole transfer unreadable because one
|
|
28
|
+
// status or location kind was unfamiliar) or silently widen to `string`, which
|
|
29
|
+
// throws away the closed set the type exists to express. An unfamiliar *present*
|
|
30
|
+
// value degrades to `unrecognized`, carrying the raw string so a caller — or
|
|
31
|
+
// support, reading a bug report — can answer "why did this read as unknown"
|
|
32
|
+
// rather than just "it did".
|
|
33
|
+
//
|
|
34
|
+
// **A general note on how requiredness is decided in this file**: a response
|
|
35
|
+
// field marked required in the service's OpenAPI schema is a hint that it is
|
|
36
|
+
// *usually* present — never proof. The only evidence that settles it is whether
|
|
37
|
+
// a code path in the service can produce the value absent. The service's
|
|
38
|
+
// mapping of transfer legs is that evidence for `source`, `destination`, and
|
|
39
|
+
// the blockchain leg's `chain`/`address` — each is marked required and each has
|
|
40
|
+
// a real path to `null`, documented per-field below. Treating them as required
|
|
41
|
+
// would reject perfectly ordinary transfers (a fiat onramp/offramp leg, or a
|
|
42
|
+
// blockchain leg recorded before its chain/address metadata backfilled) — the
|
|
43
|
+
// same class of defect `Account.description` shows.
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Where a transfer is in its lifecycle (OpenAPI `TransferStatus`, wire values
|
|
47
|
+
* are the enum constant names verbatim).
|
|
48
|
+
*
|
|
49
|
+
* `pending` also covers any asynchronous processing before settlement: the
|
|
50
|
+
* public contract has no intermediate state, so that phase folds into
|
|
51
|
+
* `pending` before this SDK ever sees it.
|
|
52
|
+
*/
|
|
53
|
+
export type TransferStatus =
|
|
54
|
+
| { readonly kind: 'pending' }
|
|
55
|
+
/** Terminal: successfully settled. */
|
|
56
|
+
| { readonly kind: 'complete' }
|
|
57
|
+
/** Terminal: failed or denied — see {@link TransferErrorCode}. */
|
|
58
|
+
| { readonly kind: 'failed' }
|
|
59
|
+
| { readonly kind: 'unrecognized'; readonly rawValue: string | null }
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Why a transfer failed (OpenAPI `TransferErrorCode`), present only when
|
|
63
|
+
* {@link TransferStatus} is `failed`.
|
|
64
|
+
*
|
|
65
|
+
* This is the service's own public subset: internal failure reasons fold into
|
|
66
|
+
* `transfer_failed` before they reach the wire.
|
|
67
|
+
* Still modeled as an open set here rather than trusted to stay exactly five
|
|
68
|
+
* values — the public enum can grow without this SDK's say-so, and a value it has
|
|
69
|
+
* not shipped for must read as `unrecognized`, not fail the transfer.
|
|
70
|
+
*/
|
|
71
|
+
export type TransferErrorCode =
|
|
72
|
+
| { readonly kind: 'transfer_failed' }
|
|
73
|
+
| { readonly kind: 'transfer_denied' }
|
|
74
|
+
| { readonly kind: 'blockchain_error' }
|
|
75
|
+
| { readonly kind: 'insufficient_funds' }
|
|
76
|
+
| { readonly kind: 'invalid_crypto_address' }
|
|
77
|
+
| { readonly kind: 'unrecognized'; readonly rawValue: string | null }
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A transfer's source leg (OpenAPI `TransferSourceLocation`, a `oneOf` of
|
|
81
|
+
* `TransferSourceAccountLocation` and `TransferSourceBlockchainLocation`).
|
|
82
|
+
*
|
|
83
|
+
* Neither source shape ever carries an address: `TransferSourceAccountLocation`
|
|
84
|
+
* has only `id`, and `TransferSourceBlockchainLocation` has only `chain` — a
|
|
85
|
+
* transfer's origin address is not part of the public contract. Both are safe as
|
|
86
|
+
* plain frozen literals, unlike the destination union below, because neither
|
|
87
|
+
* carries a value this SDK must redact.
|
|
88
|
+
*
|
|
89
|
+
* The wire discriminator is the location's shared `type` property, keyed here
|
|
90
|
+
* to `account` / `blockchain` — the only two location types the contract
|
|
91
|
+
* allows for a transfer leg (`verified_blockchain`, `wire`, and `ach` are
|
|
92
|
+
* `Transaction`-only). A transfer that ever carries one of those, or a location
|
|
93
|
+
* kind not yet invented, degrades to `unrecognized` with the raw `type` string
|
|
94
|
+
* rather than failing the whole read — the same forward-compatibility contract as
|
|
95
|
+
* every other closed set here.
|
|
96
|
+
*/
|
|
97
|
+
export type TransferSourceLocation =
|
|
98
|
+
| {
|
|
99
|
+
readonly kind: 'account'
|
|
100
|
+
/** The account id. Named `accountId` here (the wire spells it `id`) so it
|
|
101
|
+
* is not confused with the transfer's own `id` at `transfer.source.id`. */
|
|
102
|
+
readonly accountId: string
|
|
103
|
+
}
|
|
104
|
+
| {
|
|
105
|
+
readonly kind: 'blockchain'
|
|
106
|
+
/**
|
|
107
|
+
* Chain of the on-chain leg, as a plain string rather than a closed set —
|
|
108
|
+
* same reasoning as `Account.blockchain`: new chains ship without an SDK
|
|
109
|
+
* release, and the service's own chain type is the thing that would have
|
|
110
|
+
* to grow, not this union.
|
|
111
|
+
*
|
|
112
|
+
* **Nullable**, despite the OpenAPI schema marking
|
|
113
|
+
* `TransferSourceBlockchainLocation.chain` required: the service builds a
|
|
114
|
+
* blockchain source leg with no chain when the leg was recorded before its
|
|
115
|
+
* blockchain metadata backfilled, and the schema does not prevent it from
|
|
116
|
+
* sending that leg anyway.
|
|
117
|
+
*/
|
|
118
|
+
readonly chain: string | null
|
|
119
|
+
}
|
|
120
|
+
| { readonly kind: 'unrecognized'; readonly rawValue: string | null }
|
|
121
|
+
|
|
122
|
+
/** The redacted shape `JSON.stringify`/`toString` produce for a destination account leg. */
|
|
123
|
+
export type TransferDestinationAccountLocationRendering = {
|
|
124
|
+
readonly kind: 'account'
|
|
125
|
+
readonly accountId: string
|
|
126
|
+
readonly address: string | null
|
|
127
|
+
readonly addressTag: string | null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A transfer destination that is a DAA account (OpenAPI
|
|
132
|
+
* `TransferDestinationAccountLocation`).
|
|
133
|
+
*
|
|
134
|
+
* Unlike the source shape, a destination account leg can carry the on-chain
|
|
135
|
+
* `address`/`addressTag` funds arrived at — present only when this account leg
|
|
136
|
+
* received a crypto deposit. A crypto address is treated as sensitive data, so
|
|
137
|
+
* it is held the same way `Money` holds `amount`: behind a `#` private field
|
|
138
|
+
* and a prototype accessor, with `toJSON`/`toString` reporting only *whether*
|
|
139
|
+
* one is present. The service redacts it from its own logs but still sends it
|
|
140
|
+
* in the JSON body; this SDK redacts the JSON rendering too.
|
|
141
|
+
*/
|
|
142
|
+
export class TransferDestinationAccountLocation {
|
|
143
|
+
readonly kind = 'account' as const
|
|
144
|
+
readonly accountId: string
|
|
145
|
+
readonly #address: string | null
|
|
146
|
+
readonly #addressTag: string | null
|
|
147
|
+
|
|
148
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
149
|
+
constructor(fields: { accountId: string; address: string | null; addressTag: string | null }) {
|
|
150
|
+
this.accountId = fields.accountId
|
|
151
|
+
this.#address = fields.address
|
|
152
|
+
this.#addressTag = fields.addressTag
|
|
153
|
+
Object.freeze(this)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The on-chain address this account leg received a deposit at, or `null` if it did not. */
|
|
157
|
+
get address(): string | null {
|
|
158
|
+
return this.#address
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Secondary on-chain identifier (e.g. a Stellar memo) paired with {@link address}; nullable. */
|
|
162
|
+
get addressTag(): string | null {
|
|
163
|
+
return this.#addressTag
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
toJSON(): TransferDestinationAccountLocationRendering {
|
|
167
|
+
return {
|
|
168
|
+
kind: this.kind,
|
|
169
|
+
accountId: this.accountId,
|
|
170
|
+
address: this.#address === null ? null : REDACTED,
|
|
171
|
+
addressTag: this.#addressTag === null ? null : REDACTED,
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
toString(): string {
|
|
176
|
+
return (
|
|
177
|
+
`TransferDestinationAccountLocation(kind=account, accountId=${this.accountId}, ` +
|
|
178
|
+
`address=${this.#address === null ? 'null' : REDACTED}, ` +
|
|
179
|
+
`addressTag=${this.#addressTag === null ? 'null' : REDACTED})`
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The redacted shape `JSON.stringify`/`toString` produce for a destination blockchain leg. */
|
|
185
|
+
export type TransferDestinationBlockchainLocationRendering = {
|
|
186
|
+
readonly kind: 'blockchain'
|
|
187
|
+
readonly chain: string | null
|
|
188
|
+
readonly address: string | null
|
|
189
|
+
readonly addressTag: string | null
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* A transfer destination that is an on-chain address (OpenAPI
|
|
194
|
+
* `TransferDestinationBlockchainLocation`).
|
|
195
|
+
*
|
|
196
|
+
* **Both `chain` and `address` are nullable here, despite the OpenAPI schema
|
|
197
|
+
* marking both required.** The wire's `type: "blockchain"` comes from two
|
|
198
|
+
* different kinds of leg that this SDK cannot tell apart from the JSON alone:
|
|
199
|
+
* a verified-blockchain leg folds into it, because the public transfer
|
|
200
|
+
* taxonomy has no verified form on a read.
|
|
201
|
+
*
|
|
202
|
+
* - A plain blockchain leg always resolves `address` (the service falls back
|
|
203
|
+
* to the stored leg id when metadata is absent), so that path alone would
|
|
204
|
+
* justify treating it as required.
|
|
205
|
+
* - A folded verified-blockchain leg does **not** fall back — one with no
|
|
206
|
+
* recorded metadata yet genuinely has no address to report.
|
|
207
|
+
* - Both kinds report `chain` only once their blockchain metadata is
|
|
208
|
+
* recorded.
|
|
209
|
+
*
|
|
210
|
+
* Since either path can produce the wire shape this SDK decodes, and one of
|
|
211
|
+
* them can leave `address` absent, `address` has to be modeled as optional —
|
|
212
|
+
* requiring it would reject a real, un-backfilled verified-blockchain
|
|
213
|
+
* destination. Both fields are redacted the same way `Money.amount` is: behind
|
|
214
|
+
* a `#` private field, never an own enumerable property; `chain` is public
|
|
215
|
+
* because it is not sensitive.
|
|
216
|
+
*/
|
|
217
|
+
export class TransferDestinationBlockchainLocation {
|
|
218
|
+
readonly kind = 'blockchain' as const
|
|
219
|
+
readonly chain: string | null
|
|
220
|
+
readonly #address: string | null
|
|
221
|
+
readonly #addressTag: string | null
|
|
222
|
+
|
|
223
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
224
|
+
constructor(fields: { chain: string | null; address: string | null; addressTag: string | null }) {
|
|
225
|
+
this.chain = fields.chain
|
|
226
|
+
this.#address = fields.address
|
|
227
|
+
this.#addressTag = fields.addressTag
|
|
228
|
+
Object.freeze(this)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** The destination on-chain address, or `null` for an un-backfilled verified-blockchain leg. See the class note. */
|
|
232
|
+
get address(): string | null {
|
|
233
|
+
return this.#address
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Secondary on-chain identifier (e.g. a Stellar memo) paired with {@link address}; nullable. */
|
|
237
|
+
get addressTag(): string | null {
|
|
238
|
+
return this.#addressTag
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
toJSON(): TransferDestinationBlockchainLocationRendering {
|
|
242
|
+
return {
|
|
243
|
+
kind: this.kind,
|
|
244
|
+
chain: this.chain,
|
|
245
|
+
address: this.#address === null ? null : REDACTED,
|
|
246
|
+
addressTag: this.#addressTag === null ? null : REDACTED,
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
toString(): string {
|
|
251
|
+
return (
|
|
252
|
+
`TransferDestinationBlockchainLocation(kind=blockchain, chain=${this.chain}, ` +
|
|
253
|
+
`address=${this.#address === null ? 'null' : REDACTED}, ` +
|
|
254
|
+
`addressTag=${this.#addressTag === null ? 'null' : REDACTED})`
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* A transfer's destination leg (OpenAPI `TransferDestinationLocation`, a `oneOf`
|
|
261
|
+
* of `TransferDestinationBlockchainLocation` and `TransferDestinationAccountLocation`).
|
|
262
|
+
*
|
|
263
|
+
* See {@link TransferSourceLocation} for the shared discriminator and the
|
|
264
|
+
* forward-compatibility contract for a `type` this SDK does not recognise.
|
|
265
|
+
*/
|
|
266
|
+
export type TransferDestinationLocation =
|
|
267
|
+
| TransferDestinationAccountLocation
|
|
268
|
+
| TransferDestinationBlockchainLocation
|
|
269
|
+
| { readonly kind: 'unrecognized'; readonly rawValue: string | null }
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* A single fee applied to a transfer (OpenAPI `Fee`).
|
|
273
|
+
*
|
|
274
|
+
* `amount` reuses `Money` rather than carrying its own decimal string — the exact
|
|
275
|
+
* problem `Money` already solves (the service serializes `Fee.amount` the same
|
|
276
|
+
* way, as a plain decimal string) and redacts the same way. `type` is a plain
|
|
277
|
+
* `string`: the service does not constrain it to an enum (the schema's
|
|
278
|
+
* `network` value is documentation only, not a runtime constraint), so there is
|
|
279
|
+
* no closed set to model or to get wrong.
|
|
280
|
+
*/
|
|
281
|
+
export type Fee = {
|
|
282
|
+
readonly amount: Money
|
|
283
|
+
readonly type: string
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Policy-engine evaluation attached to a transfer when one is available (OpenAPI
|
|
288
|
+
* `PolicyEvaluation`).
|
|
289
|
+
*
|
|
290
|
+
* `status` is a plain `string`, matching the service: `PolicyEvaluation.status`
|
|
291
|
+
* is a free-form string, not an enum, so — unlike `TransferStatus`/
|
|
292
|
+
* `TransferErrorCode` — there is no closed set to widen or to fall back from.
|
|
293
|
+
*/
|
|
294
|
+
export type TransferPolicyEvaluation = {
|
|
295
|
+
readonly status: string
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** The redacted shape `JSON.stringify(transfer)` produces. */
|
|
299
|
+
export type TransferRendering = {
|
|
300
|
+
readonly id: string
|
|
301
|
+
readonly source: TransferSourceLocation | null
|
|
302
|
+
readonly destination: TransferDestinationLocation | null
|
|
303
|
+
readonly amount: { readonly amount: string; readonly currency: string }
|
|
304
|
+
readonly fees: string
|
|
305
|
+
readonly transactionHash: string | null
|
|
306
|
+
readonly destinationTransactionHash: string | null
|
|
307
|
+
readonly status: TransferStatus
|
|
308
|
+
readonly errorCode: TransferErrorCode | null
|
|
309
|
+
readonly policyEvaluation: TransferPolicyEvaluation | null
|
|
310
|
+
readonly createDate: string | null
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* A DAA transfer, as the service reports it (OpenAPI `Transfer`, the response
|
|
315
|
+
* contract for `POST /v1/accounts/transfers`, each element of
|
|
316
|
+
* `GET /v1/accounts/transfers`, and `GET /v1/accounts/transfers/{transferId}`).
|
|
317
|
+
*
|
|
318
|
+
* Read-only at runtime as well as in the type system, for the same reason as
|
|
319
|
+
* `Account`: `readonly` is erased at compile time and would leave a returned
|
|
320
|
+
* transfer mutable through a cast. The instance is frozen and the fee list is a
|
|
321
|
+
* frozen array.
|
|
322
|
+
*
|
|
323
|
+
* **Not constructible by a consumer.** Exported from `index.ts` as a type only,
|
|
324
|
+
* and the `#` private fields make the type nominal so an object literal cannot
|
|
325
|
+
* be typed as a `Transfer`.
|
|
326
|
+
*
|
|
327
|
+
* **Only `id`, `amount`, and `status` are guaranteed non-null here — `source`
|
|
328
|
+
* and `destination` are not, despite the OpenAPI schema marking all five
|
|
329
|
+
* required.** That marking is a hint, not proof; the only evidence that
|
|
330
|
+
* settles requiredness is whether a service code path can produce the value
|
|
331
|
+
* absent, and for `source`/`destination` one does: the service reports no leg
|
|
332
|
+
* at all for a fiat source or destination, and no source leg for a
|
|
333
|
+
* verified-blockchain source. A transfer with a fiat leg — an ordinary onramp
|
|
334
|
+
* or offramp — is real, and the service omits null locations, so that leg is
|
|
335
|
+
* simply **absent** from the JSON body, not `null`; requiring it would reject
|
|
336
|
+
* an otherwise-readable transfer. `fees`, `transactionHash`,
|
|
337
|
+
* `destinationTransactionHash`, `errorCode`, and `policyEvaluation` are each
|
|
338
|
+
* documented as present only in some cases (a non-zero fee exists; a leg is
|
|
339
|
+
* blockchain; the CCTP destination leg has minted; status is `failed`; one is
|
|
340
|
+
* available) and decode to empty/`null` when absent, exactly as documented.
|
|
341
|
+
*
|
|
342
|
+
* **`createDate` is treated as optional despite looking mandatory**, and that is
|
|
343
|
+
* a deliberate hedge rather than an oversight: the OpenAPI schema does not mark
|
|
344
|
+
* it required at all (unlike `id`/`amount`/`status`) — the same kind of gap
|
|
345
|
+
* as `Account.description`, which the service can omit. This SDK reports it
|
|
346
|
+
* as it finds it rather than rejecting a transfer that is otherwise perfectly
|
|
347
|
+
* readable.
|
|
348
|
+
*
|
|
349
|
+
* **`amount` and `fees` do not appear in any default rendering.** Like `Account`'s
|
|
350
|
+
* `balances`, they sit behind prototype accessors rather than own properties, so
|
|
351
|
+
* `Object.keys`, `JSON.stringify`, `{ ...transfer }`, `for...in`, and the object
|
|
352
|
+
* inspectors behind `console.log` do not reach them; `toJSON`/`toString` reduce
|
|
353
|
+
* `fees` to a count and delegate `amount` to `Money`'s own redacted rendering.
|
|
354
|
+
* `source`/`destination` are plain own properties — safe, because a location that
|
|
355
|
+
* can carry an address redacts it itself (see
|
|
356
|
+
* {@link TransferDestinationAccountLocation}/{@link TransferDestinationBlockchainLocation}).
|
|
357
|
+
*/
|
|
358
|
+
export class Transfer {
|
|
359
|
+
/** Transfer id. */
|
|
360
|
+
readonly id: string
|
|
361
|
+
|
|
362
|
+
/** `null` for a fiat leg (an onramp) or a stray `verified_blockchain` source — see the class note. */
|
|
363
|
+
readonly source: TransferSourceLocation | null
|
|
364
|
+
|
|
365
|
+
/** `null` for a fiat leg (an offramp) — see the class note. */
|
|
366
|
+
readonly destination: TransferDestinationLocation | null
|
|
367
|
+
|
|
368
|
+
readonly status: TransferStatus
|
|
369
|
+
|
|
370
|
+
/** Present only when {@link status} is `failed`. */
|
|
371
|
+
readonly errorCode: TransferErrorCode | null
|
|
372
|
+
|
|
373
|
+
/** On-chain transaction hash; present only when a leg is blockchain. */
|
|
374
|
+
readonly transactionHash: string | null
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* CCTP destination-mint hash — the transaction hash of the destination leg
|
|
378
|
+
* minting on the receiving chain. Present only for a CCTP transfer once
|
|
379
|
+
* that leg has minted; `null` otherwise.
|
|
380
|
+
*/
|
|
381
|
+
readonly destinationTransactionHash: string | null
|
|
382
|
+
|
|
383
|
+
/** Policy-evaluation; absent until one is available. */
|
|
384
|
+
readonly policyEvaluation: TransferPolicyEvaluation | null
|
|
385
|
+
|
|
386
|
+
/** Creation timestamp, exactly as the service sent it (ISO-8601 UTC). See the class note on why this is optional. */
|
|
387
|
+
readonly createDate: string | null
|
|
388
|
+
|
|
389
|
+
readonly #amount: Money
|
|
390
|
+
readonly #fees: readonly Fee[]
|
|
391
|
+
|
|
392
|
+
/** @internal Constructed only by the SDK's response decoder. */
|
|
393
|
+
constructor(fields: {
|
|
394
|
+
readonly id: string
|
|
395
|
+
readonly source: TransferSourceLocation | null
|
|
396
|
+
readonly destination: TransferDestinationLocation | null
|
|
397
|
+
readonly amount: Money
|
|
398
|
+
readonly fees: readonly Fee[]
|
|
399
|
+
readonly transactionHash: string | null
|
|
400
|
+
readonly destinationTransactionHash: string | null
|
|
401
|
+
readonly status: TransferStatus
|
|
402
|
+
readonly errorCode: TransferErrorCode | null
|
|
403
|
+
readonly policyEvaluation: TransferPolicyEvaluation | null
|
|
404
|
+
readonly createDate: string | null
|
|
405
|
+
}) {
|
|
406
|
+
this.id = fields.id
|
|
407
|
+
this.source = fields.source
|
|
408
|
+
this.destination = fields.destination
|
|
409
|
+
this.status = fields.status
|
|
410
|
+
this.errorCode = fields.errorCode
|
|
411
|
+
this.transactionHash = fields.transactionHash
|
|
412
|
+
this.destinationTransactionHash = fields.destinationTransactionHash
|
|
413
|
+
this.policyEvaluation = fields.policyEvaluation
|
|
414
|
+
this.createDate = fields.createDate
|
|
415
|
+
this.#amount = fields.amount
|
|
416
|
+
// Same reasoning as `Account#balances`: freezing a copy rather than the
|
|
417
|
+
// caller's own array, so this construction cannot reach back and freeze an
|
|
418
|
+
// argument the caller still holds a reference to.
|
|
419
|
+
this.#fees = Object.freeze(fields.fees.slice())
|
|
420
|
+
Object.freeze(this)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** The transferred amount. Reuses `Money`, which redacts its own `amount` field. */
|
|
424
|
+
get amount(): Money {
|
|
425
|
+
return this.#amount
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** Applied fees. Empty when the service sent none (no non-zero fee exists). */
|
|
429
|
+
get fees(): readonly Fee[] {
|
|
430
|
+
return this.#fees
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Identifiers and states render; the amount and fee amounts do not. */
|
|
434
|
+
toJSON(): TransferRendering {
|
|
435
|
+
return {
|
|
436
|
+
id: this.id,
|
|
437
|
+
source: this.source,
|
|
438
|
+
destination: this.destination,
|
|
439
|
+
amount: this.#amount.toJSON(),
|
|
440
|
+
fees: `${this.#fees.length} entries`,
|
|
441
|
+
transactionHash: this.transactionHash,
|
|
442
|
+
destinationTransactionHash: this.destinationTransactionHash,
|
|
443
|
+
status: this.status,
|
|
444
|
+
errorCode: this.errorCode,
|
|
445
|
+
policyEvaluation: this.policyEvaluation,
|
|
446
|
+
createDate: this.createDate,
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** Identifiers and states print; the amount and fee amounts do not. */
|
|
451
|
+
toString(): string {
|
|
452
|
+
return (
|
|
453
|
+
`Transfer(id=${this.id}, status=${this.status.kind}, ` +
|
|
454
|
+
`errorCode=${this.errorCode === null ? 'null' : this.errorCode.kind}, ` +
|
|
455
|
+
`amount=${this.#amount.toString()}, fees=${this.#fees.length} entries, ` +
|
|
456
|
+
`transactionHash=${this.transactionHash}, createDate=${this.createDate})`
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
}
|