@bloque/sdk 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,677 +6,70 @@ The official TypeScript/JavaScript SDK for integrating [Bloque](https://www.bloq
6
6
  >
7
7
  > This SDK is currently under active development. Breaking changes may occur between versions.
8
8
  > We strongly recommend pinning to a specific version in your `package.json` to avoid unexpected issues.
9
- >
10
- > ```json
11
- > {
12
- > "dependencies": {
13
- > "@bloque/sdk": "x.x.x"
14
- > }
15
- > }
16
- > ```
17
- >
18
- > Replace with the latest version from [npm](https://www.npmjs.com/package/@bloque/sdk).
19
9
 
20
10
  ## Platform Support
21
11
 
22
- This SDK is compatible with multiple JavaScript runtimes:
23
-
24
12
  - **Node.js** 22.x or higher
25
13
  - **Bun** 1.x or higher
26
14
  - **Deno** Latest version
27
15
  - **Web/Browsers** Modern browsers with ES2020+ support
28
16
  - **React Native** Latest version
29
17
 
30
- ## Features
31
-
32
- - **TypeScript First**: Built with TypeScript for complete type safety
33
- - **Modular Architecture**: Import only what you need - accounts, identity, compliance, or organizations
34
- - **Multi-Runtime**: Works seamlessly across Node.js, Bun, Deno, browsers, and React Native
35
- - **Account Management**: Create and manage virtual cards, virtual accounts, and Bancolombia accounts
36
- - **Identity System**: Register individual users (KYC) and businesses (KYB) with multi-method authentication
37
- - **Compliance Ready**: Built-in KYC/KYB verification workflows
38
- - **Transfer System**: Transfer funds between accounts with multiple asset support
39
- - **Production Ready**:
40
- - ✅ Automatic retry with exponential backoff
41
- - ✅ Configurable timeouts (default: 30s)
42
- - ✅ Specific error types for better error handling
43
- - ✅ Request ID tracking for debugging
44
- - ✅ Security warnings for insecure practices
45
- - **Lightweight**: Minimal dependencies for optimal bundle size
46
- - **Fully Async**: Promise-based API for modern JavaScript workflows
47
-
48
18
  ## Installation
49
19
 
50
20
  ```bash
51
- # npm
52
- npm install @bloque/sdk
53
-
54
- # bun
55
- bun add @bloque/sdk
56
-
57
- # pnpm
58
- pnpm add @bloque/sdk
59
-
60
- # yarn
61
- yarn add @bloque/sdk
21
+ pnpm install @bloque/sdk
62
22
  ```
63
23
 
64
24
  ## Quick Start
65
25
 
66
- ### Backend (Node.js, Bun, Deno)
67
-
68
26
  ```typescript
69
27
  import { SDK } from '@bloque/sdk';
70
28
 
71
- // Initialize the SDK with API key (backend only)
29
+ // Initialize SDK
30
+ const bloque = await SDK.connect({
31
+ apiKey: process.env.BLOQUE_API_KEY!,
32
+ platform: 'node',
33
+ });
72
34
  const bloque = new SDK({
73
- origin: 'your-origin-name',
35
+ origin: 'bloque',
74
36
  auth: {
75
37
  type: 'apiKey',
76
- apiKey: process.env.BLOQUE_API_KEY!,
38
+ apiKey: 'sk_live_862f110...',
77
39
  },
78
40
  mode: 'production', // or 'sandbox' for testing
79
- platform: 'node', // optional: 'node' | 'bun' | 'deno'
80
- timeout: 30000, // optional: request timeout in ms
81
- retry: { // optional: retry configuration
82
- enabled: true,
83
- maxRetries: 3,
84
- initialDelay: 1000,
85
- },
41
+ platform: 'node',
86
42
  });
87
43
 
88
- // Connect to user session
89
- const session = await bloque.connect('did:bloque:your-origin:user-alias');
90
-
91
44
  // Create a virtual card
92
- const card = await session.accounts.card.create({
45
+ const card = await bloque.accounts.card.create({
93
46
  name: 'My Virtual Card',
94
47
  });
95
48
 
96
49
  console.log('Card created:', card.urn);
97
- console.log('Last four digits:', card.lastFour);
98
- ```
99
-
100
- ### Frontend (Browser, React Native)
101
-
102
- ```typescript
103
- import { SDK } from '@bloque/sdk';
104
-
105
- // Initialize the SDK with JWT authentication
106
- const bloque = new SDK({
107
- origin: 'your-origin-name',
108
- auth: { type: 'jwt' },
109
- mode: 'production',
110
- platform: 'browser', // or 'react-native'
111
- // For browser: uses localStorage by default (with security warning)
112
- // For react-native: provide custom tokenStorage
113
- tokenStorage: {
114
- get: () => {
115
- // Your secure storage implementation
116
- return AsyncStorage.getItem('bloque_token');
117
- },
118
- set: (token) => {
119
- AsyncStorage.setItem('bloque_token', token);
120
- },
121
- clear: () => {
122
- AsyncStorage.removeItem('bloque_token');
123
- },
124
- },
125
- });
126
-
127
- // Register a new user
128
- const result = await bloque.identity.origins.register(
129
- 'did:bloque:your-origin:ethereum-mainnet',
130
- {
131
- assertionResult: { /* signing challenge result */ },
132
- type: 'individual',
133
- profile: {
134
- firstName: 'John',
135
- lastName: 'Doe',
136
- email: 'john@example.com',
137
- },
138
- }
139
- );
140
-
141
- // The JWT is automatically stored and used for subsequent requests
142
- ```
143
-
144
- ## Configuration
145
-
146
- ### Full Configuration Options
147
-
148
- ```typescript
149
- interface BloqueSDKConfig {
150
- // Required
151
- origin: string; // Your origin identifier
152
- auth: AuthStrategy; // Authentication strategy
153
-
154
- // Optional
155
- platform?: Platform; // Runtime platform (default: 'node')
156
- mode?: Mode; // Environment mode (default: 'production')
157
- timeout?: number; // Request timeout in ms (default: 30000)
158
- tokenStorage?: TokenStorage; // JWT storage (required for react-native)
159
- retry?: RetryConfig; // Retry configuration
160
- }
161
-
162
- // Authentication strategies
163
- type AuthStrategy =
164
- | { type: 'apiKey'; apiKey: string } // Backend only
165
- | { type: 'jwt' }; // Frontend (browser/react-native)
166
-
167
- // Platforms
168
- type Platform = 'node' | 'bun' | 'deno' | 'browser' | 'react-native';
169
-
170
- // Modes
171
- type Mode = 'production' | 'sandbox';
172
-
173
- // Retry configuration
174
- interface RetryConfig {
175
- enabled?: boolean; // default: true
176
- maxRetries?: number; // default: 3
177
- initialDelay?: number; // default: 1000ms
178
- maxDelay?: number; // default: 30000ms
179
- }
180
- ```
181
-
182
- ## SDK Structure
183
-
184
- After connecting to a user session, you have access to these clients:
185
-
186
- ```typescript
187
- const session = await bloque.connect('did:bloque:your-origin:user-alias');
188
-
189
- // Available clients
190
- session.accounts // Account management
191
- session.identity // Identity and aliases
192
- session.compliance // KYC/KYB verification
193
- session.orgs // Organization management
194
- ```
195
-
196
- ## Accounts Client
197
-
198
- The accounts client provides access to multiple account types:
199
-
200
- ### Virtual Cards
201
-
202
- ```typescript
203
- // Create a virtual card
204
- const card = await session.accounts.card.create({
205
- name: 'My Card',
206
- webhookUrl: 'https://your-app.com/webhooks/card',
207
- });
208
-
209
- // List cards
210
- const cards = await session.accounts.card.list();
211
-
212
- // Check balance
213
- const balance = await session.accounts.card.balance({
214
- urn: card.urn,
215
- });
216
-
217
- // Get movements/transactions
218
- const movements = await session.accounts.card.movements({
219
- urn: card.urn,
220
- asset: 'DUSD/6',
221
- limit: 50,
222
- direction: 'in', // 'in' | 'out'
223
- });
224
-
225
- // Update card
226
- const updated = await session.accounts.card.updateMetadata({
227
- urn: card.urn,
228
- metadata: { name: 'Updated Name' },
229
- });
230
-
231
- // Manage card state
232
- await session.accounts.card.activate(card.urn);
233
- await session.accounts.card.freeze(card.urn);
234
- await session.accounts.card.disable(card.urn);
235
- ```
236
-
237
- ### Virtual Accounts
238
-
239
- Virtual accounts are simple testing accounts requiring only basic personal information:
240
-
241
- ```typescript
242
- // Create a virtual account
243
- const account = await session.accounts.virtual.create({
244
- firstName: 'John',
245
- lastName: 'Doe',
246
- metadata: {
247
- environment: 'testing',
248
- purpose: 'integration-test',
249
- },
250
- });
251
-
252
- // Update metadata
253
- await session.accounts.virtual.updateMetadata({
254
- urn: account.urn,
255
- metadata: { updated_by: 'admin' },
256
- });
257
-
258
- // Manage account state
259
- await session.accounts.virtual.activate(account.urn);
260
- await session.accounts.virtual.freeze(account.urn);
261
- await session.accounts.virtual.disable(account.urn);
262
- ```
263
-
264
- ### Bancolombia Accounts
265
-
266
- Colombian virtual accounts with unique reference code system:
267
-
268
- ```typescript
269
- // Create a Bancolombia account
270
- const account = await session.accounts.bancolombia.create({
271
- name: 'Main Account',
272
- webhookUrl: 'https://your-app.com/webhooks/bancolombia',
273
- });
274
-
275
- console.log('Reference code:', account.referenceCode);
276
-
277
- // Update metadata or name
278
- await session.accounts.bancolombia.updateMetadata({
279
- urn: account.urn,
280
- metadata: { category: 'savings' },
281
- });
282
-
283
- await session.accounts.bancolombia.updateName(account.urn, 'Savings Account');
284
-
285
- // Manage account state
286
- await session.accounts.bancolombia.activate(account.urn);
287
- await session.accounts.bancolombia.freeze(account.urn);
288
- await session.accounts.bancolombia.disable(account.urn);
289
- ```
290
-
291
- ### Transfers
292
-
293
- Transfer funds between any account types:
294
-
295
- ```typescript
296
- const result = await session.accounts.transfer({
297
- sourceUrn: 'did:bloque:account:card:usr-123:crd-456',
298
- destinationUrn: 'did:bloque:account:virtual:acc-789',
299
- amount: '1000000', // Amount in smallest unit
300
- asset: 'DUSD/6', // 'DUSD/6' | 'KSM/12'
301
- metadata: {
302
- description: 'Payment for services',
303
- },
304
- });
305
-
306
- console.log('Transfer queued:', result.queueId);
307
- console.log('Status:', result.status); // 'queued' | 'processing' | 'completed' | 'failed'
308
- ```
309
-
310
- ## Identity Client
311
-
312
- Manage user identities and authentication:
313
-
314
- ```typescript
315
- // Get alias information
316
- const alias = await session.identity.aliases.get('user@example.com');
317
-
318
- // List available origins
319
- const origins = await session.identity.origins.list();
320
-
321
- // Register a new identity (individual)
322
- const result = await bloque.identity.origins.register(
323
- 'did:bloque:your-origin:ethereum-mainnet',
324
- {
325
- assertionResult: {
326
- alias: '0x742d35Cc...',
327
- challengeType: 'SIGNING_CHALLENGE',
328
- value: {
329
- signature: '0x...',
330
- alias: '0x742d35Cc...',
331
- },
332
- },
333
- type: 'individual',
334
- profile: {
335
- firstName: 'John',
336
- lastName: 'Doe',
337
- email: 'john@example.com',
338
- birthdate: '1990-01-15',
339
- countryOfResidenceCode: 'US',
340
- },
341
- }
342
- );
343
-
344
- // Register a business
345
- const businessResult = await bloque.identity.origins.register(
346
- 'did:bloque:your-origin:ethereum-mainnet',
347
- {
348
- assertionResult: { /* ... */ },
349
- type: 'business',
350
- profile: {
351
- legalName: 'Acme Corporation',
352
- taxId: '123456789',
353
- incorporationDate: '2020-01-01',
354
- type: 'llc',
355
- addressLine1: '123 Main St',
356
- city: 'San Francisco',
357
- state: 'CA',
358
- country: 'US',
359
- postalCode: '12345',
360
- // ... other required fields
361
- },
362
- }
363
- );
364
-
365
- // OTP-based authentication
366
- const otpEmail = await bloque.identity.origins.email.assert('user@example.com');
367
- const otpWhatsApp = await bloque.identity.origins.whatsapp.assert('+1234567890');
368
- const otpCustom = await bloque.identity.origins.custom('my-origin').assert('user-id');
369
- ```
370
-
371
- ## Compliance Client
372
-
373
- KYC/KYB verification workflows:
374
-
375
- ```typescript
376
- // Start KYC verification
377
- const verification = await session.compliance.kyc.startVerification({
378
- urn: 'did:bloque:user:123e4567',
379
- webhookUrl: 'https://your-app.com/webhooks/kyc',
380
- });
381
-
382
- console.log('Verification URL:', verification.url);
383
- console.log('Status:', verification.status);
384
-
385
- // Get verification status
386
- const status = await session.compliance.kyc.getVerification({
387
- urn: 'did:bloque:user:123e4567',
388
- });
389
-
390
- console.log('Status:', status.status);
391
- console.log('Completed at:', status.completedAt);
392
- ```
393
-
394
- ## Organizations Client
395
-
396
- Create and manage organizations:
397
-
398
- ```typescript
399
- const org = await session.orgs.create({
400
- org_type: 'business',
401
- profile: {
402
- legal_name: 'Acme Corporation',
403
- tax_id: '123456789',
404
- incorporation_date: '2020-01-01',
405
- business_type: 'llc',
406
- incorporation_country_code: 'US',
407
- incorporation_state: 'CA',
408
- address_line1: '123 Main St',
409
- address_line2: 'Suite 100',
410
- postal_code: '12345',
411
- city: 'San Francisco',
412
- },
413
- metadata: {
414
- industry: 'technology',
415
- },
416
- });
417
-
418
- console.log('Organization created:', org.urn);
419
- console.log('Status:', org.status);
420
- ```
421
-
422
- ## Error Handling
423
-
424
- The SDK provides specific error types for better error handling:
425
-
426
- ```typescript
427
- import {
428
- BloqueRateLimitError,
429
- BloqueAuthenticationError,
430
- BloqueValidationError,
431
- BloqueNotFoundError,
432
- BloqueInsufficientFundsError,
433
- BloqueNetworkError,
434
- BloqueTimeoutError,
435
- } from '@bloque/sdk';
436
-
437
- try {
438
- const card = await session.accounts.card.create({ name: 'My Card' });
439
- } catch (error) {
440
- if (error instanceof BloqueRateLimitError) {
441
- console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
442
- console.log(`Request ID: ${error.requestId}`);
443
- } else if (error instanceof BloqueValidationError) {
444
- console.log('Validation errors:', error.validationErrors);
445
- } else if (error instanceof BloqueAuthenticationError) {
446
- console.log('Authentication failed. Check your API key.');
447
- } else if (error instanceof BloqueNotFoundError) {
448
- console.log(`Resource not found: ${error.resourceType}`);
449
- } else if (error instanceof BloqueInsufficientFundsError) {
450
- console.log(`Insufficient funds: ${error.requestedAmount} ${error.currency}`);
451
- console.log(`Available: ${error.availableBalance} ${error.currency}`);
452
- } else if (error instanceof BloqueTimeoutError) {
453
- console.log(`Request timed out after ${error.timeoutMs}ms`);
454
- } else if (error instanceof BloqueNetworkError) {
455
- console.log('Network error:', error.message);
456
- }
457
-
458
- // All errors have these fields
459
- console.log('Error details:', error.toJSON());
460
- }
461
- ```
462
-
463
- ### Error Metadata
464
-
465
- All errors include rich metadata for debugging:
466
-
467
- - `message`: Human-readable error message
468
- - `status`: HTTP status code (if applicable)
469
- - `code`: Error code from the API
470
- - `requestId`: Unique request ID for tracing
471
- - `timestamp`: When the error occurred
472
- - `response`: Original response body (for debugging)
473
- - `cause`: Original error (for error chaining)
474
-
475
- ## Retry Logic
476
-
477
- The SDK automatically retries failed requests with exponential backoff:
478
-
479
- - **Retried scenarios**: 429 (Rate Limit), 503 (Service Unavailable), network errors, timeouts
480
- - **Exponential backoff**: Delay increases exponentially (1s → 2s → 4s)
481
- - **Jitter**: ±25% random jitter to prevent thundering herd
482
- - **Respects Retry-After**: Honors the `Retry-After` header when present
483
-
484
- ```typescript
485
- const bloque = new SDK({
486
- origin: 'your-origin',
487
- auth: { type: 'apiKey', apiKey: 'key' },
488
- retry: {
489
- enabled: true, // default: true
490
- maxRetries: 3, // default: 3
491
- initialDelay: 1000, // default: 1000ms
492
- maxDelay: 30000, // default: 30000ms
493
- },
494
- });
495
- ```
496
-
497
- ## Timeout Configuration
498
-
499
- Configure request timeouts globally or per-request:
500
-
501
- ```typescript
502
- // Global timeout
503
- const bloque = new SDK({
504
- origin: 'your-origin',
505
- auth: { type: 'apiKey', apiKey: 'key' },
506
- timeout: 15000, // 15 seconds
507
- });
508
-
509
- // Per-request timeout (override global)
510
- const card = await session.accounts.card.create(
511
- { name: 'My Card' },
512
- { timeout: 5000 } // 5 seconds for this request
513
- );
514
- ```
515
-
516
- ## Security Best Practices
517
-
518
- ### API Keys
519
-
520
- - ✅ Store API keys in environment variables
521
- - ✅ Use different keys for development and production
522
- - ✅ Never commit API keys to version control
523
- - ✅ Rotate API keys regularly
524
- - ❌ Never expose API keys in client-side code
525
-
526
- ### Token Storage (Frontend)
527
-
528
- The SDK warns when using insecure storage:
529
-
530
- ```typescript
531
- // Browser: localStorage (⚠️ vulnerable to XSS)
532
- const bloque = new SDK({
533
- auth: { type: 'jwt' },
534
- platform: 'browser',
535
- // Uses localStorage by default with security warning
536
- });
537
-
538
- // Recommended: httpOnly cookies (immune to XSS)
539
- const cookieStorage: TokenStorage = {
540
- get: () => null, // Token sent automatically in cookie
541
- set: async (token) => {
542
- await fetch('/api/auth/set-token', {
543
- method: 'POST',
544
- body: JSON.stringify({ token }),
545
- });
546
- },
547
- clear: async () => {
548
- await fetch('/api/auth/logout', { method: 'POST' });
549
- },
550
- };
551
-
552
- const bloque = new SDK({
553
- auth: { type: 'jwt' },
554
- platform: 'browser',
555
- tokenStorage: cookieStorage,
556
- });
557
- ```
558
-
559
- ## TypeScript Support
560
-
561
- The SDK is built with TypeScript and provides full type safety:
562
-
563
- ```typescript
564
- import type {
565
- BloqueSDKConfig,
566
- CardAccount,
567
- CreateCardParams,
568
- VirtualAccount,
569
- CreateVirtualAccountParams,
570
- TransferParams,
571
- TransferResult,
572
- } from '@bloque/sdk';
573
-
574
- // Type-safe configuration
575
- const config: BloqueSDKConfig = {
576
- origin: 'your-origin',
577
- auth: { type: 'apiKey', apiKey: 'key' },
578
- mode: 'production',
579
- };
580
-
581
- // Type-safe parameters
582
- const params: CreateCardParams = {
583
- name: 'My Card',
584
- };
585
-
586
- // Type-safe responses
587
- const card: CardAccount = await session.accounts.card.create(params);
588
- ```
589
-
590
- ## Package Exports
591
-
592
- The SDK supports modular imports:
593
-
594
- ```typescript
595
- // Main SDK
596
- import { SDK } from '@bloque/sdk';
597
-
598
- // Initialization helper
599
- import { init } from '@bloque/sdk/init';
600
-
601
- // Modular clients (tree-shakeable)
602
- import { AccountsClient } from '@bloque/sdk/accounts';
603
- import { IdentityClient } from '@bloque/sdk/identity';
604
- import { ComplianceClient } from '@bloque/sdk/compliance';
605
- import { OrgsClient } from '@bloque/sdk/orgs';
606
-
607
- // Types
608
- import type {
609
- BloqueSDKConfig,
610
- CardAccount,
611
- VirtualAccount,
612
- BancolombiaAccount,
613
- } from '@bloque/sdk';
614
- ```
615
-
616
- ## Advanced Usage
617
-
618
- ### Custom HTTP Client
619
-
620
- For advanced use cases, access the HTTP client directly:
621
-
622
- ```typescript
623
- const session = await bloque.connect('did:bloque:your-origin:user-alias');
624
-
625
- // Access the HTTP client
626
- const httpClient = session.accounts.card['httpClient'];
627
-
628
- // Make custom requests
629
- const response = await httpClient.request({
630
- method: 'GET',
631
- path: '/api/custom-endpoint',
632
- timeout: 10000,
633
- });
634
- ```
635
-
636
- ### Environment-Specific Configuration
637
-
638
- ```typescript
639
- const config: BloqueSDKConfig = {
640
- origin: process.env.BLOQUE_ORIGIN!,
641
- auth: {
642
- type: 'apiKey',
643
- apiKey: process.env.BLOQUE_API_KEY!,
644
- },
645
- mode: process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',
646
- platform: 'node',
647
- timeout: Number.parseInt(process.env.BLOQUE_TIMEOUT || '30000', 10),
648
- retry: {
649
- enabled: process.env.BLOQUE_RETRY_ENABLED !== 'false',
650
- maxRetries: Number.parseInt(process.env.BLOQUE_MAX_RETRIES || '3', 10),
651
- },
652
- };
653
-
654
- const bloque = new SDK(config);
655
50
  ```
656
51
 
657
- ## Examples
52
+ ## Documentation
658
53
 
659
- See the [`examples/`](./examples) directory for complete working examples:
54
+ For complete documentation, examples, and guides, visit:
660
55
 
661
- - `basic-usage.ts` - Basic SDK usage
662
- - `virtual-cards.ts` - Virtual card management
663
- - `virtual-accounts.ts` - Virtual account management
664
- - `transfers.ts` - Account transfers
665
- - `identity-registration.ts` - User registration
666
- - `kyc-verification.ts` - KYC workflows
667
- - `error-handling.ts` - Advanced error handling
56
+ **[https://docs.bloque.app/sdk](https://docs.bloque.app/sdk)**
668
57
 
669
- ## API Documentation
58
+ The documentation includes:
670
59
 
671
- For detailed API documentation, visit [docs.bloque.app/sdk](https://docs.bloque.app/sdk).
60
+ - Getting started guides
61
+ - Account management (Virtual Cards, US Accounts, Polygon, Bancolombia)
62
+ - Identity and authentication
63
+ - Transfers and transactions
64
+ - Error handling
65
+ - TypeScript support
66
+ - Advanced configuration
672
67
 
673
68
  ## Support
674
69
 
675
- - 📧 Email: [support@bloque.app](mailto:support@bloque.app)
676
- - 💬 Discord: [discord.gg/bloque](https://discord.gg/bloque)
677
- - 📖 Docs: [docs.bloque.app](https://docs.bloque.app)
678
- - 🐛 Issues: [GitHub Issues](https://github.com/bloque/sdk/issues)
70
+ - **Documentation**: [docs.bloque.app/sdk](https://docs.bloque.app/sdk)
71
+ - **GitHub Issues**: [github.com/bloque/sdk/issues](https://github.com/bloque/sdk/issues)
679
72
 
680
73
  ## License
681
74
 
682
- MIT © [Bloque](https://www.bloque.app)
75
+ [MIT](../../LICENSE) © [Bloque](https://www.bloque.app)
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__,{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;identity;constructor(e){this.httpClient=new sdk_core_namespaceObject.HttpClient(e),this.identity=new sdk_identity_namespaceObject.IdentityClient(this.httpClient)}buildClients(){return{accounts:new sdk_accounts_namespaceObject.AccountsClient(this.httpClient),compliance:new sdk_compliance_namespaceObject.ComplianceClient(this.httpClient),identity:this.identity,orgs:new sdk_orgs_namespaceObject.OrgsClient(this.httpClient)}}getApiKey(){let{auth:e}=this.httpClient;return"apiKey"===e.type?e.apiKey:""}buildUrn(e){let t=this.httpClient.origin;if(!t)throw Error("Origin is required to build a urn");return`did:bloque:${t}:${e}`}async register(e,t){t.extraContext||(t.extraContext={});let i=this.buildUrn(e),r=this.httpClient.origin,_=await this.identity.origins.register(i,r,{assertionResult:{alias:i,challengeType:"API_KEY",value:{apiKey:this.getApiKey(),alias:i}},...t});return this.httpClient.setAccessToken(_.accessToken),this.httpClient.setUrn(i),this.buildClients()}async connect(e){let t=this.buildUrn(e),i=this.httpClient.origin,r=await this.httpClient.request({path:`/api/origins/${i}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:this.getApiKey(),alias:t}},extra_context:{}}});return this.httpClient.setAccessToken(r.result.access_token),this.httpClient.setUrn(t),this.buildClients()}}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 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__,{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;identity;constructor(e){this.httpClient=new sdk_core_namespaceObject.HttpClient(e),this.identity=new sdk_identity_namespaceObject.IdentityClient(this.httpClient)}buildClients(){return{accounts:new sdk_accounts_namespaceObject.AccountsClient(this.httpClient),compliance:new sdk_compliance_namespaceObject.ComplianceClient(this.httpClient),identity:this.identity,orgs:new sdk_orgs_namespaceObject.OrgsClient(this.httpClient)}}getApiKey(){let{auth:e}=this.httpClient;return"apiKey"===e.type?e.apiKey:""}buildUrn(e){let t=this.httpClient.origin;if(!t)throw Error("Origin is required to build a urn");return`did:bloque:${t}:${e}`}async register(e,t){t.extraContext||(t.extraContext={});let i=this.buildUrn(e),r=this.httpClient.origin,_=await this.identity.origins.register(i,r,{assertionResult:{alias:e,challengeType:"API_KEY",value:{apiKey:this.getApiKey(),alias:e}},...t});return this.httpClient.setAccessToken(_.accessToken),this.httpClient.setUrn(i),this.buildClients()}async connect(e){let t=this.buildUrn(e),i=this.httpClient.origin,r=await this.httpClient.request({path:`/api/origins/${i}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:this.getApiKey(),alias:e}},extra_context:{}}});return this.httpClient.setAccessToken(r.result.access_token),this.httpClient.setUrn(t),this.buildClients()}}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 e}from"@bloque/sdk-compliance";import{HttpClient as i}from"@bloque/sdk-core";import{IdentityClient as n}from"@bloque/sdk-identity";import{OrgsClient as s}from"@bloque/sdk-orgs";class r{httpClient;identity;constructor(t){this.httpClient=new i(t),this.identity=new n(this.httpClient)}buildClients(){return{accounts:new t(this.httpClient),compliance:new e(this.httpClient),identity:this.identity,orgs:new s(this.httpClient)}}getApiKey(){let{auth:t}=this.httpClient;return"apiKey"===t.type?t.apiKey:""}buildUrn(t){let e=this.httpClient.origin;if(!e)throw Error("Origin is required to build a urn");return`did:bloque:${e}:${t}`}async register(t,e){e.extraContext||(e.extraContext={});let i=this.buildUrn(t),n=this.httpClient.origin,s=await this.identity.origins.register(i,n,{assertionResult:{alias:i,challengeType:"API_KEY",value:{apiKey:this.getApiKey(),alias:i}},...e});return this.httpClient.setAccessToken(s.accessToken),this.httpClient.setUrn(i),this.buildClients()}async connect(t){let e=this.buildUrn(t),i=this.httpClient.origin,n=await this.httpClient.request({path:`/api/origins/${i}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:this.getApiKey(),alias:e}},extra_context:{}}});return this.httpClient.setAccessToken(n.result.access_token),this.httpClient.setUrn(e),this.buildClients()}}export{r 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 n}from"@bloque/sdk-identity";import{OrgsClient as s}from"@bloque/sdk-orgs";class r{httpClient;identity;constructor(t){this.httpClient=new i(t),this.identity=new n(this.httpClient)}buildClients(){return{accounts:new t(this.httpClient),compliance:new e(this.httpClient),identity:this.identity,orgs:new s(this.httpClient)}}getApiKey(){let{auth:t}=this.httpClient;return"apiKey"===t.type?t.apiKey:""}buildUrn(t){let e=this.httpClient.origin;if(!e)throw Error("Origin is required to build a urn");return`did:bloque:${e}:${t}`}async register(t,e){e.extraContext||(e.extraContext={});let i=this.buildUrn(t),n=this.httpClient.origin,s=await this.identity.origins.register(i,n,{assertionResult:{alias:t,challengeType:"API_KEY",value:{apiKey:this.getApiKey(),alias:t}},...e});return this.httpClient.setAccessToken(s.accessToken),this.httpClient.setUrn(i),this.buildClients()}async connect(t){let e=this.buildUrn(t),i=this.httpClient.origin,n=await this.httpClient.request({path:`/api/origins/${i}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:this.getApiKey(),alias:t}},extra_context:{}}});return this.httpClient.setAccessToken(n.result.access_token),this.httpClient.setUrn(e),this.buildClients()}}export{r as SDK};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "Official Bloque SDK",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "access": "public",
14
14
  "provenance": true
15
15
  },
16
- "homepage": "git+https://github.com/bloque-app/sdk.git#readme",
16
+ "homepage": "https://docs.bloque.app/sdk",
17
17
  "repository": {
18
18
  "type": "git",
19
19
  "url": "git+https://github.com/bloque-app/sdk.git",
@@ -63,10 +63,10 @@
63
63
  "node": ">=22"
64
64
  },
65
65
  "dependencies": {
66
- "@bloque/sdk-accounts": "0.0.24",
67
- "@bloque/sdk-compliance": "0.0.24",
68
- "@bloque/sdk-core": "0.0.24",
69
- "@bloque/sdk-identity": "0.0.24",
70
- "@bloque/sdk-orgs": "0.0.24"
66
+ "@bloque/sdk-accounts": "0.0.26",
67
+ "@bloque/sdk-compliance": "0.0.26",
68
+ "@bloque/sdk-core": "0.0.26",
69
+ "@bloque/sdk-identity": "0.0.26",
70
+ "@bloque/sdk-orgs": "0.0.26"
71
71
  }
72
72
  }