@cloudbase/auth 2.5.49-beta.2 → 2.5.49-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ export { printWarn, throwError } from '@cloudbase/utilities/dist/cjs/libs/util';
2
+ export { ERRORS, COMMUNITY_SITE_URL } from '@cloudbase/utilities/dist/cjs/constants';
3
+ export { catchErrorsDecorator } from '@cloudbase/utilities/dist/cjs/helpers';
4
+ export { CloudbaseEventEmitter } from '@cloudbase/utilities/dist/cjs/libs/events';
5
+ export { CloudbaseCache } from '@cloudbase/utilities/dist/cjs/libs/cache';
6
+ export { default as adapterForWxMp } from 'cloudbase-adapter-wx_mp';
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbGl0aWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxpdGllcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsU0FBUyxFQUFFLFVBQVUsRUFBRSxNQUFNLHlDQUF5QyxDQUFBO0FBQy9FLE9BQU8sRUFBRSxNQUFNLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQTtBQUNwRixPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQTtBQUM1RSxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSwyQ0FBMkMsQ0FBQTtBQUNqRixPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sMENBQTBDLENBQUE7QUFDekUsT0FBTyxFQUFFLE9BQU8sSUFBSSxjQUFjLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbIi8vIOS4uuS6huWHj+WwkeWwj+eoi+W6j+S9k+enr++8jOWvvOWHuuaWueazleW5tiBib3VkbGXvvIzlkIzml7bpmLLmraLlhbbkuK3kvb/nlKjkuoYgd2ViIOi/kOihjOeOr+Wig1xuZXhwb3J0IHsgcHJpbnRXYXJuLCB0aHJvd0Vycm9yIH0gZnJvbSAnQGNsb3VkYmFzZS91dGlsaXRpZXMvZGlzdC9janMvbGlicy91dGlsJ1xuZXhwb3J0IHsgRVJST1JTLCBDT01NVU5JVFlfU0lURV9VUkwgfSBmcm9tICdAY2xvdWRiYXNlL3V0aWxpdGllcy9kaXN0L2Nqcy9jb25zdGFudHMnXG5leHBvcnQgeyBjYXRjaEVycm9yc0RlY29yYXRvciB9IGZyb20gJ0BjbG91ZGJhc2UvdXRpbGl0aWVzL2Rpc3QvY2pzL2hlbHBlcnMnXG5leHBvcnQgeyBDbG91ZGJhc2VFdmVudEVtaXR0ZXIgfSBmcm9tICdAY2xvdWRiYXNlL3V0aWxpdGllcy9kaXN0L2Nqcy9saWJzL2V2ZW50cydcbmV4cG9ydCB7IENsb3VkYmFzZUNhY2hlIH0gZnJvbSAnQGNsb3VkYmFzZS91dGlsaXRpZXMvZGlzdC9janMvbGlicy9jYWNoZSdcbmV4cG9ydCB7IGRlZmF1bHQgYXMgYWRhcHRlckZvcld4TXAgfSBmcm9tICdjbG91ZGJhc2UtYWRhcHRlci13eF9tcCdcbiJdfQ==
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@cloudbase/oauth")):"function"==typeof define&&define.amd?define("tcbauth",["@cloudbase/oauth"],e):"object"==typeof exports?exports.tcbauth=e(require("@cloudbase/oauth")):t.tcbauth=e(t.tcboauth)}("undefined"!=typeof window?window:this,t=>(()=>{"use strict";var e={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}},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,"\\]")),p=s.findIndex((function(t){return c.test(t)}));if(-1!==p){var l=s.filter((function(t,e){return e>p}));l.unshift(s[p].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,p=void 0===a?{}:a,l=t.title,f=t.messages,d=void 0===f?[]:f;return function(t,e,a){if(s.IS_DEBUG_MODE){var f=p.className||t.constructor.name,g=p.methodName||e,v=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:f,methodName:g,sourceLink:y});try{return v.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,c={title:l||"".concat(f,".").concat(g," 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=d.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=d.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,p;return o(this,(function(o){switch(o.label){case 0:e=h({err:new Error,className:f,methodName:g,sourceLink:y}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,v.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(f,".").concat(g," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(p=JSON.parse(s),u.subtitle=p,p.code&&(e?(e.code=p.code,e.message=p.msg):(n.code=p.code,n.message=p.msg),r=e||n,u.content=d.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=d.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 p=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=p},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.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.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.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=t.title,n=t.subtitle,r=void 0===n?"":n,o=t.content,i=void 0===o?[]:o,s=t.printTrace,a=void 0!==s&&s,c=t.collapsed;void 0!==c&&c?console.groupCollapsed(e,r):console.group(e,r);for(var u=0,h=i;u<h.length;u++){var p=h[u],l=p.type,f=p.body;switch(l){case"info":console.log(f);break;case"warn":console.warn(f);break;case"error":console.error(f)}}a&&console.trace("stack trace:"),console.groupEnd()};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)}},297:e=>{e.exports=t}},n={};function r(t){var o=n[t];if(void 0!==o)return o.exports;var i=n[t]={exports:{}};return e[t].call(i.exports,i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{r.r(o),r.d(o,{Auth:()=>C,LoginState:()=>M,generateAuthInstance:()=>k,registerAuth:()=>x});var t,e=r(297),n=r(894),i=r(141),s=r(466),a=r(988),c=r(418),u=r(829),h=(t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)},function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),p=function(){return(p=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())}))},f=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(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};var d=function(t){function e(e){void 0===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 h(e,t),e.prototype.post=function(t){var e=this;return new Promise((function(n,r){var o=t.url,i=t.data,s=t.headers,a=wx.request({url:(0,u.formatUrl)("https:",o),data:i,timeout:e._timeout,method:"POST",header:s,success:function(t){n(t)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(e._timeout&&-1!==e._restrictedMethods.indexOf("post")&&"request:fail timeout"===t.errMsg)){console.warn(e._timeoutMsg);try{a.abort()}catch(t){}}}})}))},e.prototype.upload=function(t){var e=this,n=this;return new Promise((function(r){return l(e,void 0,void 0,(function(){var e,o,i,s,a,c;return f(this,(function(u){return e=t.url,o=t.file,i=t.data,s=t.headers,a=t.onUploadProgress,c=wx.uploadFile({url:e,filePath:o,name:"file",formData:p({},i),header:s,timeout:this._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&i.success_action_status&&(e.statusCode=parseInt(i.success_action_status,10)),r(e)},fail:function(t){r(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{c.abort()}catch(t){}}}}),a&&c.onProgressUpdate((function(t){a(t)})),[2]}))}))}))},e.prototype.download=function(t){var e=this,n=this;return new Promise((function(r,o){var i=t.url,s=t.headers,a=wx.downloadFile({url:(0,u.formatUrl)("https:",i),header:s,timeout:e._timeout,success:function(t){200===t.statusCode&&t.tempFilePath?r({statusCode:200,tempFilePath:t.tempFilePath}):r(t)},fail:function(t){o(t)},complete:function(t){if(t&&t.errMsg&&(n._timeout&&-1!==n._restrictedMethods.indexOf("download")&&"request:fail timeout"===t.errMsg)){console.warn(n._timeoutMsg);try{a.abort()}catch(t){}}}})}))},e}(u.AbstractSDKRequest),g={setItem:function(t,e){wx.setStorageSync(t,e)},getItem:function(t){return wx.getStorageSync(t)},removeItem:function(t){wx.removeStorageSync(t)},clear:function(){wx.clearStorageSync()}},v=function(t,e){void 0===e&&(e={});var n=wx.connectSocket(p({url:t},e));return{set onopen(t){n.onOpen(t)},set onmessage(t){n.onMessage(t)},set onclose(t){n.onClose(t)},set onerror(t){n.onError(t)},send:function(t){return n.send({data:t})},close:function(t,e){return n.close({code:t,reason:e})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};const y={genAdapter:function(){return{root:{},reqClass:d,wsClass:v,localStorage:g,primaryStorage:u.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(t){return!1}return!0},runtime:"wx_mp"};var m=function(){return(m=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){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())}))},b=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])}}},_=function(){function t(t){this.localStorage=(null==t?void 0:t.localStorage)||globalThis.localStorage}return t.prototype.getItem=function(t){return I(this,void 0,void 0,(function(){return b(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return I(this,void 0,void 0,(function(){return b(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return I(this,void 0,void 0,(function(){return b(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}(),w=/^[^:]+:\/\/[^/]+(\/[^?#]+)/;function S(t){return function(e,n){var r;return I(this,void 0,void 0,(function(){var o;return b(this,(function(i){return o=null===(r=null==n?void 0:n.headers)||void 0===r?void 0:r["x-request-id"],[2,new Promise((function(r,i){var s=Object.assign({},n);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:e,data:s.body,timeout:t._timeout,method:s.method||"GET",header:s.headers,success:function(t){t.code&&(t={error:t.code,error_description:t.message||t.code,request_id:t.requestId}),t.request_id||(t.request_id=t.request_id||o),t.error&&(t.error_uri=function(t){return w.test(t)?RegExp.$1:t}(e),i(t)),r(t.data||{})},fail:function(t){i({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{a.abort()}catch(t){}}}})}))]}))}))}}var O=function(){return(O=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)},A=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},P=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},E=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())}))},U=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])}}},L="loginStateChanged",R=new a.CloudbaseEventEmitter,T=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 E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){var t,e,n,r;return U(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 E(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(O({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(O({},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,n.throwError)(i.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return E(this,void 0,void 0,(function(){var e;return U(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 E(this,void 0,void 0,(function(){var e;return U(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()},A([(0,s.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"update",null),A([(0,s.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[String,String]),P("design:returntype",void 0)],t.prototype,"updatePassword",null),A([(0,s.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[String]),P("design:returntype",void 0)],t.prototype,"updateUsername",null),A([(0,s.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"refresh",null),t}(),M=function(){function t(t){var e=t.envId,r=t.cache,o=t.oauthInstance;e||(0,n.throwError)(i.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=o,this.user=new T({cache:this.cache,oauthInstance:o})}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 E(this,void 0,void 0,(function(){return U(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}(),C=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.getVerification(t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,n.printWarn)(i.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser insteed")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(){return E(this,void 0,void 0,(function(){var t;return U(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={}),E(this,void 0,void 0,(function(){return U(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.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,n=void 0===e||e;return E(this,void 0,void 0,(function(){var t,e,r,o=this;return U(this,(function(i){switch(i.label){case 0:if(!y.isMatch())throw Error("wx api undefined");if(!n)return[3,7];t=wx.getAccountInfoSync().miniProgram,e=void 0,r=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_params:{provider_code_type:"open_id"}},!0)];case 2:if(null==(e=i.sent())?void 0:e.error_code)throw e;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:e.provider_token},!0)];case 3:if(null==(r=i.sent())?void 0:r.error_code)throw r;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(r)];case 6:return i.sent(),[3,9];case 7:return[4,new Promise((function(t,e){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(r){return E(o,void 0,void 0,(function(){var o,i,s,a,c;return U(this,(function(u){switch(u.label){case 0:o=null==n?void 0:n.appId,u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:r.code,provider_id:o,provider_params:{provider_code_type:"open_id",appid:null==n?void 0:n.appId}})];case 2:return i=u.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s})]:(e(i),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(e(a),[2]):(t(!0),[3,5]);case 4:return c=u.sent(),e(c),[3,5];case 5: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 8:i.sent(),i.label=9;case 9:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return E(this,void 0,void 0,(function(){var t=this;return U(this,(function(e){switch(e.label){case 0:if(!y.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 E(t,void 0,void 0,(function(){var t,i,s,a,c;return U(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 E(this,void 0,void 0,(function(){var t,e,r,o,i;return U(this,(function(s){switch(s.label){case 0:if(!y.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?{id:"",isUser:!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 E(this,void 0,void 0,(function(){var t,e,r,i,a;return U(this,(function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:n.id,verification_code:o})];case 1:if(null==(t=u.sent())?void 0:t.error_code)throw t;return e=t.verification_token,n.isUser?[4,this.oauthInstance.authApi.signIn({username:"+86 ".concat(s),verification_token:e})]:[3,5];case 2:if(null==(r=u.sent())?void 0:r.error_code)throw r;return c?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==c?void 0:c.providerToken})]:[3,4];case 3:if(null==(i=u.sent())?void 0:i.error_code)throw i;u.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp({phone_number:"+86 ".concat(s),verification_token:e,provider_token:null==c?void 0:c.providerId})];case 6:if(null==(a=u.sent())?void 0:a.error_code)throw a;u.label=7;case 7:return[2,this.createLoginState()];case 8:throw u.sent();case 9:return[2]}}))}))},t.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},t.prototype.signInWithCustomTicket=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithCustomTicket(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signIn=function(t){return E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,n.throwError)(i.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},t.prototype.signOut=function(){return E(this,void 0,void 0,(function(){var t;return U(this,(function(e){switch(e.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut()];case 1:return e.sent(),[4,this.cache.removeStoreAsync(t)];case 2:return e.sent(),R.fire(L),[2]}}))}))},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 M({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,n.printWarn)(i.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState insteed")},t.prototype.getLoginState=function(){return E(this,void 0,void 0,(function(){return U(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new M({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return E(this,void 0,void 0,(function(){return U(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return E(this,void 0,void 0,(function(){var e;return U(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 E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return E(this,void 0,void 0,(function(){return U(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={}),E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return E(this,void 0,void 0,(function(){return U(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return E(this,void 0,void 0,(function(){return U(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return E(this,void 0,void 0,(function(){return U(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return E(this,void 0,void 0,(function(){var e,n=this;return U(this,(function(r){switch(r.label){case 0:return R.on(L,(function(){return E(n,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return e=n.sent(),t.call(this,e),[2]}}))}))})),[4,this.getLoginState()];case 1:return e=r.sent(),t.call(this,e),[2]}}))}))},t.prototype.refreshTokenForce=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return E(this,void 0,void 0,(function(){return U(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return E(this,void 0,void 0,(function(){return U(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 E(this,void 0,void 0,(function(){return U(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return E(this,void 0,void 0,(function(){return U(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.createLoginState=function(t){return E(this,void 0,void 0,(function(){var e;return U(this,(function(n){switch(n.label){case 0:return[4,(e=new M({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return n.sent(),[4,e.user.refresh(t)];case 2:return n.sent(),R.fire(L),[2,e]}}))}))},A([(0,s.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),A([(0,s.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"unbindProvider",null),A([(0,s.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",void 0)],t.prototype,"bindEmail",null),A([(0,s.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"verify",null),A([(0,s.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"getVerification",null),A([(0,s.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",Promise)],t.prototype,"getCurrentUser",null),A([(0,s.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"signInAnonymously",null),A([(0,s.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),A([(0,s.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),A([(0,s.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),A([(0,s.catchErrorsDecorator)({title:"小程序短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"signInWithSms",null),A([(0,s.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),A([(0,s.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"signUp",null),A([(0,s.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[String]),P("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),A([(0,s.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",Promise)],t.prototype,"signOut",null),A([(0,s.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",Promise)],t.prototype,"getLoginState",null),A([(0,s.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"getUserInfo",null),A([(0,s.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),A([(0,s.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[Object]),P("design:returntype",Promise)],t.prototype,"bindWithProvider",null),A([(0,s.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),P("design:type",Function),P("design:paramtypes",[]),P("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function k(t,n){var r=t.region,o=void 0===r?"ap-shanghai":r,i=((null==n?void 0:n.platform)||{}).runtime,s=n||{},a=s.env,u=s.clientId,h=s.debug,p=s.cache,l=s.app,f=(n||{}).apiOrigin;f||(f="https://".concat(a,".").concat(o,".tcb-api.tencentcloudapi.com"));var d=new e.CloudbaseOAuth(function(t){if(!y.isMatch()||t.storage&&t.baseRequest)return t;var e={};try{var n=y.genAdapter(),r=n.localStorage,o=n.reqClass;if(r&&(e.storage=new _({localStorage:r})),o){var i=new o({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});e.request=S(i)}return m(m({},t),e)}catch(t){console.error("adapter generate fail:",t)}return t}({env:a,clientId:u,apiOrigin:f,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud}));return{authInstance:new C({env:a,region:o,persistence:t.persistence,debug:h,cache:p||new c.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(a)},platformInfo:null==n?void 0:n.platform}),runtime:i||"web",_fromApp:l,oauthInstance:d}),oauthInstance:d}}var N={name:"auth",namespace:"auth",entity:function(t){if(void 0===t&&(t={region:"",persistence:"local"}),this.authInstance)return(0,n.printWarn)(i.ERRORS.INVALID_OPERATION,"every cloudbase instance should has only one auth object"),this.authInstance;var e=this.platform.adapter,r=t.persistence||e.primaryStorage;r&&r!==this.config.persistence&&this.updateConfig({persistence:r});var o=k(O(O({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),s=o.authInstance,a=o.oauthInstance;return this.oauthInstance=a,this.authInstance=s,this.authInstance}};try{cloudbase.registerComponent(N)}catch(t){}function x(t){try{t.registerComponent(N)}catch(t){console.warn(t)}}})(),o})());
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@cloudbase/auth",
3
- "version": "2.5.49-beta.2",
3
+ "version": "2.5.49-beta.4",
4
4
  "description": "cloudbase javascript sdk auth componets",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
+ "miniprogram": "dist/miniprogram",
7
8
  "scripts": {
8
9
  "tsc": "rm -rf dist/ && tsc -p tsconfig.esm.json && tsc -p tsconfig.json",
9
10
  "lint": "eslint --fix \"./src/**/*.ts\"",
10
- "build": "npm run lint && npm run tsc",
11
+ "build": "npm run lint && npm run tsc && npm run build:mp",
12
+ "tsc:mp": "tsc -p tsconfig.esm.json --outDir dist/miniprogram",
13
+ "build:mp": "webpack --config ./webpack/webpack.miniprogram.js",
11
14
  "precommit": "npm run lint"
12
15
  },
13
16
  "publishConfig": {
@@ -28,11 +31,15 @@
28
31
  "author": "",
29
32
  "license": "Apache-2.0",
30
33
  "dependencies": {
31
- "@cloudbase/oauth": "^2.5.49-beta.2",
32
- "@cloudbase/utilities": "^2.5.49-beta.0"
34
+ "@cloudbase/oauth": "^2.5.49-beta.6",
35
+ "@cloudbase/utilities": "^2.5.49-beta.0",
36
+ "cloudbase-adapter-wx_mp": "0.2.0"
33
37
  },
34
38
  "devDependencies": {
35
- "@cloudbase/types": "^2.5.49-beta.0"
39
+ "@cloudbase/types": "^2.5.49-beta.0",
40
+ "@types/node": "^22.1.0",
41
+ "terser-webpack-plugin": "^3.0.2",
42
+ "webpack-bundle-analyzer": "^4.9.1"
36
43
  },
37
44
  "gitHead": "0d182ece790ba8a0ef254f63f6a06ab3e878a302"
38
45
  }
package/src/adapter.ts CHANGED
@@ -1,5 +1,5 @@
1
- import adapterForWxMp from 'cloudbase-adapter-wx_mp'
2
- import { AuthOptions } from '@cloudbase/oauth'
1
+ import { adapterForWxMp } from './utilities'
2
+ import type { AuthOptions } from '@cloudbase/oauth'
3
3
 
4
4
  declare const wx: any
5
5
 
package/src/index.ts CHANGED
@@ -1,24 +1,27 @@
1
1
  import type { ICloudbase, ICloudbaseConfig } from '@cloudbase/types'
2
- import { utils, constants, helpers, events, cache } from '@cloudbase/utilities'
3
2
  import type { ICloudbaseCache } from '@cloudbase/types/cache'
4
3
  import type { ICloudbaseRequest } from '@cloudbase/types/request'
5
4
  import type { ICloudbaseAuthConfig, IUser, IUserInfo, ILoginState } from '@cloudbase/types/auth'
6
5
  import type { ICloudbaseComponent } from '@cloudbase/types/component'
6
+ import type { GrantProviderTokenResponse, ProviderSubType } from '@cloudbase/oauth/dist/cjs/auth/models'
7
+ import type { authModels, AuthOptions, Credentials } from '@cloudbase/oauth'
7
8
 
8
- import { authModels, CloudbaseOAuth, AuthOptions, Credentials } from '@cloudbase/oauth'
9
- import { GrantProviderTokenResponse, ProviderSubType } from '@cloudbase/oauth/dist/cjs/auth/models'
9
+ import { CloudbaseOAuth } from '@cloudbase/oauth'
10
10
  import { useAuthAdapter } from './adapter'
11
- import adapterForWxMp from 'cloudbase-adapter-wx_mp'
11
+ import {
12
+ printWarn,
13
+ throwError,
14
+ ERRORS,
15
+ COMMUNITY_SITE_URL,
16
+ catchErrorsDecorator,
17
+ CloudbaseEventEmitter,
18
+ CloudbaseCache,
19
+ adapterForWxMp,
20
+ } from './utilities'
12
21
 
13
22
  declare const cloudbase: ICloudbase
14
23
  declare const wx: any
15
24
 
16
- const { printWarn, throwError } = utils
17
- const { ERRORS, COMMUNITY_SITE_URL } = constants
18
- const { catchErrorsDecorator } = helpers
19
- const { CloudbaseEventEmitter } = events
20
- const { CloudbaseCache } = cache
21
-
22
25
  const COMPONENT_NAME = 'auth'
23
26
 
24
27
  const EVENTS = {
@@ -1070,6 +1073,12 @@ class Auth {
1070
1073
  public async getCredentials(): Promise<Credentials> {
1071
1074
  return this.oauthInstance.authApi.getCredentials()
1072
1075
  }
1076
+ /**
1077
+ * 写入身份信息
1078
+ */
1079
+ public async setCredentials(credentials: Credentials) {
1080
+ await this.oauthInstance.oauth2client.setCredentials(credentials)
1081
+ }
1073
1082
 
1074
1083
  @catchErrorsDecorator({
1075
1084
  title: '获取身份源类型',
@@ -1127,12 +1136,13 @@ export function generateAuthInstance(
1127
1136
  debug?: ICloudbaseAuthConfig['debug']
1128
1137
  },
1129
1138
  ) {
1139
+ const { region = 'ap-shanghai' } = config
1130
1140
  const { runtime } = options?.platform || {}
1131
1141
 
1132
1142
  const { env, clientId, debug, cache, app: cloudbase } = options || {}
1133
1143
  let { apiOrigin } = options || {}
1134
1144
  if (!apiOrigin) {
1135
- apiOrigin = `https://${env}.${config.region}.tcb-api.tencentcloudapi.com`
1145
+ apiOrigin = `https://${env}.${region}.tcb-api.tencentcloudapi.com`
1136
1146
  }
1137
1147
  const oauthInstance = new CloudbaseOAuth(useAuthAdapter({
1138
1148
  env,
@@ -1149,7 +1159,7 @@ export function generateAuthInstance(
1149
1159
 
1150
1160
  const authInstance = new Auth({
1151
1161
  env,
1152
- region: config.region,
1162
+ region,
1153
1163
  persistence: config.persistence,
1154
1164
  debug,
1155
1165
  cache:
@@ -0,0 +1,7 @@
1
+ // 为了减少小程序体积,导出方法并 boudle,同时防止其中使用了 web 运行环境
2
+ export { printWarn, throwError } from '@cloudbase/utilities/dist/cjs/libs/util'
3
+ export { ERRORS, COMMUNITY_SITE_URL } from '@cloudbase/utilities/dist/cjs/constants'
4
+ export { catchErrorsDecorator } from '@cloudbase/utilities/dist/cjs/helpers'
5
+ export { CloudbaseEventEmitter } from '@cloudbase/utilities/dist/cjs/libs/events'
6
+ export { CloudbaseCache } from '@cloudbase/utilities/dist/cjs/libs/cache'
7
+ export { default as adapterForWxMp } from 'cloudbase-adapter-wx_mp'
@@ -0,0 +1,86 @@
1
+ const path = require('path')
2
+ const webpack = require('webpack')
3
+ const TerserPlugin = require('terser-webpack-plugin')
4
+ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
5
+
6
+ module.exports = function (options) {
7
+ const { context, entry, output, mode, watch, externals, definePlugin = {}, optimization = {} } = options
8
+ const isDevelopment = mode !== 'production'
9
+ let plugins = [
10
+ new webpack.DefinePlugin(
11
+ Object.assign(
12
+ {
13
+ 'globalThis.IS_MP_BUILD': false,
14
+ },
15
+ definePlugin,
16
+ ),
17
+ ),
18
+ // new BundleAnalyzerPlugin(),
19
+ ].filter((item) => !!item)
20
+ return {
21
+ context,
22
+ entry,
23
+ mode,
24
+ watch,
25
+ watchOptions: {
26
+ ignored: [output.path],
27
+ },
28
+ output,
29
+ externals,
30
+ cache: {
31
+ type: 'memory',
32
+ },
33
+ devtool: false,
34
+ resolve: {
35
+ extensions: ['.ts', '.js', '.json'],
36
+ },
37
+ module: {
38
+ rules: [
39
+ {
40
+ test: /\.ts$/,
41
+ exclude: [/node_modules/],
42
+
43
+ use: [
44
+ 'babel-loader',
45
+ { loader: 'ts-loader', options: { configFile: path.resolve(context, './tsconfig.esm.json') } },
46
+ ],
47
+ },
48
+ {
49
+ test: /\.js$/,
50
+ exclude: [/node_modules/],
51
+ use: ['babel-loader'],
52
+ },
53
+ {
54
+ test: /package\.json$/,
55
+ loader: 'package-json-cleanup-loader',
56
+ options: {
57
+ only: ['version'],
58
+ },
59
+ },
60
+ ],
61
+ noParse: [/sjcl\.js$/],
62
+ },
63
+ plugins,
64
+ optimization: {
65
+ emitOnErrors: false,
66
+ removeEmptyChunks: true,
67
+ usedExports: true,
68
+ ...optimization,
69
+ ...(isDevelopment
70
+ ? {
71
+ minimize: false,
72
+ removeAvailableModules: false,
73
+ concatenateModules: true,
74
+ }
75
+ : {
76
+ minimizer: [
77
+ new TerserPlugin({
78
+ test: /\.js(\?.*)?$/i,
79
+ cache: false,
80
+ parallel: true,
81
+ }),
82
+ ],
83
+ }),
84
+ },
85
+ }
86
+ }
@@ -0,0 +1,30 @@
1
+ const path = require('path')
2
+
3
+ const params = {
4
+ context: path.resolve(__dirname, '../'),
5
+ mode: 'production',
6
+ watch: false,
7
+ entry: path.resolve(__dirname, '../src/index.ts'),
8
+ output: {
9
+ path: path.resolve(__dirname, '../dist/miniprogram'),
10
+ filename: 'index.js',
11
+ library: `tcbauth`,
12
+ libraryTarget: 'umd',
13
+ umdNamedDefine: true,
14
+ globalObject: 'typeof window !== "undefined"?window:this',
15
+ },
16
+ externals: {
17
+ '@cloudbase/oauth': {
18
+ root: 'tcboauth',
19
+ commonjs: '@cloudbase/oauth',
20
+ commonjs2: '@cloudbase/oauth',
21
+ amd: '@cloudbase/oauth',
22
+ },
23
+ },
24
+ definePlugin: {
25
+ 'process.env.NODE_ENV': JSON.stringify('production'), // 注入环境变量,用于业务代码判断
26
+ 'globalThis.IS_MP_BUILD': true,
27
+ },
28
+ }
29
+
30
+ module.exports = require('./web.prod.js')(params)