@bloque/sdk-identity 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 +436 -7
- package/dist/aliases/client.d.ts +2 -4
- package/dist/api-types.d.ts +158 -0
- package/dist/client.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/origins/client.d.ts +91 -2
- package/dist/origins/origin.d.ts +2 -2
- package/dist/origins/types.d.ts +195 -0
- package/dist/types.d.ts +4 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,10 +4,13 @@ Identity, aliases, and OTP authentication API client for the Bloque SDK.
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
+
- **Identity Registration**: Register individual users (KYC) and businesses (KYB) to authentication origins
|
|
8
|
+
- **Multi-Origin Support**: Register identities across blockchain, OAuth, API key, and custom origins
|
|
7
9
|
- **Origin Management**: List and discover all available authentication origins
|
|
8
10
|
- **Aliases**: Get user identity information by email or phone
|
|
9
11
|
- **OTP Origins**: Send OTP codes via WhatsApp or Email
|
|
10
12
|
- **Custom Origins**: Support for custom authentication origins
|
|
13
|
+
- **Multiple Authentication Methods**: SIGNING_CHALLENGE, API_KEY, OAUTH_REDIRECT, WEBAUTHN, OTP, PASSWORD
|
|
11
14
|
- **TypeScript First**: Built with TypeScript for complete type safety
|
|
12
15
|
|
|
13
16
|
## Installation
|
|
@@ -179,6 +182,133 @@ interface Origin {
|
|
|
179
182
|
|
|
180
183
|
**Returns**: `Promise<Origin[]>` - Array of all registered origins
|
|
181
184
|
|
|
185
|
+
#### `origins.register(origin, params)`
|
|
186
|
+
|
|
187
|
+
Register a new user or business identity to a specific origin. Supports both individual users (KYC) and businesses (KYB) with various authentication methods:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Register individual with blockchain signature
|
|
191
|
+
const individual = await identity.origins.register('ethereum-mainnet', {
|
|
192
|
+
assertionResult: {
|
|
193
|
+
alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
|
|
194
|
+
challengeType: 'SIGNING_CHALLENGE',
|
|
195
|
+
value: {
|
|
196
|
+
signature: '0x1234...',
|
|
197
|
+
alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6'
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
type: 'individual',
|
|
201
|
+
profile: {
|
|
202
|
+
firstName: 'John',
|
|
203
|
+
lastName: 'Doe',
|
|
204
|
+
email: 'john@example.com'
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Register business with API key
|
|
209
|
+
const business = await identity.origins.register('bloque-api', {
|
|
210
|
+
assertionResult: {
|
|
211
|
+
alias: 'business-123',
|
|
212
|
+
challengeType: 'API_KEY',
|
|
213
|
+
value: {
|
|
214
|
+
apiKey: 'sk_live_abc123',
|
|
215
|
+
alias: 'business-123'
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
type: 'business',
|
|
219
|
+
profile: {
|
|
220
|
+
legalName: 'Acme Corporation',
|
|
221
|
+
name: 'Acme Corp',
|
|
222
|
+
taxId: '12-3456789',
|
|
223
|
+
type: 'LLC',
|
|
224
|
+
incorporationDate: '2020-01-15',
|
|
225
|
+
addressLine1: '123 Business St',
|
|
226
|
+
city: 'New York',
|
|
227
|
+
state: 'NY',
|
|
228
|
+
postalCode: '10001',
|
|
229
|
+
country: 'United States'
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Parameters**:
|
|
235
|
+
- `origin` (string): Origin namespace to register to (e.g., 'ethereum-mainnet', 'bloque-api')
|
|
236
|
+
- `params` (RegisterParams): Registration parameters
|
|
237
|
+
|
|
238
|
+
**Assertion Challenge Types**:
|
|
239
|
+
- `SIGNING_CHALLENGE`: Blockchain signature verification
|
|
240
|
+
- `API_KEY`: Traditional API key authentication
|
|
241
|
+
- `OAUTH_REDIRECT`: OAuth-based flows
|
|
242
|
+
- `WEBAUTHN`: WebAuthn/passkey authentication
|
|
243
|
+
- `OTP`: One-time password verification
|
|
244
|
+
- `PASSWORD`: Password-based authentication
|
|
245
|
+
|
|
246
|
+
**Individual Profile (KYC)**:
|
|
247
|
+
```typescript
|
|
248
|
+
interface UserProfile {
|
|
249
|
+
firstName?: string;
|
|
250
|
+
lastName?: string;
|
|
251
|
+
birthdate?: string; // ISO 8601 (YYYY-MM-DD)
|
|
252
|
+
email?: string;
|
|
253
|
+
phone?: string;
|
|
254
|
+
gender?: string;
|
|
255
|
+
addressLine1?: string;
|
|
256
|
+
addressLine2?: string;
|
|
257
|
+
city?: string;
|
|
258
|
+
state?: string;
|
|
259
|
+
postalCode?: string;
|
|
260
|
+
neighborhood?: string;
|
|
261
|
+
countryOfBirthCode?: string;
|
|
262
|
+
countryOfResidenceCode?: string;
|
|
263
|
+
personalIdType?: string;
|
|
264
|
+
personalIdNumber?: string;
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Business Profile (KYB)**:
|
|
269
|
+
```typescript
|
|
270
|
+
interface BusinessProfile {
|
|
271
|
+
// Required fields
|
|
272
|
+
addressLine1: string;
|
|
273
|
+
city: string;
|
|
274
|
+
country: string;
|
|
275
|
+
incorporationDate: string; // YYYY-MM-DD
|
|
276
|
+
legalName: string;
|
|
277
|
+
name: string;
|
|
278
|
+
postalCode: string;
|
|
279
|
+
state: string;
|
|
280
|
+
taxId: string;
|
|
281
|
+
type: string; // LLC, Corporation, etc.
|
|
282
|
+
|
|
283
|
+
// Optional fields
|
|
284
|
+
addressLine2?: string;
|
|
285
|
+
countryCode?: string;
|
|
286
|
+
email?: string;
|
|
287
|
+
logo?: string;
|
|
288
|
+
phone?: string;
|
|
289
|
+
|
|
290
|
+
// Owner information
|
|
291
|
+
ownerName?: string;
|
|
292
|
+
ownerIdType?: string;
|
|
293
|
+
ownerIdNumber?: string;
|
|
294
|
+
ownerAddressLine1?: string;
|
|
295
|
+
ownerAddressLine2?: string;
|
|
296
|
+
ownerCity?: string;
|
|
297
|
+
ownerState?: string;
|
|
298
|
+
ownerPostalCode?: string;
|
|
299
|
+
ownerCountryCode?: string;
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Response**:
|
|
304
|
+
```typescript
|
|
305
|
+
interface RegisterResult {
|
|
306
|
+
accessToken: string; // JWT token for authenticated sessions
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Returns**: `Promise<RegisterResult>` - Registration result with access token
|
|
311
|
+
|
|
182
312
|
## Examples
|
|
183
313
|
|
|
184
314
|
### Get Email Alias
|
|
@@ -214,7 +344,10 @@ try {
|
|
|
214
344
|
import { SDK } from '@bloque/sdk';
|
|
215
345
|
|
|
216
346
|
const bloque = new SDK({
|
|
217
|
-
|
|
347
|
+
auth: {
|
|
348
|
+
type: 'apiKey',
|
|
349
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
350
|
+
},
|
|
218
351
|
mode: 'production',
|
|
219
352
|
});
|
|
220
353
|
|
|
@@ -237,7 +370,10 @@ try {
|
|
|
237
370
|
import { SDK } from '@bloque/sdk';
|
|
238
371
|
|
|
239
372
|
const bloque = new SDK({
|
|
240
|
-
|
|
373
|
+
auth: {
|
|
374
|
+
type: 'apiKey',
|
|
375
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
376
|
+
},
|
|
241
377
|
mode: 'production',
|
|
242
378
|
});
|
|
243
379
|
|
|
@@ -260,7 +396,10 @@ try {
|
|
|
260
396
|
import { SDK } from '@bloque/sdk';
|
|
261
397
|
|
|
262
398
|
const bloque = new SDK({
|
|
263
|
-
|
|
399
|
+
auth: {
|
|
400
|
+
type: 'apiKey',
|
|
401
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
402
|
+
},
|
|
264
403
|
mode: 'production',
|
|
265
404
|
});
|
|
266
405
|
|
|
@@ -304,7 +443,10 @@ await authenticateUser('user@example.com');
|
|
|
304
443
|
import { SDK } from '@bloque/sdk';
|
|
305
444
|
|
|
306
445
|
const bloque = new SDK({
|
|
307
|
-
|
|
446
|
+
auth: {
|
|
447
|
+
type: 'apiKey',
|
|
448
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
449
|
+
},
|
|
308
450
|
mode: 'production',
|
|
309
451
|
});
|
|
310
452
|
|
|
@@ -338,7 +480,10 @@ try {
|
|
|
338
480
|
import { SDK } from '@bloque/sdk';
|
|
339
481
|
|
|
340
482
|
const bloque = new SDK({
|
|
341
|
-
|
|
483
|
+
auth: {
|
|
484
|
+
type: 'apiKey',
|
|
485
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
486
|
+
},
|
|
342
487
|
mode: 'production',
|
|
343
488
|
});
|
|
344
489
|
|
|
@@ -361,7 +506,10 @@ try {
|
|
|
361
506
|
import { SDK } from '@bloque/sdk';
|
|
362
507
|
|
|
363
508
|
const bloque = new SDK({
|
|
364
|
-
|
|
509
|
+
auth: {
|
|
510
|
+
type: 'apiKey',
|
|
511
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
512
|
+
},
|
|
365
513
|
mode: 'production',
|
|
366
514
|
});
|
|
367
515
|
|
|
@@ -395,6 +543,213 @@ async function sendOTPWithRetry(phone: string, maxRetries = 3) {
|
|
|
395
543
|
await sendOTPWithRetry('+1234567890');
|
|
396
544
|
```
|
|
397
545
|
|
|
546
|
+
### Register Individual User (KYC)
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
import { SDK } from '@bloque/sdk';
|
|
550
|
+
|
|
551
|
+
const bloque = new SDK({
|
|
552
|
+
auth: {
|
|
553
|
+
type: 'apiKey',
|
|
554
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
555
|
+
},
|
|
556
|
+
mode: 'production',
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
try {
|
|
560
|
+
// Register individual with blockchain signature
|
|
561
|
+
const result = await bloque.identity.origins.register('ethereum-mainnet', {
|
|
562
|
+
assertionResult: {
|
|
563
|
+
alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
|
|
564
|
+
challengeType: 'SIGNING_CHALLENGE',
|
|
565
|
+
value: {
|
|
566
|
+
signature: '0x1234567890abcdef...',
|
|
567
|
+
alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6'
|
|
568
|
+
},
|
|
569
|
+
originalChallengeParams: {
|
|
570
|
+
challenge: 'bloque-challenge-1234567890',
|
|
571
|
+
timestamp: 1640995200
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
type: 'individual',
|
|
575
|
+
profile: {
|
|
576
|
+
firstName: 'John',
|
|
577
|
+
lastName: 'Doe',
|
|
578
|
+
email: 'john.doe@example.com',
|
|
579
|
+
phone: '+1234567890',
|
|
580
|
+
birthdate: '1990-01-15',
|
|
581
|
+
city: 'New York',
|
|
582
|
+
state: 'NY',
|
|
583
|
+
postalCode: '10001',
|
|
584
|
+
addressLine1: '123 Main St',
|
|
585
|
+
countryOfBirthCode: 'USA',
|
|
586
|
+
countryOfResidenceCode: 'USA',
|
|
587
|
+
personalIdType: 'SSN',
|
|
588
|
+
personalIdNumber: '123-45-6789'
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
console.log('User registered successfully!');
|
|
593
|
+
console.log('Access token:', result.accessToken);
|
|
594
|
+
|
|
595
|
+
// Use the access token for authenticated API calls
|
|
596
|
+
// Store it securely for the user's session
|
|
597
|
+
} catch (error) {
|
|
598
|
+
console.error('Registration failed:', error);
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Register Business (KYB)
|
|
603
|
+
|
|
604
|
+
```typescript
|
|
605
|
+
import { SDK } from '@bloque/sdk';
|
|
606
|
+
|
|
607
|
+
const bloque = new SDK({
|
|
608
|
+
auth: {
|
|
609
|
+
type: 'apiKey',
|
|
610
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
611
|
+
},
|
|
612
|
+
mode: 'production',
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
try {
|
|
616
|
+
// Register business with API key authentication
|
|
617
|
+
const result = await bloque.identity.origins.register('bloque-api', {
|
|
618
|
+
assertionResult: {
|
|
619
|
+
alias: 'business-123',
|
|
620
|
+
challengeType: 'API_KEY',
|
|
621
|
+
value: {
|
|
622
|
+
apiKey: 'sk_live_abc123def456',
|
|
623
|
+
alias: 'business-123'
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
type: 'business',
|
|
627
|
+
profile: {
|
|
628
|
+
// Required business information
|
|
629
|
+
legalName: 'Acme Corporation',
|
|
630
|
+
name: 'Acme Corp',
|
|
631
|
+
taxId: '12-3456789',
|
|
632
|
+
type: 'LLC',
|
|
633
|
+
incorporationDate: '2020-01-15',
|
|
634
|
+
addressLine1: '123 Business St',
|
|
635
|
+
city: 'New York',
|
|
636
|
+
state: 'NY',
|
|
637
|
+
postalCode: '10001',
|
|
638
|
+
country: 'United States',
|
|
639
|
+
|
|
640
|
+
// Optional business information
|
|
641
|
+
addressLine2: 'Suite 100',
|
|
642
|
+
countryCode: 'US',
|
|
643
|
+
email: 'contact@acme.com',
|
|
644
|
+
phone: '+1-555-0123',
|
|
645
|
+
logo: 'https://acme.com/logo.png',
|
|
646
|
+
|
|
647
|
+
// Beneficial owner information
|
|
648
|
+
ownerName: 'Jane Smith',
|
|
649
|
+
ownerIdType: 'SSN',
|
|
650
|
+
ownerIdNumber: '123-45-6789',
|
|
651
|
+
ownerAddressLine1: '456 Owner Ave',
|
|
652
|
+
ownerCity: 'New York',
|
|
653
|
+
ownerState: 'NY',
|
|
654
|
+
ownerPostalCode: '10002',
|
|
655
|
+
ownerCountryCode: 'US'
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
console.log('Business registered successfully!');
|
|
660
|
+
console.log('Access token:', result.accessToken);
|
|
661
|
+
|
|
662
|
+
// Use the access token for authenticated API calls
|
|
663
|
+
} catch (error) {
|
|
664
|
+
console.error('Business registration failed:', error);
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
### Multi-Origin Registration Flow
|
|
669
|
+
|
|
670
|
+
```typescript
|
|
671
|
+
import { SDK } from '@bloque/sdk';
|
|
672
|
+
|
|
673
|
+
const bloque = new SDK({
|
|
674
|
+
auth: {
|
|
675
|
+
type: 'apiKey',
|
|
676
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
677
|
+
},
|
|
678
|
+
mode: 'production',
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
async function registerUserAcrossOrigins(userProfile: any) {
|
|
682
|
+
try {
|
|
683
|
+
// Step 1: List available origins
|
|
684
|
+
const origins = await bloque.identity.origins.list();
|
|
685
|
+
const activeOrigins = origins.filter(o => o.status === 'active');
|
|
686
|
+
|
|
687
|
+
console.log(`Found ${activeOrigins.length} active origins`);
|
|
688
|
+
|
|
689
|
+
// Step 2: Register on blockchain origin
|
|
690
|
+
const ethereumOrigin = activeOrigins.find(o => o.namespace === 'ethereum-mainnet');
|
|
691
|
+
|
|
692
|
+
if (ethereumOrigin) {
|
|
693
|
+
const ethereumResult = await bloque.identity.origins.register('ethereum-mainnet', {
|
|
694
|
+
assertionResult: {
|
|
695
|
+
alias: userProfile.walletAddress,
|
|
696
|
+
challengeType: 'SIGNING_CHALLENGE',
|
|
697
|
+
value: {
|
|
698
|
+
signature: userProfile.signature,
|
|
699
|
+
alias: userProfile.walletAddress
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
type: 'individual',
|
|
703
|
+
profile: userProfile.personalInfo
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
console.log('Registered on Ethereum:', ethereumResult.accessToken);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// Step 3: Register on custom origin
|
|
710
|
+
const customResult = await bloque.identity.origins.register('bloque-custom', {
|
|
711
|
+
assertionResult: {
|
|
712
|
+
alias: userProfile.customId,
|
|
713
|
+
challengeType: 'API_KEY',
|
|
714
|
+
value: {
|
|
715
|
+
apiKey: userProfile.apiKey,
|
|
716
|
+
alias: userProfile.customId
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
type: 'individual',
|
|
720
|
+
profile: userProfile.personalInfo
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
console.log('Registered on custom origin:', customResult.accessToken);
|
|
724
|
+
|
|
725
|
+
return {
|
|
726
|
+
ethereum: ethereumOrigin ? true : false,
|
|
727
|
+
custom: true,
|
|
728
|
+
tokens: {
|
|
729
|
+
ethereum: ethereumOrigin ? 'stored' : null,
|
|
730
|
+
custom: 'stored'
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
} catch (error) {
|
|
734
|
+
console.error('Multi-origin registration failed:', error);
|
|
735
|
+
throw error;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
// Usage
|
|
740
|
+
await registerUserAcrossOrigins({
|
|
741
|
+
walletAddress: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
|
|
742
|
+
signature: '0xabcdef...',
|
|
743
|
+
customId: 'user-123',
|
|
744
|
+
apiKey: 'sk_live_abc123',
|
|
745
|
+
personalInfo: {
|
|
746
|
+
firstName: 'Alice',
|
|
747
|
+
lastName: 'Johnson',
|
|
748
|
+
email: 'alice@example.com'
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
```
|
|
752
|
+
|
|
398
753
|
## TypeScript Support
|
|
399
754
|
|
|
400
755
|
This package is written in TypeScript and includes complete type definitions:
|
|
@@ -410,6 +765,13 @@ import type {
|
|
|
410
765
|
AliasesClient,
|
|
411
766
|
OriginsClient,
|
|
412
767
|
OriginClient,
|
|
768
|
+
// Registration types
|
|
769
|
+
RegisterParams,
|
|
770
|
+
IndividualRegisterParams,
|
|
771
|
+
BusinessRegisterParams,
|
|
772
|
+
RegisterResult,
|
|
773
|
+
UserProfile,
|
|
774
|
+
BusinessProfile,
|
|
413
775
|
} from '@bloque/sdk-identity';
|
|
414
776
|
|
|
415
777
|
// Type-safe alias retrieval
|
|
@@ -433,6 +795,55 @@ const otp: OTPAssertion =
|
|
|
433
795
|
// Custom origin client
|
|
434
796
|
const customOrigin: OriginClient<OTPAssertion> =
|
|
435
797
|
identity.origins.custom('my-origin');
|
|
798
|
+
|
|
799
|
+
// Type-safe individual registration
|
|
800
|
+
const individualParams: IndividualRegisterParams = {
|
|
801
|
+
assertionResult: {
|
|
802
|
+
alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
|
|
803
|
+
challengeType: 'SIGNING_CHALLENGE',
|
|
804
|
+
value: {
|
|
805
|
+
signature: '0x123...',
|
|
806
|
+
alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6'
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
type: 'individual',
|
|
810
|
+
profile: {
|
|
811
|
+
firstName: 'John',
|
|
812
|
+
lastName: 'Doe',
|
|
813
|
+
email: 'john@example.com'
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
const individualResult: RegisterResult =
|
|
818
|
+
await identity.origins.register('ethereum-mainnet', individualParams);
|
|
819
|
+
|
|
820
|
+
// Type-safe business registration
|
|
821
|
+
const businessParams: BusinessRegisterParams = {
|
|
822
|
+
assertionResult: {
|
|
823
|
+
alias: 'business-123',
|
|
824
|
+
challengeType: 'API_KEY',
|
|
825
|
+
value: {
|
|
826
|
+
apiKey: 'sk_live_abc123',
|
|
827
|
+
alias: 'business-123'
|
|
828
|
+
}
|
|
829
|
+
},
|
|
830
|
+
type: 'business',
|
|
831
|
+
profile: {
|
|
832
|
+
legalName: 'Acme Corp',
|
|
833
|
+
name: 'Acme',
|
|
834
|
+
taxId: '12-3456789',
|
|
835
|
+
type: 'LLC',
|
|
836
|
+
incorporationDate: '2020-01-15',
|
|
837
|
+
addressLine1: '123 Business St',
|
|
838
|
+
city: 'New York',
|
|
839
|
+
state: 'NY',
|
|
840
|
+
postalCode: '10001',
|
|
841
|
+
country: 'United States'
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
const businessResult: RegisterResult =
|
|
846
|
+
await identity.origins.register('bloque-api', businessParams);
|
|
436
847
|
```
|
|
437
848
|
|
|
438
849
|
## Use with Main SDK
|
|
@@ -443,7 +854,10 @@ When using through the main `@bloque/sdk` package:
|
|
|
443
854
|
import { SDK } from '@bloque/sdk';
|
|
444
855
|
|
|
445
856
|
const bloque = new SDK({
|
|
446
|
-
|
|
857
|
+
auth: {
|
|
858
|
+
type: 'apiKey',
|
|
859
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
860
|
+
},
|
|
447
861
|
mode: 'production',
|
|
448
862
|
});
|
|
449
863
|
|
|
@@ -454,11 +868,20 @@ const otp = await bloque.identity.origins.whatsapp.assert('+1234567890');
|
|
|
454
868
|
|
|
455
869
|
## Key Features
|
|
456
870
|
|
|
871
|
+
### Identity Registration
|
|
872
|
+
|
|
873
|
+
- **Individual Registration (KYC)**: Register users with Know Your Customer compliance
|
|
874
|
+
- **Business Registration (KYB)**: Register businesses with Know Your Business compliance
|
|
875
|
+
- **Multi-Method Authentication**: Support for blockchain signatures, API keys, OAuth, WebAuthn, OTP, and passwords
|
|
876
|
+
- **Cross-Origin Support**: Register identities across multiple authentication origins
|
|
877
|
+
- **Secure Token Generation**: Receive JWT access tokens for authenticated sessions
|
|
878
|
+
|
|
457
879
|
### Origin Management
|
|
458
880
|
|
|
459
881
|
- **List Origins**: Retrieve all available authentication origins
|
|
460
882
|
- **Filter by Provider**: Find origins by provider type (evm, auth0, whatsapp, etc.)
|
|
461
883
|
- **Check Status**: Monitor origin availability and status
|
|
884
|
+
- **Custom Registration**: Register to custom authentication providers
|
|
462
885
|
|
|
463
886
|
### OTP Authentication Channels
|
|
464
887
|
|
|
@@ -480,6 +903,12 @@ OTP assertions include built-in rate limiting:
|
|
|
480
903
|
- Support for primary and public aliases
|
|
481
904
|
- Rich metadata support
|
|
482
905
|
|
|
906
|
+
### Compliance Support
|
|
907
|
+
|
|
908
|
+
- **KYC (Know Your Customer)**: Complete individual profile fields including identity verification
|
|
909
|
+
- **KYB (Know Your Business)**: Business entity information with beneficial owner details
|
|
910
|
+
- **Data Privacy**: Secure handling of sensitive personal and business information
|
|
911
|
+
|
|
483
912
|
## Requirements
|
|
484
913
|
|
|
485
914
|
- Node.js 22.x or higher / Bun 1.x or higher
|
package/dist/aliases/client.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
2
|
import type { Alias } from './types';
|
|
3
|
-
export declare class AliasesClient {
|
|
4
|
-
private readonly httpClient;
|
|
5
|
-
constructor(httpClient: HttpClient);
|
|
3
|
+
export declare class AliasesClient extends BaseClient {
|
|
6
4
|
get(alias: string): Promise<Alias>;
|
|
7
5
|
}
|
package/dist/api-types.d.ts
CHANGED
|
@@ -63,4 +63,162 @@ export interface Origin {
|
|
|
63
63
|
*/
|
|
64
64
|
updated_at: string;
|
|
65
65
|
}
|
|
66
|
+
type SigningChallengeValue = {
|
|
67
|
+
signature: string;
|
|
68
|
+
alias: string;
|
|
69
|
+
};
|
|
70
|
+
type ApiKeyValue = {
|
|
71
|
+
api_key: string;
|
|
72
|
+
alias: string;
|
|
73
|
+
};
|
|
74
|
+
type BaseAssertion<TType extends string, TValue> = {
|
|
75
|
+
alias: string;
|
|
76
|
+
challengeType: TType;
|
|
77
|
+
value: TValue;
|
|
78
|
+
originalChallengeParams?: {
|
|
79
|
+
challenge: string;
|
|
80
|
+
timestamp: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
type ApiKeyAssertion = BaseAssertion<'API_KEY', ApiKeyValue>;
|
|
84
|
+
type InteractiveAssertion = BaseAssertion<'REDIRECT' | 'OAUTH_REDIRECT' | 'SIGNING_CHALLENGE' | 'WEBAUTHN' | 'OTP' | 'PASSWORD', SigningChallengeValue>;
|
|
85
|
+
type AssertionResult = ApiKeyAssertion | InteractiveAssertion;
|
|
86
|
+
export type UserProfile = {
|
|
87
|
+
first_name?: string;
|
|
88
|
+
last_name?: string;
|
|
89
|
+
/**
|
|
90
|
+
* ISO 8601 formatted date string (YYYY-MM-DD)
|
|
91
|
+
*/
|
|
92
|
+
birthdate?: string;
|
|
93
|
+
email?: string;
|
|
94
|
+
phone?: string;
|
|
95
|
+
gender?: string;
|
|
96
|
+
address_line1?: string;
|
|
97
|
+
address_line2?: string;
|
|
98
|
+
city?: string;
|
|
99
|
+
state?: string;
|
|
100
|
+
postal_code?: string;
|
|
101
|
+
neighborhood?: string;
|
|
102
|
+
country_of_birth_code?: string;
|
|
103
|
+
country_of_residence_code?: string;
|
|
104
|
+
personal_id_type?: string;
|
|
105
|
+
personal_id_number?: string;
|
|
106
|
+
};
|
|
107
|
+
export type BusinessProfile = {
|
|
108
|
+
/**
|
|
109
|
+
* Primary business address (street address)
|
|
110
|
+
*/
|
|
111
|
+
address_line1: string;
|
|
112
|
+
/**
|
|
113
|
+
* City where business is registered
|
|
114
|
+
*/
|
|
115
|
+
city: string;
|
|
116
|
+
/**
|
|
117
|
+
* Country of incorporation (full name)
|
|
118
|
+
*/
|
|
119
|
+
country: string;
|
|
120
|
+
/**
|
|
121
|
+
* Date of incorporation or registration (YYYY-MM-DD format)
|
|
122
|
+
*/
|
|
123
|
+
incorporation_date: string;
|
|
124
|
+
/**
|
|
125
|
+
* Official registered legal name of the business
|
|
126
|
+
*/
|
|
127
|
+
legal_name: string;
|
|
128
|
+
/**
|
|
129
|
+
* Business trading name or DBA (Doing Business As)
|
|
130
|
+
*/
|
|
131
|
+
name: string;
|
|
132
|
+
/**
|
|
133
|
+
* Postal or ZIP code
|
|
134
|
+
*/
|
|
135
|
+
postal_code: string;
|
|
136
|
+
/**
|
|
137
|
+
* State, province, or region of registration
|
|
138
|
+
*/
|
|
139
|
+
state: string;
|
|
140
|
+
/**
|
|
141
|
+
* Tax identification number (EIN, VAT, RFC, etc.)
|
|
142
|
+
*/
|
|
143
|
+
tax_id: string;
|
|
144
|
+
/**
|
|
145
|
+
* Business legal structure type (LLC, Corporation, Partnership, etc.)
|
|
146
|
+
*/
|
|
147
|
+
type: string;
|
|
148
|
+
/**
|
|
149
|
+
* Secondary address line (suite, floor, etc.)
|
|
150
|
+
*/
|
|
151
|
+
address_line2?: string;
|
|
152
|
+
/**
|
|
153
|
+
* ISO country code (2 or 3 letters)
|
|
154
|
+
*/
|
|
155
|
+
country_code?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Business contact email
|
|
158
|
+
*/
|
|
159
|
+
email?: string;
|
|
160
|
+
/**
|
|
161
|
+
* URL to business logo image
|
|
162
|
+
*/
|
|
163
|
+
logo?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Owner's primary address
|
|
166
|
+
*/
|
|
167
|
+
owner_address_line1?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Owner's secondary address line
|
|
170
|
+
*/
|
|
171
|
+
owner_address_line2?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Owner's city of residence
|
|
174
|
+
*/
|
|
175
|
+
owner_city?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Owner's country code
|
|
178
|
+
*/
|
|
179
|
+
owner_country_code?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Owner's identification number
|
|
182
|
+
*/
|
|
183
|
+
owner_id_number?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Type of identification document for owner
|
|
186
|
+
*/
|
|
187
|
+
owner_id_type?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Full name of the beneficial owner or primary representative
|
|
190
|
+
*/
|
|
191
|
+
owner_name?: string;
|
|
192
|
+
/**
|
|
193
|
+
* Owner's postal code
|
|
194
|
+
*/
|
|
195
|
+
owner_postal_code?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Owner's state or province
|
|
198
|
+
*/
|
|
199
|
+
owner_state?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Business contact phone number
|
|
202
|
+
*/
|
|
203
|
+
phone?: string;
|
|
204
|
+
};
|
|
205
|
+
export type IndividualRegisterRequest = {
|
|
206
|
+
assertion_result: AssertionResult;
|
|
207
|
+
extra_context?: Record<string, unknown>;
|
|
208
|
+
type: 'individual';
|
|
209
|
+
profile: UserProfile;
|
|
210
|
+
};
|
|
211
|
+
export type BusinessRegisterRequest = {
|
|
212
|
+
assertion_result: AssertionResult;
|
|
213
|
+
extra_context?: Record<string, unknown>;
|
|
214
|
+
type: 'business';
|
|
215
|
+
profile: BusinessProfile;
|
|
216
|
+
};
|
|
217
|
+
export type RegisterRequest = IndividualRegisterRequest | BusinessRegisterRequest;
|
|
218
|
+
export interface RegisterResponse {
|
|
219
|
+
result: {
|
|
220
|
+
access_token: string;
|
|
221
|
+
};
|
|
222
|
+
req_id: string;
|
|
223
|
+
}
|
|
66
224
|
export {};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
2
|
import { AliasesClient } from './aliases/client';
|
|
3
3
|
import { OriginsClient } from './origins/client';
|
|
4
|
+
import type { CreateIdentityParams } from './types';
|
|
4
5
|
export declare class IdentityClient {
|
|
5
6
|
private readonly httpClient;
|
|
6
7
|
readonly aliases: AliasesClient;
|
|
7
8
|
readonly origins: OriginsClient;
|
|
8
9
|
constructor(httpClient: HttpClient);
|
|
10
|
+
create(params: CreateIdentityParams): Promise<import(".").RegisterResult>;
|
|
9
11
|
}
|
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,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},__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__,{OriginClient:()=>OriginClient,AliasesClient:()=>AliasesClient,IdentityClient:()=>IdentityClient,OriginsClient:()=>OriginsClient});class AliasesClient{
|
|
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 i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},__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__,{OriginClient:()=>OriginClient,AliasesClient:()=>AliasesClient,IdentityClient:()=>IdentityClient,OriginsClient:()=>OriginsClient});const sdk_core_namespaceObject=require("@bloque/sdk-core");class AliasesClient extends sdk_core_namespaceObject.BaseClient{async get(e){return await this.httpClient.request({method:"GET",path:`/api/aliases?alias=${e}`})}}class OriginClient extends sdk_core_namespaceObject.BaseClient{origin;constructor(e,t){super(e),this.origin=t}async assert(e){return await this.httpClient.request({method:"GET",path:`/api/origins/${this.origin}/assert?alias=${e}`})}}class OriginsClient extends sdk_core_namespaceObject.BaseClient{whatsapp;email;constructor(e){super(e),this.whatsapp=new OriginClient(e,"bloque-whatsapp"),this.email=new OriginClient(e,"bloque-email")}custom(e){return new OriginClient(this.httpClient,e)}async list(){return await this.httpClient.request({method:"GET",path:"/api/origins"})}async register(e,t){let i,r=t.assertionResult,a="API_KEY"===r.challengeType?{alias:r.alias,challengeType:"API_KEY",value:{api_key:r.value.apiKey,alias:r.value.alias},originalChallengeParams:r.originalChallengeParams}:{alias:r.alias,challengeType:r.challengeType,value:r.value,originalChallengeParams:r.originalChallengeParams};return i="individual"===t.type?{assertion_result:a,extra_context:t.extraContext,type:"individual",profile:this._mapUserProfile(t.profile)}:{assertion_result:a,extra_context:t.extraContext,type:"business",profile:this._mapBusinessProfile(t.profile)},{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${e}/register`,body:i})).result.access_token}}_mapUserProfile(e){return{first_name:e.firstName,last_name:e.lastName,birthdate:e.birthdate,email:e.email,phone:e.phone,gender:e.gender,address_line1:e.addressLine1,address_line2:e.addressLine2,city:e.city,state:e.state,postal_code:e.postalCode,neighborhood:e.neighborhood,country_of_birth_code:e.countryOfBirthCode,country_of_residence_code:e.countryOfResidenceCode,personal_id_type:e.personalIdType,personal_id_number:e.personalIdNumber}}_mapBusinessProfile(e){return{address_line1:e.addressLine1,city:e.city,country:e.country,incorporation_date:e.incorporationDate,legal_name:e.legalName,name:e.name,postal_code:e.postalCode,state:e.state,tax_id:e.taxId,type:e.type,address_line2:e.addressLine2,country_code:e.countryCode,email:e.email,logo:e.logo,owner_address_line1:e.ownerAddressLine1,owner_address_line2:e.ownerAddressLine2,owner_city:e.ownerCity,owner_country_code:e.ownerCountryCode,owner_id_number:e.ownerIdNumber,owner_id_type:e.ownerIdType,owner_name:e.ownerName,owner_postal_code:e.ownerPostalCode,owner_state:e.ownerState,phone:e.phone}}}class IdentityClient{httpClient;aliases;origins;constructor(e){this.httpClient=e,this.aliases=new AliasesClient(this.httpClient),this.origins=new OriginsClient(this.httpClient)}async create(e){let t=this.httpClient.config.origin,i=e.alias;return Reflect.deleteProperty(e,"alias"),e.extraContext||(e.extraContext={}),this.origins.register(t,{assertionResult:{alias:i,challengeType:"API_KEY",value:{apiKey:"apiKey"===this.httpClient.config.auth.type?this.httpClient.config.auth.apiKey:"",alias:i}},...e})}}for(var __rspack_i in exports.AliasesClient=__webpack_exports__.AliasesClient,exports.IdentityClient=__webpack_exports__.IdentityClient,exports.OriginClient=__webpack_exports__.OriginClient,exports.OriginsClient=__webpack_exports__.OriginsClient,__webpack_exports__)-1===["AliasesClient","IdentityClient","OriginClient","OriginsClient"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class t{
|
|
1
|
+
import{BaseClient as e}from"@bloque/sdk-core";class t extends e{async get(e){return await this.httpClient.request({method:"GET",path:`/api/aliases?alias=${e}`})}}class a extends e{origin;constructor(e,t){super(e),this.origin=t}async assert(e){return await this.httpClient.request({method:"GET",path:`/api/origins/${this.origin}/assert?alias=${e}`})}}class i extends e{whatsapp;email;constructor(e){super(e),this.whatsapp=new a(e,"bloque-whatsapp"),this.email=new a(e,"bloque-email")}custom(e){return new a(this.httpClient,e)}async list(){return await this.httpClient.request({method:"GET",path:"/api/origins"})}async register(e,t){let a,i=t.assertionResult,s="API_KEY"===i.challengeType?{alias:i.alias,challengeType:"API_KEY",value:{api_key:i.value.apiKey,alias:i.value.alias},originalChallengeParams:i.originalChallengeParams}:{alias:i.alias,challengeType:i.challengeType,value:i.value,originalChallengeParams:i.originalChallengeParams};return a="individual"===t.type?{assertion_result:s,extra_context:t.extraContext,type:"individual",profile:this._mapUserProfile(t.profile)}:{assertion_result:s,extra_context:t.extraContext,type:"business",profile:this._mapBusinessProfile(t.profile)},{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${e}/register`,body:a})).result.access_token}}_mapUserProfile(e){return{first_name:e.firstName,last_name:e.lastName,birthdate:e.birthdate,email:e.email,phone:e.phone,gender:e.gender,address_line1:e.addressLine1,address_line2:e.addressLine2,city:e.city,state:e.state,postal_code:e.postalCode,neighborhood:e.neighborhood,country_of_birth_code:e.countryOfBirthCode,country_of_residence_code:e.countryOfResidenceCode,personal_id_type:e.personalIdType,personal_id_number:e.personalIdNumber}}_mapBusinessProfile(e){return{address_line1:e.addressLine1,city:e.city,country:e.country,incorporation_date:e.incorporationDate,legal_name:e.legalName,name:e.name,postal_code:e.postalCode,state:e.state,tax_id:e.taxId,type:e.type,address_line2:e.addressLine2,country_code:e.countryCode,email:e.email,logo:e.logo,owner_address_line1:e.ownerAddressLine1,owner_address_line2:e.ownerAddressLine2,owner_city:e.ownerCity,owner_country_code:e.ownerCountryCode,owner_id_number:e.ownerIdNumber,owner_id_type:e.ownerIdType,owner_name:e.ownerName,owner_postal_code:e.ownerPostalCode,owner_state:e.ownerState,phone:e.phone}}}class s{httpClient;aliases;origins;constructor(e){this.httpClient=e,this.aliases=new t(this.httpClient),this.origins=new i(this.httpClient)}async create(e){let t=this.httpClient.config.origin,a=e.alias;return Reflect.deleteProperty(e,"alias"),e.extraContext||(e.extraContext={}),this.origins.register(t,{assertionResult:{alias:a,challengeType:"API_KEY",value:{apiKey:"apiKey"===this.httpClient.config.auth.type?this.httpClient.config.auth.apiKey:"",alias:a}},...e})}}export{t as AliasesClient,s as IdentityClient,a as OriginClient,i as OriginsClient};
|
package/dist/origins/client.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
2
3
|
import type { Origin, OTPAssertion, OTPAssertionEmail, OTPAssertionWhatsApp } from '../api-types';
|
|
3
4
|
import { OriginClient } from './origin';
|
|
4
|
-
|
|
5
|
+
import type { RegisterParams, RegisterResult } from './types';
|
|
6
|
+
export declare class OriginsClient extends BaseClient {
|
|
5
7
|
readonly whatsapp: OriginClient<OTPAssertionWhatsApp>;
|
|
6
8
|
readonly email: OriginClient<OTPAssertionEmail>;
|
|
7
|
-
private readonly httpClient;
|
|
8
9
|
constructor(httpClient: HttpClient);
|
|
9
10
|
custom(origin: string): OriginClient<OTPAssertion>;
|
|
10
11
|
/**
|
|
@@ -28,4 +29,92 @@ export declare class OriginsClient {
|
|
|
28
29
|
* ```
|
|
29
30
|
*/
|
|
30
31
|
list(): Promise<Origin[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Register a new user or business identity to a specific origin
|
|
34
|
+
*
|
|
35
|
+
* Creates a new identity by verifying the assertion result (challenge response)
|
|
36
|
+
* and storing the profile information. Supports both individual users (KYC) and
|
|
37
|
+
* businesses (KYB) registration.
|
|
38
|
+
*
|
|
39
|
+
* Different origins support different challenge types:
|
|
40
|
+
* - **SIGNING_CHALLENGE**: Blockchain signature verification (e.g., Ethereum, Solana)
|
|
41
|
+
* - **API_KEY**: Traditional API key authentication
|
|
42
|
+
* - **OAUTH_REDIRECT**: OAuth-based authentication flows
|
|
43
|
+
* - **WEBAUTHN**: WebAuthn/passkey authentication
|
|
44
|
+
* - **OTP**: One-time password verification
|
|
45
|
+
* - **PASSWORD**: Password-based authentication
|
|
46
|
+
*
|
|
47
|
+
* @param origin - The origin namespace to register the identity to (e.g., 'ethereum-mainnet', 'bloque-api')
|
|
48
|
+
* @param params - Registration data including assertion result and profile information
|
|
49
|
+
* @returns Promise resolving to the registration result with access token
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* // Register individual user with blockchain signature (KYC)
|
|
54
|
+
* const individual = await bloque.identity.origins.register('ethereum-mainnet', {
|
|
55
|
+
* assertionResult: {
|
|
56
|
+
* alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6',
|
|
57
|
+
* challengeType: 'SIGNING_CHALLENGE',
|
|
58
|
+
* value: {
|
|
59
|
+
* signature: '0x1234567890abcdef...',
|
|
60
|
+
* alias: '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b6'
|
|
61
|
+
* },
|
|
62
|
+
* originalChallengeParams: {
|
|
63
|
+
* challenge: 'bloque-challenge-1234567890',
|
|
64
|
+
* timestamp: 1640995200
|
|
65
|
+
* }
|
|
66
|
+
* },
|
|
67
|
+
* type: 'individual',
|
|
68
|
+
* profile: {
|
|
69
|
+
* firstName: 'John',
|
|
70
|
+
* lastName: 'Doe',
|
|
71
|
+
* email: 'john.doe@example.com',
|
|
72
|
+
* phone: '+1234567890',
|
|
73
|
+
* birthdate: '1990-01-15',
|
|
74
|
+
* city: 'New York',
|
|
75
|
+
* state: 'NY',
|
|
76
|
+
* postalCode: '10001',
|
|
77
|
+
* countryOfBirthCode: 'USA',
|
|
78
|
+
* countryOfResidenceCode: 'USA'
|
|
79
|
+
* }
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // Register business with API key (KYB)
|
|
83
|
+
* const business = await bloque.identity.origins.register('bloque-api', {
|
|
84
|
+
* assertionResult: {
|
|
85
|
+
* alias: 'business-123',
|
|
86
|
+
* challengeType: 'API_KEY',
|
|
87
|
+
* value: {
|
|
88
|
+
* apiKey: 'sk_live_abc123def456',
|
|
89
|
+
* alias: 'business-123'
|
|
90
|
+
* }
|
|
91
|
+
* },
|
|
92
|
+
* type: 'business',
|
|
93
|
+
* profile: {
|
|
94
|
+
* legalName: 'Acme Corporation',
|
|
95
|
+
* name: 'Acme Corp',
|
|
96
|
+
* taxId: '12-3456789',
|
|
97
|
+
* type: 'LLC',
|
|
98
|
+
* incorporationDate: '2020-01-15',
|
|
99
|
+
* addressLine1: '123 Business St',
|
|
100
|
+
* city: 'New York',
|
|
101
|
+
* state: 'NY',
|
|
102
|
+
* postalCode: '10001',
|
|
103
|
+
* country: 'United States',
|
|
104
|
+
* email: 'contact@acme.com',
|
|
105
|
+
* phone: '+1-555-0123',
|
|
106
|
+
* ownerName: 'Jane Smith',
|
|
107
|
+
* ownerIdType: 'SSN',
|
|
108
|
+
* ownerIdNumber: '123-45-6789'
|
|
109
|
+
* }
|
|
110
|
+
* });
|
|
111
|
+
*
|
|
112
|
+
* // Access tokens for authenticated sessions
|
|
113
|
+
* console.log(individual.accessToken); // JWT token for individual
|
|
114
|
+
* console.log(business.accessToken); // JWT token for business
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
register(origin: string, params: RegisterParams): Promise<RegisterResult>;
|
|
118
|
+
private _mapUserProfile;
|
|
119
|
+
private _mapBusinessProfile;
|
|
31
120
|
}
|
package/dist/origins/origin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { BaseClient } from '@bloque/sdk-core';
|
|
3
|
+
export declare class OriginClient<TAssertion> extends BaseClient {
|
|
4
4
|
private readonly origin;
|
|
5
5
|
constructor(httpClient: HttpClient, origin: string);
|
|
6
6
|
assert(alias: string): Promise<TAssertion>;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export interface SigningChallengeValue {
|
|
2
|
+
/**
|
|
3
|
+
* The cryptographic signature
|
|
4
|
+
*/
|
|
5
|
+
signature: string;
|
|
6
|
+
/**
|
|
7
|
+
* The alias being verified
|
|
8
|
+
*/
|
|
9
|
+
alias: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ApiKeyValue {
|
|
12
|
+
/**
|
|
13
|
+
* API key for authentication
|
|
14
|
+
*/
|
|
15
|
+
apiKey: string;
|
|
16
|
+
/**
|
|
17
|
+
* The alias being verified
|
|
18
|
+
*/
|
|
19
|
+
alias: string;
|
|
20
|
+
}
|
|
21
|
+
type BaseAssertion<TType extends string, TValue> = {
|
|
22
|
+
alias: string;
|
|
23
|
+
challengeType: TType;
|
|
24
|
+
value: TValue;
|
|
25
|
+
originalChallengeParams?: {
|
|
26
|
+
challenge: string;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type ApiKeyAssertion = BaseAssertion<'API_KEY', ApiKeyValue>;
|
|
31
|
+
type InteractiveAssertion = BaseAssertion<'REDIRECT' | 'OAUTH_REDIRECT' | 'SIGNING_CHALLENGE' | 'WEBAUTHN' | 'OTP' | 'PASSWORD', SigningChallengeValue>;
|
|
32
|
+
type AssertionResult = ApiKeyAssertion | InteractiveAssertion;
|
|
33
|
+
interface UserProfile {
|
|
34
|
+
firstName?: string;
|
|
35
|
+
lastName?: string;
|
|
36
|
+
/**
|
|
37
|
+
* ISO 8601 formatted date string (YYYY-MM-DD)
|
|
38
|
+
*/
|
|
39
|
+
birthdate?: string;
|
|
40
|
+
email?: string;
|
|
41
|
+
phone?: string;
|
|
42
|
+
gender?: string;
|
|
43
|
+
addressLine1?: string;
|
|
44
|
+
addressLine2?: string;
|
|
45
|
+
city?: string;
|
|
46
|
+
state?: string;
|
|
47
|
+
postalCode?: string;
|
|
48
|
+
neighborhood?: string;
|
|
49
|
+
countryOfBirthCode?: string;
|
|
50
|
+
countryOfResidenceCode?: string;
|
|
51
|
+
personalIdType?: string;
|
|
52
|
+
personalIdNumber?: string;
|
|
53
|
+
}
|
|
54
|
+
interface BusinessProfile {
|
|
55
|
+
/**
|
|
56
|
+
* Primary business address (street address)
|
|
57
|
+
*/
|
|
58
|
+
addressLine1: string;
|
|
59
|
+
/**
|
|
60
|
+
* City where business is registered
|
|
61
|
+
*/
|
|
62
|
+
city: string;
|
|
63
|
+
/**
|
|
64
|
+
* Country of incorporation (full name)
|
|
65
|
+
*/
|
|
66
|
+
country: string;
|
|
67
|
+
/**
|
|
68
|
+
* Date of incorporation or registration (YYYY-MM-DD format)
|
|
69
|
+
*/
|
|
70
|
+
incorporationDate: string;
|
|
71
|
+
/**
|
|
72
|
+
* Official registered legal name of the business
|
|
73
|
+
*/
|
|
74
|
+
legalName: string;
|
|
75
|
+
/**
|
|
76
|
+
* Business trading name or DBA (Doing Business As)
|
|
77
|
+
*/
|
|
78
|
+
name: string;
|
|
79
|
+
/**
|
|
80
|
+
* Postal or ZIP code
|
|
81
|
+
*/
|
|
82
|
+
postalCode: string;
|
|
83
|
+
/**
|
|
84
|
+
* State, province, or region of registration
|
|
85
|
+
*/
|
|
86
|
+
state: string;
|
|
87
|
+
/**
|
|
88
|
+
* Tax identification number (EIN, VAT, RFC, etc.)
|
|
89
|
+
*/
|
|
90
|
+
taxId: string;
|
|
91
|
+
/**
|
|
92
|
+
* Business legal structure type (LLC, Corporation, Partnership, etc.)
|
|
93
|
+
*/
|
|
94
|
+
type: string;
|
|
95
|
+
/**
|
|
96
|
+
* Secondary address line (suite, floor, etc.)
|
|
97
|
+
*/
|
|
98
|
+
addressLine2?: string;
|
|
99
|
+
/**
|
|
100
|
+
* ISO country code (2 or 3 letters)
|
|
101
|
+
*/
|
|
102
|
+
countryCode?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Business contact email
|
|
105
|
+
*/
|
|
106
|
+
email?: string;
|
|
107
|
+
/**
|
|
108
|
+
* URL to business logo image
|
|
109
|
+
*/
|
|
110
|
+
logo?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Owner's primary address
|
|
113
|
+
*/
|
|
114
|
+
ownerAddressLine1?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Owner's secondary address line
|
|
117
|
+
*/
|
|
118
|
+
ownerAddressLine2?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Owner's city of residence
|
|
121
|
+
*/
|
|
122
|
+
ownerCity?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Owner's country code
|
|
125
|
+
*/
|
|
126
|
+
ownerCountryCode?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Owner's identification number
|
|
129
|
+
*/
|
|
130
|
+
ownerIdNumber?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Type of identification document for owner
|
|
133
|
+
*/
|
|
134
|
+
ownerIdType?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Full name of the beneficial owner or primary representative
|
|
137
|
+
*/
|
|
138
|
+
ownerName?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Owner's postal code
|
|
141
|
+
*/
|
|
142
|
+
ownerPostalCode?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Owner's state or province
|
|
145
|
+
*/
|
|
146
|
+
ownerState?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Business contact phone number
|
|
149
|
+
*/
|
|
150
|
+
phone?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface IndividualRegisterParams {
|
|
153
|
+
/**
|
|
154
|
+
* Result of the assertion challenge
|
|
155
|
+
*/
|
|
156
|
+
assertionResult: AssertionResult;
|
|
157
|
+
/**
|
|
158
|
+
* Additional context data
|
|
159
|
+
*/
|
|
160
|
+
extraContext?: Record<string, unknown>;
|
|
161
|
+
/**
|
|
162
|
+
* Type of entity being registered
|
|
163
|
+
*/
|
|
164
|
+
type: 'individual';
|
|
165
|
+
/**
|
|
166
|
+
* User profile information
|
|
167
|
+
*/
|
|
168
|
+
profile: UserProfile;
|
|
169
|
+
}
|
|
170
|
+
export interface BusinessRegisterParams {
|
|
171
|
+
/**
|
|
172
|
+
* Result of the assertion challenge
|
|
173
|
+
*/
|
|
174
|
+
assertionResult: AssertionResult;
|
|
175
|
+
/**
|
|
176
|
+
* Additional context data
|
|
177
|
+
*/
|
|
178
|
+
extraContext?: Record<string, unknown>;
|
|
179
|
+
/**
|
|
180
|
+
* Type of entity being registered
|
|
181
|
+
*/
|
|
182
|
+
type: 'business';
|
|
183
|
+
/**
|
|
184
|
+
* Business profile information
|
|
185
|
+
*/
|
|
186
|
+
profile: BusinessProfile;
|
|
187
|
+
}
|
|
188
|
+
export type RegisterParams = IndividualRegisterParams | BusinessRegisterParams;
|
|
189
|
+
export interface RegisterResult {
|
|
190
|
+
/**
|
|
191
|
+
* JWT access token for the registered identity
|
|
192
|
+
*/
|
|
193
|
+
accessToken: string;
|
|
194
|
+
}
|
|
195
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BusinessRegisterParams, IndividualRegisterParams } from './origins/types';
|
|
2
|
+
export type CreateIdentityParams = (Pick<IndividualRegisterParams, 'extraContext' | 'type' | 'profile'> | Pick<BusinessRegisterParams, 'extraContext' | 'type' | 'profile'>) & {
|
|
3
|
+
alias: string;
|
|
4
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-identity",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
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.22"
|
|
38
38
|
}
|
|
39
39
|
}
|