@bloque/sdk-accounts 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -10
- package/dist/bancolombia/client.d.ts +2 -4
- package/dist/card/client.d.ts +2 -4
- package/dist/client.d.ts +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ Financial accounts and payment methods client for the [Bloque](https://www.bloqu
|
|
|
11
11
|
- **Fully Async**: Promise-based API for modern JavaScript workflows
|
|
12
12
|
- **Secure**: PCI-compliant card details URL
|
|
13
13
|
|
|
14
|
+
> **📌 Important:** All account operations require connecting to a user session first using `bloque.connect(urn)`. This ensures proper authentication and authorization for user-specific operations. See the [Usage](#usage) section for details.
|
|
15
|
+
|
|
14
16
|
## Installation
|
|
15
17
|
|
|
16
18
|
This package is included in the main `@bloque/sdk` package. You typically don't need to install it separately.
|
|
@@ -33,13 +35,20 @@ bun add @bloque/sdk-accounts @bloque/sdk-core
|
|
|
33
35
|
import { SDK } from '@bloque/sdk';
|
|
34
36
|
|
|
35
37
|
const bloque = new SDK({
|
|
36
|
-
|
|
38
|
+
origin: 'your-origin', // Required: your origin identifier
|
|
39
|
+
auth: {
|
|
40
|
+
type: 'apiKey',
|
|
41
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
42
|
+
},
|
|
37
43
|
mode: 'production',
|
|
38
44
|
});
|
|
39
45
|
|
|
40
|
-
//
|
|
41
|
-
const
|
|
42
|
-
|
|
46
|
+
// Connect to user session first
|
|
47
|
+
const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
|
|
48
|
+
|
|
49
|
+
// Create a virtual card through the session
|
|
50
|
+
const card = await userSession.accounts.card.create({
|
|
51
|
+
urn: 'did:bloque:your-origin:user-alias',
|
|
43
52
|
name: 'My Virtual Card', // Optional
|
|
44
53
|
ledgerId: 'ledger_123', // Optional - associate with ledger account
|
|
45
54
|
});
|
|
@@ -50,9 +59,9 @@ console.log('Card details URL:', card.detailsUrl);
|
|
|
50
59
|
console.log('Ledger ID:', card.ledgerId);
|
|
51
60
|
console.log('Status:', card.status);
|
|
52
61
|
|
|
53
|
-
// Create a Bancolombia account
|
|
54
|
-
const bancolombiaAccount = await
|
|
55
|
-
urn: 'did:bloque:user
|
|
62
|
+
// Create a Bancolombia account through the session
|
|
63
|
+
const bancolombiaAccount = await userSession.accounts.bancolombia.create({
|
|
64
|
+
urn: 'did:bloque:your-origin:user-alias',
|
|
56
65
|
name: 'Main Account', // Optional
|
|
57
66
|
ledgerId: 'ledger_123', // Optional - associate with ledger account
|
|
58
67
|
});
|
|
@@ -392,13 +401,20 @@ const account = await bloque.accounts.bancolombia.disable(
|
|
|
392
401
|
import { SDK } from '@bloque/sdk';
|
|
393
402
|
|
|
394
403
|
const bloque = new SDK({
|
|
395
|
-
|
|
404
|
+
origin: 'your-origin',
|
|
405
|
+
auth: {
|
|
406
|
+
type: 'apiKey',
|
|
407
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
408
|
+
},
|
|
396
409
|
mode: 'production',
|
|
397
410
|
});
|
|
398
411
|
|
|
412
|
+
// Connect to user session
|
|
413
|
+
const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
|
|
414
|
+
|
|
399
415
|
// Create a virtual card with just URN
|
|
400
|
-
const card = await
|
|
401
|
-
urn: 'did:bloque:user
|
|
416
|
+
const card = await userSession.accounts.card.create({
|
|
417
|
+
urn: 'did:bloque:your-origin:user-alias',
|
|
402
418
|
});
|
|
403
419
|
|
|
404
420
|
console.log('Card created:', card.urn);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
2
|
import type { BancolombiaAccount, CreateBancolombiaAccountParams, UpdateBancolombiaMetadataParams } from './types';
|
|
3
|
-
export declare class BancolombiaClient {
|
|
4
|
-
private readonly httpClient;
|
|
5
|
-
constructor(httpClient: HttpClient);
|
|
3
|
+
export declare class BancolombiaClient extends BaseClient {
|
|
6
4
|
/**
|
|
7
5
|
* Create a new Bancolombia account
|
|
8
6
|
*
|
package/dist/card/client.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
2
|
import type { CardAccount, CreateCardParams, UpdateCardMetadataParams } from './types';
|
|
3
|
-
export declare class CardClient {
|
|
4
|
-
private readonly httpClient;
|
|
5
|
-
constructor(httpClient: HttpClient);
|
|
3
|
+
export declare class CardClient extends BaseClient {
|
|
6
4
|
/**
|
|
7
5
|
* Create a new card account
|
|
8
6
|
*
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
3
|
import { BancolombiaClient } from './bancolombia/client';
|
|
3
4
|
import { CardClient } from './card/client';
|
|
4
5
|
/**
|
|
@@ -11,8 +12,7 @@ import { CardClient } from './card/client';
|
|
|
11
12
|
* - us: US bank accounts
|
|
12
13
|
* - polygon: Polygon wallets
|
|
13
14
|
*/
|
|
14
|
-
export declare class AccountsClient {
|
|
15
|
-
private readonly httpClient;
|
|
15
|
+
export declare class AccountsClient extends BaseClient {
|
|
16
16
|
readonly bancolombia: BancolombiaClient;
|
|
17
17
|
readonly card: CardClient;
|
|
18
18
|
constructor(httpClient: HttpClient);
|
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=(t
|
|
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__,{AccountsClient:()=>AccountsClient,CardClient:()=>CardClient,BancolombiaClient:()=>BancolombiaClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class BancolombiaClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={holder_urn:e.urn,webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:t});return this._mapAccountResponse(a.result.account)}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{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}}}class CardClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={holder_urn:e.urn,webhook_url:e.webhookUrl,ledger_account_id:e.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:e.name,...e.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:t});return this._mapAccountResponse(a.result.account)}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{urn:e.urn,id:e.id,lastFour:e.details.card_last_four,productType:e.details.card_product_type,status:e.status,cardType:e.details.card_type,detailsUrl:e.details.card_url_details,ownerUrn:e.owner_urn,ledgerId:e.ledger_account_id,webhookUrl:e.webhook_url,metadata:e.metadata,createdAt:e.created_at,updatedAt:e.updated_at}}}class AccountsClient extends sdk_core_namespaceObject.BaseClient{bancolombia;card;constructor(e){super(e),this.bancolombia=new BancolombiaClient(this.httpClient),this.card=new CardClient(this.httpClient)}}for(var __rspack_i in exports.AccountsClient=__webpack_exports__.AccountsClient,exports.BancolombiaClient=__webpack_exports__.BancolombiaClient,exports.CardClient=__webpack_exports__.CardClient,__webpack_exports__)-1===["AccountsClient","BancolombiaClient","CardClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{BaseClient as t}from"@bloque/sdk-core";class e extends t{async create(t){let e={holder_urn:t.urn,webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/bancolombia",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,referenceCode:t.details.reference_code,status:t.status,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class a extends t{async create(t){let e={holder_urn:t.urn,webhook_url:t.webhookUrl,ledger_account_id:t.ledgerId,input:{create:{card_type:"VIRTUAL"}},metadata:{source:"sdk-typescript",name:t.name,...t.metadata}},a=await this.httpClient.request({method:"POST",path:"/api/mediums/card",body:e});return this._mapAccountResponse(a.result.account)}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async updateName(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{metadata:{name:e}}});return this._mapAccountResponse(a.result.account)}async activate(t){return this._updateStatus(t,"active")}async freeze(t){return this._updateStatus(t,"frozen")}async disable(t){return this._updateStatus(t,"disabled")}async _updateStatus(t,e){let a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t}`,body:{status:e}});return this._mapAccountResponse(a.result.account)}_mapAccountResponse(t){return{urn:t.urn,id:t.id,lastFour:t.details.card_last_four,productType:t.details.card_product_type,status:t.status,cardType:t.details.card_type,detailsUrl:t.details.card_url_details,ownerUrn:t.owner_urn,ledgerId:t.ledger_account_id,webhookUrl:t.webhook_url,metadata:t.metadata,createdAt:t.created_at,updatedAt:t.updated_at}}}class s extends t{bancolombia;card;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient)}}export{s as AccountsClient,e as BancolombiaClient,a as CardClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-accounts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
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.0.
|
|
39
|
+
"@bloque/sdk-core": "0.0.22"
|
|
40
40
|
}
|
|
41
41
|
}
|