@cloudbase/auth 2.19.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 n={829:(t,e,n)=>{var r;n.r(e),n.d(e,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>r,formatUrl:()=>s}),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},105:function(t,e,n){var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),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 n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,c=s(n(587)),u=n(894);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var n=0,o=(0,u.isArray)(t)?t:[t];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,c=i.runtime;if(s())return{adapter:r({isMatch:s},a(e)),runtime:c}}},e.useDefaultAdapter=function(){return{adapter:c.genAdapter(),runtime:a.WEB}}},587:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=n(829),u=n(894),h=n(652),d=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}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,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===c?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",r),u.append("file",n),this.request(i(i({},t),{data:u,method:c}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,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,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),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 n,r,o,c,u,h,d,l,p,f,v,g=this;return a(this,(function(y){switch(y.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,c=void 0!==o&&o,u=t.stream,h=void 0!==u&&u,d=t.signal,l=t.timeout,p=null!=l?l:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",(function(){return n.abort()}))),f=null,c&&p&&(f=setTimeout((function(){console.warn(g.timeoutMsg),n.abort(new Error(g.timeoutMsg))}),p)),[4,fetch(r,i(i({},t),{signal:n.signal})).then((function(t){return s(g,void 0,void 0,(function(){var e,n,r;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(f),t.ok?(e=t,[3,3]):[3,1];case 1:return r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(f),Promise.reject(t)}))];case 1:return v=y.sent(),[2,{data:h?v.body:(null===(e=v.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?v.json():v.text(),statusCode:v.status,header:v.headers}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,c=t.headers,d=void 0===c?{}:c,l=t.data,p=t.responseType,f=t.withCredentials,v=t.body,g=t.onUploadProgress,y=(0,u.formatUrl)((0,h.getProtocol)(),a,"get"===r?l:{}),m=new XMLHttpRequest;m.open(r,y),p&&(m.responseType=p),Object.keys(d).forEach((function(t){m.setRequestHeader(t,d[t])})),g&&m.upload.addEventListener("progress",g),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,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&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),s=(0,u.isFormData)(l)?l:"application/x-www-form-urlencoded"===d["content-type"]?(0,u.toQueryString)(l):v||(l?JSON.stringify(l):void 0),f&&(m.withCredentials=!0),m.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=d,e.genAdapter=function(){return{type:"default",root:window,reqClass:d,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 n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},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,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(652),e),o(n(151),e),e.OATUH_LOGINTYPE="constants"},64:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(894),s=n(141),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),d=s.findIndex((function(t){return c.test(t)}));if(-1!==d){var l=s.filter((function(t,e){return e>d}));l.unshift(s[d].replace(h,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(l.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,d=void 0===a?{}:a,l=t.title,p=t.messages,f=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=d.className||t.constructor.name,v=d.methodName||e,g=a.value,y=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return c.test(t)}));if(-1!==r){var o=u.exec(n[r+1]||"");e=o?o[0]:""}return e}(new Error);a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=h({err:new Error,className:p,methodName:v,sourceLink:y});try{return g.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,c={title:l||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(t.code=u.code,t.message=u.msg),r=n||t,c.content=f.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(c.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,c.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,c,u,d;return o(this,(function(o){switch(o.label){case 0:e=h({err:new Error,className:p,methodName:v,sourceLink:y}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,c=n.error_description,u={title:l||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),u.subtitle=d,d.code&&(e?(e.code=d.code,e.message=d.msg):(n.code=d.code,n.message=d.msg),r=e||n,u.content=f.map((function(t){return{type:"info",body:t}})))),a&&c&&(u.subtitle=c,e?(e.code=a,e.msg=c):(n.code=a,n.message=c),r=e||n,u.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),r;case 4:return[2]}}))}))}}}}},466:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(64),e)},418:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(829),c=n(894),u=n(141),h=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}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 d=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root));case"none":return new h(e.root);default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(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,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;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]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.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(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,c.printWarn)(u.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=d},988:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||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=n(894);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var c=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=c;var u=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,c))return console.error(t.error),this;var n=(0,s.isString)(t)?new a(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,u=this.listeners[r]?i([],this.listeners[r],!0):[];o<u.length;o++){u[o].call(this,n)}}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var h=new u;e.addEventListener=function(t,e){h.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),h.fire(t,e)},e.removeEventListener=function(t,e){h.off(t,e)}},894:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),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 r=n(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(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:7&r|8).toString(16)}))},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[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(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||window.location.search,r=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);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 n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},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 n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,n=t.title,r=t.subtitle,o=void 0===r?"":r,i=t.content,s=void 0===i?[]:i,a=t.printTrace,c=void 0!==a&&a,u=t.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var h=0,d=s;h<d.length;h++){var l=d[h],p=l.type,f=l.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}c&&(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 n=t.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(e[r]?Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]:e[r]=o)})),e}},219:t=>{t.exports=e},297:e=>{e.exports=t}},r={};function o(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return n[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 n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},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:()=>x,LoginState:()=>T,generateAuthInstance:()=>M,registerAuth:()=>k});var t=o(297),e=o(894),n=o(141),r=o(466),s=o(988),a=o(418),c=o(219),u=o.n(c),h=o(105),d=function(){return(d=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},p=function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},f=function(){function t(t){var e,n;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(n=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===n?void 0:n.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return l(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return l(this,void 0,void 0,(function(){return p(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return l(this,void 0,void 0,(function(){return p(this,(function(n){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=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,g=function(t,e){var n,r,o,i,s=null===(n=null==e?void 0:e.headers)||void 0===n?void 0:n["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.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 y=function(t,e){if(!u().isMatch()||t.storage&&t.baseRequest)return t;var n=d({},t),r={};try{var o=u().genAdapter(),i=o.localStorage,s=o.reqClass;if(i&&(r.storage=new f({localStorage:i,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.request=function(t){return function(e,n){return l(this,void 0,void 0,(function(){return p(this,(function(r){return[2,new Promise((function(r,o){var i=Object.assign({},n);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=g(t,d(d({},n),{url:e}))).error&&o(t),r(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 n.captchaOptions&&(r.baseRequest=r.request,r.request=void 0),d(d({},n),r)}catch(t){console.error("adapter generate fail:",t)}return n},m=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var n=d({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(n.storage=new f({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(n.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var r=new e.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.baseRequest=function(t,e){var n;return l(this,void 0,void 0,(function(){var o,i,s,a;return p(this,(function(c){switch(c.label){case 0:if(o={},i=(null===(n=e.method)||void 0===n?void 0:n.toLocaleLowerCase())||"get","function"!=typeof(s=null==r?void 0:r[i]))throw new Error("invalid 【".concat(i,"】 request method"));c.label=1;case 1:return c.trys.push([1,3,,4]),e.headers["content-type"]&&!e.headers["content-type"].includes("application/json")||"string"==typeof e.body||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,s(d({url:t},e))];case 2:return o=c.sent(),o=g(o,d(d({},e),{url:t})),[3,4];case 3:throw a=c.sent(),o=a,a;case 4:if(null==o?void 0:o.error)throw o;return[2,o]}}))}))}}}catch(t){console.error("user adapter generate fail:",t)}return n}(t,t.adapter):y(t,t.adapter)},I=function(){return(I=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},b=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},_=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},w=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},O=function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},S="sign_out",A="sign_in",P="credentials_error",E="loginStateChanged",U=new s.CloudbaseEventEmitter,R=function(t){U.fire(E,I(I({},t),{eventType:P}))},L=function(){function t(t){var e=t.cache,n=t.oauthInstance;this.cache=e,this.oauthInstance=n,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return w(this,void 0,void 0,(function(){return O(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 w(this,void 0,void 0,(function(){var t,e,n,r;return O(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"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.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 w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(I({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(I({},t))];case 1:return e.sent(),this.setLocalUserInfo({username:t.username}),[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)(n.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=n[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},b([(0,r.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"update",null),b([(0,r.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[String,String]),_("design:returntype",void 0)],t.prototype,"updatePassword",null),b([(0,r.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[String]),_("design:returntype",void 0)],t.prototype,"updateUsername",null),b([(0,r.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"refresh",null),t}(),T=function(){function t(t){var r=t.envId,o=t.cache,i=t.oauthInstance;r||(0,e.throwError)(n.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=o,this.oauthInstance=i,this.user=new L({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 w(this,void 0,void 0,(function(){return O(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}(),x=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},t.prototype.verify=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t,e){return w(this,void 0,void 0,(function(){return O(this,(function(n){return[2,this.oauthInstance.authApi.getVerification(t,e)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,e.printWarn)(n.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return w(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return w(this,void 0,void 0,(function(){var t,n,r=this;return O(this,(function(o){switch(o.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,n=function(n){return w(r,void 0,void 0,(function(){var r,o;return O(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:n,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:r.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 w(r,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,n(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),e(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var n=new Error(null==t?void 0:t.errMsg);n.code=null==t?void 0:t.errno,e(n)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},t.prototype.bindOpenId=function(){return w(this,void 0,void 0,(function(){var t,e,n=this;return O(this,(function(r){switch(r.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return w(n,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:n=void 0,r.label=1;case 1:return r.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==(n=r.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:n.provider_token})];case 3:return r.sent(),[3,5];case 4:throw r.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,r){wx.login({success:function(o){return w(n,void 0,void 0,(function(){var n;return O(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 n=i.sent(),r(n),[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,r(e)}})}))];case 1:return r.sent(),[2]}}))}))},t.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,n=void 0===e||e;return w(this,void 0,void 0,(function(){var t,e,r=this;return O(this,(function(o){switch(o.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return w(r,void 0,void 0,(function(){var r,o;return O(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},[4,new Promise((function(t,n){wx.login({success:function(o){return w(r,void 0,void 0,(function(){var r;return O(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 o.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return w(this,void 0,void 0,(function(){var t=this;return O(this,(function(e){switch(e.label){case 0:if(!u().isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,n){var r=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return w(t,void 0,void 0,(function(){var t,i,s,a,c;return O(this,(function(u){switch(u.label){case 0:t=null==r?void 0:r.appId,u.label=1;case 1:return u.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==r?void 0:r.appId}})];case 2:return i=u.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(n(i),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(n(a),[2]):(e(!0),[3,5]);case 4:return c=u.sent(),n(c),[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,n(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,n=void 0===e?"":e;return w(this,void 0,void 0,(function(){var t,e,r,o,i;return O(this,(function(s){switch(s.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()];case 1:r=s.sent().code,e.provider_code=r,s.label=2;case 2:return s.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(e)];case 3:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:o.provider_token,provider_id:t.appId,provider_params:{code:n,provider_code_type:"phone"}})];case 4:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token})];case 5:if(null==(i=s.sent())?void 0:i.error_code)throw i;return[3,7];case 6:throw s.sent();case 7:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,c=void 0===a?void 0:a;return w(this,void 0,void 0,(function(){return O(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:c,username:s,loginType:"sms"})]}catch(t){throw t}return[2]}))}))},t.prototype.signInWithEmail=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.bindInfo,s=void 0===i?void 0:i,a=t.email,c=void 0===a?"":a;return w(this,void 0,void 0,(function(){return O(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:s,username:c,loginType:"email"})]}catch(t){throw t}return[2]}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signUp=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,e.throwError)(n.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,r.sent().exist]}}))}))},t.prototype.signOut=function(t){return w(this,void 0,void 0,(function(){var e,n;return O(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return n=r.sent(),[4,this.cache.removeStoreAsync(e)];case 2:return r.sent(),U.fire(E,{eventType:S}),[2,n]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new T({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,e.printWarn)(n.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return w(this,void 0,void 0,(function(){var t;return O(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 T({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return(e=n.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return w(this,void 0,void 0,(function(){return O(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}]}}))}))},t.prototype.grantProviderToken=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.grantToken=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return w(this,void 0,void 0,(function(){var e,n=this;return O(this,(function(r){switch(r.label){case 0:return U.on(E,(function(e){return w(n,void 0,void 0,(function(){var n,r,o;return O(this,(function(i){switch(i.label){case 0:return(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.eventType)===P?[3,2]:[4,this.getLoginState()];case 1:return r=i.sent(),[3,3];case 2:r={},i.label=3;case 3:return n=r,t.call(this,I(I({},e),n)),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.refreshTokenForce=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.modifyPassword=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]}))}))},t.prototype.getUserBehaviorLog=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},t.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){var e,n,r,o;return O(this,(function(i){return e=t.config_version||"env",u().isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index"}):(n=t.redirect_uri||window.location.href,r=new URL(n),o="".concat(r.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId,"&config_version=").concat(e,"&redirect_uri=").concat(encodeURIComponent(n)),window.location.href=o),[2]}))}))},t.prototype.createLoginState=function(t,e){return w(this,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return[4,(n=new T({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return r.sent(),(null==e?void 0:e.asyncRefreshUser)?(n.user.refresh(t),[3,4]):[3,2];case 2:return[4,n.user.refresh(t)];case 3:r.sent(),r.label=4;case 4:return U.fire(E,{eventType:A}),[2,n]}}))}))},t.prototype.signInWithUsername=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.username,s=void 0===i?"":i,a=t.bindInfo,c=void 0===a?void 0:a,u=t.loginType,h=void 0===u?"":u;return w(this,void 0,void 0,(function(){var t,e,r,i,a,u,d;return O(this,(function(l){switch(l.label){case 0:return l.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:n.verification_id,verification_code:o})];case 1:if(null==(t=l.sent())?void 0:t.error_code)throw t;return e=t.verification_token,r="+86 ".concat(s),i={phone_number:r},"email"===h&&(i={email:r=s}),n.is_user?[4,this.oauthInstance.authApi.signIn({username:r,verification_token:e})]:[3,5];case 2:if(null==(a=l.sent())?void 0:a.error_code)throw a;return c?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==c?void 0:c.providerToken})]:[3,4];case 3:if(null==(u=l.sent())?void 0:u.error_code)throw u;l.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(I(I({},i),{verification_token:e,provider_token:null==c?void 0:c.providerId}))];case 6:if(null==(d=l.sent())?void 0:d.error_code)throw d;l.label=7;case 7:return[2,this.createLoginState()];case 8:throw l.sent();case 9:return[2]}}))}))},b([(0,r.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),b([(0,r.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"unbindProvider",null),b([(0,r.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",void 0)],t.prototype,"bindEmail",null),b([(0,r.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"verify",null),b([(0,r.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object,Object]),_("design:returntype",Promise)],t.prototype,"getVerification",null),b([(0,r.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getCurrentUser",null),b([(0,r.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInAnonymously",null),b([(0,r.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),b([(0,r.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"bindOpenId",null),b([(0,r.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),b([(0,r.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),b([(0,r.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),b([(0,r.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithSms",null),b([(0,r.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithEmail",null),b([(0,r.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),b([(0,r.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signUp",null),b([(0,r.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[String]),_("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),b([(0,r.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signOut",null),b([(0,r.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getLoginState",null),b([(0,r.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"getUserInfo",null),b([(0,r.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),b([(0,r.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"bindWithProvider",null),b([(0,r.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function M(e,n){var r=e.region,o=void 0===r?"ap-shanghai":r,i=e.i18n,s=(null==n?void 0:n.platform)||(0,h.useDefaultAdapter)(),c=s.runtime,u=s.adapter,d=n||{},l=d.env,p=d.clientId,f=d.debug,v=d.cache,g=d.app,y=(n||{}).apiOrigin;y||(y="https://".concat(l,".").concat(o,".tcb-api.tencentcloudapi.com"));var b={env:l,clientId:p,i18n:i},_=new t.CloudbaseOAuth(m(I(I({},b),{apiOrigin:y,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:u,onCredentialsError:R,headers:e.headers||{}})));return{authInstance:new x(I(I({},b),{region:o,persistence:e.persistence,debug:f,cache:v||new a.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(l)},platformInfo:s}),runtime:c||"web",_fromApp:g,oauthInstance:_})),oauthInstance:_}}var C={name:"auth",namespace:"auth",entity:function(r){if(void 0===r&&(r={region:"",persistence:"local",apiPath:t.AUTH_API_PREFIX}),this.authInstance)return(0,e.printWarn)(n.ERRORS.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var o=this.platform.adapter,i=r.persistence||o.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var s=M(I(I({wxCloud:this.config.wxCloud,storage:this.config.storage},r),{persistence:this.config.persistence,i18n:this.config.i18n}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,c=s.oauthInstance;return this.oauthInstance=c,this.authInstance=a,this.authInstance}};try{cloudbase.registerComponent(C)}catch(t){}function k(t){try{t.registerComponent(C)}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 n={829:(t,e,n)=>{var r;n.r(e),n.d(e,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>r,formatUrl:()=>s}),function(t){t.local="local",t.none="none",t.session="session"}(r||(r={}));var o=function(){},i=function(){};function s(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";for(var i in n)""===o?!r&&(e+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(e+=o)?e:""+t+e}},105:function(t,e,n){var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),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 n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,c=s(n(587)),u=n(894);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var n=0,o=(0,u.isArray)(t)?t:[t];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,c=i.runtime;if(s())return{adapter:r({isMatch:s},a(e)),runtime:c}}},e.useDefaultAdapter=function(){return{adapter:c.genAdapter(),runtime:a.WEB}}},587:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=n(829),u=n(894),h=n(652),d=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}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,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===c?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",r),u.append("file",n),this.request(i(i({},t),{data:u,method:c}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,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,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),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 n,r,o,c,u,h,d,l,p,f,v,g=this;return a(this,(function(y){switch(y.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,c=void 0!==o&&o,u=t.stream,h=void 0!==u&&u,d=t.signal,l=t.timeout,p=null!=l?l:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",(function(){return n.abort()}))),f=null,c&&p&&(f=setTimeout((function(){console.warn(g.timeoutMsg),n.abort(new Error(g.timeoutMsg))}),p)),[4,fetch(r,i(i({},t),{signal:n.signal})).then((function(t){return s(g,void 0,void 0,(function(){var e,n,r;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(f),t.ok?(e=t,[3,3]):[3,1];case 1:return r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(f),Promise.reject(t)}))];case 1:return v=y.sent(),[2,{data:h?v.body:(null===(e=v.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?v.json():v.text(),statusCode:v.status,header:v.headers}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,c=t.headers,d=void 0===c?{}:c,l=t.data,p=t.responseType,f=t.withCredentials,v=t.body,g=t.onUploadProgress,y=(0,u.formatUrl)((0,h.getProtocol)(),a,"get"===r?l:{}),m=new XMLHttpRequest;m.open(r,y),p&&(m.responseType=p),Object.keys(d).forEach((function(t){m.setRequestHeader(t,d[t])})),g&&m.upload.addEventListener("progress",g),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,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&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),s=(0,u.isFormData)(l)?l:"application/x-www-form-urlencoded"===d["content-type"]?(0,u.toQueryString)(l):v||(l?JSON.stringify(l):void 0),f&&(m.withCredentials=!0),m.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=d,e.genAdapter=function(){return{type:"default",root:window,reqClass:d,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 n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},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,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(652),e),o(n(151),e),e.OATUH_LOGINTYPE="constants"},64:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(894),s=n(141),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),d=s.findIndex((function(t){return c.test(t)}));if(-1!==d){var l=s.filter((function(t,e){return e>d}));l.unshift(s[d].replace(h,"".concat(n,".").concat(r)).replace(u,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(l.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,d=void 0===a?{}:a,l=t.title,p=t.messages,f=void 0===p?[]:p;return function(t,e,a){if(s.IS_DEBUG_MODE){var p=d.className||t.constructor.name,v=d.methodName||e,g=a.value,y=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return c.test(t)}));if(-1!==r){var o=u.exec(n[r+1]||"");e=o?o[0]:""}return e}(new Error);a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=h({err:new Error,className:p,methodName:v,sourceLink:y});try{return g.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,c={title:l||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(t.code=u.code,t.message=u.msg),r=n||t,c.content=f.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(c.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,c.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,c,u,d;return o(this,(function(o){switch(o.label){case 0:e=h({err:new Error,className:p,methodName:v,sourceLink:y}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,c=n.error_description,u={title:l||"".concat(p,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),u.subtitle=d,d.code&&(e?(e.code=d.code,e.message=d.msg):(n.code=d.code,n.message=d.msg),r=e||n,u.content=f.map((function(t){return{type:"info",body:t}})))),a&&c&&(u.subtitle=c,e?(e.code=a,e.msg=c):(n.code=a,n.message=c),r=e||n,u.content=f.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),r;case 4:return[2]}}))}))}}}}},466:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(64),e)},418:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(829),c=n(894),u=n(141),h=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}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 d=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(e.root));case"none":return new h(e.root);default:return e.localStorage?e.localStorage:((0,c.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new h(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,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;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]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,c.printWarn)(u.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n=process.env)||void 0===n?void 0:n.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(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,c.printWarn)(u.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=d},988:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||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=n(894);var a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var c=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=c;var u=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,c))return console.error(t.error),this;var n=(0,s.isString)(t)?new a(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,u=this.listeners[r]?i([],this.listeners[r],!0):[];o<u.length;o++){u[o].call(this,n)}}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=u;var h=new u;e.addEventListener=function(t,e){h.on(t,e)},e.activateEvent=function(t,e){void 0===e&&(e={}),h.fire(t,e)},e.removeEventListener=function(t,e){h.off(t,e)}},894:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),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 r=n(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(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:7&r|8).toString(16)}))},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[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(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||window.location.search,r=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);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 n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},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 n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},e.printWarn=function(t,e){console.warn("[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e))},e.printError=function(t,e){console.error({code:t,msg:"[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e)})},e.printInfo=function(t,e){console.log("[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e))},e.throwError=function(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat((0,r.getSdkName)(),"][").concat(t,"]:").concat(e)}))},e.printGroupLog=function(t){var e,n=t.title,r=t.subtitle,o=void 0===r?"":r,i=t.content,s=void 0===i?[]:i,a=t.printTrace,c=void 0!==a&&a,u=t.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var h=0,d=s;h<d.length;h++){var l=d[h],p=l.type,f=l.body;switch(p){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}c&&(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 n=t.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(e[r]?Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]:e[r]=o)})),e}},219:t=>{t.exports=e},297:e=>{e.exports=t}},r={};function o(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={exports:{}};return n[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 n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},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:()=>x,LoginState:()=>T,generateAuthInstance:()=>M,registerAuth:()=>k});var t=o(297),e=o(894),n=o(141),r=o(466),s=o(988),a=o(418),c=o(219),u=o.n(c),h=o(105),d=function(){return(d=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},l=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},p=function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},f=function(){function t(t){var e,n;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(n=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===n?void 0:n.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return l(this,void 0,void 0,(function(){return p(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return l(this,void 0,void 0,(function(){return p(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return l(this,void 0,void 0,(function(){return p(this,(function(n){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=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,g=function(t,e){var n,r,o,i,s=null===(n=null==e?void 0:e.headers)||void 0===n?void 0:n["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.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 y=function(t,e){if(!u().isMatch()||t.storage&&t.baseRequest)return t;var n=d({},t),r={};try{var o=u().genAdapter(),i=o.localStorage,s=o.reqClass;if(i&&(r.storage=new f({localStorage:i,adapter:e})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.request=function(t){return function(e,n){return l(this,void 0,void 0,(function(){return p(this,(function(r){return[2,new Promise((function(r,o){var i=Object.assign({},n);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=g(t,d(d({},n),{url:e}))).error&&o(t),r(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 n.captchaOptions&&(r.baseRequest=r.request,r.request=void 0),d(d({},n),r)}catch(t){console.error("adapter generate fail:",t)}return n},m=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var n=d({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(n.storage=new f({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(n.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var r=new e.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.baseRequest=function(t,e){var n;return l(this,void 0,void 0,(function(){var o,i,s,a;return p(this,(function(c){switch(c.label){case 0:if(o={},i=(null===(n=e.method)||void 0===n?void 0:n.toLocaleLowerCase())||"get","function"!=typeof(s=null==r?void 0:r[i]))throw new Error("invalid 【".concat(i,"】 request method"));c.label=1;case 1:return c.trys.push([1,3,,4]),e.headers["content-type"]&&!e.headers["content-type"].includes("application/json")||"string"==typeof e.body||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,s(d({url:t},e))];case 2:return o=c.sent(),o=g(o,d(d({},e),{url:t})),[3,4];case 3:throw a=c.sent(),o=a,a;case 4:if(null==o?void 0:o.error)throw o;return[2,o]}}))}))}}}catch(t){console.error("user adapter generate fail:",t)}return n}(t,t.adapter):y(t,t.adapter)},b=function(){return(b=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},I=function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},_=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},w=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},O=function(t,e){var n,r,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(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},S="sign_out",A="sign_in",P="credentials_error",E="loginStateChanged",U=new s.CloudbaseEventEmitter,R=function(t){U.fire(E,b(b({},t),{eventType:P}))},L=function(){function t(t){var e=t.cache,n=t.oauthInstance;this.cache=e,this.oauthInstance=n,this.setUserInfo()}return t.prototype.checkLocalInfo=function(){return w(this,void 0,void 0,(function(){return O(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 w(this,void 0,void 0,(function(){var t,e,n,r;return O(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"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.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 w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(b({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(b({},t))];case 1:return e.sent(),this.setLocalUserInfo({username:t.username}),[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)(n.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;return this.cache.getStore(e)[t]},t.prototype.getLocalUserInfoAsync=function(t){return w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username"].forEach((function(e){t[e]=n[e]}))},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},I([(0,r.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"update",null),I([(0,r.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[String,String]),_("design:returntype",void 0)],t.prototype,"updatePassword",null),I([(0,r.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[String]),_("design:returntype",void 0)],t.prototype,"updateUsername",null),I([(0,r.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"refresh",null),t}(),T=function(){function t(t){var r=t.envId,o=t.cache,i=t.oauthInstance;r||(0,e.throwError)(n.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=o,this.oauthInstance=i,this.user=new L({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 w(this,void 0,void 0,(function(){return O(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}(),x=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance,t.publishable_key&&this.createLoginState()}return t.prototype.bindPhoneNumber=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},t.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},t.prototype.verify=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t,e){return w(this,void 0,void 0,(function(){return O(this,(function(n){return[2,this.oauthInstance.authApi.getVerification(t,e)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,e.printWarn)(n.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return w(this,void 0,void 0,(function(){var t;return O(this,(function(e){switch(e.label){case 0:return[4,this.getLoginState()];case 1:return(t=e.sent())?[4,t.user.checkLocalInfoAsync()]:[3,3];case 2:return e.sent(),[2,t.user||null];case 3:return[2,null]}}))}))},t.prototype.signInAnonymously=function(t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return w(this,void 0,void 0,(function(){var t,n,r=this;return O(this,(function(o){switch(o.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,n=function(n){return w(r,void 0,void 0,(function(){var r,o;return O(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:n,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:r.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 w(r,void 0,void 0,(function(){var r;return O(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,n(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),e(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var n=new Error(null==t?void 0:t.errMsg);n.code=null==t?void 0:t.errno,e(n)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},t.prototype.bindOpenId=function(){return w(this,void 0,void 0,(function(){var t,e,n=this;return O(this,(function(r){switch(r.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return w(n,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:n=void 0,r.label=1;case 1:return r.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==(n=r.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:n.provider_token})];case 3:return r.sent(),[3,5];case 4:throw r.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,r){wx.login({success:function(o){return w(n,void 0,void 0,(function(){var n;return O(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 n=i.sent(),r(n),[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,r(e)}})}))];case 1:return r.sent(),[2]}}))}))},t.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,n=void 0===e||e;return w(this,void 0,void 0,(function(){var t,e,r=this;return O(this,(function(o){switch(o.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return w(r,void 0,void 0,(function(){var r,o;return O(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},[4,new Promise((function(t,n){wx.login({success:function(o){return w(r,void 0,void 0,(function(){var r;return O(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 o.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return w(this,void 0,void 0,(function(){var t=this;return O(this,(function(e){switch(e.label){case 0:if(!u().isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,n){var r=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return w(t,void 0,void 0,(function(){var t,i,s,a,c;return O(this,(function(u){switch(u.label){case 0:t=null==r?void 0:r.appId,u.label=1;case 1:return u.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==r?void 0:r.appId}})];case 2:return i=u.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(n(i),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(n(a),[2]):(e(!0),[3,5]);case 4:return c=u.sent(),n(c),[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,n(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,n=void 0===e?"":e;return w(this,void 0,void 0,(function(){var t,e,r,o,i;return O(this,(function(s){switch(s.label){case 0:if(!u().isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone"},provider_id:t.appId},[4,wx.login()];case 1:r=s.sent().code,e.provider_code=r,s.label=2;case 2:return s.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(e)];case 3:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:o.provider_token,provider_id:t.appId,provider_params:{code:n,provider_code_type:"phone"}})];case 4:if((o=s.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token})];case 5:if(null==(i=s.sent())?void 0:i.error_code)throw i;return[3,7];case 6:throw s.sent();case 7:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,c=void 0===a?void 0:a;return w(this,void 0,void 0,(function(){return O(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:c,username:s,loginType:"sms"})]}catch(t){throw t}return[2]}))}))},t.prototype.signInWithEmail=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.bindInfo,s=void 0===i?void 0:i,a=t.email,c=void 0===a?"":a;return w(this,void 0,void 0,(function(){return O(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:s,username:c,loginType:"email"})]}catch(t){throw t}return[2]}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signUp=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signUp(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.setPassword=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(r){switch(r.label){case 0:return"string"!=typeof t&&(0,e.throwError)(n.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,r.sent().exist]}}))}))},t.prototype.signOut=function(t){return w(this,void 0,void 0,(function(){var e,n;return O(this,(function(r){switch(r.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return n=r.sent(),[4,this.cache.removeStoreAsync(e)];case 2:return r.sent(),U.fire(E,{eventType:S}),[2,n]}}))}))},t.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new T({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,e.printWarn)(n.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return w(this,void 0,void 0,(function(){var t;return O(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 T({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return w(this,void 0,void 0,(function(){var e;return O(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return(e=n.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return w(this,void 0,void 0,(function(){return O(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}]}}))}))},t.prototype.grantProviderToken=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},t.prototype.grantToken=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return w(this,void 0,void 0,(function(){var e,n=this;return O(this,(function(r){switch(r.label){case 0:return U.on(E,(function(e){return w(n,void 0,void 0,(function(){var n,r,o;return O(this,(function(i){switch(i.label){case 0:return(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.eventType)===P?[3,2]:[4,this.getLoginState()];case 1:return r=i.sent(),[3,3];case 2:r={},i.label=3;case 3:return n=r,t.call(this,b(b({},e),n)),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.refreshTokenForce=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return w(this,void 0,void 0,(function(){return O(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.modifyPassword=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]}))}))},t.prototype.getUserBehaviorLog=function(t){return w(this,void 0,void 0,(function(){return O(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},t.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){var e,n,r,o;return O(this,(function(i){return e=t.config_version||"env",u().isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index"}):(n=t.redirect_uri||window.location.href,r=new URL(n),o="".concat(r.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId,"&config_version=").concat(e,"&redirect_uri=").concat(encodeURIComponent(n)),window.location.href=o),[2]}))}))},t.prototype.createLoginState=function(t,e){return w(this,void 0,void 0,(function(){var n;return O(this,(function(r){switch(r.label){case 0:return[4,(n=new T({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return r.sent(),(null==e?void 0:e.asyncRefreshUser)?(n.user.refresh(t),[3,4]):[3,2];case 2:return[4,n.user.refresh(t)];case 3:r.sent(),r.label=4;case 4:return U.fire(E,{eventType:A}),[2,n]}}))}))},t.prototype.signInWithUsername=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.username,s=void 0===i?"":i,a=t.bindInfo,c=void 0===a?void 0:a,u=t.loginType,h=void 0===u?"":u;return w(this,void 0,void 0,(function(){var t,e,r,i,a,u,d;return O(this,(function(l){switch(l.label){case 0:return l.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:n.verification_id,verification_code:o})];case 1:if(null==(t=l.sent())?void 0:t.error_code)throw t;return e=t.verification_token,r="+86 ".concat(s),i={phone_number:r},"email"===h&&(i={email:r=s}),n.is_user?[4,this.oauthInstance.authApi.signIn({username:r,verification_token:e})]:[3,5];case 2:if(null==(a=l.sent())?void 0:a.error_code)throw a;return c?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==c?void 0:c.providerToken})]:[3,4];case 3:if(null==(u=l.sent())?void 0:u.error_code)throw u;l.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(b(b({},i),{verification_token:e,provider_token:null==c?void 0:c.providerId}))];case 6:if(null==(d=l.sent())?void 0:d.error_code)throw d;l.label=7;case 7:return[2,this.createLoginState()];case 8:throw l.sent();case 9:return[2]}}))}))},I([(0,r.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),I([(0,r.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"unbindProvider",null),I([(0,r.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",void 0)],t.prototype,"bindEmail",null),I([(0,r.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"verify",null),I([(0,r.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object,Object]),_("design:returntype",Promise)],t.prototype,"getVerification",null),I([(0,r.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getCurrentUser",null),I([(0,r.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInAnonymously",null),I([(0,r.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInAnonymouslyInWx",null),I([(0,r.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"bindOpenId",null),I([(0,r.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),I([(0,r.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),I([(0,r.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),I([(0,r.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithSms",null),I([(0,r.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signInWithEmail",null),I([(0,r.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),I([(0,r.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signUp",null),I([(0,r.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[String]),_("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),I([(0,r.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"signOut",null),I([(0,r.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getLoginState",null),I([(0,r.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"getUserInfo",null),I([(0,r.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),I([(0,r.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[Object]),_("design:returntype",Promise)],t.prototype,"bindWithProvider",null),I([(0,r.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(n.COMMUNITY_SITE_URL)]}),_("design:type",Function),_("design:paramtypes",[]),_("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function M(e,n){var r=e.region,o=void 0===r?"ap-shanghai":r,i=e.i18n,s=e.publishable_key,c=(null==n?void 0:n.platform)||(0,h.useDefaultAdapter)(),u=c.runtime,d=c.adapter,l=n||{},p=l.env,f=l.clientId,v=l.debug,g=l.cache,y=l.app,I=(n||{}).apiOrigin;I||(I="https://".concat(p,".").concat(o,".tcb-api.tencentcloudapi.com"));var _={env:p,clientId:f,i18n:i,publishable_key:s},w=new t.CloudbaseOAuth(m(b(b({},_),{apiOrigin:I,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:d,onCredentialsError:R,headers:e.headers||{}})));return{authInstance:new x(b(b({},_),{region:o,persistence:e.persistence,debug:v,cache:g||new a.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(p)},platformInfo:c}),runtime:u||"web",_fromApp:y,oauthInstance:w})),oauthInstance:w}}var C={name:"auth",namespace:"auth",entity:function(r){if(void 0===r&&(r={region:"",persistence:"local",apiPath:t.AUTH_API_PREFIX}),this.authInstance)return(0,e.printWarn)(n.ERRORS.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var o=this.platform.adapter,i=r.persistence||o.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var s=M(b(b({wxCloud:this.config.wxCloud,storage:this.config.storage},r),{persistence:this.config.persistence,i18n:this.config.i18n,publishable_key:this.config.publishable_key}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),a=s.authInstance,c=s.oauthInstance;return this.oauthInstance=c,this.authInstance=a,this.authInstance}};try{cloudbase.registerComponent(C)}catch(t){}function k(t){try{t.registerComponent(C)}catch(t){console.warn(t)}}})(),i})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/auth",
3
- "version": "2.19.7",
3
+ "version": "3.0.0",
4
4
  "description": "cloudbase javascript sdk auth componets",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -32,14 +32,14 @@
32
32
  "license": "Apache-2.0",
33
33
  "dependencies": {
34
34
  "@cloudbase/adapter-wx_mp": "1.2.0",
35
- "@cloudbase/oauth": "2.19.7",
36
- "@cloudbase/utilities": "2.19.7"
35
+ "@cloudbase/oauth": "3.0.0",
36
+ "@cloudbase/utilities": "3.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@cloudbase/types": "2.19.7",
39
+ "@cloudbase/types": "3.0.0",
40
40
  "@types/node": "^22.1.0",
41
41
  "terser-webpack-plugin": "^3.0.2",
42
42
  "webpack-bundle-analyzer": "^4.9.1"
43
43
  },
44
- "gitHead": "96d36b989171037840b6f261c9c5753b0ae7476b"
44
+ "gitHead": "a70e7266db7be901d909b1fa63c1651e2a7943e4"
45
45
  }
package/src/index.ts CHANGED
@@ -303,6 +303,10 @@ class Auth {
303
303
  this.config = config
304
304
  this.cache = config.cache
305
305
  this.oauthInstance = config.oauthInstance
306
+
307
+ if (config.publishable_key) {
308
+ this.createLoginState()
309
+ }
306
310
  }
307
311
 
308
312
  /**
@@ -1368,7 +1372,7 @@ class Auth {
1368
1372
  }
1369
1373
  }
1370
1374
 
1371
- type TInitAuthOptions = Pick<ICloudbaseAuthConfig, 'region' | 'persistence' | 'i18n'> & Partial<AuthOptions>
1375
+ type TInitAuthOptions = Pick<ICloudbaseAuthConfig, 'region' | 'persistence' | 'i18n' | 'publishable_key'> & Partial<AuthOptions>
1372
1376
 
1373
1377
  export function generateAuthInstance(
1374
1378
  config: TInitAuthOptions,
@@ -1382,7 +1386,7 @@ export function generateAuthInstance(
1382
1386
  debug?: ICloudbaseAuthConfig['debug']
1383
1387
  },
1384
1388
  ) {
1385
- const { region = 'ap-shanghai', i18n } = config
1389
+ const { region = 'ap-shanghai', i18n, publishable_key } = config
1386
1390
  const platform = options?.platform || (useDefaultAdapter() as ICloudbasePlatformInfo)
1387
1391
  const { runtime, adapter } = platform
1388
1392
 
@@ -1396,6 +1400,7 @@ export function generateAuthInstance(
1396
1400
  env,
1397
1401
  clientId,
1398
1402
  i18n,
1403
+ publishable_key,
1399
1404
  }
1400
1405
 
1401
1406
  const oauthInstance = new CloudbaseOAuth(useAuthAdapter({
@@ -1460,6 +1465,7 @@ const component: ICloudbaseComponent = {
1460
1465
  ...config,
1461
1466
  persistence: this.config.persistence,
1462
1467
  i18n: this.config.i18n,
1468
+ publishable_key: this.config.publishable_key,
1463
1469
  },
1464
1470
  {
1465
1471
  env: this.config.env,