@cloudbase/auth 2.6.3-beta.0 → 2.6.5-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
+ export { useDefaultAdapter } from '@cloudbase/utilities/dist/cjs/adapters';
@@ -0,0 +1,8 @@
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
+ export { useDefaultAdapter } from '@cloudbase/utilities/dist/cjs/adapters';
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbGl0aWVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxpdGllcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsU0FBUyxFQUFFLFVBQVUsRUFBRSxNQUFNLHlDQUF5QyxDQUFBO0FBQy9FLE9BQU8sRUFBRSxNQUFNLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQTtBQUNwRixPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQTtBQUM1RSxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSwyQ0FBMkMsQ0FBQTtBQUNqRixPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sMENBQTBDLENBQUE7QUFDekUsT0FBTyxFQUFFLE9BQU8sSUFBSSxjQUFjLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQTtBQUNuRSxPQUFPLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx3Q0FBd0MsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbIi8vIOS4uuS6huWHj+WwkeWwj+eoi+W6j+S9k+enr++8jOWvvOWHuuaWueazleW5tiBib3VkbGXvvIzlkIzml7bpmLLmraLlhbbkuK3kvb/nlKjkuoYgd2ViIOi/kOihjOeOr+Wig1xuZXhwb3J0IHsgcHJpbnRXYXJuLCB0aHJvd0Vycm9yIH0gZnJvbSAnQGNsb3VkYmFzZS91dGlsaXRpZXMvZGlzdC9janMvbGlicy91dGlsJ1xuZXhwb3J0IHsgRVJST1JTLCBDT01NVU5JVFlfU0lURV9VUkwgfSBmcm9tICdAY2xvdWRiYXNlL3V0aWxpdGllcy9kaXN0L2Nqcy9jb25zdGFudHMnXG5leHBvcnQgeyBjYXRjaEVycm9yc0RlY29yYXRvciB9IGZyb20gJ0BjbG91ZGJhc2UvdXRpbGl0aWVzL2Rpc3QvY2pzL2hlbHBlcnMnXG5leHBvcnQgeyBDbG91ZGJhc2VFdmVudEVtaXR0ZXIgfSBmcm9tICdAY2xvdWRiYXNlL3V0aWxpdGllcy9kaXN0L2Nqcy9saWJzL2V2ZW50cydcbmV4cG9ydCB7IENsb3VkYmFzZUNhY2hlIH0gZnJvbSAnQGNsb3VkYmFzZS91dGlsaXRpZXMvZGlzdC9janMvbGlicy9jYWNoZSdcbmV4cG9ydCB7IGRlZmF1bHQgYXMgYWRhcHRlckZvcld4TXAgfSBmcm9tICdjbG91ZGJhc2UtYWRhcHRlci13eF9tcCdcbmV4cG9ydCB7IHVzZURlZmF1bHRBZGFwdGVyIH0gZnJvbSAnQGNsb3VkYmFzZS91dGlsaXRpZXMvZGlzdC9janMvYWRhcHRlcnMnXG4iXX0=
@@ -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}},105: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.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var s,a=i(n(587)),c=n(894);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(s=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t){for(var e=0,n=(0,c.isArray)(t)?t:[t];e<n.length;e++){var r=n[e],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},e.useDefaultAdapter=function(){return{adapter:a.genAdapter(),runtime:s.WEB}}},587:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var c=n(829),u=n(894),h=n(652),p=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(e,t),e.prototype.get=function(t){return this.request(i(i({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(i(i({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(i(i({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===c?(Object.keys(e).forEach((function(t){u.append(t,e[t])})),u.append("key",r),u.append("file",n),this.request(i(i({},t),{data:u,method:c}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=t.url,c=t.headers,p=void 0===c?{}:c,l=t.data,f=t.responseType,d=t.withCredentials,v=t.body,g=t.onUploadProgress,y=(0,u.formatUrl)((0,h.getProtocol)(),a,"get"===r?l:{}),m=new XMLHttpRequest;m.open(r,y),f&&(m.responseType=f),Object.keys(p).forEach((function(t){m.setRequestHeader(t,p[t])})),g&&m.upload.addEventListener("progress",g),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,t.statusCode=m.status;try{t.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===f?m.response:m.responseText}clearTimeout(i),o(t)}},e&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),s=(0,u.isFormData)(l)?l:"application/x-www-form-urlencoded"===p["content-type"]?(0,u.toQueryString)(l):v||(l?JSON.stringify(l):void 0),d&&(m.withCredentials=!0),m.send(s)}))},e}(c.AbstractSDKRequest);e.WebRequest=p,e.genAdapter=function(){return{root:window,reqClass:p,wsClass:WebSocket,localStorage:localStorage}}},652:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.COMMUNITY_SITE_URL=e.IS_DEBUG_MODE=e.getProtocol=e.setProtocol=e.getSdkName=e.setSdkName=void 0;var n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},151:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS=void 0,e.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},141:function(t,e,n){var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(652),e),o(n(151),e),e.OATUH_LOGINTYPE="constants"},64:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(894),s=n(141),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var c=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function h(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),c=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),h=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),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,v=p.methodName||e,g=a.value,y=function(t){var e="",n=t.stack.split("\n"),r=n.findIndex((function(t){return c.test(t)}));if(-1!==r){var o=u.exec(n[r+1]||"");e=o?o[0]:""}return e}(new Error);a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=h({err:new Error,className:f,methodName:v,sourceLink:y});try{return g.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,c={title:l||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);c.subtitle=o,u.code&&(n?(n.code=u.code,n.msg=u.msg):(t.code=u.code,t.message=u.msg),r=n||t,c.content=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:v,sourceLink:y}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,g.apply(this,t)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,s=n.message,a=n.error,c=n.error_description,u={title:l||"".concat(f,".").concat(v," 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:()=>k,LoginState:()=>C,generateAuthInstance:()=>x,registerAuth:()=>j});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),v={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()}},g=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:g,localStorage:v,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=r(105),b=function(){return(b=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},I=function(t,e,n,r){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())}))},w=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 w(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return I(this,void 0,void 0,(function(){return w(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return I(this,void 0,void 0,(function(){return w(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}(),S=/^[^:]+:\/\/[^/]+(\/[^?#]+)/;function O(t){return function(e,n){var r;return I(this,void 0,void 0,(function(){var o;return w(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 S.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 A=function(){return(A=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)},P=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},E=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},U=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())}))},L=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])}}},R="loginStateChanged",M=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 U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){var t,e,n,r;return L(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 U(this,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(A({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(A({},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 U(this,void 0,void 0,(function(){var e;return L(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 U(this,void 0,void 0,(function(){var e;return L(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()},P([(0,s.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"update",null),P([(0,s.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[String,String]),E("design:returntype",void 0)],t.prototype,"updatePassword",null),P([(0,s.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",void 0)],t.prototype,"updateUsername",null),P([(0,s.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"refresh",null),t}(),C=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 U(this,void 0,void 0,(function(){return L(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}(),k=function(){function t(t){this.config=t,this.cache=t.cache,this.oauthInstance=t.oauthInstance}return t.prototype.bindPhoneNumber=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},t.prototype.unbindProvider=function(t){return U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},t.prototype.getVerification=function(t){return U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){var t;return L(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={}),U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){var t,e,r=this;return L(this,(function(o){switch(o.label){case 0:if(!y.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return U(r,void 0,void 0,(function(){var r,o;return L(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},[4,new Promise((function(t,n){wx.login({success:function(o){return U(r,void 0,void 0,(function(){var r;return L(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})}))];case 1:return o.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithUnionId=function(){return U(this,void 0,void 0,(function(){var t=this;return L(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 U(t,void 0,void 0,(function(){var t,i,s,a,c;return L(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 U(this,void 0,void 0,(function(){var t,e,r,o,i;return L(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?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,c=void 0===a?void 0:a;return U(this,void 0,void 0,(function(){var t,e,r,i,a;return L(this,(function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:n.verification_id,verification_code:o})];case 1:if(null==(t=u.sent())?void 0:t.error_code)throw t;return e=t.verification_token,n.is_user?[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 U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},t.prototype.isUsernameRegistered=function(t){return U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){var t;return L(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(),M.fire(R),[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 C({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 U(this,void 0,void 0,(function(){return L(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.getLoginState()];case 1:return t.sent()?[2,new C({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.getUserInfo(t)]}))}))},t.prototype.getWedaUserInfo=function(){return U(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(t){return U(this,void 0,void 0,(function(){var e;return L(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 U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},t.prototype.queryUser=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},t.prototype.getAccessToken=function(){return U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},t.prototype.patchProviderToken=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},t.prototype.signInWithProvider=function(t){return U(this,void 0,void 0,(function(){return L(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={}),U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},t.prototype.resetPassword=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},t.prototype.deviceAuthorize=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},t.prototype.sudo=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},t.prototype.deleteMe=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},t.prototype.getProviders=function(){return U(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return U(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return U(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(t){return U(this,void 0,void 0,(function(){var e,n=this;return L(this,(function(r){switch(r.label){case 0:return M.on(R,(function(){return U(n,void 0,void 0,(function(){var e;return L(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 U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},t.prototype.getCredentials=function(){return U(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(t){return U(this,void 0,void 0,(function(){return L(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 U(this,void 0,void 0,(function(){return L(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},t.prototype.verifyCaptchaData=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},t.prototype.getMiniProgramQrCode=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},t.prototype.modifyPassword=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},t.prototype.getUserBehaviorLog=function(t){return U(this,void 0,void 0,(function(){return L(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},t.prototype.createLoginState=function(t){return U(this,void 0,void 0,(function(){var e;return L(this,(function(n){switch(n.label){case 0:return[4,(e=new C({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(),M.fire(R),[2,e]}}))}))},P([(0,s.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),P([(0,s.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"unbindProvider",null),P([(0,s.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",void 0)],t.prototype,"bindEmail",null),P([(0,s.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"verify",null),P([(0,s.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"getVerification",null),P([(0,s.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],t.prototype,"getCurrentUser",null),P([(0,s.catchErrorsDecorator)({title:"匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymously() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"signInAnonymously",null),P([(0,s.catchErrorsDecorator)({title:"小程序openId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().signInWithOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"signInWithOpenId",null),P([(0,s.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],t.prototype,"signInWithUnionId",null),P([(0,s.catchErrorsDecorator)({title:"小程序手机号授权登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序手机号授权登录"," 2 - 调用 auth().signInWithPhoneAuth() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"signInWithPhoneAuth",null),P([(0,s.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"signInWithSms",null),P([(0,s.catchErrorsDecorator)({title:"自定义登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了自定义登录"," 2 - 调用 auth().signInWithCustomTicket() 的语法或参数是否正确"," 3 - ticket 是否归属于当前环境"," 4 - 创建 ticket 的自定义登录私钥是否过期","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"signInWithCustomTicket",null),P([(0,s.catchErrorsDecorator)({title:"注册失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了指定登录方式"," 2 - 调用 auth().signUp() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"signUp",null),P([(0,s.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[String]),E("design:returntype",Promise)],t.prototype,"isUsernameRegistered",null),P([(0,s.catchErrorsDecorator)({title:"用户登出失败",messages:["请确认以下各项:"," 1 - 调用 auth().signOut() 的语法或参数是否正确"," 2 - 当前用户是否为匿名登录(匿名登录不支持signOut)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],t.prototype,"signOut",null),P([(0,s.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],t.prototype,"getLoginState",null),P([(0,s.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"getUserInfo",null),P([(0,s.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],t.prototype,"getWedaUserInfo",null),P([(0,s.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[Object]),E("design:returntype",Promise)],t.prototype,"bindWithProvider",null),P([(0,s.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(i.COMMUNITY_SITE_URL)]}),E("design:type",Function),E("design:paramtypes",[]),E("design:returntype",Promise)],t.prototype,"getProviderSubType",null),t}();function x(t,n){var r=t.region,o=void 0===r?"ap-shanghai":r,i=(null==n?void 0:n.platform)||(0,m.useDefaultAdapter)(),s=i.runtime,a=n||{},u=a.env,h=a.clientId,p=a.debug,l=a.cache,f=a.app,d=(n||{}).apiOrigin;d||(d="https://".concat(u,".").concat(o,".tcb-api.tencentcloudapi.com"));var v=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=O(i)}return b(b({},t),e)}catch(t){console.error("adapter generate fail:",t)}return t}({env:u,clientId:h,apiOrigin:d,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 k({env:u,region:o,persistence:t.persistence,debug:p,cache:l||new c.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(u)},platformInfo:i}),runtime:s||"web",_fromApp:f,oauthInstance:v}),oauthInstance:v}}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=x(A(A({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 j(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.6.3-beta.0",
3
+ "version": "2.6.5-beta.0",
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,9 +31,15 @@
28
31
  "author": "",
29
32
  "license": "Apache-2.0",
30
33
  "dependencies": {
31
- "@cloudbase/oauth": "^2.6.3-beta.0",
32
- "@cloudbase/types": "^2.6.3-beta.0",
33
- "@cloudbase/utilities": "^2.6.3-beta.0"
34
+ "@cloudbase/oauth": "^2.6.5-beta.0",
35
+ "@cloudbase/utilities": "^2.6.5-beta.0",
36
+ "cloudbase-adapter-wx_mp": "0.2.0"
34
37
  },
35
- "gitHead": "6cd55ade54a1525b59471b4bfd3d774fa73bea6f"
38
+ "devDependencies": {
39
+ "@cloudbase/types": "^2.6.5-beta.0",
40
+ "@types/node": "^22.1.0",
41
+ "terser-webpack-plugin": "^3.0.2",
42
+ "webpack-bundle-analyzer": "^4.9.1"
43
+ },
44
+ "gitHead": "4ac2c506df81bc571076df750ca45da7b618db00"
36
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,23 +1,27 @@
1
- import { ICloudbase } from '@cloudbase/types'
2
- import { utils, constants, helpers, events } from '@cloudbase/utilities'
3
- import { ICloudbaseCache } from '@cloudbase/types/cache'
4
- import { ICloudbaseRequest } from '@cloudbase/types/request'
5
- import { ICloudbaseAuthConfig, IUser, IUserInfo, ILoginState } from '@cloudbase/types/auth'
6
- import { ICloudbaseComponent } from '@cloudbase/types/component'
7
-
8
- import { authModels, CloudbaseOAuth, AuthOptions, Credentials } from '@cloudbase/oauth'
9
- import { GrantProviderTokenResponse, ProviderSubType } from '@cloudbase/oauth/dist/cjs/auth/models'
1
+ import type { ICloudbase, ICloudbaseConfig } from '@cloudbase/types'
2
+ import type { ICloudbaseCache } from '@cloudbase/types/cache'
3
+ import type { ICloudbaseRequest } from '@cloudbase/types/request'
4
+ import type { ICloudbaseAuthConfig, IUser, IUserInfo, ILoginState } from '@cloudbase/types/auth'
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'
8
+ import { CloudbaseOAuth } from '@cloudbase/oauth'
10
9
  import { useAuthAdapter } from './adapter'
11
- import adapterForWxMp from 'cloudbase-adapter-wx_mp'
10
+ import {
11
+ printWarn,
12
+ throwError,
13
+ ERRORS,
14
+ COMMUNITY_SITE_URL,
15
+ catchErrorsDecorator,
16
+ CloudbaseEventEmitter,
17
+ CloudbaseCache,
18
+ adapterForWxMp,
19
+ useDefaultAdapter,
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
-
21
25
  const COMPONENT_NAME = 'auth'
22
26
 
23
27
  const EVENTS = {
@@ -306,7 +310,7 @@ class Auth {
306
310
  ],
307
311
  })
308
312
  public async bindPhoneNumber(params: authModels.BindPhoneRequest) {
309
- return this.oauthInstance.authApi.bindPhone(params)
313
+ return this.oauthInstance.authApi.editContact(params)
310
314
  }
311
315
 
312
316
  /**
@@ -342,7 +346,7 @@ class Auth {
342
346
  ],
343
347
  })
344
348
  public bindEmail(params: authModels.BindEmailRequest) {
345
- return this.oauthInstance.authApi.bindEmail(params)
349
+ return this.oauthInstance.authApi.editContact(params)
346
350
  }
347
351
 
348
352
  /**
@@ -463,29 +467,32 @@ class Auth {
463
467
  if (!adapterForWxMp.isMatch()) {
464
468
  throw Error('wx api undefined')
465
469
  }
470
+ const wxInfo = wx.getAccountInfoSync().miniProgram
466
471
 
467
- if (useWxCloud) {
468
- const wxInfo = wx.getAccountInfoSync().miniProgram
472
+ const mainFunc = async (code) => {
469
473
  let result: GrantProviderTokenResponse | undefined = undefined
470
474
  let credentials: Credentials | undefined = undefined
475
+
471
476
  try {
472
477
  result = await this.oauthInstance.authApi.grantProviderToken(
473
478
  {
474
479
  provider_id: wxInfo?.appId,
480
+ provider_code: code,
475
481
  provider_params: {
476
482
  provider_code_type: 'open_id',
483
+ appid: wxInfo?.appId,
477
484
  },
478
485
  },
479
- true,
486
+ useWxCloud,
480
487
  )
481
488
 
482
- if ((result as any)?.error_code) {
489
+ if ((result as any)?.error_code || !result.provider_token) {
483
490
  throw result
484
491
  }
485
492
 
486
493
  credentials = await this.oauthInstance.authApi.signInWithProvider(
487
494
  { provider_token: result.provider_token },
488
- true,
495
+ useWxCloud,
489
496
  )
490
497
 
491
498
  if ((credentials as any)?.error_code) {
@@ -494,53 +501,26 @@ class Auth {
494
501
  } catch (error) {
495
502
  throw error
496
503
  }
497
-
498
504
  await this.oauthInstance.oauth2client.setCredentials(credentials as Credentials)
499
- } else {
500
- await new Promise((resolve, reject) => {
501
- const wxInfo = wx.getAccountInfoSync().miniProgram
502
- wx.login({
503
- success: async (res: { code: string }) => {
504
- const providerId = wxInfo?.appId
505
- try {
506
- const result = await this.oauthInstance.authApi.grantProviderToken({
507
- provider_code: res.code,
508
- provider_id: providerId,
509
- provider_params: {
510
- provider_code_type: 'open_id',
511
- appid: wxInfo?.appId,
512
- },
513
- })
514
-
515
- const { provider_token: providerToken } = result
516
-
517
- if (!providerToken) {
518
- reject(result)
519
- return
520
- }
521
-
522
- const signInRes = await this.oauthInstance.authApi.signInWithProvider({
523
- provider_token: providerToken,
524
- })
525
-
526
- if ((signInRes as any)?.error_code) {
527
- reject(signInRes)
528
- return
529
- }
505
+ }
530
506
 
531
- resolve(true)
532
- } catch (error) {
533
- reject(error)
534
- }
535
- },
536
- fail: (res: any) => {
537
- const error = new Error(res?.errMsg)
538
- ;(error as any).code = res?.errno
507
+ await new Promise((resolve, reject) => {
508
+ wx.login({
509
+ success: async (res: { code: string }) => {
510
+ try {
511
+ await mainFunc(res.code)
512
+ resolve(true)
513
+ } catch (error) {
539
514
  reject(error)
540
- },
541
- })
515
+ }
516
+ },
517
+ fail: (res: any) => {
518
+ const error = new Error(res?.errMsg)
519
+ ;(error as any).code = res?.errno
520
+ reject(error)
521
+ },
542
522
  })
543
- }
523
+ })
544
524
 
545
525
  return this.createLoginState()
546
526
  }
@@ -679,7 +659,7 @@ class Auth {
679
659
  * @memberof Auth
680
660
  */
681
661
  @catchErrorsDecorator({
682
- title: '小程序短信验证码登陆',
662
+ title: '短信验证码登陆',
683
663
  messages: [
684
664
  '请确认以下各项:',
685
665
  ' 1 - 当前环境是否开启了小程序短信验证码登陆',
@@ -688,7 +668,7 @@ class Auth {
688
668
  ],
689
669
  })
690
670
  public async signInWithSms({
691
- verificationInfo = { id: '', isUser: false },
671
+ verificationInfo = { verification_id: '', is_user: false },
692
672
  verificationCode = '',
693
673
  phoneNum = '',
694
674
  bindInfo = undefined,
@@ -696,7 +676,7 @@ class Auth {
696
676
  try {
697
677
  // 1. 验证验证码
698
678
  const verifyRes = await this.oauthInstance.authApi.verify({
699
- verification_id: verificationInfo.id,
679
+ verification_id: verificationInfo.verification_id,
700
680
  verification_code: verificationCode,
701
681
  })
702
682
 
@@ -707,7 +687,7 @@ class Auth {
707
687
  const { verification_token } = verifyRes
708
688
 
709
689
  // 2. 根据是否已经是用户,分别走登录或注册逻辑
710
- if (verificationInfo.isUser) {
690
+ if (verificationInfo.is_user) {
711
691
  // 私有化环境或者自定义应用走v1版本的老逻辑
712
692
  const signInRes = await this.oauthInstance.authApi.signIn({
713
693
  username: `+86 ${phoneNum}`,
@@ -1069,6 +1049,12 @@ class Auth {
1069
1049
  public async getCredentials(): Promise<Credentials> {
1070
1050
  return this.oauthInstance.authApi.getCredentials()
1071
1051
  }
1052
+ /**
1053
+ * 写入身份信息
1054
+ */
1055
+ public async setCredentials(credentials: Credentials) {
1056
+ await this.oauthInstance.oauth2client.setCredentials(credentials)
1057
+ }
1072
1058
 
1073
1059
  @catchErrorsDecorator({
1074
1060
  title: '获取身份源类型',
@@ -1095,7 +1081,15 @@ class Auth {
1095
1081
  }
1096
1082
 
1097
1083
  public async getMiniProgramQrCodeStatus(params: authModels.GetMiniProgramQrCodeStatusRequest,): Promise<authModels.GetMiniProgramQrCodeStatusResponse> {
1098
- return this.oauthInstance.authApi.checkMiniProgramCode(params)
1084
+ return this.oauthInstance.authApi.getMiniProgramQrCodeStatus(params)
1085
+ }
1086
+
1087
+ public async modifyPassword(params: authModels.ModifyUserBasicInfoRequest): Promise<void> {
1088
+ return this.oauthInstance.authApi.modifyPassword(params)
1089
+ }
1090
+
1091
+ public async getUserBehaviorLog(params: authModels.GetUserBehaviorLog): Promise<authModels.GetUserBehaviorLogRes> {
1092
+ return this.oauthInstance.authApi.getUserBehaviorLog(params)
1099
1093
  }
1100
1094
 
1101
1095
  private async createLoginState(params?: { version?: string; query?: any }): Promise<LoginState> {
@@ -1112,10 +1106,66 @@ class Auth {
1112
1106
  }
1113
1107
  }
1114
1108
 
1109
+ type TInitAuthOptions = Pick<ICloudbaseAuthConfig, 'region' | 'persistence'> & Partial<AuthOptions>
1110
+
1111
+ export function generateAuthInstance(
1112
+ config: TInitAuthOptions,
1113
+ options?: {
1114
+ clientId: ICloudbaseConfig['clientId']
1115
+ env: ICloudbaseConfig['env']
1116
+ apiOrigin: string
1117
+ cache?: ICloudbaseCache
1118
+ platform?: ICloudbase['platform']
1119
+ app?: ICloudbase
1120
+ debug?: ICloudbaseAuthConfig['debug']
1121
+ },
1122
+ ) {
1123
+ const { region = 'ap-shanghai' } = config
1124
+ const platform = options?.platform || useDefaultAdapter()
1125
+ const { runtime } = platform
1126
+
1127
+ const { env, clientId, debug, cache, app: cloudbase } = options || {}
1128
+ let { apiOrigin } = options || {}
1129
+ if (!apiOrigin) {
1130
+ apiOrigin = `https://${env}.${region}.tcb-api.tencentcloudapi.com`
1131
+ }
1132
+ const oauthInstance = new CloudbaseOAuth(useAuthAdapter({
1133
+ env,
1134
+ clientId,
1135
+ apiOrigin,
1136
+ // @todo 以下最好走adaptor处理,目前oauth模块没按adaptor接口设计
1137
+ storage: config?.storage,
1138
+ baseRequest: config?.baseRequest,
1139
+ request: config?.request,
1140
+ anonymousSignInFunc: config?.anonymousSignInFunc,
1141
+ captchaOptions: config?.captchaOptions,
1142
+ wxCloud: config?.wxCloud,
1143
+ }),)
1144
+
1145
+ const authInstance = new Auth({
1146
+ env,
1147
+ region,
1148
+ persistence: config.persistence,
1149
+ debug,
1150
+ cache:
1151
+ cache
1152
+ || new CloudbaseCache({
1153
+ persistence: config.persistence,
1154
+ keys: { userInfoKey: `user_info_${env}` },
1155
+ platformInfo: platform,
1156
+ }),
1157
+ runtime: runtime || 'web',
1158
+ _fromApp: cloudbase,
1159
+ oauthInstance,
1160
+ })
1161
+
1162
+ return { authInstance, oauthInstance }
1163
+ }
1164
+
1115
1165
  const component: ICloudbaseComponent = {
1116
1166
  name: COMPONENT_NAME,
1117
1167
  namespace: 'auth',
1118
- entity(config: Pick<ICloudbaseAuthConfig, 'region' | 'persistence'> & Partial<AuthOptions> = {
1168
+ entity(config: TInitAuthOptions = {
1119
1169
  region: '',
1120
1170
  persistence: 'local',
1121
1171
  },) {
@@ -1123,41 +1173,34 @@ const component: ICloudbaseComponent = {
1123
1173
  printWarn(ERRORS.INVALID_OPERATION, 'every cloudbase instance should has only one auth object')
1124
1174
  return this.authInstance
1125
1175
  }
1126
- const { adapter, runtime } = this.platform
1176
+ const { adapter } = this.platform
1127
1177
  // 如不明确指定persistence则优先取各平台adapter首选,其次localStorage
1128
1178
  const newPersistence = config.persistence || adapter.primaryStorage
1129
1179
  if (newPersistence && newPersistence !== this.config.persistence) {
1130
1180
  this.updateConfig({ persistence: newPersistence })
1131
1181
  }
1132
1182
 
1133
- const { env, persistence, debug, clientId, storage, wxCloud } = this.config
1134
- const oauthInstance = new CloudbaseOAuth(useAuthAdapter({
1135
- env,
1136
- clientId,
1137
- apiOrigin: this.request.getBaseEndPoint(),
1138
- // @todo 以下最好走adaptor处理,目前oauth模块没按adaptor接口设计
1139
- storage: config?.storage || storage,
1140
- baseRequest: config?.baseRequest,
1141
- request: config?.request,
1142
- anonymousSignInFunc: config?.anonymousSignInFunc,
1143
- captchaOptions: config?.captchaOptions,
1144
- wxCloud: config?.wxCloud || wxCloud,
1145
- }),)
1183
+ const { authInstance, oauthInstance } = generateAuthInstance(
1184
+ {
1185
+ wxCloud: this.config.wxCloud,
1186
+ storage: this.config.storage,
1187
+ ...config,
1188
+ persistence: this.config.persistence,
1189
+ },
1190
+ {
1191
+ env: this.config.env,
1192
+ clientId: this.config.clientId,
1193
+ apiOrigin: this.request.getBaseEndPoint(),
1194
+ platform: this.platform,
1195
+ cache: this.cache,
1196
+ app: this,
1197
+ debug: this.config.debug,
1198
+ },
1199
+ )
1146
1200
 
1147
1201
  this.oauthInstance = oauthInstance
1148
1202
 
1149
- this.authInstance = new Auth({
1150
- env,
1151
- region: config.region,
1152
- persistence,
1153
- debug,
1154
- cache: this.cache,
1155
- // request: this.request,
1156
- runtime,
1157
- _fromApp: this,
1158
- // oauthInstance: this.oauthInstance || (this as any).oauth()
1159
- oauthInstance,
1160
- })
1203
+ this.authInstance = authInstance
1161
1204
 
1162
1205
  return this.authInstance
1163
1206
  },
@@ -0,0 +1,8 @@
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'
8
+ export { useDefaultAdapter } from '@cloudbase/utilities/dist/cjs/adapters'