@bloque/sdk 0.6.0 → 0.7.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.
- package/dist/bloque.d.ts +44 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bloque.d.ts
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
import { AccountsClient } from '@bloque/sdk-accounts';
|
|
2
2
|
import { ComplianceClient } from '@bloque/sdk-compliance';
|
|
3
3
|
import { type BloqueSDKConfig } from '@bloque/sdk-core';
|
|
4
|
-
import { type CreateIdentityParams, IdentityClient, type IdentityMe
|
|
4
|
+
import { type CreateIdentityParams, IdentityClient, type IdentityMe } from '@bloque/sdk-identity';
|
|
5
5
|
import { OrgsClient } from '@bloque/sdk-orgs';
|
|
6
6
|
import { SwapClient } from '@bloque/sdk-swap';
|
|
7
|
+
/**
|
|
8
|
+
* Self-serviceable presentation metadata for an API-key origin. This is the
|
|
9
|
+
* complete allowlist accepted by `bloque.origins.updateMetadata()` — any
|
|
10
|
+
* other field on an origin's `metadata` (e.g. `contactEmail`) is owned by
|
|
11
|
+
* other systems and can't be set through this surface.
|
|
12
|
+
*/
|
|
13
|
+
export interface OriginMetadataPatch {
|
|
14
|
+
/**
|
|
15
|
+
* Developer-facing display name substituted as `{{developer_name}}` into
|
|
16
|
+
* the hosted TOS document. Non-empty, at most 200 characters.
|
|
17
|
+
*/
|
|
18
|
+
company?: string;
|
|
19
|
+
/** Skip the hosted TOS gate's intro screens. */
|
|
20
|
+
tosGateShowHome?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Brand accent color applied to both hosted gates' `--accent` CSS
|
|
23
|
+
* variable. Strict 3- or 6-digit CSS hex (e.g. `#f80` or `#ff8800`) —
|
|
24
|
+
* anything else is silently dropped server-side, never partially applied.
|
|
25
|
+
*/
|
|
26
|
+
gateAccentColor?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Bare origins (scheme + host + port, no path or trailing slash) allowed
|
|
29
|
+
* as `returnUrl` on `compliance.verificationGate.start()`, in addition to
|
|
30
|
+
* the deployment-wide `VERIFICATION_GATE_RETURN_URL_ALLOWLIST` env var —
|
|
31
|
+
* either being satisfied is enough. Replaces the whole array; it does not
|
|
32
|
+
* append to whatever is already configured.
|
|
33
|
+
*/
|
|
34
|
+
verificationGateReturnUrlAllowlist?: string[];
|
|
35
|
+
}
|
|
7
36
|
export interface UpdateOriginMetadataOptions {
|
|
8
37
|
/**
|
|
9
38
|
* Origin namespace to patch. Defaults to the SDK's configured `origin` —
|
|
@@ -20,6 +49,13 @@ export interface UpdateOriginMetadataOptions {
|
|
|
20
49
|
apiKey?: string;
|
|
21
50
|
metadata: OriginMetadataPatch;
|
|
22
51
|
}
|
|
52
|
+
export interface UpdateOriginMetadataResult {
|
|
53
|
+
/** Origin namespace that was updated. */
|
|
54
|
+
originName: string;
|
|
55
|
+
/** The origin's full metadata after the patch was merged in. */
|
|
56
|
+
metadata: Record<string, unknown>;
|
|
57
|
+
updated: true;
|
|
58
|
+
}
|
|
23
59
|
export interface BloqueClients {
|
|
24
60
|
accounts: AccountsClient;
|
|
25
61
|
compliance: ComplianceClient;
|
|
@@ -65,7 +101,7 @@ export declare class SDK {
|
|
|
65
101
|
* `register()`, but for configuring the origin itself rather than one of
|
|
66
102
|
* its identities.
|
|
67
103
|
*/
|
|
68
|
-
get
|
|
104
|
+
get origins(): {
|
|
69
105
|
/**
|
|
70
106
|
* Patch this origin's own presentation metadata (`company`,
|
|
71
107
|
* `tosGateShowHome`, `gateAccentColor`,
|
|
@@ -74,15 +110,18 @@ export declare class SDK {
|
|
|
74
110
|
* you typically only pass `metadata`:
|
|
75
111
|
*
|
|
76
112
|
* ```typescript
|
|
77
|
-
* await bloque.
|
|
113
|
+
* await bloque.origins.updateMetadata({
|
|
78
114
|
* metadata: { gateAccentColor: '#1a73e8' },
|
|
79
115
|
* });
|
|
80
116
|
* ```
|
|
81
117
|
*
|
|
82
118
|
* This is a one-time/deploy-script call, not something you run
|
|
83
|
-
* per-request or per-user.
|
|
119
|
+
* per-request or per-user. Fields you omit from `metadata` are left
|
|
120
|
+
* untouched on the origin (shallow merge) — the response echoes the
|
|
121
|
+
* full post-merge metadata so you can confirm what actually took
|
|
122
|
+
* effect.
|
|
84
123
|
*/
|
|
85
|
-
|
|
124
|
+
updateMetadata: (options: UpdateOriginMetadataOptions) => Promise<UpdateOriginMetadataResult>;
|
|
86
125
|
};
|
|
87
126
|
private updateOriginMetadata;
|
|
88
127
|
private resolveOwnApiKey;
|
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,
|
|
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 r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__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__,{BloqueInsufficientFundsError:()=>sdk_core_namespaceObject.BloqueInsufficientFundsError,BloqueAuthenticationError:()=>sdk_core_namespaceObject.BloqueAuthenticationError,BloqueNetworkError:()=>sdk_core_namespaceObject.BloqueNetworkError,BloqueRateLimitError:()=>sdk_core_namespaceObject.BloqueRateLimitError,BloqueAPIError:()=>sdk_core_namespaceObject.BloqueAPIError,BloqueConfigError:()=>sdk_core_namespaceObject.BloqueConfigError,BloqueTierLimitExceededError:()=>sdk_core_namespaceObject.BloqueTierLimitExceededError,BloqueValidationError:()=>sdk_core_namespaceObject.BloqueValidationError,BloqueVerificationPendingError:()=>sdk_core_namespaceObject.BloqueVerificationPendingError,BloqueVerificationRequiredError:()=>sdk_core_namespaceObject.BloqueVerificationRequiredError,BloqueNotFoundError:()=>sdk_core_namespaceObject.BloqueNotFoundError,SDK:()=>SDK,BloqueTimeoutError:()=>sdk_core_namespaceObject.BloqueTimeoutError});const sdk_core_namespaceObject=require("@bloque/sdk-core"),sdk_accounts_namespaceObject=require("@bloque/sdk-accounts"),sdk_compliance_namespaceObject=require("@bloque/sdk-compliance"),sdk_identity_namespaceObject=require("@bloque/sdk-identity"),sdk_orgs_namespaceObject=require("@bloque/sdk-orgs"),sdk_swap_namespaceObject=require("@bloque/sdk-swap");class SDK{httpClient;identity;constructor(e){this.httpClient=new sdk_core_namespaceObject.HttpClient(e),this.identity=new sdk_identity_namespaceObject.IdentityClient(this.httpClient)}buildClients(e,t){return{accounts:new sdk_accounts_namespaceObject.AccountsClient(e),compliance:new sdk_compliance_namespaceObject.ComplianceClient(e),identity:new sdk_identity_namespaceObject.IdentityClient(e),orgs:new sdk_orgs_namespaceObject.OrgsClient(e),swap:new sdk_swap_namespaceObject.SwapClient(e),urn:e.urn,get accessToken(){return t}}}getOriginKey(){let{auth:e}=this.httpClient;return"originKey"===e.type?e.originKey:""}buildUrn(e){let t=this.httpClient.origin;if(!t)throw Error("Origin is required to build a urn");return`did:bloque:${t}:${e}`}requireOrigin(){let e=this.httpClient.origin;if(!e)throw Error("Origin is required for this operation");return e}buildOtpValue(e,t){let r=e.trim();return r.includes("@")?{code:t,email:r}:{code:t,phone:r}}assertJwtAuth(){if("jwt"!==this.httpClient.auth.type)throw Error("This operation is only available for JWT auth")}async assert(e,t){return this.assertJwtAuth(),await this.httpClient.request({path:`/api/origins/${e}/assert?alias=${encodeURIComponent(t)}`,method:"GET"})}async authenticate(){let{auth:e}=this.httpClient;if("jwt"!==e.type)throw Error("authenticate is only available for JWT auth");let t=await this.identity.me();return this.httpClient.setOrigin(t.origin),this.httpClient.setUrn(t.urn),this.buildClients(this.httpClient,this.httpClient.getJwtToken()??"")}async me(){return await this.identity.me()}async register(e,t){if("originKey"!==this.httpClient.auth.type)throw Error("register() is only available for originKey auth");t.extraContext||(t.extraContext={});let r=this.buildUrn(e),i=this.requireOrigin(),o=await this.identity.origins.register(e,i,{assertionResult:{alias:e,challengeType:"API_KEY",value:{apiKey:this.getOriginKey(),alias:e}},...t}),a=this.httpClient.fork();return a.setAccessToken(o.accessToken),a.setUrn(r),this.buildClients(a,o.accessToken)}async connect(e,t,r){let i=this.httpClient.auth.type;if("apiKey"===i){if("string"==typeof e)throw Error("connect() takes no alias for apiKey auth. Use connect() or connect({ scopes })");await this.httpClient.ensureExchanged();let t=this.httpClient.fork(),r=await new sdk_identity_namespaceObject.IdentityClient(t).me();return t.setOrigin(r.origin),t.setUrn(r.urn),this.buildClients(t,t.accessToken??"")}if("originKey"===i){if(!e||"string"!=typeof e)throw Error("connect(alias) is required for originKey auth");let t=this.buildUrn(e),r=this.requireOrigin(),i=await this.httpClient.request({path:`/api/origins/${r}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:this.getOriginKey(),alias:e}},extra_context:{}}}),o=this.httpClient.fork();return o.setAccessToken(i.result.access_token),o.setUrn(t),this.buildClients(o,i.result.access_token)}if(this.assertJwtAuth(),!e||"string"!=typeof e||!t||!r)throw Error("connect(origin, alias, code) is required for JWT auth");let o=await this.httpClient.request({path:`/api/origins/${e}/connect`,method:"POST",body:{assertion_result:{challengeType:"OTP",alias:t,value:this.buildOtpValue(t,r)},extra_context:{}}}),a=`did:bloque:${e}:${t}`,n=this.httpClient.fork();return n.setJwtToken(o.result.access_token),n.setOrigin(e),n.setUrn(a),this.buildClients(n,o.result.access_token)}get origins(){return{updateMetadata:e=>this.updateOriginMetadata(e)}}async updateOriginMetadata(e){let t=e.originName??this.httpClient.origin;if(!t)throw Error("origins.updateMetadata() requires originName (or configure the SDK with an origin)");let r=e.apiKey??this.resolveOwnApiKey();if(!r)throw Error("origins.updateMetadata() requires apiKey (or configure the SDK with apiKey/originKey auth)");let i={};void 0!==e.metadata.company&&(i.company=e.metadata.company),void 0!==e.metadata.tosGateShowHome&&(i.tos_gate_show_home=e.metadata.tosGateShowHome),void 0!==e.metadata.gateAccentColor&&(i.gate_accent_color=e.metadata.gateAccentColor),void 0!==e.metadata.verificationGateReturnUrlAllowlist&&(i.verification_gate_return_url_allowlist=e.metadata.verificationGateReturnUrlAllowlist);let o=await this.httpClient.request({method:"PATCH",path:`/api/origins/${t}/metadata`,body:{api_key:r,metadata:i},_skipExchange:!0});return{originName:o.origin_name,metadata:o.metadata,updated:!0}}resolveOwnApiKey(){let{auth:e}=this.httpClient;return"apiKey"===e.type?e.apiKey:"originKey"===e.type?e.originKey:void 0}}for(var __rspack_i in exports.BloqueAPIError=__webpack_exports__.BloqueAPIError,exports.BloqueAuthenticationError=__webpack_exports__.BloqueAuthenticationError,exports.BloqueConfigError=__webpack_exports__.BloqueConfigError,exports.BloqueInsufficientFundsError=__webpack_exports__.BloqueInsufficientFundsError,exports.BloqueNetworkError=__webpack_exports__.BloqueNetworkError,exports.BloqueNotFoundError=__webpack_exports__.BloqueNotFoundError,exports.BloqueRateLimitError=__webpack_exports__.BloqueRateLimitError,exports.BloqueTierLimitExceededError=__webpack_exports__.BloqueTierLimitExceededError,exports.BloqueTimeoutError=__webpack_exports__.BloqueTimeoutError,exports.BloqueValidationError=__webpack_exports__.BloqueValidationError,exports.BloqueVerificationPendingError=__webpack_exports__.BloqueVerificationPendingError,exports.BloqueVerificationRequiredError=__webpack_exports__.BloqueVerificationRequiredError,exports.SDK=__webpack_exports__.SDK,__webpack_exports__)-1===["BloqueAPIError","BloqueAuthenticationError","BloqueConfigError","BloqueInsufficientFundsError","BloqueNetworkError","BloqueNotFoundError","BloqueRateLimitError","BloqueTierLimitExceededError","BloqueTimeoutError","BloqueValidationError","BloqueVerificationPendingError","BloqueVerificationRequiredError","SDK"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export type * from '@bloque/sdk-identity';
|
|
|
7
7
|
export type * from '@bloque/sdk-orgs';
|
|
8
8
|
export type * from '@bloque/sdk-swap';
|
|
9
9
|
export type { BrebClient as SwapBrebClient, ExternalUsBankSwapClient, } from '@bloque/sdk-swap';
|
|
10
|
-
export type { BloqueClients, UpdateOriginMetadataOptions } from './bloque';
|
|
10
|
+
export type { BloqueClients, OriginMetadataPatch, UpdateOriginMetadataOptions, UpdateOriginMetadataResult, } from './bloque';
|
|
11
11
|
export { SDK } from './bloque';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BloqueAPIError as t,BloqueAuthenticationError as e,BloqueConfigError as i,BloqueInsufficientFundsError as r,BloqueNetworkError as n,BloqueNotFoundError as o,BloqueRateLimitError as
|
|
1
|
+
import{BloqueAPIError as t,BloqueAuthenticationError as e,BloqueConfigError as i,BloqueInsufficientFundsError as r,BloqueNetworkError as n,BloqueNotFoundError as o,BloqueRateLimitError as a,BloqueTierLimitExceededError as s,BloqueTimeoutError as l,BloqueValidationError as h,BloqueVerificationPendingError as u,BloqueVerificationRequiredError as c,HttpClient as p}from"@bloque/sdk-core";import{AccountsClient as d}from"@bloque/sdk-accounts";import{ComplianceClient as g}from"@bloque/sdk-compliance";import{IdentityClient as y}from"@bloque/sdk-identity";import{OrgsClient as m}from"@bloque/sdk-orgs";import{SwapClient as w}from"@bloque/sdk-swap";class f{httpClient;identity;constructor(t){this.httpClient=new p(t),this.identity=new y(this.httpClient)}buildClients(t,e){return{accounts:new d(t),compliance:new g(t),identity:new y(t),orgs:new m(t),swap:new w(t),urn:t.urn,get accessToken(){return e}}}getOriginKey(){let{auth:t}=this.httpClient;return"originKey"===t.type?t.originKey:""}buildUrn(t){let e=this.httpClient.origin;if(!e)throw Error("Origin is required to build a urn");return`did:bloque:${e}:${t}`}requireOrigin(){let t=this.httpClient.origin;if(!t)throw Error("Origin is required for this operation");return t}buildOtpValue(t,e){let i=t.trim();return i.includes("@")?{code:e,email:i}:{code:e,phone:i}}assertJwtAuth(){if("jwt"!==this.httpClient.auth.type)throw Error("This operation is only available for JWT auth")}async assert(t,e){return this.assertJwtAuth(),await this.httpClient.request({path:`/api/origins/${t}/assert?alias=${encodeURIComponent(e)}`,method:"GET"})}async authenticate(){let{auth:t}=this.httpClient;if("jwt"!==t.type)throw Error("authenticate is only available for JWT auth");let e=await this.identity.me();return this.httpClient.setOrigin(e.origin),this.httpClient.setUrn(e.urn),this.buildClients(this.httpClient,this.httpClient.getJwtToken()??"")}async me(){return await this.identity.me()}async register(t,e){if("originKey"!==this.httpClient.auth.type)throw Error("register() is only available for originKey auth");e.extraContext||(e.extraContext={});let i=this.buildUrn(t),r=this.requireOrigin(),n=await this.identity.origins.register(t,r,{assertionResult:{alias:t,challengeType:"API_KEY",value:{apiKey:this.getOriginKey(),alias:t}},...e}),o=this.httpClient.fork();return o.setAccessToken(n.accessToken),o.setUrn(i),this.buildClients(o,n.accessToken)}async connect(t,e,i){let r=this.httpClient.auth.type;if("apiKey"===r){if("string"==typeof t)throw Error("connect() takes no alias for apiKey auth. Use connect() or connect({ scopes })");await this.httpClient.ensureExchanged();let e=this.httpClient.fork(),i=await new y(e).me();return e.setOrigin(i.origin),e.setUrn(i.urn),this.buildClients(e,e.accessToken??"")}if("originKey"===r){if(!t||"string"!=typeof t)throw Error("connect(alias) is required for originKey auth");let e=this.buildUrn(t),i=this.requireOrigin(),r=await this.httpClient.request({path:`/api/origins/${i}/connect`,method:"POST",body:{assertion_result:{challengeType:"API_KEY",value:{api_key:this.getOriginKey(),alias:t}},extra_context:{}}}),n=this.httpClient.fork();return n.setAccessToken(r.result.access_token),n.setUrn(e),this.buildClients(n,r.result.access_token)}if(this.assertJwtAuth(),!t||"string"!=typeof t||!e||!i)throw Error("connect(origin, alias, code) is required for JWT auth");let n=await this.httpClient.request({path:`/api/origins/${t}/connect`,method:"POST",body:{assertion_result:{challengeType:"OTP",alias:e,value:this.buildOtpValue(e,i)},extra_context:{}}}),o=`did:bloque:${t}:${e}`,a=this.httpClient.fork();return a.setJwtToken(n.result.access_token),a.setOrigin(t),a.setUrn(o),this.buildClients(a,n.result.access_token)}get origins(){return{updateMetadata:t=>this.updateOriginMetadata(t)}}async updateOriginMetadata(t){let e=t.originName??this.httpClient.origin;if(!e)throw Error("origins.updateMetadata() requires originName (or configure the SDK with an origin)");let i=t.apiKey??this.resolveOwnApiKey();if(!i)throw Error("origins.updateMetadata() requires apiKey (or configure the SDK with apiKey/originKey auth)");let r={};void 0!==t.metadata.company&&(r.company=t.metadata.company),void 0!==t.metadata.tosGateShowHome&&(r.tos_gate_show_home=t.metadata.tosGateShowHome),void 0!==t.metadata.gateAccentColor&&(r.gate_accent_color=t.metadata.gateAccentColor),void 0!==t.metadata.verificationGateReturnUrlAllowlist&&(r.verification_gate_return_url_allowlist=t.metadata.verificationGateReturnUrlAllowlist);let n=await this.httpClient.request({method:"PATCH",path:`/api/origins/${e}/metadata`,body:{api_key:i,metadata:r},_skipExchange:!0});return{originName:n.origin_name,metadata:n.metadata,updated:!0}}resolveOwnApiKey(){let{auth:t}=this.httpClient;return"apiKey"===t.type?t.apiKey:"originKey"===t.type?t.originKey:void 0}}export{t as BloqueAPIError,e as BloqueAuthenticationError,i as BloqueConfigError,r as BloqueInsufficientFundsError,n as BloqueNetworkError,o as BloqueNotFoundError,a as BloqueRateLimitError,s as BloqueTierLimitExceededError,l as BloqueTimeoutError,h as BloqueValidationError,u as BloqueVerificationPendingError,c as BloqueVerificationRequiredError,f as SDK};
|