@bloque/sdk-accounts 0.0.24 → 0.0.26

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.
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Parameters for listing polygon accounts
3
+ */
4
+ export interface ListPolygonAccountsParams {
5
+ /**
6
+ * URN of the account holder (user or organization) to filter by
7
+ * @example "did:bloque:bloque-root:nestor"
8
+ */
9
+ holderUrn?: string;
10
+ /**
11
+ * URN of a specific polygon account to retrieve
12
+ * @example "did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731"
13
+ */
14
+ urn?: string;
15
+ }
16
+ /**
17
+ * Result of listing polygon accounts
18
+ */
19
+ export interface ListPolygonAccountsResult {
20
+ /** Array of polygon accounts with balance information */
21
+ accounts: PolygonAccount[];
22
+ }
23
+ /**
24
+ * Parameters for creating a polygon account
25
+ */
26
+ export interface CreatePolygonAccountParams {
27
+ /**
28
+ * URN of the account holder (user or organization)
29
+ *
30
+ * @example "did:bloque:user:123e4567"
31
+ */
32
+ holderUrn?: string;
33
+ /**
34
+ * Ledger account ID to associate with the polygon account
35
+ * If not provided, a new ledger account will be created automatically
36
+ */
37
+ ledgerId?: string;
38
+ /**
39
+ * Webhook URL to receive account events
40
+ */
41
+ webhookUrl?: string;
42
+ /**
43
+ * Custom metadata to attach to the polygon account
44
+ * Must be a Record<string, string> (all values must be strings)
45
+ */
46
+ metadata?: Record<string, string>;
47
+ }
48
+ /**
49
+ * Parameters for updating polygon account metadata
50
+ */
51
+ export interface UpdatePolygonMetadataParams {
52
+ /**
53
+ * URN of the polygon account to update
54
+ *
55
+ * @example "did:bloque:account:polygon:0x05B10c9B6241b73fc8c906fB7979eFc7764AB731"
56
+ */
57
+ urn: string;
58
+ /**
59
+ * Metadata to update
60
+ * Note: 'source' is a reserved field and cannot be modified
61
+ */
62
+ metadata: Record<string, string> & {
63
+ source?: never;
64
+ };
65
+ }
66
+ /**
67
+ * Polygon account response
68
+ */
69
+ export interface PolygonAccount {
70
+ /**
71
+ * Unique resource name for the polygon account
72
+ */
73
+ urn: string;
74
+ /**
75
+ * Account ID
76
+ */
77
+ id: string;
78
+ /**
79
+ * Polygon wallet address
80
+ */
81
+ address: string;
82
+ /**
83
+ * Network name (always "polygon")
84
+ */
85
+ network: string;
86
+ /**
87
+ * Account status
88
+ */
89
+ status: 'creation_in_progress' | 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_failed';
90
+ /**
91
+ * Owner URN
92
+ */
93
+ ownerUrn: string;
94
+ /**
95
+ * Ledger account ID associated with the polygon account
96
+ */
97
+ ledgerId: string;
98
+ /**
99
+ * Webhook URL (if configured)
100
+ */
101
+ webhookUrl: string | null;
102
+ /**
103
+ * Custom metadata
104
+ */
105
+ metadata?: Record<string, string>;
106
+ /**
107
+ * Creation timestamp
108
+ */
109
+ createdAt: string;
110
+ /**
111
+ * Last update timestamp
112
+ */
113
+ updatedAt: string;
114
+ /**
115
+ * Token balances (optional, included in list responses and after creation)
116
+ */
117
+ balance?: Record<string, {
118
+ current: string;
119
+ pending: string;
120
+ in: string;
121
+ out: string;
122
+ }>;
123
+ }
package/dist/types.d.ts CHANGED
@@ -1,6 +1,22 @@
1
1
  /**
2
2
  * Public types for @bloque/sdk-accounts
3
3
  */
4
+ /**
5
+ * Options for account creation
6
+ */
7
+ export interface CreateAccountOptions {
8
+ /**
9
+ * If true, wait for the account to become active before returning
10
+ * This will poll the account status every second until it's active
11
+ * @default false
12
+ */
13
+ waitLedger?: boolean;
14
+ /**
15
+ * Maximum time to wait in milliseconds (only applies when waitLedger is true)
16
+ * @default 60000 (60 seconds)
17
+ */
18
+ timeout?: number;
19
+ }
4
20
  /**
5
21
  * Supported asset types for transfers and movements
6
22
  */
@@ -46,3 +62,80 @@ export interface TransferResult {
46
62
  /** Human-readable message about the transfer status */
47
63
  message: string;
48
64
  }
65
+ /**
66
+ * Account status
67
+ */
68
+ export type AccountStatus = 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
69
+ /**
70
+ * Account medium/type
71
+ */
72
+ export type AccountMedium = 'bancolombia' | 'card' | 'virtual' | 'polygon' | 'us-account';
73
+ /**
74
+ * Token balance information
75
+ */
76
+ export interface TokenBalance {
77
+ /** Current balance */
78
+ current: string;
79
+ /** Pending balance */
80
+ pending: string;
81
+ /** Incoming amount */
82
+ in: string;
83
+ /** Outgoing amount */
84
+ out: string;
85
+ }
86
+ /**
87
+ * Generic account response
88
+ * Details type varies based on account medium
89
+ */
90
+ export interface Account<TDetails = unknown> {
91
+ /** Unique account identifier */
92
+ id: string;
93
+ /** Unique resource name for the account */
94
+ urn: string;
95
+ /** Account type/medium */
96
+ medium: AccountMedium;
97
+ /** Account-specific details (structure varies by medium) */
98
+ details: TDetails;
99
+ /** Ledger account ID */
100
+ ledgerId: string;
101
+ /** Account status */
102
+ status: AccountStatus;
103
+ /** Owner URN */
104
+ ownerUrn: string;
105
+ /** Creation timestamp */
106
+ createdAt: string;
107
+ /** Last update timestamp */
108
+ updatedAt: string;
109
+ /** Webhook URL (if configured) */
110
+ webhookUrl: string | null;
111
+ /** Custom metadata */
112
+ metadata?: Record<string, unknown>;
113
+ /** Token balances by asset */
114
+ balance: Record<string, TokenBalance>;
115
+ }
116
+ /**
117
+ * Parameters for listing accounts
118
+ */
119
+ export interface ListAccountsParams {
120
+ /**
121
+ * URN of the account holder (user or organization) to filter by
122
+ * @example "did:bloque:bloque-root:nestor"
123
+ */
124
+ holderUrn?: string;
125
+ /**
126
+ * Specific account URN to retrieve
127
+ * @example "did:bloque:account:card:usr-123:crd-456"
128
+ */
129
+ urn?: string;
130
+ /**
131
+ * Account medium/type to filter by
132
+ */
133
+ medium?: AccountMedium;
134
+ }
135
+ /**
136
+ * Result of listing accounts
137
+ */
138
+ export interface ListAccountsResult {
139
+ /** Array of accounts */
140
+ accounts: Account[];
141
+ }
@@ -0,0 +1,257 @@
1
+ import type { TokenBalance, UsAccountType } from '../internal/wire-types';
2
+ /**
3
+ * Address information for US account creation
4
+ */
5
+ export interface UsAccountAddress {
6
+ /**
7
+ * Street address line 1
8
+ * @example "456 Wall Street"
9
+ */
10
+ streetLine1: string;
11
+ /**
12
+ * Street address line 2 (optional)
13
+ * @example "Suite 789"
14
+ */
15
+ streetLine2?: string;
16
+ /**
17
+ * City
18
+ * @example "New York"
19
+ */
20
+ city: string;
21
+ /**
22
+ * State code (2 letters)
23
+ * @example "NY"
24
+ */
25
+ state: string;
26
+ /**
27
+ * Postal code
28
+ * @example "10005"
29
+ */
30
+ postalCode: string;
31
+ /**
32
+ * Country code (2 letters)
33
+ * @example "US"
34
+ */
35
+ country: string;
36
+ }
37
+ /**
38
+ * Parameters for creating a US account
39
+ */
40
+ export interface CreateUsAccountParams {
41
+ /**
42
+ * URN of the account holder (user or organization)
43
+ * @internal - Not exposed in public documentation
44
+ */
45
+ holderUrn?: string;
46
+ /**
47
+ * Account type (individual or business)
48
+ * @example "individual"
49
+ */
50
+ type: UsAccountType;
51
+ /**
52
+ * First name
53
+ * @example "Robert"
54
+ */
55
+ firstName: string;
56
+ /**
57
+ * Middle name (optional)
58
+ * @example "James"
59
+ */
60
+ middleName?: string;
61
+ /**
62
+ * Last name
63
+ * @example "Johnson"
64
+ */
65
+ lastName: string;
66
+ /**
67
+ * Email address
68
+ * @example "robert.johnson@example.com"
69
+ */
70
+ email: string;
71
+ /**
72
+ * Phone number with country code
73
+ * @example "+12125551234"
74
+ */
75
+ phone: string;
76
+ /**
77
+ * Address information
78
+ */
79
+ address: UsAccountAddress;
80
+ /**
81
+ * Birth date in YYYY-MM-DD format
82
+ * @example "1985-03-15"
83
+ */
84
+ birthDate: string;
85
+ /**
86
+ * Tax identification number (SSN for individuals, EIN for businesses)
87
+ * @example "123-45-6789"
88
+ */
89
+ taxIdentificationNumber: string;
90
+ /**
91
+ * Government ID issuing country (2-letter code)
92
+ * @example "US"
93
+ */
94
+ govIdCountry: string;
95
+ /**
96
+ * Base64-encoded image of government ID front
97
+ */
98
+ govIdImageFront: string;
99
+ /**
100
+ * Signed agreement ID obtained from getTosLink
101
+ * @example "0d139f8e-14b0-4540-92ba-4e66c619b533"
102
+ */
103
+ signedAgreementId: string;
104
+ /**
105
+ * Webhook URL to receive account events
106
+ */
107
+ webhookUrl?: string;
108
+ /**
109
+ * Ledger account ID to associate with this account
110
+ */
111
+ ledgerId?: string;
112
+ /**
113
+ * Custom metadata to associate with the account
114
+ */
115
+ metadata?: Record<string, unknown>;
116
+ }
117
+ /**
118
+ * Parameters for getting TOS link
119
+ */
120
+ export interface GetTosLinkParams {
121
+ /**
122
+ * Redirect URI after user accepts terms of service
123
+ * @example "https://myapp.com/callback"
124
+ */
125
+ redirectUri: string;
126
+ }
127
+ /**
128
+ * Result of getting TOS link
129
+ */
130
+ export interface TosLinkResult {
131
+ /**
132
+ * URL to redirect user to accept terms of service
133
+ * @example "https://dashboard.bridge.xyz/accept-terms-of-service?session_token=4d5d8c45-9feb-422a-bb5e-0fd32e3b3c53"
134
+ */
135
+ url: string;
136
+ }
137
+ /**
138
+ * Parameters for listing US accounts
139
+ */
140
+ export interface ListUsAccountsParams {
141
+ /**
142
+ * URN of the account holder (user or organization) to filter by
143
+ * @example "did:bloque:bloque-root:nestor"
144
+ */
145
+ holderUrn?: string;
146
+ /**
147
+ * URN of a specific US account to retrieve
148
+ * @example "did:bloque:account:us-account:usr-123:us-456"
149
+ */
150
+ urn?: string;
151
+ }
152
+ /**
153
+ * Result of listing US accounts
154
+ */
155
+ export interface ListUsAccountsResult {
156
+ /** Array of US accounts with balance information */
157
+ accounts: UsAccount[];
158
+ }
159
+ /**
160
+ * Parameters for updating US account metadata
161
+ */
162
+ export interface UpdateUsMetadataParams {
163
+ /**
164
+ * URN of the US account to update
165
+ * @example "did:bloque:mediums:us-account:account:123e4567"
166
+ */
167
+ urn: string;
168
+ /**
169
+ * Metadata to update
170
+ */
171
+ metadata: Record<string, unknown>;
172
+ }
173
+ /**
174
+ * US account information
175
+ */
176
+ export interface UsAccount {
177
+ /**
178
+ * Unique resource name for the US account
179
+ */
180
+ urn: string;
181
+ /**
182
+ * US account ID
183
+ */
184
+ id: string;
185
+ /**
186
+ * Account type (individual or business)
187
+ */
188
+ type: UsAccountType;
189
+ /**
190
+ * First name
191
+ */
192
+ firstName: string;
193
+ /**
194
+ * Middle name (if provided)
195
+ */
196
+ middleName?: string;
197
+ /**
198
+ * Last name
199
+ */
200
+ lastName: string;
201
+ /**
202
+ * Email address
203
+ */
204
+ email: string;
205
+ /**
206
+ * Phone number
207
+ */
208
+ phone: string;
209
+ /**
210
+ * Address information
211
+ */
212
+ address: UsAccountAddress;
213
+ /**
214
+ * Birth date in YYYY-MM-DD format
215
+ */
216
+ birthDate: string;
217
+ /**
218
+ * Bank account number (if available)
219
+ */
220
+ accountNumber?: string;
221
+ /**
222
+ * Bank routing number (if available)
223
+ */
224
+ routingNumber?: string;
225
+ /**
226
+ * Current status of the account
227
+ */
228
+ status: 'active' | 'disabled' | 'frozen' | 'deleted' | 'creation_in_progress' | 'creation_failed';
229
+ /**
230
+ * Owner URN
231
+ */
232
+ ownerUrn: string;
233
+ /**
234
+ * Ledger account ID associated with this account
235
+ */
236
+ ledgerId: string;
237
+ /**
238
+ * Webhook URL (if configured)
239
+ */
240
+ webhookUrl: string | null;
241
+ /**
242
+ * Custom metadata
243
+ */
244
+ metadata?: Record<string, unknown>;
245
+ /**
246
+ * Creation timestamp
247
+ */
248
+ createdAt: string;
249
+ /**
250
+ * Last update timestamp
251
+ */
252
+ updatedAt: string;
253
+ /**
254
+ * Token balances (only included in list responses)
255
+ */
256
+ balance?: Record<string, TokenBalance>;
257
+ }
@@ -0,0 +1,170 @@
1
+ import { BaseClient } from '@bloque/sdk-core';
2
+ import type { CreateAccountOptions } from '../types';
3
+ import type { CreateUsAccountParams, GetTosLinkParams, ListUsAccountsParams, ListUsAccountsResult, TosLinkResult, UpdateUsMetadataParams, UsAccount } from './types';
4
+ export declare class UsClient extends BaseClient {
5
+ /**
6
+ * Get Terms of Service acceptance link
7
+ *
8
+ * This method generates a URL where users can accept the terms of service
9
+ * required for US account creation. After acceptance, a signed_agreement_id
10
+ * will be provided which is required for account creation.
11
+ *
12
+ * @param params - TOS link parameters
13
+ * @returns Promise resolving to the TOS acceptance URL
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const tosLink = await bloque.accounts.us.getTosLink({
18
+ * redirectUri: 'https://myapp.com/callback'
19
+ * });
20
+ *
21
+ * // Redirect user to tosLink.url
22
+ * // After acceptance, extract signed_agreement_id from callback
23
+ * ```
24
+ */
25
+ getTosLink(params: GetTosLinkParams): Promise<TosLinkResult>;
26
+ /**
27
+ * Create a new US bank account
28
+ *
29
+ * Creates a US bank account after the user has accepted the terms of service.
30
+ * You must first call getTosLink to obtain a signed_agreement_id.
31
+ *
32
+ * @param params - US account creation parameters
33
+ * @param options - Creation options (optional)
34
+ * @returns Promise resolving to the created US account
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // First, get TOS link and have user accept
39
+ * const tosLink = await bloque.accounts.us.getTosLink({
40
+ * redirectUri: 'https://myapp.com/callback'
41
+ * });
42
+ *
43
+ * // After user accepts, create account with signed_agreement_id
44
+ * const account = await bloque.accounts.us.create({
45
+ * type: 'individual',
46
+ * firstName: 'Robert',
47
+ * middleName: 'James',
48
+ * lastName: 'Johnson',
49
+ * email: 'robert.johnson@example.com',
50
+ * phone: '+12125551234',
51
+ * address: {
52
+ * streetLine1: '456 Wall Street',
53
+ * streetLine2: 'Suite 789',
54
+ * city: 'New York',
55
+ * state: 'NY',
56
+ * postalCode: '10005',
57
+ * country: 'US'
58
+ * },
59
+ * birthDate: '1985-03-15',
60
+ * taxIdentificationNumber: '123-45-6789',
61
+ * govIdCountry: 'US',
62
+ * govIdImageFront: 'base64_encoded_image',
63
+ * signedAgreementId: '0d139f8e-14b0-4540-92ba-4e66c619b533'
64
+ * });
65
+ *
66
+ * // Create and wait for active status
67
+ * const account = await bloque.accounts.us.create({
68
+ * // ... params
69
+ * }, { waitLedger: true });
70
+ * ```
71
+ */
72
+ create(params: CreateUsAccountParams, options?: CreateAccountOptions): Promise<UsAccount>;
73
+ /**
74
+ * List US bank accounts
75
+ *
76
+ * Retrieves a list of US bank accounts, optionally filtered by holder URN or specific account URN.
77
+ *
78
+ * @param params - List parameters (optional)
79
+ * @returns Promise resolving to list of US accounts with balances
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // List all US accounts for the authenticated holder
84
+ * const result = await bloque.accounts.us.list();
85
+ *
86
+ * // List US accounts for a specific holder
87
+ * const result = await bloque.accounts.us.list({
88
+ * holderUrn: 'did:bloque:bloque-root:nestor'
89
+ * });
90
+ *
91
+ * // Get a specific US account
92
+ * const result = await bloque.accounts.us.list({
93
+ * urn: 'did:bloque:account:us-account:usr-123:us-456'
94
+ * });
95
+ * ```
96
+ */
97
+ list(params?: ListUsAccountsParams): Promise<ListUsAccountsResult>;
98
+ /**
99
+ * Update US account metadata
100
+ *
101
+ * @param params - Metadata update parameters
102
+ * @returns Promise resolving to the updated US account
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const account = await bloque.accounts.us.updateMetadata({
107
+ * urn: 'did:bloque:mediums:us-account:account:123',
108
+ * metadata: {
109
+ * updated_by: 'admin',
110
+ * update_reason: 'customer_request'
111
+ * }
112
+ * });
113
+ * ```
114
+ */
115
+ updateMetadata(params: UpdateUsMetadataParams): Promise<UsAccount>;
116
+ /**
117
+ * Activate a US account
118
+ *
119
+ * @param urn - US account URN
120
+ * @returns Promise resolving to the updated US account
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * const account = await bloque.accounts.us.activate(
125
+ * 'did:bloque:mediums:us-account:account:123'
126
+ * );
127
+ * ```
128
+ */
129
+ activate(urn: string): Promise<UsAccount>;
130
+ /**
131
+ * Freeze a US account
132
+ *
133
+ * @param urn - US account URN
134
+ * @returns Promise resolving to the updated US account
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * const account = await bloque.accounts.us.freeze(
139
+ * 'did:bloque:mediums:us-account:account:123'
140
+ * );
141
+ * ```
142
+ */
143
+ freeze(urn: string): Promise<UsAccount>;
144
+ /**
145
+ * Disable a US account
146
+ *
147
+ * @param urn - US account URN
148
+ * @returns Promise resolving to the updated US account
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * const account = await bloque.accounts.us.disable(
153
+ * 'did:bloque:mediums:us-account:account:123'
154
+ * );
155
+ * ```
156
+ */
157
+ disable(urn: string): Promise<UsAccount>;
158
+ /**
159
+ * Private method to poll account status until it becomes active
160
+ */
161
+ private _waitForActiveStatus;
162
+ /**
163
+ * Private method to update account status
164
+ */
165
+ private _updateStatus;
166
+ /**
167
+ * Private method to map API response to UsAccount
168
+ */
169
+ private _mapAccountResponse;
170
+ }
@@ -1,3 +1,25 @@
1
+ /**
2
+ * Parameters for listing virtual accounts
3
+ */
4
+ export interface ListVirtualAccountsParams {
5
+ /**
6
+ * URN of the account holder (user or organization) to filter by
7
+ * @example "did:bloque:bloque-root:nestor"
8
+ */
9
+ holderUrn?: string;
10
+ /**
11
+ * URN of a specific virtual account to retrieve
12
+ * @example "did:bloque:account:virtual:275d10a2-0854-4081-9d61-ea506e917335"
13
+ */
14
+ urn?: string;
15
+ }
16
+ /**
17
+ * Result of listing virtual accounts
18
+ */
19
+ export interface ListVirtualAccountsResult {
20
+ /** Array of virtual accounts with balance information */
21
+ accounts: VirtualAccount[];
22
+ }
1
23
  /**
2
24
  * Parameters for creating a virtual account
3
25
  */
@@ -101,4 +123,13 @@ export interface VirtualAccount {
101
123
  * Last update timestamp
102
124
  */
103
125
  updatedAt: string;
126
+ /**
127
+ * Token balances (optional, included in list responses and after creation)
128
+ */
129
+ balance?: Record<string, {
130
+ current: string;
131
+ pending: string;
132
+ in: string;
133
+ out: string;
134
+ }>;
104
135
  }