@bloque/sdk-identity 0.0.16 → 0.0.19
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 +68 -0
- package/dist/api-types.d.ts +26 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/origins/client.d.ts +22 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ Identity, aliases, and OTP authentication API client for the Bloque SDK.
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
+
- **Origin Management**: List and discover all available authentication origins
|
|
7
8
|
- **Aliases**: Get user identity information by email or phone
|
|
8
9
|
- **OTP Origins**: Send OTP codes via WhatsApp or Email
|
|
9
10
|
- **Custom Origins**: Support for custom authentication origins
|
|
@@ -155,6 +156,29 @@ const otp = await customOrigin.assert('identifier');
|
|
|
155
156
|
|
|
156
157
|
**Returns**: `OriginClient<OTPAssertion>` instance with `assert()` method
|
|
157
158
|
|
|
159
|
+
#### `origins.list()`
|
|
160
|
+
|
|
161
|
+
List all available origins with their current status:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const origins = await identity.origins.list();
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Response**:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
interface Origin {
|
|
171
|
+
namespace: string; // Unique namespace identifier
|
|
172
|
+
provider: string; // Provider type (e.g., 'evm', 'auth0', 'whatsapp')
|
|
173
|
+
status: 'active' | 'inactive' | 'disabled'; // Current status
|
|
174
|
+
metadata: Record<string, unknown>; // Additional metadata
|
|
175
|
+
created_at: string; // Creation timestamp (ISO 8601)
|
|
176
|
+
updated_at: string; // Last update timestamp (ISO 8601)
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Returns**: `Promise<Origin[]>` - Array of all registered origins
|
|
181
|
+
|
|
158
182
|
## Examples
|
|
159
183
|
|
|
160
184
|
### Get Email Alias
|
|
@@ -274,6 +298,40 @@ async function authenticateUser(email: string) {
|
|
|
274
298
|
await authenticateUser('user@example.com');
|
|
275
299
|
```
|
|
276
300
|
|
|
301
|
+
### List Available Origins
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
import { SDK } from '@bloque/sdk';
|
|
305
|
+
|
|
306
|
+
const bloque = new SDK({
|
|
307
|
+
apiKey: process.env.BLOQUE_API_KEY!,
|
|
308
|
+
mode: 'production',
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
try {
|
|
312
|
+
const origins = await bloque.identity.origins.list();
|
|
313
|
+
|
|
314
|
+
// Filter active origins
|
|
315
|
+
const activeOrigins = origins.filter(o => o.status === 'active');
|
|
316
|
+
console.log(`Found ${activeOrigins.length} active origins`);
|
|
317
|
+
|
|
318
|
+
// Find specific origins
|
|
319
|
+
const whatsappOrigins = origins.filter(o => o.provider === 'whatsapp');
|
|
320
|
+
const evmOrigins = origins.filter(o => o.provider === 'evm');
|
|
321
|
+
|
|
322
|
+
console.log('WhatsApp origins:', whatsappOrigins.map(o => o.namespace));
|
|
323
|
+
console.log('EVM origins:', evmOrigins.map(o => o.namespace));
|
|
324
|
+
|
|
325
|
+
// Get metadata from specific origin
|
|
326
|
+
const auth0Origin = origins.find(o => o.namespace === 'bloque-auth0');
|
|
327
|
+
if (auth0Origin) {
|
|
328
|
+
console.log('Auth0 metadata:', auth0Origin.metadata);
|
|
329
|
+
}
|
|
330
|
+
} catch (error) {
|
|
331
|
+
console.error('Failed to list origins:', error);
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
277
335
|
### Using Custom Origin
|
|
278
336
|
|
|
279
337
|
```typescript
|
|
@@ -344,6 +402,7 @@ This package is written in TypeScript and includes complete type definitions:
|
|
|
344
402
|
```typescript
|
|
345
403
|
import type {
|
|
346
404
|
Alias,
|
|
405
|
+
Origin,
|
|
347
406
|
OTPAssertionEmail,
|
|
348
407
|
OTPAssertionWhatsApp,
|
|
349
408
|
OTPAssertion,
|
|
@@ -356,6 +415,9 @@ import type {
|
|
|
356
415
|
// Type-safe alias retrieval
|
|
357
416
|
const alias: Alias = await identity.aliases.get('user@example.com');
|
|
358
417
|
|
|
418
|
+
// Type-safe origins list
|
|
419
|
+
const origins: Origin[] = await identity.origins.list();
|
|
420
|
+
|
|
359
421
|
// Type-safe OTP with WhatsApp
|
|
360
422
|
const whatsappOTP: OTPAssertionWhatsApp =
|
|
361
423
|
await identity.origins.whatsapp.assert('+1234567890');
|
|
@@ -392,6 +454,12 @@ const otp = await bloque.identity.origins.whatsapp.assert('+1234567890');
|
|
|
392
454
|
|
|
393
455
|
## Key Features
|
|
394
456
|
|
|
457
|
+
### Origin Management
|
|
458
|
+
|
|
459
|
+
- **List Origins**: Retrieve all available authentication origins
|
|
460
|
+
- **Filter by Provider**: Find origins by provider type (evm, auth0, whatsapp, etc.)
|
|
461
|
+
- **Check Status**: Monitor origin availability and status
|
|
462
|
+
|
|
395
463
|
### OTP Authentication Channels
|
|
396
464
|
|
|
397
465
|
- **WhatsApp**: Send OTP codes via WhatsApp messages
|
package/dist/api-types.d.ts
CHANGED
|
@@ -37,4 +37,30 @@ export interface OTPAssertionWhatsApp extends OTPBase {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
export type OTPAssertion = OTPAssertionEmail | OTPAssertionWhatsApp;
|
|
40
|
+
export interface Origin {
|
|
41
|
+
/**
|
|
42
|
+
* Unique namespace identifier for the origin
|
|
43
|
+
*/
|
|
44
|
+
namespace: string;
|
|
45
|
+
/**
|
|
46
|
+
* Provider type (e.g., 'evm', 'auth0', 'whatsapp', 'email', 'api-key')
|
|
47
|
+
*/
|
|
48
|
+
provider: ' evm' | 'auth0' | 'whatsapp' | 'email' | 'api-key';
|
|
49
|
+
/**
|
|
50
|
+
* Current status of the origin
|
|
51
|
+
*/
|
|
52
|
+
status: 'active' | 'inactive' | 'disabled';
|
|
53
|
+
/**
|
|
54
|
+
* Additional metadata about the origin
|
|
55
|
+
*/
|
|
56
|
+
metadata: Record<string, unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* Creation timestamp (ISO 8601)
|
|
59
|
+
*/
|
|
60
|
+
created_at: string;
|
|
61
|
+
/**
|
|
62
|
+
* Last update timestamp (ISO 8601)
|
|
63
|
+
*/
|
|
64
|
+
updated_at: string;
|
|
65
|
+
}
|
|
40
66
|
export {};
|
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{httpClient;constructor(e){this.httpClient=e}async get(e){return await this.httpClient.request({method:"GET",path:`/api/aliases?alias=${e}`})}}class OriginClient{httpClient;origin;constructor(e,t){this.httpClient=e,this.origin=t}async assert(e){return await this.httpClient.request({method:"GET",path:`/api/origins/${this.origin}/assert?alias=${e}`})}}class OriginsClient{whatsapp;email;httpClient;constructor(e){this.httpClient=e,this.whatsapp=new OriginClient(e,"bloque-whatsapp"),this.email=new OriginClient(e,"bloque-email")}custom(e){return new OriginClient(this.httpClient,e)}}class IdentityClient{httpClient;aliases;origins;constructor(e){this.httpClient=e,this.aliases=new AliasesClient(this.httpClient),this.origins=new OriginsClient(this.httpClient)}}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});
|
|
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{httpClient;constructor(e){this.httpClient=e}async get(e){return await this.httpClient.request({method:"GET",path:`/api/aliases?alias=${e}`})}}class OriginClient{httpClient;origin;constructor(e,t){this.httpClient=e,this.origin=t}async assert(e){return await this.httpClient.request({method:"GET",path:`/api/origins/${this.origin}/assert?alias=${e}`})}}class OriginsClient{whatsapp;email;httpClient;constructor(e){this.httpClient=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"})}}class IdentityClient{httpClient;aliases;origins;constructor(e){this.httpClient=e,this.aliases=new AliasesClient(this.httpClient),this.origins=new OriginsClient(this.httpClient)}}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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class t{httpClient;constructor(t){this.httpClient=t}async get(t){return await this.httpClient.request({method:"GET",path:`/api/aliases?alias=${t}`})}}class i{httpClient;origin;constructor(t,i){this.httpClient=t,this.origin=i}async assert(t){return await this.httpClient.request({method:"GET",path:`/api/origins/${this.origin}/assert?alias=${t}`})}}class s{whatsapp;email;httpClient;constructor(t){this.httpClient=t,this.whatsapp=new i(t,"bloque-whatsapp"),this.email=new i(t,"bloque-email")}custom(t){return new i(this.httpClient,t)}}class e{httpClient;aliases;origins;constructor(i){this.httpClient=i,this.aliases=new t(this.httpClient),this.origins=new s(this.httpClient)}}export{t as AliasesClient,e as IdentityClient,i as OriginClient,s as OriginsClient};
|
|
1
|
+
class t{httpClient;constructor(t){this.httpClient=t}async get(t){return await this.httpClient.request({method:"GET",path:`/api/aliases?alias=${t}`})}}class i{httpClient;origin;constructor(t,i){this.httpClient=t,this.origin=i}async assert(t){return await this.httpClient.request({method:"GET",path:`/api/origins/${this.origin}/assert?alias=${t}`})}}class s{whatsapp;email;httpClient;constructor(t){this.httpClient=t,this.whatsapp=new i(t,"bloque-whatsapp"),this.email=new i(t,"bloque-email")}custom(t){return new i(this.httpClient,t)}async list(){return await this.httpClient.request({method:"GET",path:"/api/origins"})}}class e{httpClient;aliases;origins;constructor(i){this.httpClient=i,this.aliases=new t(this.httpClient),this.origins=new s(this.httpClient)}}export{t as AliasesClient,e as IdentityClient,i as OriginClient,s as OriginsClient};
|
package/dist/origins/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '@bloque/sdk-core';
|
|
2
|
-
import type { OTPAssertion, OTPAssertionEmail, OTPAssertionWhatsApp } from '../api-types';
|
|
2
|
+
import type { Origin, OTPAssertion, OTPAssertionEmail, OTPAssertionWhatsApp } from '../api-types';
|
|
3
3
|
import { OriginClient } from './origin';
|
|
4
4
|
export declare class OriginsClient {
|
|
5
5
|
readonly whatsapp: OriginClient<OTPAssertionWhatsApp>;
|
|
@@ -7,4 +7,25 @@ export declare class OriginsClient {
|
|
|
7
7
|
private readonly httpClient;
|
|
8
8
|
constructor(httpClient: HttpClient);
|
|
9
9
|
custom(origin: string): OriginClient<OTPAssertion>;
|
|
10
|
+
/**
|
|
11
|
+
* List all available origins
|
|
12
|
+
*
|
|
13
|
+
* Retrieves a list of all registered origins with their current status.
|
|
14
|
+
* Origins are the entry points for user identities and represent organizations,
|
|
15
|
+
* startups, chains, or any entity that can hold a set of identities.
|
|
16
|
+
*
|
|
17
|
+
* @returns Promise resolving to an array of origins
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const origins = await bloque.identity.origins.list();
|
|
22
|
+
*
|
|
23
|
+
* // Filter active origins
|
|
24
|
+
* const activeOrigins = origins.filter(o => o.status === 'active');
|
|
25
|
+
*
|
|
26
|
+
* // Find specific provider origins
|
|
27
|
+
* const evmOrigins = origins.filter(o => o.provider === 'evm');
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
list(): Promise<Origin[]>;
|
|
10
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk-identity",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
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.19"
|
|
38
38
|
}
|
|
39
39
|
}
|