@bloque/sdk-identity 0.8.0 → 0.9.0

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.
@@ -1,5 +1,5 @@
1
1
  import { BaseClient } from '@bloque/sdk-core';
2
- import type { ApiKeyInfo, CreateApiKeyParams, CreateApiKeyResult, ExchangeApiKeyParams, ExchangeApiKeyResult, RotateApiKeyResult } from './types';
2
+ import type { ApiKeyInfo, CreateApiKeyParams, CreateApiKeyResult, ExchangeApiKeyParams, ExchangeApiKeyResult, RotateApiKeyResult, UpsertOriginWebhookSecretParams, UpsertOriginWebhookSecretResult } from './types';
3
3
  export declare class ApiKeysClient extends BaseClient {
4
4
  /**
5
5
  * Create a new API key.
@@ -23,4 +23,12 @@ export declare class ApiKeysClient extends BaseClient {
23
23
  revoke(id: string): Promise<void>;
24
24
  /** Rotate an API key secret. Returns the new secret key (shown only once). */
25
25
  rotate(id: string): Promise<RotateApiKeyResult>;
26
+ /**
27
+ * Create or update the webhook secret for an API-key-provider origin.
28
+ * Authenticates purely via the origin's own `apiKey` — no session/JWT
29
+ * involved, so your server can call this without a logged-in user.
30
+ *
31
+ * @param originName - The namespace of the api-key-provider origin.
32
+ */
33
+ upsertOriginWebhookSecret(originName: string, params: UpsertOriginWebhookSecretParams): Promise<UpsertOriginWebhookSecretResult>;
26
34
  }
@@ -33,3 +33,13 @@ export interface ApiKeyInfo {
33
33
  export interface RotateApiKeyResult {
34
34
  secretKey: string;
35
35
  }
36
+ export interface UpsertOriginWebhookSecretParams {
37
+ /** The origin's own API key — authenticates this call, no session/JWT needed. */
38
+ apiKey: string;
39
+ webhookSecret: string;
40
+ }
41
+ export interface UpsertOriginWebhookSecretResult {
42
+ originName: string;
43
+ key: string;
44
+ updated: true;
45
+ }
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__,{ApiKeysClient:()=>ApiKeysClient,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=${encodeURIComponent(e)}`})}}function mapApiKeyWire(e){return{id:e.id,keyId:e.key_id,publishableKey:e.publishable_key,name:e.name,scopes:e.scopes,domains:e.domains,status:e.status,expiration:e.expiration,metadata:e.metadata,lastUsedAt:e.last_used_at,createdAt:e.created_at}}class ApiKeysClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={name:e.name,scopes:e.scopes,domains:e.domains,expiration:e.expiration,metadata:e.metadata},i=await this.httpClient.request({method:"POST",path:"/api/api-keys",body:t});return{keyId:i.key_id,secretKey:i.secret_key,publishableKey:i.publishable_key}}async list(){return(await this.httpClient.request({method:"GET",path:"/api/api-keys"})).map(mapApiKeyWire)}async get(e){return mapApiKeyWire(await this.httpClient.request({method:"GET",path:`/api/api-keys/${e}`}))}async exchange(e){let t=await this.httpClient.request({method:"POST",path:"/api/api-keys/exchange",body:{key:e.key,scopes:e.scopes}});return{accessToken:t.access_token,expiresIn:t.expires_in,tokenType:t.token_type}}async revoke(e){await this.httpClient.request({method:"DELETE",path:`/api/api-keys/${e}`})}async rotate(e){return{secretKey:(await this.httpClient.request({method:"POST",path:`/api/api-keys/${e}/rotate`})).secret_key}}}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,i){let a,s=i.assertionResult,n="API_KEY"===s.challengeType?{alias:s.alias,challengeType:"API_KEY",value:{api_key:s.value.apiKey,alias:e},originalChallengeParams:s.originalChallengeParams}:{alias:e,challengeType:s.challengeType,value:s.value,originalChallengeParams:s.originalChallengeParams};return a="individual"===i.type?{assertion_result:n,extra_context:i.extraContext,type:"individual",profile:this._mapUserProfile(i.profile)}:{assertion_result:n,extra_context:i.extraContext,type:"business",profile:this._mapBusinessProfile(i.profile)},{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${t}/register`,body:a,headers:i.clientIp?{"x-original-client-ip":i.clientIp}:void 0})).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;apiKeys;origins;constructor(e){this.httpClient=e,this.aliases=new AliasesClient(this.httpClient),this.apiKeys=new ApiKeysClient(this.httpClient),this.origins=new OriginsClient(this.httpClient)}async me(){return await this.httpClient.request({method:"GET",path:"/api/identities/me"})}async updateMe(e){return(await this.httpClient.request({method:"PATCH",path:"/api/identities/me",body:e})).result.identity}async myAliases(){return await this.httpClient.request({method:"GET",path:"/api/identities/me/aliases"})}async get(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}`})}async update(e,t){return(await this.httpClient.request({method:"PATCH",path:`/api/identities/${e}`,body:t})).result.identity}async getAliases(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}/aliases`})}}for(var __rspack_i in exports.AliasesClient=__webpack_exports__.AliasesClient,exports.ApiKeysClient=__webpack_exports__.ApiKeysClient,exports.IdentityClient=__webpack_exports__.IdentityClient,exports.OriginClient=__webpack_exports__.OriginClient,exports.OriginsClient=__webpack_exports__.OriginsClient,__webpack_exports__)-1===["AliasesClient","ApiKeysClient","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__,{ApiKeysClient:()=>ApiKeysClient,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=${encodeURIComponent(e)}`})}}function mapApiKeyWire(e){return{id:e.id,keyId:e.key_id,publishableKey:e.publishable_key,name:e.name,scopes:e.scopes,domains:e.domains,status:e.status,expiration:e.expiration,metadata:e.metadata,lastUsedAt:e.last_used_at,createdAt:e.created_at}}class ApiKeysClient extends sdk_core_namespaceObject.BaseClient{async create(e){let t={name:e.name,scopes:e.scopes,domains:e.domains,expiration:e.expiration,metadata:e.metadata},i=await this.httpClient.request({method:"POST",path:"/api/api-keys",body:t});return{keyId:i.key_id,secretKey:i.secret_key,publishableKey:i.publishable_key}}async list(){return(await this.httpClient.request({method:"GET",path:"/api/api-keys"})).map(mapApiKeyWire)}async get(e){return mapApiKeyWire(await this.httpClient.request({method:"GET",path:`/api/api-keys/${e}`}))}async exchange(e){let t=await this.httpClient.request({method:"POST",path:"/api/api-keys/exchange",body:{key:e.key,scopes:e.scopes}});return{accessToken:t.access_token,expiresIn:t.expires_in,tokenType:t.token_type}}async revoke(e){await this.httpClient.request({method:"DELETE",path:`/api/api-keys/${e}`})}async rotate(e){return{secretKey:(await this.httpClient.request({method:"POST",path:`/api/api-keys/${e}/rotate`})).secret_key}}async upsertOriginWebhookSecret(e,t){let i=await this.httpClient.request({method:"PUT",path:`/api/api-keys/origins/${e}/webhook-secret`,body:{api_key:t.apiKey,webhook_secret:t.webhookSecret}});return{originName:i.origin_name,key:i.key,updated:i.updated}}}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}`})}async attest(e){return await this.httpClient.request({method:"GET",path:e?`/api/origins/${this.origin}/attest?alias=${e}`:`/api/origins/${this.origin}/attest`})}}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,i){let a,s=i.assertionResult,n="API_KEY"===s.challengeType?{alias:s.alias,challengeType:"API_KEY",value:{api_key:s.value.apiKey,alias:e},originalChallengeParams:s.originalChallengeParams}:{alias:e,challengeType:s.challengeType,value:s.value,originalChallengeParams:s.originalChallengeParams};return a="individual"===i.type?{assertion_result:n,extra_context:i.extraContext,type:"individual",profile:this._mapUserProfile(i.profile)}:"business"===i.type?{assertion_result:n,extra_context:i.extraContext,type:"business",profile:this._mapBusinessProfile(i.profile)}:{assertion_result:n,extra_context:i.extraContext,type:i.type,profile:i.profile},{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${t}/register`,body:a,headers:i.clientIp?{"x-original-client-ip":i.clientIp}:void 0})).result.access_token}}async connect(e,t,i){return{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${t}/connect`,body:{assertion_result:{alias:e,challengeType:i.assertionResult.challengeType,value:i.assertionResult.value,originalChallengeParams:i.assertionResult.originalChallengeParams},extra_context:i.extraContext}})).result.access_token}}async updateMetadata(e,t){let i=await this.httpClient.request({method:"PATCH",path:`/api/origins/${e}/metadata`,body:{api_key:t.apiKey,metadata:t.metadata}});return{originName:i.origin_name,metadata:i.metadata,updated:i.updated}}_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;apiKeys;origins;constructor(e){this.httpClient=e,this.aliases=new AliasesClient(this.httpClient),this.apiKeys=new ApiKeysClient(this.httpClient),this.origins=new OriginsClient(this.httpClient)}async me(){return await this.httpClient.request({method:"GET",path:"/api/identities/me"})}async updateMe(e){return(await this.httpClient.request({method:"PATCH",path:"/api/identities/me",body:e})).result.identity}async myAliases(){return await this.httpClient.request({method:"GET",path:"/api/identities/me/aliases"})}async get(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}`})}async update(e,t){return(await this.httpClient.request({method:"PATCH",path:`/api/identities/${e}`,body:t})).result.identity}async getAliases(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}/aliases`})}}for(var __rspack_i in exports.AliasesClient=__webpack_exports__.AliasesClient,exports.ApiKeysClient=__webpack_exports__.ApiKeysClient,exports.IdentityClient=__webpack_exports__.IdentityClient,exports.OriginClient=__webpack_exports__.OriginClient,exports.OriginsClient=__webpack_exports__.OriginsClient,__webpack_exports__)-1===["AliasesClient","ApiKeysClient","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
- 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=${encodeURIComponent(e)}`})}}function a(e){return{id:e.id,keyId:e.key_id,publishableKey:e.publishable_key,name:e.name,scopes:e.scopes,domains:e.domains,status:e.status,expiration:e.expiration,metadata:e.metadata,lastUsedAt:e.last_used_at,createdAt:e.created_at}}class i extends e{async create(e){let t={name:e.name,scopes:e.scopes,domains:e.domains,expiration:e.expiration,metadata:e.metadata},a=await this.httpClient.request({method:"POST",path:"/api/api-keys",body:t});return{keyId:a.key_id,secretKey:a.secret_key,publishableKey:a.publishable_key}}async list(){return(await this.httpClient.request({method:"GET",path:"/api/api-keys"})).map(a)}async get(e){return a(await this.httpClient.request({method:"GET",path:`/api/api-keys/${e}`}))}async exchange(e){let t=await this.httpClient.request({method:"POST",path:"/api/api-keys/exchange",body:{key:e.key,scopes:e.scopes}});return{accessToken:t.access_token,expiresIn:t.expires_in,tokenType:t.token_type}}async revoke(e){await this.httpClient.request({method:"DELETE",path:`/api/api-keys/${e}`})}async rotate(e){return{secretKey:(await this.httpClient.request({method:"POST",path:`/api/api-keys/${e}/rotate`})).secret_key}}}class s 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 n extends e{whatsapp;email;constructor(e){super(e),this.whatsapp=new s(e,"bloque-whatsapp"),this.email=new s(e,"bloque-email")}custom(e){return new s(this.httpClient,e)}async list(){return await this.httpClient.request({method:"GET",path:"/api/origins"})}async register(e,t,a){let i,s=a.assertionResult,n="API_KEY"===s.challengeType?{alias:s.alias,challengeType:"API_KEY",value:{api_key:s.value.apiKey,alias:e},originalChallengeParams:s.originalChallengeParams}:{alias:e,challengeType:s.challengeType,value:s.value,originalChallengeParams:s.originalChallengeParams};return i="individual"===a.type?{assertion_result:n,extra_context:a.extraContext,type:"individual",profile:this._mapUserProfile(a.profile)}:{assertion_result:n,extra_context:a.extraContext,type:"business",profile:this._mapBusinessProfile(a.profile)},{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${t}/register`,body:i,headers:a.clientIp?{"x-original-client-ip":a.clientIp}:void 0})).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 r{httpClient;aliases;apiKeys;origins;constructor(e){this.httpClient=e,this.aliases=new t(this.httpClient),this.apiKeys=new i(this.httpClient),this.origins=new n(this.httpClient)}async me(){return await this.httpClient.request({method:"GET",path:"/api/identities/me"})}async updateMe(e){return(await this.httpClient.request({method:"PATCH",path:"/api/identities/me",body:e})).result.identity}async myAliases(){return await this.httpClient.request({method:"GET",path:"/api/identities/me/aliases"})}async get(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}`})}async update(e,t){return(await this.httpClient.request({method:"PATCH",path:`/api/identities/${e}`,body:t})).result.identity}async getAliases(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}/aliases`})}}export{t as AliasesClient,i as ApiKeysClient,r as IdentityClient,s as OriginClient,n as OriginsClient};
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=${encodeURIComponent(e)}`})}}function a(e){return{id:e.id,keyId:e.key_id,publishableKey:e.publishable_key,name:e.name,scopes:e.scopes,domains:e.domains,status:e.status,expiration:e.expiration,metadata:e.metadata,lastUsedAt:e.last_used_at,createdAt:e.created_at}}class i extends e{async create(e){let t={name:e.name,scopes:e.scopes,domains:e.domains,expiration:e.expiration,metadata:e.metadata},a=await this.httpClient.request({method:"POST",path:"/api/api-keys",body:t});return{keyId:a.key_id,secretKey:a.secret_key,publishableKey:a.publishable_key}}async list(){return(await this.httpClient.request({method:"GET",path:"/api/api-keys"})).map(a)}async get(e){return a(await this.httpClient.request({method:"GET",path:`/api/api-keys/${e}`}))}async exchange(e){let t=await this.httpClient.request({method:"POST",path:"/api/api-keys/exchange",body:{key:e.key,scopes:e.scopes}});return{accessToken:t.access_token,expiresIn:t.expires_in,tokenType:t.token_type}}async revoke(e){await this.httpClient.request({method:"DELETE",path:`/api/api-keys/${e}`})}async rotate(e){return{secretKey:(await this.httpClient.request({method:"POST",path:`/api/api-keys/${e}/rotate`})).secret_key}}async upsertOriginWebhookSecret(e,t){let a=await this.httpClient.request({method:"PUT",path:`/api/api-keys/origins/${e}/webhook-secret`,body:{api_key:t.apiKey,webhook_secret:t.webhookSecret}});return{originName:a.origin_name,key:a.key,updated:a.updated}}}class s 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}`})}async attest(e){return await this.httpClient.request({method:"GET",path:e?`/api/origins/${this.origin}/attest?alias=${e}`:`/api/origins/${this.origin}/attest`})}}class n extends e{whatsapp;email;constructor(e){super(e),this.whatsapp=new s(e,"bloque-whatsapp"),this.email=new s(e,"bloque-email")}custom(e){return new s(this.httpClient,e)}async list(){return await this.httpClient.request({method:"GET",path:"/api/origins"})}async register(e,t,a){let i,s=a.assertionResult,n="API_KEY"===s.challengeType?{alias:s.alias,challengeType:"API_KEY",value:{api_key:s.value.apiKey,alias:e},originalChallengeParams:s.originalChallengeParams}:{alias:e,challengeType:s.challengeType,value:s.value,originalChallengeParams:s.originalChallengeParams};return i="individual"===a.type?{assertion_result:n,extra_context:a.extraContext,type:"individual",profile:this._mapUserProfile(a.profile)}:"business"===a.type?{assertion_result:n,extra_context:a.extraContext,type:"business",profile:this._mapBusinessProfile(a.profile)}:{assertion_result:n,extra_context:a.extraContext,type:a.type,profile:a.profile},{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${t}/register`,body:i,headers:a.clientIp?{"x-original-client-ip":a.clientIp}:void 0})).result.access_token}}async connect(e,t,a){return{accessToken:(await this.httpClient.request({method:"POST",path:`/api/origins/${t}/connect`,body:{assertion_result:{alias:e,challengeType:a.assertionResult.challengeType,value:a.assertionResult.value,originalChallengeParams:a.assertionResult.originalChallengeParams},extra_context:a.extraContext}})).result.access_token}}async updateMetadata(e,t){let a=await this.httpClient.request({method:"PATCH",path:`/api/origins/${e}/metadata`,body:{api_key:t.apiKey,metadata:t.metadata}});return{originName:a.origin_name,metadata:a.metadata,updated:a.updated}}_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 r{httpClient;aliases;apiKeys;origins;constructor(e){this.httpClient=e,this.aliases=new t(this.httpClient),this.apiKeys=new i(this.httpClient),this.origins=new n(this.httpClient)}async me(){return await this.httpClient.request({method:"GET",path:"/api/identities/me"})}async updateMe(e){return(await this.httpClient.request({method:"PATCH",path:"/api/identities/me",body:e})).result.identity}async myAliases(){return await this.httpClient.request({method:"GET",path:"/api/identities/me/aliases"})}async get(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}`})}async update(e,t){return(await this.httpClient.request({method:"PATCH",path:`/api/identities/${e}`,body:t})).result.identity}async getAliases(e){return await this.httpClient.request({method:"GET",path:`/api/identities/${e}/aliases`})}}export{t as AliasesClient,i as ApiKeysClient,r as IdentityClient,s as OriginClient,n as OriginsClient};
@@ -21,7 +21,7 @@ export type AliasResponse = {
21
21
  alias: string;
22
22
  [key: string]: unknown;
23
23
  };
24
- status: 'active' | 'inactive' | 'revoked';
24
+ status: 'awaiting_verification' | 'active' | 'inactive' | 'blocked' | 'rejected';
25
25
  is_public: boolean;
26
26
  is_primary: boolean;
27
27
  created_at: string;
@@ -199,11 +199,22 @@ export type BusinessRegisterRequest = {
199
199
  type: 'business';
200
200
  profile: BusinessProfile;
201
201
  };
202
+ /**
203
+ * @internal
204
+ * Registration request for identity types with no dedicated profile shape
205
+ * (`dao`, `proxy`, `other`).
206
+ */
207
+ export type OtherRegisterRequest = {
208
+ assertion_result: AssertionResult;
209
+ extra_context?: Record<string, unknown>;
210
+ type: 'dao' | 'proxy' | 'other';
211
+ profile: Record<string, unknown>;
212
+ };
202
213
  /**
203
214
  * @internal
204
215
  * Combined registration request type
205
216
  */
206
- export type RegisterRequest = IndividualRegisterRequest | BusinessRegisterRequest;
217
+ export type RegisterRequest = IndividualRegisterRequest | BusinessRegisterRequest | OtherRegisterRequest;
207
218
  /**
208
219
  * @internal
209
220
  * Registration response from API
@@ -4,4 +4,15 @@ 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>;
7
+ /**
8
+ * Request the attestation challenge that starts registration — the
9
+ * counterpart to `assert()`, which starts connecting to an existing
10
+ * identity instead. Resolve the returned challenge and pass the result
11
+ * as `register()`'s `assertionResult`.
12
+ *
13
+ * @param alias - Optional identity alias/identifier (e.g. a wallet
14
+ * address for Ethereum origins). Omit for challenge types that don't
15
+ * need one.
16
+ */
17
+ attest(alias?: string): Promise<TAssertion>;
7
18
  }
@@ -2,7 +2,7 @@ import type { HttpClient } from '@bloque/sdk-core';
2
2
  import { BaseClient } from '@bloque/sdk-core';
3
3
  import type { Origin, OTPAssertion, OTPAssertionEmail, OTPAssertionWhatsApp } from '../internal/wire-types';
4
4
  import { OriginClient } from './origin-client';
5
- import type { RegisterParams, RegisterResult } from './types';
5
+ import type { ConnectParams, RegisterParams, RegisterResult, UpdateOriginMetadataParams, UpdateOriginMetadataResult } from './types';
6
6
  export declare class OriginsClient extends BaseClient {
7
7
  readonly whatsapp: OriginClient<OTPAssertionWhatsApp>;
8
8
  readonly email: OriginClient<OTPAssertionEmail>;
@@ -123,6 +123,43 @@ export declare class OriginsClient extends BaseClient {
123
123
  * ```
124
124
  */
125
125
  register(alias: string, origin: string, params: RegisterParams): Promise<RegisterResult>;
126
+ /**
127
+ * Connect to an existing identity — the counterpart to `register()`.
128
+ * Resolve an `assert()` challenge and pass the result here to obtain an
129
+ * access token for an identity that already exists, instead of creating
130
+ * a new one.
131
+ *
132
+ * @param alias - The identity alias/identifier being connected (same
133
+ * value passed to `assert()`).
134
+ * @param origin - The origin namespace to connect with.
135
+ * @param params - The resolved assertion result.
136
+ * @returns Promise resolving to the connection result with access token.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const challenge = await bloque.identity.email.assert('user@example.com');
141
+ * // ...resolve the challenge (e.g. collect the OTP the user received)...
142
+ * const session = await bloque.identity.origins.connect('user@example.com', 'bloque-email', {
143
+ * assertionResult: {
144
+ * alias: 'user@example.com',
145
+ * challengeType: 'OTP',
146
+ * value: { code: '123456' },
147
+ * },
148
+ * });
149
+ * ```
150
+ */
151
+ connect(alias: string, origin: string, params: ConnectParams): Promise<RegisterResult>;
152
+ /**
153
+ * Self-service update of an API-key-provider origin's presentation
154
+ * metadata (e.g. `company`, `gate_accent_color`). Authenticates purely
155
+ * via the origin's own `apiKey` — no session/JWT involved, so your
156
+ * server can call this directly. Shallow-merges `params.metadata` into
157
+ * the origin's existing metadata; only allowlisted keys are accepted
158
+ * (see {@link SelfServiceMetadataKey}).
159
+ *
160
+ * @param originName - The namespace of the api-key-provider origin.
161
+ */
162
+ updateMetadata(originName: string, params: UpdateOriginMetadataParams): Promise<UpdateOriginMetadataResult>;
126
163
  private _mapUserProfile;
127
164
  private _mapBusinessProfile;
128
165
  }
@@ -28,7 +28,13 @@ type BaseAssertion<TType extends string, TValue> = {
28
28
  };
29
29
  };
30
30
  type ApiKeyAssertion = BaseAssertion<'API_KEY', ApiKeyValue>;
31
- type InteractiveAssertion = BaseAssertion<'REDIRECT' | 'OAUTH_REDIRECT' | 'SIGNING_CHALLENGE' | 'WEBAUTHN' | 'OTP' | 'PASSWORD', SigningChallengeValue>;
31
+ /**
32
+ * An assertion resolution for a challenge type a user resolves directly
33
+ * (as opposed to `API_KEY`, which is your server registering on a user's
34
+ * behalf). This is the only kind `connect()` accepts.
35
+ */
36
+ export type InteractiveAssertionResult = BaseAssertion<'REDIRECT' | 'OAUTH_REDIRECT' | 'SIGNING_CHALLENGE' | 'WEBAUTHN' | 'OTP' | 'PASSWORD', SigningChallengeValue>;
37
+ type InteractiveAssertion = InteractiveAssertionResult;
32
38
  type AssertionResult = ApiKeyAssertion | InteractiveAssertion;
33
39
  interface UserProfile {
34
40
  firstName?: string;
@@ -205,11 +211,73 @@ export interface BusinessRegisterParams {
205
211
  */
206
212
  clientIp?: string;
207
213
  }
208
- export type RegisterParams = IndividualRegisterParams | BusinessRegisterParams;
214
+ /**
215
+ * Registration params for identity types with no dedicated profile shape
216
+ * (`dao`, `proxy`, `other`). These have little to no server-side profile
217
+ * validation today — confirm with Bloque which of these your integration
218
+ * actually needs before relying on one in production.
219
+ */
220
+ export interface OtherRegisterParams {
221
+ /**
222
+ * Result of the assertion challenge
223
+ */
224
+ assertionResult: AssertionResult;
225
+ /**
226
+ * Additional context data
227
+ */
228
+ extraContext?: Record<string, unknown>;
229
+ /**
230
+ * Type of entity being registered
231
+ */
232
+ type: 'dao' | 'proxy' | 'other';
233
+ /**
234
+ * Unstructured profile data — shape is caller-defined for these types.
235
+ */
236
+ profile: Record<string, unknown>;
237
+ /**
238
+ * The end user's own IP address, forwarded from your server so Bloque can
239
+ * resolve their real usage country and record it on the compliance audit
240
+ * trail — instead of falling back to your server's own IP. Only honored
241
+ * for `API_KEY`-challenge registrations (your server calling on the
242
+ * user's behalf); silently ignored otherwise, since Bloque can already
243
+ * see the caller's real IP for interactive challenge types.
244
+ * @example "190.85.12.4"
245
+ */
246
+ clientIp?: string;
247
+ }
248
+ export type RegisterParams = IndividualRegisterParams | BusinessRegisterParams | OtherRegisterParams;
209
249
  export interface RegisterResult {
210
250
  /**
211
251
  * JWT access token for the registered identity
212
252
  */
213
253
  accessToken: string;
214
254
  }
255
+ export interface ConnectParams {
256
+ /**
257
+ * Result of the assertion challenge from `assert()`. Only interactive
258
+ * challenge types are accepted — not `API_KEY`, which is for registering
259
+ * a new identity on a user's behalf, not reconnecting to an existing one.
260
+ */
261
+ assertionResult: InteractiveAssertionResult;
262
+ /**
263
+ * Additional context data
264
+ */
265
+ extraContext?: Record<string, unknown>;
266
+ }
267
+ /**
268
+ * Metadata keys an origin may self-service update via `updateMetadata()`.
269
+ * Any other key is rejected.
270
+ */
271
+ export type SelfServiceMetadataKey = 'company' | 'tos_gate_show_home' | 'gate_accent_color' | 'verification_gate_return_url_allowlist' | 'gate_frame_ancestors_allowlist';
272
+ export interface UpdateOriginMetadataParams {
273
+ /** The origin's own API key — authenticates this call, no session/JWT needed. */
274
+ apiKey: string;
275
+ /** Shallow-merged into the origin's existing metadata. Unlisted keys are rejected. */
276
+ metadata: Partial<Record<SelfServiceMetadataKey, unknown>>;
277
+ }
278
+ export interface UpdateOriginMetadataResult {
279
+ originName: string;
280
+ metadata: Record<string, unknown>;
281
+ updated: true;
282
+ }
215
283
  export {};
package/dist/types.d.ts CHANGED
@@ -4,8 +4,9 @@ export type CreateIdentityParams = Pick<IndividualRegisterParams, 'extraContext'
4
4
  * Parameters for updating the current user's identity
5
5
  */
6
6
  export interface UpdateIdentityParams {
7
- /** Partial profile fields to update (merged with existing) */
8
- profile?: Partial<IdentityMeProfile>;
7
+ /** Partial profile fields to update (merged with existing). Shape
8
+ * depends on the identity's `type` — see {@link IdentityMe.profile}. */
9
+ profile?: Partial<IdentityMeProfile> | Partial<IdentityMeBusinessProfile> | Record<string, unknown>;
9
10
  /** Partial metadata to update (merged with existing) */
10
11
  metadata?: Record<string, unknown>;
11
12
  }
@@ -18,29 +19,60 @@ export interface IdentityAlias {
18
19
  verified: boolean;
19
20
  primary: boolean;
20
21
  }
22
+ /**
23
+ * Shape of `IdentityMe.profile` when `type === 'individual'`. Other
24
+ * identity types (`business`, `dao`, `proxy`, `other`) have a differently
25
+ * shaped profile — see {@link IdentityMe.profile}.
26
+ */
21
27
  export interface IdentityMeProfile {
22
- city: string;
23
- email: string;
24
- phone: string;
25
- state: string;
26
- gender: string;
27
- birthdate: string;
28
- last_name: string;
29
- first_name: string;
30
- postal_code: string;
31
- neighborhood: string;
32
- address_line1: string;
28
+ city?: string;
29
+ email?: string;
30
+ phone?: string;
31
+ state?: string;
32
+ gender?: string;
33
+ birthdate?: string;
34
+ last_name?: string;
35
+ first_name?: string;
36
+ postal_code?: string;
37
+ neighborhood?: string;
38
+ address_line1?: string;
39
+ address_line2?: string;
40
+ personal_id_type?: string;
41
+ personal_id_number?: string;
42
+ country_of_birth_code?: string;
43
+ country_of_residence_code?: string;
44
+ }
45
+ /**
46
+ * Shape of `IdentityMe.profile` when `type === 'business'`.
47
+ */
48
+ export interface IdentityMeBusinessProfile {
49
+ legal_name?: string;
50
+ tax_id?: string;
51
+ owner_name?: string;
52
+ owner_id_type?: string;
53
+ owner_id_number?: string;
54
+ address_line1?: string;
33
55
  address_line2?: string;
34
- personal_id_type: string;
35
- personal_id_number: string;
36
- country_of_birth_code: string;
37
- country_of_residence_code: string;
56
+ city?: string;
57
+ state?: string;
58
+ postal_code?: string;
59
+ country_code?: string;
60
+ phone?: string;
61
+ email?: string;
38
62
  }
39
63
  export interface IdentityMe {
40
64
  urn: string;
41
65
  origin: string;
66
+ /** `'individual'`, `'business'`, `'dao'`, `'proxy'`, or `'other'`. Check
67
+ * this before reading `profile` — its shape depends on this value. */
42
68
  type: string;
43
- profile: IdentityMeProfile;
69
+ /**
70
+ * Shaped per `type`: {@link IdentityMeProfile} for `'individual'`,
71
+ * {@link IdentityMeBusinessProfile} for `'business'`. `'dao'`/`'proxy'`/
72
+ * `'other'` identities carry an unstructured profile — treat it as
73
+ * `Record<string, unknown>` for those.
74
+ */
75
+ profile: IdentityMeProfile | IdentityMeBusinessProfile | Record<string, unknown>;
44
76
  status: string;
45
77
  metadata: Record<string, unknown>;
46
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/sdk-identity",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
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.5.0"
37
+ "@bloque/sdk-core": "0.9.0"
38
38
  }
39
39
  }