twiklite
Version:
A lightweight optimized version of Twikoo
38 lines (37 loc) • 473 kB
JavaScript
/*
* Twiklite v2.0.0
* Copyright (c) 2025 ZeoSeven
* Released under the MIT License.
* Last Update: 2025/8/12 23:27:40 UTC+8
*
*
* Twikoo v1.6.44
* (c) 2020-2025 iMaeGoo
* Released under the MIT License.
* Last Update: 2025/8/12 23:27:40
*
*
* Vue.js v2.7.16
* (c) 2014-2023 Evan You
* Released under the MIT License.
*
*
* regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE
*
*
* Prism: Lightweight, robust, elegant syntax highlighting
*
* @license MIT <https://opensource.org/licenses/MIT>
* @author Lea Verou <https://lea.verou.me>
* @namespace
* @public
*
*
* [js-sha256]{@link https://github.com/emn178/js-sha256}
*
* @version 0.11.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2024
* @license MIT
*/
var e,t;e=this,t=function(){return function(){var e={6885:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3692);Object.keys(r).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===r[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}}))}));var i=n(2912);Object.keys(i).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===i[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}}))}))},3692:function(e,t){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.StorageType=t.AbstractStorage=t.AbstractSDKRequest=void 0,function(e){e.local="local",e.none="none",e.session="session"}(n||(t.StorageType=n={})),t.AbstractSDKRequest=function(){},t.AbstractStorage=function(){}},2912:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),i="";for(var o in n)""===i?!r&&(t+="?"):i+="&",i+=o+"="+encodeURIComponent(n[o]);return/^http(s)?\:\/\//.test(t+=i)?t:""+e+t}},3052:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LOGINTYPE=t.DATA_VERSION=void 0,t.getEndPoint=function(){return{BASE_URL:l,PROTOCOL:c}},t.getSdkName=function(){return s},t.getSdkVersion=function(){return a},t.setEndPoint=f,t.setRegionLevelEndpoint=function(e,t,n){f(t?"//"+e+"."+t+".tcb-api.tencentcloudapi.com/web":"//"+e+".ap-shanghai.tcb-api.tencentcloudapi.com/web",n)},t.setSdkName=function(e){s=e,i(e)},t.setSdkVersion=function(e){a=e};var r=n(2566),i=r.constants.setSdkName,o=r.constants.setProtocol,a="",s="@cloudbase/js-sdk";t.DATA_VERSION="2020-01-10";var u,c="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",l="//tcb-api.tencentcloudapi.com/web";function f(e,t){l=e,t&&(c=t,o(t))}!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(u||(t.LOGINTYPE=u={}))},7696:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EVENTS=void 0,t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"}},4283:function(e,t,n){"use strict";var r=n(477);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=t.cloudbase=void 0;var i=r(n(9367)),o=n(2566),a=r(n(2473)),s=n(3219),u=n(4319),c=n(1706),l=n(6153),f=n(3052),d=function(){return d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},d.apply(this,arguments)},p=function(e,t,n,r){var o,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,i["default"])(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(s=(a<3?o(s):a>3?o(t,n,s):o(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s},h=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,i["default"])(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},g=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(t){o(t)}}function s(e){try{u(r["throw"](e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},m=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),"throw":s(1),"return":s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r["return"]:o[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(s){o=[6,s],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},v=o.adapters.useAdapters,y=o.adapters.useDefaultAdapter,b=o.adapters.RUNTIME,_=o.constants.ERRORS,k=o.constants.COMMUNITY_SITE_URL,w=o.utils.printWarn,x=o.helpers.catchErrorsDecorator,A={timeout:15e3,persistence:"local"},D=6e5,E={},C=function(){function e(e){this._config=e||this._config,this.authInstance=null}return Object.defineProperty(e.prototype,"config",{get:function(){return this._config},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return u.Platform},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return(0,c.getCacheByEnvId)(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return(0,c.getLocalCache)(this._config.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return(0,l.getRequestByEnvId)(this._config.env)},enumerable:!1,configurable:!0}),e.prototype.init=function(t){if(!t.env)throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"env must not be specified"}));if(u.Platform.adapter||this._useDefaultAdapter(),this.requestClient=new u.Platform.adapter.reqClass({timeout:t.timeout||5e3,timeoutMsg:"["+(0,f.getSdkName)()+"][REQUEST TIMEOUT] request had been abort since didn't finished within"+t.timeout/1e3+"s"}),u.Platform.runtime!==b.WEB){if(!t.appSecret)throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"invalid appSecret"}));var n=u.Platform.adapter.getAppSign?u.Platform.adapter.getAppSign():"";if(t.appSign&&n&&t.appSign!==n)throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"invalid appSign"}));if(n&&(t.appSign=n),!t.appSign)throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"invalid appSign"}))}this._config=d(d({},A),t),this._config.timeout=this._formatTimeout(this._config.timeout);var r=this._config,i=r.env,o=r.persistence,a=r.debug,s=r.timeout,p=r.appSecret,h=r.appSign;(0,c.initCache)({env:i,persistence:o,debug:a,platformInfo:this.platform}),(0,l.initRequest)({env:i,region:t.region||"",timeout:s,appSecret:p,appSign:h}),t.region&&(0,f.setRegionLevelEndpoint)(i,t.region||"");var g=new e(this._config);return g.requestClient=this.requestClient,g},e.prototype.updateConfig=function(e){var t=e.persistence,n=e.debug;this._config.persistence=t,this._config.debug=n,(0,c.initCache)({env:this._config.env,persistence:t,debug:n,platformInfo:this.platform})},e.prototype.registerExtension=function(e){E[e.name]=e},e.prototype.invokeExtension=function(e,t){return g(this,void 0,void 0,(function(){var n;return m(this,(function(r){switch(r.label){case 0:if(!(n=E[e]))throw new Error(JSON.stringify({code:_.INVALID_PARAMS,msg:"extension:"+e+" must be registered before invoke"}));return[4,n.invoke(t,this)];case 1:return[2,r.sent()]}}))}))},e.prototype.useAdapters=function(e){var t=v(e)||{},n=t.adapter,r=t.runtime;n&&(u.Platform.adapter=n),r&&(u.Platform.runtime=r)},e.prototype.registerHook=function(t){(0,s.registerHook)(e,t)},e.prototype.registerComponent=function(t){(0,s.registerComponent)(e,t)},e.prototype.registerVersion=function(e){(0,f.setSdkVersion)(e)},e.prototype.registerSdkName=function(e){(0,f.setSdkName)(e)},e.prototype.registerEndPoint=function(e,t){(0,f.setEndPoint)(e,t)},e.prototype._useDefaultAdapter=function(){var e=y(),t=e.adapter,n=e.runtime;u.Platform.adapter=t,u.Platform.runtime=n},e.prototype._formatTimeout=function(e){switch(!0){case e>D:return w(_.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),D;case e<100:return w(_.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},p([x({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv2/adapter.html#jie-ru-liu-cheng)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),h("design:type",Function),h("design:paramtypes",[Object]),h("design:returntype",e)],e.prototype,"init",null),p([x({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+k]}),h("design:type",Function),h("design:paramtypes",[String,Object]),h("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}(),S=t.cloudbase=new C;S.useAdapters(a["default"]),t["default"]=S},4319:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Platform=void 0,t.Platform={}},1706:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getCacheByEnvId=function(e){return d[e]},t.getLocalCache=function(e){return p[e]},t.initCache=function(e){var t=e.env,n=e.persistence,r=e.platformInfo,h={accessTokenKey:o+"_"+t,accessTokenExpireKey:a+"_"+t,refreshTokenKey:s+"_"+t,anonymousUuidKey:u+"_"+t,loginTypeKey:c+"_"+t,userInfoKey:l+"_"+t};d[t]?d[t].updatePersistence(n):d[t]=new f(i(i({},e),{keys:h,platformInfo:r,alwaysLocalKeys:["anonymousUuidKey"]})),p[t]=p[t]||new f(i(i({},e),{keys:h,platformInfo:r,persistence:"local"}))};var r=n(2566),i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)},o="access_token",a="access_token_expire",s="refresh_token",u="anonymous_uuid",c="login_type",l="user_info",f=r.cache.CloudbaseCache,d={},p={}},3219:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.registerComponent=function(e,t){var n=t.name,r=t.namespace,u=t.entity,c=t.injectEvents,l=t.IIFE,f=void 0!==l&&l;if(a[n]||r&&e[r])throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"Duplicate component "+n}));if(f){if(!u||"function"!=typeof u)throw new Error(JSON.stringify({code:o.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));u.call(e)}if(a[n]=t,r?e.prototype[r]=u:s(e.prototype,u),c){var d=c.bus,p=c.events;if(!d||!p||0===p.length)return;var h=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[n]?e.prototype.events[n].events=i(e.prototype.events[n].events,p):e.prototype.events[n]={bus:d,events:p},e.prototype.fire=function(e,t){for(var n in h(e,t),this.events){var r=this.events[n],i=r.bus;if(r.events.includes(e)){i.fire(e,t);break}}}}},t.registerHook=function(e,t){var n=t.entity,r=t.target;if(!e.prototype.hasOwnProperty(r))throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:"+r+" is not exist"}));var a=e.prototype[r];if("function"!=typeof a)throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:"+r+" is not a function which is the only type supports hook"}));e.prototype[r]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.call.apply(n,i([this],e)),a.call.apply(a,i([this],e))}};var r=n(2566),i=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r},o=r.constants.ERRORS,a={};function s(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:e===undefined&&(e={});break;case Array:e=[];break;default:return t}for(var n in t)t.hasOwnProperty(n)&&(e[n]=s(e[n],t[n]));return e}},6153:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseRequest=void 0,t.getRequestByEnvId=function(e){return w[e]},t.initRequest=function(e){w[e.env]=new k(c(c({},e),{"throw":!0}))};var r=n(3052),i=n(2566),o=n(4283),a=n(1706),s=n(7696),u=n(4319),c=function(){return c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},c.apply(this,arguments)},l=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(t){o(t)}}function s(e){try{u(r["throw"](e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},f=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),"throw":s(1),"return":s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r["return"]:o[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(s){o=[6,s],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},d=i.constants.ERRORS,p=i.utils.genSeqId,h=i.utils.isFormData,g=i.utils.formatUrl,m=i.utils.createSign,v=i.adapters.RUNTIME,y=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function b(e,t,n){var r=e[t];e[t]=function(t){var i={},o={};n.forEach((function(n){var r=n.call(e,t),a=r.data,s=r.headers;Object.assign(i,a),Object.assign(o,s)}));var a=t.data;return a&&function(){if(h(a))for(var e in i)a.append(e,i[e]);else t.data=c(c({},a),i)}(),t.headers=c(c({},t.headers||{}),o),r.call(e,t)}}function _(){var e=p();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/"+(0,r.getSdkVersion)(),"x-seqid":e}}}var k=t.CloudbaseRequest=function(){function e(e){this._throwWhenRequestFail=!1,this.config=e,this._reqClass=new u.Platform.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在"+this.config.timeout/1e3+"s内未完成,已中断",restrictedMethods:["post"]}),this._throwWhenRequestFail=e["throw"]||!1,this._cache=(0,a.getCacheByEnvId)(this.config.env),this._localCache=(0,a.getLocalCache)(this.config.env),b(this._reqClass,"post",[_]),b(this._reqClass,"upload",[_]),b(this._reqClass,"download",[_])}return e.prototype.post=function(e){return l(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.post(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.upload=function(e){return l(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.upload(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return l(this,void 0,void 0,(function(){return f(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.refreshAccessToken=function(){return l(this,void 0,void 0,(function(){var e,t,n;return f(this,(function(r){switch(r.label){case 0:this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return e=r.sent(),[3,4];case 3:return n=r.sent(),t=n,[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return[2,e]}}))}))},e.prototype.getAccessToken=function(){return l(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s,u;return f(this,(function(c){switch(c.label){case 0:return e=this._cache.keys,t=e.accessTokenKey,n=e.accessTokenExpireKey,r=e.refreshTokenKey,[4,this._cache.getStoreAsync(r)];case 1:if(!c.sent())throw new Error(JSON.stringify({code:d.OPERATION_FAIL,msg:"refresh token is not exist, your local data might be messed up, please retry after clear localStorage or sessionStorage"}));return[4,this._cache.getStoreAsync(t)];case 2:return i=c.sent(),a=Number,[4,this._cache.getStoreAsync(n)];case 3:return o=a.apply(void 0,[c.sent()]),s=!0,(u=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(i,o)]:[3,5];case 4:u=!c.sent(),c.label=5;case 5:return u&&(s=!1),i&&o&&!(o<Date.now())||!s?[3,7]:[4,this.refreshAccessToken()];case 6:return[2,c.sent()];case 7:return[2,{accessToken:i,accessTokenExpire:o}]}}))}))},e.prototype.request=function(e,t,n){return l(this,void 0,void 0,(function(){var i,o,a,s,l,d,p,h,b,_,k,w,x,A,D,E,C,S,O,I,T,P,F,N,L,M;return f(this,(function(f){switch(f.label){case 0:return i="x-tcb-trace_"+this.config.env,o="application/x-www-form-urlencoded",a=c({action:e,dataVersion:r.DATA_VERSION,env:this.config.env},t),-1!==y.indexOf(e)?[3,3]:(s=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(s)]);case 1:return f.sent()?(l=a,[4,this.getAccessToken()]):[3,3];case 2:l.access_token=f.sent().accessToken,f.label=3;case 3:if("storage.uploadFile"===e){for(p in d=new FormData)d.hasOwnProperty(p)&&d[p]!==undefined&&d.append(p,a[p]);o="multipart/form-data"}else for(p in o="application/json;charset=UTF-8",d={},a)a[p]!==undefined&&(d[p]=a[p]);return h={headers:{"content-type":o}},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(b=this._localCache.getStore(i))&&(h.headers["X-TCB-Trace"]=b),u.Platform.runtime!==v.WEB&&(_=this.config,k=_.appSign,w=_.appSecret,x=Date.now(),A=w.appAccessKey,D=w.appAccessKeyId,E=m({data:{},timestamp:x,appAccessKeyId:D,appSign:k},A),h.headers["X-TCB-App-Source"]="timestamp="+x+";appAccessKeyId="+D+";appSign="+k+";sign="+E),C=t.parse,S=t.inQuery,O=t.search,I={env:this.config.env},C&&(I.parse=!0),S&&(I=c(c({},S),I)),T=(0,r.getEndPoint)(),P=T.BASE_URL,F=T.PROTOCOL,N=g(F,P,I),O&&(N+=O),[4,this.post(c({url:N,data:d},h))];case 4:if(L=f.sent(),(M=L.header&&L.header["x-tcb-trace"])&&this._localCache.setStore(i,M),200!==Number(L.status)&&200!==Number(L.statusCode)||!L.data)throw new Error("network request error");return[2,L]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t={}),l(this,void 0,void 0,(function(){var n;return f(this,(function(r){switch(r.label){case 0:return[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 1:return"ACCESS_TOKEN_EXPIRED"!==(n=r.sent()).data.code||-1!==y.indexOf(e)?[3,4]:[4,this.refreshAccessToken()];case 2:return r.sent(),[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 3:n=r.sent(),r.label=4;case 4:if(n.data.code&&this._throwWhenRequestFail)throw new Error(JSON.stringify({code:d.OPERATION_FAIL,msg:"["+n.data.code+"] "+n.data.message}));return[2,n.data]}}))}))},e.prototype._refreshAccessToken=function(e){return void 0===e&&(e=1),l(this,void 0,void 0,(function(){var t,n,i,a,u,c,l,p,h,g,m,v,y;return f(this,(function(f){switch(f.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,i=t.accessTokenExpireKey,a=t.refreshTokenKey,u=t.loginTypeKey,c=t.anonymousUuidKey,[4,this._cache.removeStoreAsync(n)];case 1:return f.sent(),[4,this._cache.removeStoreAsync(i)];case 2:return f.sent(),[4,this._cache.getStoreAsync(a)];case 3:if(!(l=f.sent()))throw new Error(JSON.stringify({code:d.INVALID_OPERATION,msg:"not login"}));return p={refresh_token:l},[4,this.request("auth.fetchAccessTokenWithRefreshToken",p)];case 4:return(h=f.sent()).data.code?"SIGN_PARAM_INVALID"!==(g=h.data.code)&&"REFRESH_TOKEN_EXPIRED"!==g&&"INVALID_REFRESH_TOKEN"!==g?[3,11]:[4,this._cache.getStoreAsync(u)]:[3,12];case 5:return f.sent()===r.LOGINTYPE.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===g?[4,this._cache.getStoreAsync(c)]:[3,9];case 6:return m=f.sent(),[4,this._cache.getStoreAsync(a)];case 7:return v=f.sent(),[4,this.send("auth.signInAnonymously",{anonymous_uuid:m,refresh_token:v})];case 8:if(y=f.sent(),this._setRefreshToken(y.refresh_token),e>=1)return[2,this._refreshAccessToken(--e)];throw new Error(JSON.stringify({code:d.OPERATION_FAIL,message:"重试获取 refresh token 失败"}));case 9:return o.cloudbase.fire(s.EVENTS.LOGIN_STATE_EXPIRED),[4,this._cache.removeStoreAsync(a)];case 10:f.sent(),f.label=11;case 11:throw new Error(JSON.stringify({code:d.NETWORK_ERROR,msg:"refresh access_token failed:"+h.data.code}));case 12:return h.data.access_token?(o.cloudbase.fire(s.EVENTS.ACCESS_TOKEN_REFRESHD),[4,this._cache.setStoreAsync(n,h.data.access_token)]):[3,15];case 13:return f.sent(),[4,this._cache.setStoreAsync(i,h.data.access_token_expire+Date.now())];case 14:return f.sent(),[2,{accessToken:h.data.access_token,accessTokenExpire:h.data.access_token_expire}];case 15:return h.data.refresh_token?[4,this._cache.removeStoreAsync(a)]:[3,19];case 16:return f.sent(),[4,this._cache.setStoreAsync(a,h.data.refresh_token)];case 17:return f.sent(),[4,this._refreshAccessToken()];case 18:f.sent(),f.label=19;case 19:return[2]}}))}))},e.prototype._setRefreshToken=function(e){return l(this,void 0,void 0,(function(){var t,n,r,i;return f(this,(function(o){switch(o.label){case 0:return t=this._cache.keys,n=t.accessTokenKey,r=t.accessTokenExpireKey,i=t.refreshTokenKey,[4,this._cache.removeStoreAsync(n)];case 1:return o.sent(),[4,this._cache.removeStoreAsync(r)];case 2:return o.sent(),[4,this._cache.setStoreAsync(i,e)];case 3:return o.sent(),[2]}}))}))},e}(),w={}},1235:function(e,t){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LOGINTYPE=void 0,function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL",e.PHONE="PHONE"}(n||(t.LOGINTYPE=n={}))},3442:function(e,t,n){"use strict";var r=n(477);Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0,Object.defineProperty(t,"AuthProvider",{enumerable:!0,get:function(){return l.AuthProvider}}),t.eventBus=t.LoginState=t.EVENTS=void 0,t.registerAuth=function(e){try{e.registerComponent(P)}catch(t){console.warn(t)}},t.registerProvider=function(e,t){I.prototype[e]=function(n){var r="_"+e;return this[r]||(this[r]=new t(h(h({},n),this._config))),this[r]}};var i=r(n(9367)),o=n(2566),a=n(9250),s=n(4325),u=n(2007),c=n(1235),l=n(4522),f=n(7036),d=n(9676),p=n(2424),h=function(){return h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},h.apply(this,arguments)},g=function(e,t,n,r){var o,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,i["default"])(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var u=e.length-1;u>=0;u--)(o=e[u])&&(s=(a<3?o(s):a>3?o(t,n,s):o(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s},m=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,i["default"])(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},v=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(t){o(t)}}function s(e){try{u(r["throw"](e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},y=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),"throw":s(1),"return":s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r["return"]:o[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(s){o=[6,s],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},b=o.events.CloudbaseEventEmitter,_=o.adapters.RUNTIME,k=o.utils.printWarn,w=o.utils.throwError,x=o.utils.transformPhone,A=o.constants.ERRORS,D=o.constants.COMMUNITY_SITE_URL,E=o.helpers.catchErrorsDecorator,C=t.eventBus=new b,S=function(){function e(e){var t=e.cache,n=e.request;this._cache=t,this._request=n,this._setUserInfo()}return e.prototype.checkLocalInfo=function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){return this.uid=this._getLocalUserInfo("uid"),this.loginType=this._getLocalUserInfo("loginType"),this.openid=this._getLocalUserInfo("wxOpenId"),this.wxOpenId=this._getLocalUserInfo("wxOpenId"),this.wxPublicId=this._getLocalUserInfo("wxPublicId"),this.unionId=this._getLocalUserInfo("wxUnionId"),this.qqMiniOpenId=this._getLocalUserInfo("qqMiniOpenId"),this.customUserId=this._getLocalUserInfo("customUserId"),this.nickName=this._getLocalUserInfo("nickName"),this.gender=this._getLocalUserInfo("gender"),this.avatarUrl=this._getLocalUserInfo("avatarUrl"),this.email=this._getLocalUserInfo("email"),this.hasPassword=Boolean(this._getLocalUserInfo("hasPassword")),this.phone=this._getLocalUserInfo("phone"),this.username=this._getLocalUserInfo("username"),this.location={country:this._getLocalUserInfo("country"),province:this._getLocalUserInfo("province"),city:this._getLocalUserInfo("city")},[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s,u,c,l,f,d,p,h,g,m,v;return y(this,(function(y){switch(y.label){case 0:return e=this,[4,this._getLocalUserInfoAsync("uid")];case 1:return e.uid=y.sent(),t=this,[4,this._getLocalUserInfoAsync("loginType")];case 2:return t.loginType=y.sent(),n=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 3:return n.openid=y.sent(),r=this,[4,this._getLocalUserInfoAsync("wxOpenId")];case 4:return r.wxOpenId=y.sent(),i=this,[4,this._getLocalUserInfoAsync("wxPublicId")];case 5:return i.wxPublicId=y.sent(),o=this,[4,this._getLocalUserInfoAsync("wxUnionId")];case 6:return o.unionId=y.sent(),a=this,[4,this._getLocalUserInfoAsync("qqMiniOpenId")];case 7:return a.qqMiniOpenId=y.sent(),s=this,[4,this._getLocalUserInfoAsync("customUserId")];case 8:return s.customUserId=y.sent(),u=this,[4,this._getLocalUserInfoAsync("nickName")];case 9:return u.nickName=y.sent(),c=this,[4,this._getLocalUserInfoAsync("gender")];case 10:return c.gender=y.sent(),l=this,[4,this._getLocalUserInfoAsync("avatarUrl")];case 11:return l.avatarUrl=y.sent(),f=this,[4,this._getLocalUserInfoAsync("email")];case 12:return f.email=y.sent(),d=this,p=Boolean,[4,this._getLocalUserInfoAsync("hasPassword")];case 13:return d.hasPassword=p.apply(void 0,[y.sent()]),h=this,[4,this._getLocalUserInfoAsync("phone")];case 14:return h.phone=y.sent(),g=this,[4,this._getLocalUserInfoAsync("username")];case 15:return g.username=y.sent(),m=this,v={},[4,this._getLocalUserInfoAsync("country")];case 16:return v.country=y.sent(),[4,this._getLocalUserInfoAsync("province")];case 17:return v.province=y.sent(),[4,this._getLocalUserInfoAsync("city")];case 18:return m.location=(v.city=y.sent(),v),[2]}}))}))},e.prototype.linkWithTicket=function(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})},e.prototype.linkWithRedirect=function(e){e.signInWithRedirect()},e.prototype.getLinkedUidList=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,o;return y(this,(function(a){switch(a.label){case 0:return[4,this._request.send("auth.getLinkedUidList",{})];case 1:for(e=a.sent().data,t=!1,n=e.users,r=0,i=n;r<i.length;r++)if((o=i[r]).wxOpenId&&o.wxPublicId){t=!0;break}return[2,{users:n,hasPrimaryUid:t}]}}))}))},e.prototype.setPrimaryUid=function(e){return this._request.send("auth.setPrimaryUid",{uid:e})},e.prototype.unlink=function(e){return this._request.send("auth.unlink",{platform:e})},e.prototype.update=function(e){return v(this,void 0,void 0,(function(){var t,n,r,i,o,a,s;return y(this,(function(u){switch(u.label){case 0:return t=e.nickName,n=e.gender,r=e.avatarUrl,i=e.province,o=e.country,a=e.city,[4,this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:r,province:i,country:o,city:a})];case 1:return s=u.sent().data,this._setLocalUserInfo(s),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})},e.prototype.updateEmail=function(e,t){return this._request.send("auth.updateEmail",{newEmail:e,password:t})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&w(A.INVALID_PARAMS,"username must be a string"),this._request.send("auth.updateUsername",{username:e})},e.prototype.refresh=function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return e=t.sent().data,this._setLocalUserInfo(e),[2,e]}}))}))},e.prototype.linkWithPhoneNumber=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:x(e),phoneCode:t})]}))}))},e.prototype.updatePhoneNumber=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return[2,this._request.send("auth.linkOrUpdatePhoneNumber",{phoneNumber:x(e),phoneCode:t})]}))}))},e.prototype._getLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;return this._cache.getStore(t)[e]},e.prototype._getLocalUserInfoAsync=function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return t=this._cache.keys.userInfoKey,[4,this._cache.getStoreAsync(t)];case 1:return[2,n.sent()[e]]}}))}))},e.prototype._setUserInfo=function(){var e=this,t=this._cache.keys.userInfoKey,n=this._cache.getStore(t);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl","phone","username"].forEach((function(t){e[t]=n[t]})),this.location={country:n.country,province:n.province,city:n.city}},e.prototype._setLocalUserInfo=function(e){var t=this._cache.keys.userInfoKey;this._cache.setStore(t,e),this._setUserInfo()},g([E({title:"绑定自定义登录失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithTicket() 的语法或参数是否正确"," 2 - 此账户是否已经绑定自定义登录"," 3 - ticket 参数是否归属当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String]),m("design:returntype",Promise)],e.prototype,"linkWithTicket",null),g([E({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 User.linkWithRedirect() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方"," 3 - 此第三方是否已经授权","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",void 0)],e.prototype,"linkWithRedirect",null),g([E({title:"获取账户列表失败",messages:["请确认以下各项:"," 1 - 调用 User.getLinkedUidList() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",Promise)],e.prototype,"getLinkedUidList",null),g([E({title:"设置微信主账号失败",messages:["请确认以下各项:"," 1 - 调用 User.setPrimaryUid() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String]),m("design:returntype",void 0)],e.prototype,"setPrimaryUid",null),g([E({title:"接触绑定失败",messages:["请确认以下各项:"," 1 - 调用 User.unlink() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String]),m("design:returntype",void 0)],e.prototype,"unlink",null),g([E({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[Object]),m("design:returntype",Promise)],e.prototype,"update",null),g([E({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String,String]),m("design:returntype",void 0)],e.prototype,"updatePassword",null),g([E({title:"更新邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 User.updateEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String,String]),m("design:returntype",void 0)],e.prototype,"updateEmail",null),g([E({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String]),m("design:returntype",void 0)],e.prototype,"updateUsername",null),g([E({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",Promise)],e.prototype,"refresh",null),g([E({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().linkWithPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String,String]),m("design:returntype",Promise)],e.prototype,"linkWithPhoneNumber",null),g([E({title:"更新手机号失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String,String]),m("design:returntype",Promise)],e.prototype,"updatePhoneNumber",null),e}(),O=t.LoginState=function(){function e(e){var t=e.envId,n=e.cache,r=e.request;t||w(A.INVALID_PARAMS,"envId is not defined"),this._cache=n,this.user=new S({cache:n,request:r})}return e.prototype.checkLocalState=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,o,a;return y(this,(function(s){return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,i=this._cache.getStore(t),o=this._cache.getStore(n),a=this._cache.getStore(r),this.credential={refreshToken:i,accessToken:o,accessTokenExpire:a},this._loginType=this._cache.getStore(this._cache.keys.loginTypeKey),this.user.checkLocalInfo(),[2]}))}))},e.prototype.checkLocalStateAsync=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s;return y(this,(function(u){switch(u.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,[4,this._cache.getStoreAsync(t)];case 1:return i=u.sent(),[4,this._cache.getStoreAsync(n)];case 2:return o=u.sent(),[4,this._cache.getStoreAsync(r)];case 3:return a=u.sent(),this.credential={refreshToken:i,accessToken:o,accessTokenExpire:a},s=this,[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 4:return s._loginType=u.sent(),[4,this.user.checkLocalInfoAsync()];case 5:return u.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"isAnonymousAuth",{get:function(){return this.loginType===c.LOGINTYPE.ANONYMOUS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCustomAuth",{get:function(){return this.loginType===c.LOGINTYPE.CUSTOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWeixinAuth",{get:function(){return this.loginType===c.LOGINTYPE.WECHAT||this.loginType===c.LOGINTYPE.WECHAT_OPEN||this.loginType===c.LOGINTYPE.WECHAT_PUBLIC},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsernameAuth",{get:function(){return this.loginType===c.LOGINTYPE.USERNAME},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._loginType},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPhoneAuth",{get:function(){return this.loginType===c.LOGINTYPE.PHONE},enumerable:!1,configurable:!0}),e}(),I=t.Auth=function(){function e(e){this._config=e,this._cache=e.cache,this._request=e.request,this._runtime=e.runtime||_.WEB,C.on(T.LOGIN_TYPE_CHANGED,this._onLoginTypeChanged.bind(this))}return Object.defineProperty(e.prototype,"currentUser",{get:function(){if("async"!==this._cache.mode){var e=this.hasLoginState();return e&&e.user||null}k(A.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrenUser insteed")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loginType",{get:function(){return this._cache.getStore(this._cache.keys.loginTypeKey)},enumerable:!1,configurable:!0}),e.prototype.getCurrenUser=function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return[4,this.getLoginState()];case 1:return(e=t.sent())?[4,e.user.checkLocalInfoAsync()]:[3,3];case 2:return t.sent(),[2,e.user||null];case 3:return[2,null]}}))}))},e.prototype.getLoginType=function(){return v(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,this._cache.getStoreAsync(this._cache.keys.loginTypeKey)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAccessToken=function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return e={},[4,this._request.getAccessToken()];case 1:return[2,(e.accessToken=t.sent().accessToken,e.env=this._config.env,e)]}}))}))},e.prototype.weixinAuthProvider=function(e){var t=e.appid,n=e.scope,r=e.state;return this._weixinAuthProvider||(this._weixinAuthProvider=new a.WeixinAuthProvider(h(h({},this._config),{cache:this._cache,request:this._request,runtime:this._runtime}),t,n,r)),this._weixinAuthProvider},e.prototype.anonymousAuthProvider=function(){return this._anonymousAuthProvider||(this._anonymousAuthProvider=new s.AnonymousAuthProvider(h(h({},this._config),{cache:this._cache,request:this._request}))),this._anonymousAuthProvider},e.prototype.customAuthProvider=function(){return this._customAuthProvider||(this._customAuthProvider=new u.CustomAuthProvider(h(h({},this._config),{cache:this._cache,request:this._request}))),this._customAuthProvider},e.prototype.emailAuthProvider=function(){return this._emailAuthProvider||(this._emailAuthProvider=new f.EmailAuthProvider(h(h({},this._config),{cache:this._cache,request:this._request}))),this._emailAuthProvider},e.prototype.usernameAuthProvider=function(){return this._usernameAuthProvider||(this._usernameAuthProvider=new d.UsernameAuthProvider(h(h({},this._config),{cache:this._cache,request:this._request}))),this._usernameAuthProvider},e.prototype.phoneAuthProvider=function(){return this._phoneAuthProvider||(this._phoneAuthProvider=new p.PhoneAuthProvider(h(h({},this._config),{cache:this._cache,request:this._request}))),this._phoneAuthProvider},e.prototype.signInWithUsernameAndPassword=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return[2,this.usernameAuthProvider().signIn(e,t)]}))}))},e.prototype.isUsernameRegistered=function(e){return v(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return"string"!=typeof e&&w(A.INVALID_PARAMS,"username must be a string"),[4,this._request.send("auth.isUsernameRegistered",{username:e})];case 1:return[2,null==(t=n.sent().data)?void 0:t.isRegistered]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return[2,this.emailAuthProvider().signIn(e,t)]}))}))},e.prototype.signUpWithEmailAndPassword=function(e,t){return v(this,void 0,void 0,(function(){return y(this,(function(n){return[2,this.emailAuthProvider().signUp(e,t)]}))}))},e.prototype.sendPasswordResetEmail=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this.emailAuthProvider().resetPassword(e)]}))}))},e.prototype.signOut=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,o,a;return y(this,(function(s){switch(s.label){case 0:return e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=e.accessTokenExpireKey,i="auth.logout",[4,this._cache.getStoreAsync(t)];case 1:return(o=s.sent())?[4,this._request.send(i,{refresh_token:o})]:[2];case 2:return a=s.sent(),this._cache.removeStoreAsync(t),this._cache.removeStoreAsync(n),this._cache.removeStoreAsync(r),C.fire(T.LOGIN_STATE_CHANGED),C.fire(T.LOGIN_TYPE_CHANGED,{env:this._config.env,loginType:c.LOGINTYPE.NULL,persistence:this._config.persistence}),[2,a]}}))}))},e.prototype.onLoginStateChanged=function(e){return v(this,void 0,void 0,(function(){var t,n=this;return y(this,(function(r){switch(r.label){case 0:return C.on(T.LOGIN_STATE_CHANGED,(function(){return v(n,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))})),[4,this.getLoginState()];case 1:return t=r.sent(),e.call(this,t),[2]}}))}))},e.prototype.onLoginStateExpired=function(e){C.on(T.LOGIN_STATE_EXPIRED,e.bind(this))},e.prototype.onAccessTokenRefreshed=function(e){C.on(T.ACCESS_TOKEN_REFRESHD,e.bind(this))},e.prototype.onAnonymousConverted=function(e){C.on(T.ANONYMOUS_CONVERTED,e.bind(this))},e.prototype.onLoginTypeChanged=function(e){var t=this;C.on(T.LOGIN_TYPE_CHANGED,(function(){return v(t,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return t=n.sent(),e.call(this,t),[2]}}))}))}))},e.prototype.hasLoginState=function(){if("async"!==this._cache.mode){var e=this._cache.keys.refreshTokenKey;if(this._cache.getStore(e)){var t=new O({envId:this._config.env,cache:this._cache,request:this._request});return t.checkLocalState(),t}return null}k(A.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},e.prototype.getLoginState=function(){return v(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=this._cache.keys.refreshTokenKey,[4,this._cache.getStoreAsync(e)];case 1:return n.sent()?[4,(t=new O({envId:this._config.env,cache:this._cache,request:this._request})).checkLocalStateAsync()]:[3,3];case 2:return n.sent(),[2,t];case 3:return[2,null]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)},e.prototype.getUserInfo=function(){return v(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.getUserInfo",{})];case 1:return(e=t.sent()).code?[2,e]:[2,h(h({},e.data),{requestId:e.seqId})]}}))}))},e.prototype.getAuthHeader=function(){var e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,r=this._cache.getStore(t);return{"x-cloudbase-credentials":this._cache.getStore(n)+"/@@/"+r}},e.prototype.getAuthHeaderAsync=function(){return v(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(i){switch(i.label){case 0:return[4,this._request.refreshAccessToken()];case 1:return i.sent(),e=this._cache.keys,t=e.refreshTokenKey,n=e.accessTokenKey,[4,this._cache.getStoreAsync(t)];case 2:return r=i.sent(),[4,this._cache.getStoreAsync(n)];case 3:return[2,{"x-cloudbase-credentials":i.sent()+"/@@/"+r}]}}))}))},e.prototype.sendPhoneCode=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return[4,this._request.send("auth.sendPhoneCode",{phoneNumber:x(e)})];case 1:return[2,"Ok"===t.sent().data.SendStatus]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,n){return v(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this.phoneAuthProvider().signUp(e,t,n)]}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this.phoneAuthProvider().signIn(e)]}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return v(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this.phoneAuthProvider().signIn(h(h({},e),{signMethod:p.SIGN_METHOD.FORCERESETPWD}))]}))}))},e.prototype._onLoginTypeChanged=function(e){return v(this,void 0,void 0,(function(){var t,n,r;return y(this,(function(i){switch(i.label){case 0:return t=e.data,n=t.loginType,r=t.persistence,t.env!==this._config.env?[2]:[4,this._cache.updatePersistenceAsync(r)];case 1:return i.sent(),[4,this._cache.setStoreAsync(this._cache.keys.loginTypeKey,n)];case 2:return i.sent(),[2]}}))}))},g([E({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrenUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",Promise)],e.prototype,"getCurrenUser",null),g([E({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String]),m("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),g([E({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",Promise)],e.prototype,"signOut",null),g([E({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",Promise)],e.prototype,"getLoginState",null),g([E({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",Promise)],e.prototype,"getUserInfo",null),g([E({title:"发送短信验证码失败",messages:["请确认以下各项:"," 1 - 调用语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:"+D]}),m("design:type",Function),m("design:paramtypes",[String]),m("design:returntype",Promise)],e.prototype,"sendPhoneCode",null),e}(),T=t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRED:"loginStateExpire",LOGIN_TYPE_CHANGED:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",ACCESS_TOKEN_REFRESHD:"refreshAccessToken"},P={name:"auth",namespace:"auth",injectEvents:{bus:C,events:[T.LOGIN_TYPE_CHANGED,T.LOGIN_STATE_EXPIRED,T.LOGIN_STATE_CHANGED,T.ACCESS_TOKEN_REFRESHD,T.ANONYMOUS_CONVERTED]},entity:function(e){if(void 0===e&&(e={region:"",persistence:"local"}),this.authInstance)return k(A.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var t=this.platform,n=t.adapter,r=t.runtime,i=e.persistence||n.primaryStorage;i&&i!==this.config.persistence&&this.updateConfig({persistence:i});var o=this.config,a=o.env,s=o.persistence,u=o.debug;return this.authInstance=new I({env:a,region:e.region,persistence:s,debug:u,cache:this.cache,request:this.request,runtime:r}),this.authInstance}};try{cloudbase.registerComponent(P)}catch(F){}},4325:function(e,t,n){"use strict";var r=n(477);Object.defineProperty(t,"__esModule",{value:!0}),t.AnonymousAuthProvider=void 0;var i,o=r(n(9367)),a=n(4522),s=n(2566),u=n(1235),c=n(3442),l=(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},i(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=function(e,t,n,r){var i,a=arguments.length,s=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"===("undefined"==typeof Reflect?"undefined":(0,o["default"])(Reflect))&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var u=e.length-1;u>=0;u--)(i=e[u])&&(s=(a<3?i(s):a>3?i(t,n,s):i(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s},d=function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":(0,o["default"])(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},p=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(t){o(t)}}function s(e){try{u(r["throw"](e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},h=function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),"throw":s(1),"return":s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){retu