@bloque/sdk-accounts 0.8.0 → 0.9.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/dist/accounts-client.d.ts +2 -2
- package/dist/breb/types.d.ts +14 -1
- package/dist/card/card-client.d.ts +17 -2
- package/dist/card/types.d.ts +198 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/wire-types.d.ts +77 -5
- package/dist/polygon/types.d.ts +15 -0
- package/dist/types.d.ts +112 -0
- package/dist/us/types.d.ts +41 -3
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ import { ExternalUsBankClient } from './external-us-bank/external-us-bank-client
|
|
|
10
10
|
import type { ExternalUsBankAccount } from './external-us-bank/types';
|
|
11
11
|
import { PolygonClient } from './polygon/polygon-client';
|
|
12
12
|
import type { PolygonAccount } from './polygon/types';
|
|
13
|
-
import type { BatchTransferOptions, BatchTransferParams, BatchTransferResult, GeneralTokenBalance, ListAccountsParams, ListAccountsResult, ListMovementsResult, ListTransactionsParams, ListTransactionsResult, TokenBalance, TransferOptions, TransferParams, TransferResult } from './types';
|
|
13
|
+
import type { BatchTransferOptions, BatchTransferParams, BatchTransferResult, GeneralTokenBalance, GetBalancesParams, ListAccountsParams, ListAccountsResult, ListMovementsResult, ListTransactionsParams, ListTransactionsResult, TokenBalance, TransferOptions, TransferParams, TransferResult } from './types';
|
|
14
14
|
import type { UsAccount } from './us/types';
|
|
15
15
|
import { UsClient } from './us/us-client';
|
|
16
16
|
import type { Us2Account } from './us2/types';
|
|
@@ -77,7 +77,7 @@ export declare class AccountsClient extends BaseClient {
|
|
|
77
77
|
* console.log(balances['DUSD/6']?.current);
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
balances(): Promise<Record<string, GeneralTokenBalance>>;
|
|
80
|
+
balances(params?: GetBalancesParams): Promise<Record<string, GeneralTokenBalance>>;
|
|
81
81
|
/**
|
|
82
82
|
* Get account by URN
|
|
83
83
|
*
|
package/dist/breb/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AccountStatus, TokenBalance } from '../types';
|
|
2
|
-
export type BrebKeyType = 'ID' | 'PHONE' | 'EMAIL' | 'ALPHA' | 'BCODE';
|
|
2
|
+
export type BrebKeyType = 'ID' | 'PHONE' | 'MOBILE' | 'EMAIL' | 'ALPHA' | 'BCODE';
|
|
3
3
|
export interface BrebOperationError {
|
|
4
4
|
/**
|
|
5
5
|
* Provider-specific error code when available.
|
|
@@ -289,6 +289,15 @@ export interface BrebDecodedQrMerchant {
|
|
|
289
289
|
merchantCity: string | null;
|
|
290
290
|
merchantPostCode: string | null;
|
|
291
291
|
}
|
|
292
|
+
export interface BrebDecodedQrVat {
|
|
293
|
+
vatValue: string | null;
|
|
294
|
+
vatBaseValue: string | null;
|
|
295
|
+
vatType: string | null;
|
|
296
|
+
}
|
|
297
|
+
export interface BrebDecodedQrInc {
|
|
298
|
+
incValue: string | null;
|
|
299
|
+
incType: string | null;
|
|
300
|
+
}
|
|
292
301
|
export interface BrebDecodedQrAdditionalInfo {
|
|
293
302
|
transactionPurpose: string | null;
|
|
294
303
|
terminalLabel: string | null;
|
|
@@ -310,6 +319,10 @@ export interface BrebDecodedQr {
|
|
|
310
319
|
acquirerNetworkIdentifier: string | null;
|
|
311
320
|
merchant: BrebDecodedQrMerchant | null;
|
|
312
321
|
channel: string | null;
|
|
322
|
+
/** VAT/tax info attached to the QR, if any. */
|
|
323
|
+
vat: BrebDecodedQrVat | null;
|
|
324
|
+
/** Tip ("propina"/INC) info attached to the QR, if any. */
|
|
325
|
+
inc: BrebDecodedQrInc | null;
|
|
313
326
|
qrCodeReference: string | null;
|
|
314
327
|
type: string | null;
|
|
315
328
|
resolutionId: string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
-
import type { AccountWithBalance, CardDetails, TokenBalance } from '../internal/wire-types';
|
|
2
|
+
import type { AccountStatus, AccountWithBalance, CardDetails, TokenBalance } from '../internal/wire-types';
|
|
3
3
|
import type { CreateAccountOptions } from '../types';
|
|
4
|
-
import type { CardAccount, CreateCardParams, GetBalanceParams, ListCardAccountsParams, ListCardAccountsResult, ListMovementsPagedResult, ListMovementsParams, TokenizeAppleParams, TokenizeAppleResult, TokenizeGoogleParams, TokenizeGoogleResult, UpdateCardMetadataParams, UpdateCardParams } from './types';
|
|
4
|
+
import type { CardAccount, CardStatusReason, CreateCardParams, GetBalanceParams, ListCardAccountsParams, ListCardAccountsResult, ListMovementsPagedResult, ListMovementsParams, TokenizeAppleParams, TokenizeAppleResult, TokenizeGoogleParams, TokenizeGoogleResult, UpdateCardMetadataParams, UpdateCardParams } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* Maps a wire card account to the SDK CardAccount type.
|
|
7
7
|
* Exported so AccountsClient.get() can dispatch by medium.
|
|
@@ -182,6 +182,21 @@ export declare class CardClient extends BaseClient {
|
|
|
182
182
|
* ```
|
|
183
183
|
*/
|
|
184
184
|
activate(urn: string): Promise<CardAccount>;
|
|
185
|
+
/**
|
|
186
|
+
* Freeze, disable, or activate a card account with a reason attached
|
|
187
|
+
* (e.g. `'LOST'`, `'STOLEN'`, `'BROKEN'`). Use this instead of
|
|
188
|
+
* `freeze()`/`disable()`/`activate()` when you want the reason recorded.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const card = await bloque.accounts.card.updateStatus(
|
|
193
|
+
* 'did:bloque:mediums:card:account:123',
|
|
194
|
+
* 'disabled',
|
|
195
|
+
* 'STOLEN',
|
|
196
|
+
* );
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
updateStatus(urn: string, status: AccountStatus, statusReason?: CardStatusReason): Promise<CardAccount>;
|
|
185
200
|
/**
|
|
186
201
|
* Freeze a card account
|
|
187
202
|
*
|
package/dist/card/types.d.ts
CHANGED
|
@@ -108,6 +108,84 @@ export interface GetBalanceParams {
|
|
|
108
108
|
*/
|
|
109
109
|
urn: string;
|
|
110
110
|
}
|
|
111
|
+
/** `'default'` routes every purchase to one pocket. `'smart'` routes by MCC across multiple pockets. */
|
|
112
|
+
export type SpendingControlMode = 'default' | 'smart';
|
|
113
|
+
/** A URL (fetched and cached ~10 min) or an inline array of MCC codes. */
|
|
114
|
+
export type MccWhitelistSource = string | string[];
|
|
115
|
+
/** Maps a pocket URN to the MCC codes it accepts. Smart spending control only. */
|
|
116
|
+
export type MccWhitelist = Record<string, MccWhitelistSource>;
|
|
117
|
+
/** Maps an ISO 4217 currency code to preferred settlement assets, in priority order. */
|
|
118
|
+
export type CurrencyAssetMap = Record<string, SupportedAsset[]>;
|
|
119
|
+
export type CashbackProgramType = 'extra_savings' | 'round_up';
|
|
120
|
+
export type CashbackFeeType = 'percentage' | 'flat';
|
|
121
|
+
/**
|
|
122
|
+
* An automatic savings program that creates surcharge movements on card
|
|
123
|
+
* transactions. `extra_savings` charges an extra percentage/flat amount per
|
|
124
|
+
* transaction; `round_up` rounds the transaction up, routing the delta to
|
|
125
|
+
* `targetPocketUrn`. Reported via the `cashback_surcharge` webhook event.
|
|
126
|
+
*/
|
|
127
|
+
export interface CashbackProgram {
|
|
128
|
+
programName: string;
|
|
129
|
+
type: CashbackProgramType;
|
|
130
|
+
targetPocketUrn: string;
|
|
131
|
+
/** Required for `'extra_savings'`; ignored for `'round_up'`. */
|
|
132
|
+
feeType?: CashbackFeeType;
|
|
133
|
+
/** Percentage rate (e.g. `0.05` = 5%) or flat local-currency amount. */
|
|
134
|
+
value?: number;
|
|
135
|
+
}
|
|
136
|
+
export type SpendingFeeType = 'percentage' | 'flat';
|
|
137
|
+
export type SpendingFeeCategory = 'fx' | 'interchange' | 'custom';
|
|
138
|
+
/**
|
|
139
|
+
* A fee applied to card transactions. Merged by `feeName` across three
|
|
140
|
+
* layers: defaults → origin metadata → card metadata. Base fees cannot be
|
|
141
|
+
* removed, only overridden.
|
|
142
|
+
*/
|
|
143
|
+
export interface SpendingFee {
|
|
144
|
+
/** Unique name for the fee, e.g. `"bloque-treasury"`, `"fx_fee"`. */
|
|
145
|
+
feeName: string;
|
|
146
|
+
/** Destination account URN for the fee. */
|
|
147
|
+
accountUrn: string;
|
|
148
|
+
type: SpendingFeeType;
|
|
149
|
+
/** Rate for `'percentage'` (`0.0144` = 1.44%) or a flat scaled amount. */
|
|
150
|
+
value: number;
|
|
151
|
+
/** Purpose of the fee — `'fx'` drives the exchange-rate spread. Defaults to `'custom'`. */
|
|
152
|
+
category?: SpendingFeeCategory;
|
|
153
|
+
/** Gates when this fee applies, e.g. `'fx_conversion'`, `'amount_range_usd'`, `'wallet'`. Always applies if omitted. */
|
|
154
|
+
rule?: string;
|
|
155
|
+
ruleParams?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
export interface CardSpendingControlMetadata {
|
|
158
|
+
/** `'default'` (one pocket, all merchants) or `'smart'` (MCC-based multi-pocket routing). */
|
|
159
|
+
spendingControl?: SpendingControlMode;
|
|
160
|
+
/** Pocket URNs in priority order. Smart spending control only. */
|
|
161
|
+
priorityMcc?: string[];
|
|
162
|
+
/** Pocket URN → accepted MCC codes. Smart spending control only. */
|
|
163
|
+
mccWhitelist?: MccWhitelist;
|
|
164
|
+
/** Automatic savings programs — interchange share, extra savings, or round-up. */
|
|
165
|
+
cashbackPrograms?: CashbackProgram[];
|
|
166
|
+
/** Fee overrides, merged by `feeName` on top of the defaults. */
|
|
167
|
+
spendingFees?: SpendingFee[];
|
|
168
|
+
/** Asset to fall back to when `defaultAsset`/currency matching can't resolve one. */
|
|
169
|
+
fallbackAsset?: SupportedAsset;
|
|
170
|
+
/** Whether to send a WhatsApp notification on purchase. Defaults to enabled. */
|
|
171
|
+
whatsappNotification?: boolean;
|
|
172
|
+
/** ISO 4217 currency code → preferred settlement assets, for direct-match resolution. */
|
|
173
|
+
currencyAssetMap?: CurrencyAssetMap;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Mailing address for a physical card. All fields required by the provider.
|
|
177
|
+
*/
|
|
178
|
+
export interface CardMailingAddress {
|
|
179
|
+
streetName: string;
|
|
180
|
+
streetNumber: string;
|
|
181
|
+
floor: string;
|
|
182
|
+
apartment: string;
|
|
183
|
+
city: string;
|
|
184
|
+
region: string;
|
|
185
|
+
country: string;
|
|
186
|
+
zipCode: string;
|
|
187
|
+
neighborhood: string;
|
|
188
|
+
}
|
|
111
189
|
export interface CreateCardParams {
|
|
112
190
|
/**
|
|
113
191
|
* URN of the account holder (user or organization)
|
|
@@ -119,6 +197,16 @@ export interface CreateCardParams {
|
|
|
119
197
|
* Display name for the card
|
|
120
198
|
*/
|
|
121
199
|
name?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Card type to create.
|
|
202
|
+
* @default "VIRTUAL"
|
|
203
|
+
*/
|
|
204
|
+
cardType?: CardType;
|
|
205
|
+
/**
|
|
206
|
+
* Mailing address for the physical card. Required when `cardType` is
|
|
207
|
+
* `"PHYSICAL"`.
|
|
208
|
+
*/
|
|
209
|
+
cardAddress?: CardMailingAddress;
|
|
122
210
|
/**
|
|
123
211
|
* Webhook URL to receive card events
|
|
124
212
|
*/
|
|
@@ -140,11 +228,19 @@ export interface CreateCardParams {
|
|
|
140
228
|
* @example "DUSD/6"
|
|
141
229
|
*/
|
|
142
230
|
defaultAsset?: SupportedAsset;
|
|
231
|
+
/**
|
|
232
|
+
* Spending-control, cashback, and fee configuration. Each field is
|
|
233
|
+
* stored under its own `metadata` key and takes precedence over the
|
|
234
|
+
* same key passed via a raw `metadata` object.
|
|
235
|
+
*/
|
|
236
|
+
spendingControlMetadata?: CardSpendingControlMetadata;
|
|
143
237
|
/**
|
|
144
238
|
* Custom metadata to associate with the card
|
|
145
239
|
*/
|
|
146
240
|
metadata?: Record<string, unknown>;
|
|
147
241
|
}
|
|
242
|
+
/** Reason accompanying a card status change or PIN update. */
|
|
243
|
+
export type CardStatusReason = 'CLIENT_INTERNAL_REASON' | 'USER_INTERNAL_REASON' | 'POMELO_INTERNAL_REASON' | 'PROVIDER_INTERNAL_REASON' | 'LOST' | 'STOLEN' | 'BROKEN' | 'UPGRADE';
|
|
148
244
|
export interface UpdateCardParams {
|
|
149
245
|
/** URN of the card account to update */
|
|
150
246
|
urn: string;
|
|
@@ -152,6 +248,10 @@ export interface UpdateCardParams {
|
|
|
152
248
|
metadata?: Record<string, unknown>;
|
|
153
249
|
/** Account status */
|
|
154
250
|
status?: string;
|
|
251
|
+
/** Reason for the status change, e.g. `'LOST'` or `'STOLEN'` when freezing/disabling. */
|
|
252
|
+
statusReason?: CardStatusReason;
|
|
253
|
+
/** Set or change the card's PIN. */
|
|
254
|
+
pin?: string;
|
|
155
255
|
/** Webhook URL for card events */
|
|
156
256
|
webhookUrl?: string;
|
|
157
257
|
/** Ledger account ID to link */
|
|
@@ -171,9 +271,15 @@ export interface UpdateCardMetadataParams {
|
|
|
171
271
|
* @example "DUSD/6"
|
|
172
272
|
*/
|
|
173
273
|
defaultAsset?: SupportedAsset;
|
|
274
|
+
/**
|
|
275
|
+
* Spending-control, cashback, and fee configuration. Each field is
|
|
276
|
+
* stored under its own `metadata` key and takes precedence over the
|
|
277
|
+
* same key passed via a raw `metadata` object.
|
|
278
|
+
*/
|
|
279
|
+
spendingControlMetadata?: CardSpendingControlMetadata;
|
|
174
280
|
/**
|
|
175
281
|
* Metadata to update (name and source are reserved fields and cannot be modified).
|
|
176
|
-
* Optional when `defaultAsset` is provided on its own.
|
|
282
|
+
* Optional when `defaultAsset`/`spendingControlMetadata` is provided on its own.
|
|
177
283
|
*/
|
|
178
284
|
metadata?: Record<string, unknown> & {
|
|
179
285
|
name?: never;
|
|
@@ -246,9 +352,15 @@ export interface CardAccount {
|
|
|
246
352
|
*/
|
|
247
353
|
cardType: CardType;
|
|
248
354
|
/**
|
|
249
|
-
*
|
|
355
|
+
* Reason for the current status, if one was supplied on the last status
|
|
356
|
+
* update (e.g. `'LOST'`, `'STOLEN'`).
|
|
357
|
+
*/
|
|
358
|
+
statusReason?: CardStatusReason;
|
|
359
|
+
/**
|
|
360
|
+
* URL to view card details (PCI-compliant). `null` when the card is
|
|
361
|
+
* blocked.
|
|
250
362
|
*/
|
|
251
|
-
detailsUrl: string;
|
|
363
|
+
detailsUrl: string | null;
|
|
252
364
|
/**
|
|
253
365
|
* Owner URN
|
|
254
366
|
*/
|
|
@@ -271,6 +383,11 @@ export interface CardAccount {
|
|
|
271
383
|
* @example "DUSD/6"
|
|
272
384
|
*/
|
|
273
385
|
defaultAsset?: SupportedAsset;
|
|
386
|
+
/**
|
|
387
|
+
* Spending-control, cashback, and fee configuration, read back from
|
|
388
|
+
* `metadata` for convenience. `undefined` when none of those keys are set.
|
|
389
|
+
*/
|
|
390
|
+
spendingControlMetadata?: CardSpendingControlMetadata;
|
|
274
391
|
/**
|
|
275
392
|
* Creation timestamp
|
|
276
393
|
*/
|
|
@@ -284,3 +401,81 @@ export interface CardAccount {
|
|
|
284
401
|
*/
|
|
285
402
|
balance?: Record<string, TokenBalance>;
|
|
286
403
|
}
|
|
404
|
+
/** Underlying card-network transaction type. */
|
|
405
|
+
export type CardTransactionType = 'PURCHASE' | 'WITHDRAWAL' | 'EXTRACASH' | 'BALANCE_INQUIRY' | 'PAYMENT' | 'REFUND' | 'REVERSAL_PURCHASE' | 'REVERSAL_WITHDRAWAL' | 'REVERSAL_EXTRACASH' | 'REVERSAL_BALANCE_INQUIRY' | 'REVERSAL_REFUND' | 'REVERSAL_PAYMENT';
|
|
406
|
+
/** Where the transaction currently sits in its authorization/settlement lifecycle. */
|
|
407
|
+
export type CardLifecycleStatus = 'pending_authorization' | 'captured' | 'authorization_reversed' | 'refunded' | 'payment_reversed' | 'refund_reversed';
|
|
408
|
+
export interface CardMerchantInfo {
|
|
409
|
+
id: string;
|
|
410
|
+
name: string;
|
|
411
|
+
/** Merchant category code. */
|
|
412
|
+
mcc: string;
|
|
413
|
+
address: string | null;
|
|
414
|
+
city: string | null;
|
|
415
|
+
country: string | null;
|
|
416
|
+
terminalId?: string;
|
|
417
|
+
}
|
|
418
|
+
/** How the card was presented/used for this transaction. */
|
|
419
|
+
export interface CardTransactionMedium {
|
|
420
|
+
entryMode: 'MANUAL' | 'CHIP' | 'CONTACTLESS' | 'CREDENTIAL_ON_FILE' | 'MAG_STRIPE' | 'CARDLESS' | 'OTHER' | 'UNKNOWN';
|
|
421
|
+
pointType: 'ECOMMERCE' | 'POS' | 'ATM' | 'MOTO';
|
|
422
|
+
origin: 'DOMESTIC' | 'INTERNATIONAL';
|
|
423
|
+
network?: 'MASTERCARD' | 'VISA' | 'SERVIBANCA' | 'PROSA';
|
|
424
|
+
source?: 'ONLINE' | 'CLEARING' | 'PURGE' | 'MANUAL' | 'CHARGEBACK_MANUAL' | 'TRUST_CREDIT_MANUAL';
|
|
425
|
+
cardPresence?: 'PRESENT' | 'NOT_PRESENT';
|
|
426
|
+
cardholderPresence?: 'CARDHOLDER_PRESENCE_PRESENT' | 'NOT_PRESENT' | 'NOT_PRESENT_MOTO' | 'NOT_PRESENT_ARU' | 'RECURRING_TRANSACTION' | 'NOT_PRESENT_ECOMMERCE';
|
|
427
|
+
cardholderVerificationMethod?: string;
|
|
428
|
+
pinPresence?: 'ONLINE' | 'OFFLINE' | 'NOT_PRESENT';
|
|
429
|
+
pinValidation?: 'VALID' | 'NOT_VALID';
|
|
430
|
+
cvvPresence?: 'PRESENT' | 'NOT_PRESENT';
|
|
431
|
+
cvvValidation?: 'MATCHING' | 'NOT_MATCHING' | 'NOT_PROCESSED';
|
|
432
|
+
tokenizationWalletName?: string | null;
|
|
433
|
+
tokenizationWalletId?: string | null;
|
|
434
|
+
}
|
|
435
|
+
export interface CardFeeBreakdownEntry {
|
|
436
|
+
feeName: string;
|
|
437
|
+
amount: string;
|
|
438
|
+
rate: number;
|
|
439
|
+
}
|
|
440
|
+
export interface CardFeeBreakdown {
|
|
441
|
+
total: string;
|
|
442
|
+
fees: CardFeeBreakdownEntry[];
|
|
443
|
+
settlement: string;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Body POSTed to the card account's `webhookUrl` on every authorization or
|
|
447
|
+
* adjustment. Signed the same way as other Bloque webhooks — verify it
|
|
448
|
+
* before trusting the payload.
|
|
449
|
+
*/
|
|
450
|
+
export interface CardWebhookPayload {
|
|
451
|
+
accountUrn: string;
|
|
452
|
+
transactionId: string;
|
|
453
|
+
/** `'authorization'` for the initial hold, `'adjustment'` for everything after. */
|
|
454
|
+
type: 'authorization' | 'adjustment';
|
|
455
|
+
direction: 'debit' | 'credit';
|
|
456
|
+
event: 'purchase' | 'rejected_insufficient_funds' | 'rejected_credit' | 'rejected_currency' | 'credit_adjustment' | 'debit_adjustment' | 'cashback_surcharge';
|
|
457
|
+
lifecycleStatus?: CardLifecycleStatus;
|
|
458
|
+
transactionType?: CardTransactionType;
|
|
459
|
+
/** Scaled bigint string at `asset`'s precision. */
|
|
460
|
+
amount?: string;
|
|
461
|
+
asset?: SupportedAsset;
|
|
462
|
+
/** Amount in the transaction's original currency. */
|
|
463
|
+
localAmount?: number;
|
|
464
|
+
/** ISO 4217 currency code, e.g. `"COP"`, `"USD"`. */
|
|
465
|
+
localCurrency?: string;
|
|
466
|
+
exchangeRate?: number;
|
|
467
|
+
merchant?: CardMerchantInfo;
|
|
468
|
+
medium?: CardTransactionMedium;
|
|
469
|
+
feeBreakdown?: CardFeeBreakdown;
|
|
470
|
+
/** Present on `rejected_*` events. */
|
|
471
|
+
reason?: string;
|
|
472
|
+
/** Present on `cashback_surcharge`. */
|
|
473
|
+
requiredUsd?: number;
|
|
474
|
+
currency?: string;
|
|
475
|
+
surchargeTotal?: number;
|
|
476
|
+
programs?: Array<{
|
|
477
|
+
name: string;
|
|
478
|
+
type: string;
|
|
479
|
+
amount: number;
|
|
480
|
+
}>;
|
|
481
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{mapUs2AccountFromWire:()=>mapUs2AccountFromWire,mapBrebAccountFromWire:()=>mapBrebAccountFromWire,mapUsAccountFromWire:()=>mapUsAccountFromWire,mapBancolombiaAccountFromWire:()=>mapBancolombiaAccountFromWire,mapVirtualAccountFromWire:()=>mapVirtualAccountFromWire,VirtualClient:()=>VirtualClient,BancolombiaClient:()=>BancolombiaClient,mapExternalUsBankAccountFromWire:()=>mapExternalUsBankAccountFromWire,ExternalUsBankClient:()=>ExternalUsBankClient,AccountsClient:()=>AccountsClient,PolygonClient:()=>PolygonClient,UsClient:()=>UsClient,CardClient:()=>CardClient,mapCardAccountFromWire:()=>mapCardAccountFromWire,mapPolygonAccountFromWire:()=>mapPolygonAccountFromWire,Us2Client:()=>Us2Client,BrebClient:()=>BrebClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");function mapBancolombiaAccountFromWire(e){return{urn:e.urn,id:e.id,referenceCode:e.details.reference_code,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e={},t){let a={holder_urn:e?.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapBancolombiaAccountFromWire(e)}}function mapBrebAccountFromWire(e){return{id:e.id,urn:e.urn,ownerUrn:e.owner_urn,medium:"breb",remoteKeyId:e.details.remote_key_id,accountId:e.details.account_id,keyType:e.details.key.key_type,key:e.details.key.key_value,displayName:e.details.display_name??null,status:e.status,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,details:e.details,balance:"balance"in e&&e.balance?e.balance:void 0}}function mapDecodedQrFromWire(e){return{amount:e.amount,additionalInfo:e.additional_info?{transactionPurpose:e.additional_info.transaction_purpose,terminalLabel:e.additional_info.terminal_label,invoiceNumber:e.additional_info.invoice_number,mobilePhoneNumber:e.additional_info.mobile_phone_number,storeLabel:e.additional_info.store_label,loyaltyLabel:e.additional_info.loyalty_label,referenceLabel:e.additional_info.reference_label,customerLabel:e.additional_info.customer_label,customerInfo:e.additional_info.customer_info,channelPresentation:e.additional_info.channel_presentation}:null,key:e.key?{keyType:e.key.key_type,keyValue:e.key.key_value}:null,qrCodeData:e.qr_code_data,status:e.status,acquirerNetworkIdentifier:e.acquirer_network_identifier,merchant:e.merchant?{merchantCategoryCode:e.merchant.merchant_category_code,merchantCountry:e.merchant.merchant_country,merchantName:e.merchant.merchant_name,merchantCity:e.merchant.merchant_city,merchantPostCode:e.merchant.merchant_post_code}:null,channel:e.channel,qrCodeReference:e.qr_code_reference,type:e.type,resolutionId:e.resolution_id,resolution:e.resolution}}class BrebClient extends sdk_core_namespaceObject.BaseClient{mapError(e){if(e instanceof sdk_core_namespaceObject.BloqueAPIError){let t=e.response;return{code:t?.extra_details?.provider_code??e.code??null,message:e.message}}return e instanceof Error?{code:null,message:e.message}:{code:null,message:"Unknown BRE-B error"}}async createKey(e){try{let t=this.httpClient.urn;if(!t?.trim())throw Error("Holder URN is required");if(!e.key?.trim())throw Error("BRE-B key value is required");let a=await this.httpClient.request({method:"POST",path:"/api/mediums/breb",body:{holder_urn:t,input:{key_type:e.keyType,key_value:e.key,display_name:e.displayName},webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,metadata:{source:"sdk-typescript",...e.metadata}}});return{data:mapBrebAccountFromWire(a.result.account),error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async resolveKey(e){try{if(!e.key?.trim())throw Error("BRE-B key value is required");return{data:(await this.httpClient.request({method:"POST",path:"/api/mediums/breb/resolve-key",body:{...e.keyType&&{key_type:e.keyType},key:e.key}})).result,error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async decodeQr(e){try{if(!e.qrCodeData?.trim())throw Error("BRE-B QR code data is required");let t=await this.httpClient.request({method:"POST",path:"/api/mediums/breb/decode-qr",body:{qr_code_data:e.qrCodeData}});return{data:mapDecodedQrFromWire(t.result),error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async deleteKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"deleted"}});return{data:{deleted:!0,accountUrn:t.result.account.urn,keyId:t.result.account.details.id,status:"deleted"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async suspendKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"frozen"}});return{data:{accountUrn:t.result.account.urn,keyId:t.result.account.details.id,keyStatus:t.result.account.details.status,status:"frozen"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async activateKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"active"}});return{data:{accountUrn:t.result.account.urn,keyId:t.result.account.details.id,keyStatus:t.result.account.details.status,status:"active"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}}function mapCardAccountFromWire(e){let t=e.metadata?.default_asset;return{urn:e.urn,id:e.id,program:e.medium,lastFour:e.details.card_last_four,productType:e.details.card_product_type,status:e.status,cardType:e.details.card_type,detailsUrl:e.details.card_url_details,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,defaultAsset:"string"==typeof t&&(0,sdk_core_namespaceObject.isSupportedAsset)(t)?t:void 0,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(e={},t){if(e.defaultAsset&&!(0,sdk_core_namespaceObject.isSupportedAsset)(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=e.program||"card",r={holder_urn:e?.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:e.name,...e.metadata,...e.defaultAsset&&{default_asset:e.defaultAsset}}},n=await this.httpClient.request({method:"POST",path:`/api/mediums/${a}`,body:r,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),o=this._mapAccountResponse(n.result.account);return t?.waitLedger?this._waitForActiveStatus(o.urn,t.timeout||6e4,a):o}async _waitForActiveStatus(e,t,a){let r=Date.now();for(;;){if(Date.now()-r>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let n=(await this.list({urn:e,program:a})).accounts[0];if(!n)throw Error(`Account not found. URN: ${e}`);if("active"===n.status)return n;if("creation_failed"===n.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=e?.program||"card",r=new URLSearchParams;r.append("medium",a),t&&r.append("holder_urn",t),e?.urn&&r.append("urn",e.urn);let n=`/api/accounts?${r.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(mapCardAccountFromWire)}}async movements(e){let t=new URLSearchParams,a=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(a))throw Error(`Invalid asset type "${a}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);t.set("asset",a),void 0!==e.limit&&t.set("limit",e.limit.toString()),e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.reference&&t.set("reference",e.reference),e.direction&&t.set("direction",e.direction),void 0!==e.collapsed_view&&t.set("collapsed_view",String(e.collapsed_view)),e.pocket&&t.set("pocket",e.pocket),e.next&&t.set("next",e.next);let r=t.toString(),n=`/api/accounts/${e.urn}/movements${r?`?${r}`:""}`,o=await this.httpClient.request({method:"GET",path:n});return{data:o.data,pageSize:o.page_size,hasMore:o.has_more,next:o.next}}async balance(e){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e.urn}/balance`})).balance}async update(e){let t={...e.metadata&&{metadata:e.metadata},...e.status&&{status:e.status},...e.webhookUrl&&{webhook_url:e.webhookUrl},...e.ledgerId&&{ledger_account_id:e.ledgerId}},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateMetadata(e){if(e.defaultAsset&&!(0,sdk_core_namespaceObject.isSupportedAsset)(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);if(!e.metadata&&!e.defaultAsset)throw Error("updateMetadata requires either `metadata` or `defaultAsset`");let t={metadata:{...e.metadata,...e.defaultAsset&&{default_asset:e.defaultAsset}}},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async tokenizeApple(e,t){let a={certificates:t.certificates,nonce:t.nonce,nonce_signature:t.nonceSignature},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${e}/tokenize/apple`,body:a});return{activationData:r.result.tokenization.activation_data,encryptedPassData:r.result.tokenization.encrypted_pass_data,ephemeralPublicKey:r.result.tokenization.ephemeral_public_key}}async tokenizeGoogle(e,t){let a={device_id:t.deviceId,wallet_account_id:t.walletAccountId};return{opc:(await this.httpClient.request({method:"POST",path:`/api/accounts/${e}/tokenize/google`,body:a})).result.tokenization.opc}}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapCardAccountFromWire(e)}}function mapBankAddressFromWire(e){if(e)return{streetLine1:e.street_line_1,...void 0!==e.street_line_2?{streetLine2:e.street_line_2}:{},city:e.city,state:e.state,zip:e.zip,...void 0!==e.country?{country:e.country}:{}}}function mapExternalUsBankAccountFromWire(e){return{urn:e.urn,id:e.id,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance,details:{id:e.details.id,linkStatus:e.details.link_status,braleAccountId:e.details.brale_account_id,braleAddressId:e.details.brale_address_id,linkToken:e.details.link_token,linkTokenExpiration:e.details.link_token_expiration,linkUrl:e.details.link_url,jwt:e.details.jwt,bankAccountLast4:e.details.bank_account_last4,bankName:e.details.bank_name,failureReason:e.details.failure_reason,owner:e.details.owner,routingNumber:e.details.routing_number,accountNumber:e.details.account_number,accountType:e.details.account_type,bankAddress:mapBankAddressFromWire(e.details.bank_address),beneficiaryAddress:mapBankAddressFromWire(e.details.beneficiary_address),transferTypes:e.details.transfer_types,needsUpdate:e.details.needs_update,lastUpdated:e.details.last_updated}}}class ExternalUsBankClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{label:e.label,...void 0!==e.returnUrl?{return_url:e.returnUrl}:{},...void 0!==e.state?{state:e.state}:{}},metadata:{source:"sdk-typescript",...e.metadata}};return mapExternalUsBankAccountFromWire((await this.httpClient.request({method:"POST",path:"/api/mediums/external-us-bank",body:a})).result.account)}async exchangePublicToken(e){let t={input:{public_token:e.publicToken}};return mapExternalUsBankAccountFromWire((await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t})).result.account)}async pull(e){if(!e?.urn?.trim())throw Error("Bank account URN is required");if("string"!=typeof e.amount||""===e.amount.trim())throw Error('Amount is required and must be a string (e.g. "100.00")');let t=e.idempotencyKey??(void 0!==globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`idem_${Date.now()}_${Math.random().toString(36).slice(2)}`),a={amount:e.amount,idempotency_key:t},r=await this.httpClient.request({method:"POST",path:`/api/mediums/external-us-bank/${encodeURIComponent(e.urn)}/pull`,body:a,headers:{"Idempotency-Key":t}});return{orderSig:r.result?.order_sig,graphId:r.result?.graph_id,status:r.result?.status,execution:r.result?.execution,requestId:r.req_id}}}function mapPolygonAccountFromWire(e){return{urn:e.urn,id:e.id,address:e.details.address,network:e.details.network,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class PolygonClient extends sdk_core_namespaceObject.BaseClient{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e={},t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapPolygonAccountFromWire(e)}}function mapUsAccountFromWire(e){return{urn:e.urn,id:e.id,type:e.details.type,firstName:e.details.first_name,middleName:e.details.middle_name,lastName:e.details.last_name,email:e.details.email,phone:e.details.phone,address:{streetLine1:e.details.address.street_line_1,streetLine2:e.details.address.street_line_2,city:e.details.address.city,state:e.details.address.state,postalCode:e.details.address.postal_code,country:e.details.address.country},birthDate:e.details.birth_date,accountNumber:e.details.account_number,routingNumber:e.details.routing_number,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}}class UsClient extends sdk_core_namespaceObject.BaseClient{async getTosLink(e){let t=new URLSearchParams({redirect_uri:e.redirectUri}),a=(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${t.toString()}`})).result.url;try{let t=new URL(a);t.searchParams.has("redirect_uri")||(t.searchParams.set("redirect_uri",e.redirectUri),a=t.toString())}catch{let t=a.includes("?")?"&":"?";/[?&]redirect_uri=/.test(a)||(a=`${a}${t}redirect_uri=${encodeURIComponent(e.redirectUri)}`)}return{url:a}}async create(e,t){let a={street_line_1:e.address.streetLine1,street_line_2:e.address.streetLine2,city:e.address.city,state:e.address.state,postal_code:e.address.postalCode,country:e.address.country},r={type:e.type,first_name:e.firstName,middle_name:e.middleName,last_name:e.lastName,email:e.email,phone:e.phone,address:a,birth_date:e.birthDate,tax_identification_number:e.taxIdentificationNumber,gov_id_country:e.govIdCountry,gov_id_image_front:e.govIdImageFront,signed_agreement_id:e.signedAgreementId},n={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:r,metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},o=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:n,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),s=this._mapAccountResponse(o.result.account);return t?.waitLedger?this._waitForActiveStatus(s.urn,t.timeout||6e4):s}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({urn:e.urn,id:e.id,type:e.details.type,firstName:e.details.first_name,middleName:e.details.middle_name,lastName:e.details.last_name,email:e.details.email,phone:e.details.phone,address:{streetLine1:e.details.address.street_line_1,streetLine2:e.details.address.street_line_2,city:e.details.address.city,state:e.details.address.state,postalCode:e.details.address.postal_code,country:e.details.address.country},birthDate:e.details.birth_date,accountNumber:e.details.account_number,routingNumber:e.details.routing_number,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapUsAccountFromWire(e)}}function mapUs2AccountFromWire(e){return{urn:e.urn,id:e.id,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance,details:{id:e.details.id,userId:e.details.user_id,virtualAccountId:e.details.virtual_account_id,type:e.details.type,currency:e.details.currency}}}class Us2Client extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a={type:e.type,email:e.email,phone:e.phone,proof_of_address:e.proofOfAddress,business_formation_document:e.businessFormationDocument,tax_id:e.taxId,address:e.address?{street:e.address.street,city:e.address.city,state:e.address.state,postal_code:e.address.postalCode,country:e.address.country}:void 0},r={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:a,metadata:{source:"sdk-typescript",...e.metadata}};return mapUs2AccountFromWire((await this.httpClient.request({method:"POST",path:"/api/mediums/us2-account",body:r})).result.account)}async list(e={}){let t=e.holderUrn||this.httpClient.urn,a=new URLSearchParams;return a.append("medium","us2-account"),t&&a.append("holder_urn",t),e.urn&&a.append("urn",e.urn),{accounts:(await this.httpClient.request({method:"GET",path:`/api/accounts?${a.toString()}`})).accounts.map(e=>mapUs2AccountFromWire(e))}}}function mapVirtualAccountFromWire(e){return{urn:e.urn,id:e.id,firstName:e.details.first_name,lastName:e.details.last_name,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class VirtualClient extends sdk_core_namespaceObject.BaseClient{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e,t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapVirtualAccountFromWire(e)}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;breb;card;externalUsBank;polygon;us;us2;virtual;constructor(e){super(e),this.bancolombia=new BancolombiaClient(this.httpClient),this.breb=new BrebClient(this.httpClient),this.card=new CardClient(this.httpClient),this.externalUsBank=new ExternalUsBankClient(this.httpClient),this.polygon=new PolygonClient(this.httpClient),this.us=new UsClient(this.httpClient),this.us2=new Us2Client(this.httpClient),this.virtual=new VirtualClient(this.httpClient)}async balance(e){if(!e?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e}/balance`})).balance}async balances(){return(await this.httpClient.request({method:"GET",path:"/api/accounts/balances"})).balance}async get(e){if(!e?.trim())throw Error("Account URN is required");let t=await this.httpClient.request({method:"GET",path:`/api/accounts/${e}`});return this._mapByMedium(t.account)}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;t&&a.append("holder_urn",t);let r=a.toString(),n=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(e=>this._mapByMedium(e))}}async transfer(e,t){let a=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(a))throw Error(`Invalid asset type "${a}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let r={destination_account_urn:e.destinationUrn,amount:e.amount,asset:a,metadata:e.metadata},n=await this.httpClient.request({method:"POST",path:`/api/accounts/${e.sourceUrn}/transfer`,body:r,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{queueId:n.result.queue_id,status:n.result.status,message:n.result.message}}async batchTransfer(e,t){if(!e.operations||0===e.operations.length)throw Error("At least one operation is required");if(!e.reference)throw Error("Batch reference is required");for(let t of e.operations)if(!(0,sdk_core_namespaceObject.isSupportedAsset)(t.asset))throw Error(`Invalid asset type "${t.asset}" in operation "${t.reference}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a={operations:e.operations.map(e=>({from_account_urn:e.fromUrn,to_account_urn:e.toUrn,reference:e.reference,amount:e.amount,asset:e.asset,metadata:e.metadata})),reference:e.reference,metadata:e.metadata,webhook_url:e.webhookUrl},r=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{chunks:r.result.chunks.map(e=>({queueId:e.queue_id,status:e.status,message:e.message})),totalOperations:r.result.total_operations,totalChunks:r.result.total_chunks}}async movements(e){if(!e.urn)throw Error("Account URN is required");let t=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(t))throw Error(`Invalid asset type "${t}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=new URLSearchParams;a.set("asset",t),void 0!==e.limit&&a.set("limit",e.limit.toString()),e.before&&a.set("before",e.before),e.after&&a.set("after",e.after),e.reference&&a.set("reference",e.reference),e.direction&&a.set("direction",e.direction),void 0!==e.collapsed_view&&a.set("collapsed_view",String(e.collapsed_view)),e.pocket&&a.set("pocket",e.pocket),e.next&&a.set("next",e.next);let r=`/api/accounts/${e.urn}/movements?${a.toString()}`,n=await this.httpClient.request({method:"GET",path:r});return{data:n.data.map(e=>({amount:e.amount,asset:e.asset,fromAccountId:e.from_account_id,toAccountId:e.to_account_id,direction:e.direction,type:e.type,reference:e.reference,status:e.status,railName:e.rail_name,details:e.details,createdAt:e.created_at})),pageSize:n.page_size,hasMore:n.has_more,next:n.next}}async transactions(e={}){let t=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(t))throw Error(`Invalid asset type "${t}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=new URLSearchParams;a.set("asset",t),void 0!==e.limit&&a.set("limit",e.limit.toString()),e.before&&a.set("before",e.before),e.after&&a.set("after",e.after),e.reference&&a.set("reference",e.reference),e.direction&&a.set("direction",e.direction),void 0!==e.collapsed_view&&a.set("collapsed_view",String(e.collapsed_view)),e.pocket&&a.set("pocket",e.pocket),e.next&&a.set("next",e.next);let r=await this.httpClient.request({method:"GET",path:`/api/accounts/transactions?${a.toString()}`});return{data:r.data.map(e=>({amount:e.amount,asset:e.asset,fromAccountId:e.from_account_id,toAccountId:e.to_account_id,direction:e.direction,reference:e.reference,status:e.status,railName:e.rail_name,details:e.details??{},createdAt:e.created_at,type:e.type})),pageSize:r.page_size,hasMore:r.has_more,next:r.next}}_mapByMedium(e){let t=e.medium;if("card"===t||t.startsWith("card-"))return mapCardAccountFromWire(e);switch(t){case"virtual":return mapVirtualAccountFromWire(e);case"polygon":return mapPolygonAccountFromWire(e);case"bancolombia":return mapBancolombiaAccountFromWire(e);case"breb":return mapBrebAccountFromWire(e);case"external-us-bank":return mapExternalUsBankAccountFromWire(e);case"us-account":return mapUsAccountFromWire(e);case"us2-account":return mapUs2AccountFromWire(e);default:throw Error(`Unknown account medium: ${e.medium}`)}}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.BrebClient=__webpack_exports__.BrebClient,exports.CardClient=__webpack_exports__.CardClient,exports.ExternalUsBankClient=__webpack_exports__.ExternalUsBankClient,exports.PolygonClient=__webpack_exports__.PolygonClient,exports.Us2Client=__webpack_exports__.Us2Client,exports.UsClient=__webpack_exports__.UsClient,exports.VirtualClient=__webpack_exports__.VirtualClient,exports.mapBancolombiaAccountFromWire=__webpack_exports__.mapBancolombiaAccountFromWire,exports.mapBrebAccountFromWire=__webpack_exports__.mapBrebAccountFromWire,exports.mapCardAccountFromWire=__webpack_exports__.mapCardAccountFromWire,exports.mapExternalUsBankAccountFromWire=__webpack_exports__.mapExternalUsBankAccountFromWire,exports.mapPolygonAccountFromWire=__webpack_exports__.mapPolygonAccountFromWire,exports.mapUs2AccountFromWire=__webpack_exports__.mapUs2AccountFromWire,exports.mapUsAccountFromWire=__webpack_exports__.mapUsAccountFromWire,exports.mapVirtualAccountFromWire=__webpack_exports__.mapVirtualAccountFromWire,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","BrebClient","CardClient","ExternalUsBankClient","PolygonClient","Us2Client","UsClient","VirtualClient","mapBancolombiaAccountFromWire","mapBrebAccountFromWire","mapCardAccountFromWire","mapExternalUsBankAccountFromWire","mapPolygonAccountFromWire","mapUs2AccountFromWire","mapUsAccountFromWire","mapVirtualAccountFromWire"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,t)=>{for(var a in t)__webpack_require__.o(t,a)&&!__webpack_require__.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{mapUs2AccountFromWire:()=>mapUs2AccountFromWire,mapBrebAccountFromWire:()=>mapBrebAccountFromWire,mapUsAccountFromWire:()=>mapUsAccountFromWire,mapBancolombiaAccountFromWire:()=>mapBancolombiaAccountFromWire,mapVirtualAccountFromWire:()=>mapVirtualAccountFromWire,VirtualClient:()=>VirtualClient,BancolombiaClient:()=>BancolombiaClient,mapExternalUsBankAccountFromWire:()=>mapExternalUsBankAccountFromWire,ExternalUsBankClient:()=>ExternalUsBankClient,AccountsClient:()=>AccountsClient,PolygonClient:()=>PolygonClient,UsClient:()=>UsClient,CardClient:()=>CardClient,mapCardAccountFromWire:()=>mapCardAccountFromWire,mapPolygonAccountFromWire:()=>mapPolygonAccountFromWire,Us2Client:()=>Us2Client,BrebClient:()=>BrebClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");function mapBancolombiaAccountFromWire(e){return{urn:e.urn,id:e.id,referenceCode:e.details.reference_code,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e={},t){let a={holder_urn:e?.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapBancolombiaAccountFromWire(e)}}function mapBrebAccountFromWire(e){return{id:e.id,urn:e.urn,ownerUrn:e.owner_urn,medium:"breb",remoteKeyId:e.details.remote_key_id,accountId:e.details.account_id,keyType:e.details.key.key_type,key:e.details.key.key_value,displayName:e.details.display_name??null,status:e.status,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,details:e.details,balance:"balance"in e&&e.balance?e.balance:void 0}}function mapDecodedQrFromWire(e){return{amount:e.amount,additionalInfo:e.additional_info?{transactionPurpose:e.additional_info.transaction_purpose,terminalLabel:e.additional_info.terminal_label,invoiceNumber:e.additional_info.invoice_number,mobilePhoneNumber:e.additional_info.mobile_phone_number,storeLabel:e.additional_info.store_label,loyaltyLabel:e.additional_info.loyalty_label,referenceLabel:e.additional_info.reference_label,customerLabel:e.additional_info.customer_label,customerInfo:e.additional_info.customer_info,channelPresentation:e.additional_info.channel_presentation}:null,key:e.key?{keyType:e.key.key_type,keyValue:e.key.key_value}:null,qrCodeData:e.qr_code_data,status:e.status,acquirerNetworkIdentifier:e.acquirer_network_identifier,merchant:e.merchant?{merchantCategoryCode:e.merchant.merchant_category_code,merchantCountry:e.merchant.merchant_country,merchantName:e.merchant.merchant_name,merchantCity:e.merchant.merchant_city,merchantPostCode:e.merchant.merchant_post_code}:null,channel:e.channel,vat:e.vat?{vatValue:e.vat.vat_value,vatBaseValue:e.vat.vat_base_value,vatType:e.vat.vat_type}:null,inc:e.inc?{incValue:e.inc.inc_value,incType:e.inc.inc_type}:null,qrCodeReference:e.qr_code_reference,type:e.type,resolutionId:e.resolution_id,resolution:e.resolution}}class BrebClient extends sdk_core_namespaceObject.BaseClient{mapError(e){if(e instanceof sdk_core_namespaceObject.BloqueAPIError){let t=e.response;return{code:t?.extra_details?.provider_code??e.code??null,message:e.message}}return e instanceof Error?{code:null,message:e.message}:{code:null,message:"Unknown BRE-B error"}}async createKey(e){try{let t=this.httpClient.urn;if(!t?.trim())throw Error("Holder URN is required");if(!e.key?.trim())throw Error("BRE-B key value is required");let a=await this.httpClient.request({method:"POST",path:"/api/mediums/breb",body:{holder_urn:t,input:{key_type:e.keyType,key_value:e.key,display_name:e.displayName},webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,metadata:{source:"sdk-typescript",...e.metadata}}});return{data:mapBrebAccountFromWire(a.result.account),error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async resolveKey(e){try{if(!e.key?.trim())throw Error("BRE-B key value is required");return{data:(await this.httpClient.request({method:"POST",path:"/api/mediums/breb/resolve-key",body:{...e.keyType&&{key_type:e.keyType},key:e.key}})).result,error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async decodeQr(e){try{if(!e.qrCodeData?.trim())throw Error("BRE-B QR code data is required");let t=await this.httpClient.request({method:"POST",path:"/api/mediums/breb/decode-qr",body:{qr_code_data:e.qrCodeData}});return{data:mapDecodedQrFromWire(t.result),error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async deleteKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"deleted"}});return{data:{deleted:!0,accountUrn:t.result.account.urn,keyId:t.result.account.details.id,status:"deleted"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async suspendKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"frozen"}});return{data:{accountUrn:t.result.account.urn,keyId:t.result.account.details.id,keyStatus:t.result.account.details.status,status:"frozen"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async activateKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"active"}});return{data:{accountUrn:t.result.account.urn,keyId:t.result.account.details.id,keyStatus:t.result.account.details.status,status:"active"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}}function mapSpendingControlMetadataToRaw(e){let t={};return void 0!==e.spendingControl&&(t.spending_control=e.spendingControl),void 0!==e.priorityMcc&&(t.priority_mcc=e.priorityMcc),void 0!==e.mccWhitelist&&(t.mcc_whitelist=e.mccWhitelist),void 0!==e.cashbackPrograms&&(t.cashback_programs=e.cashbackPrograms.map(e=>({program_name:e.programName,type:e.type,target_pocket_urn:e.targetPocketUrn,...e.feeType&&{fee_type:e.feeType},...void 0!==e.value&&{value:e.value}}))),void 0!==e.spendingFees&&(t.spending_fees=e.spendingFees.map(e=>({fee_name:e.feeName,account_urn:e.accountUrn,type:e.type,value:e.value,...e.category&&{category:e.category},...e.rule&&{rule:e.rule},...e.ruleParams&&{rule_params:e.ruleParams}}))),void 0!==e.fallbackAsset&&(t.fallback_asset=e.fallbackAsset),void 0!==e.whatsappNotification&&(t.whatsapp_notification=e.whatsappNotification),void 0!==e.currencyAssetMap&&(t.currency_asset_map=e.currencyAssetMap),t}function mapSpendingControlMetadataFromRaw(e){if(!e)return;let t={};return("default"===e.spending_control||"smart"===e.spending_control)&&(t.spendingControl=e.spending_control),Array.isArray(e.priority_mcc)&&(t.priorityMcc=e.priority_mcc),e.mcc_whitelist&&"object"==typeof e.mcc_whitelist&&(t.mccWhitelist=e.mcc_whitelist),Array.isArray(e.cashback_programs)&&(t.cashbackPrograms=e.cashback_programs.map(e=>({programName:e.program_name,type:e.type,targetPocketUrn:e.target_pocket_urn,...void 0!==e.fee_type&&{feeType:e.fee_type},...void 0!==e.value&&{value:e.value}}))),Array.isArray(e.spending_fees)&&(t.spendingFees=e.spending_fees.map(e=>({feeName:e.fee_name,accountUrn:e.account_urn,type:e.type,value:e.value,...void 0!==e.category&&{category:e.category},...void 0!==e.rule&&{rule:e.rule},...void 0!==e.rule_params&&{ruleParams:e.rule_params}}))),"string"==typeof e.fallback_asset&&(t.fallbackAsset=e.fallback_asset),"boolean"==typeof e.whatsapp_notification&&(t.whatsappNotification=e.whatsapp_notification),e.currency_asset_map&&"object"==typeof e.currency_asset_map&&(t.currencyAssetMap=e.currency_asset_map),Object.keys(t).length>0?t:void 0}function mapCardAccountFromWire(e){let t=e.metadata?.default_asset;return{urn:e.urn,id:e.id,program:e.medium,lastFour:e.details.card_last_four,productType:e.details.card_product_type,status:e.status,cardType:e.details.card_type,statusReason:e.details.status_reason,detailsUrl:e.details.card_url_details,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,defaultAsset:"string"==typeof t&&(0,sdk_core_namespaceObject.isSupportedAsset)(t)?t:void 0,spendingControlMetadata:mapSpendingControlMetadataFromRaw(e.metadata),createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(e={},t){if(e.defaultAsset&&!(0,sdk_core_namespaceObject.isSupportedAsset)(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=e.program||"card",r=e.cardType||"VIRTUAL";if("PHYSICAL"===r&&!e.cardAddress)throw Error('cardAddress is required when cardType is "PHYSICAL"');let n={holder_urn:e?.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{create:{card_type:r,...e.cardAddress&&{card_address:{street_name:e.cardAddress.streetName,street_number:e.cardAddress.streetNumber,floor:e.cardAddress.floor,apartment:e.cardAddress.apartment,city:e.cardAddress.city,region:e.cardAddress.region,country:e.cardAddress.country,zip_code:e.cardAddress.zipCode,neighborhood:e.cardAddress.neighborhood}}}},metadata:{source:"sdk-typescript",name:e.name,...e.metadata,...e.spendingControlMetadata&&mapSpendingControlMetadataToRaw(e.spendingControlMetadata),...e.defaultAsset&&{default_asset:e.defaultAsset}}},o=await this.httpClient.request({method:"POST",path:`/api/mediums/${a}`,body:n,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),s=this._mapAccountResponse(o.result.account);return t?.waitLedger?this._waitForActiveStatus(s.urn,t.timeout||6e4,a):s}async _waitForActiveStatus(e,t,a){let r=Date.now();for(;;){if(Date.now()-r>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let n=(await this.list({urn:e,program:a})).accounts[0];if(!n)throw Error(`Account not found. URN: ${e}`);if("active"===n.status)return n;if("creation_failed"===n.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=e?.program||"card",r=new URLSearchParams;r.append("medium",a),t&&r.append("holder_urn",t),e?.urn&&r.append("urn",e.urn);let n=`/api/accounts?${r.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(mapCardAccountFromWire)}}async movements(e){let t=new URLSearchParams,a=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(a))throw Error(`Invalid asset type "${a}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);t.set("asset",a),void 0!==e.limit&&t.set("limit",e.limit.toString()),e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.reference&&t.set("reference",e.reference),e.direction&&t.set("direction",e.direction),void 0!==e.collapsed_view&&t.set("collapsed_view",String(e.collapsed_view)),e.pocket&&t.set("pocket",e.pocket),e.next&&t.set("next",e.next);let r=t.toString(),n=`/api/accounts/${e.urn}/movements${r?`?${r}`:""}`,o=await this.httpClient.request({method:"GET",path:n});return{data:o.data,pageSize:o.page_size,hasMore:o.has_more,next:o.next}}async balance(e){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e.urn}/balance`})).balance}async update(e){let t=e.statusReason||e.pin?{...e.statusReason&&{status_reason:e.statusReason},...e.pin&&{pin:e.pin}}:void 0,a={...e.metadata&&{metadata:e.metadata},...e.status&&{status:e.status},...e.webhookUrl&&{webhook_url:e.webhookUrl},...e.ledgerId&&{ledger_account_id:e.ledgerId},...t&&{input:t}},r=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:a});return this._mapAccountResponse(r.result.account)}async updateMetadata(e){if(e.defaultAsset&&!(0,sdk_core_namespaceObject.isSupportedAsset)(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);if(!e.metadata&&!e.defaultAsset&&!e.spendingControlMetadata)throw Error("updateMetadata requires `metadata`, `defaultAsset`, or `spendingControlMetadata`");let t={metadata:{...e.metadata,...e.spendingControlMetadata&&mapSpendingControlMetadataToRaw(e.spendingControlMetadata),...e.defaultAsset&&{default_asset:e.defaultAsset}}},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async updateStatus(e,t,a){return this._updateStatus(e,t,a)}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async tokenizeApple(e,t){let a={certificates:t.certificates,nonce:t.nonce,nonce_signature:t.nonceSignature},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${e}/tokenize/apple`,body:a});return{activationData:r.result.tokenization.activation_data,encryptedPassData:r.result.tokenization.encrypted_pass_data,ephemeralPublicKey:r.result.tokenization.ephemeral_public_key}}async tokenizeGoogle(e,t){let a={device_id:t.deviceId,wallet_account_id:t.walletAccountId};return{opc:(await this.httpClient.request({method:"POST",path:`/api/accounts/${e}/tokenize/google`,body:a})).result.tokenization.opc}}async _updateStatus(e,t,a){let r={status:t,...a&&{input:{status_reason:a}}},n=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:r});return this._mapAccountResponse(n.result.account)}_mapAccountResponse(e){return mapCardAccountFromWire(e)}}function mapBankAddressFromWire(e){if(e)return{streetLine1:e.street_line_1,...void 0!==e.street_line_2?{streetLine2:e.street_line_2}:{},city:e.city,state:e.state,zip:e.zip,...void 0!==e.country?{country:e.country}:{}}}function mapExternalUsBankAccountFromWire(e){return{urn:e.urn,id:e.id,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance,details:{id:e.details.id,linkStatus:e.details.link_status,braleAccountId:e.details.brale_account_id,braleAddressId:e.details.brale_address_id,linkToken:e.details.link_token,linkTokenExpiration:e.details.link_token_expiration,linkUrl:e.details.link_url,jwt:e.details.jwt,bankAccountLast4:e.details.bank_account_last4,bankName:e.details.bank_name,failureReason:e.details.failure_reason,owner:e.details.owner,routingNumber:e.details.routing_number,accountNumber:e.details.account_number,accountType:e.details.account_type,bankAddress:mapBankAddressFromWire(e.details.bank_address),beneficiaryAddress:mapBankAddressFromWire(e.details.beneficiary_address),transferTypes:e.details.transfer_types,needsUpdate:e.details.needs_update,lastUpdated:e.details.last_updated}}}class ExternalUsBankClient extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{label:e.label,...void 0!==e.returnUrl?{return_url:e.returnUrl}:{},...void 0!==e.state?{state:e.state}:{}},metadata:{source:"sdk-typescript",...e.metadata}};return mapExternalUsBankAccountFromWire((await this.httpClient.request({method:"POST",path:"/api/mediums/external-us-bank",body:a})).result.account)}async exchangePublicToken(e){let t={input:{public_token:e.publicToken}};return mapExternalUsBankAccountFromWire((await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t})).result.account)}async pull(e){if(!e?.urn?.trim())throw Error("Bank account URN is required");if("string"!=typeof e.amount||""===e.amount.trim())throw Error('Amount is required and must be a string (e.g. "100.00")');let t=e.idempotencyKey??(void 0!==globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`idem_${Date.now()}_${Math.random().toString(36).slice(2)}`),a={amount:e.amount,idempotency_key:t},r=await this.httpClient.request({method:"POST",path:`/api/mediums/external-us-bank/${encodeURIComponent(e.urn)}/pull`,body:a,headers:{"Idempotency-Key":t}});return{orderSig:r.result?.order_sig,graphId:r.result?.graph_id,status:r.result?.status,execution:r.result?.execution,requestId:r.req_id}}}function mapPolygonAccountFromWire(e){return{urn:e.urn,id:e.id,address:e.details.address,fundingTx:e.details.funding_tx,network:e.details.network,openDeposits:e.details.open_deposits?Object.fromEntries(Object.entries(e.details.open_deposits).map(([e,t])=>[e,{fromAccountId:t.from_account_id,sweptHash:t.swept_hash,toLedgerAccountId:t.to_ledger_account_id,fromAmount:t.from_amount}])):void 0,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class PolygonClient extends sdk_core_namespaceObject.BaseClient{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e={},t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapPolygonAccountFromWire(e)}}function mapUsAccountFromWire(e){return{urn:e.urn,id:e.id,type:e.details.type,firstName:e.details.first_name,middleName:e.details.middle_name,lastName:e.details.last_name,email:e.details.email,phone:e.details.phone,address:{streetLine1:e.details.address.street_line_1,streetLine2:e.details.address.street_line_2,city:e.details.address.city,state:e.details.address.state,postalCode:e.details.address.postal_code,country:e.details.address.country},birthDate:e.details.birth_date,accountNumber:e.details.account_number,routingNumber:e.details.routing_number,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}}class UsClient extends sdk_core_namespaceObject.BaseClient{async getTosLink(e){let t=new URLSearchParams({redirect_uri:e.redirectUri}),a=(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${t.toString()}`})).result.url;try{let t=new URL(a);t.searchParams.has("redirect_uri")||(t.searchParams.set("redirect_uri",e.redirectUri),a=t.toString())}catch{let t=a.includes("?")?"&":"?";/[?&]redirect_uri=/.test(a)||(a=`${a}${t}redirect_uri=${encodeURIComponent(e.redirectUri)}`)}return{url:a}}async create(e,t){let a={street_line_1:e.address.streetLine1,street_line_2:e.address.streetLine2,city:e.address.city,state:e.address.state,postal_code:e.address.postalCode,country:e.address.country},r={type:e.type,first_name:e.firstName,middle_name:e.middleName,last_name:e.lastName,transliterated_first_name:e.transliteratedFirstName,transliterated_middle_name:e.transliteratedMiddleName,transliterated_last_name:e.transliteratedLastName,email:e.email,phone:e.phone,address:a,birth_date:e.birthDate,tax_identification_number:e.taxIdentificationNumber,gov_id_country:e.govIdCountry,gov_id_image_front:e.govIdImageFront,gov_id_image_back:e.govIdImageBack,proof_of_address_document:e.proofOfAddressDocument,signed_agreement_id:e.signedAgreementId,...e.sofEuQuestionnaire&&{sof_eu_questionnaire:{acting_as_intermediary:e.sofEuQuestionnaire.actingAsIntermediary,employment_status:e.sofEuQuestionnaire.employmentStatus,expected_monthly_payments:e.sofEuQuestionnaire.expectedMonthlyPayments,most_recent_occupation:e.sofEuQuestionnaire.mostRecentOccupation,primary_purpose:e.sofEuQuestionnaire.primaryPurpose,primary_purpose_other:e.sofEuQuestionnaire.primaryPurposeOther,source_of_funds:e.sofEuQuestionnaire.sourceOfFunds}}},n={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:r,metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},o=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:n,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),s=this._mapAccountResponse(o.result.account);return t?.waitLedger?this._waitForActiveStatus(s.urn,t.timeout||6e4):s}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({urn:e.urn,id:e.id,type:e.details.type,firstName:e.details.first_name,middleName:e.details.middle_name,lastName:e.details.last_name,email:e.details.email,phone:e.details.phone,address:{streetLine1:e.details.address.street_line_1,streetLine2:e.details.address.street_line_2,city:e.details.address.city,state:e.details.address.state,postalCode:e.details.address.postal_code,country:e.details.address.country},birthDate:e.details.birth_date,accountNumber:e.details.account_number,routingNumber:e.details.routing_number,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapUsAccountFromWire(e)}}function mapUs2AccountFromWire(e){return{urn:e.urn,id:e.id,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance,details:{id:e.details.id,userId:e.details.user_id,virtualAccountId:e.details.virtual_account_id,type:e.details.type,currency:e.details.currency}}}class Us2Client extends sdk_core_namespaceObject.BaseClient{async create(e,t){let a={type:e.type,email:e.email,phone:e.phone,proof_of_address:e.proofOfAddress,business_formation_document:e.businessFormationDocument,tax_id:e.taxId,address:e.address?{street:e.address.street,city:e.address.city,state:e.address.state,postal_code:e.address.postalCode,country:e.address.country}:void 0},r={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:a,metadata:{source:"sdk-typescript",...e.metadata}};return mapUs2AccountFromWire((await this.httpClient.request({method:"POST",path:"/api/mediums/us2-account",body:r})).result.account)}async list(e={}){let t=e.holderUrn||this.httpClient.urn,a=new URLSearchParams;return a.append("medium","us2-account"),t&&a.append("holder_urn",t),e.urn&&a.append("urn",e.urn),{accounts:(await this.httpClient.request({method:"GET",path:`/api/accounts?${a.toString()}`})).accounts.map(e=>mapUs2AccountFromWire(e))}}}function mapVirtualAccountFromWire(e){return{urn:e.urn,id:e.id,firstName:e.details.first_name,lastName:e.details.last_name,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class VirtualClient extends sdk_core_namespaceObject.BaseClient{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e,t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return mapVirtualAccountFromWire(e)}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;breb;card;externalUsBank;polygon;us;us2;virtual;constructor(e){super(e),this.bancolombia=new BancolombiaClient(this.httpClient),this.breb=new BrebClient(this.httpClient),this.card=new CardClient(this.httpClient),this.externalUsBank=new ExternalUsBankClient(this.httpClient),this.polygon=new PolygonClient(this.httpClient),this.us=new UsClient(this.httpClient),this.us2=new Us2Client(this.httpClient),this.virtual=new VirtualClient(this.httpClient)}async balance(e){if(!e?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e}/balance`})).balance}async balances(e){let t=new URLSearchParams;for(let a of e?.accountUrns??[])t.append("account_urns",a);let a=t.toString(),r=a?`/api/accounts/balances?${a}`:"/api/accounts/balances";return(await this.httpClient.request({method:"GET",path:r})).balance}async get(e){if(!e?.trim())throw Error("Account URN is required");let t=await this.httpClient.request({method:"GET",path:`/api/accounts/${e}`});return this._mapByMedium(t.account)}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;for(let r of(t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn),e?.urns??[]))a.append("urns",r);for(let t of(e?.medium&&a.append("medium",e.medium),e?.q&&a.append("q",e.q),e?.customId&&a.append("custom_id",e.customId),Array.isArray(e?.status)?e?.status??[]:e?.status?[e.status]:[]))a.append("status",t);for(let t of(e?.createdAfter&&a.append("created_after",e.createdAfter),e?.createdBefore&&a.append("created_before",e.createdBefore),e?.ledgerAccountId&&a.append("ledger_account_id",e.ledgerAccountId),e?.ledgerAccountIds??[]))a.append("ledger_account_ids",t);for(let[t,r]of(e?.limit!==void 0&&a.append("limit",e.limit.toString()),e?.offset!==void 0&&a.append("offset",e.offset.toString()),e?.order&&a.append("order",e.order),Object.entries(e?.metadata??{})))a.append(`metadata[${t}]`,r);let r=a.toString(),n=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(e=>this._mapByMedium(e))}}async transfer(e,t){let a=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(a))throw Error(`Invalid asset type "${a}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let r={destination_account_urn:e.destinationUrn,amount:e.amount,asset:a,metadata:e.metadata},n=await this.httpClient.request({method:"POST",path:`/api/accounts/${e.sourceUrn}/transfer`,body:r,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{queueId:n.result.queue_id,status:n.result.status,message:n.result.message}}async batchTransfer(e,t){if(!e.operations||0===e.operations.length)throw Error("At least one operation is required");if(!e.reference)throw Error("Batch reference is required");for(let t of e.operations)if(!(0,sdk_core_namespaceObject.isSupportedAsset)(t.asset))throw Error(`Invalid asset type "${t.asset}" in operation "${t.reference}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a={operations:e.operations.map(e=>({from_account_urn:e.fromUrn,to_account_urn:e.toUrn,reference:e.reference,amount:e.amount,asset:e.asset,metadata:e.metadata})),reference:e.reference,metadata:e.metadata,webhook_url:e.webhookUrl},r=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=r.result.chunks.map(e=>({queueId:e.queue_id,status:e.status,message:e.message}));return{status:r.result.status,chunks:n,totalOperations:r.result.total_operations,totalChunks:r.result.total_chunks}}async movements(e){if(!e.urn)throw Error("Account URN is required");let t=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(t))throw Error(`Invalid asset type "${t}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=new URLSearchParams;a.set("asset",t),void 0!==e.limit&&a.set("limit",e.limit.toString()),e.before&&a.set("before",e.before),e.after&&a.set("after",e.after),e.reference&&a.set("reference",e.reference),e.direction&&a.set("direction",e.direction),void 0!==e.collapsed_view&&a.set("collapsed_view",String(e.collapsed_view)),e.pocket&&a.set("pocket",e.pocket),e.next&&a.set("next",e.next);let r=`/api/accounts/${e.urn}/movements?${a.toString()}`,n=await this.httpClient.request({method:"GET",path:r});return{data:n.data.map(e=>({amount:e.amount,asset:e.asset,fromAccountId:e.from_account_id,toAccountId:e.to_account_id,direction:e.direction,type:e.type,reference:e.reference,status:e.status,railName:e.rail_name,details:e.details,createdAt:e.created_at})),pageSize:n.page_size,hasMore:n.has_more,next:n.next}}async transactions(e={}){let t=e.asset||"DUSD/6";if(!(0,sdk_core_namespaceObject.isSupportedAsset)(t))throw Error(`Invalid asset type "${t}". Supported assets: ${sdk_core_namespaceObject.SUPPORTED_ASSETS.join(", ")}`);let a=new URLSearchParams;for(let r of(a.set("asset",t),e.accountUrns??[]))a.append("account_urns",r);void 0!==e.limit&&a.set("limit",e.limit.toString()),e.before&&a.set("before",e.before),e.after&&a.set("after",e.after),e.reference&&a.set("reference",e.reference),e.direction&&a.set("direction",e.direction),void 0!==e.collapsed_view&&a.set("collapsed_view",String(e.collapsed_view)),e.pocket&&a.set("pocket",e.pocket),e.next&&a.set("next",e.next);let r=await this.httpClient.request({method:"GET",path:`/api/accounts/transactions?${a.toString()}`});return{data:r.data.map(e=>({amount:e.amount,asset:e.asset,fromAccountId:e.from_account_id,toAccountId:e.to_account_id,direction:e.direction,reference:e.reference,status:e.status,railName:e.rail_name,details:e.details??{},createdAt:e.created_at,type:e.type})),pageSize:r.page_size,hasMore:r.has_more,next:r.next}}_mapByMedium(e){let t=e.medium;if("card"===t||t.startsWith("card-"))return mapCardAccountFromWire(e);switch(t){case"virtual":return mapVirtualAccountFromWire(e);case"polygon":return mapPolygonAccountFromWire(e);case"bancolombia":return mapBancolombiaAccountFromWire(e);case"breb":return mapBrebAccountFromWire(e);case"external-us-bank":return mapExternalUsBankAccountFromWire(e);case"us-account":return mapUsAccountFromWire(e);case"us2-account":return mapUs2AccountFromWire(e);default:throw Error(`Unknown account medium: ${e.medium}`)}}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.BrebClient=__webpack_exports__.BrebClient,exports.CardClient=__webpack_exports__.CardClient,exports.ExternalUsBankClient=__webpack_exports__.ExternalUsBankClient,exports.PolygonClient=__webpack_exports__.PolygonClient,exports.Us2Client=__webpack_exports__.Us2Client,exports.UsClient=__webpack_exports__.UsClient,exports.VirtualClient=__webpack_exports__.VirtualClient,exports.mapBancolombiaAccountFromWire=__webpack_exports__.mapBancolombiaAccountFromWire,exports.mapBrebAccountFromWire=__webpack_exports__.mapBrebAccountFromWire,exports.mapCardAccountFromWire=__webpack_exports__.mapCardAccountFromWire,exports.mapExternalUsBankAccountFromWire=__webpack_exports__.mapExternalUsBankAccountFromWire,exports.mapPolygonAccountFromWire=__webpack_exports__.mapPolygonAccountFromWire,exports.mapUs2AccountFromWire=__webpack_exports__.mapUs2AccountFromWire,exports.mapUsAccountFromWire=__webpack_exports__.mapUsAccountFromWire,exports.mapVirtualAccountFromWire=__webpack_exports__.mapVirtualAccountFromWire,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","BrebClient","CardClient","ExternalUsBankClient","PolygonClient","Us2Client","UsClient","VirtualClient","mapBancolombiaAccountFromWire","mapBrebAccountFromWire","mapCardAccountFromWire","mapExternalUsBankAccountFromWire","mapPolygonAccountFromWire","mapUs2AccountFromWire","mapUsAccountFromWire","mapVirtualAccountFromWire"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BaseClient as t,BloqueAPIError as e,SUPPORTED_ASSETS as a,isSupportedAsset as r}from"@bloque/sdk-core";function n(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:"balance"in t&&t.balance?t.balance:void 0}}class s extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a,headers:e?.idempotencyKey?{"Idempotency-Key":e.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return n(t)}}function i(t){return{id:t.id,urn:t.urn,ownerUrn:t.owner_urn,medium:"breb",remoteKeyId:t.details.remote_key_id,accountId:t.details.account_id,keyType:t.details.key.key_type,key:t.details.key.key_value,displayName:t.details.display_name??null,status:t.status,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,details:t.details,balance:"balance"in t&&t.balance?t.balance:void 0}}class o extends t{mapError(t){if(t instanceof e){let e=t.response;return{code:e?.extra_details?.provider_code??t.code??null,message:t.message}}return t instanceof Error?{code:null,message:t.message}:{code:null,message:"Unknown BRE-B error"}}async createKey(t){try{let e=this.httpClient.urn;if(!e?.trim())throw Error("Holder URN is required");if(!t.key?.trim())throw Error("BRE-B key value is required");let a=await this.httpClient.request({method:"POST",path:"/api/mediums/breb",body:{holder_urn:e,input:{key_type:t.keyType,key_value:t.key,display_name:t.displayName},webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,metadata:{source:"sdk-typescript",...t.metadata}}});return{data:i(a.result.account),error:null}}catch(t){return{data:null,error:this.mapError(t)}}}async resolveKey(t){try{if(!t.key?.trim())throw Error("BRE-B key value is required");return{data:(await this.httpClient.request({method:"POST",path:"/api/mediums/breb/resolve-key",body:{...t.keyType&&{key_type:t.keyType},key:t.key}})).result,error:null}}catch(t){return{data:null,error:this.mapError(t)}}}async decodeQr(t){try{var e;if(!t.qrCodeData?.trim())throw Error("BRE-B QR code data is required");return{data:{amount:(e=(await this.httpClient.request({method:"POST",path:"/api/mediums/breb/decode-qr",body:{qr_code_data:t.qrCodeData}})).result).amount,additionalInfo:e.additional_info?{transactionPurpose:e.additional_info.transaction_purpose,terminalLabel:e.additional_info.terminal_label,invoiceNumber:e.additional_info.invoice_number,mobilePhoneNumber:e.additional_info.mobile_phone_number,storeLabel:e.additional_info.store_label,loyaltyLabel:e.additional_info.loyalty_label,referenceLabel:e.additional_info.reference_label,customerLabel:e.additional_info.customer_label,customerInfo:e.additional_info.customer_info,channelPresentation:e.additional_info.channel_presentation}:null,key:e.key?{keyType:e.key.key_type,keyValue:e.key.key_value}:null,qrCodeData:e.qr_code_data,status:e.status,acquirerNetworkIdentifier:e.acquirer_network_identifier,merchant:e.merchant?{merchantCategoryCode:e.merchant.merchant_category_code,merchantCountry:e.merchant.merchant_country,merchantName:e.merchant.merchant_name,merchantCity:e.merchant.merchant_city,merchantPostCode:e.merchant.merchant_post_code}:null,channel:e.channel,qrCodeReference:e.qr_code_reference,type:e.type,resolutionId:e.resolution_id,resolution:e.resolution},error:null}}catch(t){return{data:null,error:this.mapError(t)}}}async deleteKey(t){try{if(!t.accountUrn?.trim())throw Error("BRE-B account URN is required");let e=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(t.accountUrn)}`,body:{status:"deleted"}});return{data:{deleted:!0,accountUrn:e.result.account.urn,keyId:e.result.account.details.id,status:"deleted"},error:null}}catch(t){return{data:null,error:this.mapError(t)}}}async suspendKey(t){try{if(!t.accountUrn?.trim())throw Error("BRE-B account URN is required");let e=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(t.accountUrn)}`,body:{status:"frozen"}});return{data:{accountUrn:e.result.account.urn,keyId:e.result.account.details.id,keyStatus:e.result.account.details.status,status:"frozen"},error:null}}catch(t){return{data:null,error:this.mapError(t)}}}async activateKey(t){try{if(!t.accountUrn?.trim())throw Error("BRE-B account URN is required");let e=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(t.accountUrn)}`,body:{status:"active"}});return{data:{accountUrn:e.result.account.urn,keyId:e.result.account.details.id,keyStatus:e.result.account.details.status,status:"active"},error:null}}catch(t){return{data:null,error:this.mapError(t)}}}}function d(t){let e=t.metadata?.default_asset;return{urn:t.urn,id:t.id,program:t.medium,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,defaultAsset:"string"==typeof e&&r(e)?e:void 0,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}}class u extends t{async create(t={},e){if(t.defaultAsset&&!r(t.defaultAsset))throw Error(`Invalid asset type "${t.defaultAsset}". Supported assets: ${a.join(", ")}`);let n=t.program||"card",s={holder_urn:t?.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata,...t.defaultAsset&&{default_asset:t.defaultAsset}}},i=await this.httpClient.request({method:"POST",path:`/api/mediums/${n}`,body:s,headers:e?.idempotencyKey?{"Idempotency-Key":e.idempotencyKey}:void 0}),o=this._mapAccountResponse(i.result.account);return e?.waitLedger?this._waitForActiveStatus(o.urn,e.timeout||6e4,n):o}async _waitForActiveStatus(t,e,a){let r=Date.now();for(;;){if(Date.now()-r>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let n=(await this.list({urn:t,program:a})).accounts[0];if(!n)throw Error(`Account not found. URN: ${t}`);if("active"===n.status)return n;if("creation_failed"===n.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=t?.program||"card",r=new URLSearchParams;r.append("medium",a),e&&r.append("holder_urn",e),t?.urn&&r.append("urn",t.urn);let n=`/api/accounts?${r.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(d)}}async movements(t){let e=new URLSearchParams,n=t.asset||"DUSD/6";if(!r(n))throw Error(`Invalid asset type "${n}". Supported assets: ${a.join(", ")}`);e.set("asset",n),void 0!==t.limit&&e.set("limit",t.limit.toString()),t.before&&e.set("before",t.before),t.after&&e.set("after",t.after),t.reference&&e.set("reference",t.reference),t.direction&&e.set("direction",t.direction),void 0!==t.collapsed_view&&e.set("collapsed_view",String(t.collapsed_view)),t.pocket&&e.set("pocket",t.pocket),t.next&&e.set("next",t.next);let s=e.toString(),i=`/api/accounts/${t.urn}/movements${s?`?${s}`:""}`,o=await this.httpClient.request({method:"GET",path:i});return{data:o.data,pageSize:o.page_size,hasMore:o.has_more,next:o.next}}async balance(t){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t.urn}/balance`})).balance}async update(t){let e={...t.metadata&&{metadata:t.metadata},...t.status&&{status:t.status},...t.webhookUrl&&{webhook_url:t.webhookUrl},...t.ledgerId&&{ledger_account_id:t.ledgerId}},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){if(t.defaultAsset&&!r(t.defaultAsset))throw Error(`Invalid asset type "${t.defaultAsset}". Supported assets: ${a.join(", ")}`);if(!t.metadata&&!t.defaultAsset)throw Error("updateMetadata requires either `metadata` or `defaultAsset`");let e={metadata:{...t.metadata,...t.defaultAsset&&{default_asset:t.defaultAsset}}},n=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(n.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async tokenizeApple(t,e){let a={certificates:e.certificates,nonce:e.nonce,nonce_signature:e.nonceSignature},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${t}/tokenize/apple`,body:a});return{activationData:r.result.tokenization.activation_data,encryptedPassData:r.result.tokenization.encrypted_pass_data,ephemeralPublicKey:r.result.tokenization.ephemeral_public_key}}async tokenizeGoogle(t,e){let a={device_id:e.deviceId,wallet_account_id:e.walletAccountId};return{opc:(await this.httpClient.request({method:"POST",path:`/api/accounts/${t}/tokenize/google`,body:a})).result.tokenization.opc}}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return d(t)}}function c(t){if(t)return{streetLine1:t.street_line_1,...void 0!==t.street_line_2?{streetLine2:t.street_line_2}:{},city:t.city,state:t.state,zip:t.zip,...void 0!==t.country?{country:t.country}:{}}}function l(t){return{urn:t.urn,id:t.id,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance,details:{id:t.details.id,linkStatus:t.details.link_status,braleAccountId:t.details.brale_account_id,braleAddressId:t.details.brale_address_id,linkToken:t.details.link_token,linkTokenExpiration:t.details.link_token_expiration,linkUrl:t.details.link_url,jwt:t.details.jwt,bankAccountLast4:t.details.bank_account_last4,bankName:t.details.bank_name,failureReason:t.details.failure_reason,owner:t.details.owner,routingNumber:t.details.routing_number,accountNumber:t.details.account_number,accountType:t.details.account_type,bankAddress:c(t.details.bank_address),beneficiaryAddress:c(t.details.beneficiary_address),transferTypes:t.details.transfer_types,needsUpdate:t.details.needs_update,lastUpdated:t.details.last_updated}}}class p extends t{async create(t,e){let a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{label:t.label,...void 0!==t.returnUrl?{return_url:t.returnUrl}:{},...void 0!==t.state?{state:t.state}:{}},metadata:{source:"sdk-typescript",...t.metadata}};return l((await this.httpClient.request({method:"POST",path:"/api/mediums/external-us-bank",body:a})).result.account)}async exchangePublicToken(t){let e={input:{public_token:t.publicToken}};return l((await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e})).result.account)}async pull(t){if(!t?.urn?.trim())throw Error("Bank account URN is required");if("string"!=typeof t.amount||""===t.amount.trim())throw Error('Amount is required and must be a string (e.g. "100.00")');let e=t.idempotencyKey??(void 0!==globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`idem_${Date.now()}_${Math.random().toString(36).slice(2)}`),a={amount:t.amount,idempotency_key:e},r=await this.httpClient.request({method:"POST",path:`/api/mediums/external-us-bank/${encodeURIComponent(t.urn)}/pull`,body:a,headers:{"Idempotency-Key":e}});return{orderSig:r.result?.order_sig,graphId:r.result?.graph_id,status:r.result?.status,execution:r.result?.execution,requestId:r.req_id}}}function h(t){return{urn:t.urn,id:t.id,address:t.details.address,network:t.details.network,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:"balance"in t&&t.balance?t.balance:void 0}}class m extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t={},e){let a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a,headers:e?.idempotencyKey?{"Idempotency-Key":e.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return h(t)}}function _(t){return{urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}}class y extends t{async getTosLink(t){let e=new URLSearchParams({redirect_uri:t.redirectUri}),a=(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${e.toString()}`})).result.url;try{let e=new URL(a);e.searchParams.has("redirect_uri")||(e.searchParams.set("redirect_uri",t.redirectUri),a=e.toString())}catch{let e=a.includes("?")?"&":"?";/[?&]redirect_uri=/.test(a)||(a=`${a}${e}redirect_uri=${encodeURIComponent(t.redirectUri)}`)}return{url:a}}async create(t,e){let a={street_line_1:t.address.streetLine1,street_line_2:t.address.streetLine2,city:t.address.city,state:t.address.state,postal_code:t.address.postalCode,country:t.address.country},r={type:t.type,first_name:t.firstName,middle_name:t.middleName,last_name:t.lastName,email:t.email,phone:t.phone,address:a,birth_date:t.birthDate,tax_identification_number:t.taxIdentificationNumber,gov_id_country:t.govIdCountry,gov_id_image_front:t.govIdImageFront,signed_agreement_id:t.signedAgreementId},n={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:r,metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},s=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:n,headers:e?.idempotencyKey?{"Idempotency-Key":e.idempotencyKey}:void 0}),i=this._mapAccountResponse(s.result.account);return e?.waitLedger?this._waitForActiveStatus(i.urn,e.timeout||6e4):i}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({urn:t.urn,id:t.id,type:t.details.type,firstName:t.details.first_name,middleName:t.details.middle_name,lastName:t.details.last_name,email:t.details.email,phone:t.details.phone,address:{streetLine1:t.details.address.street_line_1,streetLine2:t.details.address.street_line_2,city:t.details.address.city,state:t.details.address.state,postalCode:t.details.address.postal_code,country:t.details.address.country},birthDate:t.details.birth_date,accountNumber:t.details.account_number,routingNumber:t.details.routing_number,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance}))}}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return _(t)}}function b(t){return{urn:t.urn,id:t.id,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:t.balance,details:{id:t.details.id,userId:t.details.user_id,virtualAccountId:t.details.virtual_account_id,type:t.details.type,currency:t.details.currency}}}class w extends t{async create(t,e){let a={type:t.type,email:t.email,phone:t.phone,proof_of_address:t.proofOfAddress,business_formation_document:t.businessFormationDocument,tax_id:t.taxId,address:t.address?{street:t.address.street,city:t.address.city,state:t.address.state,postal_code:t.address.postalCode,country:t.address.country}:void 0},r={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:a,metadata:{source:"sdk-typescript",...t.metadata}};return b((await this.httpClient.request({method:"POST",path:"/api/mediums/us2-account",body:r})).result.account)}async list(t={}){let e=t.holderUrn||this.httpClient.urn,a=new URLSearchParams;return a.append("medium","us2-account"),e&&a.append("holder_urn",e),t.urn&&a.append("urn",t.urn),{accounts:(await this.httpClient.request({method:"GET",path:`/api/accounts?${a.toString()}`})).accounts.map(t=>b(t))}}}function f(t){return{urn:t.urn,id:t.id,firstName:t.details.first_name,lastName:t.details.last_name,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at,balance:"balance"in t&&t.balance?t.balance:void 0}}class k extends t{async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),e&&a.append("holder_urn",e),t?.urn&&a.append("urn",t.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(t=>({...this._mapAccountResponse(t),balance:t.balance}))}}async create(t,e){let a={holder_urn:t.holderUrn||this.httpClient.urn||"",webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a,headers:e?.idempotencyKey?{"Idempotency-Key":e.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return e?.waitLedger?this._waitForActiveStatus(n.urn,e.timeout||6e4):n}async _waitForActiveStatus(t,e){let a=Date.now();for(;;){if(Date.now()-a>e)throw Error(`Timeout waiting for account to become active. URN: ${t}`);let r=(await this.list({urn:t})).accounts[0];if(!r)throw Error(`Account not found. URN: ${t}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${t}`);await new Promise(t=>setTimeout(t,2e3))}}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return f(t)}}class g extends t{bancolombia;breb;card;externalUsBank;polygon;us;us2;virtual;constructor(t){super(t),this.bancolombia=new s(this.httpClient),this.breb=new o(this.httpClient),this.card=new u(this.httpClient),this.externalUsBank=new p(this.httpClient),this.polygon=new m(this.httpClient),this.us=new y(this.httpClient),this.us2=new w(this.httpClient),this.virtual=new k(this.httpClient)}async balance(t){if(!t?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t}/balance`})).balance}async balances(){return(await this.httpClient.request({method:"GET",path:"/api/accounts/balances"})).balance}async get(t){if(!t?.trim())throw Error("Account URN is required");let e=await this.httpClient.request({method:"GET",path:`/api/accounts/${t}`});return this._mapByMedium(e.account)}async list(t){let e=t?.holderUrn||this.httpClient.urn,a=new URLSearchParams;e&&a.append("holder_urn",e);let r=a.toString(),n=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(t=>this._mapByMedium(t))}}async transfer(t,e){let n=t.asset||"DUSD/6";if(!r(n))throw Error(`Invalid asset type "${n}". Supported assets: ${a.join(", ")}`);let s={destination_account_urn:t.destinationUrn,amount:t.amount,asset:n,metadata:t.metadata},i=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:s,headers:e?.idempotencyKey?{"Idempotency-Key":e.idempotencyKey}:void 0});return{queueId:i.result.queue_id,status:i.result.status,message:i.result.message}}async batchTransfer(t,e){if(!t.operations||0===t.operations.length)throw Error("At least one operation is required");if(!t.reference)throw Error("Batch reference is required");for(let e of t.operations)if(!r(e.asset))throw Error(`Invalid asset type "${e.asset}" in operation "${e.reference}". Supported assets: ${a.join(", ")}`);let n={operations:t.operations.map(t=>({from_account_urn:t.fromUrn,to_account_urn:t.toUrn,reference:t.reference,amount:t.amount,asset:t.asset,metadata:t.metadata})),reference:t.reference,metadata:t.metadata,webhook_url:t.webhookUrl},s=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:n,headers:e?.idempotencyKey?{"Idempotency-Key":e.idempotencyKey}:void 0});return{chunks:s.result.chunks.map(t=>({queueId:t.queue_id,status:t.status,message:t.message})),totalOperations:s.result.total_operations,totalChunks:s.result.total_chunks}}async movements(t){if(!t.urn)throw Error("Account URN is required");let e=t.asset||"DUSD/6";if(!r(e))throw Error(`Invalid asset type "${e}". Supported assets: ${a.join(", ")}`);let n=new URLSearchParams;n.set("asset",e),void 0!==t.limit&&n.set("limit",t.limit.toString()),t.before&&n.set("before",t.before),t.after&&n.set("after",t.after),t.reference&&n.set("reference",t.reference),t.direction&&n.set("direction",t.direction),void 0!==t.collapsed_view&&n.set("collapsed_view",String(t.collapsed_view)),t.pocket&&n.set("pocket",t.pocket),t.next&&n.set("next",t.next);let s=`/api/accounts/${t.urn}/movements?${n.toString()}`,i=await this.httpClient.request({method:"GET",path:s});return{data:i.data.map(t=>({amount:t.amount,asset:t.asset,fromAccountId:t.from_account_id,toAccountId:t.to_account_id,direction:t.direction,type:t.type,reference:t.reference,status:t.status,railName:t.rail_name,details:t.details,createdAt:t.created_at})),pageSize:i.page_size,hasMore:i.has_more,next:i.next}}async transactions(t={}){let e=t.asset||"DUSD/6";if(!r(e))throw Error(`Invalid asset type "${e}". Supported assets: ${a.join(", ")}`);let n=new URLSearchParams;n.set("asset",e),void 0!==t.limit&&n.set("limit",t.limit.toString()),t.before&&n.set("before",t.before),t.after&&n.set("after",t.after),t.reference&&n.set("reference",t.reference),t.direction&&n.set("direction",t.direction),void 0!==t.collapsed_view&&n.set("collapsed_view",String(t.collapsed_view)),t.pocket&&n.set("pocket",t.pocket),t.next&&n.set("next",t.next);let s=await this.httpClient.request({method:"GET",path:`/api/accounts/transactions?${n.toString()}`});return{data:s.data.map(t=>({amount:t.amount,asset:t.asset,fromAccountId:t.from_account_id,toAccountId:t.to_account_id,direction:t.direction,reference:t.reference,status:t.status,railName:t.rail_name,details:t.details??{},createdAt:t.created_at,type:t.type})),pageSize:s.page_size,hasMore:s.has_more,next:s.next}}_mapByMedium(t){let e=t.medium;if("card"===e||e.startsWith("card-"))return d(t);switch(e){case"virtual":return f(t);case"polygon":return h(t);case"bancolombia":return n(t);case"breb":return i(t);case"external-us-bank":return l(t);case"us-account":return _(t);case"us2-account":return b(t);default:throw Error(`Unknown account medium: ${t.medium}`)}}}export{g as AccountsClient,s as BancolombiaClient,o as BrebClient,u as CardClient,p as ExternalUsBankClient,m as PolygonClient,w as Us2Client,y as UsClient,k as VirtualClient,n as mapBancolombiaAccountFromWire,i as mapBrebAccountFromWire,d as mapCardAccountFromWire,l as mapExternalUsBankAccountFromWire,h as mapPolygonAccountFromWire,b as mapUs2AccountFromWire,_ as mapUsAccountFromWire,f as mapVirtualAccountFromWire};
|
|
1
|
+
import{BaseClient as e,BloqueAPIError as t,SUPPORTED_ASSETS as a,isSupportedAsset as r}from"@bloque/sdk-core";function n(e){return{urn:e.urn,id:e.id,referenceCode:e.details.reference_code,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class s extends e{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","bancolombia"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e={},t){let a={holder_urn:e?.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return n(e)}}function o(e){return{id:e.id,urn:e.urn,ownerUrn:e.owner_urn,medium:"breb",remoteKeyId:e.details.remote_key_id,accountId:e.details.account_id,keyType:e.details.key.key_type,key:e.details.key.key_value,displayName:e.details.display_name??null,status:e.status,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,details:e.details,balance:"balance"in e&&e.balance?e.balance:void 0}}class i extends e{mapError(e){if(e instanceof t){let t=e.response;return{code:t?.extra_details?.provider_code??e.code??null,message:e.message}}return e instanceof Error?{code:null,message:e.message}:{code:null,message:"Unknown BRE-B error"}}async createKey(e){try{let t=this.httpClient.urn;if(!t?.trim())throw Error("Holder URN is required");if(!e.key?.trim())throw Error("BRE-B key value is required");let a=await this.httpClient.request({method:"POST",path:"/api/mediums/breb",body:{holder_urn:t,input:{key_type:e.keyType,key_value:e.key,display_name:e.displayName},webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,metadata:{source:"sdk-typescript",...e.metadata}}});return{data:o(a.result.account),error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async resolveKey(e){try{if(!e.key?.trim())throw Error("BRE-B key value is required");return{data:(await this.httpClient.request({method:"POST",path:"/api/mediums/breb/resolve-key",body:{...e.keyType&&{key_type:e.keyType},key:e.key}})).result,error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async decodeQr(e){try{var t;if(!e.qrCodeData?.trim())throw Error("BRE-B QR code data is required");return{data:{amount:(t=(await this.httpClient.request({method:"POST",path:"/api/mediums/breb/decode-qr",body:{qr_code_data:e.qrCodeData}})).result).amount,additionalInfo:t.additional_info?{transactionPurpose:t.additional_info.transaction_purpose,terminalLabel:t.additional_info.terminal_label,invoiceNumber:t.additional_info.invoice_number,mobilePhoneNumber:t.additional_info.mobile_phone_number,storeLabel:t.additional_info.store_label,loyaltyLabel:t.additional_info.loyalty_label,referenceLabel:t.additional_info.reference_label,customerLabel:t.additional_info.customer_label,customerInfo:t.additional_info.customer_info,channelPresentation:t.additional_info.channel_presentation}:null,key:t.key?{keyType:t.key.key_type,keyValue:t.key.key_value}:null,qrCodeData:t.qr_code_data,status:t.status,acquirerNetworkIdentifier:t.acquirer_network_identifier,merchant:t.merchant?{merchantCategoryCode:t.merchant.merchant_category_code,merchantCountry:t.merchant.merchant_country,merchantName:t.merchant.merchant_name,merchantCity:t.merchant.merchant_city,merchantPostCode:t.merchant.merchant_post_code}:null,channel:t.channel,vat:t.vat?{vatValue:t.vat.vat_value,vatBaseValue:t.vat.vat_base_value,vatType:t.vat.vat_type}:null,inc:t.inc?{incValue:t.inc.inc_value,incType:t.inc.inc_type}:null,qrCodeReference:t.qr_code_reference,type:t.type,resolutionId:t.resolution_id,resolution:t.resolution},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async deleteKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"deleted"}});return{data:{deleted:!0,accountUrn:t.result.account.urn,keyId:t.result.account.details.id,status:"deleted"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async suspendKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"frozen"}});return{data:{accountUrn:t.result.account.urn,keyId:t.result.account.details.id,keyStatus:t.result.account.details.status,status:"frozen"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}async activateKey(e){try{if(!e.accountUrn?.trim())throw Error("BRE-B account URN is required");let t=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${encodeURIComponent(e.accountUrn)}`,body:{status:"active"}});return{data:{accountUrn:t.result.account.urn,keyId:t.result.account.details.id,keyStatus:t.result.account.details.status,status:"active"},error:null}}catch(e){return{data:null,error:this.mapError(e)}}}}function d(e){let t={};return void 0!==e.spendingControl&&(t.spending_control=e.spendingControl),void 0!==e.priorityMcc&&(t.priority_mcc=e.priorityMcc),void 0!==e.mccWhitelist&&(t.mcc_whitelist=e.mccWhitelist),void 0!==e.cashbackPrograms&&(t.cashback_programs=e.cashbackPrograms.map(e=>({program_name:e.programName,type:e.type,target_pocket_urn:e.targetPocketUrn,...e.feeType&&{fee_type:e.feeType},...void 0!==e.value&&{value:e.value}}))),void 0!==e.spendingFees&&(t.spending_fees=e.spendingFees.map(e=>({fee_name:e.feeName,account_urn:e.accountUrn,type:e.type,value:e.value,...e.category&&{category:e.category},...e.rule&&{rule:e.rule},...e.ruleParams&&{rule_params:e.ruleParams}}))),void 0!==e.fallbackAsset&&(t.fallback_asset=e.fallbackAsset),void 0!==e.whatsappNotification&&(t.whatsapp_notification=e.whatsappNotification),void 0!==e.currencyAssetMap&&(t.currency_asset_map=e.currencyAssetMap),t}function c(e){let t=e.metadata?.default_asset;return{urn:e.urn,id:e.id,program:e.medium,lastFour:e.details.card_last_four,productType:e.details.card_product_type,status:e.status,cardType:e.details.card_type,statusReason:e.details.status_reason,detailsUrl:e.details.card_url_details,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,defaultAsset:"string"==typeof t&&r(t)?t:void 0,spendingControlMetadata:function(e){if(!e)return;let t={};return("default"===e.spending_control||"smart"===e.spending_control)&&(t.spendingControl=e.spending_control),Array.isArray(e.priority_mcc)&&(t.priorityMcc=e.priority_mcc),e.mcc_whitelist&&"object"==typeof e.mcc_whitelist&&(t.mccWhitelist=e.mcc_whitelist),Array.isArray(e.cashback_programs)&&(t.cashbackPrograms=e.cashback_programs.map(e=>({programName:e.program_name,type:e.type,targetPocketUrn:e.target_pocket_urn,...void 0!==e.fee_type&&{feeType:e.fee_type},...void 0!==e.value&&{value:e.value}}))),Array.isArray(e.spending_fees)&&(t.spendingFees=e.spending_fees.map(e=>({feeName:e.fee_name,accountUrn:e.account_urn,type:e.type,value:e.value,...void 0!==e.category&&{category:e.category},...void 0!==e.rule&&{rule:e.rule},...void 0!==e.rule_params&&{ruleParams:e.rule_params}}))),"string"==typeof e.fallback_asset&&(t.fallbackAsset=e.fallback_asset),"boolean"==typeof e.whatsapp_notification&&(t.whatsappNotification=e.whatsapp_notification),e.currency_asset_map&&"object"==typeof e.currency_asset_map&&(t.currencyAssetMap=e.currency_asset_map),Object.keys(t).length>0?t:void 0}(e.metadata),createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}}class u extends e{async create(e={},t){if(e.defaultAsset&&!r(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${a.join(", ")}`);let n=e.program||"card",s=e.cardType||"VIRTUAL";if("PHYSICAL"===s&&!e.cardAddress)throw Error('cardAddress is required when cardType is "PHYSICAL"');let o={holder_urn:e?.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{create:{card_type:s,...e.cardAddress&&{card_address:{street_name:e.cardAddress.streetName,street_number:e.cardAddress.streetNumber,floor:e.cardAddress.floor,apartment:e.cardAddress.apartment,city:e.cardAddress.city,region:e.cardAddress.region,country:e.cardAddress.country,zip_code:e.cardAddress.zipCode,neighborhood:e.cardAddress.neighborhood}}}},metadata:{source:"sdk-typescript",name:e.name,...e.metadata,...e.spendingControlMetadata&&d(e.spendingControlMetadata),...e.defaultAsset&&{default_asset:e.defaultAsset}}},i=await this.httpClient.request({method:"POST",path:`/api/mediums/${n}`,body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),c=this._mapAccountResponse(i.result.account);return t?.waitLedger?this._waitForActiveStatus(c.urn,t.timeout||6e4,n):c}async _waitForActiveStatus(e,t,a){let r=Date.now();for(;;){if(Date.now()-r>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let n=(await this.list({urn:e,program:a})).accounts[0];if(!n)throw Error(`Account not found. URN: ${e}`);if("active"===n.status)return n;if("creation_failed"===n.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=e?.program||"card",r=new URLSearchParams;r.append("medium",a),t&&r.append("holder_urn",t),e?.urn&&r.append("urn",e.urn);let n=`/api/accounts?${r.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(c)}}async movements(e){let t=new URLSearchParams,n=e.asset||"DUSD/6";if(!r(n))throw Error(`Invalid asset type "${n}". Supported assets: ${a.join(", ")}`);t.set("asset",n),void 0!==e.limit&&t.set("limit",e.limit.toString()),e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.reference&&t.set("reference",e.reference),e.direction&&t.set("direction",e.direction),void 0!==e.collapsed_view&&t.set("collapsed_view",String(e.collapsed_view)),e.pocket&&t.set("pocket",e.pocket),e.next&&t.set("next",e.next);let s=t.toString(),o=`/api/accounts/${e.urn}/movements${s?`?${s}`:""}`,i=await this.httpClient.request({method:"GET",path:o});return{data:i.data,pageSize:i.page_size,hasMore:i.has_more,next:i.next}}async balance(e){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e.urn}/balance`})).balance}async update(e){let t=e.statusReason||e.pin?{...e.statusReason&&{status_reason:e.statusReason},...e.pin&&{pin:e.pin}}:void 0,a={...e.metadata&&{metadata:e.metadata},...e.status&&{status:e.status},...e.webhookUrl&&{webhook_url:e.webhookUrl},...e.ledgerId&&{ledger_account_id:e.ledgerId},...t&&{input:t}},r=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:a});return this._mapAccountResponse(r.result.account)}async updateMetadata(e){if(e.defaultAsset&&!r(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${a.join(", ")}`);if(!e.metadata&&!e.defaultAsset&&!e.spendingControlMetadata)throw Error("updateMetadata requires `metadata`, `defaultAsset`, or `spendingControlMetadata`");let t={metadata:{...e.metadata,...e.spendingControlMetadata&&d(e.spendingControlMetadata),...e.defaultAsset&&{default_asset:e.defaultAsset}}},n=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(n.result.account)}async updateName(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{metadata:{name:t}}});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async updateStatus(e,t,a){return this._updateStatus(e,t,a)}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async tokenizeApple(e,t){let a={certificates:t.certificates,nonce:t.nonce,nonce_signature:t.nonceSignature},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${e}/tokenize/apple`,body:a});return{activationData:r.result.tokenization.activation_data,encryptedPassData:r.result.tokenization.encrypted_pass_data,ephemeralPublicKey:r.result.tokenization.ephemeral_public_key}}async tokenizeGoogle(e,t){let a={device_id:t.deviceId,wallet_account_id:t.walletAccountId};return{opc:(await this.httpClient.request({method:"POST",path:`/api/accounts/${e}/tokenize/google`,body:a})).result.tokenization.opc}}async _updateStatus(e,t,a){let r={status:t,...a&&{input:{status_reason:a}}},n=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:r});return this._mapAccountResponse(n.result.account)}_mapAccountResponse(e){return c(e)}}function l(e){if(e)return{streetLine1:e.street_line_1,...void 0!==e.street_line_2?{streetLine2:e.street_line_2}:{},city:e.city,state:e.state,zip:e.zip,...void 0!==e.country?{country:e.country}:{}}}function p(e){return{urn:e.urn,id:e.id,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance,details:{id:e.details.id,linkStatus:e.details.link_status,braleAccountId:e.details.brale_account_id,braleAddressId:e.details.brale_address_id,linkToken:e.details.link_token,linkTokenExpiration:e.details.link_token_expiration,linkUrl:e.details.link_url,jwt:e.details.jwt,bankAccountLast4:e.details.bank_account_last4,bankName:e.details.bank_name,failureReason:e.details.failure_reason,owner:e.details.owner,routingNumber:e.details.routing_number,accountNumber:e.details.account_number,accountType:e.details.account_type,bankAddress:l(e.details.bank_address),beneficiaryAddress:l(e.details.beneficiary_address),transferTypes:e.details.transfer_types,needsUpdate:e.details.needs_update,lastUpdated:e.details.last_updated}}}class m extends e{async create(e,t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{label:e.label,...void 0!==e.returnUrl?{return_url:e.returnUrl}:{},...void 0!==e.state?{state:e.state}:{}},metadata:{source:"sdk-typescript",...e.metadata}};return p((await this.httpClient.request({method:"POST",path:"/api/mediums/external-us-bank",body:a})).result.account)}async exchangePublicToken(e){let t={input:{public_token:e.publicToken}};return p((await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t})).result.account)}async pull(e){if(!e?.urn?.trim())throw Error("Bank account URN is required");if("string"!=typeof e.amount||""===e.amount.trim())throw Error('Amount is required and must be a string (e.g. "100.00")');let t=e.idempotencyKey??(void 0!==globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`idem_${Date.now()}_${Math.random().toString(36).slice(2)}`),a={amount:e.amount,idempotency_key:t},r=await this.httpClient.request({method:"POST",path:`/api/mediums/external-us-bank/${encodeURIComponent(e.urn)}/pull`,body:a,headers:{"Idempotency-Key":t}});return{orderSig:r.result?.order_sig,graphId:r.result?.graph_id,status:r.result?.status,execution:r.result?.execution,requestId:r.req_id}}}function h(e){return{urn:e.urn,id:e.id,address:e.details.address,fundingTx:e.details.funding_tx,network:e.details.network,openDeposits:e.details.open_deposits?Object.fromEntries(Object.entries(e.details.open_deposits).map(([e,t])=>[e,{fromAccountId:t.from_account_id,sweptHash:t.swept_hash,toLedgerAccountId:t.to_ledger_account_id,fromAmount:t.from_amount}])):void 0,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class _ extends e{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","polygon"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e={},t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/polygon",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return h(e)}}function y(e){return{urn:e.urn,id:e.id,type:e.details.type,firstName:e.details.first_name,middleName:e.details.middle_name,lastName:e.details.last_name,email:e.details.email,phone:e.details.phone,address:{streetLine1:e.details.address.street_line_1,streetLine2:e.details.address.street_line_2,city:e.details.address.city,state:e.details.address.state,postalCode:e.details.address.postal_code,country:e.details.address.country},birthDate:e.details.birth_date,accountNumber:e.details.account_number,routingNumber:e.details.routing_number,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}}class f extends e{async getTosLink(e){let t=new URLSearchParams({redirect_uri:e.redirectUri}),a=(await this.httpClient.request({method:"POST",path:`/api/mediums/us-account/tos-link?${t.toString()}`})).result.url;try{let t=new URL(a);t.searchParams.has("redirect_uri")||(t.searchParams.set("redirect_uri",e.redirectUri),a=t.toString())}catch{let t=a.includes("?")?"&":"?";/[?&]redirect_uri=/.test(a)||(a=`${a}${t}redirect_uri=${encodeURIComponent(e.redirectUri)}`)}return{url:a}}async create(e,t){let a={street_line_1:e.address.streetLine1,street_line_2:e.address.streetLine2,city:e.address.city,state:e.address.state,postal_code:e.address.postalCode,country:e.address.country},r={type:e.type,first_name:e.firstName,middle_name:e.middleName,last_name:e.lastName,transliterated_first_name:e.transliteratedFirstName,transliterated_middle_name:e.transliteratedMiddleName,transliterated_last_name:e.transliteratedLastName,email:e.email,phone:e.phone,address:a,birth_date:e.birthDate,tax_identification_number:e.taxIdentificationNumber,gov_id_country:e.govIdCountry,gov_id_image_front:e.govIdImageFront,gov_id_image_back:e.govIdImageBack,proof_of_address_document:e.proofOfAddressDocument,signed_agreement_id:e.signedAgreementId,...e.sofEuQuestionnaire&&{sof_eu_questionnaire:{acting_as_intermediary:e.sofEuQuestionnaire.actingAsIntermediary,employment_status:e.sofEuQuestionnaire.employmentStatus,expected_monthly_payments:e.sofEuQuestionnaire.expectedMonthlyPayments,most_recent_occupation:e.sofEuQuestionnaire.mostRecentOccupation,primary_purpose:e.sofEuQuestionnaire.primaryPurpose,primary_purpose_other:e.sofEuQuestionnaire.primaryPurposeOther,source_of_funds:e.sofEuQuestionnaire.sourceOfFunds}}},n={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:r,metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},s=await this.httpClient.request({method:"POST",path:"/api/mediums/us-account",body:n,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),o=this._mapAccountResponse(s.result.account);return t?.waitLedger?this._waitForActiveStatus(o.urn,t.timeout||6e4):o}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","us-account"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({urn:e.urn,id:e.id,type:e.details.type,firstName:e.details.first_name,middleName:e.details.middle_name,lastName:e.details.last_name,email:e.details.email,phone:e.details.phone,address:{streetLine1:e.details.address.street_line_1,streetLine2:e.details.address.street_line_2,city:e.details.address.city,state:e.details.address.state,postalCode:e.details.address.postal_code,country:e.details.address.country},birthDate:e.details.birth_date,accountNumber:e.details.account_number,routingNumber:e.details.routing_number,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance}))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return y(e)}}function b(e){return{urn:e.urn,id:e.id,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:e.balance,details:{id:e.details.id,userId:e.details.user_id,virtualAccountId:e.details.virtual_account_id,type:e.details.type,currency:e.details.currency}}}class w extends e{async create(e,t){let a={type:e.type,email:e.email,phone:e.phone,proof_of_address:e.proofOfAddress,business_formation_document:e.businessFormationDocument,tax_id:e.taxId,address:e.address?{street:e.address.street,city:e.address.city,state:e.address.state,postal_code:e.address.postalCode,country:e.address.country}:void 0},r={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:a,metadata:{source:"sdk-typescript",...e.metadata}};return b((await this.httpClient.request({method:"POST",path:"/api/mediums/us2-account",body:r})).result.account)}async list(e={}){let t=e.holderUrn||this.httpClient.urn,a=new URLSearchParams;return a.append("medium","us2-account"),t&&a.append("holder_urn",t),e.urn&&a.append("urn",e.urn),{accounts:(await this.httpClient.request({method:"GET",path:`/api/accounts?${a.toString()}`})).accounts.map(e=>b(e))}}}function g(e){return{urn:e.urn,id:e.id,firstName:e.details.first_name,lastName:e.details.last_name,status:e.status,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at,balance:"balance"in e&&e.balance?e.balance:void 0}}class A extends e{async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;a.append("medium","virtual"),t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn);let r=`/api/accounts?${a.toString()}`;return{accounts:(await this.httpClient.request({method:"GET",path:r})).accounts.map(e=>({...this._mapAccountResponse(e),balance:e.balance}))}}async create(e,t){let a={holder_urn:e.holderUrn||this.httpClient.urn||"",webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},r=await this.httpClient.request({method:"POST",path:"/api/mediums/virtual",body:a,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),n=this._mapAccountResponse(r.result.account);return t?.waitLedger?this._waitForActiveStatus(n.urn,t.timeout||6e4):n}async _waitForActiveStatus(e,t){let a=Date.now();for(;;){if(Date.now()-a>t)throw Error(`Timeout waiting for account to become active. URN: ${e}`);let r=(await this.list({urn:e})).accounts[0];if(!r)throw Error(`Account not found. URN: ${e}`);if("active"===r.status)return r;if("creation_failed"===r.status)throw Error(`Account creation failed. URN: ${e}`);await new Promise(e=>setTimeout(e,2e3))}}async updateMetadata(e){let t={metadata:e.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e.urn}`,body:t});return this._mapAccountResponse(a.result.account)}async activate(e){return this._updateStatus(e,"active")}async freeze(e){return this._updateStatus(e,"frozen")}async disable(e){return this._updateStatus(e,"disabled")}async _updateStatus(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${e}`,body:{status:t}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(e){return g(e)}}class k extends e{bancolombia;breb;card;externalUsBank;polygon;us;us2;virtual;constructor(e){super(e),this.bancolombia=new s(this.httpClient),this.breb=new i(this.httpClient),this.card=new u(this.httpClient),this.externalUsBank=new m(this.httpClient),this.polygon=new _(this.httpClient),this.us=new f(this.httpClient),this.us2=new w(this.httpClient),this.virtual=new A(this.httpClient)}async balance(e){if(!e?.trim())throw Error("Account URN is required");return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e}/balance`})).balance}async balances(e){let t=new URLSearchParams;for(let a of e?.accountUrns??[])t.append("account_urns",a);let a=t.toString(),r=a?`/api/accounts/balances?${a}`:"/api/accounts/balances";return(await this.httpClient.request({method:"GET",path:r})).balance}async get(e){if(!e?.trim())throw Error("Account URN is required");let t=await this.httpClient.request({method:"GET",path:`/api/accounts/${e}`});return this._mapByMedium(t.account)}async list(e){let t=e?.holderUrn||this.httpClient.urn,a=new URLSearchParams;for(let r of(t&&a.append("holder_urn",t),e?.urn&&a.append("urn",e.urn),e?.urns??[]))a.append("urns",r);for(let t of(e?.medium&&a.append("medium",e.medium),e?.q&&a.append("q",e.q),e?.customId&&a.append("custom_id",e.customId),Array.isArray(e?.status)?e?.status??[]:e?.status?[e.status]:[]))a.append("status",t);for(let t of(e?.createdAfter&&a.append("created_after",e.createdAfter),e?.createdBefore&&a.append("created_before",e.createdBefore),e?.ledgerAccountId&&a.append("ledger_account_id",e.ledgerAccountId),e?.ledgerAccountIds??[]))a.append("ledger_account_ids",t);for(let[t,r]of(e?.limit!==void 0&&a.append("limit",e.limit.toString()),e?.offset!==void 0&&a.append("offset",e.offset.toString()),e?.order&&a.append("order",e.order),Object.entries(e?.metadata??{})))a.append(`metadata[${t}]`,r);let r=a.toString(),n=r?`/api/accounts?${r}`:"/api/accounts";return{accounts:(await this.httpClient.request({method:"GET",path:n})).accounts.map(e=>this._mapByMedium(e))}}async transfer(e,t){let n=e.asset||"DUSD/6";if(!r(n))throw Error(`Invalid asset type "${n}". Supported assets: ${a.join(", ")}`);let s={destination_account_urn:e.destinationUrn,amount:e.amount,asset:n,metadata:e.metadata},o=await this.httpClient.request({method:"POST",path:`/api/accounts/${e.sourceUrn}/transfer`,body:s,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0});return{queueId:o.result.queue_id,status:o.result.status,message:o.result.message}}async batchTransfer(e,t){if(!e.operations||0===e.operations.length)throw Error("At least one operation is required");if(!e.reference)throw Error("Batch reference is required");for(let t of e.operations)if(!r(t.asset))throw Error(`Invalid asset type "${t.asset}" in operation "${t.reference}". Supported assets: ${a.join(", ")}`);let n={operations:e.operations.map(e=>({from_account_urn:e.fromUrn,to_account_urn:e.toUrn,reference:e.reference,amount:e.amount,asset:e.asset,metadata:e.metadata})),reference:e.reference,metadata:e.metadata,webhook_url:e.webhookUrl},s=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:n,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),o=s.result.chunks.map(e=>({queueId:e.queue_id,status:e.status,message:e.message}));return{status:s.result.status,chunks:o,totalOperations:s.result.total_operations,totalChunks:s.result.total_chunks}}async movements(e){if(!e.urn)throw Error("Account URN is required");let t=e.asset||"DUSD/6";if(!r(t))throw Error(`Invalid asset type "${t}". Supported assets: ${a.join(", ")}`);let n=new URLSearchParams;n.set("asset",t),void 0!==e.limit&&n.set("limit",e.limit.toString()),e.before&&n.set("before",e.before),e.after&&n.set("after",e.after),e.reference&&n.set("reference",e.reference),e.direction&&n.set("direction",e.direction),void 0!==e.collapsed_view&&n.set("collapsed_view",String(e.collapsed_view)),e.pocket&&n.set("pocket",e.pocket),e.next&&n.set("next",e.next);let s=`/api/accounts/${e.urn}/movements?${n.toString()}`,o=await this.httpClient.request({method:"GET",path:s});return{data:o.data.map(e=>({amount:e.amount,asset:e.asset,fromAccountId:e.from_account_id,toAccountId:e.to_account_id,direction:e.direction,type:e.type,reference:e.reference,status:e.status,railName:e.rail_name,details:e.details,createdAt:e.created_at})),pageSize:o.page_size,hasMore:o.has_more,next:o.next}}async transactions(e={}){let t=e.asset||"DUSD/6";if(!r(t))throw Error(`Invalid asset type "${t}". Supported assets: ${a.join(", ")}`);let n=new URLSearchParams;for(let a of(n.set("asset",t),e.accountUrns??[]))n.append("account_urns",a);void 0!==e.limit&&n.set("limit",e.limit.toString()),e.before&&n.set("before",e.before),e.after&&n.set("after",e.after),e.reference&&n.set("reference",e.reference),e.direction&&n.set("direction",e.direction),void 0!==e.collapsed_view&&n.set("collapsed_view",String(e.collapsed_view)),e.pocket&&n.set("pocket",e.pocket),e.next&&n.set("next",e.next);let s=await this.httpClient.request({method:"GET",path:`/api/accounts/transactions?${n.toString()}`});return{data:s.data.map(e=>({amount:e.amount,asset:e.asset,fromAccountId:e.from_account_id,toAccountId:e.to_account_id,direction:e.direction,reference:e.reference,status:e.status,railName:e.rail_name,details:e.details??{},createdAt:e.created_at,type:e.type})),pageSize:s.page_size,hasMore:s.has_more,next:s.next}}_mapByMedium(e){let t=e.medium;if("card"===t||t.startsWith("card-"))return c(e);switch(t){case"virtual":return g(e);case"polygon":return h(e);case"bancolombia":return n(e);case"breb":return o(e);case"external-us-bank":return p(e);case"us-account":return y(e);case"us2-account":return b(e);default:throw Error(`Unknown account medium: ${e.medium}`)}}}export{k as AccountsClient,s as BancolombiaClient,i as BrebClient,u as CardClient,m as ExternalUsBankClient,_ as PolygonClient,w as Us2Client,f as UsClient,A as VirtualClient,n as mapBancolombiaAccountFromWire,o as mapBrebAccountFromWire,c as mapCardAccountFromWire,p as mapExternalUsBankAccountFromWire,h as mapPolygonAccountFromWire,b as mapUs2AccountFromWire,y as mapUsAccountFromWire,g as mapVirtualAccountFromWire};
|
|
@@ -42,6 +42,22 @@ export interface CreateAccountRequest<TInput = unknown> {
|
|
|
42
42
|
metadata?: Record<string, unknown>;
|
|
43
43
|
webhook_url?: string;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
* Physical card mailing address. All fields required by the provider —
|
|
48
|
+
* only relevant when `card_type: 'PHYSICAL'`.
|
|
49
|
+
*/
|
|
50
|
+
export type PomeloCardAddress = {
|
|
51
|
+
street_name: string;
|
|
52
|
+
street_number: string;
|
|
53
|
+
floor: string;
|
|
54
|
+
apartment: string;
|
|
55
|
+
city: string;
|
|
56
|
+
region: string;
|
|
57
|
+
country: string;
|
|
58
|
+
zip_code: string;
|
|
59
|
+
neighborhood: string;
|
|
60
|
+
};
|
|
45
61
|
/**
|
|
46
62
|
* @internal
|
|
47
63
|
* Card account input for creation
|
|
@@ -49,8 +65,23 @@ export interface CreateAccountRequest<TInput = unknown> {
|
|
|
49
65
|
export type CreateCardAccountInput = {
|
|
50
66
|
create: {
|
|
51
67
|
card_type: CardType;
|
|
68
|
+
/** Required when `card_type` is `'PHYSICAL'`. */
|
|
69
|
+
card_address?: PomeloCardAddress;
|
|
52
70
|
};
|
|
53
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
* Reason accompanying a card status/PIN update.
|
|
75
|
+
*/
|
|
76
|
+
export type PomeloCardUpdateReason = 'CLIENT_INTERNAL_REASON' | 'USER_INTERNAL_REASON' | 'POMELO_INTERNAL_REASON' | 'PROVIDER_INTERNAL_REASON' | 'LOST' | 'STOLEN' | 'BROKEN' | 'UPGRADE';
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
* Card-specific update input, nested under `UpdateAccountRequest.input`.
|
|
80
|
+
*/
|
|
81
|
+
export type UpdateCardAccountInput = {
|
|
82
|
+
status_reason?: PomeloCardUpdateReason;
|
|
83
|
+
pin?: string;
|
|
84
|
+
};
|
|
54
85
|
/**
|
|
55
86
|
* @internal
|
|
56
87
|
* Create account response
|
|
@@ -75,7 +106,9 @@ export type CardDetails = {
|
|
|
75
106
|
card_provider: 'VISA';
|
|
76
107
|
card_product_type: 'CREDIT';
|
|
77
108
|
card_status: 'ACTIVE';
|
|
78
|
-
card_url_details: string;
|
|
109
|
+
card_url_details: string | null;
|
|
110
|
+
/** Set only after a status update that supplied a reason. */
|
|
111
|
+
status_reason?: PomeloCardUpdateReason;
|
|
79
112
|
card_type: CardType;
|
|
80
113
|
user_id: string;
|
|
81
114
|
};
|
|
@@ -130,16 +163,34 @@ export type CreatePolygonAccountInput = Record<string, never>;
|
|
|
130
163
|
* @internal
|
|
131
164
|
* Polygon account details from API
|
|
132
165
|
*/
|
|
166
|
+
/**
|
|
167
|
+
* @internal
|
|
168
|
+
* A deposit swap order in progress against a Polygon account's address.
|
|
169
|
+
*/
|
|
170
|
+
export type PolygonDepositSwapOrder = {
|
|
171
|
+
/** Account ID the deposit operation originated from. */
|
|
172
|
+
from_account_id: string;
|
|
173
|
+
/** Transaction hash of the swept event that originated this order. */
|
|
174
|
+
swept_hash: string;
|
|
175
|
+
/** Ledger account ID the deposit is addressed to. */
|
|
176
|
+
to_ledger_account_id: string;
|
|
177
|
+
/** Original deposit amount. */
|
|
178
|
+
from_amount: string;
|
|
179
|
+
};
|
|
133
180
|
export type PolygonDetails = {
|
|
134
181
|
id: string;
|
|
135
182
|
address: string;
|
|
183
|
+
/** Transaction hash of the on-chain funding transfer, or `null` before it lands. */
|
|
184
|
+
funding_tx: string | null;
|
|
136
185
|
network: string;
|
|
186
|
+
/** Deposit swap orders currently in flight against this address, keyed by id. */
|
|
187
|
+
open_deposits?: Record<string, PolygonDepositSwapOrder>;
|
|
137
188
|
};
|
|
138
189
|
/**
|
|
139
190
|
* @internal
|
|
140
|
-
* US account type
|
|
191
|
+
* US account type — this medium only accepts individual profiles.
|
|
141
192
|
*/
|
|
142
|
-
export type UsAccountType = 'individual'
|
|
193
|
+
export type UsAccountType = 'individual';
|
|
143
194
|
/**
|
|
144
195
|
* @internal
|
|
145
196
|
* US account address for creation
|
|
@@ -152,6 +203,20 @@ export interface UsAccountAddress {
|
|
|
152
203
|
postal_code: string;
|
|
153
204
|
country: string;
|
|
154
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* @internal
|
|
208
|
+
* EU compliance source-of-funds questionnaire, required by some EU
|
|
209
|
+
* jurisdictions on account creation.
|
|
210
|
+
*/
|
|
211
|
+
export interface UsAccountSofEuQuestionnaire {
|
|
212
|
+
acting_as_intermediary: 'yes' | 'no';
|
|
213
|
+
employment_status: 'employed' | 'unemployed';
|
|
214
|
+
expected_monthly_payments: string;
|
|
215
|
+
most_recent_occupation: string;
|
|
216
|
+
primary_purpose: string;
|
|
217
|
+
primary_purpose_other: string;
|
|
218
|
+
source_of_funds: string;
|
|
219
|
+
}
|
|
155
220
|
/**
|
|
156
221
|
* @internal
|
|
157
222
|
* US account input for creation
|
|
@@ -161,14 +226,20 @@ export interface CreateUsAccountInput {
|
|
|
161
226
|
first_name: string;
|
|
162
227
|
middle_name?: string;
|
|
163
228
|
last_name: string;
|
|
229
|
+
transliterated_first_name?: string;
|
|
230
|
+
transliterated_middle_name?: string;
|
|
231
|
+
transliterated_last_name?: string;
|
|
164
232
|
email: string;
|
|
165
233
|
phone: string;
|
|
166
234
|
address: UsAccountAddress;
|
|
167
235
|
birth_date: string;
|
|
168
236
|
tax_identification_number: string;
|
|
237
|
+
signed_agreement_id?: string;
|
|
169
238
|
gov_id_country: string;
|
|
170
|
-
gov_id_image_front
|
|
171
|
-
|
|
239
|
+
gov_id_image_front?: string;
|
|
240
|
+
gov_id_image_back?: string;
|
|
241
|
+
proof_of_address_document?: string;
|
|
242
|
+
sof_eu_questionnaire?: UsAccountSofEuQuestionnaire;
|
|
172
243
|
}
|
|
173
244
|
/**
|
|
174
245
|
* @internal
|
|
@@ -569,6 +640,7 @@ export interface BatchTransferChunk {
|
|
|
569
640
|
*/
|
|
570
641
|
export interface BatchTransferResponse {
|
|
571
642
|
result: {
|
|
643
|
+
status: 'executed' | 'deferred' | 'failed';
|
|
572
644
|
chunks: BatchTransferChunk[];
|
|
573
645
|
total_operations: number;
|
|
574
646
|
total_chunks: number;
|
package/dist/polygon/types.d.ts
CHANGED
|
@@ -83,10 +83,25 @@ export interface PolygonAccount {
|
|
|
83
83
|
* Polygon wallet address
|
|
84
84
|
*/
|
|
85
85
|
address: string;
|
|
86
|
+
/**
|
|
87
|
+
* Transaction hash of the on-chain funding transfer, or `null` before
|
|
88
|
+
* the funding transaction lands.
|
|
89
|
+
*/
|
|
90
|
+
fundingTx: string | null;
|
|
86
91
|
/**
|
|
87
92
|
* Network name (always "polygon")
|
|
88
93
|
*/
|
|
89
94
|
network: string;
|
|
95
|
+
/**
|
|
96
|
+
* Deposit swap orders currently in flight against this address, keyed
|
|
97
|
+
* by an internal id. Present only while a sweep is being processed.
|
|
98
|
+
*/
|
|
99
|
+
openDeposits?: Record<string, {
|
|
100
|
+
fromAccountId: string;
|
|
101
|
+
sweptHash: string;
|
|
102
|
+
toLedgerAccountId: string;
|
|
103
|
+
fromAmount: string;
|
|
104
|
+
}>;
|
|
90
105
|
/**
|
|
91
106
|
* Account status
|
|
92
107
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -148,6 +148,13 @@ export interface BatchTransferChunkResult {
|
|
|
148
148
|
* Result of a batch transfer operation
|
|
149
149
|
*/
|
|
150
150
|
export interface BatchTransferResult {
|
|
151
|
+
/**
|
|
152
|
+
* `'executed'` — all effective operations were queued (including the
|
|
153
|
+
* ready portion of a mixed batch). `'deferred'` — every account is still
|
|
154
|
+
* being created; the whole batch was rescheduled for retry.
|
|
155
|
+
* `'failed'` — the batch exhausted all retry attempts.
|
|
156
|
+
*/
|
|
157
|
+
status: 'executed' | 'deferred' | 'failed';
|
|
151
158
|
/** Array of chunk results */
|
|
152
159
|
chunks: BatchTransferChunkResult[];
|
|
153
160
|
/** Total number of operations in the batch */
|
|
@@ -155,6 +162,43 @@ export interface BatchTransferResult {
|
|
|
155
162
|
/** Total number of chunks the batch was split into */
|
|
156
163
|
totalChunks: number;
|
|
157
164
|
}
|
|
165
|
+
/** Lifecycle event fired over the course of a batch transfer's execution. */
|
|
166
|
+
export type BatchTransferWebhookEvent = 'batch_transfer.completed' | 'batch_transfer.operations_deferred' | 'batch_transfer.retry_attempt' | 'batch_transfer.failed';
|
|
167
|
+
/**
|
|
168
|
+
* Body POSTed to `webhookUrl` for a batch-level lifecycle event. Signed
|
|
169
|
+
* with `x-bloque-signature` (HMAC-SHA256 over the JSON body) when the
|
|
170
|
+
* origin has a webhook secret configured.
|
|
171
|
+
*/
|
|
172
|
+
export interface BatchTransferLifecycleWebhookPayload {
|
|
173
|
+
event: BatchTransferWebhookEvent;
|
|
174
|
+
reference: string;
|
|
175
|
+
status: 'executed' | 'deferred' | 'failed';
|
|
176
|
+
chunks: BatchTransferChunkResult[];
|
|
177
|
+
totalOperations: number;
|
|
178
|
+
totalChunks: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Body POSTed to `webhookUrl` for a single chunk's settlement, proxied
|
|
182
|
+
* from the underlying signing service. Signed the same way as the
|
|
183
|
+
* lifecycle events above.
|
|
184
|
+
*/
|
|
185
|
+
export interface BatchTransferSettlementWebhookPayload {
|
|
186
|
+
queueId: string;
|
|
187
|
+
status: 'pending' | 'confirmed' | 'settled' | 'failed';
|
|
188
|
+
message: {
|
|
189
|
+
urn: string;
|
|
190
|
+
railName: string;
|
|
191
|
+
metadata?: Record<string, unknown>;
|
|
192
|
+
};
|
|
193
|
+
settlement: {
|
|
194
|
+
status: 'pending' | 'confirmed' | 'settled' | 'cancelled' | 'failed' | 'ignored';
|
|
195
|
+
txHash?: string;
|
|
196
|
+
output?: {
|
|
197
|
+
results: unknown[];
|
|
198
|
+
};
|
|
199
|
+
[key: string]: unknown;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
158
202
|
/**
|
|
159
203
|
* Account status
|
|
160
204
|
*/
|
|
@@ -234,10 +278,63 @@ export interface ListAccountsParams {
|
|
|
234
278
|
* @example "did:bloque:account:card:usr-123:crd-456"
|
|
235
279
|
*/
|
|
236
280
|
urn?: string;
|
|
281
|
+
/**
|
|
282
|
+
* Multiple account URNs to filter by
|
|
283
|
+
*/
|
|
284
|
+
urns?: string[];
|
|
237
285
|
/**
|
|
238
286
|
* Account medium/type to filter by
|
|
239
287
|
*/
|
|
240
288
|
medium?: AccountMedium;
|
|
289
|
+
/**
|
|
290
|
+
* Free-text search query
|
|
291
|
+
*/
|
|
292
|
+
q?: string;
|
|
293
|
+
/**
|
|
294
|
+
* Filter by a custom identifier set on the account
|
|
295
|
+
*/
|
|
296
|
+
customId?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Filter by account status (one or more)
|
|
299
|
+
*/
|
|
300
|
+
status?: AccountStatus | AccountStatus[];
|
|
301
|
+
/**
|
|
302
|
+
* Only accounts created on or after this ISO 8601 timestamp
|
|
303
|
+
* @example "2026-01-01T00:00:00.000Z"
|
|
304
|
+
*/
|
|
305
|
+
createdAfter?: string;
|
|
306
|
+
/**
|
|
307
|
+
* Only accounts created on or before this ISO 8601 timestamp
|
|
308
|
+
* @example "2026-01-31T23:59:59.999Z"
|
|
309
|
+
*/
|
|
310
|
+
createdBefore?: string;
|
|
311
|
+
/**
|
|
312
|
+
* Filter by a single ledger account ID
|
|
313
|
+
*/
|
|
314
|
+
ledgerAccountId?: string;
|
|
315
|
+
/**
|
|
316
|
+
* Filter by multiple ledger account IDs
|
|
317
|
+
*/
|
|
318
|
+
ledgerAccountIds?: string[];
|
|
319
|
+
/**
|
|
320
|
+
* Filter by metadata key/value pairs
|
|
321
|
+
*/
|
|
322
|
+
metadata?: Record<string, string>;
|
|
323
|
+
/**
|
|
324
|
+
* Maximum number of accounts to return
|
|
325
|
+
* @default 100
|
|
326
|
+
*/
|
|
327
|
+
limit?: number;
|
|
328
|
+
/**
|
|
329
|
+
* Number of accounts to skip
|
|
330
|
+
* @default 0
|
|
331
|
+
*/
|
|
332
|
+
offset?: number;
|
|
333
|
+
/**
|
|
334
|
+
* Sort order by creation date
|
|
335
|
+
* @default "DESC"
|
|
336
|
+
*/
|
|
337
|
+
order?: 'ASC' | 'DESC';
|
|
241
338
|
}
|
|
242
339
|
/**
|
|
243
340
|
* Result of listing accounts.
|
|
@@ -301,11 +398,26 @@ export interface ListMovementsResult {
|
|
|
301
398
|
/** Pagination token for the next page (if hasMore is true) */
|
|
302
399
|
next?: string;
|
|
303
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Parameters for aggregated balances across accounts.
|
|
403
|
+
*/
|
|
404
|
+
export interface GetBalancesParams {
|
|
405
|
+
/**
|
|
406
|
+
* Restrict the aggregation to this subset of the holder's accounts.
|
|
407
|
+
* Omit to aggregate across all of them.
|
|
408
|
+
*/
|
|
409
|
+
accountUrns?: string[];
|
|
410
|
+
}
|
|
304
411
|
/**
|
|
305
412
|
* Parameters for listing transactions across all accounts.
|
|
306
413
|
* This endpoint does not receive account URN.
|
|
307
414
|
*/
|
|
308
415
|
export interface ListTransactionsParams {
|
|
416
|
+
/**
|
|
417
|
+
* Restrict the query to this subset of the holder's accounts. Omit to
|
|
418
|
+
* query across all of them.
|
|
419
|
+
*/
|
|
420
|
+
accountUrns?: string[];
|
|
309
421
|
/**
|
|
310
422
|
* Asset to filter transactions by.
|
|
311
423
|
* @example "DUSD/6"
|
package/dist/us/types.d.ts
CHANGED
|
@@ -34,6 +34,19 @@ export interface UsAccountAddress {
|
|
|
34
34
|
*/
|
|
35
35
|
country: string;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* EU compliance source-of-funds questionnaire, required by some EU
|
|
39
|
+
* jurisdictions on account creation.
|
|
40
|
+
*/
|
|
41
|
+
export interface UsAccountSofEuQuestionnaire {
|
|
42
|
+
actingAsIntermediary: 'yes' | 'no';
|
|
43
|
+
employmentStatus: 'employed' | 'unemployed';
|
|
44
|
+
expectedMonthlyPayments: string;
|
|
45
|
+
mostRecentOccupation: string;
|
|
46
|
+
primaryPurpose: string;
|
|
47
|
+
primaryPurposeOther: string;
|
|
48
|
+
sourceOfFunds: string;
|
|
49
|
+
}
|
|
37
50
|
/**
|
|
38
51
|
* Parameters for creating a US account
|
|
39
52
|
*/
|
|
@@ -44,7 +57,7 @@ export interface CreateUsAccountParams {
|
|
|
44
57
|
*/
|
|
45
58
|
holderUrn?: string;
|
|
46
59
|
/**
|
|
47
|
-
* Account type
|
|
60
|
+
* Account type — this medium only accepts individual profiles.
|
|
48
61
|
* @example "individual"
|
|
49
62
|
*/
|
|
50
63
|
type: UsAccountType;
|
|
@@ -63,6 +76,19 @@ export interface CreateUsAccountParams {
|
|
|
63
76
|
* @example "Johnson"
|
|
64
77
|
*/
|
|
65
78
|
lastName: string;
|
|
79
|
+
/**
|
|
80
|
+
* Transliterated (e.g. Latin-alphabet) first name, when `firstName` uses
|
|
81
|
+
* a non-Latin script.
|
|
82
|
+
*/
|
|
83
|
+
transliteratedFirstName?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Transliterated middle name.
|
|
86
|
+
*/
|
|
87
|
+
transliteratedMiddleName?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Transliterated last name.
|
|
90
|
+
*/
|
|
91
|
+
transliteratedLastName?: string;
|
|
66
92
|
/**
|
|
67
93
|
* Email address
|
|
68
94
|
* @example "robert.johnson@example.com"
|
|
@@ -95,12 +121,24 @@ export interface CreateUsAccountParams {
|
|
|
95
121
|
/**
|
|
96
122
|
* Base64-encoded image of government ID front
|
|
97
123
|
*/
|
|
98
|
-
govIdImageFront
|
|
124
|
+
govIdImageFront?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Base64-encoded image of government ID back
|
|
127
|
+
*/
|
|
128
|
+
govIdImageBack?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Base64-encoded proof-of-address document
|
|
131
|
+
*/
|
|
132
|
+
proofOfAddressDocument?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Required by some EU jurisdictions on account creation.
|
|
135
|
+
*/
|
|
136
|
+
sofEuQuestionnaire?: UsAccountSofEuQuestionnaire;
|
|
99
137
|
/**
|
|
100
138
|
* Signed agreement ID obtained from getTosLink
|
|
101
139
|
* @example "0d139f8e-14b0-4540-92ba-4e66c619b533"
|
|
102
140
|
*/
|
|
103
|
-
signedAgreementId
|
|
141
|
+
signedAgreementId?: string;
|
|
104
142
|
/**
|
|
105
143
|
* Display name for the US account
|
|
106
144
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-accounts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bloque",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"node": ">=22"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@bloque/sdk-core": "0.
|
|
39
|
+
"@bloque/sdk-core": "0.9.0"
|
|
40
40
|
}
|
|
41
41
|
}
|