@cloudbase/auth 2.25.3 → 2.25.4

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.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):"function"==typeof define&&define.amd?define("tcbauth",["@cloudbase/oauth","@cloudbase/adapter-wx_mp"],t):"object"==typeof exports?exports.tcbauth=t(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):e.tcbauth=t(e.tcboauth,e.tcbadaptermp)}("undefined"!=typeof window?window:this,(e,t)=>(()=>{"use strict";var r={829:(e,t,r)=>{var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>s}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},105:function(e,t,r){var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(587)),c=r(894);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},587:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(829),c=r(894),d=r(652),l=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach((function(e){c.append(e,t[e])})),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,(function(){var r,n,o,u,c,d,l,h,p,f,v,y,g,m=this;return a(this,(function(b){switch(b.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,d=void 0!==c&&c,l=e.signal,h=e.timeout,p=e.shouldThrowOnError,f=void 0===p||p,v=null!=h?h:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(m,void 0,void 0,(function(){var t,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(y),f)return Promise.reject(e)}))];case 1:return g=b.sent(),[2,{data:d?g.body:(null===(t=g.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?g.json():g.text(),statusCode:g.status,header:g.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,l=void 0===u?{}:u,h=e.data,p=e.responseType,f=e.withCredentials,v=e.body,y=e.onUploadProgress,g=(0,c.formatUrl)((0,d.getProtocol)(),a,"get"===n?h:{}),m=new XMLHttpRequest;m.open(n,g),p&&(m.responseType=p),Object.keys(l).forEach((function(e){m.setRequestHeader(e,l[e])})),y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=m.status;try{e.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===l["content-type"]?(0,c.toQueryString)(h):v||(h?JSON.stringify(h):void 0),f&&(m.withCredentials=!0),m.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=l,t.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},652:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=("undefined"==typeof process||process.env,!1),t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},151:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},141:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(652),t),o(r(151),t),t.OATUH_LOGINTYPE="constants"},64:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(894),s=r(141),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function d(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),d=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex((function(e){return u.test(e)}));if(-1!==l){var h=s.filter((function(e,t){return t>l}));h.unshift(s[l].replace(d,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,l=void 0===a?{}:a,h=e.title,p=e.messages,f=void 0===p?[]:p;return function(e,t,a){if(s.IS_DEBUG_MODE){var p=l.className||e.constructor.name,v=l.methodName||t,y=a.value,g=function(e){var t="",r=e.stack.split("\n"),n=r.findIndex((function(e){return u.test(e)}));if(-1!==n){var o=c.exec(r[n+1]||"");t=o?o[0]:""}return t}(new Error);a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=d({err:new Error,className:p,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:h||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=f.map((function(e){return{type:"info",body:e}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=f.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,l;return o(this,(function(o){switch(o.label){case 0:t=d({err:new Error,className:p,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:h||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(t?(t.code=l.code,t.message=l.msg):(r.code=l.code,r.message=l.msg),n=t||r,c.content=f.map((function(e){return{type:"info",body:e}})))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=f.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},466:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(64),t)},418:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(829),u=r(894),c=r(141),d=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage);var l=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(t.root));case"none":return new d(t.root);default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(t.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();t.CloudbaseCache=l},988:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(894);var a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++){c[o].call(this,r)}}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var d=new c;t.addEventListener=function(e,t){d.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),d.fire(e,t)},t.removeEventListener=function(e,t){d.off(e,t)}},894:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(141);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""};t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var d=0,l=s;d<l.length;d++){var h=l[d],p=h.type,f=h.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)};t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86".concat(e)};t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},219:e=>{e.exports=t},297:t=>{t.exports=e}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e].call(i.exports,i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{Auth:()=>ee,LoginState:()=>Z,User:()=>X,generateAuthInstance:()=>te,registerAuth:()=>ne});var e=o(297),t=o(894),r=o(141),n=o(466),s=o(988),a=o(418),u=o(219),c=o.n(u),d=o(105),l=function(){return(l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},h=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},p=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},f=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return h(this,void 0,void 0,(function(){return p(this,(function(t){return[2,this.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return h(this,void 0,void 0,(function(){return p(this,(function(t){return this.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return h(this,void 0,void 0,(function(){return p(this,(function(r){return this.localStorage.setItem(e,t),[2]}))}))},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),v=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,y=function(e,t){var r,n,o,i,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,v.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}};var g=function(e,t){var r=l({},e),n={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!c().isMatch()||e.storage&&e.baseRequest)return r;try{var o=c().genAdapter({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new f({localStorage:i,adapter:t})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(e){return function(t,r){return h(this,void 0,void 0,(function(){return p(this,(function(n){return[2,new Promise((function(n,o){var i=Object.assign({},r);i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body));var s=wx.request({url:t,data:i.body,timeout:e._timeout,method:i.method||"GET",header:i.headers,success:function(e){(e=y(e,l(l({},r),{url:t}))).error&&o(e),n(e)},fail:function(e){o({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{s.abort()}catch(e){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),l(l({},r),n)}catch(e){console.error("adapter generate fail:",e)}return r},m=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=l({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new f({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var n=new t.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(e,t){var r,o,i,s,a;return h(this,void 0,void 0,(function(){var u,c,d,h;return p(this,(function(p){switch(p.label){case 0:if(u={},c=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(d=null===(i=null===(o=null==n?void 0:n[c])||void 0===o?void 0:o.bind)||void 0===i?void 0:i.call(o,n)))throw new Error("invalid 【".concat(c,"】 request method"));p.label=1;case 1:return p.trys.push([1,3,,4]),(null===(s=t.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=t.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,d(l({url:e},t))];case 2:return u=p.sent(),u=y(u,l(l({},t),{url:e})),[3,4];case 3:throw h=p.sent(),u=l(l({},null==h?void 0:h.data),h);case 4:if(null==u?void 0:u.error)throw u;return[2,u]}}))}))}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):g(e,e.adapter)};var b="@cloudbase/js-sdk";function _(){return b}var w="https:";"undefined"==typeof process||process.env;var I="INVALID_PARAMS",E="INVALID_OPERATION",A="OPERATION_FAIL",S=o(829);function O(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}function T(e,t){console.warn("[".concat(_(),"][").concat(e,"]:").concat(t))}var P,U=(P=function(e,t){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),k=function(){return(k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},C=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},N=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};!function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}U(t,e),t.prototype.get=function(e){return this.request(k(k({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(k(k({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(k(k({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,i=e.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(t).forEach((function(e){u.append(e,t[e])})),u.append("key",n),u.append("file",r),this.request(k(k({},e),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(k(k({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return C(this,void 0,void 0,(function(){var t,r,n,o;return N(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(k(k({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return C(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d,l,h,p,f,v=this;return N(this,(function(y){switch(y.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,i=void 0!==o&&o,s=e.stream,a=void 0!==s&&s,u=e.signal,c=e.timeout,d=e.shouldThrowOnError,l=void 0===d||d,h=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),p=null,i&&h&&(p=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),h)),[4,fetch(n,k(k({},e),{signal:r.signal})).then((function(e){return C(v,void 0,void 0,(function(){var t,r,n;return N(this,(function(o){switch(o.label){case 0:return clearTimeout(p),l?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(p),l)return Promise.reject(e)}))];case 1:return f=y.sent(),[2,{data:a?f.body:(null===(t=f.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?f.json():f.text(),statusCode:f.status,header:f.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a,u=e.url,c=e.headers,d=void 0===c?{}:c,l=e.data,h=e.responseType,p=e.withCredentials,f=e.body,v=e.onUploadProgress,y=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)}(w,u,"get"===n?l:{}),g=new XMLHttpRequest;g.open(n,y),h&&(g.responseType=h),Object.keys(d).forEach((function(e){g.setRequestHeader(e,d[e])})),v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=g.status;try{e.data="blob"===h?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===h?g.response:g.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),a=l,s="[object FormData]"===Object.prototype.toString.call(a)?l:"application/x-www-form-urlencoded"===d["content-type"]?function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")}(l):f||(l?JSON.stringify(l):void 0),p&&(g.withCredentials=!0),g.send(s)}))}}(S.AbstractSDKRequest);var L;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(L||(L={}));var R=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),x=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},j=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},M=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return R(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(S.AbstractStorage);!function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":return t.localStorage?t.localStorage:(T(I,"localStorage is not supported on current platform"),new M(t.root));case"none":return new M(t.root);default:return t.localStorage?t.localStorage:(T(I,"localStorage is not supported on current platform"),new M(t.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:A,msg:"[".concat(_(),"][").concat(A,"]setStore failed"),info:e}))}}else T(E,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return x(this,void 0,void 0,(function(){var n;return j(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}T(E,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return x(this,void 0,void 0,(function(){var n;return j(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):T(E,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return x(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))}}();var D=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),q=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};var W=function(e,t){this.data=t||null,this.name=e},H=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return D(t,e),t}(W),G=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(e instanceof H)return console.error(e.error),this;var r="string"==typeof e?new W(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?q([],this.listeners[n],!0):[];o<i.length;o++){i[o].call(this,r)}}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();new G;new G;"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");!function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,r){"abort"===t&&e.listeners.push(r)}}}e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(e){return e()})))}}();function Y(e){this.message=e}Y.prototype=new Error,Y.prototype.name="InvalidCharacterError";"undefined"!=typeof window&&window.atob&&window.atob.bind(window);function F(e){this.message=e}F.prototype=new Error,F.prototype.name="InvalidTokenError";var V=function(){return(V=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},B=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},K=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},J=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},$=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Q=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},z=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},X=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}return e.prototype.checkLocalInfo=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return J(this,void 0,void 0,(function(){var e,t,r,n;return $(this,(function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},e.prototype.update=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(V({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}}))}))},e.prototype.updateUserBasicInfo=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(V({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,t.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}}))}))},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}}))}))},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at"].forEach((function(t){e[t]=r[t]}))},B([(0,n.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],e.prototype,"update",null),B([(0,n.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[String,String]),K("design:returntype",void 0)],e.prototype,"updatePassword",null),B([(0,n.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[String]),K("design:returntype",void 0)],e.prototype,"updateUsername",null),B([(0,n.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],e.prototype,"refresh",null),e}(),Z=function(){function e(e){var n=e.envId,o=e.cache,i=e.oauthInstance;n||(0,t.throwError)(r.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=o,this.oauthInstance=i,this.user=new X({cache:this.cache,oauthInstance:i})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}}))}))},e}(),ee=function(){function o(e){this.listeners=new Map,this.hasListenerSetUp=!1,this.config=e,this.oauthInstance=e.oauthInstance,this.cache=e.cache,this.init(),this.setAccessKey()}return o.prototype.bindPhoneNumber=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.editContact(e)]}))}))},o.prototype.unbindProvider=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]}))}))},o.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},o.prototype.verify=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.verify(e)]}))}))},o.prototype.getVerification=function(e,t){return J(this,void 0,void 0,(function(){return $(this,(function(r){return[2,this.oauthInstance.authApi.getVerification(e,t)]}))}))},Object.defineProperty(o.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,t.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),o.prototype.getCurrentUser=function(){return J(this,void 0,void 0,(function(){var e,t;return $(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?(t=e.user.getLocalUserInfo(),[4,e.user.checkLocalInfoAsync()]):[3,3];case 2:return r.sent(),[2,V(V({},e.user),t)];case 3:return[2,null]}}))}))},o.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return J(this,void 0,void 0,(function(){var e,r,n=this;return $(this,(function(o){switch(o.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return J(n,void 0,void 0,(function(){var n,o;return $(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}}))}))},[4,new Promise((function(e,t){wx.login({success:function(o){return J(n,void 0,void 0,(function(){var n;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}}))}))},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},o.prototype.bindOpenId=function(){return J(this,void 0,void 0,(function(){var e,t,r=this;return $(this,(function(n){switch(n.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return J(r,void 0,void 0,(function(){var r;return $(this,(function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}}))}))},[4,new Promise((function(e,n){wx.login({success:function(o){return J(r,void 0,void 0,(function(){var r;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})}))];case 1:return n.sent(),[2]}}))}))},o.prototype.signInWithUnionId=function(){return J(this,void 0,void 0,(function(){var e=this;return $(this,(function(t){switch(t.label){case 0:if(!c().isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise((function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return J(e,void 0,void 0,(function(){var e,i,s,a,u;return $(this,(function(c){switch(c.label){case 0:e=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}}))}))},o.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a;return J(this,void 0,void 0,(function(){return $(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(e){throw e}return[2]}))}))},o.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,u=void 0===a?"":a;return J(this,void 0,void 0,(function(){return $(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(e){throw e}return[2]}))}))},o.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},o.prototype.signIn=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},o.prototype.setPassword=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.setPassword(e)]}))}))},o.prototype.isUsernameRegistered=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,t.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,n.sent().exist]}}))}))},o.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new Z({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,t.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},o.prototype.getLoginState=function(){return J(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new Z({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},o.prototype.getUserInfo=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.getCurrentUser()]}))}))},o.prototype.getWedaUserInfo=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},o.prototype.updateUserBasicInfo=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},o.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},o.prototype.bindWithProvider=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]}))}))},o.prototype.queryUser=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]}))}))},o.prototype.getAccessToken=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}}))}))},o.prototype.grantProviderToken=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]}))}))},o.prototype.patchProviderToken=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]}))}))},o.prototype.signInWithProvider=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},o.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},o.prototype.grantToken=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},o.prototype.genProviderRedirectUri=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]}))}))},o.prototype.resetPassword=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]}))}))},o.prototype.deviceAuthorize=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]}))}))},o.prototype.sudo=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.sudo(e)]}))}))},o.prototype.deleteMe=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]}))}))},o.prototype.getProviders=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getProviders()]}))}))},o.prototype.loginScope=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.loginScope()]}))}))},o.prototype.loginGroups=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},o.prototype.onLoginStateChanged=function(t){var r;return J(this,void 0,void 0,(function(){var n,o=this;return $(this,(function(i){switch(i.label){case 0:return null===(r=this.config.eventBus)||void 0===r||r.on(e.EVENTS.LOGIN_STATE_CHANGED,(function(r){return J(o,void 0,void 0,(function(){var n,o,i;return $(this,(function(s){switch(s.label){case 0:return(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.eventType)===e.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return o=s.sent(),[3,3];case 2:o={},s.label=3;case 3:return n=o,t.call(this,V(V({},r),n)),[2]}}))}))})),[4,this.getLoginState()];case 1:return n=i.sent(),t.call(this,n),[2]}}))}))},o.prototype.refreshTokenForce=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]}))}))},o.prototype.getCredentials=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},o.prototype.setCredentials=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}}))}))},o.prototype.getProviderSubType=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},o.prototype.createCaptchaData=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]}))}))},o.prototype.verifyCaptchaData=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]}))}))},o.prototype.getMiniProgramQrCode=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]}))}))},o.prototype.getMiniProgramQrCodeStatus=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]}))}))},o.prototype.modifyPassword=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]}))}))},o.prototype.modifyPasswordWithoutLogin=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]}))}))},o.prototype.getUserBehaviorLog=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]}))}))},o.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.username,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a,c=e.loginType,d=void 0===c?"":c;return J(this,void 0,void 0,(function(){var e,t,n,i,a,c,l;return $(this,(function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=h.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=/^\+\d{1,3}\s+/.test(s)?s:"+86 ".concat(s),i={phone_number:n},"email"===d&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(a=h.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=h.sent())?void 0:c.error_code)throw c;h.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(V(V({},i),{verification_token:t,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(l=h.sent())?void 0:l.error_code)throw l;h.label=7;case 7:return[2,this.createLoginState()];case 8:throw h.sent();case 9:return[2]}}))}))},o.prototype.createLoginState=function(t,r){var n,o;return J(this,void 0,void 0,(function(){var i;return $(this,(function(s){switch(s.label){case 0:return[4,(i=new Z({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return s.sent(),(null==r?void 0:r.userInfo)?(i.user.setLocalUserInfo(r.userInfo),[3,5]):[3,2];case 2:return(null==r?void 0:r.asyncRefreshUser)?(i.user.refresh(t),[3,5]):[3,3];case 3:return[4,i.user.refresh(t)];case 4:s.sent(),s.label=5;case 5:return null===(n=this.config.eventBus)||void 0===n||n.fire(e.EVENTS.LOGIN_STATE_CHANGED,{eventType:e.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(o=this.config.eventBus)||void 0===o||o.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,i]}}))}))},o.prototype.setAccessKey=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){if(this.config.accessKey)try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:this.config.accessKey,token_type:"Bearer",scope:"accessKey",expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]}))}))},o.prototype.signInAnonymously=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return s.sent(),[4,this.createLoginState()];case 2:return r=s.sent(),[4,this.getSession()];case 3:return n=s.sent().data,o=(void 0===n?{}:n).session,[2,V(V({},r),{data:{user:o.user,session:o},error:null})];case 4:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 5:return[2]}}))}))},o.prototype.signUp=function(t){return J(this,void 0,void 0,(function(){var r,n,o=this;return $(this,(function(i){switch(i.label){case 0:return t.phone_number||t.verification_code||t.verification_token||t.provider_token?[4,this.oauthInstance.authApi.signUp(t)]:[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)})];case 3:return r=i.sent(),[2,{data:{verifyOtp:function(n){var i=n.token,s=n.messageId,a=void 0===s?r.verification_id:s;return J(o,void 0,void 0,(function(){var n,o,s,u,c;return $(this,(function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.verify({verification_id:a||r.verification_id,verification_code:i})];case 1:return n=d.sent(),r.is_user?[4,this.signIn({username:t.email||this.formatPhone(t.phone),verification_token:n.verification_token})]:[3,3];case 2:return d.sent(),[3,6];case 3:return delete(o=JSON.parse(JSON.stringify(t))).email,delete o.phone,[4,this.oauthInstance.authApi.signUp(V(V(V({},o),t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)}),{verification_token:n.verification_token,verification_code:i}))];case 4:return d.sent(),[4,this.createLoginState()];case 5:d.sent(),d.label=6;case 6:return[4,this.getSession()];case 7:return s=d.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return c=d.sent(),[2,{data:{},error:new e.AuthError(c)}];case 9:return[2]}}))}))}},error:null}];case 4:return n=i.sent(),[2,{data:{},error:new e.AuthError(n)}];case 5:return[2]}}))}))},o.prototype.signOut=function(t){var r,n;return J(this,void 0,void 0,(function(){var o,i,s;return $(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),o=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return i=a.sent(),[4,this.cache.removeStoreAsync(o)];case 2:return a.sent(),this.setAccessKey(),null===(r=this.config.eventBus)||void 0===r||r.fire(e.EVENTS.LOGIN_STATE_CHANGED,{eventType:e.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(n=this.config.eventBus)||void 0===n||n.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,V(V({},i),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new e.AuthError(s)}];case 4:return[2]}}))}))},o.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},o.prototype.signInWithPassword=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateAtLeastOne(t,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(V({username:t.username||t.email||this.formatPhone(t.phone),password:t.password},t.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.signInWithIdToken=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(t,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:t.token})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.signInWithOtp=function(t){return J(this,void 0,void 0,(function(){var r,n,o=this;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)})];case 1:return r=i.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var n=e.token,i=e.messageId,s=void 0===i?r.verification_id:i;return J(o,void 0,void 0,(function(){return $(this,(function(e){return[2,this.verifyOtp({email:t.email,phone:t.phone,token:n,messageId:s})]}))}))}},error:null}];case 2:return n=i.sent(),[2,{data:{},error:new e.AuthError(n)}];case 3:return[2]}}))}))},o.prototype.verifyOAuth=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d;return $(this,(function(l){switch(l.label){case 0:r={},l.label=1;case 1:return l.trys.push([1,7,,8]),n=(null==t?void 0:t.code)||O("code"),o=(null==t?void 0:t.state)||O("state"),n?o?(i=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}}(o),r.type=null==i?void 0:i.type,(s=(null==t?void 0:t.provider)||(null==i?void 0:i.provider)||O("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:n})]:[2,{data:r,error:new e.AuthError({message:"Provider is required"})}]):[2,{data:{},error:new e.AuthError({message:"State is required"})}]:[2,{data:{},error:new e.AuthError({message:"Code is required"})}];case 2:return a=l.sent().provider_token,u=void 0,i.type!==e.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=l.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=l.sent()).data=V(V({},r),u.data),l.label=6;case 6:return(c=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),c.delete("state"),function(e,t){if(void 0!==e){var r=new URL(window.location.href);r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href)}}(void 0===(null==i?void 0:i.search)?"?".concat(c.toString()):null==i?void 0:i.search,(null==i?void 0:i.hash)||location.hash),function(e){try{sessionStorage.removeItem(e)}catch(e){return console.error("Failed to remove browser session:",e),null}}(o),[2,u];case 7:return d=l.sent(),[2,{data:r,error:new e.AuthError(d)}];case 8:return[2]}}))}))},o.prototype.signInWithOAuth=function(t){var r,n,o,i,s;return J(this,void 0,void 0,(function(){var a,u,c,d,l,h,p,f,v;return $(this,(function(y){switch(y.label){case 0:return y.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),a=(null===(r=t.options)||void 0===r?void 0:r.redirectTo)||location.href,u=new URL(a),c=u.origin+u.pathname,d=(null===(n=t.options)||void 0===n?void 0:n.state)||"prd-".concat(t.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:t.provider,provider_redirect_uri:c,state:d})];case 1:return l=y.sent().uri,h=decodeURIComponent(l),p=h,(null===(o=t.options)||void 0===o?void 0:o.queryParams)&&(f=new URL(h),Object.entries(t.options.queryParams).forEach((function(e){var t=e[0],r=e[1];f.searchParams.set(t,r)})),p=f.toString()),function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}}(d,{provider:t.provider,search:u.search,hash:u.hash,type:(null===(i=t.options)||void 0===i?void 0:i.type)||e.OAUTH_TYPE.SIGN_IN}),z()&&!(null===(s=t.options)||void 0===s?void 0:s.skipBrowserRedirect)&&window.location.assign(p),[2,{data:{url:p,provider:t.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new e.AuthError(v)}];case 3:return[2]}}))}))},o.prototype.signInWithSSO=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2]}))}))},o.prototype.signInWithWeb3=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2]}))}))},o.prototype.getClaims=function(){return J(this,void 0,void 0,(function(){var t,r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return t=n.sent().accessToken,[2,{data:(0,e.weappJwtDecodeAll)(t),error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.resetPasswordForEmail=function(t,r){return J(this,void 0,void 0,(function(){var n,o,i,s,a,u,c=this;return $(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),this.validateParams({emailOrPhone:t},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),n=(r||{}).redirectTo,o=t.includes("@"),i=void 0,o?i={email:t}:(s=this.formatPhone(t),i={phone_number:s}),[4,this.getVerification(i)];case 1:return a=d.sent(),[2,{data:{updateUser:function(r){return J(c,void 0,void 0,(function(){var i,s,u,c;return $(this,(function(d){switch(d.label){case 0:this.validateParams(r,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),d.label=1;case 1:return d.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:r.nonce})];case 2:return i=d.sent(),[4,this.oauthInstance.authApi.resetPassword({email:o?t:void 0,phone:o?void 0:t,new_password:r.password,verification_token:i.verification_token})];case 3:return d.sent(),null===(c=this.config.eventBus)||void 0===c||c.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:o?t:void 0,phone:o?void 0:t,password:r.password})];case 4:return s=d.sent(),n&&z()&&window.location.assign(n),[2,s];case 5:return u=d.sent(),[2,{data:{},error:new e.AuthError(u)}];case 6:return[2]}}))}))}},error:null}];case 2:return u=d.sent(),[2,{data:{},error:new e.AuthError(u)}];case 3:return[2]}}))}))},o.prototype.resetPasswordForOld=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:t.old_password,new_password:t.new_password})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.verifyOtp=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),r=t.type,this.validateParams(t,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(r)?[4,this.verify({verification_id:t.messageId,verification_code:t.token})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:t.messageId,is_user:!0},verificationCode:t.token,username:t.email||this.formatPhone(t.phone)||"",loginType:t.email?"email":"phone"})];case 3:s.sent(),s.label=4;case 4:return[4,this.getSession()];case 5:return n=s.sent().data,[2,{data:{user:(o=(void 0===n?{}:n).session).user,session:o},error:null}];case 6:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 7:return[2]}}))}))},o.prototype.getSession=function(){return J(this,void 0,void 0,(function(){var t,r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=i.sent())&&"accessKey"!==t.scope?[4,this.getUser()]:[2,{data:{session:null},error:null}];case 2:return r=i.sent().data,n=(void 0===r?{}:r).user,[2,{data:{session:V(V({},t),{user:n}),user:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.refreshSession=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i,s;return $(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(r=a.sent()).refresh_token=t||r.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(r)];case 2:return n=a.sent(),[4,this.getUser()];case 3:return o=a.sent().data,[2,{data:{user:i=(void 0===o?{}:o).user,session:V(V({},n),{user:i})},error:null}];case 4:return s=a.sent(),[2,{data:{},error:new e.AuthError(s)}];case 5:return[2]}}))}))},o.prototype.getUser=function(){return J(this,void 0,void 0,(function(){var t,r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=this.convertToUser,[4,this.getUserInfo()];case 1:return[2,{data:{user:t.apply(this,[n.sent()])},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.refreshUser=function(){return J(this,void 0,void 0,(function(){var t,r,n;return $(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new e.AuthError(n)}];case 4:return[2]}}))}))},o.prototype.updateUser=function(t){var r;return J(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,d,l,h,p,f,v=this;return $(this,(function(y){switch(y.label){case 0:if(y.trys.push([0,8,,9]),!Object.keys(t).some((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})))throw new e.AuthError({message:"At least one field must be provided for update"});return n=t.email,o=t.phone,i=Q(t,["email","phone"]),a=void 0!==o,u={},(s=void 0!==n)||a?(c=void 0,s?(c={email:t.email},d="email_change"):(l=this.formatPhone(t.phone),c={phone_number:l},d="phone_change"),[4,this.getVerification(c)]):[3,4];case 1:return h=y.sent(),Object.keys(i).length>0?[4,this.updateUserBasicInfo(i)]:[3,3];case 2:y.sent(),y.label=3;case 3:return u={messageId:h.verification_id,verifyOtp:function(r){return J(v,void 0,void 0,(function(){var n,o,i;return $(this,(function(a){switch(a.label){case 0:return a.trys.push([0,11,,12]),r.email&&t.email===r.email?[4,this.verifyOtp({type:"email_change",email:t.email,token:r.token,messageId:h.verification_id})]:[3,3];case 1:return a.sent(),[4,this.updateUserBasicInfo({email:t.email})];case 2:return a.sent(),[3,9];case 3:return r.phone&&t.phone===r.phone?[4,this.verifyOtp({type:"phone_change",phone:t.phone,token:r.token,messageId:h.verification_id})]:[3,6];case 4:return a.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(t.phone)})];case 5:return a.sent(),[3,9];case 6:return[4,this.verifyOtp({type:d,email:s?t.email:void 0,phone:s?void 0:t.phone,token:r.token,messageId:h.verification_id})];case 7:return a.sent(),[4,this.updateUserBasicInfo(t)];case 8:a.sent(),a.label=9;case 9:return[4,this.getUser()];case 10:return n=a.sent().data.user,null===(i=this.config.eventBus)||void 0===i||i.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return o=a.sent(),[2,{data:{},error:new e.AuthError(o)}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(t)];case 5:y.sent(),y.label=6;case 6:return[4,this.getUser()];case 7:return p=y.sent().data.user,null===(r=this.config.eventBus)||void 0===r||r.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:V({user:p},u),error:null}];case 8:return f=y.sent(),[2,{data:{},error:new e.AuthError(f)}];case 9:return[2]}}))}))},o.prototype.getUserIdentities=function(){var t;return J(this,void 0,void 0,(function(){var r,n;return $(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return r=o.sent(),[2,{data:{identities:null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.filter((function(e){return!!e.bind}))},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new e.AuthError(n)}];case 3:return[2]}}))}))},o.prototype.linkIdentity=function(t){return J(this,void 0,void 0,(function(){var r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:t.provider,options:{type:e.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return n.sent(),[2,{data:{provider:t.provider},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.unlinkIdentity=function(t){return J(this,void 0,void 0,(function(){var r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:t.provider})];case 1:return n.sent(),[2,{data:{},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.reauthenticate=function(){return J(this,void 0,void 0,(function(){var t,r,n,o,i=this;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser()];case 1:return t=s.sent().data.user,this.validateAtLeastOne(t,[["email","phone"]],"You must provide either an email or phone number"),r=t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)},[4,this.getVerification(r)];case 2:return n=s.sent(),[2,{data:{updateUser:function(t){return J(i,void 0,void 0,(function(){var o,i,s,a,u;return $(this,(function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),t.password?[4,this.verify({verification_id:n.verification_id,verification_code:t.nonce})]:[3,5];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:o.verification_token})];case 3:return i=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:t.password,sudo_token:i.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(V(V({verificationInfo:n,verificationCode:t.nonce},r),{loginType:r.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{},error:new e.AuthError(u)}];case 10:return[2]}}))}))}},error:null}];case 3:return o=s.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.resend=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),r="signup"===t.type?"ANY":"USER",n={target:r},"email"in t&&(n.email=t.email),"phone"in t&&(n.phone_number=this.formatPhone(t.phone)),[4,this.oauthInstance.authApi.getVerification(n)];case 1:return[2,{data:{messageId:i.sent().verification_id},error:null}];case 2:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 3:return[2]}}))}))},o.prototype.setSession=function(t){var r;return J(this,void 0,void 0,(function(){var n,o,i;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),this.validateParams(t,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(t,{throwOnError:!0})];case 1:return s.sent(),[4,this.getSession()];case 2:return n=s.sent().data,o=(void 0===n?{}:n).session,null===(r=this.config.eventBus)||void 0===r||r.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:o.user,session:o},error:null}];case 3:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 4:return[2]}}))}))},o.prototype.exchangeCodeForSession=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2]}))}))},o.prototype.deleteUser=function(t){return J(this,void 0,void 0,(function(){var r,n;return $(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(t)];case 1:return r=o.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:r})];case 2:return o.sent(),[2,{data:{},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new e.AuthError(n)}];case 4:return[2]}}))}))},o.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),J(this,void 0,void 0,(function(){var r,n,o,i,s;return $(this,(function(a){try{return r=t.config_version||"env",n=Object.keys(t.query||{}).map((function(e){return"".concat(e,"=").concat(t.query[e])})).join("&"),c().isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(n?"?".concat(n):"")}):(o=t.redirect_uri||window.location.href,i=new URL(o),s="".concat(i.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(r,"&redirect_uri=").concat(encodeURIComponent(o)).concat(n?"&".concat(n):""),window.location.href=s),[2,{data:{},error:null}]}catch(t){return[2,{data:{},error:new e.AuthError(t)}]}return[2]}))}))},o.prototype.signInWithCustomTicket=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i;return $(this,(function(s){switch(s.label){case 0:t&&this.setCustomSignFunc(t),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return r=s.sent(),[4,this.getSession()];case 4:return n=s.sent().data,o=(void 0===n?{}:n).session,[2,V(V({},r),{data:{user:o.user,session:o},error:null})];case 5:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 6:return[2]}}))}))},o.prototype.signInWithOpenId=function(t){var r=(void 0===t?{}:t).useWxCloud,n=void 0===r||r;return J(this,void 0,void 0,(function(){var t,r,o,i,s,a,u=this;return $(this,(function(d){switch(d.label){case 0:if(!c().isMatch())throw Error("wx api undefined");t=wx.getAccountInfoSync().miniProgram,r=function(e){return J(u,void 0,void 0,(function(){var r,o;return $(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise((function(e,t){wx.login({success:function(n){return J(u,void 0,void 0,(function(){var o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),t(o),[3,3];case 3:return[2]}}))}))},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})}))];case 2:return d.sent(),[4,this.createLoginState()];case 3:return o=d.sent(),[4,this.getSession()];case 4:return i=d.sent().data,s=(void 0===i?{}:i).session,[2,V(V({},o),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{},error:new e.AuthError(a)}];case 6:return[2]}}))}))},o.prototype.signInWithPhoneAuth=function(t){var r=t.phoneCode,n=void 0===r?"":r;return J(this,void 0,void 0,(function(){var t,r,o,i,s,a,u,d,l;return $(this,(function(h){switch(h.label){case 0:return c().isMatch()?(t=wx.getAccountInfoSync().miniProgram,r={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()]):[2,{data:{},error:new e.AuthError({message:"wx api undefined"})}];case 1:o=h.sent().code,r.provider_code=o,h.label=2;case 2:return h.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(r)];case 3:if((i=h.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:i.provider_token,provider_id:t.appId,provider_params:{code:n,provider_code_type:"phone"}})];case 4:if((i=h.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:i.provider_token})];case 5:if(null==(s=h.sent())?void 0:s.error_code)throw s;return[3,7];case 6:return a=h.sent(),[2,{data:{},error:new e.AuthError(a)}];case 7:return[4,this.createLoginState()];case 8:return u=h.sent(),[4,this.getSession()];case 9:return d=h.sent().data,l=(void 0===d?{}:d).session,[2,V(V({},u),{data:{user:l.user,session:l},error:null})]}}))}))},o.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},o.prototype.notifyListeners=function(e,t,r){this.listeners.forEach((function(n){n.forEach((function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}}))}))},o.prototype.setupListeners=function(){var t,r=this;null===(t=this.config.eventBus)||void 0===t||t.on(e.EVENTS.AUTH_STATE_CHANGED,(function(e){return J(r,void 0,void 0,(function(){var t,r,n,o,i;return $(this,(function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}}))}))}))},o.prototype.convertToUser=function(e){var t,r,n;if(!e)return null;var o=(null==e?void 0:e.email)||"",i=(null==e?void 0:e.phone_number)||"",s=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:s,aud:"authenticated",role:e.groups,email:o||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:i,phone_confirmed_at:i?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(t=e.loginType)||void 0===t?void 0:t.toLowerCase())||"cloudbase",providers:[(null===(r=e.loginType)||void 0===r?void 0:r.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName,avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:e.hasPassword},identities:(null===(n=null==e?void 0:e.providers)||void 0===n?void 0:n.map((function(t){return{id:t.id||"",identity_id:t.id||"",user_id:s,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}})))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},o.prototype.validateParams=function(t,r){for(var n=0,o=Object.entries(r);n<o.length;n++){var i=o[n],s=i[0],a=i[1];if(a.required&&(void 0===(null==t?void 0:t[s])||null===(null==t?void 0:t[s])||""===(null==t?void 0:t[s])))throw new e.AuthError({message:a.message})}},o.prototype.validateAtLeastOne=function(t,r,n){if(!r.some((function(e){return e.some((function(e){return void 0!==(null==t?void 0:t[e])&&null!==(null==t?void 0:t[e])&&""!==(null==t?void 0:t[e])}))})))throw new e.AuthError({message:n})},o.prototype.init=function(){var t;return J(this,void 0,void 0,(function(){return $(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return r.sent()&&(null===(t=this.config.eventBus)||void 0===t||t.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return r.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},B([(0,n.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"bindPhoneNumber",null),B([(0,n.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"unbindProvider",null),B([(0,n.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",void 0)],o.prototype,"bindEmail",null),B([(0,n.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"verify",null),B([(0,n.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object,Object]),K("design:returntype",Promise)],o.prototype,"getVerification",null),B([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getCurrentUser",null),B([(0,n.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"signInAnonymouslyInWx",null),B([(0,n.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"bindOpenId",null),B([(0,n.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"signInWithUnionId",null),B([(0,n.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"signInWithSms",null),B([(0,n.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"signInWithEmail",null),B([(0,n.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[String]),K("design:returntype",Promise)],o.prototype,"isUsernameRegistered",null),B([(0,n.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getLoginState",null),B([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getUserInfo",null),B([(0,n.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getWedaUserInfo",null),B([(0,n.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"bindWithProvider",null),B([(0,n.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getProviderSubType",null),o}();function te(t,r){var n=this,o=t.region,i=void 0===o?"ap-shanghai":o,u=t.i18n,c=t.accessKey,l=t.useWxCloud,h=(null==r?void 0:r.platform)||d.useDefaultAdapter.bind(r)(),p=h.runtime,f=h.adapter,v=r||{},y=v.env,g=v.clientId,b=v.debug,_=v.cache,w=v.app,I=(r||{}).apiOrigin;I||(I="https://".concat(y,".").concat(i,".tcb-api.tencentcloudapi.com"));var E,A={env:y,clientId:g,i18n:u,accessKey:c,useWxCloud:l,eventBus:new s.CloudbaseEventEmitter},S=new e.CloudbaseOAuth(m(V(V({},A),{apiOrigin:I,apiPath:(null==t?void 0:t.apiPath)||e.AUTH_API_PREFIX,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud,adapter:f,onCredentialsError:(E=A.eventBus,function(t){E.fire(e.EVENTS.LOGIN_STATE_CHANGED,V(V({},t),{eventType:e.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:V({"X-SDK-Version":"@cloudbase/js-sdk/".concat(t.sdkVersion)},t.headers||{}),detectSessionInUrl:t.detectSessionInUrl,debug:b}))),O=new ee(V(V({},A),{region:i,persistence:t.persistence,debug:b,cache:_||new a.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(y)},platformInfo:h}),runtime:p||"web",_fromApp:w,oauthInstance:S}));return S.initializeSession((function(t,r){return J(n,void 0,void 0,(function(){return $(this,(function(n){return t?(t.type===e.OAUTH_TYPE.SIGN_IN?r?A.eventBus.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:V(V({},t),{error:r})}):t.user&&O.createLoginState({},{userInfo:t.user}):t.type===e.OAUTH_TYPE.BIND_IDENTITY&&A.eventBus.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:V(V({},t),{error:r})}),[2]):[2]}))}))})),{authInstance:O,oauthInstance:S}}var re={name:"auth",namespace:"auth",entity:function(t){var r=function(t){var r;if(this.authInstance&&!t)return this.authInstance;t=t||{region:"",persistence:"local",apiPath:e.AUTH_API_PREFIX};var n=this.platform.adapter,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=te(V(V({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(r=this.config.auth)||void 0===r?void 0:r.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(this.config.endPointMode||"CLOUD_API"),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),s=i.authInstance,a=i.oauthInstance;return this.oauthInstance=a,this.authInstance=s,this.authInstance},n=r.call(this,t);return Object.assign(r,n),Object.setPrototypeOf(r,Object.getPrototypeOf(n)),this.auth=r,r}};try{cloudbase.registerComponent(re)}catch(Y){}function ne(e){try{e.registerComponent(re)}catch(e){console.warn(e)}}})(),i})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):"function"==typeof define&&define.amd?define("tcbauth",["@cloudbase/oauth","@cloudbase/adapter-wx_mp"],t):"object"==typeof exports?exports.tcbauth=t(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):e.tcbauth=t(e.tcboauth,e.tcbadaptermp)}("undefined"!=typeof window?window:this,(e,t)=>(()=>{"use strict";var r={829:(e,t,r)=>{var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>s}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},105:function(e,t,r){var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(587)),c=r(894);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},587:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(829),c=r(894),d=r(652),l=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach((function(e){c.append(e,t[e])})),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,(function(){var r,n,o,u,c,d,l,h,p,f,v,y,g,m=this;return a(this,(function(b){switch(b.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,d=void 0!==c&&c,l=e.signal,h=e.timeout,p=e.shouldThrowOnError,f=void 0===p||p,v=null!=h?h:this.timeout,l&&(l.aborted&&r.abort(),l.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(m.timeoutMsg),r.abort(new Error(m.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(m,void 0,void 0,(function(){var t,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),f?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(y),f)return Promise.reject(e)}))];case 1:return g=b.sent(),[2,{data:d?g.body:(null===(t=g.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?g.json():g.text(),statusCode:g.status,header:g.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,l=void 0===u?{}:u,h=e.data,p=e.responseType,f=e.withCredentials,v=e.body,y=e.onUploadProgress,g=(0,c.formatUrl)((0,d.getProtocol)(),a,"get"===n?h:{}),m=new XMLHttpRequest;m.open(n,g),p&&(m.responseType=p),Object.keys(l).forEach((function(e){m.setRequestHeader(e,l[e])})),y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=m.status;try{e.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),m.abort()}),r.timeout)),s=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===l["content-type"]?(0,c.toQueryString)(h):v||(h?JSON.stringify(h):void 0),f&&(m.withCredentials=!0),m.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=l,t.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},652:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=("undefined"==typeof process||process.env,!1),t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},151:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},141:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(652),t),o(r(151),t),t.OATUH_LOGINTYPE="constants"},64:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(894),s=r(141),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function d(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),d=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),l=s.findIndex((function(e){return u.test(e)}));if(-1!==l){var h=s.filter((function(e,t){return t>l}));h.unshift(s[l].replace(d,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,l=void 0===a?{}:a,h=e.title,p=e.messages,f=void 0===p?[]:p;return function(e,t,a){if(s.IS_DEBUG_MODE){var p=l.className||e.constructor.name,v=l.methodName||t,y=a.value,g=function(e){var t="",r=e.stack.split("\n"),n=r.findIndex((function(e){return u.test(e)}));if(-1!==n){var o=c.exec(r[n+1]||"");t=o?o[0]:""}return t}(new Error);a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=d({err:new Error,className:p,methodName:v,sourceLink:g});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:h||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=f.map((function(e){return{type:"info",body:e}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=f.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,l;return o(this,(function(o){switch(o.label){case 0:t=d({err:new Error,className:p,methodName:v,sourceLink:g}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:h||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(l=JSON.parse(s),c.subtitle=l,l.code&&(t?(t.code=l.code,t.message=l.msg):(r.code=l.code,r.message=l.msg),n=t||r,c.content=f.map((function(e){return{type:"info",body:e}})))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=f.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},466:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(64),t)},418:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(829),u=r(894),c=r(141),d=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage);var l=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(t.root));case"none":return new d(t.root);default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(t.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();t.CloudbaseCache=l},988:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(894);var a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++){c[o].call(this,r)}}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var d=new c;t.addEventListener=function(e,t){d.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),d.fire(e,t)},t.removeEventListener=function(e,t){d.off(e,t)}},894:function(e,t,r){var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(141);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""};t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var d=0,l=s;d<l.length;d++){var h=l[d],p=h.type,f=h.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)};t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86".concat(e)};t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},219:e=>{e.exports=t},297:t=>{t.exports=e}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e].call(i.exports,i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{Auth:()=>ee,LoginState:()=>Z,User:()=>X,generateAuthInstance:()=>te,registerAuth:()=>ne});var e=o(297),t=o(894),r=o(141),n=o(466),s=o(988),a=o(418),u=o(219),c=o.n(u),d=o(105),l=function(){return(l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},h=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},p=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},f=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return h(this,void 0,void 0,(function(){return p(this,(function(t){return[2,this.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return h(this,void 0,void 0,(function(){return p(this,(function(t){return this.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return h(this,void 0,void 0,(function(){return p(this,(function(r){return this.localStorage.setItem(e,t),[2]}))}))},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),v=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,y=function(e,t){var r,n,o,i,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,v.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}};var g=function(e,t){var r=l({},e),n={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!c().isMatch()||e.storage&&e.baseRequest)return r;try{var o=c().genAdapter({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new f({localStorage:i,adapter:t})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(e){return function(t,r){return h(this,void 0,void 0,(function(){return p(this,(function(n){return[2,new Promise((function(n,o){var i=Object.assign({},r);i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body));var s=wx.request({url:t,data:i.body,timeout:e._timeout,method:i.method||"GET",header:i.headers,success:function(e){(e=y(e,l(l({},r),{url:t}))).error&&o(e),n(e)},fail:function(e){o({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{s.abort()}catch(e){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),l(l({},r),n)}catch(e){console.error("adapter generate fail:",e)}return r},m=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=l({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new f({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var n=new t.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(e,t){var r,o,i,s,a;return h(this,void 0,void 0,(function(){var u,c,d,h;return p(this,(function(p){switch(p.label){case 0:if(u={},c=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(d=null===(i=null===(o=null==n?void 0:n[c])||void 0===o?void 0:o.bind)||void 0===i?void 0:i.call(o,n)))throw new Error("invalid 【".concat(c,"】 request method"));p.label=1;case 1:return p.trys.push([1,3,,4]),(null===(s=t.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=t.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,d(l({url:e},t))];case 2:return u=p.sent(),u=y(u,l(l({},t),{url:e})),[3,4];case 3:throw h=p.sent(),u=l(l({},null==h?void 0:h.data),h);case 4:if(null==u?void 0:u.error)throw u;return[2,u]}}))}))}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):g(e,e.adapter)};var b="@cloudbase/js-sdk";function _(){return b}var w="https:";"undefined"==typeof process||process.env;var I="INVALID_PARAMS",A="INVALID_OPERATION",E="OPERATION_FAIL",S=o(829);function O(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}function T(e,t){console.warn("[".concat(_(),"][").concat(e,"]:").concat(t))}var P,U=(P=function(e,t){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}P(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),k=function(){return(k=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},C=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},N=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};!function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}U(t,e),t.prototype.get=function(e){return this.request(k(k({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(k(k({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(k(k({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,i=e.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===a?(Object.keys(t).forEach((function(e){u.append(e,t[e])})),u.append("key",n),u.append("file",r),this.request(k(k({},e),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(k(k({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return C(this,void 0,void 0,(function(){var t,r,n,o;return N(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(k(k({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return C(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d,l,h,p,f,v=this;return N(this,(function(y){switch(y.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,i=void 0!==o&&o,s=e.stream,a=void 0!==s&&s,u=e.signal,c=e.timeout,d=e.shouldThrowOnError,l=void 0===d||d,h=null!=c?c:this.timeout,u&&(u.aborted&&r.abort(),u.addEventListener("abort",(function(){return r.abort()}))),p=null,i&&h&&(p=setTimeout((function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))}),h)),[4,fetch(n,k(k({},e),{signal:r.signal})).then((function(e){return C(v,void 0,void 0,(function(){var t,r,n;return N(this,(function(o){switch(o.label){case 0:return clearTimeout(p),l?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(p),l)return Promise.reject(e)}))];case 1:return f=y.sent(),[2,{data:a?f.body:(null===(t=f.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?f.json():f.text(),statusCode:f.status,header:f.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a,u=e.url,c=e.headers,d=void 0===c?{}:c,l=e.data,h=e.responseType,p=e.withCredentials,f=e.body,v=e.onUploadProgress,y=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)}(w,u,"get"===n?l:{}),g=new XMLHttpRequest;g.open(n,y),h&&(g.responseType=h),Object.keys(d).forEach((function(e){g.setRequestHeader(e,d[e])})),v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=g.status;try{e.data="blob"===h?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===h?g.response:g.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),a=l,s="[object FormData]"===Object.prototype.toString.call(a)?l:"application/x-www-form-urlencoded"===d["content-type"]?function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")}(l):f||(l?JSON.stringify(l):void 0),p&&(g.withCredentials=!0),g.send(s)}))}}(S.AbstractSDKRequest);var L;!function(e){e.WEB="web",e.WX_MP="wx_mp"}(L||(L={}));var R=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),x=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},j=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},M=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return R(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(S.AbstractStorage);!function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":return t.localStorage?t.localStorage:(T(I,"localStorage is not supported on current platform"),new M(t.root));case"none":return new M(t.root);default:return t.localStorage?t.localStorage:(T(I,"localStorage is not supported on current platform"),new M(t.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:E,msg:"[".concat(_(),"][").concat(E,"]setStore failed"),info:e}))}}else T(A,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return x(this,void 0,void 0,(function(){var n;return j(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}T(A,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return x(this,void 0,void 0,(function(){var n;return j(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):T(A,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return x(this,void 0,void 0,(function(){return j(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))}}();var D=function(){var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),q=function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};var W=function(e,t){this.data=t||null,this.name=e},H=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return D(t,e),t}(W),G=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(e instanceof H)return console.error(e.error),this;var r="string"==typeof e?new W(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?q([],this.listeners[n],!0):[];o<i.length;o++){i[o].call(this,r)}}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();new G;new G;"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");!function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,r){"abort"===t&&e.listeners.push(r)}}}e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(e){return e()})))}}();function Y(e){this.message=e}Y.prototype=new Error,Y.prototype.name="InvalidCharacterError";"undefined"!=typeof window&&window.atob&&window.atob.bind(window);function F(e){this.message=e}F.prototype=new Error,F.prototype.name="InvalidTokenError";var V=function(){return(V=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},B=function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},K=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},J=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},$=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},Q=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},z=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},X=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}return e.prototype.checkLocalInfo=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return J(this,void 0,void 0,(function(){var e,t,r,n;return $(this,(function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},e.prototype.update=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(V({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}}))}))},e.prototype.updateUserBasicInfo=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(V({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,t.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}}))}))},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}}))}))},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at"].forEach((function(t){e[t]=r[t]}))},B([(0,n.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],e.prototype,"update",null),B([(0,n.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[String,String]),K("design:returntype",void 0)],e.prototype,"updatePassword",null),B([(0,n.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[String]),K("design:returntype",void 0)],e.prototype,"updateUsername",null),B([(0,n.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],e.prototype,"refresh",null),e}(),Z=function(){function e(e){var n=e.envId,o=e.cache,i=e.oauthInstance;n||(0,t.throwError)(r.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=o,this.oauthInstance=i,this.user=new X({cache:this.cache,oauthInstance:i})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}}))}))},e}(),ee=function(){function o(e){this.listeners=new Map,this.hasListenerSetUp=!1,this.config=e,this.oauthInstance=e.oauthInstance,this.cache=e.cache,this.init(),this.setAccessKey()}return o.prototype.bindPhoneNumber=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.editContact(e)]}))}))},o.prototype.unbindProvider=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]}))}))},o.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},o.prototype.verify=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.verify(e)]}))}))},o.prototype.getVerification=function(e,t){return J(this,void 0,void 0,(function(){return $(this,(function(r){return[2,this.oauthInstance.authApi.getVerification(e,t)]}))}))},Object.defineProperty(o.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,t.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),o.prototype.getCurrentUser=function(){return J(this,void 0,void 0,(function(){var e,t;return $(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?(t=e.user.getLocalUserInfo(),[4,e.user.checkLocalInfoAsync()]):[3,3];case 2:return r.sent(),[2,V(V({},e.user),t)];case 3:return[2,null]}}))}))},o.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return J(this,void 0,void 0,(function(){var e,r,n=this;return $(this,(function(o){switch(o.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return J(n,void 0,void 0,(function(){var n,o;return $(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}}))}))},[4,new Promise((function(e,t){wx.login({success:function(o){return J(n,void 0,void 0,(function(){var n;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}}))}))},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},o.prototype.bindOpenId=function(){return J(this,void 0,void 0,(function(){var e,t,r=this;return $(this,(function(n){switch(n.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return J(r,void 0,void 0,(function(){var r;return $(this,(function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}}))}))},[4,new Promise((function(e,n){wx.login({success:function(o){return J(r,void 0,void 0,(function(){var r;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})}))];case 1:return n.sent(),[2]}}))}))},o.prototype.signInWithUnionId=function(){return J(this,void 0,void 0,(function(){var e=this;return $(this,(function(t){switch(t.label){case 0:if(!c().isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise((function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return J(e,void 0,void 0,(function(){var e,i,s,a,u;return $(this,(function(c){switch(c.label){case 0:e=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}}))}))},o.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a;return J(this,void 0,void 0,(function(){return $(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(e){throw e}return[2]}))}))},o.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,u=void 0===a?"":a;return J(this,void 0,void 0,(function(){return $(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(e){throw e}return[2]}))}))},o.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},o.prototype.signIn=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},o.prototype.setPassword=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.setPassword(e)]}))}))},o.prototype.isUsernameRegistered=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&(0,t.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,n.sent().exist]}}))}))},o.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new Z({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,t.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},o.prototype.getLoginState=function(){return J(this,void 0,void 0,(function(){var e;return $(this,(function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new Z({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},o.prototype.getUserInfo=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.getCurrentUser()]}))}))},o.prototype.getWedaUserInfo=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},o.prototype.updateUserBasicInfo=function(e){return J(this,void 0,void 0,(function(){var t;return $(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},o.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},o.prototype.bindWithProvider=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]}))}))},o.prototype.queryUser=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]}))}))},o.prototype.getAccessToken=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}}))}))},o.prototype.grantProviderToken=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]}))}))},o.prototype.patchProviderToken=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]}))}))},o.prototype.signInWithProvider=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},o.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},o.prototype.grantToken=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},o.prototype.genProviderRedirectUri=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]}))}))},o.prototype.resetPassword=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]}))}))},o.prototype.deviceAuthorize=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]}))}))},o.prototype.sudo=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.sudo(e)]}))}))},o.prototype.deleteMe=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]}))}))},o.prototype.getProviders=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getProviders()]}))}))},o.prototype.loginScope=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.loginScope()]}))}))},o.prototype.loginGroups=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},o.prototype.onLoginStateChanged=function(t){var r;return J(this,void 0,void 0,(function(){var n,o=this;return $(this,(function(i){switch(i.label){case 0:return null===(r=this.config.eventBus)||void 0===r||r.on(e.EVENTS.LOGIN_STATE_CHANGED,(function(r){return J(o,void 0,void 0,(function(){var n,o,i;return $(this,(function(s){switch(s.label){case 0:return(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.eventType)===e.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return o=s.sent(),[3,3];case 2:o={},s.label=3;case 3:return n=o,t.call(this,V(V({},r),n)),[2]}}))}))})),[4,this.getLoginState()];case 1:return n=i.sent(),t.call(this,n),[2]}}))}))},o.prototype.refreshTokenForce=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]}))}))},o.prototype.getCredentials=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},o.prototype.setCredentials=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}}))}))},o.prototype.getProviderSubType=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},o.prototype.createCaptchaData=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]}))}))},o.prototype.verifyCaptchaData=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]}))}))},o.prototype.getMiniProgramQrCode=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]}))}))},o.prototype.getMiniProgramQrCodeStatus=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]}))}))},o.prototype.modifyPassword=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]}))}))},o.prototype.modifyPasswordWithoutLogin=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]}))}))},o.prototype.getUserBehaviorLog=function(e){return J(this,void 0,void 0,(function(){return $(this,(function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]}))}))},o.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.username,s=void 0===i?"":i,a=e.bindInfo,u=void 0===a?void 0:a,c=e.loginType,d=void 0===c?"":c;return J(this,void 0,void 0,(function(){var e,t,n,i,a,c,l;return $(this,(function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=h.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=/^\+\d{1,3}\s+/.test(s)?s:"+86 ".concat(s),i={phone_number:n},"email"===d&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(a=h.sent())?void 0:a.error_code)throw a;return u?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==u?void 0:u.providerToken})]:[3,4];case 3:if(null==(c=h.sent())?void 0:c.error_code)throw c;h.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(V(V({},i),{verification_token:t,provider_token:null==u?void 0:u.providerId}))];case 6:if(null==(l=h.sent())?void 0:l.error_code)throw l;h.label=7;case 7:return[2,this.createLoginState()];case 8:throw h.sent();case 9:return[2]}}))}))},o.prototype.createLoginState=function(t,r){var n,o;return J(this,void 0,void 0,(function(){var i;return $(this,(function(s){switch(s.label){case 0:return[4,(i=new Z({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return s.sent(),(null==r?void 0:r.userInfo)?(i.user.setLocalUserInfo(r.userInfo),[3,5]):[3,2];case 2:return(null==r?void 0:r.asyncRefreshUser)?(i.user.refresh(t),[3,5]):[3,3];case 3:return[4,i.user.refresh(t)];case 4:s.sent(),s.label=5;case 5:return null===(n=this.config.eventBus)||void 0===n||n.fire(e.EVENTS.LOGIN_STATE_CHANGED,{eventType:e.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(o=this.config.eventBus)||void 0===o||o.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,i]}}))}))},o.prototype.setAccessKey=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){if(this.config.accessKey)try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:this.config.accessKey,token_type:"Bearer",scope:"accessKey",expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]}))}))},o.prototype.signInAnonymously=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return s.sent(),[4,this.createLoginState()];case 2:return r=s.sent(),[4,this.getSession()];case 3:return n=s.sent().data,o=(void 0===n?{}:n).session,[2,V(V({},r),{data:{user:o.user,session:o},error:null})];case 4:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 5:return[2]}}))}))},o.prototype.signUp=function(t){return J(this,void 0,void 0,(function(){var r,n,o=this;return $(this,(function(i){switch(i.label){case 0:return t.phone_number||t.verification_code||t.verification_token||t.provider_token?[4,this.oauthInstance.authApi.signUp(t)]:[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)})];case 3:return r=i.sent(),[2,{data:{verifyOtp:function(n){var i=n.token,s=n.messageId,a=void 0===s?r.verification_id:s;return J(o,void 0,void 0,(function(){var n,o,s,u,c;return $(this,(function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.verify({verification_id:a||r.verification_id,verification_code:i})];case 1:return n=d.sent(),r.is_user?[4,this.signIn({username:t.email||this.formatPhone(t.phone),verification_token:n.verification_token})]:[3,3];case 2:return d.sent(),[3,6];case 3:return delete(o=JSON.parse(JSON.stringify(t))).email,delete o.phone,[4,this.oauthInstance.authApi.signUp(V(V(V({},o),t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)}),{verification_token:n.verification_token,verification_code:i}))];case 4:return d.sent(),[4,this.createLoginState()];case 5:d.sent(),d.label=6;case 6:return[4,this.getSession()];case 7:return s=d.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return c=d.sent(),[2,{data:{},error:new e.AuthError(c)}];case 9:return[2]}}))}))}},error:null}];case 4:return n=i.sent(),[2,{data:{},error:new e.AuthError(n)}];case 5:return[2]}}))}))},o.prototype.signOut=function(t){var r,n;return J(this,void 0,void 0,(function(){var o,i,s;return $(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),o=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return i=a.sent(),[4,this.cache.removeStoreAsync(o)];case 2:return a.sent(),this.setAccessKey(),null===(r=this.config.eventBus)||void 0===r||r.fire(e.EVENTS.LOGIN_STATE_CHANGED,{eventType:e.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(n=this.config.eventBus)||void 0===n||n.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,V(V({},i),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new e.AuthError(s)}];case 4:return[2]}}))}))},o.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},o.prototype.signInWithPassword=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateAtLeastOne(t,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(V({username:t.username||t.email||this.formatPhone(t.phone),password:t.password},t.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.signInWithIdToken=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(t,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:t.token})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.signInWithOtp=function(t){return J(this,void 0,void 0,(function(){var r,n,o=this;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)})];case 1:return r=i.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var n=e.token,i=e.messageId,s=void 0===i?r.verification_id:i;return J(o,void 0,void 0,(function(){return $(this,(function(e){return[2,this.verifyOtp({email:t.email,phone:t.phone,token:n,messageId:s})]}))}))}},error:null}];case 2:return n=i.sent(),[2,{data:{},error:new e.AuthError(n)}];case 3:return[2]}}))}))},o.prototype.verifyOAuth=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d;return $(this,(function(l){switch(l.label){case 0:r={},l.label=1;case 1:return l.trys.push([1,7,,8]),n=(null==t?void 0:t.code)||O("code"),o=(null==t?void 0:t.state)||O("state"),n?o?(i=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}}(o),r.type=null==i?void 0:i.type,(s=(null==t?void 0:t.provider)||(null==i?void 0:i.provider)||O("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:n})]:[2,{data:r,error:new e.AuthError({message:"Provider is required"})}]):[2,{data:{},error:new e.AuthError({message:"State is required"})}]:[2,{data:{},error:new e.AuthError({message:"Code is required"})}];case 2:return a=l.sent().provider_token,u=void 0,i.type!==e.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=l.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=l.sent()).data=V(V({},r),u.data),l.label=6;case 6:return(c=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),c.delete("state"),function(e,t){if(void 0!==e){var r=new URL(window.location.href);r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href)}}(void 0===(null==i?void 0:i.search)?"?".concat(c.toString()):null==i?void 0:i.search,(null==i?void 0:i.hash)||location.hash),function(e){try{sessionStorage.removeItem(e)}catch(e){return console.error("Failed to remove browser session:",e),null}}(o),[2,u];case 7:return d=l.sent(),[2,{data:r,error:new e.AuthError(d)}];case 8:return[2]}}))}))},o.prototype.signInWithOAuth=function(t){var r,n,o,i,s;return J(this,void 0,void 0,(function(){var a,u,c,d,l,h,p,f,v;return $(this,(function(y){switch(y.label){case 0:return y.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),a=(null===(r=t.options)||void 0===r?void 0:r.redirectTo)||location.href,u=new URL(a),c=u.origin+u.pathname,d=(null===(n=t.options)||void 0===n?void 0:n.state)||"prd-".concat(t.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:t.provider,provider_redirect_uri:c,state:d})];case 1:return l=y.sent().uri,h=decodeURIComponent(l),p=h,(null===(o=t.options)||void 0===o?void 0:o.queryParams)&&(f=new URL(h),Object.entries(t.options.queryParams).forEach((function(e){var t=e[0],r=e[1];f.searchParams.set(t,r)})),p=f.toString()),function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}}(d,{provider:t.provider,search:u.search,hash:u.hash,type:(null===(i=t.options)||void 0===i?void 0:i.type)||e.OAUTH_TYPE.SIGN_IN}),z()&&!(null===(s=t.options)||void 0===s?void 0:s.skipBrowserRedirect)&&window.location.assign(p),[2,{data:{url:p,provider:t.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new e.AuthError(v)}];case 3:return[2]}}))}))},o.prototype.getClaims=function(){return J(this,void 0,void 0,(function(){var t,r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return t=n.sent().accessToken,[2,{data:(0,e.weAppJwtDecodeAll)(t),error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.resetPasswordForEmail=function(t,r){return J(this,void 0,void 0,(function(){var n,o,i,s,a,u,c=this;return $(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),this.validateParams({emailOrPhone:t},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),n=(r||{}).redirectTo,o=t.includes("@"),i=void 0,o?i={email:t}:(s=this.formatPhone(t),i={phone_number:s}),[4,this.getVerification(i)];case 1:return a=d.sent(),[2,{data:{updateUser:function(r){return J(c,void 0,void 0,(function(){var i,s,u,c;return $(this,(function(d){switch(d.label){case 0:this.validateParams(r,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),d.label=1;case 1:return d.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:r.nonce})];case 2:return i=d.sent(),[4,this.oauthInstance.authApi.resetPassword({email:o?t:void 0,phone_number:o?void 0:t,new_password:r.password,verification_token:i.verification_token})];case 3:return d.sent(),null===(c=this.config.eventBus)||void 0===c||c.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:o?t:void 0,phone:o?void 0:t,password:r.password})];case 4:return s=d.sent(),n&&z()&&window.location.assign(n),[2,s];case 5:return u=d.sent(),[2,{data:{},error:new e.AuthError(u)}];case 6:return[2]}}))}))}},error:null}];case 2:return u=d.sent(),[2,{data:{},error:new e.AuthError(u)}];case 3:return[2]}}))}))},o.prototype.resetPasswordForOld=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:t.old_password,new_password:t.new_password})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.verifyOtp=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),r=t.type,this.validateParams(t,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(r)?[4,this.verify({verification_id:t.messageId,verification_code:t.token})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:t.messageId,is_user:!0},verificationCode:t.token,username:t.email||this.formatPhone(t.phone)||"",loginType:t.email?"email":"phone"})];case 3:s.sent(),s.label=4;case 4:return[4,this.getSession()];case 5:return n=s.sent().data,[2,{data:{user:(o=(void 0===n?{}:n).session).user,session:o},error:null}];case 6:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 7:return[2]}}))}))},o.prototype.getSession=function(){return J(this,void 0,void 0,(function(){var t,r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=i.sent())&&"accessKey"!==t.scope?[4,this.getUser()]:[2,{data:{session:null},error:null}];case 2:return r=i.sent().data,n=(void 0===r?{}:r).user,[2,{data:{session:V(V({},t),{user:n}),user:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.refreshSession=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i,s;return $(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(r=a.sent()).refresh_token=t||r.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(r)];case 2:return n=a.sent(),[4,this.getUser()];case 3:return o=a.sent().data,[2,{data:{user:i=(void 0===o?{}:o).user,session:V(V({},n),{user:i})},error:null}];case 4:return s=a.sent(),[2,{data:{},error:new e.AuthError(s)}];case 5:return[2]}}))}))},o.prototype.getUser=function(){return J(this,void 0,void 0,(function(){var t,r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=this.convertToUser,[4,this.getUserInfo()];case 1:return[2,{data:{user:t.apply(this,[n.sent()])},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.refreshUser=function(){return J(this,void 0,void 0,(function(){var t,r,n;return $(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new e.AuthError(n)}];case 4:return[2]}}))}))},o.prototype.updateUser=function(t){var r;return J(this,void 0,void 0,(function(){var n,o,i,s,a,u,c,d,l,h,p,f,v=this;return $(this,(function(y){switch(y.label){case 0:if(y.trys.push([0,8,,9]),!Object.keys(t).some((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})))throw new e.AuthError({message:"At least one field must be provided for update"});return n=t.email,o=t.phone,i=Q(t,["email","phone"]),a=void 0!==o,u={},(s=void 0!==n)||a?(c=void 0,s?(c={email:t.email},d="email_change"):(l=this.formatPhone(t.phone),c={phone_number:l},d="phone_change"),[4,this.getVerification(c)]):[3,4];case 1:return h=y.sent(),Object.keys(i).length>0?[4,this.updateUserBasicInfo(i)]:[3,3];case 2:y.sent(),y.label=3;case 3:return u={messageId:h.verification_id,verifyOtp:function(r){return J(v,void 0,void 0,(function(){var n,o,i;return $(this,(function(a){switch(a.label){case 0:return a.trys.push([0,11,,12]),r.email&&t.email===r.email?[4,this.verifyOtp({type:"email_change",email:t.email,token:r.token,messageId:h.verification_id})]:[3,3];case 1:return a.sent(),[4,this.updateUserBasicInfo({email:t.email})];case 2:return a.sent(),[3,9];case 3:return r.phone&&t.phone===r.phone?[4,this.verifyOtp({type:"phone_change",phone:t.phone,token:r.token,messageId:h.verification_id})]:[3,6];case 4:return a.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(t.phone)})];case 5:return a.sent(),[3,9];case 6:return[4,this.verifyOtp({type:d,email:s?t.email:void 0,phone:s?void 0:t.phone,token:r.token,messageId:h.verification_id})];case 7:return a.sent(),[4,this.updateUserBasicInfo(t)];case 8:a.sent(),a.label=9;case 9:return[4,this.getUser()];case 10:return n=a.sent().data.user,null===(i=this.config.eventBus)||void 0===i||i.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return o=a.sent(),[2,{data:{},error:new e.AuthError(o)}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(t)];case 5:y.sent(),y.label=6;case 6:return[4,this.getUser()];case 7:return p=y.sent().data.user,null===(r=this.config.eventBus)||void 0===r||r.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:V({user:p},u),error:null}];case 8:return f=y.sent(),[2,{data:{},error:new e.AuthError(f)}];case 9:return[2]}}))}))},o.prototype.getUserIdentities=function(){var t;return J(this,void 0,void 0,(function(){var r,n;return $(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return r=o.sent(),[2,{data:{identities:null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.filter((function(e){return!!e.bind}))},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new e.AuthError(n)}];case 3:return[2]}}))}))},o.prototype.linkIdentity=function(t){return J(this,void 0,void 0,(function(){var r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:t.provider,options:{type:e.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return n.sent(),[2,{data:{provider:t.provider},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.unlinkIdentity=function(t){return J(this,void 0,void 0,(function(){var r;return $(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:t.provider})];case 1:return n.sent(),[2,{data:{},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new e.AuthError(r)}];case 3:return[2]}}))}))},o.prototype.reauthenticate=function(){return J(this,void 0,void 0,(function(){var t,r,n,o,i=this;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser()];case 1:return t=s.sent().data.user,this.validateAtLeastOne(t,[["email","phone"]],"You must provide either an email or phone number"),r=t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)},[4,this.getVerification(r)];case 2:return n=s.sent(),[2,{data:{updateUser:function(t){return J(i,void 0,void 0,(function(){var o,i,s,a,u;return $(this,(function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),t.password?[4,this.verify({verification_id:n.verification_id,verification_code:t.nonce})]:[3,5];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:o.verification_token})];case 3:return i=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:t.password,sudo_token:i.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(V(V({verificationInfo:n,verificationCode:t.nonce},r),{loginType:r.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{},error:new e.AuthError(u)}];case 10:return[2]}}))}))}},error:null}];case 3:return o=s.sent(),[2,{data:{},error:new e.AuthError(o)}];case 4:return[2]}}))}))},o.prototype.resend=function(t){return J(this,void 0,void 0,(function(){var r,n,o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),r="signup"===t.type?"ANY":"USER",n={target:r},"email"in t&&(n.email=t.email),"phone"in t&&(n.phone_number=this.formatPhone(t.phone)),[4,this.oauthInstance.authApi.getVerification(n)];case 1:return[2,{data:{messageId:i.sent().verification_id},error:null}];case 2:return o=i.sent(),[2,{data:{},error:new e.AuthError(o)}];case 3:return[2]}}))}))},o.prototype.setSession=function(t){var r;return J(this,void 0,void 0,(function(){var n,o,i;return $(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),this.validateParams(t,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(t,{throwError:!0})];case 1:return s.sent(),[4,this.getSession()];case 2:return n=s.sent().data,o=(void 0===n?{}:n).session,null===(r=this.config.eventBus)||void 0===r||r.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:o.user,session:o},error:null}];case 3:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 4:return[2]}}))}))},o.prototype.exchangeCodeForSession=function(){return J(this,void 0,void 0,(function(){return $(this,(function(e){return[2]}))}))},o.prototype.deleteUser=function(t){return J(this,void 0,void 0,(function(){var r,n;return $(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(t)];case 1:return r=o.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:r})];case 2:return o.sent(),[2,{data:{},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new e.AuthError(n)}];case 4:return[2]}}))}))},o.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),J(this,void 0,void 0,(function(){var r,n,o,i,s;return $(this,(function(a){try{return r=t.config_version||"env",n=Object.keys(t.query||{}).map((function(e){return"".concat(e,"=").concat(t.query[e])})).join("&"),c().isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(n?"?".concat(n):"")}):(o=t.redirect_uri||window.location.href,i=new URL(o),s="".concat(i.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(r,"&redirect_uri=").concat(encodeURIComponent(o)).concat(n?"&".concat(n):""),window.location.href=s),[2,{data:{},error:null}]}catch(t){return[2,{data:{},error:new e.AuthError(t)}]}return[2]}))}))},o.prototype.signInWithCustomTicket=function(t){return J(this,void 0,void 0,(function(){var r,n,o,i;return $(this,(function(s){switch(s.label){case 0:t&&this.setCustomSignFunc(t),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return r=s.sent(),[4,this.getSession()];case 4:return n=s.sent().data,o=(void 0===n?{}:n).session,[2,V(V({},r),{data:{user:o.user,session:o},error:null})];case 5:return i=s.sent(),[2,{data:{},error:new e.AuthError(i)}];case 6:return[2]}}))}))},o.prototype.signInWithOpenId=function(t){var r=(void 0===t?{}:t).useWxCloud,n=void 0===r||r;return J(this,void 0,void 0,(function(){var t,r,o,i,s,a,u=this;return $(this,(function(d){switch(d.label){case 0:if(!c().isMatch())throw Error("wx api undefined");t=wx.getAccountInfoSync().miniProgram,r=function(e){return J(u,void 0,void 0,(function(){var r,o;return $(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},d.label=1;case 1:return d.trys.push([1,5,,6]),[4,new Promise((function(e,t){wx.login({success:function(n){return J(u,void 0,void 0,(function(){var o;return $(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),t(o),[3,3];case 3:return[2]}}))}))},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})}))];case 2:return d.sent(),[4,this.createLoginState()];case 3:return o=d.sent(),[4,this.getSession()];case 4:return i=d.sent().data,s=(void 0===i?{}:i).session,[2,V(V({},o),{data:{user:s.user,session:s},error:null})];case 5:return a=d.sent(),[2,{data:{},error:new e.AuthError(a)}];case 6:return[2]}}))}))},o.prototype.signInWithPhoneAuth=function(t){var r=t.phoneCode,n=void 0===r?"":r;return J(this,void 0,void 0,(function(){var t,r,o,i,s,a,u,d,l;return $(this,(function(h){switch(h.label){case 0:return c().isMatch()?(t=wx.getAccountInfoSync().miniProgram,r={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()]):[2,{data:{},error:new e.AuthError({message:"wx api undefined"})}];case 1:o=h.sent().code,r.provider_code=o,h.label=2;case 2:return h.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(r)];case 3:if((i=h.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:i.provider_token,provider_id:t.appId,provider_params:{code:n,provider_code_type:"phone"}})];case 4:if((i=h.sent()).error_code)throw i;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:i.provider_token})];case 5:if(null==(s=h.sent())?void 0:s.error_code)throw s;return[3,7];case 6:return a=h.sent(),[2,{data:{},error:new e.AuthError(a)}];case 7:return[4,this.createLoginState()];case 8:return u=h.sent(),[4,this.getSession()];case 9:return d=h.sent().data,l=(void 0===d?{}:d).session,[2,V(V({},u),{data:{user:l.user,session:l},error:null})]}}))}))},o.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},o.prototype.notifyListeners=function(e,t,r){this.listeners.forEach((function(n){n.forEach((function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}}))}))},o.prototype.setupListeners=function(){var t,r=this;null===(t=this.config.eventBus)||void 0===t||t.on(e.EVENTS.AUTH_STATE_CHANGED,(function(e){return J(r,void 0,void 0,(function(){var t,r,n,o,i;return $(this,(function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}}))}))}))},o.prototype.convertToUser=function(e){var t,r,n;if(!e)return null;var o=(null==e?void 0:e.email)||"",i=(null==e?void 0:e.phone_number)||"",s=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:s,aud:"authenticated",role:e.groups.map((function(e){return"string"==typeof e?e:e.id})),email:o||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:i,phone_confirmed_at:i?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(t=e.loginType)||void 0===t?void 0:t.toLowerCase())||"cloudbase",providers:[(null===(r=e.loginType)||void 0===r?void 0:r.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName,avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:e.hasPassword},identities:(null===(n=null==e?void 0:e.providers)||void 0===n?void 0:n.map((function(t){return{id:t.id||"",identity_id:t.id||"",user_id:s,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}})))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},o.prototype.validateParams=function(t,r){for(var n=0,o=Object.entries(r);n<o.length;n++){var i=o[n],s=i[0],a=i[1];if(a.required&&(void 0===(null==t?void 0:t[s])||null===(null==t?void 0:t[s])||""===(null==t?void 0:t[s])))throw new e.AuthError({message:a.message})}},o.prototype.validateAtLeastOne=function(t,r,n){if(!r.some((function(e){return e.some((function(e){return void 0!==(null==t?void 0:t[e])&&null!==(null==t?void 0:t[e])&&""!==(null==t?void 0:t[e])}))})))throw new e.AuthError({message:n})},o.prototype.init=function(){var t;return J(this,void 0,void 0,(function(){return $(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return r.sent()&&(null===(t=this.config.eventBus)||void 0===t||t.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return r.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},B([(0,n.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"bindPhoneNumber",null),B([(0,n.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"unbindProvider",null),B([(0,n.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",void 0)],o.prototype,"bindEmail",null),B([(0,n.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"verify",null),B([(0,n.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object,Object]),K("design:returntype",Promise)],o.prototype,"getVerification",null),B([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getCurrentUser",null),B([(0,n.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"signInAnonymouslyInWx",null),B([(0,n.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"bindOpenId",null),B([(0,n.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"signInWithUnionId",null),B([(0,n.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"signInWithSms",null),B([(0,n.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"signInWithEmail",null),B([(0,n.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[String]),K("design:returntype",Promise)],o.prototype,"isUsernameRegistered",null),B([(0,n.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getLoginState",null),B([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getUserInfo",null),B([(0,n.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getWedaUserInfo",null),B([(0,n.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[Object]),K("design:returntype",Promise)],o.prototype,"bindWithProvider",null),B([(0,n.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),K("design:type",Function),K("design:paramtypes",[]),K("design:returntype",Promise)],o.prototype,"getProviderSubType",null),o}();function te(t,r){var n=this,o=t.region,i=void 0===o?"ap-shanghai":o,u=t.i18n,c=t.accessKey,l=t.useWxCloud,h=(null==r?void 0:r.platform)||d.useDefaultAdapter.bind(r)(),p=h.runtime,f=h.adapter,v=r||{},y=v.env,g=v.clientId,b=v.debug,_=v.cache,w=v.app,I=(r||{}).apiOrigin;I||(I="https://".concat(y,".").concat(i,".tcb-api.tencentcloudapi.com"));var A,E={env:y,clientId:g,i18n:u,accessKey:c,useWxCloud:l,eventBus:new s.CloudbaseEventEmitter},S=new e.CloudbaseOAuth(m(V(V({},E),{apiOrigin:I,apiPath:(null==t?void 0:t.apiPath)||e.AUTH_API_PREFIX,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud,adapter:f,onCredentialsError:(A=E.eventBus,function(t){A.fire(e.EVENTS.LOGIN_STATE_CHANGED,V(V({},t),{eventType:e.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:V({"X-SDK-Version":"@cloudbase/js-sdk/".concat(t.sdkVersion)},t.headers||{}),detectSessionInUrl:t.detectSessionInUrl,debug:b}))),O=new ee(V(V({},E),{region:i,persistence:t.persistence,debug:b,cache:_||new a.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(y)},platformInfo:h}),runtime:p||"web",_fromApp:w,oauthInstance:S}));return S.initializeSession((function(t,r){return J(n,void 0,void 0,(function(){return $(this,(function(n){return t?(t.type===e.OAUTH_TYPE.SIGN_IN?r?E.eventBus.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:V(V({},t),{error:r})}):t.user&&O.createLoginState({},{userInfo:t.user}):t.type===e.OAUTH_TYPE.BIND_IDENTITY&&E.eventBus.fire(e.EVENTS.AUTH_STATE_CHANGED,{event:e.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:V(V({},t),{error:r})}),[2]):[2]}))}))})),{authInstance:O,oauthInstance:S}}var re={name:"auth",namespace:"auth",entity:function(t){var r=function(t){var r;if(this.authInstance&&!t)return this.authInstance;t=t||{region:"",persistence:"local",apiPath:e.AUTH_API_PREFIX};var n=this.platform.adapter,o=t.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=te(V(V({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(r=this.config.auth)||void 0===r?void 0:r.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(this.config.endPointMode||"CLOUD_API"),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),s=i.authInstance,a=i.oauthInstance;return this.oauthInstance=a,this.authInstance=s,this.authInstance},n=r.call(this,t);return Object.assign(r,n),Object.setPrototypeOf(r,Object.getPrototypeOf(n)),this.auth=r,r}};try{cloudbase.registerComponent(re)}catch(Y){}function ne(e){try{e.registerComponent(re)}catch(e){console.warn(e)}}})(),i})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/auth",
3
- "version": "2.25.3",
3
+ "version": "2.25.4",
4
4
  "description": "cloudbase javascript sdk auth componets",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -32,14 +32,14 @@
32
32
  "license": "Apache-2.0",
33
33
  "dependencies": {
34
34
  "@cloudbase/adapter-wx_mp": "^1.2.1",
35
- "@cloudbase/oauth": "2.25.3",
36
- "@cloudbase/utilities": "2.25.3"
35
+ "@cloudbase/oauth": "2.25.4",
36
+ "@cloudbase/utilities": "2.25.4"
37
37
  },
38
38
  "devDependencies": {
39
- "@cloudbase/types": "2.25.3",
39
+ "@cloudbase/types": "2.25.4",
40
40
  "@types/node": "^22.1.0",
41
41
  "terser-webpack-plugin": "^3.0.2",
42
42
  "webpack-bundle-analyzer": "^4.9.1"
43
43
  },
44
- "gitHead": "2bf2f90d89b7e9b2a4bd232836f32b5f46868bb5"
44
+ "gitHead": "cb3b43f79a34d6216a45f065ab940c4225fe55d5"
45
45
  }