@bloque/sdk-accounts 0.0.21 → 0.0.23
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 +3 -793
- package/dist/api-types.d.ts +109 -0
- package/dist/bancolombia/client.d.ts +2 -4
- package/dist/card/client.d.ts +57 -5
- package/dist/card/types.d.ts +67 -1
- package/dist/client.d.ts +24 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,795 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@bloque/sdk-accounts`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
⚠️ **Warning**: This package is intended for internal use. Its release cycle does not follow SemVer, which means we might release breaking changes (change APIs, remove functionality) without any prior warning.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **Virtual Cards**: Create virtual cards instantly
|
|
8
|
-
- **Bancolombia Accounts**: Create Bancolombia accounts with reference codes
|
|
9
|
-
- **TypeScript First**: Built with TypeScript for complete type safety
|
|
10
|
-
- **Simple API**: Minimal input required - just URN and optional name
|
|
11
|
-
- **Fully Async**: Promise-based API for modern JavaScript workflows
|
|
12
|
-
- **Secure**: PCI-compliant card details URL
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
This package is included in the main `@bloque/sdk` package. You typically don't need to install it separately.
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
bun add @bloque/sdk
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
If you need to use this package standalone:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
bun add @bloque/sdk-accounts @bloque/sdk-core
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
### With the Main SDK (Recommended)
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
import { SDK } from '@bloque/sdk';
|
|
34
|
-
|
|
35
|
-
const bloque = new SDK({
|
|
36
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
37
|
-
mode: 'production',
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Create a virtual card
|
|
41
|
-
const card = await bloque.accounts.card.create({
|
|
42
|
-
urn: 'did:bloque:user:123',
|
|
43
|
-
name: 'My Virtual Card', // Optional
|
|
44
|
-
ledgerId: 'ledger_123', // Optional - associate with ledger account
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
console.log('Card created:', card.urn);
|
|
48
|
-
console.log('Last four digits:', card.lastFour);
|
|
49
|
-
console.log('Card details URL:', card.detailsUrl);
|
|
50
|
-
console.log('Ledger ID:', card.ledgerId);
|
|
51
|
-
console.log('Status:', card.status);
|
|
52
|
-
|
|
53
|
-
// Create a Bancolombia account
|
|
54
|
-
const bancolombiaAccount = await bloque.accounts.bancolombia.create({
|
|
55
|
-
urn: 'did:bloque:user:123',
|
|
56
|
-
name: 'Main Account', // Optional
|
|
57
|
-
ledgerId: 'ledger_123', // Optional - associate with ledger account
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
console.log('Bancolombia account created:', bancolombiaAccount.urn);
|
|
61
|
-
console.log('Reference code:', bancolombiaAccount.referenceCode);
|
|
62
|
-
console.log('Ledger ID:', bancolombiaAccount.ledgerId);
|
|
63
|
-
console.log('Status:', bancolombiaAccount.status);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## API Reference
|
|
67
|
-
|
|
68
|
-
### Card Accounts
|
|
69
|
-
|
|
70
|
-
Create virtual cards instantly.
|
|
71
|
-
|
|
72
|
-
#### `card.create(params)`
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
const card = await bloque.accounts.card.create({
|
|
76
|
-
urn: 'did:bloque:user:123',
|
|
77
|
-
name: 'My Virtual Card', // Optional
|
|
78
|
-
ledgerId: 'ledger_123', // Optional
|
|
79
|
-
});
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**Parameters**:
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
interface CreateCardParams {
|
|
86
|
-
/**
|
|
87
|
-
* URN of the account holder (user or organization)
|
|
88
|
-
* @example "did:bloque:user:123e4567"
|
|
89
|
-
*/
|
|
90
|
-
urn: string;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Display name for the card (optional)
|
|
94
|
-
*/
|
|
95
|
-
name?: string;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Ledger account ID to associate with the card (optional)
|
|
99
|
-
*/
|
|
100
|
-
ledgerId?: string;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Webhook URL to receive card events (optional)
|
|
104
|
-
*/
|
|
105
|
-
webhookUrl?: string;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Custom metadata to associate with the card (optional)
|
|
109
|
-
*/
|
|
110
|
-
metadata?: Record<string, unknown>;
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Returns**:
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
interface CardAccount {
|
|
118
|
-
urn: string; // Unique resource name
|
|
119
|
-
id: string; // Card account ID
|
|
120
|
-
lastFour: string; // Last four digits
|
|
121
|
-
productType: 'CREDIT' | 'DEBIT'; // Card product type
|
|
122
|
-
status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
|
|
123
|
-
cardType: 'VIRTUAL' | 'PHYSICAL'; // Card type
|
|
124
|
-
detailsUrl: string; // PCI-compliant URL to view card details
|
|
125
|
-
ownerUrn: string; // Owner URN
|
|
126
|
-
ledgerId: string; // Ledger account ID
|
|
127
|
-
webhookUrl: string | null; // Webhook URL (if configured)
|
|
128
|
-
metadata?: Record<string, unknown>; // Custom metadata
|
|
129
|
-
createdAt: string; // Creation timestamp (ISO 8601)
|
|
130
|
-
updatedAt: string; // Last update timestamp (ISO 8601)
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
#### `card.updateMetadata(params)`
|
|
135
|
-
|
|
136
|
-
Update the metadata of an existing card account.
|
|
137
|
-
|
|
138
|
-
```typescript
|
|
139
|
-
const card = await bloque.accounts.card.updateMetadata({
|
|
140
|
-
urn: 'did:bloque:mediums:card:account:123',
|
|
141
|
-
metadata: {
|
|
142
|
-
updated_by: 'admin',
|
|
143
|
-
update_reason: 'customer_request',
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
**Parameters**:
|
|
149
|
-
|
|
150
|
-
```typescript
|
|
151
|
-
interface UpdateCardMetadataParams {
|
|
152
|
-
/**
|
|
153
|
-
* URN of the card account to update
|
|
154
|
-
* @example "did:bloque:mediums:card:account:123e4567"
|
|
155
|
-
*/
|
|
156
|
-
urn: string;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Metadata to update (name and source are reserved fields and cannot be modified)
|
|
160
|
-
*/
|
|
161
|
-
metadata: Record<string, unknown> & {
|
|
162
|
-
name?: never;
|
|
163
|
-
source?: never;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
**Returns**: `CardAccount`
|
|
169
|
-
|
|
170
|
-
#### `card.updateName(urn, name)`
|
|
171
|
-
|
|
172
|
-
Update the name of a card account.
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
const card = await bloque.accounts.card.updateName(
|
|
176
|
-
'did:bloque:mediums:card:account:123',
|
|
177
|
-
'My Business Card'
|
|
178
|
-
);
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
**Parameters**:
|
|
182
|
-
- `urn: string` - Card account URN
|
|
183
|
-
- `name: string` - New name for the card
|
|
184
|
-
|
|
185
|
-
**Returns**: `CardAccount`
|
|
186
|
-
|
|
187
|
-
#### `card.activate(urn)`
|
|
188
|
-
|
|
189
|
-
Activate a card account.
|
|
190
|
-
|
|
191
|
-
```typescript
|
|
192
|
-
const card = await bloque.accounts.card.activate(
|
|
193
|
-
'did:bloque:mediums:card:account:123'
|
|
194
|
-
);
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
**Parameters**: `urn: string` - Card account URN
|
|
198
|
-
|
|
199
|
-
**Returns**: `CardAccount`
|
|
200
|
-
|
|
201
|
-
#### `card.freeze(urn)`
|
|
202
|
-
|
|
203
|
-
Freeze a card account.
|
|
204
|
-
|
|
205
|
-
```typescript
|
|
206
|
-
const card = await bloque.accounts.card.freeze(
|
|
207
|
-
'did:bloque:mediums:card:account:123'
|
|
208
|
-
);
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
**Parameters**: `urn: string` - Card account URN
|
|
212
|
-
|
|
213
|
-
**Returns**: `CardAccount`
|
|
214
|
-
|
|
215
|
-
#### `card.disable(urn)`
|
|
216
|
-
|
|
217
|
-
Disable a card account.
|
|
218
|
-
|
|
219
|
-
```typescript
|
|
220
|
-
const card = await bloque.accounts.card.disable(
|
|
221
|
-
'did:bloque:mediums:card:account:123'
|
|
222
|
-
);
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
**Parameters**: `urn: string` - Card account URN
|
|
226
|
-
|
|
227
|
-
**Returns**: `CardAccount`
|
|
228
|
-
|
|
229
|
-
### Bancolombia Accounts
|
|
230
|
-
|
|
231
|
-
Create Bancolombia accounts with reference codes for local payments.
|
|
232
|
-
|
|
233
|
-
#### `bancolombia.create(params)`
|
|
234
|
-
|
|
235
|
-
```typescript
|
|
236
|
-
const account = await bloque.accounts.bancolombia.create({
|
|
237
|
-
urn: 'did:bloque:user:123',
|
|
238
|
-
name: 'Main Account', // Optional
|
|
239
|
-
ledgerId: 'ledger_123', // Optional
|
|
240
|
-
});
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Parameters**:
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
interface CreateBancolombiaAccountParams {
|
|
247
|
-
/**
|
|
248
|
-
* URN of the account holder (user or organization)
|
|
249
|
-
* @example "did:bloque:user:123e4567"
|
|
250
|
-
*/
|
|
251
|
-
urn: string;
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Display name for the account (optional)
|
|
255
|
-
*/
|
|
256
|
-
name?: string;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Ledger account ID to associate with the Bancolombia account (optional)
|
|
260
|
-
*/
|
|
261
|
-
ledgerId?: string;
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Webhook URL to receive account events (optional)
|
|
265
|
-
*/
|
|
266
|
-
webhookUrl?: string;
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Custom metadata to attach to the Bancolombia account (optional)
|
|
270
|
-
*/
|
|
271
|
-
metadata?: Record<string, unknown>;
|
|
272
|
-
}
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
**Returns**:
|
|
276
|
-
|
|
277
|
-
```typescript
|
|
278
|
-
interface BancolombiaAccount {
|
|
279
|
-
urn: string; // Unique resource name
|
|
280
|
-
id: string; // Account ID
|
|
281
|
-
referenceCode: string; // Reference code for payments
|
|
282
|
-
status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
|
|
283
|
-
ownerUrn: string; // Owner URN
|
|
284
|
-
ledgerId: string; // Ledger account ID
|
|
285
|
-
webhookUrl: string | null; // Webhook URL (if configured)
|
|
286
|
-
metadata?: Record<string, unknown>; // Custom metadata
|
|
287
|
-
createdAt: string; // Creation timestamp (ISO 8601)
|
|
288
|
-
updatedAt: string; // Last update timestamp (ISO 8601)
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
#### `bancolombia.updateMetadata(params)`
|
|
293
|
-
|
|
294
|
-
Update the metadata of an existing Bancolombia account.
|
|
295
|
-
|
|
296
|
-
```typescript
|
|
297
|
-
const account = await bloque.accounts.bancolombia.updateMetadata({
|
|
298
|
-
urn: 'did:bloque:mediums:bancolombia:account:123',
|
|
299
|
-
metadata: {
|
|
300
|
-
updated_by: 'admin',
|
|
301
|
-
update_reason: 'customer_request',
|
|
302
|
-
},
|
|
303
|
-
});
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
**Parameters**:
|
|
307
|
-
|
|
308
|
-
```typescript
|
|
309
|
-
interface UpdateBancolombiaMetadataParams {
|
|
310
|
-
/**
|
|
311
|
-
* URN of the Bancolombia account to update
|
|
312
|
-
* @example "did:bloque:mediums:bancolombia:account:123e4567"
|
|
313
|
-
*/
|
|
314
|
-
urn: string;
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Metadata to update (name and source are reserved fields and cannot be modified)
|
|
318
|
-
*/
|
|
319
|
-
metadata: Record<string, unknown> & {
|
|
320
|
-
name?: never;
|
|
321
|
-
source?: never;
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
**Returns**: `BancolombiaAccount`
|
|
327
|
-
|
|
328
|
-
#### `bancolombia.updateName(urn, name)`
|
|
329
|
-
|
|
330
|
-
Update the name of a Bancolombia account.
|
|
331
|
-
|
|
332
|
-
```typescript
|
|
333
|
-
const account = await bloque.accounts.bancolombia.updateName(
|
|
334
|
-
'did:bloque:mediums:bancolombia:account:123',
|
|
335
|
-
'Main Business Account'
|
|
336
|
-
);
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
**Parameters**:
|
|
340
|
-
- `urn: string` - Bancolombia account URN
|
|
341
|
-
- `name: string` - New name for the account
|
|
342
|
-
|
|
343
|
-
**Returns**: `BancolombiaAccount`
|
|
344
|
-
|
|
345
|
-
#### `bancolombia.activate(urn)`
|
|
346
|
-
|
|
347
|
-
Activate a Bancolombia account.
|
|
348
|
-
|
|
349
|
-
```typescript
|
|
350
|
-
const account = await bloque.accounts.bancolombia.activate(
|
|
351
|
-
'did:bloque:mediums:bancolombia:account:123'
|
|
352
|
-
);
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
**Parameters**: `urn: string` - Bancolombia account URN
|
|
356
|
-
|
|
357
|
-
**Returns**: `BancolombiaAccount`
|
|
358
|
-
|
|
359
|
-
#### `bancolombia.freeze(urn)`
|
|
360
|
-
|
|
361
|
-
Freeze a Bancolombia account.
|
|
362
|
-
|
|
363
|
-
```typescript
|
|
364
|
-
const account = await bloque.accounts.bancolombia.freeze(
|
|
365
|
-
'did:bloque:mediums:bancolombia:account:123'
|
|
366
|
-
);
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
**Parameters**: `urn: string` - Bancolombia account URN
|
|
370
|
-
|
|
371
|
-
**Returns**: `BancolombiaAccount`
|
|
372
|
-
|
|
373
|
-
#### `bancolombia.disable(urn)`
|
|
374
|
-
|
|
375
|
-
Disable a Bancolombia account.
|
|
376
|
-
|
|
377
|
-
```typescript
|
|
378
|
-
const account = await bloque.accounts.bancolombia.disable(
|
|
379
|
-
'did:bloque:mediums:bancolombia:account:123'
|
|
380
|
-
);
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
**Parameters**: `urn: string` - Bancolombia account URN
|
|
384
|
-
|
|
385
|
-
**Returns**: `BancolombiaAccount`
|
|
386
|
-
|
|
387
|
-
## Complete Examples
|
|
388
|
-
|
|
389
|
-
### Basic Card Creation
|
|
390
|
-
|
|
391
|
-
```typescript
|
|
392
|
-
import { SDK } from '@bloque/sdk';
|
|
393
|
-
|
|
394
|
-
const bloque = new SDK({
|
|
395
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
396
|
-
mode: 'production',
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
// Create a virtual card with just URN
|
|
400
|
-
const card = await bloque.accounts.card.create({
|
|
401
|
-
urn: 'did:bloque:user:123e4567',
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
console.log('Card created:', card.urn);
|
|
405
|
-
console.log('Last four:', card.lastFour);
|
|
406
|
-
console.log('Status:', card.status);
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
### Card Creation with Name
|
|
410
|
-
|
|
411
|
-
```typescript
|
|
412
|
-
import { SDK } from '@bloque/sdk';
|
|
413
|
-
|
|
414
|
-
const bloque = new SDK({
|
|
415
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
416
|
-
mode: 'production',
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
// Create a named virtual card
|
|
420
|
-
const card = await bloque.accounts.card.create({
|
|
421
|
-
urn: 'did:bloque:user:123e4567',
|
|
422
|
-
name: 'My Business Card',
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
console.log('Card name:', card.metadata?.name);
|
|
426
|
-
console.log('Card details URL:', card.detailsUrl);
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
### Creating Multiple Cards
|
|
430
|
-
|
|
431
|
-
```typescript
|
|
432
|
-
import { SDK } from '@bloque/sdk';
|
|
433
|
-
|
|
434
|
-
const bloque = new SDK({
|
|
435
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
436
|
-
mode: 'production',
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
const userUrn = 'did:bloque:user:123e4567';
|
|
440
|
-
|
|
441
|
-
// Create multiple cards for the same user
|
|
442
|
-
const personalCard = await bloque.accounts.card.create({
|
|
443
|
-
urn: userUrn,
|
|
444
|
-
name: 'Personal Card',
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
const businessCard = await bloque.accounts.card.create({
|
|
448
|
-
urn: userUrn,
|
|
449
|
-
name: 'Business Card',
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
console.log('Personal card:', personalCard.lastFour);
|
|
453
|
-
console.log('Business card:', businessCard.lastFour);
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
### Updating Card Metadata
|
|
457
|
-
|
|
458
|
-
```typescript
|
|
459
|
-
import { SDK } from '@bloque/sdk';
|
|
460
|
-
|
|
461
|
-
const bloque = new SDK({
|
|
462
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
463
|
-
mode: 'production',
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
// Create a card first
|
|
467
|
-
const card = await bloque.accounts.card.create({
|
|
468
|
-
urn: 'did:bloque:user:123e4567',
|
|
469
|
-
name: 'My Card',
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
// Update the card metadata
|
|
473
|
-
const updatedCard = await bloque.accounts.card.updateMetadata({
|
|
474
|
-
urn: card.urn,
|
|
475
|
-
metadata: {
|
|
476
|
-
updated_by: 'admin',
|
|
477
|
-
update_reason: 'customer_request',
|
|
478
|
-
custom_field: 'custom_value',
|
|
479
|
-
},
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
console.log('Card metadata updated:', updatedCard.metadata);
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
### Updating Card Name
|
|
486
|
-
|
|
487
|
-
```typescript
|
|
488
|
-
import { SDK } from '@bloque/sdk';
|
|
489
|
-
|
|
490
|
-
const bloque = new SDK({
|
|
491
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
492
|
-
mode: 'production',
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
// Update the card name
|
|
496
|
-
const updatedCard = await bloque.accounts.card.updateName(
|
|
497
|
-
'did:bloque:mediums:card:account:123',
|
|
498
|
-
'My Personal Card'
|
|
499
|
-
);
|
|
500
|
-
|
|
501
|
-
console.log('Card name updated:', updatedCard.metadata?.name); // 'My Personal Card'
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
### Updating Card Status
|
|
505
|
-
|
|
506
|
-
```typescript
|
|
507
|
-
import { SDK } from '@bloque/sdk';
|
|
508
|
-
|
|
509
|
-
const bloque = new SDK({
|
|
510
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
511
|
-
mode: 'production',
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
// Freeze a card
|
|
515
|
-
const frozenCard = await bloque.accounts.card.freeze(
|
|
516
|
-
'did:bloque:mediums:card:account:123'
|
|
517
|
-
);
|
|
518
|
-
|
|
519
|
-
console.log('Card status:', frozenCard.status); // 'frozen'
|
|
520
|
-
|
|
521
|
-
// Reactivate the card
|
|
522
|
-
const activeCard = await bloque.accounts.card.activate(
|
|
523
|
-
'did:bloque:mediums:card:account:123'
|
|
524
|
-
);
|
|
525
|
-
|
|
526
|
-
console.log('Card status:', activeCard.status); // 'active'
|
|
527
|
-
|
|
528
|
-
// Disable a card
|
|
529
|
-
const disabledCard = await bloque.accounts.card.disable(
|
|
530
|
-
'did:bloque:mediums:card:account:123'
|
|
531
|
-
);
|
|
532
|
-
|
|
533
|
-
console.log('Card status:', disabledCard.status); // 'disabled'
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
### Error Handling
|
|
537
|
-
|
|
538
|
-
```typescript
|
|
539
|
-
import { SDK } from '@bloque/sdk';
|
|
540
|
-
|
|
541
|
-
const bloque = new SDK({
|
|
542
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
543
|
-
mode: 'production',
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
try {
|
|
547
|
-
const card = await bloque.accounts.card.create({
|
|
548
|
-
urn: 'did:bloque:user:123e4567',
|
|
549
|
-
name: 'My Card',
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
console.log('Card created successfully:', card.urn);
|
|
553
|
-
|
|
554
|
-
// Check if card is ready to use
|
|
555
|
-
if (card.status === 'active') {
|
|
556
|
-
console.log('Card is active and ready to use!');
|
|
557
|
-
} else if (card.status === 'creation_in_progress') {
|
|
558
|
-
console.log('Card is being created...');
|
|
559
|
-
}
|
|
560
|
-
} catch (error) {
|
|
561
|
-
if (error instanceof Error) {
|
|
562
|
-
console.error('Failed to create card:', error.message);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
```
|
|
566
|
-
|
|
567
|
-
### Basic Bancolombia Account Creation
|
|
568
|
-
|
|
569
|
-
```typescript
|
|
570
|
-
import { SDK } from '@bloque/sdk';
|
|
571
|
-
|
|
572
|
-
const bloque = new SDK({
|
|
573
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
574
|
-
mode: 'production',
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
// Create a Bancolombia account with just URN
|
|
578
|
-
const account = await bloque.accounts.bancolombia.create({
|
|
579
|
-
urn: 'did:bloque:user:123e4567',
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
console.log('Account created:', account.urn);
|
|
583
|
-
console.log('Reference code:', account.referenceCode);
|
|
584
|
-
console.log('Status:', account.status);
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
### Bancolombia Account with Ledger Association
|
|
588
|
-
|
|
589
|
-
```typescript
|
|
590
|
-
import { SDK } from '@bloque/sdk';
|
|
591
|
-
|
|
592
|
-
const bloque = new SDK({
|
|
593
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
594
|
-
mode: 'production',
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
const userUrn = 'did:bloque:user:123e4567';
|
|
598
|
-
const ledgerId = 'ledger_abc123';
|
|
599
|
-
|
|
600
|
-
// Create a card associated with a ledger
|
|
601
|
-
const card = await bloque.accounts.card.create({
|
|
602
|
-
urn: userUrn,
|
|
603
|
-
name: 'My Card',
|
|
604
|
-
ledgerId: ledgerId,
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
// Create Bancolombia account with the same ledger
|
|
608
|
-
const account = await bloque.accounts.bancolombia.create({
|
|
609
|
-
urn: userUrn,
|
|
610
|
-
name: 'Main Account',
|
|
611
|
-
ledgerId: ledgerId,
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
console.log('Card URN:', card.urn);
|
|
615
|
-
console.log('Card Ledger ID:', card.ledgerId);
|
|
616
|
-
console.log('Account URN:', account.urn);
|
|
617
|
-
console.log('Account Ledger ID:', account.ledgerId);
|
|
618
|
-
console.log('Reference code for payments:', account.referenceCode);
|
|
619
|
-
```
|
|
620
|
-
|
|
621
|
-
### Bancolombia Account with Metadata
|
|
622
|
-
|
|
623
|
-
```typescript
|
|
624
|
-
import { SDK } from '@bloque/sdk';
|
|
625
|
-
|
|
626
|
-
const bloque = new SDK({
|
|
627
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
628
|
-
mode: 'production',
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
// Create Bancolombia account with custom metadata
|
|
632
|
-
const account = await bloque.accounts.bancolombia.create({
|
|
633
|
-
urn: 'did:bloque:user:123e4567',
|
|
634
|
-
name: 'Business Account',
|
|
635
|
-
metadata: {
|
|
636
|
-
purpose: 'business-payments',
|
|
637
|
-
department: 'sales',
|
|
638
|
-
customField: 'custom-value',
|
|
639
|
-
},
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
console.log('Account created with metadata:', account.metadata);
|
|
643
|
-
console.log('Reference code:', account.referenceCode);
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
### Updating Bancolombia Account Metadata
|
|
647
|
-
|
|
648
|
-
```typescript
|
|
649
|
-
import { SDK } from '@bloque/sdk';
|
|
650
|
-
|
|
651
|
-
const bloque = new SDK({
|
|
652
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
653
|
-
mode: 'production',
|
|
654
|
-
});
|
|
655
|
-
|
|
656
|
-
// Create a Bancolombia account first
|
|
657
|
-
const account = await bloque.accounts.bancolombia.create({
|
|
658
|
-
urn: 'did:bloque:user:123e4567',
|
|
659
|
-
name: 'Main Account',
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
// Update the account metadata
|
|
663
|
-
const updatedAccount = await bloque.accounts.bancolombia.updateMetadata({
|
|
664
|
-
urn: account.urn,
|
|
665
|
-
metadata: {
|
|
666
|
-
updated_by: 'admin',
|
|
667
|
-
update_reason: 'customer_request',
|
|
668
|
-
department: 'finance',
|
|
669
|
-
},
|
|
670
|
-
});
|
|
671
|
-
|
|
672
|
-
console.log('Account metadata updated:', updatedAccount.metadata);
|
|
673
|
-
```
|
|
674
|
-
|
|
675
|
-
### Updating Bancolombia Account Name
|
|
676
|
-
|
|
677
|
-
```typescript
|
|
678
|
-
import { SDK } from '@bloque/sdk';
|
|
679
|
-
|
|
680
|
-
const bloque = new SDK({
|
|
681
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
682
|
-
mode: 'production',
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
// Update the account name
|
|
686
|
-
const updatedAccount = await bloque.accounts.bancolombia.updateName(
|
|
687
|
-
'did:bloque:mediums:bancolombia:account:123',
|
|
688
|
-
'Main Business Account'
|
|
689
|
-
);
|
|
690
|
-
|
|
691
|
-
console.log('Account name updated:', updatedAccount.metadata?.name); // 'Main Business Account'
|
|
692
|
-
```
|
|
693
|
-
|
|
694
|
-
### Updating Bancolombia Account Status
|
|
695
|
-
|
|
696
|
-
```typescript
|
|
697
|
-
import { SDK } from '@bloque/sdk';
|
|
698
|
-
|
|
699
|
-
const bloque = new SDK({
|
|
700
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
701
|
-
mode: 'production',
|
|
702
|
-
});
|
|
703
|
-
|
|
704
|
-
// Freeze a Bancolombia account
|
|
705
|
-
const frozenAccount = await bloque.accounts.bancolombia.freeze(
|
|
706
|
-
'did:bloque:mediums:bancolombia:account:123'
|
|
707
|
-
);
|
|
708
|
-
|
|
709
|
-
console.log('Account status:', frozenAccount.status); // 'frozen'
|
|
710
|
-
|
|
711
|
-
// Reactivate the account
|
|
712
|
-
const activeAccount = await bloque.accounts.bancolombia.activate(
|
|
713
|
-
'did:bloque:mediums:bancolombia:account:123'
|
|
714
|
-
);
|
|
715
|
-
|
|
716
|
-
console.log('Account status:', activeAccount.status); // 'active'
|
|
717
|
-
|
|
718
|
-
// Disable an account
|
|
719
|
-
const disabledAccount = await bloque.accounts.bancolombia.disable(
|
|
720
|
-
'did:bloque:mediums:bancolombia:account:123'
|
|
721
|
-
);
|
|
722
|
-
|
|
723
|
-
console.log('Account status:', disabledAccount.status); // 'disabled'
|
|
724
|
-
```
|
|
725
|
-
|
|
726
|
-
## TypeScript Support
|
|
727
|
-
|
|
728
|
-
This package is written in TypeScript and includes complete type definitions:
|
|
729
|
-
|
|
730
|
-
```typescript
|
|
731
|
-
import type {
|
|
732
|
-
CardAccount,
|
|
733
|
-
CreateCardParams,
|
|
734
|
-
UpdateCardMetadataParams,
|
|
735
|
-
BancolombiaAccount,
|
|
736
|
-
CreateBancolombiaAccountParams,
|
|
737
|
-
UpdateBancolombiaMetadataParams,
|
|
738
|
-
} from '@bloque/sdk-accounts';
|
|
739
|
-
|
|
740
|
-
// Type-safe card creation
|
|
741
|
-
const cardParams: CreateCardParams = {
|
|
742
|
-
urn: 'did:bloque:user:123e4567',
|
|
743
|
-
name: 'My Card', // Optional
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
const card: CardAccount = await bloque.accounts.card.create(cardParams);
|
|
747
|
-
|
|
748
|
-
// TypeScript infers all card properties with full type safety
|
|
749
|
-
console.log(card.lastFour); // string
|
|
750
|
-
console.log(card.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
|
|
751
|
-
console.log(card.cardType); // 'VIRTUAL' | 'PHYSICAL'
|
|
752
|
-
|
|
753
|
-
// Type-safe Bancolombia account creation
|
|
754
|
-
const accountParams: CreateBancolombiaAccountParams = {
|
|
755
|
-
urn: 'did:bloque:user:123e4567',
|
|
756
|
-
name: 'Main Account', // Optional
|
|
757
|
-
ledgerId: 'ledger_123', // Optional
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
const account: BancolombiaAccount = await bloque.accounts.bancolombia.create(accountParams);
|
|
761
|
-
|
|
762
|
-
// TypeScript infers all account properties with full type safety
|
|
763
|
-
console.log(account.referenceCode); // string
|
|
764
|
-
console.log(account.ledgerId); // string
|
|
765
|
-
console.log(account.status); // 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed'
|
|
766
|
-
```
|
|
767
|
-
|
|
768
|
-
## Account Status
|
|
769
|
-
|
|
770
|
-
Both cards and Bancolombia accounts have a status field indicating their current state:
|
|
771
|
-
|
|
772
|
-
- `creation_in_progress`: Account/card is being created
|
|
773
|
-
- `creation_failed`: Account/card creation failed
|
|
774
|
-
- `active`: Account/card is active and ready to use
|
|
775
|
-
- `disabled`: Account/card has been disabled
|
|
776
|
-
- `frozen`: Account/card has been temporarily frozen
|
|
777
|
-
- `deleted`: Account/card has been deleted
|
|
778
|
-
|
|
779
|
-
## Requirements
|
|
780
|
-
|
|
781
|
-
- Node.js 22.x or higher / Bun 1.x or higher
|
|
782
|
-
- TypeScript 5.x or higher (for TypeScript projects)
|
|
783
|
-
|
|
784
|
-
## Links
|
|
785
|
-
|
|
786
|
-
- [Homepage](https://www.bloque.app)
|
|
787
|
-
- [Main SDK Documentation](../sdk/README.md)
|
|
788
|
-
- [GitHub Repository](https://github.com/bloque-app/sdk)
|
|
789
|
-
- [Issue Tracker](https://github.com/bloque-app/sdk/issues)
|
|
790
|
-
|
|
791
|
-
## License
|
|
792
|
-
|
|
793
|
-
[MIT](../../LICENSE)
|
|
794
|
-
|
|
795
|
-
Copyright (c) 2025-present Bloque Copilot Inc.
|
|
5
|
+
For documentation, please refer to the [main SDK documentation](../sdk/README.md).
|
package/dist/api-types.d.ts
CHANGED
|
@@ -62,4 +62,113 @@ export interface UpdateAccountResponse<TDetails = unknown> {
|
|
|
62
62
|
};
|
|
63
63
|
req_id: string;
|
|
64
64
|
}
|
|
65
|
+
export interface TokenBalance {
|
|
66
|
+
current: string;
|
|
67
|
+
pending: string;
|
|
68
|
+
in: string;
|
|
69
|
+
out: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AccountWithBalance<TDetails = unknown> extends Account<TDetails> {
|
|
72
|
+
balance: Record<string, TokenBalance>;
|
|
73
|
+
}
|
|
74
|
+
export interface ListAccountsResponse<TDetails = unknown> {
|
|
75
|
+
accounts: AccountWithBalance<TDetails>[];
|
|
76
|
+
}
|
|
77
|
+
export interface TransactionMetadata {
|
|
78
|
+
amount?: string;
|
|
79
|
+
asset_type?: string;
|
|
80
|
+
card_id?: string;
|
|
81
|
+
card_last_four?: string;
|
|
82
|
+
card_product_type?: string;
|
|
83
|
+
card_provider?: string;
|
|
84
|
+
currency?: string;
|
|
85
|
+
installments?: string;
|
|
86
|
+
local_amount?: string;
|
|
87
|
+
local_currency?: string;
|
|
88
|
+
local_to_usd_rate?: string;
|
|
89
|
+
merchant_address?: string;
|
|
90
|
+
merchant_city?: string;
|
|
91
|
+
merchant_country?: string;
|
|
92
|
+
merchant_id?: string;
|
|
93
|
+
merchant_mcc?: string;
|
|
94
|
+
merchant_name?: string;
|
|
95
|
+
merchant_terminal_id?: string;
|
|
96
|
+
operation_type?: string;
|
|
97
|
+
original_transaction_id?: string;
|
|
98
|
+
selected_asset?: string;
|
|
99
|
+
transaction_id?: string;
|
|
100
|
+
transaction_type?: string;
|
|
101
|
+
type?: string;
|
|
102
|
+
usd_amount?: string;
|
|
103
|
+
user_id?: string;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
}
|
|
106
|
+
export interface TransactionDetails {
|
|
107
|
+
metadata: TransactionMetadata;
|
|
108
|
+
type: string;
|
|
109
|
+
}
|
|
110
|
+
export interface Transaction {
|
|
111
|
+
amount: string;
|
|
112
|
+
asset: string;
|
|
113
|
+
from_account_id: string;
|
|
114
|
+
to_account_id: string;
|
|
115
|
+
direction: 'in' | 'out';
|
|
116
|
+
reference: string;
|
|
117
|
+
rail_name: string;
|
|
118
|
+
details: TransactionDetails;
|
|
119
|
+
created_at: string;
|
|
120
|
+
}
|
|
121
|
+
export interface ListMovementsResponse {
|
|
122
|
+
transactions: Transaction[];
|
|
123
|
+
}
|
|
124
|
+
export interface GetBalanceResponse {
|
|
125
|
+
balance: Record<string, TokenBalance>;
|
|
126
|
+
}
|
|
127
|
+
export type SupportedAsset = 'DUSD/6' | 'KSM/12';
|
|
128
|
+
export interface TransferParams {
|
|
129
|
+
/**
|
|
130
|
+
* URN of the source account
|
|
131
|
+
* @example "did:bloque:account:card:usr-123:crd-456"
|
|
132
|
+
*/
|
|
133
|
+
sourceUrn: string;
|
|
134
|
+
/**
|
|
135
|
+
* URN of the destination account
|
|
136
|
+
* @example "did:bloque:account:virtual:acc-67890"
|
|
137
|
+
*/
|
|
138
|
+
destinationUrn: string;
|
|
139
|
+
/**
|
|
140
|
+
* Amount to transfer
|
|
141
|
+
* @example "1000000000000"
|
|
142
|
+
*/
|
|
143
|
+
amount: string;
|
|
144
|
+
/**
|
|
145
|
+
* Asset to transfer
|
|
146
|
+
* @example "USD"
|
|
147
|
+
*/
|
|
148
|
+
asset: SupportedAsset;
|
|
149
|
+
/**
|
|
150
|
+
* Optional metadata for the transfer
|
|
151
|
+
* @example { reference: "payment-123", note: "Monthly subscription" }
|
|
152
|
+
*/
|
|
153
|
+
metadata?: Record<string, unknown>;
|
|
154
|
+
}
|
|
155
|
+
export interface TransferRequest {
|
|
156
|
+
destination_account_urn: string;
|
|
157
|
+
amount: string;
|
|
158
|
+
asset: string;
|
|
159
|
+
metadata?: Record<string, unknown>;
|
|
160
|
+
}
|
|
161
|
+
export interface TransferResult {
|
|
162
|
+
queueId: string;
|
|
163
|
+
status: 'queued' | 'processing' | 'completed' | 'failed';
|
|
164
|
+
message: string;
|
|
165
|
+
}
|
|
166
|
+
export interface TransferResponse {
|
|
167
|
+
result: {
|
|
168
|
+
queue_id: string;
|
|
169
|
+
status: 'queued' | 'processing' | 'completed' | 'failed';
|
|
170
|
+
message: string;
|
|
171
|
+
};
|
|
172
|
+
req_id: string;
|
|
173
|
+
}
|
|
65
174
|
export {};
|
|
@@ -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,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(httpClient: HttpClient);
|
|
1
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
|
+
import type { TokenBalance } from '../api-types';
|
|
3
|
+
import type { CardAccount, CardMovement, CreateCardParams, GetBalanceParams, ListCardParams, ListMovementsParams, UpdateCardMetadataParams } from './types';
|
|
4
|
+
export declare class CardClient extends BaseClient {
|
|
6
5
|
/**
|
|
7
6
|
* Create a new card account
|
|
8
7
|
*
|
|
@@ -18,6 +17,59 @@ export declare class CardClient {
|
|
|
18
17
|
* ```
|
|
19
18
|
*/
|
|
20
19
|
create(params: CreateCardParams): Promise<CardAccount>;
|
|
20
|
+
/**
|
|
21
|
+
* List card accounts for a holder
|
|
22
|
+
*
|
|
23
|
+
* @param params - List parameters
|
|
24
|
+
* @returns Promise resolving to array of card accounts with balances
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const cards = await bloque.accounts.card.list({
|
|
29
|
+
* holderUrn: 'did:bloque:bloque-whatsapp:573023348486',
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
list(params?: ListCardParams): Promise<CardAccount[]>;
|
|
34
|
+
/**
|
|
35
|
+
* List card account movements/transactions
|
|
36
|
+
*
|
|
37
|
+
* @param params - Movement list parameters
|
|
38
|
+
* @returns Promise resolving to array of card movements
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Basic usage
|
|
43
|
+
* const movements = await bloque.accounts.card.movements({
|
|
44
|
+
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
45
|
+
* asset: 'DUSD/6',
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // With pagination and filters
|
|
49
|
+
* const recentMovements = await bloque.accounts.card.movements({
|
|
50
|
+
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
51
|
+
* asset: 'DUSD/6',
|
|
52
|
+
* limit: 50,
|
|
53
|
+
* direction: 'in',
|
|
54
|
+
* after: '2025-01-01T00:00:00Z',
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
movements(params: ListMovementsParams): Promise<CardMovement[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Get card account balance
|
|
61
|
+
*
|
|
62
|
+
* @param params - Balance query parameters
|
|
63
|
+
* @returns Promise resolving to token balances
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const balances = await bloque.accounts.card.balance({
|
|
68
|
+
* urn: 'did:bloque:account:card:usr-123:crd-456',
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
balance(params: GetBalanceParams): Promise<Record<string, TokenBalance>>;
|
|
21
73
|
/**
|
|
22
74
|
* Update card account metadata
|
|
23
75
|
*
|
package/dist/card/types.d.ts
CHANGED
|
@@ -1,4 +1,66 @@
|
|
|
1
|
-
import type { CardType } from '../api-types';
|
|
1
|
+
import type { CardType, SupportedAsset, TokenBalance, Transaction } from '../api-types';
|
|
2
|
+
export interface ListCardParams {
|
|
3
|
+
/**
|
|
4
|
+
* URN of the account holder to filter by
|
|
5
|
+
*
|
|
6
|
+
* @example "did:bloque:bloque-whatsapp:573023348486"
|
|
7
|
+
*/
|
|
8
|
+
holderUrn: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ListMovementsParams {
|
|
11
|
+
/**
|
|
12
|
+
* URN of the card account
|
|
13
|
+
*
|
|
14
|
+
* @example "did:bloque:account:card:usr-123:crd-456"
|
|
15
|
+
*/
|
|
16
|
+
urn: string;
|
|
17
|
+
/**
|
|
18
|
+
* Asset to filter transactions by
|
|
19
|
+
*
|
|
20
|
+
* @example "USD" (defaults to "USD" if "USD" is provided)
|
|
21
|
+
*/
|
|
22
|
+
asset?: SupportedAsset;
|
|
23
|
+
/**
|
|
24
|
+
* Maximum number of transactions to return
|
|
25
|
+
*
|
|
26
|
+
* @example 50
|
|
27
|
+
*/
|
|
28
|
+
limit?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Filter transactions before this date (ISO 8601)
|
|
31
|
+
*
|
|
32
|
+
* @example "2025-01-01T00:00:00Z"
|
|
33
|
+
*/
|
|
34
|
+
before?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Filter transactions after this date (ISO 8601)
|
|
37
|
+
*
|
|
38
|
+
* @example "2025-01-01T00:00:00Z"
|
|
39
|
+
*/
|
|
40
|
+
after?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Filter by transaction reference
|
|
43
|
+
*
|
|
44
|
+
* @example "0xbff43fa587e0efa275f8b643d95881713c0f0ee13682d049cc452f607241b752"
|
|
45
|
+
*/
|
|
46
|
+
reference?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Filter by transaction direction
|
|
49
|
+
* - 'in' for incoming funds (deposits, transfers received)
|
|
50
|
+
* - 'out' for outgoing funds (withdrawals, transfers sent)
|
|
51
|
+
*/
|
|
52
|
+
direction?: 'in' | 'out';
|
|
53
|
+
}
|
|
54
|
+
export interface CardMovement extends Transaction {
|
|
55
|
+
}
|
|
56
|
+
export interface GetBalanceParams {
|
|
57
|
+
/**
|
|
58
|
+
* URN of the card account
|
|
59
|
+
*
|
|
60
|
+
* @example "did:bloque:account:card:usr-123:crd-456"
|
|
61
|
+
*/
|
|
62
|
+
urn: string;
|
|
63
|
+
}
|
|
2
64
|
export interface CreateCardParams {
|
|
3
65
|
/**
|
|
4
66
|
* URN of the account holder (user or organization)
|
|
@@ -91,4 +153,8 @@ export interface CardAccount {
|
|
|
91
153
|
* Last update timestamp
|
|
92
154
|
*/
|
|
93
155
|
updatedAt: string;
|
|
156
|
+
/**
|
|
157
|
+
* Token balances (only included in list responses)
|
|
158
|
+
*/
|
|
159
|
+
balance?: Record<string, TokenBalance>;
|
|
94
160
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
3
|
+
import type { TransferParams, TransferResult } from './api-types';
|
|
2
4
|
import { BancolombiaClient } from './bancolombia/client';
|
|
3
5
|
import { CardClient } from './card/client';
|
|
4
6
|
/**
|
|
@@ -11,9 +13,29 @@ import { CardClient } from './card/client';
|
|
|
11
13
|
* - us: US bank accounts
|
|
12
14
|
* - polygon: Polygon wallets
|
|
13
15
|
*/
|
|
14
|
-
export declare class AccountsClient {
|
|
15
|
-
private readonly httpClient;
|
|
16
|
+
export declare class AccountsClient extends BaseClient {
|
|
16
17
|
readonly bancolombia: BancolombiaClient;
|
|
17
18
|
readonly card: CardClient;
|
|
18
19
|
constructor(httpClient: HttpClient);
|
|
20
|
+
/**
|
|
21
|
+
* Transfer funds between accounts
|
|
22
|
+
*
|
|
23
|
+
* @param params - Transfer parameters
|
|
24
|
+
* @returns Promise resolving to transfer result
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const transfer = await bloque.accounts.transfer({
|
|
29
|
+
* sourceUrn: 'did:bloque:account:card:usr-123:crd-456',
|
|
30
|
+
* destinationUrn: 'did:bloque:account:virtual:acc-67890',
|
|
31
|
+
* amount: '1000000000000',
|
|
32
|
+
* asset: 'KSM/12',
|
|
33
|
+
* metadata: {
|
|
34
|
+
* reference: 'payment-123',
|
|
35
|
+
* note: 'Monthly subscription'
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
transfer(params: TransferParams): Promise<TransferResult>;
|
|
19
41
|
}
|
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 list(e){let t=new URLSearchParams({holder_urn:e?.holderUrn||this.httpClient.config.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${t.toString()}`})).accounts.map(e=>({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,balance:e.balance}))}async movements(e){let t=new URLSearchParams,a=e.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");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);let r=t.toString(),s=`/api/accounts/${e.urn}/movements${r?`?${r}`:""}`;return(await this.httpClient.request({method:"GET",path:s})).transactions}async balance(e){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${e.urn}/balance`})).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 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)}async transfer(e){let t=e.asset||"DUSD/6";if("DUSD/6"!==t&&"KSM/12"!==t)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:e.destinationUrn,amount:e.amount,asset:t,metadata:e.metadata},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${e.sourceUrn}/transfer`,body:a});return{queueId:r.result.queue_id,status:r.result.status,message:r.result.message}}}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 list(t){let e=new URLSearchParams({holder_urn:t?.holderUrn||this.httpClient.config.urn||"",medium:"card"});return(await this.httpClient.request({method:"GET",path:`/api/accounts?${e.toString()}`})).accounts.map(t=>({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,balance:t.balance}))}async movements(t){let e=new URLSearchParams,a=t.asset||"DUSD/6";if("DUSD/6"!==a&&"KSM/12"!==a)throw Error("Invalid asset type. Supported assets are USD and KSM.");e.set("asset",a),void 0!==t.limit&&e.set("limit",t.limit.toString()),t.before&&e.set("before",t.before),t.after&&e.set("after",t.after),t.reference&&e.set("reference",t.reference),t.direction&&e.set("direction",t.direction);let r=e.toString(),s=`/api/accounts/${t.urn}/movements${r?`?${r}`:""}`;return(await this.httpClient.request({method:"GET",path:s})).transactions}async balance(t){return(await this.httpClient.request({method:"GET",path:`/api/accounts/${t.urn}/balance`})).balance}async updateMetadata(t){let e={metadata:t.metadata},a=await this.httpClient.request({method:"PATCH",path:`/api/accounts/${t.urn}`,body:e});return this._mapAccountResponse(a.result.account)}async 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 r extends t{bancolombia;card;constructor(t){super(t),this.bancolombia=new e(this.httpClient),this.card=new a(this.httpClient)}async transfer(t){let e=t.asset||"DUSD/6";if("DUSD/6"!==e&&"KSM/12"!==e)throw Error("Invalid asset type. Supported assets are USD and KSM.");let a={destination_account_urn:t.destinationUrn,amount:t.amount,asset:e,metadata:t.metadata},r=await this.httpClient.request({method:"POST",path:`/api/accounts/${t.sourceUrn}/transfer`,body:a});return{queueId:r.result.queue_id,status:r.result.status,message:r.result.message}}}export{r 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.23",
|
|
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.23"
|
|
40
40
|
}
|
|
41
41
|
}
|