UNPKG

bkash

Version:

bKash API client for Browser & Node.js

13 lines 24.3 kB
var BKash=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=31)}([function(e){e.exports={baseUrl:{pay:"https://direct.pay.bka.sh/v1.1.0-beta",sandbox:"https://direct.sandbox.bka.sh/v1.1.0-beta"},title:"bKash Payments API",version:"1.1.0-beta"}},function(e){e.exports={baseUrl:{pay:"https://checkout.pay.bka.sh/v1.1.0-beta",sandbox:"https://checkout.sandbox.bka.sh/v1.1.0-beta"},title:"bKash Checkout API",version:"1.1.0-beta"}},function(e,t){e.exports=class extends Error{constructor(e,t,r){super(Array.isArray(e)?e.join(", "):e),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.meta=t,this.headers=r}}},function(e,t,r){const n=r(26),o=e=>n(e)||Array.isArray(e),a=e=>o(e)?s((e=>Array.isArray(e)?[]:{})(e),e):e,s=(e,t)=>{let r=Array.isArray(t);return r===Array.isArray(e)?r?((e,t)=>e.concat(t).map(e=>a(e)))(e,t):((e,t)=>{let r={};return o(e)&&Object.keys(e).forEach(t=>{r[t]=a(e[t])}),Object.keys(t).forEach(n=>{o(t[n])&&e[n]?r[n]=s(e[n],t[n]):r[n]=a(t[n])}),r})(e,t):a(t)};e.exports=s},function(e){e.exports={name:"bkash",version:"0.2.2",description:"bKash API client for Browser & Node.js",keywords:["bkash","api-client"],homepage:"https://github.com/MunifTanjim/node-bkash#readme",bugs:"https://github.com/MunifTanjim/node-bkash/issues",license:"MIT",author:"MunifTanjim (https://muniftanjim.com)",files:["index.js","libs","dist/*.js"],main:"index.js",repository:"github:MunifTanjim/node-bkash",scripts:{build:"npm-run-all build:*","prebuild:browser":"mkdirp dist/","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development","build:browser:production":"webpack --mode production --output-filename=bkash.min.js","generate:routes":"node scripts/generate-routes.js",publish:"npm run build && npm publish"},dependencies:{"before-after-hook":"^1.1.0","is-plain-object":"^2.0.4","node-fetch":"^2.1.2","url-template":"^2.0.8"},devDependencies:{"clean-deep":"^3.0.2",debug:"^3.1.0","deep-sort-object":"^1.0.2",mkdirp:"^0.5.1","npm-run-all":"^4.1.3",webpack:"^4.8.3","webpack-cli":"^2.1.3"}}},function(e){e.exports=[{method:"POST",name:"createMandate",params:{amount:{type:"string"},currency:{type:"string"},endRangeOfDays:{type:"string"},expiryDate:{type:"string"},firstPaymentDate:{required:!0,type:"string"},frequency:{required:!0,type:"string"},intent:{type:"string"},merchantInvoiceNumber:{type:"string"},payerReferenceNumber:{required:!0,type:"string"},requestType:{required:!0,type:"string"},startRangeOfDays:{type:"string"}},url:"/payments/mandate/create"},{method:"POST",name:"executeMandate",params:{paymentID:{required:!0,type:"string"}},url:"/payments/mandate/execute/{paymentID}"},{method:"GET",name:"queryMandate",params:{mandateID:{required:!0,type:"string"}},url:"/payments/mandate/query/{mandateID}"},{method:"POST",name:"cancelMandate",params:{mandateID:{required:!0,type:"string"}},url:"/payments/mandate/cancel/{mandateID}"},{method:"POST",name:"createPayment",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},intent:{required:!0,type:"string"},merchantInvoiceNumber:{required:!0,type:"string"}},url:"/checkout/payment/create"},{method:"POST",name:"capturePayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/capture/{paymentID}"},{method:"POST",name:"executePayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/execute/{paymentID}"},{method:"GET",name:"queryPayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/query/{paymentID}"},{method:"POST",name:"voidPayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/void/{paymentID}"},{method:"POST",name:"directDebit",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},intent:{required:!0,type:"string"},mandateID:{required:!0,type:"string"},merchantInvoiceNumber:{required:!0,type:"string"},payerReferenceNumber:{required:!0,type:"string"}},url:"/payments/payment/mandate/{mandateID}"},{method:"POST",name:"directDebitCapture",params:{paymentID:{required:!0,type:"string"}},url:"/payments/payment/capture/{paymentID}"},{method:"GET",name:"queryAuthorizationPayment",params:{paymentID:{required:!0,type:"string"}},url:"/payments/payment/query/{paymentID}"},{method:"POST",name:"cancelPayment",params:{paymentID:{required:!0,type:"string"}},url:"/payments/payment/void/{paymentID}"},{method:"POST",name:"b2cPayment",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},merchantInvoiceNumber:{required:!0,type:"string"},receiverMSISDN:{required:!0,type:"string"}},url:"/payments/payment/b2cPayment"},{method:"GET",name:"queryOrganizationBalance",params:{},url:"/payments/payment/organizationBalance"},{method:"POST",name:"intraAccountTransfer",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},transferType:{required:!0,type:"string"}},url:"/payments/payment/intraAccountTransfer"},{method:"GET",name:"searchTransaction",params:{trxID:{required:!0,type:"string"}},url:"/payments/payment/search/{trxID}"},{method:"POST",name:"refundTransaction",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},trxID:{required:!0,type:"string"}},url:"/payments/payment/refund/{trxID}"},{method:"POST",name:"getToken",params:{app_key:{required:!0,type:"string"},app_secret:{required:!0,type:"string"}},url:"/payments/token/grant"},{method:"POST",name:"refreshToken",params:{app_key:{required:!0,type:"string"},app_secret:{required:!0,type:"string"},refresh_token:{required:!0,type:"string"}},url:"/payments/token/refresh"}]},function(e){e.exports=[{method:"POST",name:"createPayment",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},intent:{required:!0,type:"string"},merchantAssociationInfo:{type:"string"},merchantInvoiceNumber:{required:!0,type:"string"}},url:"/checkout/payment/create"},{method:"POST",name:"executePayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/execute/{paymentID}"},{method:"POST",name:"capturePayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/capture/{paymentID}"},{method:"GET",name:"queryPayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/query/{paymentID}"},{method:"POST",name:"voidPayment",params:{paymentID:{required:!0,type:"string"}},url:"/checkout/payment/void/{paymentID}"},{method:"POST",name:"b2cPayment",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},merchantInvoiceNumber:{required:!0,type:"string"},receiverMSISDN:{required:!0,type:"string"}},url:"/checkout/payment/b2cPayment"},{method:"GET",name:"queryOrganizationBalance",params:{},url:"/checkout/payment/organizationBalance"},{method:"POST",name:"intraAccountTransfer",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},transferType:{required:!0,type:"string"}},url:"/checkout/payment/intraAccountTransfer"},{method:"GET",name:"searchTransaction",params:{trxID:{required:!0,type:"string"}},url:"/checkout/payment/search/{trxID}"},{method:"POST",name:"refundTransaction",params:{amount:{required:!0,type:"string"},currency:{required:!0,type:"string"},trxID:{required:!0,type:"string"}},url:"/checkout/payment/refund/{trxID}"},{method:"POST",name:"getToken",params:{app_key:{required:!0,type:"string"},app_secret:{required:!0,type:"string"}},url:"/checkout/token/grant"},{method:"POST",name:"refreshToken",params:{app_key:{required:!0,type:"string"},app_secret:{required:!0,type:"string"},refresh_token:{required:!0,type:"string"}},url:"/checkout/token/refresh"}]},function(e,t,r){var n={"./checkout-1.1.0-beta-info.json":1,"./checkout-1.1.0-beta.json":6,"./payments-1.1.0-beta-info.json":0,"./payments-1.1.0-beta.json":5};function o(e){var t=a(e);return r(t)}function a(e){var t=n[e];if(!(t+1)){var r=new Error('Cannot find module "'+e+'".');throw r.code="MODULE_NOT_FOUND",r}return t}o.keys=function(){return Object.keys(n)},o.resolve=a,e.exports=o,o.id=7},function(e,t,r){var n={"./checkout-1.1.0-beta-info.json":1,"./payments-1.1.0-beta-info.json":0};function o(e){var t=a(e);return r(t)}function a(e){var t=n[e];if(!(t+1)){var r=new Error('Cannot find module "'+e+'".');throw r.code="MODULE_NOT_FOUND",r}return t}o.keys=function(){return Object.keys(n)},o.resolve=a,e.exports=o,o.id=8},function(e,t,r){const n=r(2);e.exports=((e={},t)=>(Object.entries(e).forEach(([e,r])=>{const o=void 0!==t[e];if((r.required||o)&&r.required&&!o)throw new n(`Parameter required: ${paramKey}`,{status:400})}),t))},function(e,t,r){const n=r(3),o=r(9);e.exports=((e,t,r,a={},s)=>{const i=n(t,a),u=Promise.resolve(i).then(e=>o(r,e)).then(e.request);if(!s)return u;u.then(e=>s(null,e)).catch(s)})},function(e,t,r){const n=r(10);e.exports=class{constructor(e){this.core=e;const{mode:t,type:n,version:o}=this.core;this.baseUrl=r(8)(`./${n}-${o}-info.json`).baseUrl[t],this.endpoints=r(7)(`./${n}-${o}.json`)}inject(){Object.keys(this.endpoints).forEach(e=>{const{name:t,method:r,params:o,url:a}=e;this.core[t]=n.bind(null,this.core,{baseUrl:this.baseUrl,method:r,url:a},o)})}}},function(e,t){e.exports=((e,t)=>{if(e.auth)switch(e.auth.type){case"simple":t.headers.username=e.auth.username,t.headers.password=e.auth.password;break;case"token":t.headers.authorization=e.auth.token,t.headers["x-app-key"]=e.auth.appkey}})},function(e,t){e.exports=((e,t={})=>{if(t.type){switch(t.type){case"simple":if(!t.username||!t.password)throw new Error("Simple authentication requires both `username` and `password` to be set");break;case"token":if(!t.token||!t.appkey)throw new Error("Token authentication requires both `token` and `appkey` to be set");break;default:throw new Error("Invalid authentication type, must be `simple` or `token`")}e.auth=t}else e.auth=!1})},function(e,t,r){const n=r(13),o=r(12);e.exports=class{constructor(e){this.core=e,this.state={auth:!1}}inject(){this.core.authenticate=n.bind(null,this.state),this.core.hook.before("request",o.bind(null,this.state))}}},function(e,t){const r=/\{[^}]+\}/g,n=e=>e.replace(/^\W+|\W+$/g,"");e.exports=(e=>{let t=e.match(r);return t?t.map(n):[]})},function(e,t,r){e.exports=function(){function e(){}return e.prototype.encodeReserved=function(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(e){return/%[0-9A-Fa-f]/.test(e)||(e=encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]")),e}).join("")},e.prototype.encodeUnreserved=function(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})},e.prototype.encodeValue=function(e,t,r){return t="+"===e||"#"===e?this.encodeReserved(t):this.encodeUnreserved(t),r?this.encodeUnreserved(r)+"="+t:t},e.prototype.isDefined=function(e){return void 0!==e&&null!==e},e.prototype.isKeyOperator=function(e){return";"===e||"&"===e||"?"===e},e.prototype.getValues=function(e,t,r,n){var o=e[r],a=[];if(this.isDefined(o)&&""!==o)if("string"==typeof o||"number"==typeof o||"boolean"==typeof o)o=o.toString(),n&&"*"!==n&&(o=o.substring(0,parseInt(n,10))),a.push(this.encodeValue(t,o,this.isKeyOperator(t)?r:null));else if("*"===n)Array.isArray(o)?o.filter(this.isDefined).forEach(function(e){a.push(this.encodeValue(t,e,this.isKeyOperator(t)?r:null))},this):Object.keys(o).forEach(function(e){this.isDefined(o[e])&&a.push(this.encodeValue(t,o[e],e))},this);else{var s=[];Array.isArray(o)?o.filter(this.isDefined).forEach(function(e){s.push(this.encodeValue(t,e))},this):Object.keys(o).forEach(function(e){this.isDefined(o[e])&&(s.push(this.encodeUnreserved(e)),s.push(this.encodeValue(t,o[e].toString())))},this),this.isKeyOperator(t)?a.push(this.encodeUnreserved(r)+"="+s.join(",")):0!==s.length&&a.push(s.join(","))}else";"===t?this.isDefined(o)&&a.push(this.encodeUnreserved(r)):""!==o||"&"!==t&&"?"!==t?""===o&&a.push(""):a.push(this.encodeUnreserved(r)+"=");return a},e.prototype.parse=function(e){var t=this,r=["+","#",".","/",";","?","&"];return{expand:function(n){return e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(e,o,a){if(o){var s=null,i=[];if(-1!==r.indexOf(o.charAt(0))&&(s=o.charAt(0),o=o.substr(1)),o.split(/,/g).forEach(function(e){var r=/([^:\*]*)(?::(\d+)|(\*))?/.exec(e);i.push.apply(i,t.getValues(n,s,r[1],r[2]||r[3]))}),s&&"+"!==s){var u=",";return"?"===s?u="&":"#"!==s&&(u=s),(0!==i.length?s:"")+i.join(u)}return i.join(",")}return t.encodeReserved(a)})}}},new e}()},function(e,t,r){const n=r(16),o=r(15);e.exports=(e=>{let{baseUrl:t,body:r,headers:a,method:s,url:i,options:u,...c}=e;i=i.replace(/\{([a-z]\w+)\}/gi,"{+$1}");const p=o(i);return i=n.parse(i).expand(c),/^http/.test(i)||(i=`${t}${i}`),p.forEach(e=>{delete c[e]}),Object.keys(c).length&&!["GET","HEAD"].includes(s.toUpperCase())&&(r=JSON.stringify(c)),{...u,method:s,url:i,headers:a,body:r}})},function(e,t){var r=1e3,n=60*r,o=60*n,a=24*o,s=365.25*a;function i(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}e.exports=function(e,t){t=t||{};var u,c=typeof e;if("string"===c&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var i=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return i*s;case"days":case"day":case"d":return i*a;case"hours":case"hour":case"hrs":case"hr":case"h":return i*o;case"minutes":case"minute":case"mins":case"min":case"m":return i*n;case"seconds":case"second":case"secs":case"sec":case"s":return i*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return i;default:return}}(e);if("number"===c&&!1===isNaN(e))return t.long?i(u=e,a,"day")||i(u,o,"hour")||i(u,n,"minute")||i(u,r,"second")||u+" ms":function(e){if(e>=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){function n(e){var r;function n(){if(n.enabled){var e=n,o=+new Date,a=o-(r||o);e.diff=a,e.prev=r,e.curr=o,r=o;for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var u=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(r,n){if("%%"===r)return r;u++;var o=t.formatters[n];if("function"==typeof o){var a=s[u];r=o.call(e,a),s.splice(u,1),u--}return r}),t.formatArgs.call(e,s),(n.log||t.log||console.log.bind(console)).apply(e,s)}}return n.namespace=e,n.enabled=t.enabled(e),n.useColors=t.useColors(),n.color=function(e){var r,n=0;for(r in e)n=(n<<5)-n+e.charCodeAt(r),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),n.destroy=o,"function"==typeof t.init&&t.init(n),t.instances.push(n),n}function o(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var r;t.save(e),t.names=[],t.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(r=0;r<o;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(r=0;r<t.instances.length;r++){var a=t.instances[r];a.enabled=t.enabled(a.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(18),t.instances=[],t.names=[],t.skips=[],t.formatters={}},function(e,t){var r,n,o=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function i(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var u,c=[],p=!1,d=-1;function m(){p&&u&&(p=!1,u.length?c=u.concat(c):d=-1,c.length&&h())}function h(){if(!p){var e=i(m);p=!0;for(var t=c.length;t;){for(u=c,c=[];++d<t;)u&&u[d].run();d=-1,t=c.length}u=null,p=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function y(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new f(e,t)),1!==c.length||p||i(h)},f.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){(function(n){function o(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(19)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,a=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(a=++o)}),e.splice(a,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=o,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(o())}).call(this,r(20))},function(e,t){e.exports=t=window.fetch,t.default=window.fetch.bind(window),t.Headers=window.Headers,t.Request=window.Request,t.Response=window.Response},function(e,t,r){const n=r(22),o=r(21)("bKash"),a=r(2),s=e=>{const t={headers:{},meta:{}};for(let[r,n]of e.headers.entries())t.headers[r]=n;return t.meta.status=e.status,204===e.status?t:(e=>{const t=e.headers.get("content-type");return/application\/json/.test(t)?e.json():e.text()})(e).then(r=>{if(e.status>=500)throw new a(errors,t.meta,t.headers);return t.data=r,t})};e.exports=(e=>{o("REQUEST:",e);const{method:t,url:r,headers:i,body:u,...c}=e;t=t.toUpperCase();const p={method:t,headers:i,body:u,...c};return n(r,p).then(s).catch(e=>{if(e instanceof a)throw e;throw new a(e.message)})})},function(e,t,r){const n=r(23),o=r(17);e.exports=(e=>{let t=o(e);return n(t)})},function(e,t,r){"use strict"; /*! * isobject <https://github.com/jonschlinkert/isobject> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */e.exports=function(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}},function(e,t,r){"use strict"; /*! * is-plain-object <https://github.com/jonschlinkert/is-plain-object> * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */var n=r(25);function o(e){return!0===n(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.exports=function(e){var t,r;return!1!==o(e)&&("function"==typeof(t=e.constructor)&&(!1!==o(r=t.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},function(e,t){e.exports=function(e,t,r,n){if(!e.registry[r])return;var o=e.registry[r][t].indexOf(n);if(-1===o)return;e.registry[r][t].splice(o,1)}},function(e,t){e.exports=function(e,t,r,n){e.registry[r]||(e.registry[r]={before:[],error:[],after:[]});e.registry[r][t]["before"===t?"unshift":"push"](n)}},function(e,t){function r(e){return!(e instanceof Error)}e.exports=function e(t,n,o,a){3===arguments.length&&(a=o,o={});if("function"!=typeof a)throw new Error("method for before hook must be a function");if("object"!=typeof o)throw new Error("options for before hook must be an object");if(Array.isArray(n))return n.reverse().reduce(function(r,n){return e.bind(null,t,n,o,r)},a)();var s=t.registry[n];if(!s)return function(e,t){try{return Promise.resolve(t(e))}catch(e){return Promise.reject(e)}}(o,a);var i=s.before;var u=s.error;var c=s.after;return Promise.all(i.map(function(e,t){try{return t(e)}catch(e){return Promise.reject(e)}}.bind(null,o))).then(function(){return a(o)}).catch(function(e){return Promise.all(u.map(function(e,t,r){try{return Promise.resolve(r(e,t)).catch(function(e){return e})}catch(e){return Promise.resolve(e)}}.bind(null,e,o))).then(function(t){var n=t.filter(r);if(n.length)return n[0];throw e})}).then(function(e){return Promise.all(c.map(function(e,t,r){try{return r(e,t)}catch(e){return Promise.reject(e)}}.bind(null,e,o))).then(function(){return e})})}},function(e,t,r){e.exports=function(){var e={registry:{}},t=n.bind(null,e);return t.remove={},t.api={remove:{}},["before","error","after"].forEach(function(r){t[r]=t.api[r]=o.bind(null,e,r),t.remove[r]=t.api.remove[r]=a.bind(null,e,r)}),t};var n=r(29),o=r(28),a=r(27)},function(e,t,r){const n=r(30),o=r(3),a=r(24),s=[r(14),r(11)],{version:i}=r(4),u={mode:"sandbox",type:"checkout",headers:{"content-type":"application/json; charset=utf-8","user-agent":`NodeBKash/${i}`},options:{timeout:0}},c="1.1.0-beta",p=["sandbox","pay"],d=["checkout","payments"];e.exports=class{constructor(e=u){let{mode:t,type:r,headers:a,options:i}=o(u,e);if(!p.includes(t))throw new Error(`Invalid mode, must be one of: ${p.join("/")}`);if(!d.includes(r))throw new Error(`Invalid type, must be one of: ${d.join("/")}`);this.mode=t,this.type=r,this.version=c,this.options={headers:a,options:i},this.hook=new n,this.request=this.request.bind(this),s.forEach(e=>this.addPlugin(e))}addPlugin(e){new e(this).inject()}request(e){return this.hook("request",o(this.options,e),a)}}}]);