@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,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
20
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
21
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
22
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
23
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
24
|
+
};
|
|
25
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
27
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
|
+
};
|
|
30
|
+
var _WireFiatAccountsClient_transport;
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.WireFiatAccountsClient = void 0;
|
|
33
|
+
const errors_1 = require("../errors");
|
|
34
|
+
const uuid_1 = require("../validation/uuid");
|
|
35
|
+
const wirePayload_1 = require("../wire/wirePayload");
|
|
36
|
+
const queryParameters_1 = require("./queryParameters");
|
|
37
|
+
const resourceRequest_1 = require("./resourceRequest");
|
|
38
|
+
const WIRE_COLLECTION_PATH = '/v1/banks/wires';
|
|
39
|
+
const WIRE_PATH_PREFIX = '/v1/banks/wires/';
|
|
40
|
+
/**
|
|
41
|
+
* Reads over wire fiat accounts.
|
|
42
|
+
*
|
|
43
|
+
* Every operation here is an **ordinary typed read** — fiat-account list and
|
|
44
|
+
* get and the receiving-instructions read are all unsigned — so, like
|
|
45
|
+
* `AccountsClient.get`, none of it needs a device signature.
|
|
46
|
+
*
|
|
47
|
+
* {@link list} returns the API's **unpaginated list shape**: a plain `data`
|
|
48
|
+
* array, not this SDK's opaque-cursor `Page<T>`. {@link get} and
|
|
49
|
+
* {@link getInstructions} are separate SDK methods and response types by
|
|
50
|
+
* design: {@link get} returns the linked bank account, {@link getInstructions}
|
|
51
|
+
* returns Circle receiving instructions for it. {@link getInstructions} is a
|
|
52
|
+
* plain typed read of the public instruction route: it returns Circle's
|
|
53
|
+
* receiving instructions and does not resolve a self-custody pass-through
|
|
54
|
+
* account.
|
|
55
|
+
*
|
|
56
|
+
* Not constructible by a consumer: exported from `index.ts` as a type only,
|
|
57
|
+
* and the `#transport` field makes the type nominal.
|
|
58
|
+
*/
|
|
59
|
+
class WireFiatAccountsClient {
|
|
60
|
+
/** @internal Constructed only through `createDaaUserClient`. */
|
|
61
|
+
constructor(transport) {
|
|
62
|
+
_WireFiatAccountsClient_transport.set(this, void 0);
|
|
63
|
+
__classPrivateFieldSet(this, _WireFiatAccountsClient_transport, transport, "f");
|
|
64
|
+
Object.freeze(this);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* List wire fiat accounts.
|
|
68
|
+
*
|
|
69
|
+
* `clientEntityId` is optional here — unlike `AchFiatAccountsClient.list`,
|
|
70
|
+
* where it is required. This is a deliberate asymmetry, not a typo:
|
|
71
|
+
* `WireFiatAccountListQuery.clientEntityId` is optional and
|
|
72
|
+
* `AchFiatAccountListQuery.clientEntityId` is required, because ACH listing
|
|
73
|
+
* covers third-party accounts only.
|
|
74
|
+
*
|
|
75
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for an
|
|
76
|
+
* invalid query or a response the SDK cannot read, and
|
|
77
|
+
* `detail.kind === 'api'` for a status other than the documented `200`;
|
|
78
|
+
* `detail.kind === 'transport'` if the consumer's transport throws, with the
|
|
79
|
+
* thrown value as `err.cause`.
|
|
80
|
+
*/
|
|
81
|
+
async list(query) {
|
|
82
|
+
return (0, resourceRequest_1.readResource)({
|
|
83
|
+
transport: __classPrivateFieldGet(this, _WireFiatAccountsClient_transport, "f"),
|
|
84
|
+
path: WIRE_COLLECTION_PATH,
|
|
85
|
+
query: wireListQuery(query),
|
|
86
|
+
decode: wirePayload_1.toWireSummaries,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Read one wire fiat account.
|
|
91
|
+
*
|
|
92
|
+
* @param fiatAccountId The service-assigned UUID.
|
|
93
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a
|
|
94
|
+
* rejected `fiatAccountId` or a response the SDK cannot read, and
|
|
95
|
+
* `detail.kind === 'api'` for a status other than the documented `200`;
|
|
96
|
+
* `detail.kind === 'transport'` if the consumer's transport throws, with the
|
|
97
|
+
* thrown value as `err.cause`.
|
|
98
|
+
*/
|
|
99
|
+
async get(fiatAccountId) {
|
|
100
|
+
if (!(0, uuid_1.isUuid)(fiatAccountId)) {
|
|
101
|
+
throw (0, errors_1.contractViolation)('fiatAccountId must be a UUID');
|
|
102
|
+
}
|
|
103
|
+
return (0, resourceRequest_1.readResource)({
|
|
104
|
+
transport: __classPrivateFieldGet(this, _WireFiatAccountsClient_transport, "f"),
|
|
105
|
+
path: WIRE_PATH_PREFIX + fiatAccountId,
|
|
106
|
+
decode: wirePayload_1.toWire,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Read Circle receiving instructions for a wire fiat account.
|
|
111
|
+
*
|
|
112
|
+
* A plain typed read of the public instruction route — see the class doc.
|
|
113
|
+
*
|
|
114
|
+
* @param fiatAccountId The service-assigned UUID.
|
|
115
|
+
* @param query Optional public `accountId`. The wire instruction route
|
|
116
|
+
* accepts this parameter; the ACH route does not.
|
|
117
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a
|
|
118
|
+
* rejected `fiatAccountId`/`accountId` or a response the SDK cannot read,
|
|
119
|
+
* and `detail.kind === 'api'` for a status other than the documented
|
|
120
|
+
* `200`; `detail.kind === 'transport'` if the consumer's transport throws,
|
|
121
|
+
* with the thrown value as `err.cause`.
|
|
122
|
+
*/
|
|
123
|
+
async getInstructions(fiatAccountId, query) {
|
|
124
|
+
if (!(0, uuid_1.isUuid)(fiatAccountId)) {
|
|
125
|
+
throw (0, errors_1.contractViolation)('fiatAccountId must be a UUID');
|
|
126
|
+
}
|
|
127
|
+
return (0, resourceRequest_1.readResource)({
|
|
128
|
+
transport: __classPrivateFieldGet(this, _WireFiatAccountsClient_transport, "f"),
|
|
129
|
+
path: WIRE_PATH_PREFIX + fiatAccountId + '/instructions',
|
|
130
|
+
query: wireInstructionQuery(query),
|
|
131
|
+
decode: wirePayload_1.toWireInstruction,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.WireFiatAccountsClient = WireFiatAccountsClient;
|
|
136
|
+
_WireFiatAccountsClient_transport = new WeakMap();
|
|
137
|
+
function wireListQuery(query) {
|
|
138
|
+
if (query === undefined)
|
|
139
|
+
return null;
|
|
140
|
+
if (typeof query !== 'object' || query === null || Array.isArray(query)) {
|
|
141
|
+
throw (0, errors_1.contractViolation)('wire list query must be an object');
|
|
142
|
+
}
|
|
143
|
+
const parts = [];
|
|
144
|
+
(0, queryParameters_1.appendUuid)(parts, 'clientEntityId', query.clientEntityId);
|
|
145
|
+
return parts.length === 0 ? null : parts.join('&');
|
|
146
|
+
}
|
|
147
|
+
function wireInstructionQuery(query) {
|
|
148
|
+
if (query === undefined)
|
|
149
|
+
return null;
|
|
150
|
+
if (typeof query !== 'object' || query === null || Array.isArray(query)) {
|
|
151
|
+
throw (0, errors_1.contractViolation)('wire instruction query must be an object');
|
|
152
|
+
}
|
|
153
|
+
const parts = [];
|
|
154
|
+
(0, queryParameters_1.appendString)(parts, 'accountId', query.accountId);
|
|
155
|
+
return parts.length === 0 ? null : parts.join('&');
|
|
156
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { CreateWithdrawalRequest } from '../models/CreateWithdrawalRequest';
|
|
19
|
+
import type { Page } from '../models/Page';
|
|
20
|
+
import type { WithdrawalDetail } from '../models/Withdrawal';
|
|
21
|
+
import type { DaaTransport } from '../transport/DaaTransport';
|
|
22
|
+
import { type DaaUserSigning } from './signedResource';
|
|
23
|
+
/** The closed set of withdrawal list statuses; mirrors `models/Withdrawal.ts`'s `WithdrawalStatus` kinds. */
|
|
24
|
+
declare const WITHDRAWAL_LIST_STATUSES: readonly ["pending", "complete", "failed"];
|
|
25
|
+
export type WithdrawalListQuery = Readonly<{
|
|
26
|
+
/** Select a backing source explicitly; omitted derives from `accountId` or defaults to omnibus. */
|
|
27
|
+
custodyType?: 'omnibus' | 'segregated' | 'self';
|
|
28
|
+
/** Match withdrawals funded from this source account. Account ids are strings, not necessarily UUIDs. */
|
|
29
|
+
accountId?: string;
|
|
30
|
+
/** Match any of these withdrawal statuses. Repeatable `status` query params. */
|
|
31
|
+
status?: readonly (typeof WITHDRAWAL_LIST_STATUSES)[number][];
|
|
32
|
+
/** Inclusive RFC 3339 creation-time lower bound. */
|
|
33
|
+
from?: string;
|
|
34
|
+
/** Inclusive RFC 3339 creation-time upper bound. */
|
|
35
|
+
to?: string;
|
|
36
|
+
/** Initial forward keyset cursor. Link-derived navigation remains opaque. */
|
|
37
|
+
pageAfter?: string;
|
|
38
|
+
/** Initial backward keyset cursor. Link-derived navigation remains opaque. */
|
|
39
|
+
pageBefore?: string;
|
|
40
|
+
pageSize?: number;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Reads over DAA withdrawals, plus the signed withdrawal create, as the SDK
|
|
44
|
+
* contract's `WithdrawalsClient`.
|
|
45
|
+
*
|
|
46
|
+
* {@link list} retains the API's RFC 8288 navigation queries as opaque text.
|
|
47
|
+
* Collection rows use the same public projection {@link get} uses;
|
|
48
|
+
* `policyEvaluation` is GET-only and is omitted (decoded as `null`) on list
|
|
49
|
+
* items. {@link create} is an Owner-authorized write: it carries an
|
|
50
|
+
* `X-Device-Authorization` bound to the exact bytes it sends and cannot happen
|
|
51
|
+
* without the registered AuthKey `forUser` supplies.
|
|
52
|
+
*
|
|
53
|
+
* Not constructible by a consumer: exported from `index.ts` as a type only, and
|
|
54
|
+
* the `#transport` field makes the type nominal.
|
|
55
|
+
*/
|
|
56
|
+
export declare class WithdrawalsClient {
|
|
57
|
+
#private;
|
|
58
|
+
/** @internal Constructed only through the internal user-client factory. */
|
|
59
|
+
constructor(transport: DaaTransport, publicApiOrigin: string, signing: DaaUserSigning);
|
|
60
|
+
/** List withdrawals and retain the API's opaque navigation queries unchanged. */
|
|
61
|
+
list(query?: WithdrawalListQuery): Promise<Page<WithdrawalDetail>>;
|
|
62
|
+
/** Read one withdrawal over the public Accounts route. */
|
|
63
|
+
get(withdrawalId: string): Promise<WithdrawalDetail>;
|
|
64
|
+
/**
|
|
65
|
+
* Create a withdrawal, authorized by the registered device key.
|
|
66
|
+
*
|
|
67
|
+
* The body is validated, serialized **once**, and that exact byte slice is
|
|
68
|
+
* both hashed into the authorization's `body_sha256` claim and sent as the
|
|
69
|
+
* request entity. Nothing between here and the transport re-serializes it.
|
|
70
|
+
*
|
|
71
|
+
* Neither the method nor the path is chosen here. `postSignedResource`
|
|
72
|
+
* resolves both from the registry entry for `withdrawal`, so a signed write
|
|
73
|
+
* cannot be aimed somewhere the operation does not name.
|
|
74
|
+
*
|
|
75
|
+
* The response decodes through the same public projection {@link get} uses:
|
|
76
|
+
* `policyEvaluation` is GET-only and is omitted (decoded as `null`) here too.
|
|
77
|
+
*
|
|
78
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a request
|
|
79
|
+
* the registry schema would reject, for an AuthKey that is not yet
|
|
80
|
+
* registered — the create is refused locally, before anything is signed or
|
|
81
|
+
* sent — for a rejected or replayed authorization (including a key that is
|
|
82
|
+
* no longer active: DAA has no revoked-credential code, so this never
|
|
83
|
+
* throws `device_revoked`), and for a response the SDK cannot read;
|
|
84
|
+
* `clock_skew` when DAA refused the authorization because the device clock
|
|
85
|
+
* was more than 60 seconds off: correct the device time, then send the same
|
|
86
|
+
* request again;
|
|
87
|
+
* `idempotency_conflict`, with the request's key, for a `409` with
|
|
88
|
+
* `IDEMPOTENCY_KEY_REUSED` (`420034`): reconcile the original withdrawal with
|
|
89
|
+
* the same key; do not mint a new key for it;
|
|
90
|
+
* `detail.kind === 'api'` for a status other than the documented `201`; and
|
|
91
|
+
* `detail.kind === 'transport'` if the consumer's transport throws, with the
|
|
92
|
+
* thrown value as `err.cause` and the request's `idempotencyKey` on the
|
|
93
|
+
* detail.
|
|
94
|
+
*/
|
|
95
|
+
create(request: CreateWithdrawalRequest): Promise<WithdrawalDetail>;
|
|
96
|
+
}
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
20
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
21
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
22
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
23
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
24
|
+
};
|
|
25
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
27
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
|
+
};
|
|
30
|
+
var _WithdrawalsClient_transport, _WithdrawalsClient_publicApiOrigin, _WithdrawalsClient_signing;
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.WithdrawalsClient = void 0;
|
|
33
|
+
const serialization_1 = require("../crypto/serialization");
|
|
34
|
+
const errors_1 = require("../errors");
|
|
35
|
+
const requestBody_1 = require("../validation/requestBody");
|
|
36
|
+
const uuid_1 = require("../validation/uuid");
|
|
37
|
+
const jsonNumber_1 = require("../wire/jsonNumber");
|
|
38
|
+
const withdrawalPayload_1 = require("../wire/withdrawalPayload");
|
|
39
|
+
const pagination_1 = require("./pagination");
|
|
40
|
+
const queryParameters_1 = require("./queryParameters");
|
|
41
|
+
const resourceRequest_1 = require("./resourceRequest");
|
|
42
|
+
const signedResource_1 = require("./signedResource");
|
|
43
|
+
/**
|
|
44
|
+
* `GET /v1/accounts/withdrawals[/{withdrawalId}]` — the **public** path,
|
|
45
|
+
* exactly as for Transfers (`TransfersClient.ts`).
|
|
46
|
+
*/
|
|
47
|
+
const WITHDRAWAL_PATH_PREFIX = '/v1/accounts/withdrawals/';
|
|
48
|
+
const WITHDRAWAL_COLLECTION_PATH = '/v1/accounts/withdrawals';
|
|
49
|
+
/** The closed set of withdrawal list statuses; mirrors `models/Withdrawal.ts`'s `WithdrawalStatus` kinds. */
|
|
50
|
+
const WITHDRAWAL_LIST_STATUSES = Object.freeze(['pending', 'complete', 'failed']);
|
|
51
|
+
/**
|
|
52
|
+
* The properties the Owner-authorization registry's `withdrawal` schema names,
|
|
53
|
+
* in the order it names them, at each level of the body. See
|
|
54
|
+
* `TransfersClient`'s equivalent constant for why order matters: these are the
|
|
55
|
+
* bytes that get signed.
|
|
56
|
+
*/
|
|
57
|
+
const WITHDRAWAL_PROPERTIES = Object.freeze([
|
|
58
|
+
'idempotencyKey',
|
|
59
|
+
'source',
|
|
60
|
+
'destination',
|
|
61
|
+
'amount',
|
|
62
|
+
'toAmount',
|
|
63
|
+
'riskSignals',
|
|
64
|
+
'burnAll',
|
|
65
|
+
]);
|
|
66
|
+
const WITHDRAWAL_SOURCE_PROPERTIES = Object.freeze(['type', 'id']);
|
|
67
|
+
const WITHDRAWAL_DESTINATION_PROPERTIES = Object.freeze(['type', 'id', 'name']);
|
|
68
|
+
const WITHDRAWAL_AMOUNT_PROPERTIES = Object.freeze(['amount', 'currency']);
|
|
69
|
+
const WITHDRAWAL_TO_AMOUNT_PROPERTIES = Object.freeze(['amount', 'currency']);
|
|
70
|
+
const WITHDRAWAL_RISK_SIGNAL_PROPERTIES = Object.freeze(['ipAddress', 'sessionId', 'deviceId']);
|
|
71
|
+
const WITHDRAWAL_TO_AMOUNT_CURRENCIES = Object.freeze(['USD', 'EUR']);
|
|
72
|
+
/**
|
|
73
|
+
* Reads over DAA withdrawals, plus the signed withdrawal create, as the SDK
|
|
74
|
+
* contract's `WithdrawalsClient`.
|
|
75
|
+
*
|
|
76
|
+
* {@link list} retains the API's RFC 8288 navigation queries as opaque text.
|
|
77
|
+
* Collection rows use the same public projection {@link get} uses;
|
|
78
|
+
* `policyEvaluation` is GET-only and is omitted (decoded as `null`) on list
|
|
79
|
+
* items. {@link create} is an Owner-authorized write: it carries an
|
|
80
|
+
* `X-Device-Authorization` bound to the exact bytes it sends and cannot happen
|
|
81
|
+
* without the registered AuthKey `forUser` supplies.
|
|
82
|
+
*
|
|
83
|
+
* Not constructible by a consumer: exported from `index.ts` as a type only, and
|
|
84
|
+
* the `#transport` field makes the type nominal.
|
|
85
|
+
*/
|
|
86
|
+
class WithdrawalsClient {
|
|
87
|
+
/** @internal Constructed only through the internal user-client factory. */
|
|
88
|
+
constructor(transport, publicApiOrigin, signing) {
|
|
89
|
+
_WithdrawalsClient_transport.set(this, void 0);
|
|
90
|
+
_WithdrawalsClient_publicApiOrigin.set(this, void 0);
|
|
91
|
+
_WithdrawalsClient_signing.set(this, void 0);
|
|
92
|
+
__classPrivateFieldSet(this, _WithdrawalsClient_transport, transport, "f");
|
|
93
|
+
__classPrivateFieldSet(this, _WithdrawalsClient_publicApiOrigin, publicApiOrigin, "f");
|
|
94
|
+
__classPrivateFieldSet(this, _WithdrawalsClient_signing, signing, "f");
|
|
95
|
+
Object.freeze(this);
|
|
96
|
+
}
|
|
97
|
+
/** List withdrawals and retain the API's opaque navigation queries unchanged. */
|
|
98
|
+
async list(query) {
|
|
99
|
+
return (0, pagination_1.readPage)({
|
|
100
|
+
transport: __classPrivateFieldGet(this, _WithdrawalsClient_transport, "f"),
|
|
101
|
+
publicApiOrigin: __classPrivateFieldGet(this, _WithdrawalsClient_publicApiOrigin, "f"),
|
|
102
|
+
path: WITHDRAWAL_COLLECTION_PATH,
|
|
103
|
+
query: withdrawalListQuery(query),
|
|
104
|
+
decode: withdrawalPayload_1.toWithdrawalDetails,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Read one withdrawal over the public Accounts route. */
|
|
108
|
+
async get(withdrawalId) {
|
|
109
|
+
if (!(0, uuid_1.isUuid)(withdrawalId)) {
|
|
110
|
+
throw (0, errors_1.contractViolation)('withdrawalId must be a UUID');
|
|
111
|
+
}
|
|
112
|
+
return (0, resourceRequest_1.readResource)({
|
|
113
|
+
transport: __classPrivateFieldGet(this, _WithdrawalsClient_transport, "f"),
|
|
114
|
+
path: WITHDRAWAL_PATH_PREFIX + withdrawalId,
|
|
115
|
+
decode: withdrawalPayload_1.toWithdrawalDetail,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create a withdrawal, authorized by the registered device key.
|
|
120
|
+
*
|
|
121
|
+
* The body is validated, serialized **once**, and that exact byte slice is
|
|
122
|
+
* both hashed into the authorization's `body_sha256` claim and sent as the
|
|
123
|
+
* request entity. Nothing between here and the transport re-serializes it.
|
|
124
|
+
*
|
|
125
|
+
* Neither the method nor the path is chosen here. `postSignedResource`
|
|
126
|
+
* resolves both from the registry entry for `withdrawal`, so a signed write
|
|
127
|
+
* cannot be aimed somewhere the operation does not name.
|
|
128
|
+
*
|
|
129
|
+
* The response decodes through the same public projection {@link get} uses:
|
|
130
|
+
* `policyEvaluation` is GET-only and is omitted (decoded as `null`) here too.
|
|
131
|
+
*
|
|
132
|
+
* @throws DaaError with `detail.kind === 'contract_violation'` for a request
|
|
133
|
+
* the registry schema would reject, for an AuthKey that is not yet
|
|
134
|
+
* registered — the create is refused locally, before anything is signed or
|
|
135
|
+
* sent — for a rejected or replayed authorization (including a key that is
|
|
136
|
+
* no longer active: DAA has no revoked-credential code, so this never
|
|
137
|
+
* throws `device_revoked`), and for a response the SDK cannot read;
|
|
138
|
+
* `clock_skew` when DAA refused the authorization because the device clock
|
|
139
|
+
* was more than 60 seconds off: correct the device time, then send the same
|
|
140
|
+
* request again;
|
|
141
|
+
* `idempotency_conflict`, with the request's key, for a `409` with
|
|
142
|
+
* `IDEMPOTENCY_KEY_REUSED` (`420034`): reconcile the original withdrawal with
|
|
143
|
+
* the same key; do not mint a new key for it;
|
|
144
|
+
* `detail.kind === 'api'` for a status other than the documented `201`; and
|
|
145
|
+
* `detail.kind === 'transport'` if the consumer's transport throws, with the
|
|
146
|
+
* thrown value as `err.cause` and the request's `idempotencyKey` on the
|
|
147
|
+
* detail.
|
|
148
|
+
*/
|
|
149
|
+
async create(request) {
|
|
150
|
+
const bodyBytes = (0, serialization_1.serializeBody)(createWithdrawalBody(request));
|
|
151
|
+
return (0, signedResource_1.postSignedResource)({
|
|
152
|
+
transport: __classPrivateFieldGet(this, _WithdrawalsClient_transport, "f"),
|
|
153
|
+
operation: 'withdrawal',
|
|
154
|
+
authKey: await __classPrivateFieldGet(this, _WithdrawalsClient_signing, "f").resolveAuthKey(),
|
|
155
|
+
authKeyId: __classPrivateFieldGet(this, _WithdrawalsClient_signing, "f").authKeyId,
|
|
156
|
+
bodyBytes,
|
|
157
|
+
// The contract documents exactly 201, with a Location header. Another
|
|
158
|
+
// 2xx is an observable API failure rather than a silently accepted
|
|
159
|
+
// variant, the same rule the by-id read applies to 200.
|
|
160
|
+
expectedStatus: 201,
|
|
161
|
+
decode: withdrawalPayload_1.toWithdrawalDetail,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.WithdrawalsClient = WithdrawalsClient;
|
|
166
|
+
_WithdrawalsClient_transport = new WeakMap(), _WithdrawalsClient_publicApiOrigin = new WeakMap(), _WithdrawalsClient_signing = new WeakMap();
|
|
167
|
+
/**
|
|
168
|
+
* Project a validated request onto the registry's `withdrawal` shape.
|
|
169
|
+
*
|
|
170
|
+
* Returned rather than serialized here so the caller can hold the one byte
|
|
171
|
+
* slice this body becomes; see {@link WithdrawalsClient.create}.
|
|
172
|
+
*/
|
|
173
|
+
function createWithdrawalBody(request) {
|
|
174
|
+
(0, requestBody_1.requireBodyObject)(request, 'withdrawal create request');
|
|
175
|
+
(0, requestBody_1.requireKnownProperties)(request, WITHDRAWAL_PROPERTIES, 'withdrawal create request');
|
|
176
|
+
const { idempotencyKey, source, destination, amount, toAmount, riskSignals, burnAll } = request;
|
|
177
|
+
// The registry types this `format: uuid` and, like `transfer`, narrows it no
|
|
178
|
+
// further — unlike `create_account`, whose own contract text says v4.
|
|
179
|
+
if (typeof idempotencyKey !== 'string' || !(0, uuid_1.isUuid)(idempotencyKey)) {
|
|
180
|
+
throw (0, errors_1.contractViolation)('idempotencyKey must be a UUID');
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
idempotencyKey,
|
|
184
|
+
...(source === undefined ? {} : { source: withdrawalSource(source) }),
|
|
185
|
+
destination: withdrawalDestination(destination),
|
|
186
|
+
amount: withdrawalAmount(amount),
|
|
187
|
+
...(toAmount === undefined ? {} : { toAmount: withdrawalToAmount(toAmount) }),
|
|
188
|
+
...(riskSignals === undefined ? {} : { riskSignals: withdrawalRiskSignals(riskSignals) }),
|
|
189
|
+
...(burnAll === undefined ? {} : { burnAll: withdrawalBurnAll(burnAll) }),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function withdrawalSource(source) {
|
|
193
|
+
(0, requestBody_1.requireBodyObject)(source, 'withdrawal source');
|
|
194
|
+
(0, requestBody_1.requireKnownProperties)(source, WITHDRAWAL_SOURCE_PROPERTIES, 'withdrawal source');
|
|
195
|
+
const { type, id } = source;
|
|
196
|
+
if (type !== 'account') {
|
|
197
|
+
throw (0, errors_1.contractViolation)('withdrawal source type must be account');
|
|
198
|
+
}
|
|
199
|
+
if (typeof id !== 'string' || id.length === 0) {
|
|
200
|
+
throw (0, errors_1.contractViolation)('withdrawal source id must be a non-empty string');
|
|
201
|
+
}
|
|
202
|
+
return { type, id };
|
|
203
|
+
}
|
|
204
|
+
function withdrawalDestination(destination) {
|
|
205
|
+
(0, requestBody_1.requireBodyObject)(destination, 'withdrawal destination');
|
|
206
|
+
(0, requestBody_1.requireKnownProperties)(destination, WITHDRAWAL_DESTINATION_PROPERTIES, 'withdrawal destination');
|
|
207
|
+
const { type, id, name } = destination;
|
|
208
|
+
if (type !== 'wire' && type !== 'ach') {
|
|
209
|
+
throw (0, errors_1.contractViolation)('withdrawal destination type must be wire or ach');
|
|
210
|
+
}
|
|
211
|
+
// Unlike a transfer's account-leg id, the registry types this `format: uuid`:
|
|
212
|
+
// a withdrawal destination names a registered fiat account, not a public
|
|
213
|
+
// account id.
|
|
214
|
+
if (typeof id !== 'string' || !(0, uuid_1.isUuid)(id)) {
|
|
215
|
+
throw (0, errors_1.contractViolation)('withdrawal destination id must be a UUID');
|
|
216
|
+
}
|
|
217
|
+
if (name !== undefined && (typeof name !== 'string' || name.length === 0)) {
|
|
218
|
+
throw (0, errors_1.contractViolation)('withdrawal destination name must be a non-empty string');
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
type,
|
|
222
|
+
id,
|
|
223
|
+
...(name === undefined ? {} : { name }),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function withdrawalAmount(amount) {
|
|
227
|
+
(0, requestBody_1.requireBodyObject)(amount, 'withdrawal amount');
|
|
228
|
+
(0, requestBody_1.requireKnownProperties)(amount, WITHDRAWAL_AMOUNT_PROPERTIES, 'withdrawal amount');
|
|
229
|
+
const { amount: amountValue, currency } = amount;
|
|
230
|
+
if (typeof amountValue !== 'string' || !jsonNumber_1.JSON_NUMBER.test(amountValue)) {
|
|
231
|
+
throw (0, errors_1.contractViolation)('withdrawal amount must be a decimal string, e.g. "10.25"');
|
|
232
|
+
}
|
|
233
|
+
if (typeof currency !== 'string' || currency.length === 0) {
|
|
234
|
+
throw (0, errors_1.contractViolation)('withdrawal amount currency must be a non-empty string');
|
|
235
|
+
}
|
|
236
|
+
return { amount: amountValue, currency };
|
|
237
|
+
}
|
|
238
|
+
function withdrawalToAmount(toAmount) {
|
|
239
|
+
(0, requestBody_1.requireBodyObject)(toAmount, 'withdrawal toAmount');
|
|
240
|
+
(0, requestBody_1.requireKnownProperties)(toAmount, WITHDRAWAL_TO_AMOUNT_PROPERTIES, 'withdrawal toAmount');
|
|
241
|
+
const { amount, currency } = toAmount;
|
|
242
|
+
if (amount !== undefined && (typeof amount !== 'string' || !jsonNumber_1.JSON_NUMBER.test(amount))) {
|
|
243
|
+
throw (0, errors_1.contractViolation)('withdrawal toAmount amount must be a decimal string, e.g. "10.25"');
|
|
244
|
+
}
|
|
245
|
+
if (typeof currency !== 'string' || !WITHDRAWAL_TO_AMOUNT_CURRENCIES.includes(currency)) {
|
|
246
|
+
throw (0, errors_1.contractViolation)('withdrawal toAmount currency must be USD or EUR');
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
...(amount === undefined ? {} : { amount }),
|
|
250
|
+
currency,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function withdrawalRiskSignals(riskSignals) {
|
|
254
|
+
(0, requestBody_1.requireBodyObject)(riskSignals, 'withdrawal risk signals');
|
|
255
|
+
(0, requestBody_1.requireKnownProperties)(riskSignals, WITHDRAWAL_RISK_SIGNAL_PROPERTIES, 'withdrawal risk signals');
|
|
256
|
+
const { ipAddress, sessionId, deviceId } = riskSignals;
|
|
257
|
+
requireOptionalRiskSignal(ipAddress, 'ipAddress');
|
|
258
|
+
requireOptionalRiskSignal(sessionId, 'sessionId');
|
|
259
|
+
requireOptionalRiskSignal(deviceId, 'deviceId');
|
|
260
|
+
// The registry requires none of these, so an object with none of them is a
|
|
261
|
+
// valid `riskSignals` and is sent as the empty object the caller asked for.
|
|
262
|
+
return {
|
|
263
|
+
...(ipAddress === undefined ? {} : { ipAddress }),
|
|
264
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
265
|
+
...(deviceId === undefined ? {} : { deviceId }),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function requireOptionalRiskSignal(value, name) {
|
|
269
|
+
if (value !== undefined && (typeof value !== 'string' || value.length === 0)) {
|
|
270
|
+
throw (0, errors_1.contractViolation)(`withdrawal risk signal ${name} must be a non-empty string`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function withdrawalBurnAll(value) {
|
|
274
|
+
if (typeof value !== 'boolean') {
|
|
275
|
+
throw (0, errors_1.contractViolation)('withdrawal burnAll must be a boolean');
|
|
276
|
+
}
|
|
277
|
+
return value;
|
|
278
|
+
}
|
|
279
|
+
function withdrawalListQuery(query) {
|
|
280
|
+
if (query === undefined)
|
|
281
|
+
return null;
|
|
282
|
+
if (typeof query !== 'object' || query === null || Array.isArray(query)) {
|
|
283
|
+
throw (0, errors_1.contractViolation)('withdrawal list query must be an object');
|
|
284
|
+
}
|
|
285
|
+
if (query.pageAfter !== undefined && query.pageBefore !== undefined) {
|
|
286
|
+
throw (0, errors_1.contractViolation)('pageAfter and pageBefore cannot be used together');
|
|
287
|
+
}
|
|
288
|
+
if (query.status !== undefined && (!Array.isArray(query.status) || query.status.length === 0)) {
|
|
289
|
+
throw (0, errors_1.contractViolation)('status must be a non-empty array');
|
|
290
|
+
}
|
|
291
|
+
const parts = [];
|
|
292
|
+
(0, queryParameters_1.appendEnum)(parts, 'custodyType', query.custodyType, ['omnibus', 'segregated', 'self']);
|
|
293
|
+
(0, queryParameters_1.appendString)(parts, 'accountId', query.accountId);
|
|
294
|
+
(0, queryParameters_1.appendEnums)(parts, 'status', query.status, WITHDRAWAL_LIST_STATUSES);
|
|
295
|
+
(0, queryParameters_1.appendString)(parts, 'from', query.from);
|
|
296
|
+
(0, queryParameters_1.appendString)(parts, 'to', query.to);
|
|
297
|
+
// Unlike account cursors, the service models withdrawal cursors as UUID
|
|
298
|
+
// withdrawal ids — the same rule `get`'s `withdrawalId` guard applies.
|
|
299
|
+
(0, queryParameters_1.appendUuid)(parts, 'pageAfter', query.pageAfter);
|
|
300
|
+
(0, queryParameters_1.appendUuid)(parts, 'pageBefore', query.pageBefore);
|
|
301
|
+
if (query.pageSize !== undefined) {
|
|
302
|
+
if (!Number.isInteger(query.pageSize) || query.pageSize < 1) {
|
|
303
|
+
throw (0, errors_1.contractViolation)('pageSize must be a positive integer');
|
|
304
|
+
}
|
|
305
|
+
(0, queryParameters_1.append)(parts, 'pageSize', String(query.pageSize));
|
|
306
|
+
}
|
|
307
|
+
return parts.length === 0 ? null : parts.join('&');
|
|
308
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Circle Internet Group, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
import type { DeviceStatus } from '../models/DeviceStatus';
|
|
19
|
+
import type { DaaTransport } from '../transport/DaaTransport';
|
|
20
|
+
import { type DaaUserSigning } from './signedResource';
|
|
21
|
+
/** The device list: the user's devices and the new devices waiting for approval. */
|
|
22
|
+
export declare const DEVICE_LIST_PATH = "/v1/accounts/auth/devices";
|
|
23
|
+
/**
|
|
24
|
+
* What a retry of one request's approval needs: the exact body (its
|
|
25
|
+
* `idempotencyKey` included), the code secret native checks against it, and
|
|
26
|
+
* the code a typed code must match.
|
|
27
|
+
*/
|
|
28
|
+
type KeptApproval = Readonly<{
|
|
29
|
+
targetAuthKeyId: string;
|
|
30
|
+
codeSecret: Uint8Array;
|
|
31
|
+
code: string;
|
|
32
|
+
bodyBytes: Uint8Array;
|
|
33
|
+
}>;
|
|
34
|
+
/** Approval bodies DAA has not answered yet, by lowercase request id. One per `DaaUserClient`. */
|
|
35
|
+
export type KeptApprovals = Map<string, KeptApproval>;
|
|
36
|
+
export type ApproveDeviceArgs = Readonly<{
|
|
37
|
+
/** The add-a-device request to approve, from the device list or the partner's push. */
|
|
38
|
+
requestId: string;
|
|
39
|
+
/** The six digits the user typed from the new device's screen. Spaces and dashes are ignored. */
|
|
40
|
+
typedCode: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Approve the waiting device `requestId` with the code the user typed. Resolves
|
|
44
|
+
* with the new device's status, normally `pending_activation` with its
|
|
45
|
+
* `readyAt`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function approveDevice(transport: DaaTransport, signing: DaaUserSigning, kept: KeptApprovals, assertOpen: () => void, args: ApproveDeviceArgs): Promise<DeviceStatus>;
|
|
48
|
+
export {};
|