@bloque/sdk 0.0.40 → 0.0.42
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/index.cjs +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/package.json +7 -7
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
|
|
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,BloqueValidationError:()=>sdk_core_namespaceObject.BloqueValidationError,SDK:()=>SDK,BloqueNotFoundError:()=>sdk_core_namespaceObject.BloqueNotFoundError,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){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),swap:new sdk_swap_namespaceObject.SwapClient(this.httpClient),urn:this.httpClient.urn,get accessToken(){return e}}}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}`}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=this.httpClient.getJwtToken();if(!t?.trim())throw Error("Authentication token is missing in tokenStorage");this.httpClient.setJwtToken(t);let r=await this.identity.me();return this.httpClient.setOrigin(r.origin),this.httpClient.setUrn(r.urn),this.buildClients(t)}async me(){return await this.identity.me()}async register(e,t){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.getApiKey(),alias:e}},...t});return this.httpClient.setAccessToken(o.accessToken),this.httpClient.setUrn(r),this.buildClients(o.accessToken)}async connect(e,t,r){if("apiKey"===this.httpClient.auth.type){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.getApiKey(),alias:e}},extra_context:{}}});return this.httpClient.setAccessToken(i.result.access_token),this.httpClient.setUrn(t),this.buildClients(i.result.access_token)}if(this.assertJwtAuth(),!t||!r)throw Error("JWT connect requires origin and OTP code. Use connect(origin, alias, code)");let i=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:{}}}),o=`did:bloque:${e}:${t}`;return this.httpClient.setJwtToken(i.result.access_token),this.httpClient.setOrigin(e),this.httpClient.setUrn(o),this.buildClients(i.result.access_token)}}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.BloqueTimeoutError=__webpack_exports__.BloqueTimeoutError,exports.BloqueValidationError=__webpack_exports__.BloqueValidationError,exports.SDK=__webpack_exports__.SDK,__webpack_exports__)-1===["BloqueAPIError","BloqueAuthenticationError","BloqueConfigError","BloqueInsufficientFundsError","BloqueNetworkError","BloqueNotFoundError","BloqueRateLimitError","BloqueTimeoutError","BloqueValidationError","SDK"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
export type * from '@bloque/sdk-accounts';
|
|
2
|
+
export type * from '@bloque/sdk-compliance';
|
|
1
3
|
export type { BloqueSDKConfig } from '@bloque/sdk-core';
|
|
4
|
+
export { BloqueAPIError, BloqueAuthenticationError, BloqueConfigError, BloqueInsufficientFundsError, BloqueNetworkError, BloqueNotFoundError, BloqueRateLimitError, BloqueTimeoutError, BloqueValidationError, } from '@bloque/sdk-core';
|
|
5
|
+
export type * from '@bloque/sdk-identity';
|
|
6
|
+
export type * from '@bloque/sdk-orgs';
|
|
7
|
+
export type * from '@bloque/sdk-swap';
|
|
2
8
|
export { SDK } from './bloque';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{BloqueAPIError as t,BloqueAuthenticationError as e,BloqueConfigError as i,BloqueInsufficientFundsError as r,BloqueNetworkError as n,BloqueNotFoundError as s,BloqueRateLimitError as o,BloqueTimeoutError as l,BloqueValidationError as h,HttpClient as a}from"@bloque/sdk-core";import{AccountsClient as u}from"@bloque/sdk-accounts";import{ComplianceClient as p}from"@bloque/sdk-compliance";import{IdentityClient as c}from"@bloque/sdk-identity";import{OrgsClient as d}from"@bloque/sdk-orgs";import{SwapClient as C}from"@bloque/sdk-swap";class y{httpClient;identity;constructor(t){this.httpClient=new a(t),this.identity=new c(this.httpClient)}buildClients(t){return{accounts:new u(this.httpClient),compliance:new p(this.httpClient),identity:this.identity,orgs:new d(this.httpClient),swap:new C(this.httpClient),urn:this.httpClient.urn,get accessToken(){return t}}}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}`}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=this.httpClient.getJwtToken();if(!e?.trim())throw Error("Authentication token is missing in tokenStorage");this.httpClient.setJwtToken(e);let i=await this.identity.me();return this.httpClient.setOrigin(i.origin),this.httpClient.setUrn(i.urn),this.buildClients(e)}async me(){return await this.identity.me()}async register(t,e){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.getApiKey(),alias:t}},...e});return this.httpClient.setAccessToken(n.accessToken),this.httpClient.setUrn(i),this.buildClients(n.accessToken)}async connect(t,e,i){if("apiKey"===this.httpClient.auth.type){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.getApiKey(),alias:t}},extra_context:{}}});return this.httpClient.setAccessToken(r.result.access_token),this.httpClient.setUrn(e),this.buildClients(r.result.access_token)}if(this.assertJwtAuth(),!e||!i)throw Error("JWT connect requires origin and OTP code. Use connect(origin, alias, code)");let r=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:{}}}),n=`did:bloque:${t}:${e}`;return this.httpClient.setJwtToken(r.result.access_token),this.httpClient.setOrigin(t),this.httpClient.setUrn(n),this.buildClients(r.result.access_token)}}export{t as BloqueAPIError,e as BloqueAuthenticationError,i as BloqueConfigError,r as BloqueInsufficientFundsError,n as BloqueNetworkError,s as BloqueNotFoundError,o as BloqueRateLimitError,l as BloqueTimeoutError,h as BloqueValidationError,y as SDK};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloque/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"description": "Official Bloque SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"node": ">=22"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@bloque/sdk-accounts": "0.0.
|
|
72
|
-
"@bloque/sdk-compliance": "0.0.
|
|
73
|
-
"@bloque/sdk-core": "0.0.
|
|
74
|
-
"@bloque/sdk-identity": "0.0.
|
|
75
|
-
"@bloque/sdk-orgs": "0.0.
|
|
76
|
-
"@bloque/sdk-swap": "0.0.
|
|
71
|
+
"@bloque/sdk-accounts": "0.0.42",
|
|
72
|
+
"@bloque/sdk-compliance": "0.0.42",
|
|
73
|
+
"@bloque/sdk-core": "0.0.42",
|
|
74
|
+
"@bloque/sdk-identity": "0.0.42",
|
|
75
|
+
"@bloque/sdk-orgs": "0.0.42",
|
|
76
|
+
"@bloque/sdk-swap": "0.0.42"
|
|
77
77
|
}
|
|
78
78
|
}
|