@bloque/sdk-compliance 0.0.22 → 0.0.24
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
CHANGED
|
@@ -1,358 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@bloque/sdk-compliance`
|
|
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
|
-
- **KYC Verification**: Start and manage Know Your Customer verification processes
|
|
8
|
-
- **TypeScript First**: Built with TypeScript for complete type safety
|
|
9
|
-
- **Fully Async**: Promise-based API for modern JavaScript workflows
|
|
10
|
-
- **Lightweight**: Minimal dependencies for optimal bundle size
|
|
11
|
-
|
|
12
|
-
> **📌 Important:** All compliance 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.
|
|
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-compliance @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
|
-
origin: 'your-origin', // Required: your origin identifier
|
|
37
|
-
auth: {
|
|
38
|
-
type: 'apiKey',
|
|
39
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
40
|
-
},
|
|
41
|
-
mode: 'production',
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// Connect to user session first
|
|
45
|
-
const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
|
|
46
|
-
|
|
47
|
-
// Start KYC verification through the session
|
|
48
|
-
const verification = await userSession.compliance.kyc.startVerification({
|
|
49
|
-
urn: 'did:bloque:your-origin:user-alias',
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
console.log('Verification URL:', verification.url);
|
|
53
|
-
console.log('Status:', verification.status);
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Standalone Usage
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
import { ComplianceClient } from '@bloque/sdk-compliance';
|
|
60
|
-
import { HttpClient } from '@bloque/sdk-core';
|
|
61
|
-
|
|
62
|
-
const httpClient = new HttpClient({
|
|
63
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
64
|
-
mode: 'production',
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const compliance = new ComplianceClient(httpClient);
|
|
68
|
-
|
|
69
|
-
const verification = await compliance.kyc.startVerification({
|
|
70
|
-
urn: 'did:bloque:origin:user-123',
|
|
71
|
-
});
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## API Reference
|
|
75
|
-
|
|
76
|
-
### KYC Verification
|
|
77
|
-
|
|
78
|
-
#### `startVerification(params)`
|
|
79
|
-
|
|
80
|
-
Initiates a KYC verification process for a user.
|
|
81
|
-
|
|
82
|
-
**Parameters**:
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
interface KycVerificationParams {
|
|
86
|
-
/**
|
|
87
|
-
* URN (Uniform Resource Name) that uniquely identifies the user
|
|
88
|
-
* within the system.
|
|
89
|
-
*
|
|
90
|
-
* This value is used to associate the KYC verification process
|
|
91
|
-
* with a specific user.
|
|
92
|
-
*
|
|
93
|
-
* @example "did:bloque:origin:user-123"
|
|
94
|
-
*/
|
|
95
|
-
urn: string;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* URL where webhook notifications will be sent when the verification
|
|
99
|
-
* status changes.
|
|
100
|
-
*
|
|
101
|
-
* This is optional. If provided, the platform will send POST requests
|
|
102
|
-
* to this URL with verification status updates.
|
|
103
|
-
*
|
|
104
|
-
* @example "https://api.example.com/webhooks/kyc"
|
|
105
|
-
*/
|
|
106
|
-
webhookUrl?: string;
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
**Returns**:
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
interface KycVerificationResponse {
|
|
114
|
-
/**
|
|
115
|
-
* URL where the user should complete the verification process.
|
|
116
|
-
* Redirect the user to this URL to complete KYC.
|
|
117
|
-
*/
|
|
118
|
-
url: string;
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Current status of the verification
|
|
122
|
-
*/
|
|
123
|
-
status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
**Example**:
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
const verification = await bloque.compliance.kyc.startVerification({
|
|
131
|
-
urn: 'did:bloque:origin:user-123',
|
|
132
|
-
webhookUrl: 'https://api.example.com/webhooks/kyc', // Optional
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Redirect user to verification.url
|
|
136
|
-
window.location.href = verification.url;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
#### `getVerification(params)`
|
|
140
|
-
|
|
141
|
-
Retrieves the current status of a KYC verification.
|
|
142
|
-
|
|
143
|
-
**Parameters**:
|
|
144
|
-
|
|
145
|
-
```typescript
|
|
146
|
-
interface GetKycVerificationParams {
|
|
147
|
-
/**
|
|
148
|
-
* URN (Uniform Resource Name) that uniquely identifies the user
|
|
149
|
-
* within the system.
|
|
150
|
-
*
|
|
151
|
-
* @example "did:bloque:user:123e4567"
|
|
152
|
-
*/
|
|
153
|
-
urn: string;
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
**Returns**:
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
interface KycVerificationResponse {
|
|
161
|
-
/**
|
|
162
|
-
* Current status of the verification
|
|
163
|
-
*/
|
|
164
|
-
status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* URL where the user can complete or view the verification
|
|
168
|
-
*/
|
|
169
|
-
url: string;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Date when the verification was completed (ISO 8601 format)
|
|
173
|
-
* null if verification is not yet completed
|
|
174
|
-
*/
|
|
175
|
-
completedAt: string | null;
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
**Example**:
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
const status = await bloque.compliance.kyc.getVerification({
|
|
183
|
-
urn: 'did:bloque:user:123e4567',
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
console.log('Status:', status.status);
|
|
187
|
-
console.log('Completed At:', status.completedAt);
|
|
188
|
-
|
|
189
|
-
if (status.status === 'approved') {
|
|
190
|
-
console.log('Verification approved!');
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Complete Examples
|
|
195
|
-
|
|
196
|
-
### Basic KYC Verification
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
import { SDK } from '@bloque/sdk';
|
|
200
|
-
import type { KycVerificationParams } from '@bloque/sdk-compliance';
|
|
201
|
-
|
|
202
|
-
const bloque = new SDK({
|
|
203
|
-
origin: 'your-origin',
|
|
204
|
-
auth: {
|
|
205
|
-
type: 'apiKey',
|
|
206
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
207
|
-
},
|
|
208
|
-
mode: 'production',
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
async function startUserVerification(
|
|
212
|
-
userUrn: string,
|
|
213
|
-
webhookUrl?: string,
|
|
214
|
-
) {
|
|
215
|
-
try {
|
|
216
|
-
// Connect to user session
|
|
217
|
-
const userSession = await bloque.connect(userUrn);
|
|
218
|
-
|
|
219
|
-
const params: KycVerificationParams = {
|
|
220
|
-
urn: userUrn,
|
|
221
|
-
webhookUrl,
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const verification = await userSession.compliance.kyc.startVerification(params);
|
|
225
|
-
|
|
226
|
-
console.log('✓ Verification started');
|
|
227
|
-
console.log(' URL:', verification.url);
|
|
228
|
-
console.log(' Status:', verification.status);
|
|
229
|
-
|
|
230
|
-
return verification;
|
|
231
|
-
} catch (error) {
|
|
232
|
-
console.error('Failed to start verification:', error);
|
|
233
|
-
throw error;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Usage
|
|
238
|
-
await startUserVerification(
|
|
239
|
-
'did:bloque:your-origin:user-alias',
|
|
240
|
-
'https://api.example.com/webhooks/kyc',
|
|
241
|
-
);
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
### Getting Verification Status
|
|
245
|
-
|
|
246
|
-
```typescript
|
|
247
|
-
import { SDK } from '@bloque/sdk';
|
|
248
|
-
import type { GetKycVerificationParams } from '@bloque/sdk-compliance';
|
|
249
|
-
|
|
250
|
-
const bloque = new SDK({
|
|
251
|
-
apiKey: process.env.BLOQUE_API_KEY!,
|
|
252
|
-
mode: 'production',
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
async function checkVerificationStatus(userUrn: string) {
|
|
256
|
-
try {
|
|
257
|
-
const params: GetKycVerificationParams = {
|
|
258
|
-
urn: userUrn,
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
const status = await bloque.compliance.kyc.getVerification(params);
|
|
262
|
-
|
|
263
|
-
console.log('✓ Verification status retrieved');
|
|
264
|
-
console.log(' Status:', status.status);
|
|
265
|
-
console.log(' Verification URL:', status.url);
|
|
266
|
-
console.log(' Completed At:', status.completedAt);
|
|
267
|
-
|
|
268
|
-
return status;
|
|
269
|
-
} catch (error) {
|
|
270
|
-
console.error('Failed to get verification status:', error);
|
|
271
|
-
throw error;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// Usage
|
|
276
|
-
await checkVerificationStatus('did:bloque:user:123e4567');
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
## TypeScript Support
|
|
280
|
-
|
|
281
|
-
This package is written in TypeScript and includes complete type definitions:
|
|
282
|
-
|
|
283
|
-
```typescript
|
|
284
|
-
import type {
|
|
285
|
-
ComplianceClient,
|
|
286
|
-
KycClient,
|
|
287
|
-
KycVerificationParams,
|
|
288
|
-
KycVerificationResponse,
|
|
289
|
-
GetKycVerificationParams,
|
|
290
|
-
} from '@bloque/sdk-compliance';
|
|
291
|
-
|
|
292
|
-
// Type-safe verification start
|
|
293
|
-
const startParams: KycVerificationParams = {
|
|
294
|
-
urn: 'did:bloque:origin:user-123',
|
|
295
|
-
webhookUrl: 'https://api.example.com/webhooks/kyc', // Optional
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
const verification: KycVerificationResponse =
|
|
299
|
-
await bloque.compliance.kyc.startVerification(startParams);
|
|
300
|
-
|
|
301
|
-
// Type-safe verification status check
|
|
302
|
-
const statusParams: GetKycVerificationParams = {
|
|
303
|
-
urn: 'did:bloque:user:123e4567',
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
const status: KycVerificationStatus =
|
|
307
|
-
await bloque.compliance.kyc.getVerification(statusParams);
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
## Error Handling
|
|
311
|
-
|
|
312
|
-
Always wrap API calls in try-catch blocks:
|
|
313
|
-
|
|
314
|
-
```typescript
|
|
315
|
-
// Start verification
|
|
316
|
-
try {
|
|
317
|
-
const verification = await bloque.compliance.kyc.startVerification({
|
|
318
|
-
urn: userUrn,
|
|
319
|
-
});
|
|
320
|
-
// Handle success
|
|
321
|
-
} catch (error) {
|
|
322
|
-
if (error instanceof Error) {
|
|
323
|
-
console.error('Verification failed:', error.message);
|
|
324
|
-
}
|
|
325
|
-
// Handle error
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// Get verification status
|
|
329
|
-
try {
|
|
330
|
-
const status = await bloque.compliance.kyc.getVerification({
|
|
331
|
-
urn: userUrn,
|
|
332
|
-
});
|
|
333
|
-
// Handle success
|
|
334
|
-
} catch (error) {
|
|
335
|
-
if (error instanceof Error) {
|
|
336
|
-
console.error('Failed to get status:', error.message);
|
|
337
|
-
}
|
|
338
|
-
// Handle error
|
|
339
|
-
}
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
## Requirements
|
|
343
|
-
|
|
344
|
-
- Node.js 22.x or higher / Bun 1.x or higher
|
|
345
|
-
- TypeScript 5.x or higher (for TypeScript projects)
|
|
346
|
-
|
|
347
|
-
## Links
|
|
348
|
-
|
|
349
|
-
- [Homepage](https://www.bloque.app)
|
|
350
|
-
- [Main SDK Documentation](../sdk/README.md)
|
|
351
|
-
- [GitHub Repository](https://github.com/bloque-app/sdk)
|
|
352
|
-
- [Issue Tracker](https://github.com/bloque-app/sdk/issues)
|
|
353
|
-
|
|
354
|
-
## License
|
|
355
|
-
|
|
356
|
-
[MIT](../../LICENSE)
|
|
357
|
-
|
|
358
|
-
Copyright (c) 2025-present Bloque Copilot Inc.
|
|
5
|
+
For documentation, please refer to the [main SDK documentation](../sdk/README.md).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
2
|
import { BaseClient } from '@bloque/sdk-core';
|
|
3
|
-
import { KycClient } from './kyc/client';
|
|
3
|
+
import { KycClient } from './kyc/kyc-client';
|
|
4
4
|
export declare class ComplianceClient extends BaseClient {
|
|
5
5
|
readonly kyc: KycClient;
|
|
6
6
|
constructor(httpClient: HttpClient);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './client';
|
|
2
|
-
export * from './kyc/client';
|
|
1
|
+
export * from './compliance-client';
|
|
2
|
+
export * from './kyc/kyc-client';
|
|
3
3
|
export * from './kyc/types';
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Wire types for Compliance API communication (snake_case format)
|
|
4
|
+
* These types represent the raw API request/response format
|
|
5
|
+
* and should not be used directly by SDK consumers.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* Accomplice type for compliance verification
|
|
10
|
+
*/
|
|
1
11
|
export type AccompliceType = 'person' | 'company';
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* Start KYC verification request body
|
|
15
|
+
*/
|
|
2
16
|
export interface StartKycVerificationRequest {
|
|
3
17
|
urn: string;
|
|
4
18
|
type: 'kyc' | 'kyb';
|
|
5
19
|
accompliceType: AccompliceType;
|
|
6
20
|
webhookUrl?: string;
|
|
7
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* Start KYC verification response
|
|
25
|
+
*/
|
|
8
26
|
export interface StartKycVerificationResponse {
|
|
9
27
|
url: string;
|
|
10
28
|
type: 'kyc' | 'kyb';
|
|
@@ -12,6 +30,10 @@ export interface StartKycVerificationResponse {
|
|
|
12
30
|
provider: 'AMLBOT';
|
|
13
31
|
status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
|
|
14
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
* Get KYC verification response
|
|
36
|
+
*/
|
|
15
37
|
export interface GetKycVerificationResponse {
|
|
16
38
|
type: 'kyc' | 'kyb';
|
|
17
39
|
level: 'basic';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-compliance",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bloque",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"node": ">=22"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@bloque/sdk-core": "0.0.
|
|
37
|
+
"@bloque/sdk-core": "0.0.24"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
File without changes
|