@bloque/sdk-accounts 0.12.0 → 0.13.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.
|
@@ -29,10 +29,11 @@ export declare class ExternalUsBankClient extends BaseClient {
|
|
|
29
29
|
/**
|
|
30
30
|
* Pull funds from a linked US bank via Brale ACH debit.
|
|
31
31
|
*
|
|
32
|
-
* Proactively initiates an ACH debit from the user's linked bank account
|
|
33
|
-
*
|
|
34
|
-
* the caller's Kreivo ledger account
|
|
35
|
-
* bank URN.
|
|
32
|
+
* Proactively initiates an ACH debit from the user's linked bank account.
|
|
33
|
+
* Omit `chain` (or pass `'kusama'`) to swap the proceeds to DUSD on Kusama
|
|
34
|
+
* and teleport them to the caller's Kreivo ledger account associated with
|
|
35
|
+
* the linked bank URN. Pass `chain: 'base'` with `walletAddress` to receive
|
|
36
|
+
* USDC on Base at that 0x instead — no ledger account is required.
|
|
36
37
|
*
|
|
37
38
|
* The account must already be in `linkStatus === 'active'` — i.e. Plaid
|
|
38
39
|
* Link has finished and the `public_token` has been exchanged (either via
|
|
@@ -42,7 +43,8 @@ export declare class ExternalUsBankClient extends BaseClient {
|
|
|
42
43
|
* correlate webhook events (`swap.order.*`) and to poll the swap service
|
|
43
44
|
* for status.
|
|
44
45
|
*
|
|
45
|
-
* @param params - Pull parameters (URN of the linked bank, USD amount
|
|
46
|
+
* @param params - Pull parameters (URN of the linked bank, USD amount,
|
|
47
|
+
* optional Base destination)
|
|
46
48
|
* @returns Snapshot of the created swap order
|
|
47
49
|
*
|
|
48
50
|
* @example
|
|
@@ -56,13 +58,26 @@ export declare class ExternalUsBankClient extends BaseClient {
|
|
|
56
58
|
* console.log(order.status); // "pending"
|
|
57
59
|
* ```
|
|
58
60
|
*
|
|
59
|
-
* @
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const order = await user.accounts.externalUsBank.pull({
|
|
64
|
+
* urn: linked.urn,
|
|
65
|
+
* amount: '100.00',
|
|
66
|
+
* chain: 'base',
|
|
67
|
+
* walletAddress: '0x1234567890abcdef1234567890abcdef12345678',
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @throws BloqueConfigError — `chain: 'base'` without `walletAddress`, or
|
|
72
|
+
* `walletAddress` without `chain: 'base'`.
|
|
73
|
+
* @throws BloqueAPIError 400 — invalid amount or `urn`, or Base destination
|
|
74
|
+
* fields are incomplete.
|
|
60
75
|
* @throws BloqueAPIError 401 — unauthenticated.
|
|
61
76
|
* @throws BloqueAPIError 403 — the caller does not own the linked bank account.
|
|
62
77
|
* @throws BloqueAPIError 404 — the bank URN has no address mapping yet
|
|
63
|
-
* (`linkStatus !== 'active'`), or the
|
|
78
|
+
* (`linkStatus !== 'active'`), or the Kusama path has no ledger.
|
|
64
79
|
* @throws BloqueAPIError 503 — no swap rate available for
|
|
65
|
-
* `external-us-bank → kusama`.
|
|
80
|
+
* `external-us-bank → kusama` or `external-us-bank → base`.
|
|
66
81
|
*/
|
|
67
82
|
pull(params: PullExternalUsBankParams): Promise<PullExternalUsBankResult>;
|
|
68
83
|
}
|
|
@@ -134,12 +134,15 @@ export interface ExchangeExternalUsBankPublicTokenParams {
|
|
|
134
134
|
urn: string;
|
|
135
135
|
publicToken: string;
|
|
136
136
|
}
|
|
137
|
+
/** Destination chain for {@link ExternalUsBankClient.pull}. */
|
|
138
|
+
export type PullExternalUsBankChain = 'kusama' | 'base';
|
|
137
139
|
/**
|
|
138
140
|
* Parameters for {@link ExternalUsBankClient.pull}.
|
|
139
141
|
*
|
|
140
|
-
* Initiates a Brale ACH debit from the user's linked bank
|
|
141
|
-
* proceeds
|
|
142
|
-
*
|
|
142
|
+
* Initiates a Brale ACH debit from the user's linked bank. By default the
|
|
143
|
+
* proceeds land as DUSD on Kusama and teleport to the Kreivo ledger account
|
|
144
|
+
* associated with the linked-bank URN. Pass `chain: 'base'` with
|
|
145
|
+
* `walletAddress` to receive USDC on Base at that 0x instead.
|
|
143
146
|
*/
|
|
144
147
|
export interface PullExternalUsBankParams {
|
|
145
148
|
/**
|
|
@@ -161,6 +164,18 @@ export interface PullExternalUsBankParams {
|
|
|
161
164
|
* @example "100.00"
|
|
162
165
|
*/
|
|
163
166
|
amount: string;
|
|
167
|
+
/**
|
|
168
|
+
* Destination chain. Omit or `'kusama'` to land DUSD on Kusama (default).
|
|
169
|
+
* Pass `'base'` together with `walletAddress` to receive USDC on Base.
|
|
170
|
+
*/
|
|
171
|
+
chain?: PullExternalUsBankChain;
|
|
172
|
+
/**
|
|
173
|
+
* Destination 0x on Base. Required when `chain` is `'base'`.
|
|
174
|
+
* The server rejects this field unless `chain` is `'base'`.
|
|
175
|
+
*
|
|
176
|
+
* @example "0x1234567890abcdef1234567890abcdef12345678"
|
|
177
|
+
*/
|
|
178
|
+
walletAddress?: string;
|
|
164
179
|
/**
|
|
165
180
|
* Optional caller-supplied idempotency hint. Currently informational
|
|
166
181
|
* (server-side idempotency is keyed on the swap signature).
|
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,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}}},s=await this.httpClient.request({method:"POST",path:`/api/mediums/${a}`,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,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}`:""}`,s=await this.httpClient.request({method:"GET",path:n});return{data:s.data,pageSize:s.page_size,hasMore:s.has_more,next:s.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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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}},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 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,ledgerAccountUrn:e.metadata?.ledger_account_urn,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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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});
|
|
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}}},s=await this.httpClient.request({method:"POST",path:`/api/mediums/${a}`,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,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}`:""}`,s=await this.httpClient.request({method:"GET",path:n});return{data:s.data,pageSize:s.page_size,hasMore:s.has_more,next:s.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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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.chain,a=e.walletAddress?.trim();if(("base"===t||a)&&("base"!==t||!a))throw new sdk_core_namespaceObject.BloqueConfigError('Base destination requires chain: "base" and walletAddress (0x on Base).');let r=e.idempotencyKey??(void 0!==globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`idem_${Date.now()}_${Math.random().toString(36).slice(2)}`),n={amount:e.amount,idempotency_key:r,...t?{chain:t}:{},...a?{wallet_address:a}:{}},s=await this.httpClient.request({method:"POST",path:`/api/mediums/external-us-bank/${encodeURIComponent(e.urn)}/pull`,body:n,headers:{"Idempotency-Key":r}});return{orderSig:s.result?.order_sig,graphId:s.result?.graph_id,status:s.result?.status,execution:s.result?.execution,requestId:s.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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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}},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 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,ledgerAccountUrn:e.metadata?.ledger_account_urn,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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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 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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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,ledgerAccountUrn:e.metadata?.ledger_account_urn,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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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};
|
|
1
|
+
import{BaseClient as e,BloqueAPIError as t,BloqueConfigError as a,SUPPORTED_ASSETS as r,isSupportedAsset as n}from"@bloque/sdk-core";function s(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 o 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 s(e)}}function i(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 d 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:i(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 c(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 u(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&&n(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 l extends e{async create(e={},t){if(e.defaultAsset&&!n(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${r.join(", ")}`);let a=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&&c(e.spendingControlMetadata),...e.defaultAsset&&{default_asset:e.defaultAsset}}},i=await this.httpClient.request({method:"POST",path:`/api/mediums/${a}`,body:o,headers:t?.idempotencyKey?{"Idempotency-Key":t.idempotencyKey}:void 0}),d=this._mapAccountResponse(i.result.account);return t?.waitLedger?this._waitForActiveStatus(d.urn,t.timeout||6e4,a):d}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(u)}}async movements(e){let t=new URLSearchParams,a=e.asset||"DUSD/6";if(!n(a))throw Error(`Invalid asset type "${a}". Supported assets: ${r.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 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&&!n(e.defaultAsset))throw Error(`Invalid asset type "${e.defaultAsset}". Supported assets: ${r.join(", ")}`);if(!e.metadata&&!e.defaultAsset&&!e.spendingControlMetadata)throw Error("updateMetadata requires `metadata`, `defaultAsset`, or `spendingControlMetadata`");let t={metadata:{...e.metadata,...e.spendingControlMetadata&&c(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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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 u(e)}}function p(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 m(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:p(e.details.bank_address),beneficiaryAddress:p(e.details.beneficiary_address),transferTypes:e.details.transfer_types,needsUpdate:e.details.needs_update,lastUpdated:e.details.last_updated}}}class h 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 m((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 m((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.chain,r=e.walletAddress?.trim();if(("base"===t||r)&&("base"!==t||!r))throw new a('Base destination requires chain: "base" and walletAddress (0x on Base).');let n=e.idempotencyKey??(void 0!==globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`idem_${Date.now()}_${Math.random().toString(36).slice(2)}`),s={amount:e.amount,idempotency_key:n,...t?{chain:t}:{},...r?{wallet_address:r}:{}},o=await this.httpClient.request({method:"POST",path:`/api/mediums/external-us-bank/${encodeURIComponent(e.urn)}/pull`,body:s,headers:{"Idempotency-Key":n}});return{orderSig:o.result?.order_sig,graphId:o.result?.graph_id,status:o.result?.status,execution:o.result?.execution,requestId:o.req_id}}}function _(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 y 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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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 _(e)}}function f(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 b 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 f(e)}}function w(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 g 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 w((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=>w(e))}}}function A(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,ledgerAccountUrn:e.metadata?.ledger_account_urn,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 k 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 delete(e){let t=await this.httpClient.request({method:"DELETE",path:`/api/accounts/${e}`});return this._mapAccountResponse(t.result.account)}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 A(e)}}class v extends e{bancolombia;breb;card;externalUsBank;polygon;us;us2;virtual;constructor(e){super(e),this.bancolombia=new o(this.httpClient),this.breb=new d(this.httpClient),this.card=new l(this.httpClient),this.externalUsBank=new h(this.httpClient),this.polygon=new y(this.httpClient),this.us=new b(this.httpClient),this.us2=new g(this.httpClient),this.virtual=new k(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(!n(a))throw Error(`Invalid asset type "${a}". Supported assets: ${r.join(", ")}`);let s={destination_account_urn:e.destinationUrn,amount:e.amount,asset:a,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(!n(t.asset))throw Error(`Invalid asset type "${t.asset}" in operation "${t.reference}". Supported assets: ${r.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},s=await this.httpClient.request({method:"POST",path:"/api/accounts/batch/transfer",body:a,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(!n(t))throw Error(`Invalid asset type "${t}". Supported assets: ${r.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 s=`/api/accounts/${e.urn}/movements?${a.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(!n(t))throw Error(`Invalid asset type "${t}". Supported assets: ${r.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 s=await this.httpClient.request({method:"GET",path:`/api/accounts/transactions?${a.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 u(e);switch(t){case"virtual":return A(e);case"polygon":return _(e);case"bancolombia":return s(e);case"breb":return i(e);case"external-us-bank":return m(e);case"us-account":return f(e);case"us2-account":return w(e);default:throw Error(`Unknown account medium: ${e.medium}`)}}}export{v as AccountsClient,o as BancolombiaClient,d as BrebClient,l as CardClient,h as ExternalUsBankClient,y as PolygonClient,g as Us2Client,b as UsClient,k as VirtualClient,s as mapBancolombiaAccountFromWire,i as mapBrebAccountFromWire,u as mapCardAccountFromWire,m as mapExternalUsBankAccountFromWire,_ as mapPolygonAccountFromWire,w as mapUs2AccountFromWire,f as mapUsAccountFromWire,A as mapVirtualAccountFromWire};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-accounts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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.13.0"
|
|
40
40
|
}
|
|
41
41
|
}
|