@bloque/sdk-compliance 0.0.3

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 ADDED
@@ -0,0 +1,342 @@
1
+ # @bloque/sdk-compliance
2
+
3
+ Compliance and KYC verification client for the [Bloque](https://www.bloque.app) platform.
4
+
5
+ ## Features
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
+ ## Installation
13
+
14
+ This package is included in the main `@bloque/sdk` package. You typically don't need to install it separately.
15
+
16
+ ```bash
17
+ bun add @bloque/sdk
18
+ ```
19
+
20
+ If you need to use this package standalone:
21
+
22
+ ```bash
23
+ bun add @bloque/sdk-compliance @bloque/sdk-core
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### With the Main SDK (Recommended)
29
+
30
+ ```typescript
31
+ import { SDK } from '@bloque/sdk';
32
+
33
+ const bloque = new SDK({
34
+ apiKey: process.env.BLOQUE_API_KEY!,
35
+ mode: 'production',
36
+ });
37
+
38
+ // Start KYC verification
39
+ const verification = await bloque.compliance.kyc.startVerification({
40
+ urn: 'did:bloque:origin:user-123',
41
+ });
42
+
43
+ console.log('Verification URL:', verification.url);
44
+ console.log('Status:', verification.status);
45
+ ```
46
+
47
+ ### Standalone Usage
48
+
49
+ ```typescript
50
+ import { ComplianceClient } from '@bloque/sdk-compliance';
51
+ import { HttpClient } from '@bloque/sdk-core';
52
+
53
+ const httpClient = new HttpClient({
54
+ apiKey: process.env.BLOQUE_API_KEY!,
55
+ mode: 'production',
56
+ });
57
+
58
+ const compliance = new ComplianceClient(httpClient);
59
+
60
+ const verification = await compliance.kyc.startVerification({
61
+ urn: 'did:bloque:origin:user-123',
62
+ });
63
+ ```
64
+
65
+ ## API Reference
66
+
67
+ ### KYC Verification
68
+
69
+ #### `startVerification(params)`
70
+
71
+ Initiates a KYC verification process for a user.
72
+
73
+ **Parameters**:
74
+
75
+ ```typescript
76
+ interface KycVerificationParams {
77
+ /**
78
+ * URN (Uniform Resource Name) that uniquely identifies the user
79
+ * within the system.
80
+ *
81
+ * This value is used to associate the KYC verification process
82
+ * with a specific user.
83
+ *
84
+ * @example "did:bloque:origin:user-123"
85
+ */
86
+ urn: string;
87
+
88
+ /**
89
+ * URL where webhook notifications will be sent when the verification
90
+ * status changes.
91
+ *
92
+ * This is optional. If provided, the platform will send POST requests
93
+ * to this URL with verification status updates.
94
+ *
95
+ * @example "https://api.example.com/webhooks/kyc"
96
+ */
97
+ webhookUrl?: string;
98
+ }
99
+ ```
100
+
101
+ **Returns**:
102
+
103
+ ```typescript
104
+ interface KycVerificationResponse {
105
+ /**
106
+ * URL where the user should complete the verification process.
107
+ * Redirect the user to this URL to complete KYC.
108
+ */
109
+ url: string;
110
+
111
+ /**
112
+ * Current status of the verification
113
+ */
114
+ status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
115
+ }
116
+ ```
117
+
118
+ **Example**:
119
+
120
+ ```typescript
121
+ const verification = await bloque.compliance.kyc.startVerification({
122
+ urn: 'did:bloque:origin:user-123',
123
+ webhookUrl: 'https://api.example.com/webhooks/kyc', // Optional
124
+ });
125
+
126
+ // Redirect user to verification.url
127
+ window.location.href = verification.url;
128
+ ```
129
+
130
+ #### `getVerification(params)`
131
+
132
+ Retrieves the current status of a KYC verification.
133
+
134
+ **Parameters**:
135
+
136
+ ```typescript
137
+ interface GetKycVerificationParams {
138
+ /**
139
+ * URN (Uniform Resource Name) that uniquely identifies the user
140
+ * within the system.
141
+ *
142
+ * @example "did:bloque:user:123e4567"
143
+ */
144
+ urn: string;
145
+ }
146
+ ```
147
+
148
+ **Returns**:
149
+
150
+ ```typescript
151
+ interface KycVerificationResponse {
152
+ /**
153
+ * Current status of the verification
154
+ */
155
+ status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
156
+
157
+ /**
158
+ * URL where the user can complete or view the verification
159
+ */
160
+ url: string;
161
+
162
+ /**
163
+ * Date when the verification was completed (ISO 8601 format)
164
+ * null if verification is not yet completed
165
+ */
166
+ completedAt: string | null;
167
+ }
168
+ ```
169
+
170
+ **Example**:
171
+
172
+ ```typescript
173
+ const status = await bloque.compliance.kyc.getVerification({
174
+ urn: 'did:bloque:user:123e4567',
175
+ });
176
+
177
+ console.log('Status:', status.status);
178
+ console.log('Completed At:', status.completedAt);
179
+
180
+ if (status.status === 'approved') {
181
+ console.log('Verification approved!');
182
+ }
183
+ ```
184
+
185
+ ## Complete Examples
186
+
187
+ ### Basic KYC Verification
188
+
189
+ ```typescript
190
+ import { SDK } from '@bloque/sdk';
191
+ import type { KycVerificationParams } from '@bloque/sdk-compliance';
192
+
193
+ const bloque = new SDK({
194
+ apiKey: process.env.BLOQUE_API_KEY!,
195
+ mode: 'production',
196
+ });
197
+
198
+ async function startUserVerification(
199
+ userUrn: string,
200
+ webhookUrl?: string,
201
+ ) {
202
+ try {
203
+ const params: KycVerificationParams = {
204
+ urn: userUrn,
205
+ webhookUrl,
206
+ };
207
+
208
+ const verification = await bloque.compliance.kyc.startVerification(params);
209
+
210
+ console.log('✓ Verification started');
211
+ console.log(' URL:', verification.url);
212
+ console.log(' Status:', verification.status);
213
+
214
+ return verification;
215
+ } catch (error) {
216
+ console.error('Failed to start verification:', error);
217
+ throw error;
218
+ }
219
+ }
220
+
221
+ // Usage
222
+ await startUserVerification(
223
+ 'did:bloque:origin:user-123',
224
+ 'https://api.example.com/webhooks/kyc',
225
+ );
226
+ ```
227
+
228
+ ### Getting Verification Status
229
+
230
+ ```typescript
231
+ import { SDK } from '@bloque/sdk';
232
+ import type { GetKycVerificationParams } from '@bloque/sdk-compliance';
233
+
234
+ const bloque = new SDK({
235
+ apiKey: process.env.BLOQUE_API_KEY!,
236
+ mode: 'production',
237
+ });
238
+
239
+ async function checkVerificationStatus(userUrn: string) {
240
+ try {
241
+ const params: GetKycVerificationParams = {
242
+ urn: userUrn,
243
+ };
244
+
245
+ const status = await bloque.compliance.kyc.getVerification(params);
246
+
247
+ console.log('✓ Verification status retrieved');
248
+ console.log(' Status:', status.status);
249
+ console.log(' Verification URL:', status.url);
250
+ console.log(' Completed At:', status.completedAt);
251
+
252
+ return status;
253
+ } catch (error) {
254
+ console.error('Failed to get verification status:', error);
255
+ throw error;
256
+ }
257
+ }
258
+
259
+ // Usage
260
+ await checkVerificationStatus('did:bloque:user:123e4567');
261
+ ```
262
+
263
+ ## TypeScript Support
264
+
265
+ This package is written in TypeScript and includes complete type definitions:
266
+
267
+ ```typescript
268
+ import type {
269
+ ComplianceClient,
270
+ KycClient,
271
+ KycVerificationParams,
272
+ KycVerificationResponse,
273
+ GetKycVerificationParams,
274
+ } from '@bloque/sdk-compliance';
275
+
276
+ // Type-safe verification start
277
+ const startParams: KycVerificationParams = {
278
+ urn: 'did:bloque:origin:user-123',
279
+ webhookUrl: 'https://api.example.com/webhooks/kyc', // Optional
280
+ };
281
+
282
+ const verification: KycVerificationResponse =
283
+ await bloque.compliance.kyc.startVerification(startParams);
284
+
285
+ // Type-safe verification status check
286
+ const statusParams: GetKycVerificationParams = {
287
+ urn: 'did:bloque:user:123e4567',
288
+ };
289
+
290
+ const status: KycVerificationStatus =
291
+ await bloque.compliance.kyc.getVerification(statusParams);
292
+ ```
293
+
294
+ ## Error Handling
295
+
296
+ Always wrap API calls in try-catch blocks:
297
+
298
+ ```typescript
299
+ // Start verification
300
+ try {
301
+ const verification = await bloque.compliance.kyc.startVerification({
302
+ urn: userUrn,
303
+ });
304
+ // Handle success
305
+ } catch (error) {
306
+ if (error instanceof Error) {
307
+ console.error('Verification failed:', error.message);
308
+ }
309
+ // Handle error
310
+ }
311
+
312
+ // Get verification status
313
+ try {
314
+ const status = await bloque.compliance.kyc.getVerification({
315
+ urn: userUrn,
316
+ });
317
+ // Handle success
318
+ } catch (error) {
319
+ if (error instanceof Error) {
320
+ console.error('Failed to get status:', error.message);
321
+ }
322
+ // Handle error
323
+ }
324
+ ```
325
+
326
+ ## Requirements
327
+
328
+ - Node.js 22.x or higher / Bun 1.x or higher
329
+ - TypeScript 5.x or higher (for TypeScript projects)
330
+
331
+ ## Links
332
+
333
+ - [Homepage](https://www.bloque.app)
334
+ - [Main SDK Documentation](../sdk/README.md)
335
+ - [GitHub Repository](https://github.com/bloque-app/sdk)
336
+ - [Issue Tracker](https://github.com/bloque-app/sdk/issues)
337
+
338
+ ## License
339
+
340
+ [MIT](../../LICENSE)
341
+
342
+ Copyright (c) 2025-present Bloque Copilot Inc.
@@ -0,0 +1,22 @@
1
+ export type AccompliceType = 'person' | 'company';
2
+ export interface StartKycVerificationRequest {
3
+ urn: string;
4
+ type: 'kyc' | 'kyb';
5
+ accompliceType: AccompliceType;
6
+ webhookUrl?: string;
7
+ }
8
+ export interface StartKycVerificationResponse {
9
+ url: string;
10
+ type: 'kyc' | 'kyb';
11
+ level: 'basic';
12
+ provider: 'AMLBOT';
13
+ status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
14
+ }
15
+ export interface GetKycVerificationResponse {
16
+ type: 'kyc' | 'kyb';
17
+ level: 'basic';
18
+ provider: 'AMLBOT';
19
+ status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
20
+ verification_url: string;
21
+ completed_at: string | null;
22
+ }
@@ -0,0 +1,7 @@
1
+ import type { HttpClient } from '@bloque/sdk-core';
2
+ import { KycClient } from './kyc/client';
3
+ export declare class ComplianceClient {
4
+ private readonly httpClient;
5
+ readonly kyc: KycClient;
6
+ constructor(httpClient: HttpClient);
7
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ KycClient: ()=>KycClient,
28
+ ComplianceClient: ()=>ComplianceClient
29
+ });
30
+ class KycClient {
31
+ httpClient;
32
+ constructor(httpClient){
33
+ this.httpClient = httpClient;
34
+ }
35
+ async startVerification(params) {
36
+ const response = await this.httpClient.request({
37
+ method: 'POST',
38
+ path: '/api/compliance',
39
+ body: {
40
+ urn: params.urn,
41
+ type: 'kyc',
42
+ accompliceType: 'person',
43
+ ...params.webhookUrl && {
44
+ webhookUrl: params.webhookUrl
45
+ }
46
+ }
47
+ });
48
+ return {
49
+ url: response.url,
50
+ status: response.status,
51
+ completedAt: null
52
+ };
53
+ }
54
+ async getVerification(params) {
55
+ const response = await this.httpClient.request({
56
+ method: 'GET',
57
+ path: `/api/compliance/${params.urn}`
58
+ });
59
+ return {
60
+ status: response.status,
61
+ url: response.verification_url,
62
+ completedAt: response.completed_at
63
+ };
64
+ }
65
+ }
66
+ class ComplianceClient {
67
+ httpClient;
68
+ kyc;
69
+ constructor(httpClient){
70
+ this.httpClient = httpClient;
71
+ this.kyc = new KycClient(this.httpClient);
72
+ }
73
+ }
74
+ exports.ComplianceClient = __webpack_exports__.ComplianceClient;
75
+ exports.KycClient = __webpack_exports__.KycClient;
76
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
77
+ "ComplianceClient",
78
+ "KycClient"
79
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
80
+ Object.defineProperty(exports, '__esModule', {
81
+ value: true
82
+ });
@@ -0,0 +1,3 @@
1
+ export * from './client';
2
+ export * from './kyc/client';
3
+ export * from './kyc/types';
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ class KycClient {
2
+ httpClient;
3
+ constructor(httpClient){
4
+ this.httpClient = httpClient;
5
+ }
6
+ async startVerification(params) {
7
+ const response = await this.httpClient.request({
8
+ method: 'POST',
9
+ path: '/api/compliance',
10
+ body: {
11
+ urn: params.urn,
12
+ type: 'kyc',
13
+ accompliceType: 'person',
14
+ ...params.webhookUrl && {
15
+ webhookUrl: params.webhookUrl
16
+ }
17
+ }
18
+ });
19
+ return {
20
+ url: response.url,
21
+ status: response.status,
22
+ completedAt: null
23
+ };
24
+ }
25
+ async getVerification(params) {
26
+ const response = await this.httpClient.request({
27
+ method: 'GET',
28
+ path: `/api/compliance/${params.urn}`
29
+ });
30
+ return {
31
+ status: response.status,
32
+ url: response.verification_url,
33
+ completedAt: response.completed_at
34
+ };
35
+ }
36
+ }
37
+ class ComplianceClient {
38
+ httpClient;
39
+ kyc;
40
+ constructor(httpClient){
41
+ this.httpClient = httpClient;
42
+ this.kyc = new KycClient(this.httpClient);
43
+ }
44
+ }
45
+ export { ComplianceClient, KycClient };
@@ -0,0 +1,8 @@
1
+ import type { HttpClient } from '@bloque/sdk-core';
2
+ import type { GetKycVerificationParams, KycVerificationParams, KycVerificationResponse } from './types';
3
+ export declare class KycClient {
4
+ private readonly httpClient;
5
+ constructor(httpClient: HttpClient);
6
+ startVerification(params: KycVerificationParams): Promise<KycVerificationResponse>;
7
+ getVerification(params: GetKycVerificationParams): Promise<KycVerificationResponse>;
8
+ }
@@ -0,0 +1,46 @@
1
+ export interface KycVerificationParams {
2
+ /**
3
+ * URN (Uniform Resource Name) that uniquely identifies the user
4
+ * within the system.
5
+ *
6
+ * This value is used to associate the KYC verification process
7
+ * with a specific user.
8
+ *
9
+ * @example "did:bloque:origin:..."
10
+ */
11
+ urn: string;
12
+ /**
13
+ * URL where webhook notifications will be sent when the verification
14
+ * status changes.
15
+ *
16
+ * This is optional. If provided, the platform will send POST requests
17
+ * to this URL with verification status updates.
18
+ *
19
+ * @example "https://api.example.com/webhooks/kyc"
20
+ */
21
+ webhookUrl?: string;
22
+ }
23
+ export interface KycVerificationResponse {
24
+ /**
25
+ * Current status of the verification
26
+ */
27
+ status: 'awaiting_compliance_verification' | 'approved' | 'rejected';
28
+ /**
29
+ * URL where the user can complete or view the verification
30
+ */
31
+ url: string;
32
+ /**
33
+ * Date when the verification was completed (ISO 8601 format)
34
+ * null if verification is not yet completed
35
+ */
36
+ completedAt: string | null;
37
+ }
38
+ export interface GetKycVerificationParams {
39
+ /**
40
+ * URN (Uniform Resource Name) that uniquely identifies the user
41
+ * within the system.
42
+ *
43
+ * @example "did:bloque:user:123e4567"
44
+ */
45
+ urn: string;
46
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@bloque/sdk-compliance",
3
+ "version": "0.0.3",
4
+ "type": "module",
5
+ "keywords": [
6
+ "bloque",
7
+ "sdk",
8
+ "api"
9
+ ],
10
+ "license": "MIT",
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "provenance": true
14
+ },
15
+ "homepage": "git+https://github.com/bloque-app/sdk.git#readme",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/bloque-app/sdk.git",
19
+ "directory": "packages/compliance"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js",
25
+ "require": "./dist/index.cjs"
26
+ }
27
+ },
28
+ "main": "./dist/index.cjs",
29
+ "types": "./dist/index.d.ts",
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "engines": {
34
+ "node": ">=22"
35
+ },
36
+ "scripts": {
37
+ "build": "rslib build",
38
+ "dev": "rslib build --watch",
39
+ "clean": "rm -rf node_modules && rm -rf dist",
40
+ "check": "biome check --write",
41
+ "typecheck": "tsgo --noEmit"
42
+ },
43
+ "dependencies": {
44
+ "@bloque/sdk-core": "workspace:*"
45
+ },
46
+ "devDependencies": {
47
+ "@rslib/core": "catalog:",
48
+ "@types/node": "catalog:",
49
+ "@typescript/native-preview": "catalog:",
50
+ "typescript": "catalog:"
51
+ }
52
+ }