@mbanq/core-sdk-js 0.23.0 → 0.25.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/{chunk-ARR7PVSU.js → chunk-EM7SKZCN.js} +1 -1
- package/dist/{chunk-5SFHDAQT.mjs → chunk-ZUBUHVOU.mjs} +1 -1
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/commands/index.d.mts +2163 -2
- package/dist/commands/index.d.ts +2163 -2
- package/dist/commands/index.js +2 -2
- package/dist/commands/index.mjs +2 -2
- package/dist/{config.d-3z0BBs0n.d.mts → config.d-BSoFrdxi.d.mts} +0 -2
- package/dist/{config.d-3z0BBs0n.d.ts → config.d-BSoFrdxi.d.ts} +0 -2
- package/dist/{error.d-b8v9_A6B.d.ts → error.d-Cn1_ZmBN.d.ts} +1 -1
- package/dist/{error.d-Dxib52uQ.d.mts → error.d-aUq9Boe9.d.mts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/types/types.d.mts +2 -2
- package/dist/types/types.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk6M772WIBjs = require('./chunk-6M772WIB.js');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk6M772WIBjs = require('./chunk-6M772WIB.js');var k=r=>{let s=[];if(!r.baseUrl)s.push("baseUrl is required");else if(typeof r.baseUrl!="string")s.push("baseUrl must be a string");else try{new URL(r.baseUrl)}catch (e2){s.push("baseUrl must be a valid URL")}return _optionalChain([r, 'access', _ => _.axiosConfig, 'optionalAccess', _2 => _2.timeout])!==void 0&&(typeof r.axiosConfig.timeout!="number"||r.axiosConfig.timeout<0)&&s.push("timeout must be a positive number"),s};var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);var _jsonwebtoken = require('jsonwebtoken'); var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken);var m=(r,s)=>{if(!r)throw _chunk6M772WIBjs.a.call(void 0, {message:"Missing JWT secret",code:"missing_jwt_secret"});return _jsonwebtoken2.default.sign({signee:s},r,{algorithm:"HS512",expiresIn:"1d"})||""},w=async(r,s,a)=>{let o={method:"POST",url:`${r}/oauth/token`,headers:{"Content-Type":"application/x-www-form-urlencoded",tenantId:s},data:a},{data:{access_token:c}}=await _axios2.default.request(o);return c};var O=r=>{let s=k(r);if(s.length>0)throw _chunk6M772WIBjs.a.call(void 0, {message:`Invalid configuration: ${s.join(", ")}`,code:"invalid_config"});let a=r,o={accessToken:"",tokenType:"bearer",authConfig:null},c=async(e,t,n)=>{if(a.middlewares)for(let i of a.middlewares)e==="before"&&i.before?await i.before(t):e==="after"&&i.after?await i.after(t,n):e==="onError"&&i.onError&&await i.onError(t,n)},f=e=>{let t={...e,[o.tokenType==="jwt"?"jwtToken":"bearerToken"]:o.accessToken};return _optionalChain([o, 'access', _3 => _3.authConfig, 'optionalAccess', _4 => _4.tenantId])&&(t.tenantId=o.authConfig.tenantId),t},d=(e,t)=>t?{...e,axiosConfig:{...e.axiosConfig,...t.timeout&&{timeout:t.timeout},...t.keepAlive!==void 0&&{keepAlive:t.keepAlive},headers:{..._optionalChain([e, 'access', _5 => _5.axiosConfig, 'optionalAccess', _6 => _6.headers]),...t.headers}}}:e,l=async e=>{if(e.credential){let t=e.tenantId||a.tenantId;if(!t)throw _chunk6M772WIBjs.a.call(void 0, {message:"Tenant ID is required when using credential-based authentication",code:"missing_tenant_id"});return{token:await w(a.baseUrl,t,e.credential),type:"bearer"}}else{if(e.signee&&e.secret)return{token:m(e.secret,e.signee||""),type:"jwt"};if(e.bearerToken)return{token:e.bearerToken,type:"bearer"};if(e.jwtToken)return{token:e.jwtToken,type:"jwt"};throw _chunk6M772WIBjs.a.call(void 0, {message:"No valid authentication method provided in config",code:"missing_authentication"})}};return{connect:async e=>{let{token:t,type:n}=await l(e);o.accessToken=t,o.tokenType=n,o.authConfig=e},request:async(e,t)=>{try{if(await c("before",e),!o.accessToken)throw _chunk6M772WIBjs.a.call(void 0, {message:"No authentication token found. Please await instance.connect() first.",code:"missing_authentication"});let n=d(a,t);n=f(n);try{let i=await e.execute(n);return await c("after",e,i),i}catch(i){if(_chunk6M772WIBjs.b.call(void 0, i)&&i.statusCode===401&&o.authConfig){let{token:T,type:h}=await l(o.authConfig);o.accessToken=T,o.tokenType=h,n=d(a,t),n=f(n);let g=await e.execute(n);return await c("after",e,g),g}else throw await c("onError",e,i),i}}catch(n){throw await c("onError",e,n),n}}}};exports.a = O;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as u,b as p}from"./chunk-2PLZ534I.mjs";var
|
|
1
|
+
import{a as u,b as p}from"./chunk-2PLZ534I.mjs";var k=r=>{let s=[];if(!r.baseUrl)s.push("baseUrl is required");else if(typeof r.baseUrl!="string")s.push("baseUrl must be a string");else try{new URL(r.baseUrl)}catch{s.push("baseUrl must be a valid URL")}return r.axiosConfig?.timeout!==void 0&&(typeof r.axiosConfig.timeout!="number"||r.axiosConfig.timeout<0)&&s.push("timeout must be a positive number"),s};import C from"axios";import b from"jsonwebtoken";var m=(r,s)=>{if(!r)throw u({message:"Missing JWT secret",code:"missing_jwt_secret"});return b.sign({signee:s},r,{algorithm:"HS512",expiresIn:"1d"})||""},w=async(r,s,a)=>{let o={method:"POST",url:`${r}/oauth/token`,headers:{"Content-Type":"application/x-www-form-urlencoded",tenantId:s},data:a},{data:{access_token:c}}=await C.request(o);return c};var O=r=>{let s=k(r);if(s.length>0)throw u({message:`Invalid configuration: ${s.join(", ")}`,code:"invalid_config"});let a=r,o={accessToken:"",tokenType:"bearer",authConfig:null},c=async(e,t,n)=>{if(a.middlewares)for(let i of a.middlewares)e==="before"&&i.before?await i.before(t):e==="after"&&i.after?await i.after(t,n):e==="onError"&&i.onError&&await i.onError(t,n)},f=e=>{let t={...e,[o.tokenType==="jwt"?"jwtToken":"bearerToken"]:o.accessToken};return o.authConfig?.tenantId&&(t.tenantId=o.authConfig.tenantId),t},d=(e,t)=>t?{...e,axiosConfig:{...e.axiosConfig,...t.timeout&&{timeout:t.timeout},...t.keepAlive!==void 0&&{keepAlive:t.keepAlive},headers:{...e.axiosConfig?.headers,...t.headers}}}:e,l=async e=>{if(e.credential){let t=e.tenantId||a.tenantId;if(!t)throw u({message:"Tenant ID is required when using credential-based authentication",code:"missing_tenant_id"});return{token:await w(a.baseUrl,t,e.credential),type:"bearer"}}else{if(e.signee&&e.secret)return{token:m(e.secret,e.signee||""),type:"jwt"};if(e.bearerToken)return{token:e.bearerToken,type:"bearer"};if(e.jwtToken)return{token:e.jwtToken,type:"jwt"};throw u({message:"No valid authentication method provided in config",code:"missing_authentication"})}};return{connect:async e=>{let{token:t,type:n}=await l(e);o.accessToken=t,o.tokenType=n,o.authConfig=e},request:async(e,t)=>{try{if(await c("before",e),!o.accessToken)throw u({message:"No authentication token found. Please await instance.connect() first.",code:"missing_authentication"});let n=d(a,t);n=f(n);try{let i=await e.execute(n);return await c("after",e,i),i}catch(i){if(p(i)&&i.statusCode===401&&o.authConfig){let{token:T,type:h}=await l(o.authConfig);o.accessToken=T,o.tokenType=h,n=d(a,t),n=f(n);let g=await e.execute(n);return await c("after",e,g),g}else throw await c("onError",e,i),i}}catch(n){throw await c("onError",e,n),n}}}};export{O as a};
|
package/dist/client/index.d.mts
CHANGED
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEM7SKZCNjs = require('../chunk-EM7SKZCN.js');require('../chunk-6M772WIB.js');exports.createInstance = _chunkEM7SKZCNjs.a;
|
package/dist/client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-ZUBUHVOU.mjs";import"../chunk-2PLZ534I.mjs";export{a as createInstance};
|