wasabi-api
Version:
1 lines • 20.3 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("crypto-js")):"function"==typeof define&&define.amd?define(["crypto-js"],e):"object"==typeof exports?exports["wasabi-api"]=e(require("crypto-js")):t["wasabi-api"]=e(t["crypto-js"])}(self,(function(t){return(()=>{var e={264:(t,e,r)=>{t.exports=r(588)},588:t=>{var e=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof v?e:v,a=Object.create(o.prototype),i=new A(n||[]);return a._invoke=function(t,e,r){var n=l;return function(o,a){if(n===d)throw new Error("Generator is already running");if(n===p){if("throw"===o)throw a;return M()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=O(i,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var c=f(t,e,r);if("normal"===c.type){if(n=r.done?p:h,c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=p,r.method="throw",r.arg=c.arg)}}}(t,r,i),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l="suspendedStart",h="suspendedYield",d="executing",p="completed",y={};function v(){}function g(){}function w(){}var m={};c(m,a,(function(){return this}));var b=Object.getPrototypeOf,x=b&&b(b(H([])));x&&x!==r&&n.call(x,a)&&(m=x);var j=w.prototype=v.prototype=Object.create(m);function T(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function r(o,a,i,s){var c=f(t[o],t,a);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,s)}),(function(t){r("throw",t,i,s)})):e.resolve(l).then((function(t){u.value=t,i(u)}),(function(t){return r("throw",t,i,s)}))}s(c.arg)}var o;this._invoke=function(t,n){function a(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(a,a):a()}}function O(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,O(t,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=f(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function H(t){if(t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}return{next:M}}function M(){return{value:e,done:!0}}return g.prototype=w,c(j,"constructor",w),c(w,"constructor",g),g.displayName=c(w,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,c(t,s,"GeneratorFunction")),t.prototype=Object.create(j),t},t.awrap=function(t){return{__await:t}},T(E.prototype),c(E.prototype,i,(function(){return this})),t.AsyncIterator=E,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new E(u(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},T(j),c(j,s,"Generator"),c(j,a,(function(){return this})),c(j,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=H,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(S),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],s=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:H(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}},460:e=>{"use strict";e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}n.r(o),n.d(o,{AjaxModel:()=>g,FetchModel:()=>w,ajax:()=>i,default:()=>m,fetch:()=>p,paramFormat:()=>e,secret:()=>y});const e=function(e){if(!e)return e;if("string"==typeof e||"number"==typeof e)return e;if(e.constructor===FormData)return e;if(e instanceof Array)throw new Error("参数必须是字符,空值,对象,FormData,不可以为数组");e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={};r.isArray=Function.isArray||function(e){return"object"===t(e)&&"[object Array]"===Object.prototype.toString.call(e)},r.convertArrayToObject=function(e,n,o){var a=o||{};return function e(n,o){for(var i in o)if(r.isArray(o[i])||"object"!==t(o[i]))a[n+"["+i+"]"]=o[i];else for(var s in o[i])r.isArray(o[i][s])?e(n+"["+i+"]."+s,o[i][s]):"object"===t(o[i][s])?r.convertObject(n+"["+i+"]."+s+".",o[i][s],a):a[n+"["+i+"]."+s]=o[i][s]}(e,n),a},r.convertObject=function(e,n,o){var a=o||{};return function e(n,o){for(var i in o)r.isArray(o[i])?r.convertArrayToObject(i,o[i],a):"object"===t(o[i])?e(n+i+".",o[i]):a[n+i]=o[i]}(e,n),a};var n="";if("object"!==t(e))throw new Error("请传入json对象");if(r.isArray(e)&&!n)throw new Error("必须是对象,如果是数组请使用对象包裹!");return r.isArray(e)?r.convertArrayToObject(n,e):r.convertObject("",e)}(e);var r=[];for(var n in e)r.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return r.length>0?r.join("&"):null},r={100:"客户必须继续发出请求",101:"客户要求服务器根据请求转换HTTP协议版本",200:"交易成功",201:"提示知道新文件的URL",202:"接受和处理、但处理未完成",203:"返回信息不确定或不完整",204:"请求收到,但返回信息为空",205:"服务器完成了请求,用户代理必须复位当前已经浏览过的文件",206:"服务器已经完成了部分用户的GET请求",300:"请求的资源可在多处得到",301:"删除请求数据",302:"在其他地址发现了请求数据",303:"建议客户访问其他URL或访问方式",304:"客户端已经执行了GET,但文件未变化",305:"请求的资源必须从服务器指定的地址得到",306:"前一版本HTTP中使用的代码,现行版本中不再使用",307:"申明请求的资源临时性删除",400:"错误请求,如语法错误",401:"请求授权失败",402:"保留有效ChargeTo头响应",403:"请求不允许",404:"没有发现文件、查询或URl",405:"用户在Request-Line字段定义的方法不允许",406:"根据用户发送的Accept拖,请求资源不可访问",407:"类似401,用户必须首先在代理服务器上得到授权",408:"客户端没有在用户指定的饿时间内完成请求",409:"对当前资源状态,请求不能完成",410:"服务器上不再有此资源且无进一步的参考地址",411:"服务器拒绝用户定义的Content-Length属性请求",412:"一个或多个请求头字段在当前请求中错误",413:"请求的资源大于服务器允许的大小",414:"请求的资源URL长于服务器允许的长度",415:"请求资源不支持请求项目格式",416:"请求中包含Range请求头字段,在当前请求资源范围内没有range指示值,请求也不包含If-Range请求头字段",417:"服务器不满足请求Expect头字段指定的期望值,如果是代理服务器,可能是下一级服务器不能满足请求",500:"服务器产生内部错误",501:"服务器不支持请求的函数",502:"服务器暂时不可用,有时是为了防止发生系统过载",503:"服务器过载或暂停维修",504:"关口过载,服务器使用另一个关口或服务来响应用户,等待时间设定值较长",505:"服务器不支持或拒绝支请求头中指定的HTTP版本"};function a(e){if(!(e&&e instanceof Object))throw new Error("ajax配置无效,不能为空,必须为对象");if(e.data instanceof Array)throw new Error("ajax的data参数必须是字符,空值,对象,FormData,不可以为数组");if(e.dataType||(e.dataType="json"),e.type||(e.type="GET"),"string"!=typeof e.type)throw new Error("ajax中的type参数必须是字符");if(!1!==e.async&&(e.async=!0),!e.url)throw new Error("ajax请求地址不能为空");if("string"!=typeof e.url)throw new Error("ajax请求地址必须是字符串");if(!e.success)throw new Error("ajax的success[请求成功函数]不能为空");if("function"!=typeof e.success)throw new Error("ajax的success[请求成功函数]必须为函数");if(e.error&&"function"!=typeof e.error)throw new Error("ajax的error[请求失败函数]必须为函数");if(e.progress&&"function"!=typeof e.progress)throw new Error("ajax的progress[上传进度函数]必须为函数");if(null!==e.contentType&&void 0!==e.contentType&&""!==e.contentType||(e.contentType="application/x-www-form-urlencoded"),e.headers&&!(e.headers instanceof Object))throw new Error("headers要么为空,要么为对象");return e.contentType&&e.contentType.indexOf("json")>-1&&e.data&&"object"==t(e.data)&&e.data instanceof Object&&!(e.data instanceof FormData)&&(e.data=JSON.stringify(e.data)),!0}function i(t){var n=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");function o(e){if(e.lengthComputable){var r=Math.round(100*e.loaded/e.total);"function"==typeof t.progress&&t.progress(r)}}function i(e){var r=e.target;if(4==r.readyState&&(r.status>=200&&r.status<300||304==r.status)){var o=n.getAllResponseHeaders();if("json"==t.dataType){var a=r.response?r.response:r.responseText;a?("string"==typeof a&&(a=JSON.parse(a)),null!=a.success&&null!=a.success?a.success?t.success(a,o):a.message?f(a.statusCode||a.code||801,a.message):f(801,"服务器正常响应,后台业务代码的逻辑报错"):a.statusCode||a.code||a.status||a.state?(a.statusCode=a.statusCode||a.code||a.status||a.state,a.statusCode=1*a.statusCode,200==a.statusCode||1==a.statusCode?t.success(a,o):a.message?f(a.statusCode||a.code||801,a.message):f(801,"服务器正常响应,后台业务代码的逻辑报错")):t.success(a,o)):f(802,"服务器返回的数据格式不正确")}else if("blob"==t.dataType||"arrayBuffer"==t.dataType)t.success(r.response,o);else try{t.success(r.responseText,o)}catch(e){t.success(r.response,o)}}else f(r.status,r.statusText)}function s(e){var r=e.target;"function"==typeof t.complete&&(4==r.readyState&&(r.status>=200&&r.status<300||304==r.status)||4==r.readyState&&0==r.status?t.complete(r,"success"):t.complete(r,"error"))}function c(t){f(804,"请求超时")}function u(t){var e=t.target,n=r[e.status.toString()||"404"];f(e.statusText?e.statusText:n,e.status)}function f(e,r){console.error(e),"function"==typeof t.error&&t.error(e,r)}a(t)&&function(){t.data=e(t.data),"get"==t.type.toLowerCase()&&(t.data&&t.url.indexOf("?")<=-1&&(t.url+="?"),t.data&&t.url.indexOf("?")>-1&&t.url.indexOf("?")==t.url.length-1?t.url+=t.data:t.data&&t.url.indexOf("?")>-1&&t.url.indexOf("?")<t.url.length-1&&(t.url+="&"+t.data));try{n.open(t.type,t.url,t.async)}catch(t){f(803,"[IE,360]自动阻止了跨域:"+t.message)}0==t.contentType||n.setRequestHeader("Content-Type",t.contentType);try{n.responseType=t.dataType}catch(t){console.log("该浏览器[IE,360]不支持responseType的设置,跳过")}if(t.timeout&&!1!==t.async&&(n.timeout=t.timeout),t.headers instanceof Object)try{for(var r in t.headers)n.setRequestHeader(r,encodeURI(t.headers[r]))}catch(t){throw new Error(t.message)}try{n.addEventListener("load",i,!1),n.addEventListener("loadend",s,!1),n.addEventListener("timeout",c,!1),n.addEventListener("error",u,!1),n.upload.addEventListener("progress",o,!1)}catch(t){console.log("浏览器不支持xhr2.0,已经转为1.0"),n.onreadystatechange=function(){if(4==n.readyState){var t={};t.target=n,i(t)}}}return!0}()&&(t.data?"get"==t.type.toLowerCase()?n.send():n.send(t.data):n.send())}var s=n(460),c=n.n(s);const u=function(e){if(!(e&&e instanceof Object))throw new Error("fetchModel配置无效,不能为空,必须为对象");if(e.data instanceof Array)throw new Error("fetchModel的data参数必须是字符,空值,对象,FormData,不可以为数组");if("string"!=typeof e.type)throw new Error("fetchModel中的type参数必须是字符");if(e.type||(e.type="GET"),!e.url)throw new Error("请求地址不能为空");if("string"!=typeof e.url)throw new Error("fetchModel中的url参数必须是字符");if(e.error&&"function"!=typeof e.error)throw new Error("fetchModel的error[请求失败函数]必须为函数");if(null!=e.contentType&&null!=e.contentType&&""!=e.contentType||(e.contentType="application/x-www-form-urlencoded"),e.headers&&!(e.headers instanceof Object))throw new Error("fetchModel中的headers要么为空,要么为对象");return e.contentType&&e.contentType.indexOf("json")>-1&&e.data&&"object"==t(e.data)&&e.data instanceof Object&&!(e.data instanceof FormData)&&(e.data=JSON.stringify(e.data)),!0};function f(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}var l=n(264),h=n.n(l);const d=function(e){return!(!e||"object"!==t(e)||"{}"!=JSON.stringify(e))||!e},p=function(){var t,r=(t=h().mark((function t(r){var n,o,a,i;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u(r)){t.next=2;break}return t.abrupt("return");case 2:if(r.data=e(r.data),r.headers=r.headers?r.headers:{},r.headers instanceof Object)for(n in r.headers)r.headers[n]=encodeURI(r.headers[n]);return r.contentType&&(r.headers["Content-Type"]=r.contentType),o={method:r.type,headers:r.headers,body:r.data},"get"==r.type.toLowerCase()&&(r.data&&r.url.indexOf("?")<=-1&&(r.url+="?"),r.data&&r.url.indexOf("?")>-1&&r.url.indexOf("?")==r.url.length-1?r.url+=r.data:r.data&&r.url.indexOf("?")>-1&&r.url.indexOf("?")<r.url.length-1&&(r.url+="&"+r.data)),t.prev=8,console.log("fetch请求开始,地址:",r.url),console.log("fetch请求开始,参数体:",o),t.next=13,fetch(r.url,o);case 13:if(!(a=t.sent).ok){t.next=22;break}return t.next=17,a.json();case 17:return i=t.sent,d(i)||d(a.headers)||(i.headers=a.headers),t.abrupt("return",Promise.resolve(i));case 22:return t.abrupt("return",Promise.reject("请求错误:"+(a.statusText?a.statusText:"")+a.status));case 23:t.next=28;break;case 25:return t.prev=25,t.t0=t.catch(8),t.abrupt("return",Promise.reject("请求错误:"+t.t0.message));case 28:case"end":return t.stop()}}),t,null,[[8,25]])})),function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){f(a,n,o,i,s,"next",t)}function s(t){f(a,n,o,i,s,"throw",t)}i(void 0)}))});return function(t){return r.apply(this,arguments)}}(),y=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"HmacSHA256",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"ajax";if("fetch"==s?u(e):a(e)){if(!c()[n])throw new Error("加密方式无效[MD5,SHA1,SHA256,SHA512,AES,HmacMD5,HmacSHA1,HmacSHA256,HmacSHA512]");if("MD5"!=n&&"SHA1"!=n&&"SHA256"!=n&&"SHA512"!=n&&!r)throw new Error("非MD5,SHA1,SHA256,密钥secretKey不能为空");o=o||{};try{var f=Object.assign({},e.data,e.headers);if(!d(f)){var l=[];for(var h in f)o.indexOf(h)<=-1&&l.push(h);l.sort();var y=l.map((function(e,r){return e+"="+(f[e]?"object"===t(f[e])?JSON.stringify(f[e]):f[e]:"")})).join("&"),v="MD5"!=n&&"SHA1"!=n&&"SHA256"!=n?c()[n](y,r).toString(c().enc.Base64url):c()[n](y).toString(c().enc.Base64url);e.headers="object"===t(e.headers)?e.headers:{},e.headers.sign=v}return"fetch"==s?p(e):i(e)}catch(t){throw new Error(t.message)}}};function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var g=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"GET",r=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;v(this,t),this.type=e,this.url=r,this.data=o,this.success=n,this.error=a,this.progress=null,this.dataType="json",this.contentType="application/x-www-form-urlencoded",this.async=!0,this.timeout=null,this.headers=[]},w=function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/x-www-form-urlencoded",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;v(this,t),this.url=e,this.data=r,this.type=n,this.contentType=o,this.headers=a};const m={paramFormat:e,ajax:i,secret:y,fetch:p,AjaxModel:g,FetchModel:w}})(),o})()}));