@bloque/sdk 0.0.20 → 0.0.22

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
@@ -30,10 +30,14 @@ This SDK is compatible with multiple JavaScript runtimes:
30
30
 
31
31
  - **TypeScript First**: Built with TypeScript for complete type safety
32
32
  - **Simple API**: Intuitive interface for managing organizations, compliance, accounts, and identity
33
+ - **Identity Registration**: Register individual users (KYC) and businesses (KYB) with multi-method authentication
34
+ - **User Sessions**: Secure user session management with `connect()` for authenticated operations
33
35
  - **Fully Async**: Promise-based API for modern JavaScript workflows
34
36
  - **Lightweight**: Minimal dependencies for optimal bundle size
35
37
  - **Modular**: Import only what you need with tree-shakeable exports
36
38
 
39
+ > **📌 Important:** Most operations require connecting to a user session first using `bloque.connect(urn)`. This ensures proper authentication and authorization. See the [User Sessions](#user-sessions-with-connect) section for details.
40
+
37
41
  ## Installation
38
42
 
39
43
  ```bash
@@ -42,17 +46,39 @@ bun add @bloque/sdk
42
46
 
43
47
  ## Quick Start
44
48
 
49
+ ### Backend (Node.js, Bun, Deno)
50
+
45
51
  ```typescript
46
52
  import { SDK } from '@bloque/sdk';
47
53
  import type { CreateOrgParams } from '@bloque/sdk/orgs';
48
54
 
49
- // Initialize the SDK (server-side only)
55
+ // Initialize the SDK with API key (backend only)
50
56
  const bloque = new SDK({
51
- apiKey: process.env.BLOQUE_API_KEY!,
57
+ origin: 'your-origin-name', // Required: your origin identifier
58
+ auth: {
59
+ type: 'apiKey',
60
+ apiKey: process.env.BLOQUE_API_KEY!,
61
+ },
52
62
  mode: 'production', // or 'sandbox' for testing
63
+ platform: 'node', // optional: 'node' | 'bun' | 'deno'
53
64
  });
54
65
 
55
- // Create an organization
66
+ // Connect to user session for account operations
67
+ async function createCard() {
68
+ // First, connect to the user's session
69
+ const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
70
+
71
+ // Now create a virtual card through the session
72
+ const card = await userSession.accounts.card.create({
73
+ urn: 'did:bloque:your-origin:user-alias',
74
+ name: 'My Virtual Card',
75
+ });
76
+
77
+ console.log('Card created:', card.urn);
78
+ console.log('Last four digits:', card.lastFour);
79
+ }
80
+
81
+ // Create an organization (direct SDK access, no connect needed)
56
82
  async function createOrganization() {
57
83
  const params: CreateOrgParams = {
58
84
  org_type: 'business',
@@ -72,42 +98,161 @@ async function createOrganization() {
72
98
  },
73
99
  };
74
100
 
75
- const organization = await bloque.orgs.create(params);
101
+ const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
102
+ const organization = await userSession.orgs.create(params);
76
103
  console.log('Organization created:', organization);
77
104
  }
105
+ ```
78
106
 
79
- // Create a virtual card
80
- async function createCard() {
81
- const card = await bloque.accounts.card.create({
82
- urn: 'did:bloque:user:123e4567',
83
- name: 'My Virtual Card',
84
- });
107
+ ### Frontend (Browser, React Native)
85
108
 
86
- console.log('Card created:', card.urn);
87
- console.log('Last four digits:', card.lastFour);
88
- }
109
+ ```typescript
110
+ import { SDK } from '@bloque/sdk';
111
+
112
+ // Initialize the SDK with JWT authentication
113
+ const bloque = new SDK({
114
+ auth: { type: 'jwt' },
115
+ mode: 'production',
116
+ platform: 'browser', // or 'react-native'
117
+ // tokenStorage is optional for browser (uses localStorage by default)
118
+ // for react-native, provide a custom storage implementation
119
+ });
120
+
121
+ // After user registration, the SDK automatically stores the JWT
122
+ const result = await bloque.identity.origins.register('ethereum-mainnet', {
123
+ assertionResult: { /* ... */ },
124
+ type: 'individual',
125
+ profile: { /* ... */ }
126
+ });
127
+
128
+ // The token is now stored and used for subsequent requests
129
+ const alias = await bloque.identity.aliases.get('user@example.com');
89
130
  ```
90
131
 
91
132
  ## Configuration
92
133
 
93
134
  ### Initialize the SDK
94
135
 
136
+ The SDK supports different authentication methods depending on where it's running:
137
+
138
+ #### Backend Configuration (API Key)
139
+
140
+ For server-side applications (Node.js, Bun, Deno):
141
+
142
+ ```typescript
143
+ import { SDK } from '@bloque/sdk';
144
+
145
+ const bloque = new SDK({
146
+ auth: {
147
+ type: 'apiKey',
148
+ apiKey: process.env.BLOQUE_API_KEY!, // Your Bloque API key
149
+ },
150
+ mode: 'production', // 'sandbox' or 'production'
151
+ platform: 'node', // optional: 'node' | 'bun' | 'deno' (defaults to 'node')
152
+ });
153
+ ```
154
+
155
+ #### Frontend Configuration (JWT)
156
+
157
+ For client-side applications (Browser, React Native):
158
+
95
159
  ```typescript
96
160
  import { SDK } from '@bloque/sdk';
97
- import type { BloqueConfig } from '@bloque/sdk';
98
161
 
162
+ // Browser
99
163
  const bloque = new SDK({
100
- apiKey: 'your-api-key-here', // Required: Your Bloque API key
101
- mode: 'sandbox', // Required: 'sandbox' or 'production'
164
+ auth: { type: 'jwt' },
165
+ mode: 'production',
166
+ platform: 'browser',
167
+ // tokenStorage is optional - uses localStorage by default
168
+ });
169
+
170
+ // React Native (with custom storage)
171
+ import AsyncStorage from '@react-native-async-storage/async-storage';
172
+
173
+ const bloque = new SDK({
174
+ auth: { type: 'jwt' },
175
+ mode: 'production',
176
+ platform: 'react-native',
177
+ tokenStorage: {
178
+ get: async () => await AsyncStorage.getItem('access_token'),
179
+ set: async (token: string) => await AsyncStorage.setItem('access_token', token),
180
+ clear: async () => await AsyncStorage.removeItem('access_token'),
181
+ },
102
182
  });
103
183
  ```
104
184
 
105
185
  ### Configuration Options
106
186
 
107
- - **`apiKey`** (string, required): Your Bloque API key
108
- - **`mode`** ('sandbox' | 'production', required): Environment mode
187
+ - **`origin`** (string, required): Your origin identifier/namespace
188
+ - This identifies your application or organization in the Bloque platform
189
+ - Example: `'my-app'`, `'bloque-root'`, `'ethereum-mainnet'`
190
+
191
+ - **`auth`** (object, required): Authentication configuration
192
+ - `type: 'apiKey'`: For backend platforms
193
+ - `apiKey` (string, required): Your Bloque API key
194
+ - `type: 'jwt'`: For frontend platforms
195
+ - Requires storing and managing JWT tokens via `tokenStorage`
196
+
197
+ - **`mode`** ('sandbox' | 'production', optional): Environment mode
109
198
  - `sandbox`: For testing and development
110
- - `production`: For live operations
199
+ - `production`: For live operations (default)
200
+
201
+ - **`platform`** (string, optional): Execution platform
202
+ - Backend: `'node'` (default) | `'bun'` | `'deno'`
203
+ - Frontend: `'browser'` | `'react-native'`
204
+ - Determines available authentication methods
205
+
206
+ - **`tokenStorage`** (object, optional): JWT token storage mechanism
207
+ - Required for JWT authentication on non-browser platforms
208
+ - Browser automatically uses `localStorage` if not provided
209
+ - Must implement: `get()`, `set(token)`, `clear()`
210
+
211
+ ### User Sessions with `connect()`
212
+
213
+ Most operations in the SDK require connecting to a user session first. This ensures proper authentication and authorization for user-specific operations.
214
+
215
+ ```typescript
216
+ // Initialize SDK
217
+ const bloque = new SDK({
218
+ origin: 'your-origin',
219
+ auth: {
220
+ type: 'apiKey',
221
+ apiKey: process.env.BLOQUE_API_KEY!,
222
+ },
223
+ mode: 'production',
224
+ });
225
+
226
+ // Connect to user session
227
+ const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
228
+
229
+ // Now perform operations through the session
230
+ const card = await userSession.accounts.card.create({
231
+ urn: 'did:bloque:your-origin:user-alias',
232
+ name: 'My Card',
233
+ });
234
+ ```
235
+
236
+ **What `connect()` does:**
237
+ - Authenticates the user with the specified URN
238
+ - Obtains an access token for the user session
239
+ - Returns a session object with access to: `accounts`, `compliance`, `identity`, `orgs`
240
+
241
+ **URN Format:**
242
+ - Pattern: `did:bloque:{origin}:{user-alias}`
243
+ - Example: `did:bloque:my-app:john-doe`
244
+ - The `{origin}` must match the origin specified in SDK configuration
245
+ - The `{user-alias}` is the user's unique identifier in your origin
246
+
247
+ ### Platform and Authentication Compatibility
248
+
249
+ | Platform | API Key Auth | JWT Auth | Token Storage |
250
+ |----------|--------------|----------|---------------|
251
+ | `node` | ✅ | ✅ | Required for JWT |
252
+ | `bun` | ✅ | ✅ | Required for JWT |
253
+ | `deno` | ✅ | ✅ | Required for JWT |
254
+ | `browser` | ❌ | ✅ | Optional (uses localStorage) |
255
+ | `react-native` | ❌ | ✅ | Required |
111
256
 
112
257
  ## API Reference
113
258
 
@@ -118,7 +263,11 @@ The organizations resource allows you to create and manage organizations in the
118
263
  #### Create an Organization
119
264
 
120
265
  ```typescript
121
- const organization = await bloque.orgs.create(params);
266
+ // Connect to user session first
267
+ const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
268
+
269
+ // Create organization through the session
270
+ const organization = await userSession.orgs.create(params);
122
271
  ```
123
272
 
124
273
  **Parameters**:
@@ -182,8 +331,12 @@ The compliance resource provides KYC (Know Your Customer) verification functiona
182
331
  Start a KYC verification process for a user:
183
332
 
184
333
  ```typescript
185
- const verification = await bloque.compliance.kyc.startVerification({
186
- urn: 'did:bloque:origin:user-id',
334
+ // Connect to user session
335
+ const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
336
+
337
+ // Start KYC verification
338
+ const verification = await userSession.compliance.kyc.startVerification({
339
+ urn: 'did:bloque:your-origin:user-alias',
187
340
  });
188
341
  ```
189
342
 
@@ -262,8 +415,12 @@ The accounts resource allows you to create virtual cards for users.
262
415
  Create a virtual card for a user:
263
416
 
264
417
  ```typescript
265
- const card = await bloque.accounts.card.create({
266
- urn: 'did:bloque:user:123e4567',
418
+ // Connect to user session
419
+ const userSession = await bloque.connect('did:bloque:your-origin:user-alias');
420
+
421
+ // Create virtual card
422
+ const card = await userSession.accounts.card.create({
423
+ urn: 'did:bloque:your-origin:user-alias',
267
424
  name: 'My Virtual Card', // Optional
268
425
  });
269
426
  ```
@@ -306,7 +463,152 @@ interface CardAccount {
306
463
 
307
464
  ### Identity
308
465
 
309
- The identity resource allows you to retrieve user aliases (alternative identifiers like email or phone).
466
+ The identity resource allows you to register identities, retrieve user aliases, and manage authentication origins.
467
+
468
+ #### Register Identity
469
+
470
+ Register a new user or business identity to an authentication origin. Supports individual users (KYC) and businesses (KYB):
471
+
472
+ ```typescript
473
+ // Register individual user
474
+ const individual = await bloque.identity.origins.register('ethereum-mainnet', {
475
+ assertionResult: {
476
+ alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
477
+ challengeType: 'SIGNING_CHALLENGE',
478
+ value: {
479
+ signature: '0x1234567890abcdef...',
480
+ alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6'
481
+ }
482
+ },
483
+ type: 'individual',
484
+ profile: {
485
+ firstName: 'John',
486
+ lastName: 'Doe',
487
+ email: 'john@example.com'
488
+ }
489
+ });
490
+
491
+ // Register business
492
+ const business = await bloque.identity.origins.register('bloque-api', {
493
+ assertionResult: {
494
+ alias: 'business-123',
495
+ challengeType: 'API_KEY',
496
+ value: {
497
+ apiKey: 'sk_live_abc123',
498
+ alias: 'business-123'
499
+ }
500
+ },
501
+ type: 'business',
502
+ profile: {
503
+ legalName: 'Acme Corporation',
504
+ name: 'Acme Corp',
505
+ taxId: '12-3456789',
506
+ type: 'LLC',
507
+ incorporationDate: '2020-01-15',
508
+ addressLine1: '123 Business St',
509
+ city: 'New York',
510
+ state: 'NY',
511
+ postalCode: '10001',
512
+ country: 'United States'
513
+ }
514
+ });
515
+ ```
516
+
517
+ **Parameters**:
518
+
519
+ ```typescript
520
+ // Registration parameters (discriminated union by type)
521
+ type RegisterParams = IndividualRegisterParams | BusinessRegisterParams;
522
+
523
+ interface IndividualRegisterParams {
524
+ assertionResult: AssertionResult;
525
+ extraContext?: Record<string, unknown>;
526
+ type: 'individual';
527
+ profile: UserProfile;
528
+ }
529
+
530
+ interface BusinessRegisterParams {
531
+ assertionResult: AssertionResult;
532
+ extraContext?: Record<string, unknown>;
533
+ type: 'business';
534
+ profile: BusinessProfile;
535
+ }
536
+
537
+ // Assertion result for challenge verification
538
+ interface AssertionResult {
539
+ alias: string; // Identity identifier
540
+ challengeType: 'SIGNING_CHALLENGE' | 'API_KEY' | 'OAUTH_REDIRECT' | 'WEBAUTHN' | 'OTP' | 'PASSWORD';
541
+ value: {
542
+ signature?: string; // For SIGNING_CHALLENGE
543
+ apiKey?: string; // For API_KEY
544
+ alias: string;
545
+ };
546
+ originalChallengeParams?: {
547
+ challenge: string;
548
+ timestamp: number;
549
+ };
550
+ }
551
+
552
+ // Individual user profile (KYC)
553
+ interface UserProfile {
554
+ firstName?: string;
555
+ lastName?: string;
556
+ birthdate?: string; // ISO 8601 (YYYY-MM-DD)
557
+ email?: string;
558
+ phone?: string;
559
+ gender?: string;
560
+ addressLine1?: string;
561
+ addressLine2?: string;
562
+ city?: string;
563
+ state?: string;
564
+ postalCode?: string;
565
+ neighborhood?: string;
566
+ countryOfBirthCode?: string;
567
+ countryOfResidenceCode?: string;
568
+ personalIdType?: string;
569
+ personalIdNumber?: string;
570
+ }
571
+
572
+ // Business profile (KYB)
573
+ interface BusinessProfile {
574
+ // Required fields
575
+ addressLine1: string;
576
+ city: string;
577
+ country: string;
578
+ incorporationDate: string;
579
+ legalName: string;
580
+ name: string;
581
+ postalCode: string;
582
+ state: string;
583
+ taxId: string;
584
+ type: string;
585
+
586
+ // Optional fields
587
+ addressLine2?: string;
588
+ countryCode?: string;
589
+ email?: string;
590
+ logo?: string;
591
+ phone?: string;
592
+
593
+ // Beneficial owner information
594
+ ownerName?: string;
595
+ ownerIdType?: string;
596
+ ownerIdNumber?: string;
597
+ ownerAddressLine1?: string;
598
+ ownerCity?: string;
599
+ ownerState?: string;
600
+ ownerPostalCode?: string;
601
+ ownerCountryCode?: string;
602
+ }
603
+ ```
604
+
605
+ **Response**:
606
+
607
+ ```typescript
608
+ interface RegisterResult {
609
+ accessToken: string; // JWT access token for authenticated sessions
610
+ }
611
+ ```
310
612
 
311
613
  #### Get Alias
312
614
 
@@ -357,7 +659,10 @@ import type { CreateOrgParams } from '@bloque/sdk/orgs';
357
659
 
358
660
  // Initialize SDK with your API key
359
661
  const bloque = new SDK({
360
- apiKey: process.env.BLOQUE_API_KEY!,
662
+ auth: {
663
+ type: 'apiKey',
664
+ apiKey: process.env.BLOQUE_API_KEY!,
665
+ },
361
666
  mode: 'production',
362
667
  });
363
668
 
@@ -399,7 +704,10 @@ import { SDK } from '@bloque/sdk';
399
704
  import type { CreateOrgParams } from '@bloque/sdk/orgs';
400
705
 
401
706
  const bloque = new SDK({
402
- apiKey: process.env.BLOQUE_API_KEY!,
707
+ auth: {
708
+ type: 'apiKey',
709
+ apiKey: process.env.BLOQUE_API_KEY!,
710
+ },
403
711
  mode: 'sandbox',
404
712
  });
405
713
 
@@ -428,7 +736,10 @@ import { SDK } from '@bloque/sdk';
428
736
  import type { CreateOrgParams } from '@bloque/sdk/orgs';
429
737
 
430
738
  const bloque = new SDK({
431
- apiKey: process.env.BLOQUE_API_KEY!,
739
+ auth: {
740
+ type: 'apiKey',
741
+ apiKey: process.env.BLOQUE_API_KEY!,
742
+ },
432
743
  mode: 'production',
433
744
  });
434
745
 
@@ -476,7 +787,10 @@ import { SDK } from '@bloque/sdk';
476
787
  import type { KycVerificationParams } from '@bloque/sdk/compliance';
477
788
 
478
789
  const bloque = new SDK({
479
- apiKey: process.env.BLOQUE_API_KEY!,
790
+ auth: {
791
+ type: 'apiKey',
792
+ apiKey: process.env.BLOQUE_API_KEY!,
793
+ },
480
794
  mode: 'production',
481
795
  });
482
796
 
@@ -506,7 +820,10 @@ import { SDK } from '@bloque/sdk';
506
820
  import type { GetKycVerificationParams } from '@bloque/sdk/compliance';
507
821
 
508
822
  const bloque = new SDK({
509
- apiKey: process.env.BLOQUE_API_KEY!,
823
+ auth: {
824
+ type: 'apiKey',
825
+ apiKey: process.env.BLOQUE_API_KEY!,
826
+ },
510
827
  mode: 'production',
511
828
  });
512
829
 
@@ -541,7 +858,10 @@ import { SDK } from '@bloque/sdk';
541
858
  import type { CreateCardParams } from '@bloque/sdk/accounts';
542
859
 
543
860
  const bloque = new SDK({
544
- apiKey: process.env.BLOQUE_API_KEY!,
861
+ auth: {
862
+ type: 'apiKey',
863
+ apiKey: process.env.BLOQUE_API_KEY!,
864
+ },
545
865
  mode: 'production',
546
866
  });
547
867
 
@@ -577,7 +897,10 @@ try {
577
897
  import { SDK } from '@bloque/sdk';
578
898
 
579
899
  const bloque = new SDK({
580
- apiKey: process.env.BLOQUE_API_KEY!,
900
+ auth: {
901
+ type: 'apiKey',
902
+ apiKey: process.env.BLOQUE_API_KEY!,
903
+ },
581
904
  mode: 'production',
582
905
  });
583
906
 
@@ -610,6 +933,134 @@ try {
610
933
  }
611
934
  ```
612
935
 
936
+ ### Registering Individual User Identity (KYC)
937
+
938
+ ```typescript
939
+ import { SDK } from '@bloque/sdk';
940
+ import type { IndividualRegisterParams } from '@bloque/sdk/identity';
941
+
942
+ const bloque = new SDK({
943
+ auth: {
944
+ type: 'apiKey',
945
+ apiKey: process.env.BLOQUE_API_KEY!,
946
+ },
947
+ mode: 'production',
948
+ });
949
+
950
+ // Register an individual with blockchain signature
951
+ const params: IndividualRegisterParams = {
952
+ assertionResult: {
953
+ alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
954
+ challengeType: 'SIGNING_CHALLENGE',
955
+ value: {
956
+ signature: '0x1234567890abcdef...',
957
+ alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6'
958
+ },
959
+ originalChallengeParams: {
960
+ challenge: 'bloque-challenge-1234567890',
961
+ timestamp: 1640995200
962
+ }
963
+ },
964
+ type: 'individual',
965
+ profile: {
966
+ firstName: 'John',
967
+ lastName: 'Doe',
968
+ email: 'john.doe@example.com',
969
+ phone: '+1234567890',
970
+ birthdate: '1990-01-15',
971
+ city: 'New York',
972
+ state: 'NY',
973
+ postalCode: '10001',
974
+ addressLine1: '123 Main St',
975
+ countryOfBirthCode: 'USA',
976
+ countryOfResidenceCode: 'USA',
977
+ personalIdType: 'SSN',
978
+ personalIdNumber: '123-45-6789'
979
+ }
980
+ };
981
+
982
+ try {
983
+ const result = await bloque.identity.origins.register('ethereum-mainnet', params);
984
+
985
+ console.log('User registered successfully!');
986
+ console.log('Access token:', result.accessToken);
987
+
988
+ // Store the access token securely for the user's session
989
+ // Use it for subsequent authenticated API calls
990
+ } catch (error) {
991
+ console.error('Registration failed:', error);
992
+ }
993
+ ```
994
+
995
+ ### Registering Business Identity (KYB)
996
+
997
+ ```typescript
998
+ import { SDK } from '@bloque/sdk';
999
+ import type { BusinessRegisterParams } from '@bloque/sdk/identity';
1000
+
1001
+ const bloque = new SDK({
1002
+ auth: {
1003
+ type: 'apiKey',
1004
+ apiKey: process.env.BLOQUE_API_KEY!,
1005
+ },
1006
+ mode: 'production',
1007
+ });
1008
+
1009
+ // Register a business with API key authentication
1010
+ const params: BusinessRegisterParams = {
1011
+ assertionResult: {
1012
+ alias: 'business-123',
1013
+ challengeType: 'API_KEY',
1014
+ value: {
1015
+ apiKey: 'sk_live_abc123def456',
1016
+ alias: 'business-123'
1017
+ }
1018
+ },
1019
+ type: 'business',
1020
+ profile: {
1021
+ // Required business information
1022
+ legalName: 'Acme Corporation',
1023
+ name: 'Acme Corp',
1024
+ taxId: '12-3456789',
1025
+ type: 'LLC',
1026
+ incorporationDate: '2020-01-15',
1027
+ addressLine1: '123 Business St',
1028
+ city: 'New York',
1029
+ state: 'NY',
1030
+ postalCode: '10001',
1031
+ country: 'United States',
1032
+
1033
+ // Optional business information
1034
+ addressLine2: 'Suite 100',
1035
+ countryCode: 'US',
1036
+ email: 'contact@acme.com',
1037
+ phone: '+1-555-0123',
1038
+ logo: 'https://acme.com/logo.png',
1039
+
1040
+ // Beneficial owner information (for compliance)
1041
+ ownerName: 'Jane Smith',
1042
+ ownerIdType: 'SSN',
1043
+ ownerIdNumber: '123-45-6789',
1044
+ ownerAddressLine1: '456 Owner Ave',
1045
+ ownerCity: 'New York',
1046
+ ownerState: 'NY',
1047
+ ownerPostalCode: '10002',
1048
+ ownerCountryCode: 'US'
1049
+ }
1050
+ };
1051
+
1052
+ try {
1053
+ const result = await bloque.identity.origins.register('bloque-api', params);
1054
+
1055
+ console.log('Business registered successfully!');
1056
+ console.log('Access token:', result.accessToken);
1057
+
1058
+ // Use the access token for authenticated API calls
1059
+ } catch (error) {
1060
+ console.error('Business registration failed:', error);
1061
+ }
1062
+ ```
1063
+
613
1064
  ### Using in an API Endpoint
614
1065
 
615
1066
  ```typescript
@@ -617,7 +1068,10 @@ import { SDK } from '@bloque/sdk';
617
1068
  import type { CreateOrgParams } from '@bloque/sdk/orgs';
618
1069
 
619
1070
  const bloque = new SDK({
620
- apiKey: process.env.BLOQUE_API_KEY!,
1071
+ auth: {
1072
+ type: 'apiKey',
1073
+ apiKey: process.env.BLOQUE_API_KEY!,
1074
+ },
621
1075
  mode: process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',
622
1076
  });
623
1077
 
@@ -765,6 +1219,13 @@ import type {
765
1219
  // Identity types
766
1220
  import type {
767
1221
  Alias,
1222
+ RegisterParams,
1223
+ IndividualRegisterParams,
1224
+ BusinessRegisterParams,
1225
+ RegisterResult,
1226
+ UserProfile,
1227
+ BusinessProfile,
1228
+ AssertionResult,
768
1229
  } from '@bloque/sdk/identity';
769
1230
  ```
770
1231
 
package/dist/bloque.d.ts CHANGED
@@ -5,9 +5,12 @@ import { IdentityClient } from '@bloque/sdk-identity';
5
5
  import { OrgsClient } from '@bloque/sdk-orgs';
6
6
  export declare class SDK {
7
7
  private readonly httpClient;
8
- readonly accounts: AccountsClient;
9
- readonly compliance: ComplianceClient;
10
- readonly identity: IdentityClient;
11
- readonly orgs: OrgsClient;
12
8
  constructor(config: BloqueConfig);
9
+ private extractUserAlias;
10
+ connect(urn: string): Promise<{
11
+ accounts: AccountsClient;
12
+ compliance: ComplianceClient;
13
+ identity: IdentityClient;
14
+ orgs: OrgsClient;
15
+ }>;
13
16
  }
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=(e,_)=>{for(var t in _)__webpack_require__.o(_,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:_[t]})},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__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__,{SDK:()=>SDK});const sdk_accounts_namespaceObject=require("@bloque/sdk-accounts"),sdk_compliance_namespaceObject=require("@bloque/sdk-compliance"),sdk_core_namespaceObject=require("@bloque/sdk-core"),sdk_identity_namespaceObject=require("@bloque/sdk-identity"),sdk_orgs_namespaceObject=require("@bloque/sdk-orgs");class SDK{httpClient;accounts;compliance;identity;orgs;constructor(e){this.httpClient=new sdk_core_namespaceObject.HttpClient(e),this.accounts=new sdk_accounts_namespaceObject.AccountsClient(this.httpClient),this.compliance=new sdk_compliance_namespaceObject.ComplianceClient(this.httpClient),this.identity=new sdk_identity_namespaceObject.IdentityClient(this.httpClient),this.orgs=new sdk_orgs_namespaceObject.OrgsClient(this.httpClient)}}for(var __rspack_i in exports.SDK=__webpack_exports__.SDK,__webpack_exports__)-1===["SDK"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
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 _ in t)__webpack_require__.o(t,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:t[_]})},__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__,{SDK:()=>SDK});const sdk_accounts_namespaceObject=require("@bloque/sdk-accounts"),sdk_compliance_namespaceObject=require("@bloque/sdk-compliance"),sdk_core_namespaceObject=require("@bloque/sdk-core"),sdk_identity_namespaceObject=require("@bloque/sdk-identity"),sdk_orgs_namespaceObject=require("@bloque/sdk-orgs");class SDK{httpClient;constructor(e){this.httpClient=new sdk_core_namespaceObject.HttpClient(e)}extractUserAlias(e){let t=e.match(/^did:bloque:[^:]+:([^:]+)$/);if(!t)throw Error(`Invalid user alias URN: ${e}`);return t[1]}async connect(e){let t=this.httpClient.config,_=await this.httpClient.request({path:`/api/origins/${t.origin}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:"apiKey"===t.auth.type?t.auth.apiKey:"",alias:this.extractUserAlias(e)}},extra_context:{}}});return this.httpClient.config.accessToken=_.result.access_token,{accounts:new sdk_accounts_namespaceObject.AccountsClient(this.httpClient),compliance:new sdk_compliance_namespaceObject.ComplianceClient(this.httpClient),identity:new sdk_identity_namespaceObject.IdentityClient(this.httpClient),orgs:new sdk_orgs_namespaceObject.OrgsClient(this.httpClient)}}}for(var __rspack_i in exports.SDK=__webpack_exports__.SDK,__webpack_exports__)-1===["SDK"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{AccountsClient as t}from"@bloque/sdk-accounts";import{ComplianceClient as i}from"@bloque/sdk-compliance";import{HttpClient as o}from"@bloque/sdk-core";import{IdentityClient as e}from"@bloque/sdk-identity";import{OrgsClient as s}from"@bloque/sdk-orgs";class n{httpClient;accounts;compliance;identity;orgs;constructor(n){this.httpClient=new o(n),this.accounts=new t(this.httpClient),this.compliance=new i(this.httpClient),this.identity=new e(this.httpClient),this.orgs=new s(this.httpClient)}}export{n as SDK};
1
+ import{AccountsClient as t}from"@bloque/sdk-accounts";import{ComplianceClient as e}from"@bloque/sdk-compliance";import{HttpClient as i}from"@bloque/sdk-core";import{IdentityClient as o}from"@bloque/sdk-identity";import{OrgsClient as s}from"@bloque/sdk-orgs";class n{httpClient;constructor(t){this.httpClient=new i(t)}extractUserAlias(t){let e=t.match(/^did:bloque:[^:]+:([^:]+)$/);if(!e)throw Error(`Invalid user alias URN: ${t}`);return e[1]}async connect(i){let n=this.httpClient.config,r=await this.httpClient.request({path:`/api/origins/${n.origin}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:"apiKey"===n.auth.type?n.auth.apiKey:"",alias:this.extractUserAlias(i)}},extra_context:{}}});return this.httpClient.config.accessToken=r.result.access_token,{accounts:new t(this.httpClient),compliance:new e(this.httpClient),identity:new o(this.httpClient),orgs:new s(this.httpClient)}}}export{n as SDK};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "Official Bloque SDK",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -63,10 +63,10 @@
63
63
  "node": ">=22"
64
64
  },
65
65
  "dependencies": {
66
- "@bloque/sdk-accounts": "0.0.20",
67
- "@bloque/sdk-compliance": "0.0.20",
68
- "@bloque/sdk-core": "0.0.20",
69
- "@bloque/sdk-identity": "0.0.20",
70
- "@bloque/sdk-orgs": "0.0.20"
66
+ "@bloque/sdk-accounts": "0.0.22",
67
+ "@bloque/sdk-compliance": "0.0.22",
68
+ "@bloque/sdk-core": "0.0.22",
69
+ "@bloque/sdk-identity": "0.0.22",
70
+ "@bloque/sdk-orgs": "0.0.22"
71
71
  }
72
72
  }