@cloudbase/auth 2.24.5 → 2.24.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/adapter.js +3 -3
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/type.d.ts +1 -1
- package/dist/cjs/type.js +1 -1
- package/dist/esm/adapter.js +3 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/type.d.ts +1 -1
- package/dist/esm/type.js +1 -1
- package/dist/miniprogram/index.js +1 -1
- package/package.json +5 -5
- package/src/adapter.ts +2 -2
- package/src/index.ts +1 -0
- package/src/type.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):"function"==typeof define&&define.amd?define("tcbauth",["@cloudbase/oauth","@cloudbase/adapter-wx_mp"],e):"object"==typeof exports?exports.tcbauth=e(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):t.tcbauth=e(t.tcboauth,t.tcbadaptermp)}("undefined"!=typeof window?window:this,(t,e)=>(()=>{"use strict";var r={829:(t,e,r)=>{var n;r.r(e),r.d(e,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>s}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},105:function(t,e,r){var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&o(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(r(587)),c=r(894);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,o=(0,c.isArray)(t)?t:[t];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(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},587:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=r(829),c=r(894),d=r(652),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,s=t.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(e).forEach((function(t){c.append(t,e[t])})),c.append("key",n),c.append("file",r),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,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({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.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(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;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=t.url,o=t.enableAbort,u=void 0!==o&&o,c=t.stream,d=void 0!==c&&c,l=t.signal,h=t.timeout,p=t.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({},t),{signal:r.signal})).then((function(t){return s(m,void 0,void 0,(function(){var e,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),f?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){if(clearTimeout(y),f)return Promise.reject(t)}))];case 1:return g=b.sent(),[2,{data:d?g.body:(null===(e=g.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?g.json():g.text(),statusCode:g.status,header:g.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,l=void 0===u?{}:u,h=t.data,p=t.responseType,f=t.withCredentials,v=t.body,y=t.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(t){m.setRequestHeader(t,l[t])})),y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=m.status;try{t.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&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)}))},e}(u.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},652:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},151:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.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(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(652),e),o(r(151),e),e.OATUH_LOGINTYPE="constants"},64:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(e,"__esModule",{value:!0}),e.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(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.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(t){return u.test(t)}));if(-1!==l){var h=s.filter((function(t,e){return e>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}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,h=t.title,p=t.messages,f=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=l.className||t.constructor.name,v=l.methodName||e,y=a.value,g=function(t){var e="",r=t.stack.split("\n"),n=r.findIndex((function(t){return u.test(t)}));if(-1!==n){var o=c.exec(r[n+1]||"");e=o?o[0]:""}return e}(new Error);a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=d({err:new Error,className:p,methodName:v,sourceLink:g});try{return y.apply(this,t)}catch(t){var n=t,o=t.message,s=t.error,a=t.error_description,u={title:h||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(t.code=c.code,t.message=c.msg),n=r||t,u.content=f.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,u.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,s,a,u,c,l;return o(this,(function(o){switch(o.label){case 0:e=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,t)];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&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,c.content=f.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(r.code=a,r.message=u),n=e||r,c.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},466:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(64),e)},418:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(829),u=r(894),c=r(141),d=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage);var l=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(e.root));case"none":return new d(e.root);default:return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,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:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){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(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){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(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=l},988:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=r(894);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,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},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var d=new c;e.addEventListener=function(t,e){d.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),d.fire(t,e)},e.removeEventListener=function(t,e){d.off(t,e)}},894:function(t,e,r){var n=this&&this.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(141);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(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 t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""};e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.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===(e=console.groupEnd)||void 0===e||e.call(console)};e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86".concat(t)};e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e},e.parseCaptcha=function(t){var r={},o=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){t=o[1];var i=o[2];i&&(r=(0,e.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(t)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:s?{state:a.state,token:s,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},219:t=>{t.exports=e},297:e=>{e.exports=t}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t].call(i.exports,i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{Auth:()=>at,LoginState:()=>st,User:()=>it,eventBus:()=>nt,generateAuthInstance:()=>ut,registerAuth:()=>dt});var t=o(297),e=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(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},h=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},p=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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 t(t){var e,r;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(r=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return h(this,void 0,void 0,(function(){return p(this,(function(r){return this.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),v=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,y=function(t,e){var r,n,o,i,s=null===(r=null==e?void 0:e.headers)||void 0===r?void 0:r["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.error_code))&&(t={error:t.code||t.data.error,error_description:t.data.error_description||t.message||t.code||t.data.error_code,request_id:t.requestId,error_code:null===(o=t.data)||void 0===o?void 0:o.error_code}),(null==t?void 0:t.request_id)||(t.request_id=t.request_id||s),(null==t?void 0:t.error)?(t.error_uri=(i=null==e?void 0:e.url,v.test(i)?RegExp.$1:i),t):(null==t?void 0:t.data)||{}};var g=function(t,e){var r=l({},t),n={};if((null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!c().isMatch()||t.storage&&t.baseRequest)return r;try{var o=c().genAdapter({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new f({localStorage:i,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(t){return function(e,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:e,data:i.body,timeout:t._timeout,method:i.method||"GET",header:i.headers,success:function(t){(t=y(t,l(l({},r),{url:e}))).error&&o(t),n(t)},fail:function(t){o({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&(t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg)){console.warn(t._timeoutMsg);try{s.abort()}catch(t){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),l(l({},r),n)}catch(t){console.error("adapter generate fail:",t)}return r},m=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var r=l({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(r.storage=new f({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var n=new e.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(t,e){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=e.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=e.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=e.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof e.body)||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,d(l({url:t},e))];case 2:return u=p.sent(),u=y(u,l(l({},e),{url:t})),[3,4];case 3:throw h=p.sent(),u=h,h;case 4:if(null==u?void 0:u.error)throw u;return[2,u]}}))}))}}}catch(t){console.error("user adapter generate fail:",t)}return r}(t,t.adapter):g(t,t.adapter)};var b="@cloudbase/js-sdk";function w(){return b}var _="https:";var I="INVALID_PARAMS",A="INVALID_OPERATION",E="OPERATION_FAIL",S=o(829);function O(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}function T(t,e){console.warn("[".concat(w(),"][").concat(t,"]:").concat(e))}var P,U=(P=function(t,e){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}P(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),k=function(){return(k=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},C=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},L=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}U(e,t),e.prototype.get=function(t){return this.request(k(k({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(k(k({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(k(k({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,i=t.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(e).forEach((function(t){u.append(t,e[t])})),u.append("key",n),u.append("file",r),this.request(k(k({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(k(k({},t),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return C(this,void 0,void 0,(function(){var e,r,n,o;return L(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(k(k({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.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(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;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 L(this,(function(y){switch(y.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,i=void 0!==o&&o,s=t.stream,a=void 0!==s&&s,u=t.signal,c=t.timeout,d=t.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({},t),{signal:r.signal})).then((function(t){return C(v,void 0,void 0,(function(){var e,r,n;return L(this,(function(o){switch(o.label){case 0:return clearTimeout(p),l?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){if(clearTimeout(p),l)return Promise.reject(t)}))];case 1:return f=y.sent(),[2,{data:a?f.body:(null===(e=f.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?f.json():f.text(),statusCode:f.status,header:f.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a,u=t.url,c=t.headers,d=void 0===c?{}:c,l=t.data,h=t.responseType,p=t.withCredentials,f=t.body,v=t.onUploadProgress,y=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}(_,u,"get"===n?l:{}),g=new XMLHttpRequest;g.open(n,y),h&&(g.responseType=h),Object.keys(d).forEach((function(t){g.setRequestHeader(t,d[t])})),v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=g.status;try{t.data="blob"===h?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===h?g.response:g.responseText}clearTimeout(i),o(t)}},e&&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(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")}(l):f||(l?JSON.stringify(l):void 0),p&&(g.withCredentials=!0),g.send(s)}))}}(S.AbstractSDKRequest);var N;!function(t){t.WEB="web",t.WX_MP="wx_mp"}(N||(N={}));var R=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),x=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},j=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return R(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(S.AbstractStorage);!function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(T(I,"localStorage is not supported on current platform"),new M(e.root));case"none":return new M(e.root);default:return e.localStorage?e.localStorage:(T(I,"localStorage is not supported on current platform"),new M(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:E,msg:"[".concat(w(),"][").concat(E,"]setStore failed"),info:t}))}}else T(A,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,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:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){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(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}T(A,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){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(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):T(A,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return x(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))}}();var D=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),q=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var W=function(t,e){this.data=e||null,this.name=t},H=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return D(e,t),e}(W),G=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof H)return console.error(t.error),this;var r="string"==typeof t?new W(t,e||{}):t,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},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new G;new G;"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");!function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,r){"abort"===e&&t.listeners.push(r)}}}t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(t){return t()})))}}();function Y(t){this.message=t}Y.prototype=new Error,Y.prototype.name="InvalidCharacterError";"undefined"!=typeof window&&window.atob&&window.atob.bind(window);function F(t){this.message=t}F.prototype=new Error,F.prototype.name="InvalidTokenError";var V=function(){return(V=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},B=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},K=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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])}}},J=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},$=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},Q=function(){function e(t){this.listeners=new Map,this.hasListenerSetUp=!1,this.config=t,this.oauthInstance=t.oauthInstance,this.cache=t.cache,this.init()}return Object.defineProperty(e.prototype,"currentUser",{get:function(){var t=this.hasLoginState();return t&&t.user||null},enumerable:!1,configurable:!0}),e.prototype.hasLoginState=function(){throw new Error("Auth.hasLoginState() is not implemented")},e.prototype.setAccessKey=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.setAccessKey() is not implemented")}))}))},e.prototype.signIn=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.signIn() is not implemented")}))}))},e.prototype.signInWithProvider=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.signInWithProvider() is not implemented")}))}))},e.prototype.genProviderRedirectUri=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.genProviderRedirectUri() is not implemented")}))}))},e.prototype.getAccessToken=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.getAccessToken() is not implemented")}))}))},e.prototype.getUserInfo=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.getUserInfo() is not implemented")}))}))},e.prototype.updateUserBasicInfo=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.updateUserBasicInfo() is not implemented")}))}))},e.prototype.setCustomSignFunc=function(t){throw new Error("Auth.setCustomSignFunc() is not implemented")},e.prototype.grantProviderToken=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.grantProviderToken() is not implemented")}))}))},e.prototype.bindWithProvider=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.bindWithProvider() is not implemented")}))}))},e.prototype.signInWithUsername=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.signInWithUsername() is not implemented")}))}))},e.prototype.getVerification=function(t,e){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.getVerification() is not implemented")}))}))},e.prototype.createLoginState=function(t,e){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.createLoginState() is not implemented")}))}))},e.prototype.verify=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.verify() is not implemented")}))}))},e.prototype.signInAnonymously=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];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 t.AuthError(i)}];case 5:return[2]}}))}))},e.prototype.signUp=function(e){return B(this,void 0,void 0,(function(){var r,n,o=this;return K(this,(function(i){switch(i.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?[4,this.oauthInstance.authApi.signUp(e)]:[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.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 B(o,void 0,void 0,(function(){var n,o,s,u,c;return K(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:e.email||this.formatPhone(e.phone),verification_token:n.verification_token})]:[3,3];case 2:return d.sent(),[3,6];case 3:return delete(o=JSON.parse(JSON.stringify(e))).email,delete o.phone,[4,this.oauthInstance.authApi.signUp(V(V(V({},o),e.email?{email:e.email}:{phone_number:this.formatPhone(e.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 t.AuthError(c)}];case 9:return[2]}}))}))}},error:null}];case 4:return n=i.sent(),[2,{data:{},error:new t.AuthError(n)}];case 5:return[2]}}))}))},e.prototype.signOut=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),r=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return n=i.sent(),[4,this.cache.removeStoreAsync(r)];case 2:return i.sent(),this.setAccessKey(),nt.fire(t.EVENTS.LOGIN_STATE_CHANGED,{eventType:t.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,V(V({},n),{data:{},error:null})];case 3:return o=i.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.onAuthStateChange=function(t){var e=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(t),{data:{subscription:{id:r,callback:t,unsubscribe:function(){var n=e.listeners.get(r);n&&(n.delete(t),0===n.size&&e.listeners.delete(r))}}}}},e.prototype.signInWithPassword=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(V({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.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 t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.signInWithIdToken=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.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 t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.signInWithOtp=function(e){return B(this,void 0,void 0,(function(){var r,n,o=this;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 1:return r=i.sent(),[2,{data:{user:null,session:null,verifyOtp:function(t){var n=t.token,i=t.messageId,s=void 0===i?r.verification_id:i;return B(o,void 0,void 0,(function(){return K(this,(function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:n,messageId:s})]}))}))}},error:null}];case 2:return n=i.sent(),[2,{data:{},error:new t.AuthError(n)}];case 3:return[2]}}))}))},e.prototype.verifyOAuth=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d;return K(this,(function(l){switch(l.label){case 0:r={},l.label=1;case 1:return l.trys.push([1,7,,8]),n=(null==e?void 0:e.code)||O("code"),o=(null==e?void 0:e.state)||O("state"),n?o?(i=function(t){try{return JSON.parse(sessionStorage.getItem(t))}catch(t){return console.error("Failed to get browser session:",t),null}}(o),r.type=null==i?void 0:i.type,(s=(null==e?void 0:e.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 t.AuthError({message:"Provider is required"})}]):[2,{data:{},error:new t.AuthError({message:"State is required"})}]:[2,{data:{},error:new t.AuthError({message:"Code is required"})}];case 2:return a=l.sent().provider_token,u=void 0,i.type!==t.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(t,e){if(void 0!==t){var r=new URL(window.location.href);r.search=t,r.hash=e||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(t){try{sessionStorage.removeItem(t)}catch(t){return console.error("Failed to remove browser session:",t),null}}(o),[2,u];case 7:return d=l.sent(),[2,{data:r,error:new t.AuthError(d)}];case 8:return[2]}}))}))},e.prototype.signInWithOAuth=function(e){var r,n,o,i,s;return B(this,void 0,void 0,(function(){var a,u,c,d,l,h,p,f,v;return K(this,(function(y){switch(y.label){case 0:return y.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),a=(null===(r=e.options)||void 0===r?void 0:r.redirectTo)||location.href,u=new URL(a),c=u.origin+u.pathname,d=(null===(n=e.options)||void 0===n?void 0:n.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:c,state:d})];case 1:return l=y.sent().uri,h=decodeURIComponent(l),p=h,(null===(o=e.options)||void 0===o?void 0:o.queryParams)&&(f=new URL(h),Object.entries(e.options.queryParams).forEach((function(t){var e=t[0],r=t[1];f.searchParams.set(e,r)})),p=f.toString()),function(t,e){try{sessionStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save to browser session:",t)}}(d,{provider:e.provider,search:u.search,hash:u.hash,type:(null===(i=e.options)||void 0===i?void 0:i.type)||t.OAUTH_TYPE.SIGN_IN}),$()&&!(null===(s=e.options)||void 0===s?void 0:s.skipBrowserRedirect)&&window.location.assign(p),[2,{data:{url:p,provider:e.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new t.AuthError(v)}];case 3:return[2]}}))}))},e.prototype.signInWithSSO=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){return[2]}))}))},e.prototype.signInWithWeb3=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){return[2]}))}))},e.prototype.getClaims=function(){return B(this,void 0,void 0,(function(){var e,r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=n.sent().accessToken,[2,{data:(0,t.weappJwtDecodeAll)(e),error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForEmail=function(e,r){return B(this,void 0,void 0,(function(){var n,o,i,s,a,u,c=this;return K(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),n=(r||{}).redirectTo,o=e.includes("@"),i=void 0,o?i={email:e}:(s=this.formatPhone(e),i={phone_number:s}),[4,this.getVerification(i)];case 1:return a=d.sent(),[2,{data:{updateUser:function(r){return B(c,void 0,void 0,(function(){var i,s,u;return K(this,(function(c){switch(c.label){case 0:this.validateParams(r,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:r.nonce})];case 2:return i=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:o?e:void 0,phone:o?void 0:e,new_password:r.password,verification_token:i.verification_token})];case 3:return c.sent(),nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:o?e:void 0,phone:o?void 0:e,password:r.password})];case 4:return s=c.sent(),n&&$()&&window.location.assign(n),[2,s];case 5:return u=c.sent(),[2,{data:{},error:new t.AuthError(u)}];case 6:return[2]}}))}))}},error:null}];case 2:return u=d.sent(),[2,{data:{},error:new t.AuthError(u)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForOld=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.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 t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.verifyOtp=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),r=e.type,this.validateParams(e,{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:e.messageId,verification_code:e.token})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:e.token,username:e.email||this.formatPhone(e.phone)||"",loginType:e.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 t.AuthError(i)}];case 7:return[2]}}))}))},e.prototype.getSession=function(){return B(this,void 0,void 0,(function(){var e,r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=i.sent())&&"accessKey"!==e.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({},e),{user:n})},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.refreshSession=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i,s;return K(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=e||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 t.AuthError(s)}];case 5:return[2]}}))}))},e.prototype.getUser=function(){return B(this,void 0,void 0,(function(){var e,r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=this.convertToUser,[4,this.getUserInfo()];case 1:return[2,{data:{user:e.apply(this,[n.sent()])},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.refreshUser=function(){return B(this,void 0,void 0,(function(){var e,r,n;return K(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 e=o.sent().data,[2,{data:{user:(r=(void 0===e?{}:e).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new t.AuthError(n)}];case 4:return[2]}}))}))},e.prototype.updateUser=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d,l,h,p,f=this;return K(this,(function(v){switch(v.label){case 0:if(v.trys.push([0,8,,9]),!Object.keys(e).some((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})))throw new t.AuthError({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=J(e,["email","phone"]),s=void 0!==n,a={},(i=void 0!==r)||s?(u=void 0,i?(u={email:e.email},c="email_change"):(d=this.formatPhone(e.phone),u={phone_number:d},c="phone_change"),[4,this.getVerification(u)]):[3,4];case 1:return l=v.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:v.sent(),v.label=3;case 3:return a={messageId:l.verification_id,verifyOtp:function(r){return B(f,void 0,void 0,(function(){var n,o;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),r.email&&e.email===r.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:r.token,messageId:l.verification_id})]:[3,3];case 1:return s.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return r.phone&&e.phone===r.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:r.token,messageId:l.verification_id})]:[3,6];case 4:return s.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp({type:c,email:i?e.email:void 0,phone:i?void 0:e.phone,token:r.token,messageId:l.verification_id})];case 7:return s.sent(),[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser()];case 10:return n=s.sent().data.user,nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return o=s.sent(),[2,{data:{},error:new t.AuthError(o)}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:v.sent(),v.label=6;case 6:return[4,this.getUser()];case 7:return h=v.sent().data.user,nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:V({user:h},a),error:null}];case 8:return p=v.sent(),[2,{data:{},error:new t.AuthError(p)}];case 9:return[2]}}))}))},e.prototype.getUserIdentities=function(){var e;return B(this,void 0,void 0,(function(){var r,n;return K(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===(e=null==r?void 0:r.data)||void 0===e?void 0:e.filter((function(t){return!!t.bind}))},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new t.AuthError(n)}];case 3:return[2]}}))}))},e.prototype.linkIdentity=function(e){return B(this,void 0,void 0,(function(){var r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:t.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return n.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.unlinkIdentity=function(e){return B(this,void 0,void 0,(function(){var r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return n.sent(),[2,{data:{},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.reauthenticate=function(){return B(this,void 0,void 0,(function(){var e,r,n,o,i=this;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser()];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),r=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(r)];case 2:return n=s.sent(),[2,{data:{updateUser:function(e){return B(i,void 0,void 0,(function(){var o,i,s,a,u;return K(this,(function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:n.verification_id,verification_code:e.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:e.password,sudo_token:i.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(V(V({verificationInfo:n,verificationCode:e.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 t.AuthError(u)}];case 10:return[2]}}))}))}},error:null}];case 3:return o=s.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.resend=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),r="signup"===e.type?"ANY":"USER",n={target:r},"email"in e&&(n.email=e.email),"phone"in e&&(n.phone_number=this.formatPhone(e.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 t.AuthError(o)}];case 3:return[2]}}))}))},e.prototype.setSession=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwOnError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.exchangeCodeForSession=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){return[2]}))}))},e.prototype.deleteUser=function(e){return B(this,void 0,void 0,(function(){var r,n;return K(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];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 t.AuthError(n)}];case 4:return[2]}}))}))},e.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),B(this,void 0,void 0,(function(){var r,n,o,i,s;return K(this,(function(a){try{return r=e.config_version||"env",n=Object.keys(e.query||{}).map((function(t){return"".concat(t,"=").concat(e.query[t])})).join("&"),c().isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(n?"?".concat(n):"")}):(o=e.redirect_uri||window.location.href,i=new URL(o),s="".concat(i.origin,"/__auth/?app_id=").concat(e.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(e){return[2,{data:{},error:new t.AuthError(e)}]}return[2]}))}))},e.prototype.signInWithCustomTicket=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i;return K(this,(function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),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 t.AuthError(i)}];case 6:return[2]}}))}))},e.prototype.signInWithOpenId=function(e){var r=(void 0===e?{}:e).useWxCloud,n=void 0===r||r;return B(this,void 0,void 0,(function(){var e,r,o,i,s,a,u=this;return K(this,(function(d){switch(d.label){case 0:if(!c().isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,r=function(t){return B(u,void 0,void 0,(function(){var r,o;return K(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==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.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(t,e){wx.login({success:function(n){return B(u,void 0,void 0,(function(){var o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(n.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return o=i.sent(),e(o),[3,3];case 3:return[2]}}))}))},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(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 t.AuthError(a)}];case 6:return[2]}}))}))},e.prototype.signInWithPhoneAuth=function(e){var r=e.phoneCode,n=void 0===r?"":r;return B(this,void 0,void 0,(function(){var e,r,o,i,s,a,u,d,l;return K(this,(function(h){switch(h.label){case 0:return c().isMatch()?(e=wx.getAccountInfoSync().miniProgram,r={provider_params:{provider_code_type:"phone"},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new t.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:e.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 t.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})]}}))}))},e.prototype.formatPhone=function(t){return!/\s+/.test(t)&&/^\+\d{1,3}\d+/.test(t)?t.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(t)?t:"+86 ".concat(t)},e.prototype.notifyListeners=function(t,e,r){this.listeners.forEach((function(n){n.forEach((function(n){try{n(t,e,r)}catch(t){console.error("Error in auth state change callback:",t)}}))}))},e.prototype.init=function(){return B(this,void 0,void 0,(function(){return K(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return e.sent()&&nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION}),[3,3];case 2:return e.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},e.prototype.setupListeners=function(){var e=this;nt.on(t.EVENTS.AUTH_STATE_CHANGED,(function(t){return B(e,void 0,void 0,(function(){var e,r,n,o,i;return K(this,(function(s){switch(s.label){case 0:return e=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.event,r=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(e,n,r),[2]}}))}))}))},e.prototype.convertToUser=function(t){var e,r,n;if(!t)return null;var o=(null==t?void 0:t.email)||(null==t?void 0:t.username),i=null==t?void 0:t.phone_number,s=(null==t?void 0:t.sub)||(null==t?void 0:t.uid)||"";return{id:s,aud:"authenticated",role:t.groups,email:o||"",email_confirmed_at:(null==t||t.email_verified,t.created_at),phone:i,phone_confirmed_at:i?t.created_at:void 0,confirmed_at:t.created_at,last_sign_in_at:t.last_sign_in_at,app_metadata:{provider:(null===(e=t.loginType)||void 0===e?void 0:e.toLowerCase())||"cloudbase",providers:[(null===(r=t.loginType)||void 0===r?void 0:r.toLowerCase())||"cloudbase"]},user_metadata:{name:null==t?void 0:t.name,picture:null==t?void 0:t.picture,username:null==t?void 0:t.username,gender:null==t?void 0:t.gender,locale:null==t?void 0:t.locale,uid:t.uid,nickName:t.nickName,avatarUrl:t.avatarUrl||t.picture,location:t.location,hasPassword:t.hasPassword},identities:(null===(n=null==t?void 0:t.providers)||void 0===n?void 0:n.map((function(e){return{id:e.id||"",identity_id:e.id||"",user_id:s,identity_data:{provider_id:e.id,provider_user_id:e.provider_user_id,name:e.name},provider:e.id||"cloudbase",created_at:t.created_at,updated_at:t.updated_at,last_sign_in_at:t.last_sign_in_at}})))||[],created_at:t.created_at,updated_at:t.updated_at,is_anonymous:"anonymous"===t.name}},e.prototype.validateParams=function(e,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==e?void 0:e[s])||null===(null==e?void 0:e[s])||""===(null==e?void 0:e[s])))throw new t.AuthError({message:a.message})}},e.prototype.validateAtLeastOne=function(e,r,n){if(!r.some((function(t){return t.some((function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])}))})))throw new t.AuthError({message:n})},e}(),z=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),X=function(){return(X=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Z=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},tt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},et=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},rt=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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])}}},nt=new s.CloudbaseEventEmitter,ot=function(e){nt.fire(t.EVENTS.LOGIN_STATE_CHANGED,X(X({},e),{eventType:t.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))},it=function(){function t(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){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]}))}))},t.prototype.checkLocalInfoAsync=function(){return et(this,void 0,void 0,(function(){var t,e,r,n;return rt(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.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]}}))}))},t.prototype.update=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(X({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(X({},t))];case 1:return e.sent(),[4,this.refresh()];case 2:return e.sent(),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,e.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:if("INVALID_ACCESS_TOKEN"===(e=r.sent()).code)throw this.setLocalUserInfo({}),e;return this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);return t?r[t]:r||{}},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},t.prototype.getLocalUserInfoAsync=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at"].forEach((function(e){t[e]=r[e]}))},Z([(0,n.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],t.prototype,"update",null),Z([(0,n.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[String,String]),tt("design:returntype",void 0)],t.prototype,"updatePassword",null),Z([(0,n.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[String]),tt("design:returntype",void 0)],t.prototype,"updateUsername",null),Z([(0,n.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],t.prototype,"refresh",null),t}(),st=function(){function t(t){var n=t.envId,o=t.cache,i=t.oauthInstance;n||(0,e.throwError)(r.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=o,this.oauthInstance=i,this.user=new it({cache:this.cache,oauthInstance:i})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),at=function(o){function i(t){var e=o.call(this,t)||this;return e.setAccessKey(),e}return z(i,o),i.prototype.bindPhoneNumber=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},i.prototype.unbindProvider=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},i.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},i.prototype.verify=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},i.prototype.getVerification=function(t,e){return et(this,void 0,void 0,(function(){return rt(this,(function(r){return[2,this.oauthInstance.authApi.getVerification(t,e)]}))}))},Object.defineProperty(i.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,e.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),i.prototype.getCurrentUser=function(){return et(this,void 0,void 0,(function(){var t,e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?(e=t.user.getLocalUserInfo(),[4,t.user.checkLocalInfoAsync()]):[3,3];case 2:return r.sent(),[2,X(X({},t.user),e)];case 3:return[2,null]}}))}))},i.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return et(this,void 0,void 0,(function(){var t,r,n=this;return rt(this,(function(o){switch(o.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,r=function(r){return et(n,void 0,void 0,(function(){var n,o;return rt(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==t?void 0:t.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];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},e)];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(t,e){wx.login({success:function(o){return et(n,void 0,void 0,(function(){var n;return rt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return n=i.sent(),e(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},i.prototype.bindOpenId=function(){return et(this,void 0,void 0,(function(){var t,e,r=this;return rt(this,(function(n){switch(n.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return et(r,void 0,void 0,(function(){var r;return rt(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==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.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(t,n){wx.login({success:function(o){return et(r,void 0,void 0,(function(){var r;return rt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})}))];case 1:return n.sent(),[2]}}))}))},i.prototype.signInWithUnionId=function(){return et(this,void 0,void 0,(function(){var t=this;return rt(this,(function(e){switch(e.label){case 0:if(!c().isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return et(t,void 0,void 0,(function(){var t,i,s,a,u;return rt(this,(function(c){switch(c.label){case 0:t=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:t,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:t,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},i.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a;return et(this,void 0,void 0,(function(){return rt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(t){throw t}return[2]}))}))},i.prototype.signInWithEmail=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.bindInfo,s=void 0===i?void 0:i,a=t.email,u=void 0===a?"":a;return et(this,void 0,void 0,(function(){return rt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(t){throw t}return[2]}))}))},i.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},i.prototype.signIn=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},i.prototype.setPassword=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},i.prototype.isUsernameRegistered=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&(0,e.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,n.sent().exist]}}))}))},i.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new st({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,e.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},i.prototype.getLoginState=function(){return et(this,void 0,void 0,(function(){var t;return rt(this,(function(e){switch(e.label){case 0:t=null,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[2,null];case 4:return t?[2,new st({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},i.prototype.getUserInfo=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.getCurrentUser()]}))}))},i.prototype.getWedaUserInfo=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},i.prototype.updateUserBasicInfo=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},i.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},i.prototype.bindWithProvider=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},i.prototype.queryUser=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},i.prototype.getAccessToken=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},i.prototype.grantProviderToken=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},i.prototype.patchProviderToken=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},i.prototype.signInWithProvider=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},i.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},i.prototype.grantToken=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},i.prototype.genProviderRedirectUri=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},i.prototype.resetPassword=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},i.prototype.deviceAuthorize=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},i.prototype.sudo=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},i.prototype.deleteMe=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},i.prototype.getProviders=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},i.prototype.loginScope=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},i.prototype.loginGroups=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},i.prototype.onLoginStateChanged=function(e){return et(this,void 0,void 0,(function(){var r,n=this;return rt(this,(function(o){switch(o.label){case 0:return nt.on(t.EVENTS.LOGIN_STATE_CHANGED,(function(r){return et(n,void 0,void 0,(function(){var n,o,i;return rt(this,(function(s){switch(s.label){case 0:return(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.eventType)===t.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,e.call(this,X(X({},r),n)),[2]}}))}))})),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}}))}))},i.prototype.refreshTokenForce=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},i.prototype.getCredentials=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},i.prototype.setCredentials=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},i.prototype.getProviderSubType=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},i.prototype.createCaptchaData=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},i.prototype.verifyCaptchaData=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},i.prototype.getMiniProgramQrCode=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},i.prototype.getMiniProgramQrCodeStatus=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},i.prototype.modifyPassword=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},i.prototype.modifyPasswordWithoutLogin=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]}))}))},i.prototype.getUserBehaviorLog=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},i.prototype.signInWithUsername=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.username,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a,c=t.loginType,d=void 0===c?"":c;return et(this,void 0,void 0,(function(){var t,e,n,i,a,c,l;return rt(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==(t=h.sent())?void 0:t.error_code)throw t;return e=t.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:e})]:[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(X(X({},i),{verification_token:e,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]}}))}))},i.prototype.createLoginState=function(e,r){return et(this,void 0,void 0,(function(){var n;return rt(this,(function(o){switch(o.label){case 0:return[4,(n=new st({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return o.sent(),(null==r?void 0:r.userInfo)?(n.user.setLocalUserInfo(r.userInfo),[3,5]):[3,2];case 2:return(null==r?void 0:r.asyncRefreshUser)?(n.user.refresh(e),[3,5]):[3,3];case 3:return[4,n.user.refresh(e)];case 4:o.sent(),o.label=5;case 5:return nt.fire(t.EVENTS.LOGIN_STATE_CHANGED,{eventType:t.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,n]}}))}))},i.prototype.setAccessKey=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){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(t){console.warn("accessKey error: ",t)}return[2]}))}))},Z([(0,n.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"bindPhoneNumber",null),Z([(0,n.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"unbindProvider",null),Z([(0,n.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",void 0)],i.prototype,"bindEmail",null),Z([(0,n.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"verify",null),Z([(0,n.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object,Object]),tt("design:returntype",Promise)],i.prototype,"getVerification",null),Z([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getCurrentUser",null),Z([(0,n.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"signInAnonymouslyInWx",null),Z([(0,n.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"bindOpenId",null),Z([(0,n.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"signInWithUnionId",null),Z([(0,n.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"signInWithSms",null),Z([(0,n.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"signInWithEmail",null),Z([(0,n.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[String]),tt("design:returntype",Promise)],i.prototype,"isUsernameRegistered",null),Z([(0,n.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getLoginState",null),Z([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getUserInfo",null),Z([(0,n.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getWedaUserInfo",null),Z([(0,n.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"bindWithProvider",null),Z([(0,n.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getProviderSubType",null),i}(Q);function ut(e,r){var n=this,o=e.region,i=void 0===o?"ap-shanghai":o,s=e.i18n,u=e.accessKey,c=e.useWxCloud,l=(null==r?void 0:r.platform)||d.useDefaultAdapter.bind(r)(),h=l.runtime,p=l.adapter,f=r||{},v=f.env,y=f.clientId,g=f.debug,b=f.cache,w=f.app,_=(r||{}).apiOrigin;_||(_="https://".concat(v,".").concat(i,".tcb-api.tencentcloudapi.com"));var I={env:v,clientId:y,i18n:s,accessKey:u,useWxCloud:c,eventBus:nt},A=new t.CloudbaseOAuth(m(X(X({},I),{apiOrigin:_,apiPath:(null==e?void 0:e.apiPath)||t.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:p,onCredentialsError:ot,headers:X({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:g}))),E=new at(X(X({},I),{region:i,persistence:e.persistence,debug:g,cache:b||new a.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(v)},platformInfo:l}),runtime:h||"web",_fromApp:w,oauthInstance:A}));return A.initializeSession((function(e,r){return et(n,void 0,void 0,(function(){return rt(this,(function(n){return e?(e.type===t.OAUTH_TYPE.SIGN_IN?r?nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:X(X({},e),{error:r})}):e.user&&E.createLoginState({},{userInfo:e.user}):e.type===t.OAUTH_TYPE.BIND_IDENTITY&&nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:X(X({},e),{error:r})}),[2]):[2]}))}))})),{authInstance:E,oauthInstance:A}}var ct={name:"auth",namespace:"auth",entity:function(e){var r;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:t.AUTH_API_PREFIX};var n=this.platform.adapter,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=ut(X(X({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{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}};try{cloudbase.registerComponent(ct)}catch(Y){}function dt(t){try{t.registerComponent(ct)}catch(t){console.warn(t)}}})(),i})());
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):"function"==typeof define&&define.amd?define("tcbauth",["@cloudbase/oauth","@cloudbase/adapter-wx_mp"],e):"object"==typeof exports?exports.tcbauth=e(require("@cloudbase/oauth"),require("@cloudbase/adapter-wx_mp")):t.tcbauth=e(t.tcboauth,t.tcbadaptermp)}("undefined"!=typeof window?window:this,(t,e)=>(()=>{"use strict";var r={829:(t,e,r)=>{var n;r.r(e),r.d(e,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>s}),function(t){t.local="local",t.none="none",t.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";for(var i in r)""===o?!n&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},105:function(t,e,r){var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&o(e,t,r);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(r(587)),c=r(894);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var r=0,o=(0,c.isArray)(t)?t:[t];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(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},587:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=r(829),c=r(894),d=r(652),l=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,s=t.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(e).forEach((function(t){c.append(t,e[t])})),c.append("key",n),c.append("file",r),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,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({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.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(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;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=t.url,o=t.enableAbort,u=void 0!==o&&o,c=t.stream,d=void 0!==c&&c,l=t.signal,h=t.timeout,p=t.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({},t),{signal:r.signal})).then((function(t){return s(m,void 0,void 0,(function(){var e,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),f?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){if(clearTimeout(y),f)return Promise.reject(t)}))];case 1:return g=b.sent(),[2,{data:d?g.body:(null===(e=g.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?g.json():g.text(),statusCode:g.status,header:g.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,u=t.headers,l=void 0===u?{}:u,h=t.data,p=t.responseType,f=t.withCredentials,v=t.body,y=t.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(t){m.setRequestHeader(t,l[t])})),y&&m.upload.addEventListener("progress",y),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=m.status;try{t.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&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)}))},e}(u.AbstractSDKRequest);e.WebRequest=l,e.genAdapter=function(){return{type:"default",root:window,reqClass:l,wsClass:WebSocket,localStorage:localStorage}}},652:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var r="@cloudbase/js-sdk";e.setSdkName=function(t){r=t},e.getSdkName=function(){return r};var n="https:";e.setProtocol=function(t){n=t},e.getProtocol=function(){return n},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},151:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.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(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(r(652),e),o(r(151),e),e.OATUH_LOGINTYPE="constants"},64:function(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(e,"__esModule",{value:!0}),e.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(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.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(t){return u.test(t)}));if(-1!==l){var h=s.filter((function(t,e){return e>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}e.catchErrorsDecorator=function(t){var e=t.mode,r=void 0===e?"async":e,a=t.customInfo,l=void 0===a?{}:a,h=t.title,p=t.messages,f=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=l.className||t.constructor.name,v=l.methodName||e,y=a.value,g=function(t){var e="",r=t.stack.split("\n"),n=r.findIndex((function(t){return u.test(t)}));if(-1!==n){var o=c.exec(r[n+1]||"");e=o?o[0]:""}return e}(new Error);a.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=d({err:new Error,className:p,methodName:v,sourceLink:g});try{return y.apply(this,t)}catch(t){var n=t,o=t.message,s=t.error,a=t.error_description,u={title:h||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(t.code=c.code,t.message=c.msg),n=r||t,u.content=f.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(t.code=s,t.message=a),n=r||t,u.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n(this,void 0,void 0,(function(){var e,r,n,s,a,u,c,l;return o(this,(function(o){switch(o.label){case 0:e=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,t)];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&&(e?(e.code=l.code,e.message=l.msg):(r.code=l.code,r.message=l.msg),n=e||r,c.content=f.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(r.code=a,r.message=u),n=e||r,c.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},466:function(t,e,r){var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(64),e)},418:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=r(829),u=r(894),c=r(141),d=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return o(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(a.AbstractStorage);var l=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(e.root));case"none":return new d(e.root);default:return e.localStorage?e.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new d(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,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:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){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(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){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(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=l},988:function(t,e,r){var n,o=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__spreadArray||function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=r(894);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var r=(0,s.isString)(t)?new a(t,e||{}):t,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},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var d=new c;e.addEventListener=function(t,e){d.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),d.fire(t,e)},e.removeEventListener=function(t,e){d.off(t,e)}},894:function(t,e,r){var n=this&&this.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCaptcha=e.parseQueryString=e.transformPhone=e.sleep=e.printGroupLog=e.throwError=e.printInfo=e.printError=e.printWarn=e.execCallback=e.createPromiseCallback=e.removeParam=e.getHash=e.getQuery=e.toQueryString=e.formatUrl=e.generateRequestId=e.genSeqId=e.isFormData=e.isInstanceOf=e.isNull=e.isPalinObject=e.isUndefined=e.isString=e.isArray=void 0;var o=r(141);e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isString=function(t){return"string"==typeof t},e.isUndefined=function(t){return void 0===t},e.isPalinObject=function(t){return"[object Object]"===Object.prototype.toString.call(t)},e.isNull=function(t){return"[object Null]"===Object.prototype.toString.call(t)},e.isInstanceOf=function(t,e){return t instanceof e},e.isFormData=function(t){return"[object FormData]"===Object.prototype.toString.call(t)},e.genSeqId=function(){return Math.random().toString(16).slice(2)},e.generateRequestId=function(){var t=(new Date).getTime(),e=(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 t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))},e.formatUrl=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)},e.toQueryString=function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""};e.getHash=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""},e.removeParam=function(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},e.createPromiseCallback=function(){var t={};if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t},e.execCallback=function(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r},e.printWarn=function(t,e){console.warn("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,o.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.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===(e=console.groupEnd)||void 0===e||e.call(console)};e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))},e.transformPhone=function(t){return"+86".concat(t)};e.parseQueryString=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e},e.parseCaptcha=function(t){var r={},o=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){t=o[1];var i=o[2];i&&(r=(0,e.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(t)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:s?{state:a.state,token:s,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},219:t=>{t.exports=e},297:e=>{e.exports=t}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t].call(i.exports,i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{Auth:()=>at,LoginState:()=>st,User:()=>it,eventBus:()=>nt,generateAuthInstance:()=>ut,registerAuth:()=>dt});var t=o(297),e=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(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},h=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},p=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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 t(t){var e,r;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(r=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return h(this,void 0,void 0,(function(){return p(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return h(this,void 0,void 0,(function(){return p(this,(function(r){return this.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),v=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,y=function(t,e){var r,n,o,i,s=null===(r=null==e?void 0:e.headers)||void 0===r?void 0:r["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.error_code))&&(t={error:t.code||t.data.error,error_description:t.data.error_description||t.message||t.code||t.data.error_code,request_id:t.requestId,error_code:null===(o=t.data)||void 0===o?void 0:o.error_code}),(null==t?void 0:t.request_id)||(t.request_id=t.request_id||s),(null==t?void 0:t.error)?(t.error_uri=(i=null==e?void 0:e.url,v.test(i)?RegExp.$1:i),t):(null==t?void 0:t.data)||{}};var g=function(t,e){var r=l({},t),n={};if((null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!c().isMatch()||t.storage&&t.baseRequest)return r;try{var o=c().genAdapter({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new f({localStorage:i,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(t){return function(e,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:e,data:i.body,timeout:t._timeout,method:i.method||"GET",header:i.headers,success:function(t){(t=y(t,l(l({},r),{url:e}))).error&&o(t),n(t)},fail:function(t){o({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&(t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg)){console.warn(t._timeoutMsg);try{s.abort()}catch(t){}}}})}))]}))}))}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),l(l({},r),n)}catch(t){console.error("adapter generate fail:",t)}return r},m=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var r=l({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(r.storage=new f({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(r.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var n=new e.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(t,e){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=e.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=e.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=e.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof e.body)||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,d(l({url:t},e))];case 2:return u=p.sent(),u=y(u,l(l({},e),{url:t})),[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(t){console.error("user adapter generate fail:",t)}return r}(t,t.adapter):g(t,t.adapter)};var b="@cloudbase/js-sdk";function w(){return b}var _="https:";var I="INVALID_PARAMS",A="INVALID_OPERATION",E="OPERATION_FAIL",S=o(829);function O(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}function T(t,e){console.warn("[".concat(w(),"][").concat(t,"]:").concat(e))}var P,U=(P=function(t,e){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}P(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),k=function(){return(k=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},C=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},L=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}U(e,t),e.prototype.get=function(t){return this.request(k(k({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(k(k({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(k(k({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,i=t.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(e).forEach((function(t){u.append(t,e[t])})),u.append("key",n),u.append("file",r),this.request(k(k({},t),{data:u,method:a}),this.restrictedMethods.includes("upload"))):this.request(k(k({},t),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return C(this,void 0,void 0,(function(){var e,r,n,o;return L(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(k(k({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.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(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;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 L(this,(function(y){switch(y.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,i=void 0!==o&&o,s=t.stream,a=void 0!==s&&s,u=t.signal,c=t.timeout,d=t.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({},t),{signal:r.signal})).then((function(t){return C(v,void 0,void 0,(function(){var e,r,n;return L(this,(function(o){switch(o.label){case 0:return clearTimeout(p),l?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){if(clearTimeout(p),l)return Promise.reject(t)}))];case 1:return f=y.sent(),[2,{data:a?f.body:(null===(e=f.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?f.json():f.text(),statusCode:f.status,header:f.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a,u=t.url,c=t.headers,d=void 0===c?{}:c,l=t.data,h=t.responseType,p=t.withCredentials,f=t.body,v=t.onUploadProgress,y=function(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}(_,u,"get"===n?l:{}),g=new XMLHttpRequest;g.open(n,y),h&&(g.responseType=h),Object.keys(d).forEach((function(t){g.setRequestHeader(t,d[t])})),v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=g.status;try{t.data="blob"===h?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===h?g.response:g.responseText}clearTimeout(i),o(t)}},e&&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(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")}(l):f||(l?JSON.stringify(l):void 0),p&&(g.withCredentials=!0),g.send(s)}))}}(S.AbstractSDKRequest);var N;!function(t){t.WEB="web",t.WX_MP="wx_mp"}(N||(N={}));var R=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),x=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},j=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return R(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(S.AbstractStorage);!function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(T(I,"localStorage is not supported on current platform"),new M(e.root));case"none":return new M(e.root);default:return e.localStorage?e.localStorage:(T(I,"localStorage is not supported on current platform"),new M(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:E,msg:"[".concat(w(),"][").concat(E,"]setStore failed"),info:t}))}}else T(A,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,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:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){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(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}T(A,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){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(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):T(A,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return x(this,void 0,void 0,(function(){return j(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))}}();var D=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),q=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var W=function(t,e){this.data=e||null,this.name=t},H=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return D(e,t),e}(W),G=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof H)return console.error(t.error),this;var r="string"==typeof t?new W(t,e||{}):t,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},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new G;new G;"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");!function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,r){"abort"===e&&t.listeners.push(r)}}}t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(t){return t()})))}}();function Y(t){this.message=t}Y.prototype=new Error,Y.prototype.name="InvalidCharacterError";"undefined"!=typeof window&&window.atob&&window.atob.bind(window);function F(t){this.message=t}F.prototype=new Error,F.prototype.name="InvalidTokenError";var V=function(){return(V=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},B=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},K=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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])}}},J=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},$=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},Q=function(){function e(t){this.listeners=new Map,this.hasListenerSetUp=!1,this.config=t,this.oauthInstance=t.oauthInstance,this.cache=t.cache,this.init()}return Object.defineProperty(e.prototype,"currentUser",{get:function(){var t=this.hasLoginState();return t&&t.user||null},enumerable:!1,configurable:!0}),e.prototype.hasLoginState=function(){throw new Error("Auth.hasLoginState() is not implemented")},e.prototype.setAccessKey=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.setAccessKey() is not implemented")}))}))},e.prototype.signIn=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.signIn() is not implemented")}))}))},e.prototype.signInWithProvider=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.signInWithProvider() is not implemented")}))}))},e.prototype.genProviderRedirectUri=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.genProviderRedirectUri() is not implemented")}))}))},e.prototype.getAccessToken=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.getAccessToken() is not implemented")}))}))},e.prototype.getUserInfo=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.getUserInfo() is not implemented")}))}))},e.prototype.updateUserBasicInfo=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.updateUserBasicInfo() is not implemented")}))}))},e.prototype.setCustomSignFunc=function(t){throw new Error("Auth.setCustomSignFunc() is not implemented")},e.prototype.grantProviderToken=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.grantProviderToken() is not implemented")}))}))},e.prototype.bindWithProvider=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.bindWithProvider() is not implemented")}))}))},e.prototype.signInWithUsername=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.signInWithUsername() is not implemented")}))}))},e.prototype.getVerification=function(t,e){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.getVerification() is not implemented")}))}))},e.prototype.createLoginState=function(t,e){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.createLoginState() is not implemented")}))}))},e.prototype.verify=function(t){return B(this,void 0,void 0,(function(){return K(this,(function(t){throw new Error("Auth.verify() is not implemented")}))}))},e.prototype.signInAnonymously=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];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 t.AuthError(i)}];case 5:return[2]}}))}))},e.prototype.signUp=function(e){return B(this,void 0,void 0,(function(){var r,n,o=this;return K(this,(function(i){switch(i.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?[4,this.oauthInstance.authApi.signUp(e)]:[3,2];case 1:return i.sent(),[2,this.createLoginState()];case 2:return i.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.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 B(o,void 0,void 0,(function(){var n,o,s,u,c;return K(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:e.email||this.formatPhone(e.phone),verification_token:n.verification_token})]:[3,3];case 2:return d.sent(),[3,6];case 3:return delete(o=JSON.parse(JSON.stringify(e))).email,delete o.phone,[4,this.oauthInstance.authApi.signUp(V(V(V({},o),e.email?{email:e.email}:{phone_number:this.formatPhone(e.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 t.AuthError(c)}];case 9:return[2]}}))}))}},error:null}];case 4:return n=i.sent(),[2,{data:{},error:new t.AuthError(n)}];case 5:return[2]}}))}))},e.prototype.signOut=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),r=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return n=i.sent(),[4,this.cache.removeStoreAsync(r)];case 2:return i.sent(),this.setAccessKey(),nt.fire(t.EVENTS.LOGIN_STATE_CHANGED,{eventType:t.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,V(V({},n),{data:{},error:null})];case 3:return o=i.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.onAuthStateChange=function(t){var e=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(t),{data:{subscription:{id:r,callback:t,unsubscribe:function(){var n=e.listeners.get(r);n&&(n.delete(t),0===n.size&&e.listeners.delete(r))}}}}},e.prototype.signInWithPassword=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(V({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.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 t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.signInWithIdToken=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.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 t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.signInWithOtp=function(e){return B(this,void 0,void 0,(function(){var r,n,o=this;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 1:return r=i.sent(),[2,{data:{user:null,session:null,verifyOtp:function(t){var n=t.token,i=t.messageId,s=void 0===i?r.verification_id:i;return B(o,void 0,void 0,(function(){return K(this,(function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:n,messageId:s})]}))}))}},error:null}];case 2:return n=i.sent(),[2,{data:{},error:new t.AuthError(n)}];case 3:return[2]}}))}))},e.prototype.verifyOAuth=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d;return K(this,(function(l){switch(l.label){case 0:r={},l.label=1;case 1:return l.trys.push([1,7,,8]),n=(null==e?void 0:e.code)||O("code"),o=(null==e?void 0:e.state)||O("state"),n?o?(i=function(t){try{return JSON.parse(sessionStorage.getItem(t))}catch(t){return console.error("Failed to get browser session:",t),null}}(o),r.type=null==i?void 0:i.type,(s=(null==e?void 0:e.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 t.AuthError({message:"Provider is required"})}]):[2,{data:{},error:new t.AuthError({message:"State is required"})}]:[2,{data:{},error:new t.AuthError({message:"Code is required"})}];case 2:return a=l.sent().provider_token,u=void 0,i.type!==t.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(t,e){if(void 0!==t){var r=new URL(window.location.href);r.search=t,r.hash=e||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(t){try{sessionStorage.removeItem(t)}catch(t){return console.error("Failed to remove browser session:",t),null}}(o),[2,u];case 7:return d=l.sent(),[2,{data:r,error:new t.AuthError(d)}];case 8:return[2]}}))}))},e.prototype.signInWithOAuth=function(e){var r,n,o,i,s;return B(this,void 0,void 0,(function(){var a,u,c,d,l,h,p,f,v;return K(this,(function(y){switch(y.label){case 0:return y.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),a=(null===(r=e.options)||void 0===r?void 0:r.redirectTo)||location.href,u=new URL(a),c=u.origin+u.pathname,d=(null===(n=e.options)||void 0===n?void 0:n.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:c,state:d})];case 1:return l=y.sent().uri,h=decodeURIComponent(l),p=h,(null===(o=e.options)||void 0===o?void 0:o.queryParams)&&(f=new URL(h),Object.entries(e.options.queryParams).forEach((function(t){var e=t[0],r=t[1];f.searchParams.set(e,r)})),p=f.toString()),function(t,e){try{sessionStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save to browser session:",t)}}(d,{provider:e.provider,search:u.search,hash:u.hash,type:(null===(i=e.options)||void 0===i?void 0:i.type)||t.OAUTH_TYPE.SIGN_IN}),$()&&!(null===(s=e.options)||void 0===s?void 0:s.skipBrowserRedirect)&&window.location.assign(p),[2,{data:{url:p,provider:e.provider},error:null}];case 2:return v=y.sent(),[2,{data:{},error:new t.AuthError(v)}];case 3:return[2]}}))}))},e.prototype.signInWithSSO=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){return[2]}))}))},e.prototype.signInWithWeb3=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){return[2]}))}))},e.prototype.getClaims=function(){return B(this,void 0,void 0,(function(){var e,r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=n.sent().accessToken,[2,{data:(0,t.weappJwtDecodeAll)(e),error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForEmail=function(e,r){return B(this,void 0,void 0,(function(){var n,o,i,s,a,u,c=this;return K(this,(function(d){switch(d.label){case 0:return d.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),n=(r||{}).redirectTo,o=e.includes("@"),i=void 0,o?i={email:e}:(s=this.formatPhone(e),i={phone_number:s}),[4,this.getVerification(i)];case 1:return a=d.sent(),[2,{data:{updateUser:function(r){return B(c,void 0,void 0,(function(){var i,s,u;return K(this,(function(c){switch(c.label){case 0:this.validateParams(r,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:a.verification_id,verification_code:r.nonce})];case 2:return i=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:o?e:void 0,phone:o?void 0:e,new_password:r.password,verification_token:i.verification_token})];case 3:return c.sent(),nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:o?e:void 0,phone:o?void 0:e,password:r.password})];case 4:return s=c.sent(),n&&$()&&window.location.assign(n),[2,s];case 5:return u=c.sent(),[2,{data:{},error:new t.AuthError(u)}];case 6:return[2]}}))}))}},error:null}];case 2:return u=d.sent(),[2,{data:{},error:new t.AuthError(u)}];case 3:return[2]}}))}))},e.prototype.resetPasswordForOld=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.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 t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.verifyOtp=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),r=e.type,this.validateParams(e,{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:e.messageId,verification_code:e.token})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:e.token,username:e.email||this.formatPhone(e.phone)||"",loginType:e.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 t.AuthError(i)}];case 7:return[2]}}))}))},e.prototype.getSession=function(){return B(this,void 0,void 0,(function(){var e,r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=i.sent())&&"accessKey"!==e.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({},e),{user:n})},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.refreshSession=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i,s;return K(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=e||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 t.AuthError(s)}];case 5:return[2]}}))}))},e.prototype.getUser=function(){return B(this,void 0,void 0,(function(){var e,r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=this.convertToUser,[4,this.getUserInfo()];case 1:return[2,{data:{user:e.apply(this,[n.sent()])},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.refreshUser=function(){return B(this,void 0,void 0,(function(){var e,r,n;return K(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 e=o.sent().data,[2,{data:{user:(r=(void 0===e?{}:e).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new t.AuthError(n)}];case 4:return[2]}}))}))},e.prototype.updateUser=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i,s,a,u,c,d,l,h,p,f=this;return K(this,(function(v){switch(v.label){case 0:if(v.trys.push([0,8,,9]),!Object.keys(e).some((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})))throw new t.AuthError({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=J(e,["email","phone"]),s=void 0!==n,a={},(i=void 0!==r)||s?(u=void 0,i?(u={email:e.email},c="email_change"):(d=this.formatPhone(e.phone),u={phone_number:d},c="phone_change"),[4,this.getVerification(u)]):[3,4];case 1:return l=v.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:v.sent(),v.label=3;case 3:return a={messageId:l.verification_id,verifyOtp:function(r){return B(f,void 0,void 0,(function(){var n,o;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),r.email&&e.email===r.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:r.token,messageId:l.verification_id})]:[3,3];case 1:return s.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return r.phone&&e.phone===r.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:r.token,messageId:l.verification_id})]:[3,6];case 4:return s.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp({type:c,email:i?e.email:void 0,phone:i?void 0:e.phone,token:r.token,messageId:l.verification_id})];case 7:return s.sent(),[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser()];case 10:return n=s.sent().data.user,nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return o=s.sent(),[2,{data:{},error:new t.AuthError(o)}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:v.sent(),v.label=6;case 6:return[4,this.getUser()];case 7:return h=v.sent().data.user,nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:V({user:h},a),error:null}];case 8:return p=v.sent(),[2,{data:{},error:new t.AuthError(p)}];case 9:return[2]}}))}))},e.prototype.getUserIdentities=function(){var e;return B(this,void 0,void 0,(function(){var r,n;return K(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===(e=null==r?void 0:r.data)||void 0===e?void 0:e.filter((function(t){return!!t.bind}))},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new t.AuthError(n)}];case 3:return[2]}}))}))},e.prototype.linkIdentity=function(e){return B(this,void 0,void 0,(function(){var r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:t.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return n.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.unlinkIdentity=function(e){return B(this,void 0,void 0,(function(){var r;return K(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return n.sent(),[2,{data:{},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new t.AuthError(r)}];case 3:return[2]}}))}))},e.prototype.reauthenticate=function(){return B(this,void 0,void 0,(function(){var e,r,n,o,i=this;return K(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser()];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),r=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(r)];case 2:return n=s.sent(),[2,{data:{updateUser:function(e){return B(i,void 0,void 0,(function(){var o,i,s,a,u;return K(this,(function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:n.verification_id,verification_code:e.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:e.password,sudo_token:i.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(V(V({verificationInfo:n,verificationCode:e.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 t.AuthError(u)}];case 10:return[2]}}))}))}},error:null}];case 3:return o=s.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.resend=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),r="signup"===e.type?"ANY":"USER",n={target:r},"email"in e&&(n.email=e.email),"phone"in e&&(n.phone_number=this.formatPhone(e.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 t.AuthError(o)}];case 3:return[2]}}))}))},e.prototype.setSession=function(e){return B(this,void 0,void 0,(function(){var r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwOnError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new t.AuthError(o)}];case 4:return[2]}}))}))},e.prototype.exchangeCodeForSession=function(){return B(this,void 0,void 0,(function(){return K(this,(function(t){return[2]}))}))},e.prototype.deleteUser=function(e){return B(this,void 0,void 0,(function(){var r,n;return K(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];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 t.AuthError(n)}];case 4:return[2]}}))}))},e.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),B(this,void 0,void 0,(function(){var r,n,o,i,s;return K(this,(function(a){try{return r=e.config_version||"env",n=Object.keys(e.query||{}).map((function(t){return"".concat(t,"=").concat(e.query[t])})).join("&"),c().isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(n?"?".concat(n):"")}):(o=e.redirect_uri||window.location.href,i=new URL(o),s="".concat(i.origin,"/__auth/?app_id=").concat(e.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(e){return[2,{data:{},error:new t.AuthError(e)}]}return[2]}))}))},e.prototype.signInWithCustomTicket=function(e){return B(this,void 0,void 0,(function(){var r,n,o,i;return K(this,(function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),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 t.AuthError(i)}];case 6:return[2]}}))}))},e.prototype.signInWithOpenId=function(e){var r=(void 0===e?{}:e).useWxCloud,n=void 0===r||r;return B(this,void 0,void 0,(function(){var e,r,o,i,s,a,u=this;return K(this,(function(d){switch(d.label){case 0:if(!c().isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,r=function(t){return B(u,void 0,void 0,(function(){var r,o;return K(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==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.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(t,e){wx.login({success:function(n){return B(u,void 0,void 0,(function(){var o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(n.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return o=i.sent(),e(o),[3,3];case 3:return[2]}}))}))},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(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 t.AuthError(a)}];case 6:return[2]}}))}))},e.prototype.signInWithPhoneAuth=function(e){var r=e.phoneCode,n=void 0===r?"":r;return B(this,void 0,void 0,(function(){var e,r,o,i,s,a,u,d,l;return K(this,(function(h){switch(h.label){case 0:return c().isMatch()?(e=wx.getAccountInfoSync().miniProgram,r={provider_params:{provider_code_type:"phone"},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new t.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:e.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 t.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})]}}))}))},e.prototype.formatPhone=function(t){return!/\s+/.test(t)&&/^\+\d{1,3}\d+/.test(t)?t.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(t)?t:"+86 ".concat(t)},e.prototype.notifyListeners=function(t,e,r){this.listeners.forEach((function(n){n.forEach((function(n){try{n(t,e,r)}catch(t){console.error("Error in auth state change callback:",t)}}))}))},e.prototype.init=function(){return B(this,void 0,void 0,(function(){return K(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return e.sent()&&nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION}),[3,3];case 2:return e.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},e.prototype.setupListeners=function(){var e=this;nt.on(t.EVENTS.AUTH_STATE_CHANGED,(function(t){return B(e,void 0,void 0,(function(){var e,r,n,o,i;return K(this,(function(s){switch(s.label){case 0:return e=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.event,r=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(e,n,r),[2]}}))}))}))},e.prototype.convertToUser=function(t){var e,r,n;if(!t)return null;var o=(null==t?void 0:t.email)||(null==t?void 0:t.username),i=null==t?void 0:t.phone_number,s=(null==t?void 0:t.sub)||(null==t?void 0:t.uid)||"";return{id:s,aud:"authenticated",role:t.groups,email:o||"",email_confirmed_at:(null==t||t.email_verified,t.created_at),phone:i,phone_confirmed_at:i?t.created_at:void 0,confirmed_at:t.created_at,last_sign_in_at:t.last_sign_in_at,app_metadata:{provider:(null===(e=t.loginType)||void 0===e?void 0:e.toLowerCase())||"cloudbase",providers:[(null===(r=t.loginType)||void 0===r?void 0:r.toLowerCase())||"cloudbase"]},user_metadata:{name:null==t?void 0:t.name,picture:null==t?void 0:t.picture,username:null==t?void 0:t.username,gender:null==t?void 0:t.gender,locale:null==t?void 0:t.locale,uid:t.uid,nickName:t.nickName,avatarUrl:t.avatarUrl||t.picture,location:t.location,hasPassword:t.hasPassword},identities:(null===(n=null==t?void 0:t.providers)||void 0===n?void 0:n.map((function(e){return{id:e.id||"",identity_id:e.id||"",user_id:s,identity_data:{provider_id:e.id,provider_user_id:e.provider_user_id,name:e.name},provider:e.id||"cloudbase",created_at:t.created_at,updated_at:t.updated_at,last_sign_in_at:t.last_sign_in_at}})))||[],created_at:t.created_at,updated_at:t.updated_at,is_anonymous:"anonymous"===t.name}},e.prototype.validateParams=function(e,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==e?void 0:e[s])||null===(null==e?void 0:e[s])||""===(null==e?void 0:e[s])))throw new t.AuthError({message:a.message})}},e.prototype.validateAtLeastOne=function(e,r,n){if(!r.some((function(t){return t.some((function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])}))})))throw new t.AuthError({message:n})},e}(),z=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),X=function(){return(X=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},Z=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s},tt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},et=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},rt=function(t,e){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=e.call(t,s)}catch(t){a=[6,t],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])}}},nt=new s.CloudbaseEventEmitter,ot=function(e){nt.fire(t.EVENTS.LOGIN_STATE_CHANGED,X(X({},e),{eventType:t.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))},it=function(){function t(t){var e=t.cache,r=t.oauthInstance;this.cache=e,this.oauthInstance=r,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){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]}))}))},t.prototype.checkLocalInfoAsync=function(){return et(this,void 0,void 0,(function(){var t,e,r,n;return rt(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.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]}}))}))},t.prototype.update=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(X({},t))];case 1:return e=r.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(X({},t))];case 1:return e.sent(),[4,this.refresh()];case 2:return e.sent(),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,e.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:if("INVALID_ACCESS_TOKEN"===(e=r.sent()).code)throw this.setLocalUserInfo({}),e;return this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);return t?r[t]:r||{}},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},t.prototype.getLocalUserInfoAsync=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,r.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,r=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at"].forEach((function(e){t[e]=r[e]}))},Z([(0,n.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],t.prototype,"update",null),Z([(0,n.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[String,String]),tt("design:returntype",void 0)],t.prototype,"updatePassword",null),Z([(0,n.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[String]),tt("design:returntype",void 0)],t.prototype,"updateUsername",null),Z([(0,n.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],t.prototype,"refresh",null),t}(),st=function(){function t(t){var n=t.envId,o=t.cache,i=t.oauthInstance;n||(0,e.throwError)(r.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=o,this.oauthInstance=i,this.user=new it({cache:this.cache,oauthInstance:i})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}(),at=function(o){function i(t){var e=o.call(this,t)||this;return e.setAccessKey(),e}return z(i,o),i.prototype.bindPhoneNumber=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},i.prototype.unbindProvider=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},i.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},i.prototype.verify=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},i.prototype.getVerification=function(t,e){return et(this,void 0,void 0,(function(){return rt(this,(function(r){return[2,this.oauthInstance.authApi.getVerification(t,e)]}))}))},Object.defineProperty(i.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,e.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),i.prototype.getCurrentUser=function(){return et(this,void 0,void 0,(function(){var t,e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?(e=t.user.getLocalUserInfo(),[4,t.user.checkLocalInfoAsync()]):[3,3];case 2:return r.sent(),[2,X(X({},t.user),e)];case 3:return[2,null]}}))}))},i.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return et(this,void 0,void 0,(function(){var t,r,n=this;return rt(this,(function(o){switch(o.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,r=function(r){return et(n,void 0,void 0,(function(){var n,o;return rt(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==t?void 0:t.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];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},e)];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(t,e){wx.login({success:function(o){return et(n,void 0,void 0,(function(){var n;return rt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return n=i.sent(),e(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var r=new Error(null==t?void 0:t.errMsg);r.code=null==t?void 0:t.errno,e(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},i.prototype.bindOpenId=function(){return et(this,void 0,void 0,(function(){var t,e,r=this;return rt(this,(function(n){switch(n.label){case 0:if(!c().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return et(r,void 0,void 0,(function(){var r;return rt(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==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.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(t,n){wx.login({success:function(o){return et(r,void 0,void 0,(function(){var r;return rt(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})}))];case 1:return n.sent(),[2]}}))}))},i.prototype.signInWithUnionId=function(){return et(this,void 0,void 0,(function(){var t=this;return rt(this,(function(e){switch(e.label){case 0:if(!c().isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return et(t,void 0,void 0,(function(){var t,i,s,a,u;return rt(this,(function(c){switch(c.label){case 0:t=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:t,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:t,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(e(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},i.prototype.signInWithSms=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a;return et(this,void 0,void 0,(function(){return rt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:u,username:s,loginType:"sms"})]}catch(t){throw t}return[2]}))}))},i.prototype.signInWithEmail=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.bindInfo,s=void 0===i?void 0:i,a=t.email,u=void 0===a?"":a;return et(this,void 0,void 0,(function(){return rt(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:u,loginType:"email"})]}catch(t){throw t}return[2]}))}))},i.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},i.prototype.signIn=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},i.prototype.setPassword=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},i.prototype.isUsernameRegistered=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&(0,e.throwError)(r.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,n.sent().exist]}}))}))},i.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new st({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,e.printWarn)(r.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},i.prototype.getLoginState=function(){return et(this,void 0,void 0,(function(){var t;return rt(this,(function(e){switch(e.label){case 0:t=null,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[2,null];case 4:return t?[2,new st({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},i.prototype.getUserInfo=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.getCurrentUser()]}))}))},i.prototype.getWedaUserInfo=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},i.prototype.updateUserBasicInfo=function(t){return et(this,void 0,void 0,(function(){var e;return rt(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},i.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},i.prototype.bindWithProvider=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},i.prototype.queryUser=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},i.prototype.getAccessToken=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},i.prototype.grantProviderToken=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},i.prototype.patchProviderToken=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},i.prototype.signInWithProvider=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},i.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},i.prototype.grantToken=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},i.prototype.genProviderRedirectUri=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},i.prototype.resetPassword=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},i.prototype.deviceAuthorize=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},i.prototype.sudo=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},i.prototype.deleteMe=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},i.prototype.getProviders=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},i.prototype.loginScope=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},i.prototype.loginGroups=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},i.prototype.onLoginStateChanged=function(e){return et(this,void 0,void 0,(function(){var r,n=this;return rt(this,(function(o){switch(o.label){case 0:return nt.on(t.EVENTS.LOGIN_STATE_CHANGED,(function(r){return et(n,void 0,void 0,(function(){var n,o,i;return rt(this,(function(s){switch(s.label){case 0:return(null===(i=null==r?void 0:r.data)||void 0===i?void 0:i.eventType)===t.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,e.call(this,X(X({},r),n)),[2]}}))}))})),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}}))}))},i.prototype.refreshTokenForce=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},i.prototype.getCredentials=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},i.prototype.setCredentials=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},i.prototype.getProviderSubType=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},i.prototype.createCaptchaData=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},i.prototype.verifyCaptchaData=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},i.prototype.getMiniProgramQrCode=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},i.prototype.getMiniProgramQrCodeStatus=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},i.prototype.modifyPassword=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},i.prototype.modifyPasswordWithoutLogin=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]}))}))},i.prototype.getUserBehaviorLog=function(t){return et(this,void 0,void 0,(function(){return rt(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},i.prototype.signInWithUsername=function(t){var e=t.verificationInfo,r=void 0===e?{verification_id:"",is_user:!1}:e,n=t.verificationCode,o=void 0===n?"":n,i=t.username,s=void 0===i?"":i,a=t.bindInfo,u=void 0===a?void 0:a,c=t.loginType,d=void 0===c?"":c;return et(this,void 0,void 0,(function(){var t,e,n,i,a,c,l;return rt(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==(t=h.sent())?void 0:t.error_code)throw t;return e=t.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:e})]:[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(X(X({},i),{verification_token:e,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]}}))}))},i.prototype.createLoginState=function(e,r){return et(this,void 0,void 0,(function(){var n;return rt(this,(function(o){switch(o.label){case 0:return[4,(n=new st({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return o.sent(),(null==r?void 0:r.userInfo)?(n.user.setLocalUserInfo(r.userInfo),[3,5]):[3,2];case 2:return(null==r?void 0:r.asyncRefreshUser)?(n.user.refresh(e),[3,5]):[3,3];case 3:return[4,n.user.refresh(e)];case 4:o.sent(),o.label=5;case 5:return nt.fire(t.EVENTS.LOGIN_STATE_CHANGED,{eventType:t.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,n]}}))}))},i.prototype.setAccessKey=function(){return et(this,void 0,void 0,(function(){return rt(this,(function(t){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(t){console.warn("accessKey error: ",t)}return[2]}))}))},Z([(0,n.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"bindPhoneNumber",null),Z([(0,n.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"unbindProvider",null),Z([(0,n.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",void 0)],i.prototype,"bindEmail",null),Z([(0,n.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"verify",null),Z([(0,n.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object,Object]),tt("design:returntype",Promise)],i.prototype,"getVerification",null),Z([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getCurrentUser",null),Z([(0,n.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"signInAnonymouslyInWx",null),Z([(0,n.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"bindOpenId",null),Z([(0,n.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"signInWithUnionId",null),Z([(0,n.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"signInWithSms",null),Z([(0,n.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"signInWithEmail",null),Z([(0,n.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[String]),tt("design:returntype",Promise)],i.prototype,"isUsernameRegistered",null),Z([(0,n.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getLoginState",null),Z([(0,n.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getUserInfo",null),Z([(0,n.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getWedaUserInfo",null),Z([(0,n.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[Object]),tt("design:returntype",Promise)],i.prototype,"bindWithProvider",null),Z([(0,n.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(r.COMMUNITY_SITE_URL)]}),tt("design:type",Function),tt("design:paramtypes",[]),tt("design:returntype",Promise)],i.prototype,"getProviderSubType",null),i}(Q);function ut(e,r){var n=this,o=e.region,i=void 0===o?"ap-shanghai":o,s=e.i18n,u=e.accessKey,c=e.useWxCloud,l=(null==r?void 0:r.platform)||d.useDefaultAdapter.bind(r)(),h=l.runtime,p=l.adapter,f=r||{},v=f.env,y=f.clientId,g=f.debug,b=f.cache,w=f.app,_=(r||{}).apiOrigin;_||(_="https://".concat(v,".").concat(i,".tcb-api.tencentcloudapi.com"));var I={env:v,clientId:y,i18n:s,accessKey:u,useWxCloud:c,eventBus:nt},A=new t.CloudbaseOAuth(m(X(X({},I),{apiOrigin:_,apiPath:(null==e?void 0:e.apiPath)||t.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:p,onCredentialsError:ot,headers:X({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:g}))),E=new at(X(X({},I),{region:i,persistence:e.persistence,debug:g,cache:b||new a.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(v)},platformInfo:l}),runtime:h||"web",_fromApp:w,oauthInstance:A}));return A.initializeSession((function(e,r){return et(n,void 0,void 0,(function(){return rt(this,(function(n){return e?(e.type===t.OAUTH_TYPE.SIGN_IN?r?nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:X(X({},e),{error:r})}):e.user&&E.createLoginState({},{userInfo:e.user}):e.type===t.OAUTH_TYPE.BIND_IDENTITY&&nt.fire(t.EVENTS.AUTH_STATE_CHANGED,{event:t.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:X(X({},e),{error:r})}),[2]):[2]}))}))})),{authInstance:E,oauthInstance:A}}var ct={name:"auth",namespace:"auth",entity:function(e){var r;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:t.AUTH_API_PREFIX};var n=this.platform.adapter,o=e.persistence||n.primaryStorage;o&&o!==this.config.persistence&&this.updateConfig({persistence:o});var i=ut(X(X({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{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}};try{cloudbase.registerComponent(ct)}catch(Y){}function dt(t){try{t.registerComponent(ct)}catch(t){console.warn(t)}}})(),i})());
|