@circle-fin/daa-react-native-sdk 0.0.0-stage → 0.5.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 +69 -0
- package/LICENSE +176 -0
- package/README.md +691 -2
- package/android/build.gradle +102 -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 +104 -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 +107 -0
- package/android/src/main/java/com/circle/daa/reactnative/DaaSecureKeyModule.kt +318 -0
- package/android/src/main/java/com/circle/daa/reactnative/InstallationIdentityStore.kt +122 -0
- package/android/src/main/java/com/circle/daa/reactnative/UnpaddedBase64Url.kt +45 -0
- package/build/DaaClient.d.ts +237 -0
- package/build/DaaClient.js +442 -0
- package/build/api/AccountLimitsClient.d.ts +79 -0
- package/build/api/AccountLimitsClient.js +142 -0
- package/build/api/AccountsClient.d.ts +98 -0
- package/build/api/AccountsClient.js +279 -0
- package/build/api/AchFiatAccountsClient.d.ts +92 -0
- package/build/api/AchFiatAccountsClient.js +142 -0
- package/build/api/AuthClient.d.ts +95 -0
- package/build/api/AuthClient.js +221 -0
- package/build/api/ContractExecutionsClient.d.ts +114 -0
- package/build/api/ContractExecutionsClient.js +462 -0
- package/build/api/DaaUserClient.d.ts +187 -0
- package/build/api/DaaUserClient.js +312 -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 +121 -0
- package/build/api/TransfersClient.d.ts +107 -0
- package/build/api/TransfersClient.js +324 -0
- package/build/api/WireFiatAccountsClient.d.ts +99 -0
- package/build/api/WireFiatAccountsClient.js +156 -0
- package/build/api/WithdrawalsClient.d.ts +97 -0
- package/build/api/WithdrawalsClient.js +308 -0
- package/build/api/deviceApproval.d.ts +48 -0
- package/build/api/deviceApproval.js +247 -0
- package/build/api/deviceStatus.d.ts +61 -0
- package/build/api/deviceStatus.js +216 -0
- package/build/api/loginFailure.d.ts +51 -0
- package/build/api/loginFailure.js +95 -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 +124 -0
- package/build/api/signedResource.js +267 -0
- package/build/auth/RegistrationFlowKey.d.ts +93 -0
- package/build/auth/RegistrationFlowKey.js +203 -0
- package/build/auth/daaRegistrationNative.d.ts +58 -0
- package/build/auth/daaRegistrationNative.js +158 -0
- package/build/auth/deviceAuthorization.d.ts +87 -0
- package/build/auth/deviceAuthorization.js +295 -0
- package/build/auth/ownerGrant.d.ts +29 -0
- package/build/auth/ownerGrant.js +90 -0
- package/build/auth/registrationAuthorization.d.ts +48 -0
- package/build/auth/registrationAuthorization.js +246 -0
- package/build/auth/registrationCodeVerifier.d.ts +31 -0
- package/build/auth/registrationCodeVerifier.js +75 -0
- package/build/config.d.ts +106 -0
- package/build/config.js +131 -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/jwkThumbprint.d.ts +32 -0
- package/build/crypto/jwkThumbprint.js +49 -0
- package/build/crypto/matchingCode.d.ts +47 -0
- package/build/crypto/matchingCode.js +93 -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 +307 -0
- package/build/errors.js +413 -0
- package/build/index.d.ts +69 -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/ContractExecution.d.ts +197 -0
- package/build/models/ContractExecution.js +130 -0
- package/build/models/CreateAccountRequest.d.ts +74 -0
- package/build/models/CreateAccountRequest.js +19 -0
- package/build/models/CreateContractExecutionRequest.d.ts +81 -0
- package/build/models/CreateContractExecutionRequest.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 +146 -0
- package/build/models/DaaUserContext.js +164 -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/DeviceStatus.d.ts +69 -0
- package/build/models/DeviceStatus.js +19 -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/PendingDeviceApproval.d.ts +121 -0
- package/build/models/PendingDeviceApproval.js +208 -0
- package/build/models/PendingDeviceRegistration.d.ts +229 -0
- package/build/models/PendingDeviceRegistration.js +636 -0
- package/build/models/PreparedContractExecution.d.ts +70 -0
- package/build/models/PreparedContractExecution.js +77 -0
- package/build/models/PreparedSocialLogin.d.ts +148 -0
- package/build/models/PreparedSocialLogin.js +252 -0
- package/build/models/Transaction.d.ts +233 -0
- package/build/models/Transaction.js +182 -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/codeSecrets.d.ts +100 -0
- package/build/models/codeSecrets.js +321 -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 +25 -0
- package/build/securekey/InMemorySecureKey.js +168 -0
- package/build/securekey/NativeSecureKey.d.ts +26 -0
- package/build/securekey/NativeSecureKey.js +355 -0
- package/build/securekey/NativeSecureKeyBridge.d.ts +151 -0
- package/build/securekey/NativeSecureKeyBridge.js +19 -0
- package/build/securekey/SecureKey.d.ts +257 -0
- package/build/securekey/SecureKey.js +19 -0
- package/build/securekey/alias.d.ts +97 -0
- package/build/securekey/alias.js +184 -0
- package/build/securekey/ownerAuthKeyResolver.d.ts +73 -0
- package/build/securekey/ownerAuthKeyResolver.js +78 -0
- package/build/securekey/registration.d.ts +19 -0
- package/build/securekey/registration.js +38 -0
- package/build/securekey/resolveNativeBridge.d.ts +33 -0
- package/build/securekey/resolveNativeBridge.js +201 -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 +41 -0
- package/build/transport/headers.js +81 -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/contractExecutionPayload.d.ts +24 -0
- package/build/wire/contractExecutionPayload.js +130 -0
- package/build/wire/daaStatusCodes.d.ts +81 -0
- package/build/wire/daaStatusCodes.js +86 -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 +35 -0
- package/build/wire/deviceContextPayload.js +59 -0
- package/build/wire/deviceRegistrationResultPayload.d.ts +77 -0
- package/build/wire/deviceRegistrationResultPayload.js +162 -0
- package/build/wire/deviceStatusPayload.d.ts +20 -0
- package/build/wire/deviceStatusPayload.js +66 -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 +94 -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 +48 -0
- package/build/wire/pendingRegistrationPayload.js +72 -0
- package/build/wire/socialLoginRequestPayload.d.ts +26 -0
- package/build/wire/socialLoginRequestPayload.js +55 -0
- package/build/wire/transactionPayload.d.ts +31 -0
- package/build/wire/transactionPayload.js +149 -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 +125 -0
- package/ios/DaaScaExceptions.swift +96 -0
- package/ios/DaaScaModule.swift +125 -0
- package/ios/DaaSecureKeyExceptions.swift +125 -0
- package/ios/DaaSecureKeyModule.swift +306 -0
- package/ios/InstallationIdentityStore.swift +162 -0
- package/ios/UnpaddedBase64URL.swift +42 -0
- package/package.json +114 -4
- package/src/DaaClient.ts +509 -0
- package/src/api/AccountLimitsClient.ts +146 -0
- package/src/api/AccountsClient.ts +308 -0
- package/src/api/AchFiatAccountsClient.ts +147 -0
- package/src/api/AuthClient.ts +266 -0
- package/src/api/ContractExecutionsClient.ts +527 -0
- package/src/api/DaaUserClient.ts +345 -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 +138 -0
- package/src/api/TransfersClient.ts +364 -0
- package/src/api/WireFiatAccountsClient.ts +172 -0
- package/src/api/WithdrawalsClient.ts +342 -0
- package/src/api/deviceApproval.ts +306 -0
- package/src/api/deviceStatus.ts +238 -0
- package/src/api/loginFailure.ts +112 -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 +427 -0
- package/src/auth/RegistrationFlowKey.ts +274 -0
- package/src/auth/daaRegistrationNative.ts +191 -0
- package/src/auth/deviceAuthorization.ts +365 -0
- package/src/auth/ownerGrant.ts +102 -0
- package/src/auth/registrationAuthorization.ts +309 -0
- package/src/auth/registrationCodeVerifier.ts +76 -0
- package/src/config.ts +192 -0
- package/src/crypto/base64url.ts +88 -0
- package/src/crypto/bytes.ts +30 -0
- package/src/crypto/jwkThumbprint.ts +65 -0
- package/src/crypto/matchingCode.ts +100 -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 +576 -0
- package/src/index.ts +258 -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/ContractExecution.ts +250 -0
- package/src/models/CreateAccountRequest.ts +109 -0
- package/src/models/CreateContractExecutionRequest.ts +100 -0
- package/src/models/CreateTransferRequest.ts +114 -0
- package/src/models/CreateWithdrawalRequest.ts +120 -0
- package/src/models/DaaUserContext.ts +228 -0
- package/src/models/Deposit.ts +307 -0
- package/src/models/DepositSummary.ts +142 -0
- package/src/models/DeviceStatus.ts +50 -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/PendingDeviceApproval.ts +229 -0
- package/src/models/PendingDeviceRegistration.ts +791 -0
- package/src/models/PreparedContractExecution.ts +128 -0
- package/src/models/PreparedSocialLogin.ts +297 -0
- package/src/models/Transaction.ts +322 -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/codeSecrets.ts +360 -0
- package/src/models/redaction.ts +22 -0
- package/src/sca/ScaClient.ts +289 -0
- package/src/securekey/InMemorySecureKey.ts +192 -0
- package/src/securekey/NativeSecureKey.ts +388 -0
- package/src/securekey/NativeSecureKeyBridge.ts +189 -0
- package/src/securekey/SecureKey.ts +279 -0
- package/src/securekey/alias.ts +212 -0
- package/src/securekey/ownerAuthKeyResolver.ts +135 -0
- package/src/securekey/registration.ts +40 -0
- package/src/securekey/resolveNativeBridge.ts +343 -0
- package/src/testing.ts +32 -0
- package/src/transport/DaaTransport.ts +42 -0
- package/src/transport/headers.ts +93 -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/contractExecutionPayload.ts +152 -0
- package/src/wire/daaStatusCodes.ts +86 -0
- package/src/wire/dataEnvelope.ts +80 -0
- package/src/wire/depositPayload.ts +186 -0
- package/src/wire/deviceContextPayload.ts +60 -0
- package/src/wire/deviceRegistrationResultPayload.ts +211 -0
- package/src/wire/deviceStatusPayload.ts +68 -0
- package/src/wire/errorEnvelope.ts +87 -0
- package/src/wire/fiatAccountPayload.ts +112 -0
- package/src/wire/instant.ts +96 -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 +118 -0
- package/src/wire/socialLoginRequestPayload.ts +66 -0
- package/src/wire/transactionPayload.ts +181 -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,56 @@
|
|
|
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.requireBodyObject = requireBodyObject;
|
|
21
|
+
exports.requireKnownProperties = requireKnownProperties;
|
|
22
|
+
// Local checks on a request body before it is serialized, signed, and sent.
|
|
23
|
+
//
|
|
24
|
+
// These exist because the Owner-authorization registry declares every signed
|
|
25
|
+
// operation's schema `additionalProperties: false`, and DAA enforces it
|
|
26
|
+
// property by property. A body carrying a property the schema does not name is
|
|
27
|
+
// refused there, so the SDK refuses it here — where the caller still has the
|
|
28
|
+
// stack that produced it, and before an Owner signature has been spent on bytes
|
|
29
|
+
// that cannot succeed.
|
|
30
|
+
//
|
|
31
|
+
// Rejecting is deliberate, and it is not the same as projecting the known
|
|
32
|
+
// properties and dropping the rest. A dropped property is a silent change of
|
|
33
|
+
// meaning: `blockChain` for `blockchain` would create an account on the default
|
|
34
|
+
// home chain rather than the requested one, and the caller would have no way to
|
|
35
|
+
// tell from the result that the field it set was never sent.
|
|
36
|
+
const errors_1 = require("../errors");
|
|
37
|
+
/** Refuse anything that is not a plain JSON object, including an array or null. */
|
|
38
|
+
function requireBodyObject(value, label) {
|
|
39
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
40
|
+
throw (0, errors_1.contractViolation)(`${label} must be an object`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Refuse a property the operation's registry schema does not name.
|
|
45
|
+
*
|
|
46
|
+
* `Object.keys` reports own enumerable string keys, which is exactly the set
|
|
47
|
+
* `JSON.stringify` would serialize — so this checks the properties that would
|
|
48
|
+
* actually reach the wire rather than a structural approximation of them.
|
|
49
|
+
*/
|
|
50
|
+
function requireKnownProperties(value, allowed, label) {
|
|
51
|
+
for (const key of Object.keys(value)) {
|
|
52
|
+
if (!allowed.includes(key)) {
|
|
53
|
+
throw (0, errors_1.contractViolation)(`${label} does not accept the property "${key}"`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
* Whether a value uses the hyphenated UUID form accepted by DAA path
|
|
20
|
+
* parameters. UUIDs are strings at the TypeScript boundary, so this is the
|
|
21
|
+
* runtime guard before one becomes part of a request path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isUuid(value: string): boolean;
|
|
24
|
+
/** Whether a value is an RFC 4122 UUID v4, including a valid variant nibble. */
|
|
25
|
+
export declare function isUuidV4(value: string): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
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.isUuid = isUuid;
|
|
21
|
+
exports.isUuidV4 = isUuidV4;
|
|
22
|
+
/**
|
|
23
|
+
* Whether a value uses the hyphenated UUID form accepted by DAA path
|
|
24
|
+
* parameters. UUIDs are strings at the TypeScript boundary, so this is the
|
|
25
|
+
* runtime guard before one becomes part of a request path.
|
|
26
|
+
*/
|
|
27
|
+
function isUuid(value) {
|
|
28
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
29
|
+
}
|
|
30
|
+
/** Whether a value is an RFC 4122 UUID v4, including a valid variant nibble. */
|
|
31
|
+
function isUuidV4(value) {
|
|
32
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { AccountLimitsUsage } from '../models/AccountLimitsUsage';
|
|
19
|
+
/**
|
|
20
|
+
* Map a decoded `GET /v1/accounts/{accountId}/limits/usage` payload onto the
|
|
21
|
+
* public model.
|
|
22
|
+
*
|
|
23
|
+
* `type`, `accountId`, `currency`, `watermark`, and `items` are all required —
|
|
24
|
+
* the public reference marks every one of them required on `data`, and this is
|
|
25
|
+
* a single-object envelope (see `AccountLimitsClient.get`), not a page, so
|
|
26
|
+
* there is no separate list-projection type the way `deposits.list` has one.
|
|
27
|
+
*
|
|
28
|
+
* @throws MalformedPayloadError
|
|
29
|
+
*/
|
|
30
|
+
export declare function toAccountLimitsUsage(value: unknown): AccountLimitsUsage;
|
|
@@ -0,0 +1,130 @@
|
|
|
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.toAccountLimitsUsage = toAccountLimitsUsage;
|
|
21
|
+
const AccountLimitsUsage_1 = require("../models/AccountLimitsUsage");
|
|
22
|
+
const payload_1 = require("./payload");
|
|
23
|
+
// Wire-string to public-type mapping, one `Map` per closed-set field — the
|
|
24
|
+
// same `Object.prototype` hazard `wireEnums.ts` guards against, kept local to
|
|
25
|
+
// this endpoint the same way `depositPayload.ts` keeps `DEPOSIT_STATUSES` and
|
|
26
|
+
// `DEPOSIT_TYPES` local rather than exporting them off the model.
|
|
27
|
+
const RESOURCE_TYPES = new Map([
|
|
28
|
+
['limitsUsage', Object.freeze({ kind: 'limitsUsage' })],
|
|
29
|
+
]);
|
|
30
|
+
const OPERATIONS = new Map([
|
|
31
|
+
['deposit', Object.freeze({ kind: 'deposit' })],
|
|
32
|
+
['withdrawal', Object.freeze({ kind: 'withdrawal' })],
|
|
33
|
+
['receive', Object.freeze({ kind: 'receive' })],
|
|
34
|
+
['send', Object.freeze({ kind: 'send' })],
|
|
35
|
+
['send_count', Object.freeze({ kind: 'send_count' })],
|
|
36
|
+
['address_linking', Object.freeze({ kind: 'address_linking' })],
|
|
37
|
+
['fiat_linking', Object.freeze({ kind: 'fiat_linking' })],
|
|
38
|
+
['deposit_return_count', Object.freeze({ kind: 'deposit_return_count' })],
|
|
39
|
+
['balance_cap', Object.freeze({ kind: 'balance_cap' })],
|
|
40
|
+
]);
|
|
41
|
+
const ASSET_TYPES = new Map([
|
|
42
|
+
['fiat', Object.freeze({ kind: 'fiat' })],
|
|
43
|
+
['crypto', Object.freeze({ kind: 'crypto' })],
|
|
44
|
+
]);
|
|
45
|
+
const COMPARISON_TYPES = new Map([
|
|
46
|
+
['transaction', Object.freeze({ kind: 'transaction' })],
|
|
47
|
+
['aggregation', Object.freeze({ kind: 'aggregation' })],
|
|
48
|
+
]);
|
|
49
|
+
const UNITS = new Map([
|
|
50
|
+
['usd_cents', Object.freeze({ kind: 'usd_cents' })],
|
|
51
|
+
['count', Object.freeze({ kind: 'count' })],
|
|
52
|
+
]);
|
|
53
|
+
const WINDOWS = new Map([
|
|
54
|
+
['PT24H', Object.freeze({ kind: 'PT24H' })],
|
|
55
|
+
['P30D', Object.freeze({ kind: 'P30D' })],
|
|
56
|
+
]);
|
|
57
|
+
function toResourceType(raw) {
|
|
58
|
+
return RESOURCE_TYPES.get(raw) ?? (0, payload_1.unrecognized)(raw);
|
|
59
|
+
}
|
|
60
|
+
function toOperation(raw) {
|
|
61
|
+
return OPERATIONS.get(raw) ?? (0, payload_1.unrecognized)(raw);
|
|
62
|
+
}
|
|
63
|
+
function toAssetType(raw) {
|
|
64
|
+
return ASSET_TYPES.get(raw) ?? (0, payload_1.unrecognized)(raw);
|
|
65
|
+
}
|
|
66
|
+
function toComparisonType(raw) {
|
|
67
|
+
return COMPARISON_TYPES.get(raw) ?? (0, payload_1.unrecognized)(raw);
|
|
68
|
+
}
|
|
69
|
+
function toUnit(raw) {
|
|
70
|
+
return UNITS.get(raw) ?? (0, payload_1.unrecognized)(raw);
|
|
71
|
+
}
|
|
72
|
+
function toWindow(raw) {
|
|
73
|
+
return WINDOWS.get(raw) ?? (0, payload_1.unrecognized)(raw);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Map one decoded `items[]` element onto the public shape.
|
|
77
|
+
*
|
|
78
|
+
* `window`, `currentAggregate`, and `usagePercent` are read as optional
|
|
79
|
+
* unconditionally — there is no `comparisonType` branch that requires them.
|
|
80
|
+
* The public reference's own example shows a `transaction` item omitting all
|
|
81
|
+
* three and an `aggregation` item carrying all three, but nothing here
|
|
82
|
+
* enforces that correlation: a service that sent an `aggregation` item
|
|
83
|
+
* without, say, `usagePercent` would still decode rather than fail the whole
|
|
84
|
+
* read, which is the same latitude this SDK gives every other
|
|
85
|
+
* service-guarantees-in-practice-but-not-by-schema field (see `Deposit`'s
|
|
86
|
+
* class note on `destination`).
|
|
87
|
+
*
|
|
88
|
+
* @throws MalformedPayloadError
|
|
89
|
+
*/
|
|
90
|
+
function toAccountLimitsUsageItem(value) {
|
|
91
|
+
const payload = (0, payload_1.asObject)(value, 'accountLimitsUsage.items[]');
|
|
92
|
+
const window = (0, payload_1.optionalString)(payload, 'window');
|
|
93
|
+
return Object.freeze({
|
|
94
|
+
operation: toOperation((0, payload_1.requiredString)(payload, 'operation', 'accountLimitsUsage.items[].operation')),
|
|
95
|
+
assetType: toAssetType((0, payload_1.requiredString)(payload, 'assetType', 'accountLimitsUsage.items[].assetType')),
|
|
96
|
+
comparisonType: toComparisonType((0, payload_1.requiredString)(payload, 'comparisonType', 'accountLimitsUsage.items[].comparisonType')),
|
|
97
|
+
window: window === null ? null : toWindow(window),
|
|
98
|
+
unit: toUnit((0, payload_1.requiredString)(payload, 'unit', 'accountLimitsUsage.items[].unit')),
|
|
99
|
+
effectiveThreshold: (0, payload_1.requiredNonNegativeInteger)(payload, 'effectiveThreshold', 'accountLimitsUsage.items[].effectiveThreshold'),
|
|
100
|
+
currentAggregate: (0, payload_1.optionalNonNegativeInteger)(payload, 'currentAggregate', 'accountLimitsUsage.items[].currentAggregate'),
|
|
101
|
+
usagePercent: (0, payload_1.optionalNonNegativeNumber)(payload, 'usagePercent', 'accountLimitsUsage.items[].usagePercent'),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function toAccountLimitsUsageItems(value) {
|
|
105
|
+
if (!Array.isArray(value)) {
|
|
106
|
+
throw new payload_1.MalformedPayloadError('accountLimitsUsage.items');
|
|
107
|
+
}
|
|
108
|
+
return Object.freeze(value.map(toAccountLimitsUsageItem));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Map a decoded `GET /v1/accounts/{accountId}/limits/usage` payload onto the
|
|
112
|
+
* public model.
|
|
113
|
+
*
|
|
114
|
+
* `type`, `accountId`, `currency`, `watermark`, and `items` are all required —
|
|
115
|
+
* the public reference marks every one of them required on `data`, and this is
|
|
116
|
+
* a single-object envelope (see `AccountLimitsClient.get`), not a page, so
|
|
117
|
+
* there is no separate list-projection type the way `deposits.list` has one.
|
|
118
|
+
*
|
|
119
|
+
* @throws MalformedPayloadError
|
|
120
|
+
*/
|
|
121
|
+
function toAccountLimitsUsage(value) {
|
|
122
|
+
const payload = (0, payload_1.asObject)(value, 'accountLimitsUsage');
|
|
123
|
+
return new AccountLimitsUsage_1.AccountLimitsUsage({
|
|
124
|
+
type: toResourceType((0, payload_1.requiredString)(payload, 'type', 'accountLimitsUsage.type')),
|
|
125
|
+
accountId: (0, payload_1.requiredString)(payload, 'accountId'),
|
|
126
|
+
currency: (0, payload_1.requiredString)(payload, 'currency'),
|
|
127
|
+
watermark: (0, payload_1.requiredString)(payload, 'watermark'),
|
|
128
|
+
items: toAccountLimitsUsageItems(payload['items']),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { Account } from '../models/Account';
|
|
19
|
+
export { MalformedPayloadError } from './payload';
|
|
20
|
+
/**
|
|
21
|
+
* Map a decoded `Account` payload onto the public model.
|
|
22
|
+
*
|
|
23
|
+
* Unknown *additional* fields are ignored and an unfamiliar *present* closed-set
|
|
24
|
+
* value degrades to `unrecognized`; a missing guaranteed field throws. That is the
|
|
25
|
+
* line between forward compatibility and accepting a hole.
|
|
26
|
+
*
|
|
27
|
+
* `depositAddress` and `businessPii` are read because the service's responses
|
|
28
|
+
* carry them: self-custody and segregated accounts add `blockchain` and
|
|
29
|
+
* `depositAddress`. The OpenAPI schema shows none of the three, so the decoder
|
|
30
|
+
* follows the service's responses. For a self-custody consumer,
|
|
31
|
+
* `depositAddress` is the field the account exists for.
|
|
32
|
+
*
|
|
33
|
+
* @throws MalformedPayloadError
|
|
34
|
+
*/
|
|
35
|
+
export declare function toAccount(value: unknown): Account;
|
|
36
|
+
export declare function toAccounts(value: unknown): readonly Account[];
|
|
@@ -0,0 +1,100 @@
|
|
|
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.MalformedPayloadError = void 0;
|
|
21
|
+
exports.toAccount = toAccount;
|
|
22
|
+
exports.toAccounts = toAccounts;
|
|
23
|
+
const Account_1 = require("../models/Account");
|
|
24
|
+
const BusinessPii_1 = require("../models/BusinessPii");
|
|
25
|
+
const moneyPayload_1 = require("./moneyPayload");
|
|
26
|
+
const payload_1 = require("./payload");
|
|
27
|
+
const wireEnums_1 = require("./wireEnums");
|
|
28
|
+
var payload_2 = require("./payload");
|
|
29
|
+
Object.defineProperty(exports, "MalformedPayloadError", { enumerable: true, get: function () { return payload_2.MalformedPayloadError; } });
|
|
30
|
+
function requiredArray(payload, name) {
|
|
31
|
+
const value = payload[name];
|
|
32
|
+
if (!Array.isArray(value)) {
|
|
33
|
+
throw new payload_1.MalformedPayloadError(name);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function toAddress(payload) {
|
|
38
|
+
return new BusinessPii_1.Address({
|
|
39
|
+
city: (0, payload_1.optionalString)(payload, 'city'),
|
|
40
|
+
country: (0, payload_1.optionalString)(payload, 'country'),
|
|
41
|
+
district: (0, payload_1.optionalString)(payload, 'district'),
|
|
42
|
+
line1: (0, payload_1.optionalString)(payload, 'line1'),
|
|
43
|
+
line2: (0, payload_1.optionalString)(payload, 'line2'),
|
|
44
|
+
postalCode: (0, payload_1.optionalString)(payload, 'postalCode'),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function toBusinessPii(payload) {
|
|
48
|
+
const address = (0, payload_1.optionalObject)(payload, 'address');
|
|
49
|
+
return new BusinessPii_1.BusinessPii({
|
|
50
|
+
address: address === null ? null : toAddress(address),
|
|
51
|
+
businessName: (0, payload_1.optionalString)(payload, 'businessName'),
|
|
52
|
+
businessUniqueIdentifier: (0, payload_1.optionalString)(payload, 'businessUniqueIdentifier'),
|
|
53
|
+
identifierIssuingCountryCode: (0, payload_1.optionalString)(payload, 'identifierIssuingCountryCode'),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Map a decoded `Account` payload onto the public model.
|
|
58
|
+
*
|
|
59
|
+
* Unknown *additional* fields are ignored and an unfamiliar *present* closed-set
|
|
60
|
+
* value degrades to `unrecognized`; a missing guaranteed field throws. That is the
|
|
61
|
+
* line between forward compatibility and accepting a hole.
|
|
62
|
+
*
|
|
63
|
+
* `depositAddress` and `businessPii` are read because the service's responses
|
|
64
|
+
* carry them: self-custody and segregated accounts add `blockchain` and
|
|
65
|
+
* `depositAddress`. The OpenAPI schema shows none of the three, so the decoder
|
|
66
|
+
* follows the service's responses. For a self-custody consumer,
|
|
67
|
+
* `depositAddress` is the field the account exists for.
|
|
68
|
+
*
|
|
69
|
+
* @throws MalformedPayloadError
|
|
70
|
+
*/
|
|
71
|
+
function toAccount(value) {
|
|
72
|
+
const payload = (0, payload_1.asObject)(value, 'account');
|
|
73
|
+
const businessPii = (0, payload_1.optionalObject)(payload, 'businessPii');
|
|
74
|
+
return new Account_1.Account({
|
|
75
|
+
accountId: (0, payload_1.requiredString)(payload, 'accountId'),
|
|
76
|
+
balances: requiredArray(payload, 'balances').map((balance) => (0, moneyPayload_1.toMoney)(balance, 'balances[]')),
|
|
77
|
+
blockchain: (0, payload_1.optionalString)(payload, 'blockchain'),
|
|
78
|
+
businessPii: businessPii === null ? null : toBusinessPii(businessPii),
|
|
79
|
+
clientEntityId: (0, payload_1.optionalString)(payload, 'clientEntityId'),
|
|
80
|
+
// Outside the guaranteed set, unlike the three below, so an absent one is
|
|
81
|
+
// tolerated and is the only way to reach `unrecognized` with a null raw
|
|
82
|
+
// value.
|
|
83
|
+
custodyType: (0, wireEnums_1.toCustodyType)((0, payload_1.optionalString)(payload, 'custodyType')),
|
|
84
|
+
depositAddress: (0, payload_1.optionalString)(payload, 'depositAddress'),
|
|
85
|
+
description: (0, payload_1.optionalString)(payload, 'description'),
|
|
86
|
+
entityId: (0, payload_1.requiredString)(payload, 'entityId'),
|
|
87
|
+
groupId: (0, payload_1.optionalString)(payload, 'groupId'),
|
|
88
|
+
// Guaranteed, so an absent one is malformed. Only an unfamiliar *present*
|
|
89
|
+
// value becomes `unrecognized`.
|
|
90
|
+
purpose: (0, wireEnums_1.toAccountPurpose)((0, payload_1.requiredString)(payload, 'purpose')),
|
|
91
|
+
status: (0, wireEnums_1.toAccountStatus)((0, payload_1.requiredString)(payload, 'status')),
|
|
92
|
+
type: (0, wireEnums_1.toAccountType)((0, payload_1.requiredString)(payload, 'type')),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function toAccounts(value) {
|
|
96
|
+
if (!Array.isArray(value)) {
|
|
97
|
+
throw new payload_1.MalformedPayloadError('accounts');
|
|
98
|
+
}
|
|
99
|
+
return Object.freeze(value.map(toAccount));
|
|
100
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { ACH, ACHInstruction } from '../models/Ach';
|
|
19
|
+
/** Decode one `ACH` fiat account, for both list entries and the by-id read. */
|
|
20
|
+
export declare function toAch(value: unknown): ACH;
|
|
21
|
+
/** Decode the ACH collection's unpaginated `data` array. */
|
|
22
|
+
export declare function toAchList(value: unknown): readonly ACH[];
|
|
23
|
+
/** Decode an `ACHInstruction` (`GET /v1/banks/ach/{id}/instructions`). */
|
|
24
|
+
export declare function toAchInstruction(value: unknown): ACHInstruction;
|
|
@@ -0,0 +1,82 @@
|
|
|
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.toAch = toAch;
|
|
21
|
+
exports.toAchList = toAchList;
|
|
22
|
+
exports.toAchInstruction = toAchInstruction;
|
|
23
|
+
const Ach_1 = require("../models/Ach");
|
|
24
|
+
const fiatAccountPayload_1 = require("./fiatAccountPayload");
|
|
25
|
+
const payload_1 = require("./payload");
|
|
26
|
+
// See `models/Ach.ts`'s file header: this decoder mirrors `wirePayload.ts`
|
|
27
|
+
// field-for-field wherever `Wire`/`WireInstruction` and `ACH`/`ACHInstruction`
|
|
28
|
+
// share a shape, and the model file explains the one extra field
|
|
29
|
+
// (`ACH.routingNumber`).
|
|
30
|
+
function toAchInstructionBeneficiary(payload) {
|
|
31
|
+
return Object.freeze({
|
|
32
|
+
name: (0, payload_1.optionalString)(payload, 'name', 'beneficiary.name'),
|
|
33
|
+
address1: (0, payload_1.optionalString)(payload, 'address1', 'beneficiary.address1'),
|
|
34
|
+
address2: (0, payload_1.optionalString)(payload, 'address2', 'beneficiary.address2'),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function toAchInstructionBeneficiaryBank(payload) {
|
|
38
|
+
return new Ach_1.ACHInstructionBeneficiaryBank({
|
|
39
|
+
name: (0, payload_1.optionalString)(payload, 'name', 'beneficiaryBank.name'),
|
|
40
|
+
routingNumber: (0, payload_1.optionalString)(payload, 'routingNumber', 'beneficiaryBank.routingNumber'),
|
|
41
|
+
accountNumber: (0, payload_1.optionalString)(payload, 'accountNumber', 'beneficiaryBank.accountNumber'),
|
|
42
|
+
address: (0, payload_1.optionalString)(payload, 'address', 'beneficiaryBank.address'),
|
|
43
|
+
city: (0, payload_1.optionalString)(payload, 'city', 'beneficiaryBank.city'),
|
|
44
|
+
postalCode: (0, payload_1.optionalString)(payload, 'postalCode', 'beneficiaryBank.postalCode'),
|
|
45
|
+
country: (0, payload_1.optionalString)(payload, 'country', 'beneficiaryBank.country'),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** Decode one `ACH` fiat account, for both list entries and the by-id read. */
|
|
49
|
+
function toAch(value) {
|
|
50
|
+
const payload = (0, payload_1.asObject)(value, 'ach');
|
|
51
|
+
return new Ach_1.ACH({
|
|
52
|
+
id: (0, payload_1.requiredString)(payload, 'id'),
|
|
53
|
+
type: (0, payload_1.optionalString)(payload, 'type'),
|
|
54
|
+
status: (0, fiatAccountPayload_1.toFiatAccountStatus)((0, payload_1.requiredString)(payload, 'status')),
|
|
55
|
+
description: (0, payload_1.requiredString)(payload, 'description'),
|
|
56
|
+
trackingRef: (0, payload_1.requiredString)(payload, 'trackingRef'),
|
|
57
|
+
fingerprint: (0, payload_1.requiredString)(payload, 'fingerprint'),
|
|
58
|
+
billingDetails: (0, fiatAccountPayload_1.requiredBillingDetails)(payload, 'billingDetails'),
|
|
59
|
+
bankAddress: (0, fiatAccountPayload_1.optionalBankAddress)(payload, 'bankAddress'),
|
|
60
|
+
routingNumber: (0, payload_1.optionalString)(payload, 'routingNumber'),
|
|
61
|
+
createDate: (0, payload_1.requiredString)(payload, 'createDate'),
|
|
62
|
+
updateDate: (0, payload_1.requiredString)(payload, 'updateDate'),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** Decode the ACH collection's unpaginated `data` array. */
|
|
66
|
+
function toAchList(value) {
|
|
67
|
+
if (!Array.isArray(value)) {
|
|
68
|
+
throw new payload_1.MalformedPayloadError('ach');
|
|
69
|
+
}
|
|
70
|
+
return Object.freeze(value.map(toAch));
|
|
71
|
+
}
|
|
72
|
+
/** Decode an `ACHInstruction` (`GET /v1/banks/ach/{id}/instructions`). */
|
|
73
|
+
function toAchInstruction(value) {
|
|
74
|
+
const payload = (0, payload_1.asObject)(value, 'achInstruction');
|
|
75
|
+
const beneficiary = (0, payload_1.optionalObject)(payload, 'beneficiary');
|
|
76
|
+
const beneficiaryBank = (0, payload_1.optionalObject)(payload, 'beneficiaryBank');
|
|
77
|
+
return new Ach_1.ACHInstruction({
|
|
78
|
+
trackingRef: (0, payload_1.optionalString)(payload, 'trackingRef'),
|
|
79
|
+
beneficiary: beneficiary === null ? null : toAchInstructionBeneficiary(beneficiary),
|
|
80
|
+
beneficiaryBank: beneficiaryBank === null ? null : toAchInstructionBeneficiaryBank(beneficiaryBank),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 { AddressObject } from '../models/AddressObject';
|
|
19
|
+
/**
|
|
20
|
+
* Map a decoded `AddressObject` payload onto the public model.
|
|
21
|
+
*
|
|
22
|
+
* `id`, `address`, and `chain` are guaranteed by every custody source a
|
|
23
|
+
* by-id read can return from; `addressTag`, `currency`, and `accountId` are
|
|
24
|
+
* not — see the class note on `AddressObject` for the source-by-source
|
|
25
|
+
* evidence, which disagrees with the schema (it names only `addressTag` as
|
|
26
|
+
* nullable).
|
|
27
|
+
*
|
|
28
|
+
* Unknown *additional* fields are ignored, matching the service's own
|
|
29
|
+
* tolerance for unknown fields — see `addressObjectPayload.test.ts`'s
|
|
30
|
+
* forward-compatibility case.
|
|
31
|
+
*
|
|
32
|
+
* `currency` and `chain` are carried as plain strings rather than a
|
|
33
|
+
* closed-set union: the service adds chains and currencies independently of an
|
|
34
|
+
* SDK release, the same reasoning `models/Account.ts` and `models/Money.ts`
|
|
35
|
+
* give for `Account.blockchain` and `Money.currency`. Neither needs the
|
|
36
|
+
* `wireEnums.ts`-style unrecognized-with-raw-value treatment `custodyType`,
|
|
37
|
+
* `purpose`, `status`, and `type` need, because neither is modelled as a
|
|
38
|
+
* small closed set this SDK discriminates on.
|
|
39
|
+
*
|
|
40
|
+
* @throws MalformedPayloadError
|
|
41
|
+
*/
|
|
42
|
+
export declare function toAddressObject(value: unknown): AddressObject;
|
|
43
|
+
/** Decode the `data` array returned by the deposit-address collection. */
|
|
44
|
+
export declare function toAddressObjects(value: unknown): readonly AddressObject[];
|
|
@@ -0,0 +1,64 @@
|
|
|
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.toAddressObject = toAddressObject;
|
|
21
|
+
exports.toAddressObjects = toAddressObjects;
|
|
22
|
+
const AddressObject_1 = require("../models/AddressObject");
|
|
23
|
+
const payload_1 = require("./payload");
|
|
24
|
+
/**
|
|
25
|
+
* Map a decoded `AddressObject` payload onto the public model.
|
|
26
|
+
*
|
|
27
|
+
* `id`, `address`, and `chain` are guaranteed by every custody source a
|
|
28
|
+
* by-id read can return from; `addressTag`, `currency`, and `accountId` are
|
|
29
|
+
* not — see the class note on `AddressObject` for the source-by-source
|
|
30
|
+
* evidence, which disagrees with the schema (it names only `addressTag` as
|
|
31
|
+
* nullable).
|
|
32
|
+
*
|
|
33
|
+
* Unknown *additional* fields are ignored, matching the service's own
|
|
34
|
+
* tolerance for unknown fields — see `addressObjectPayload.test.ts`'s
|
|
35
|
+
* forward-compatibility case.
|
|
36
|
+
*
|
|
37
|
+
* `currency` and `chain` are carried as plain strings rather than a
|
|
38
|
+
* closed-set union: the service adds chains and currencies independently of an
|
|
39
|
+
* SDK release, the same reasoning `models/Account.ts` and `models/Money.ts`
|
|
40
|
+
* give for `Account.blockchain` and `Money.currency`. Neither needs the
|
|
41
|
+
* `wireEnums.ts`-style unrecognized-with-raw-value treatment `custodyType`,
|
|
42
|
+
* `purpose`, `status`, and `type` need, because neither is modelled as a
|
|
43
|
+
* small closed set this SDK discriminates on.
|
|
44
|
+
*
|
|
45
|
+
* @throws MalformedPayloadError
|
|
46
|
+
*/
|
|
47
|
+
function toAddressObject(value) {
|
|
48
|
+
const payload = (0, payload_1.asObject)(value, 'addressObject');
|
|
49
|
+
return new AddressObject_1.AddressObject({
|
|
50
|
+
id: (0, payload_1.requiredString)(payload, 'id'),
|
|
51
|
+
address: (0, payload_1.requiredString)(payload, 'address'),
|
|
52
|
+
addressTag: (0, payload_1.optionalString)(payload, 'addressTag'),
|
|
53
|
+
currency: (0, payload_1.optionalString)(payload, 'currency'),
|
|
54
|
+
chain: (0, payload_1.requiredString)(payload, 'chain'),
|
|
55
|
+
accountId: (0, payload_1.optionalString)(payload, 'accountId'),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** Decode the `data` array returned by the deposit-address collection. */
|
|
59
|
+
function toAddressObjects(value) {
|
|
60
|
+
if (!Array.isArray(value)) {
|
|
61
|
+
throw new payload_1.MalformedPayloadError('depositAddresses');
|
|
62
|
+
}
|
|
63
|
+
return Object.freeze(value.map(toAddressObject));
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { ContractExecution } from '../models/ContractExecution';
|
|
19
|
+
/**
|
|
20
|
+
* Map a decoded `ContractExecution` payload onto the public model.
|
|
21
|
+
*
|
|
22
|
+
* @throws MalformedPayloadError
|
|
23
|
+
*/
|
|
24
|
+
export declare function toContractExecution(value: unknown): ContractExecution;
|