@bloque/sdk-accounts 0.0.6 → 0.0.11
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 +170 -10
- package/dist/api-types.d.ts +6 -0
- package/dist/bancolombia/client.d.ts +21 -0
- package/dist/bancolombia/types.d.ts +63 -0
- package/dist/card/types.d.ts +4 -0
- package/dist/client.d.ts +2 -0
- package/dist/index.cjs +39 -1
- package/dist/index.js +39 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Financial accounts and payment methods client for the [Bloque](https://www.bloqu
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Virtual Cards**: Create virtual cards instantly
|
|
8
|
+
- **Bancolombia Accounts**: Create Bancolombia accounts with reference codes
|
|
8
9
|
- **TypeScript First**: Built with TypeScript for complete type safety
|
|
9
10
|
- **Simple API**: Minimal input required - just URN and optional name
|
|
10
11
|
- **Fully Async**: Promise-based API for modern JavaScript workflows
|
|
@@ -46,6 +47,17 @@ console.log('Card created:', card.urn);
|
|
|
46
47
|
console.log('Last four digits:', card.lastFour);
|
|
47
48
|
console.log('Card details URL:', card.detailsUrl);
|
|
48
49
|
console.log('Status:', card.status);
|
|
50
|
+
|
|
51
|
+
// Create a Bancolombia account
|
|
52
|
+
const bancolombiaAccount = await bloque.accounts.bancolombia.create({
|
|
53
|
+
urn: 'did:bloque:user:123',
|
|
54
|
+
name: 'Main Account', // Optional
|
|
55
|
+
cardUrn: card.urn, // Optional - link with existing card
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
console.log('Bancolombia account created:', bancolombiaAccount.urn);
|
|
59
|
+
console.log('Reference code:', bancolombiaAccount.referenceCode);
|
|
60
|
+
console.log('Status:', bancolombiaAccount.status);
|
|
49
61
|
```
|
|
50
62
|
|
|
51
63
|
## API Reference
|
|
@@ -99,6 +111,64 @@ interface CardAccount {
|
|
|
99
111
|
}
|
|
100
112
|
```
|
|
101
113
|
|
|
114
|
+
### Bancolombia Accounts
|
|
115
|
+
|
|
116
|
+
Create Bancolombia accounts with reference codes for local payments.
|
|
117
|
+
|
|
118
|
+
#### `bancolombia.create(params)`
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const account = await bloque.accounts.bancolombia.create({
|
|
122
|
+
urn: 'did:bloque:user:123',
|
|
123
|
+
name: 'Main Account', // Optional
|
|
124
|
+
cardUrn: 'did:bloque:card:456', // Optional - link with existing card
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Parameters**:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
interface CreateBancolombiaAccountParams {
|
|
132
|
+
/**
|
|
133
|
+
* URN of the account holder (user or organization)
|
|
134
|
+
* @example "did:bloque:user:123e4567"
|
|
135
|
+
*/
|
|
136
|
+
urn: string;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Display name for the account (optional)
|
|
140
|
+
*/
|
|
141
|
+
name?: string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* URN of an existing card to link with the Bancolombia account (optional)
|
|
145
|
+
* @example "did:bloque:card:123e4567"
|
|
146
|
+
*/
|
|
147
|
+
cardUrn?: string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Custom metadata to attach to the Bancolombia account (optional)
|
|
151
|
+
*/
|
|
152
|
+
metadata?: Record<string, unknown>;
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Returns**:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
interface BancolombiaAccount {
|
|
160
|
+
urn: string; // Unique resource name
|
|
161
|
+
id: string; // Account ID
|
|
162
|
+
referenceCode: string; // Reference code for payments
|
|
163
|
+
status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
|
|
164
|
+
ownerUrn: string; // Owner URN
|
|
165
|
+
webhookUrl: string | null; // Webhook URL (if configured)
|
|
166
|
+
metadata?: Record<string, unknown>; // Custom metadata
|
|
167
|
+
createdAt: string; // Creation timestamp (ISO 8601)
|
|
168
|
+
updatedAt: string; // Last update timestamp (ISO 8601)
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
102
172
|
## Complete Examples
|
|
103
173
|
|
|
104
174
|
### Basic Card Creation
|
|
@@ -199,6 +269,81 @@ try {
|
|
|
199
269
|
}
|
|
200
270
|
```
|
|
201
271
|
|
|
272
|
+
### Basic Bancolombia Account Creation
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
import { SDK } from '@bloque/sdk';
|
|
276
|
+
|
|
277
|
+
const bloque = new SDK({
|
|
278
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
279
|
+
mode: 'production',
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Create a Bancolombia account with just URN
|
|
283
|
+
const account = await bloque.accounts.bancolombia.create({
|
|
284
|
+
urn: 'did:bloque:user:123e4567',
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
console.log('Account created:', account.urn);
|
|
288
|
+
console.log('Reference code:', account.referenceCode);
|
|
289
|
+
console.log('Status:', account.status);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Bancolombia Account with Card Link
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import { SDK } from '@bloque/sdk';
|
|
296
|
+
|
|
297
|
+
const bloque = new SDK({
|
|
298
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
299
|
+
mode: 'production',
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const userUrn = 'did:bloque:user:123e4567';
|
|
303
|
+
|
|
304
|
+
// Create a card first
|
|
305
|
+
const card = await bloque.accounts.card.create({
|
|
306
|
+
urn: userUrn,
|
|
307
|
+
name: 'My Card',
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
// Create Bancolombia account and link it to the card
|
|
311
|
+
const account = await bloque.accounts.bancolombia.create({
|
|
312
|
+
urn: userUrn,
|
|
313
|
+
name: 'Main Account',
|
|
314
|
+
cardUrn: card.urn, // Link to existing card
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
console.log('Card URN:', card.urn);
|
|
318
|
+
console.log('Account URN:', account.urn);
|
|
319
|
+
console.log('Reference code for payments:', account.referenceCode);
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Bancolombia Account with Metadata
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
import { SDK } from '@bloque/sdk';
|
|
326
|
+
|
|
327
|
+
const bloque = new SDK({
|
|
328
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
329
|
+
mode: 'production',
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// Create Bancolombia account with custom metadata
|
|
333
|
+
const account = await bloque.accounts.bancolombia.create({
|
|
334
|
+
urn: 'did:bloque:user:123e4567',
|
|
335
|
+
name: 'Business Account',
|
|
336
|
+
metadata: {
|
|
337
|
+
purpose: 'business-payments',
|
|
338
|
+
department: 'sales',
|
|
339
|
+
customField: 'custom-value',
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
console.log('Account created with metadata:', account.metadata);
|
|
344
|
+
console.log('Reference code:', account.referenceCode);
|
|
345
|
+
```
|
|
346
|
+
|
|
202
347
|
## TypeScript Support
|
|
203
348
|
|
|
204
349
|
This package is written in TypeScript and includes complete type definitions:
|
|
@@ -207,32 +352,47 @@ This package is written in TypeScript and includes complete type definitions:
|
|
|
207
352
|
import type {
|
|
208
353
|
CardAccount,
|
|
209
354
|
CreateCardParams,
|
|
355
|
+
BancolombiaAccount,
|
|
356
|
+
CreateBancolombiaAccountParams,
|
|
210
357
|
} from '@bloque/sdk-accounts';
|
|
211
358
|
|
|
212
359
|
// Type-safe card creation
|
|
213
|
-
const
|
|
360
|
+
const cardParams: CreateCardParams = {
|
|
214
361
|
urn: 'did:bloque:user:123e4567',
|
|
215
362
|
name: 'My Card', // Optional
|
|
216
363
|
};
|
|
217
364
|
|
|
218
|
-
const card: CardAccount = await bloque.accounts.card.create(
|
|
365
|
+
const card: CardAccount = await bloque.accounts.card.create(cardParams);
|
|
219
366
|
|
|
220
367
|
// TypeScript infers all card properties with full type safety
|
|
221
368
|
console.log(card.lastFour); // string
|
|
222
369
|
console.log(card.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
|
|
223
370
|
console.log(card.cardType); // 'VIRTUAL' | 'PHYSICAL'
|
|
371
|
+
|
|
372
|
+
// Type-safe Bancolombia account creation
|
|
373
|
+
const accountParams: CreateBancolombiaAccountParams = {
|
|
374
|
+
urn: 'did:bloque:user:123e4567',
|
|
375
|
+
name: 'Main Account', // Optional
|
|
376
|
+
cardUrn: card.urn, // Optional
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const account: BancolombiaAccount = await bloque.accounts.bancolombia.create(accountParams);
|
|
380
|
+
|
|
381
|
+
// TypeScript infers all account properties with full type safety
|
|
382
|
+
console.log(account.referenceCode); // string
|
|
383
|
+
console.log(account.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
|
|
224
384
|
```
|
|
225
385
|
|
|
226
|
-
##
|
|
386
|
+
## Account Status
|
|
227
387
|
|
|
228
|
-
|
|
388
|
+
Both cards and Bancolombia accounts have a status field indicating their current state:
|
|
229
389
|
|
|
230
|
-
- `creation_in_progress`:
|
|
231
|
-
- `creation_failed`:
|
|
232
|
-
- `active`:
|
|
233
|
-
- `disabled`:
|
|
234
|
-
- `frozen`:
|
|
235
|
-
- `deleted`:
|
|
390
|
+
- `creation_in_progress`: Account/card is being created
|
|
391
|
+
- `creation_failed`: Account/card creation failed
|
|
392
|
+
- `active`: Account/card is active and ready to use
|
|
393
|
+
- `disabled`: Account/card has been disabled
|
|
394
|
+
- `frozen`: Account/card has been temporarily frozen
|
|
395
|
+
- `deleted`: Account/card has been deleted
|
|
236
396
|
|
|
237
397
|
## Requirements
|
|
238
398
|
|
package/dist/api-types.d.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { BancolombiaAccount, CreateBancolombiaAccountParams } from './types';
|
|
3
|
+
export declare class BancolombiaClient {
|
|
4
|
+
private readonly httpClient;
|
|
5
|
+
constructor(httpClient: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Create a new Bancolombia account
|
|
8
|
+
*
|
|
9
|
+
* @param params - Bancolombia account creation parameters
|
|
10
|
+
* @returns Promise resolving to the created Bancolombia account
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const account = await bloque.accounts.bancolombia.create({
|
|
15
|
+
* urn: 'did:bloque:user:123',
|
|
16
|
+
* name: 'Main Account'
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
create(params: CreateBancolombiaAccountParams): Promise<BancolombiaAccount>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface CreateBancolombiaAccountParams {
|
|
2
|
+
/**
|
|
3
|
+
* URN of the account holder (user or organization)
|
|
4
|
+
*
|
|
5
|
+
* @example "did:bloque:user:123e4567"
|
|
6
|
+
*/
|
|
7
|
+
urn: string;
|
|
8
|
+
/**
|
|
9
|
+
* Display name for the card
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* URN of an existing card to link with the Bancolombia account
|
|
14
|
+
*
|
|
15
|
+
* @example "did:bloque:card:123e4567"
|
|
16
|
+
*/
|
|
17
|
+
cardUrn?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Custom metadata to attach to the Bancolombia account
|
|
20
|
+
*/
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Bancolombia account response
|
|
25
|
+
*/
|
|
26
|
+
export interface BancolombiaAccount {
|
|
27
|
+
/**
|
|
28
|
+
* Unique resource name for the Bancolombia account
|
|
29
|
+
*/
|
|
30
|
+
urn: string;
|
|
31
|
+
/**
|
|
32
|
+
* Account ID
|
|
33
|
+
*/
|
|
34
|
+
id: string;
|
|
35
|
+
/**
|
|
36
|
+
* Reference code for the Bancolombia account
|
|
37
|
+
*/
|
|
38
|
+
referenceCode: string;
|
|
39
|
+
/**
|
|
40
|
+
* Account status
|
|
41
|
+
*/
|
|
42
|
+
status: 'creation_in_progress' | 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_failed';
|
|
43
|
+
/**
|
|
44
|
+
* Owner URN
|
|
45
|
+
*/
|
|
46
|
+
ownerUrn: string;
|
|
47
|
+
/**
|
|
48
|
+
* Webhook URL (if configured)
|
|
49
|
+
*/
|
|
50
|
+
webhookUrl: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Custom metadata
|
|
53
|
+
*/
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Creation timestamp
|
|
57
|
+
*/
|
|
58
|
+
createdAt: string;
|
|
59
|
+
/**
|
|
60
|
+
* Last update timestamp
|
|
61
|
+
*/
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
}
|
package/dist/card/types.d.ts
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
+
import { BancolombiaClient } from './bancolombia/client';
|
|
2
3
|
import { CardClient } from './card/client';
|
|
3
4
|
/**
|
|
4
5
|
* Accounts client for managing financial accounts and payment methods
|
|
@@ -12,6 +13,7 @@ import { CardClient } from './card/client';
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class AccountsClient {
|
|
14
15
|
private readonly httpClient;
|
|
16
|
+
readonly bancolombia: BancolombiaClient;
|
|
15
17
|
readonly card: CardClient;
|
|
16
18
|
constructor(httpClient: HttpClient);
|
|
17
19
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,8 @@ class CardClient {
|
|
|
42
42
|
},
|
|
43
43
|
metadata: {
|
|
44
44
|
source: "sdk-typescript",
|
|
45
|
-
name: params.name
|
|
45
|
+
name: params.name,
|
|
46
|
+
...params.metadata
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
const response = await this.httpClient.request({
|
|
@@ -67,11 +68,48 @@ class CardClient {
|
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
}
|
|
71
|
+
class BancolombiaClient {
|
|
72
|
+
httpClient;
|
|
73
|
+
constructor(httpClient){
|
|
74
|
+
this.httpClient = httpClient;
|
|
75
|
+
}
|
|
76
|
+
async create(params) {
|
|
77
|
+
const request = {
|
|
78
|
+
holder_urn: params.urn,
|
|
79
|
+
input: {},
|
|
80
|
+
metadata: {
|
|
81
|
+
source: "sdk-typescript",
|
|
82
|
+
name: params.name,
|
|
83
|
+
card_urn: params.cardUrn,
|
|
84
|
+
...params.metadata
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const response = await this.httpClient.request({
|
|
88
|
+
method: 'POST',
|
|
89
|
+
path: '/api/mediums/bancolombia',
|
|
90
|
+
body: request
|
|
91
|
+
});
|
|
92
|
+
const account = response.result.account;
|
|
93
|
+
return {
|
|
94
|
+
urn: account.urn,
|
|
95
|
+
id: account.id,
|
|
96
|
+
referenceCode: account.details.reference_code,
|
|
97
|
+
status: account.status,
|
|
98
|
+
ownerUrn: account.owner_urn,
|
|
99
|
+
webhookUrl: account.webhook_url,
|
|
100
|
+
metadata: account.metadata,
|
|
101
|
+
createdAt: account.created_at,
|
|
102
|
+
updatedAt: account.updated_at
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
70
106
|
class AccountsClient {
|
|
71
107
|
httpClient;
|
|
108
|
+
bancolombia;
|
|
72
109
|
card;
|
|
73
110
|
constructor(httpClient){
|
|
74
111
|
this.httpClient = httpClient;
|
|
112
|
+
this.bancolombia = new BancolombiaClient(this.httpClient);
|
|
75
113
|
this.card = new CardClient(this.httpClient);
|
|
76
114
|
}
|
|
77
115
|
}
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,8 @@ class CardClient {
|
|
|
13
13
|
},
|
|
14
14
|
metadata: {
|
|
15
15
|
source: "sdk-typescript",
|
|
16
|
-
name: params.name
|
|
16
|
+
name: params.name,
|
|
17
|
+
...params.metadata
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
const response = await this.httpClient.request({
|
|
@@ -38,11 +39,48 @@ class CardClient {
|
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
}
|
|
42
|
+
class BancolombiaClient {
|
|
43
|
+
httpClient;
|
|
44
|
+
constructor(httpClient){
|
|
45
|
+
this.httpClient = httpClient;
|
|
46
|
+
}
|
|
47
|
+
async create(params) {
|
|
48
|
+
const request = {
|
|
49
|
+
holder_urn: params.urn,
|
|
50
|
+
input: {},
|
|
51
|
+
metadata: {
|
|
52
|
+
source: "sdk-typescript",
|
|
53
|
+
name: params.name,
|
|
54
|
+
card_urn: params.cardUrn,
|
|
55
|
+
...params.metadata
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const response = await this.httpClient.request({
|
|
59
|
+
method: 'POST',
|
|
60
|
+
path: '/api/mediums/bancolombia',
|
|
61
|
+
body: request
|
|
62
|
+
});
|
|
63
|
+
const account = response.result.account;
|
|
64
|
+
return {
|
|
65
|
+
urn: account.urn,
|
|
66
|
+
id: account.id,
|
|
67
|
+
referenceCode: account.details.reference_code,
|
|
68
|
+
status: account.status,
|
|
69
|
+
ownerUrn: account.owner_urn,
|
|
70
|
+
webhookUrl: account.webhook_url,
|
|
71
|
+
metadata: account.metadata,
|
|
72
|
+
createdAt: account.created_at,
|
|
73
|
+
updatedAt: account.updated_at
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
41
77
|
class AccountsClient {
|
|
42
78
|
httpClient;
|
|
79
|
+
bancolombia;
|
|
43
80
|
card;
|
|
44
81
|
constructor(httpClient){
|
|
45
82
|
this.httpClient = httpClient;
|
|
83
|
+
this.bancolombia = new BancolombiaClient(this.httpClient);
|
|
46
84
|
this.card = new CardClient(this.httpClient);
|
|
47
85
|
}
|
|
48
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-accounts",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bloque",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"node": ">=22"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
|
-
"
|
|
39
|
+
"release": "bun publish",
|
|
40
40
|
"build": "rslib build",
|
|
41
41
|
"dev": "rslib build --watch",
|
|
42
42
|
"clean": "rm -rf node_modules && rm -rf dist",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typecheck": "tsgo --noEmit"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@bloque/sdk-core": "0.0.
|
|
47
|
+
"@bloque/sdk-core": "0.0.11"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@rslib/core": "^0.18.4",
|