module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1689906741546, function(require, module, exports) {
var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.d(t,{e:()=>J});var n={};function o(){}e.r(n),e.d(n,{checkSession:()=>I,chooseImage:()=>P,clearStorage:()=>S,getStorage:()=>x,getUserProfile:()=>C,login:()=>d,removeStorage:()=>b,request:()=>g,scanCode:()=>y,setStorage:()=>m,uploadFile:()=>k}),function(e){!function(e){e.use=function(e,t={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(e)>-1)return this;const o=[t];return o.unshift(this),"function"==typeof e.install?e.install.apply(e,o):"function"==typeof e&&e.apply(null,o),n.push(e),this}}(e)}(o);const r=o;function i(e){return[null,e]}function s(e){return[e,void 0]}function a(){return["wx","ali","baidu","qq","tt","jd","ks","qa_webview","qa_ux","Mpx","Taro","uni"].reduce(((e,t)=>(e[`__authing_move_src_mode_${t}__`]=t,e)),{})}function u(e){console.error&&console.error(`[AuthingMove/api-proxy error in "wx"]:\n ${e}`)}function c(){}function p(e,t={},n={}){let o={};return Object.keys(e).forEach((n=>{const r=t.hasOwnProperty(n)?t[n]:n;r&&(o[r]=e[n])})),o=Object.assign({},o,n),o}function l(){return wx}const h=l();function d(e={}){return h.login(e)}const f=l();function g(e={}){return f.request(e)}const v=l();function y(e={}){return v.scanCode(e)}const w=l();function m(e={}){const t=p(e,{},{encrypt:!1});return w.setStorage(t)}function x(e={}){const t=p(e,{},{encrypt:!1});return w.getStorage(t)}function b(e={}){return w.removeStorage(e)}function S(e={}){return w.clearStorage(e)}const _=l();function P(e={}){return _.chooseMedia(e)}const T=l();function k(e={}){return T.uploadFile(e)}const E=l();function C(e={}){return E.getUserProfile(e)}const O=l();function I(e={}){return O.checkSession(e)}const D=a();const L=l();r.use((function(e,t={}){const{custom:o={}}=t,r=function(e){const t=l(),o=Object.create(null);Object.keys(n).forEach((e=>{o[e]=t[e]||n[e]}));const r=Object.create(null);return Object.keys(o).forEach((i=>{"function"==typeof o[i]?r[i]=(...o)=>{let r=e.from;const s=e.to;o.length&&(r=o.pop(),"string"==typeof r&&D[r]||(o.push(r),r=e.from));const a=function(e="",t=""){return`${D[`__authing_move_src_mode_${e}__`]}_${t}`}(r,s);return e.custom[a]&&e.custom[a][i]?e.custom[a][i].apply(this,o):n[i]?n[i].apply(this,o):t[i]?t[i].apply(this,o):void u(`"${i}" method does not exist in the current context`)}:r[i]=o[i]})),r}({from:"wx",to:"wx",custom:o}),i=Object.assign({},r,function(e){const t=a();return Object.keys(e).reduce(((n,o)=>("function"!=typeof e[o]||(n[o]=function(...n){if(function(e){return/^get\w*Manager$/.test(e)||/^create\w*Context$/.test(e)||/^(on|off)/.test(e)||/\w+Sync$/.test(e)}(o))return e[o].apply(e,n);n[0]&&!t[n[0]]||n.unshift({success:c,fail:c});const r=n[0];let i;const s=new Promise(((t,s)=>{const a=r.success,u=r.fail;r.success=function(e){a&&a.call(this,e),t(e)},r.fail=function(e){u&&u.call(this,e),s(e)},i=e[o].apply(L,n)}));return s.__returned=i,s}),n)),{})}(r));Object.keys(i).forEach((t=>{try{if("function"!=typeof i[t])return void(e[t]=i[t]);e[t]=(...n)=>i[t].apply(e,n)}catch(n){u(`Call ${e}.${t} error:`+JSON.stringify(n))}}))}));var R=function(){function e(){}return e.prototype.get=function(e){return r.getStorage({key:e})},e.prototype.set=function(e,t){return r.setStorage({key:e,data:t})},e.prototype.remove=function(e){return r.removeStorage({key:e})},e}();const N=JSON.parse('{"i8":"5.1.9-alpha.0"}');var A,j=function(){return j=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},j.apply(this,arguments)};function q(e){return t=this,n=void 0,a=function(){var t,n,o,a;return function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[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,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),t=Object.assign({},e,{header:j(j({},e.header),{"x-authing-request-from":"sdk-miniapp","x-authing-sdk-version":N.i8})}),[4,r.request(t)];case 1:switch(n=u.sent().data,o=function(e,t){for(var n=[{test:/(\/api\/v3\/system)$/,validate:function(){return!(!t.rsa&&!t.sm2)}},{test:/(\/oidc\/token)$/,validate:function(){return!(!t.access_token&&!t.id_token)}},{test:/(\/oidc\/token\/revocation)$/,validate:function(){return""===t}}],o=0;o<n.length;o++){var r=e.match(n[o].test);if(r&&r[0])return n[o].validate()?A.INTERCEPTED_SUCCESS:A.INTERCEPTED_ERROR}return 200===t.statusCode?A.NOT_INTERCEPTED_SUCCESS:A.NOT_INTERCEPTED_ERROR}(e.url,n),o){case A.NOT_INTERCEPTED_SUCCESS:return[2,i(n.data||n)];case A.INTERCEPTED_SUCCESS:return[2,i(n)];default:return[2,s(n)]}return[3,3];case 2:return a=u.sent(),[2,s({message:JSON.stringify(a)})];case 3:return[2]}}))},new((o=void 0)||(o=Promise))((function(e,r){function i(e){try{u(a.next(e))}catch(e){r(e)}}function s(e){try{u(a.throw(e))}catch(e){r(e)}}function u(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(i,s)}u((a=a.apply(t,n||[])).next())}));var t,n,o,a}function $(e){return["authing",e,"login-state"].join(":")}function z(e){return["authing",e,"wx-login-code"].join(":")}!function(e){e[e.NOT_INTERCEPTED_SUCCESS=0]="NOT_INTERCEPTED_SUCCESS",e[e.NOT_INTERCEPTED_ERROR=1]="NOT_INTERCEPTED_ERROR",e[e.INTERCEPTED_SUCCESS=2]="INTERCEPTED_SUCCESS",e[e.INTERCEPTED_ERROR=3]="INTERCEPTED_ERROR"}(A||(A={}));var F=function(){return F=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},F.apply(this,arguments)},U=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{u(o.next(e))}catch(e){i(e)}}function a(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((o=o.apply(e,t||[])).next())}))},W=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[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,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((r=(r=s.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},M=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s},J=function(){function e(e){this.options=F(F({},e),{host:e.host||"https://core.authing.cn"}),this.storage=new R,this.encryptFunction=e.encryptFunction,this.resetWxLoginCode()}return e.prototype.getLoginState=function(){return U(this,void 0,void 0,(function(){var e,t,n;return W(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.storage.get($(this.options.appId))];case 1:return e=o.sent(),(t=e.data).expires_at>Date.now()?[2,i(t)]:[2,s({message:"login state has expired, please login again"})];case 2:return n=o.sent(),[2,s({message:JSON.stringify(n)})];case 3:return[2]}}))}))},e.prototype.clearLoginState=function(){return U(this,void 0,void 0,(function(){var e;return W(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove($(this.options.appId))];case 1:return t.sent(),[2,i(!0)];case 2:return e=t.sent(),[2,s({message:JSON.stringify(e)})];case 3:return[2]}}))}))},e.prototype.saveLoginState=function(e){return U(this,void 0,void 0,(function(){var t;return W(this,(function(n){switch(n.label){case 0:return t=F(F({},e),{expires_at:1e3*e.expires_in+Date.now()}),[4,this.storage.set($(this.options.appId),t)];case 1:return n.sent(),[2,t]}}))}))},e.prototype.getPublicKey=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r;return W(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,q({method:"GET",url:this.options.host+"/api/v3/system"})];case 1:return t=M.apply(void 0,[a.sent(),2]),n=t[0],o=t[1],n?[2,s(n)]:[2,i(o[e].publicKey)];case 2:return r=a.sent(),[2,s({message:"get public key error: "+JSON.stringify(r)})];case 3:return[2]}}))}))},e.prototype.getCachedWxLoginCode=function(){return U(this,void 0,void 0,(function(){return W(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.storage.get(z(this.options.appId))];case 1:return[2,e.sent().data];case 2:return e.sent(),[2,""];case 3:return[2]}}))}))},e.prototype.cacheWxLoginCode=function(e){return U(this,void 0,void 0,(function(){return W(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.set(z(this.options.appId),e)];case 1:return t.sent(),[2,e];case 2:return t.sent(),[2,""];case 3:return[2]}}))}))},e.prototype.resetWxLoginCode=function(){return U(this,void 0,void 0,(function(){var e,t=this;return W(this,(function(n){switch(n.label){case 0:e=function(){return U(t,void 0,void 0,(function(){var e;return W(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,r.login()];case 1:return e=t.sent(),[4,this.cacheWxLoginCode(e.code)];case 2:return t.sent(),[2,!0];case 3:return t.sent(),[2,!1];case 4:return[2]}}))}))},n.label=1;case 1:return n.trys.push([1,6,8,10]),[4,r.checkSession()];case 2:return n.sent(),[4,this.getCachedWxLoginCode()];case 3:return n.sent()?[3,5]:[4,e()];case 4:n.sent(),n.label=5;case 5:return[3,10];case 6:return n.sent(),this.storage.remove(z(this.options.appId)),[4,e()];case 7:return n.sent(),[3,10];case 8:return[4,this.getCachedWxLoginCode()];case 9:return[2,n.sent()];case 10:return[2]}}))}))},e.prototype.getLoginCode=function(){return U(this,void 0,void 0,(function(){return W(this,(function(e){switch(e.label){case 0:return[4,this.resetWxLoginCode()];case 1:return[2,e.sent()]}}))}))},e.prototype.loginByCode=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),(n=t[1])&&n.expires_at>Date.now()?[2,i(n)]:(o=e.extIdpConnidentifier,r=e.connection,a=e.wechatMiniProgramCodePayload,u=e.options,[4,this.resetWxLoginCode()]);case 2:return(c=l.sent())?(p={connection:r||"wechat_mini_program_code",extIdpConnidentifier:o,wechatMiniProgramCodePayload:{encryptedData:(null==a?void 0:a.encryptedData)||"",iv:(null==a?void 0:a.iv)||"",code:c},options:u},[4,this.login(p,"code")]):[2,s({message:"get wx login code error"})];case 3:return[2,l.sent()]}}))}))},e.prototype.loginByPassword=function(e){var t,n;return U(this,void 0,void 0,(function(){var o,r,i,a;return W(this,(function(u){switch(u.label){case 0:return(null===(t=e.options)||void 0===t?void 0:t.passwordEncryptType)&&"none"!==(null===(n=e.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(e.options.passwordEncryptType)]:[2,s({message:'encryptFunction is required, if passwordEncryptType is not "none"'})]:[3,2];case 1:if(o=M.apply(void 0,[u.sent(),2]),r=o[0],i=o[1],r)return[2,s(r)];if("string"!=typeof i)return[2,s({message:"publicKey of "+e.options.passwordEncryptType+" is not a string, please contact the administrator"})];e.passwordPayload.password=this.encryptFunction(e.passwordPayload.password,i),u.label=2;case 2:return a=F(F({},e),{connection:"PASSWORD"}),[4,this.login(a,"password")];case 3:return[2,u.sent()]}}))}))},e.prototype.loginByPassCode=function(e){return U(this,void 0,void 0,(function(){var t;return W(this,(function(n){switch(n.label){case 0:return e.passCodePayload.phone&&(e.passCodePayload.phoneCountryCode=e.passCodePayload.phoneCountryCode||"+86"),t=F(F({},e),{connection:"PASSCODE"}),[4,this.login(t,"passCode")];case 1:return[2,n.sent()]}}))}))},e.prototype.loginByPhone=function(e){var t,n;return U(this,void 0,void 0,(function(){var o,r,a,u,c,p,l,h;return W(this,(function(d){switch(d.label){case 0:return[4,this.getLoginState()];case 1:return o=M.apply(void 0,[d.sent(),2]),(r=o[1])&&r.expires_at>Date.now()?[2,i(r)]:(a=e.extIdpConnidentifier,u=e.wechatMiniProgramCodeAndPhonePayload,c=e.options,(p=u.wxPhoneInfo)&&p.code?[4,this.resetWxLoginCode()]:[2,s({message:"wxPhoneInfo.code is required"})]);case 2:return(l=d.sent())?(h={connection:"wechat_mini_program_code_and_phone",extIdpConnidentifier:a,wechatMiniProgramCodeAndPhonePayload:{wxPhoneInfo:p,wxLoginInfo:{encryptedData:(null===(t=null==u?void 0:u.wxLoginInfo)||void 0===t?void 0:t.encryptedData)||"",iv:(null===(n=null==u?void 0:u.wxLoginInfo)||void 0===n?void 0:n.iv)||"",code:l}},options:c},[4,this.login(h,"phone")]):[2,s({message:"get wx login code error"})];case 3:return[2,d.sent()]}}))}))},e.prototype.logout=function(){return U(this,void 0,void 0,(function(){var e,t,n,o,r,a,u,c;return W(this,(function(p){switch(p.label){case 0:return[4,this.getLoginState()];case 1:return e=M.apply(void 0,[p.sent(),2]),t=e[0],n=e[1],t?[4,this.clearLoginState()]:[3,3];case 2:case 4:case 7:return p.sent(),[2,i(!0)];case 3:return r=(o=n).access_token,a=o.expires_at,!r||a<Date.now()?[4,this.clearLoginState()]:[3,5];case 5:return[4,q({method:"POST",url:this.options.host+"/oidc/token/revocation",data:{client_id:this.options.appId,token:r},header:{"content-type":"application/x-www-form-urlencoded"}})];case 6:return u=M.apply(void 0,[p.sent(),1]),(c=u[0])?[2,s(c)]:[4,this.clearLoginState()]}}))}))},e.prototype.sendSms=function(e){return U(this,void 0,void 0,(function(){var t,n,o;return W(this,(function(r){switch(r.label){case 0:return e.phoneCountryCode=e.phoneCountryCode||"+86",[4,q({method:"POST",url:this.options.host+"/api/v3/send-sms",data:e,header:{"x-authing-userpool-id":this.options.userPoolId}})];case 1:return t=M.apply(void 0,[r.sent(),2]),n=t[0],o=t[1],n?[2,s(n)]:[2,i(o)]}}))}))},e.prototype.sendEmailCode=function(e){return U(this,void 0,void 0,(function(){var t,n,o;return W(this,(function(r){switch(r.label){case 0:return[4,q({method:"POST",url:this.options.host+"/api/v3/send-email",data:e,header:{"x-authing-userpool-id":this.options.userPoolId}})];case 1:return t=M.apply(void 0,[r.sent(),2]),n=t[0],o=t[1],n?[2,s(n)]:[2,i(o)]}}))}))},e.prototype.login=function(e,t){return U(this,void 0,void 0,(function(){var n,o,r,a;return W(this,(function(u){switch(u.label){case 0:return n={code:"/api/v3/signin-by-mobile",phone:"/api/v3/signin-by-mobile",password:"/api/v3/signin",passCode:"/api/v3/signin"},[4,q({method:"POST",url:this.options.host+n[t],data:e,header:{"x-authing-app-id":this.options.appId}})];case 1:return o=M.apply(void 0,[u.sent(),2]),r=o[0],a=o[1],r?[2,s(r)]:a.access_token||a.id_token?[4,this.saveLoginState(a)]:[3,3];case 2:return[2,i(u.sent())];case 3:return[4,this.clearLoginState()];case 4:return u.sent(),[2,s(a)]}}))}))},e.prototype.refreshToken=function(){return U(this,void 0,void 0,(function(){var e,t,n,o,r,a,u,c,p,l;return W(this,(function(h){switch(h.label){case 0:return[4,this.getLoginState()];case 1:return e=M.apply(void 0,[h.sent(),2]),t=e[0],n=e[1],t?[2,s({message:"refresh_token has expired, please login again"})]:(r=(o=n).refresh_token,a=o.expires_at,r?a<Date.now()?[2,s({message:"refresh_token has expired, please login again"})]:(u={grant_type:"refresh_token",redirect_uri:"",refresh_token:r},[4,q({method:"POST",url:this.options.host+"/oidc/token",data:u,header:{"content-type":"application/x-www-form-urlencoded","x-authing-app-id":this.options.appId}})]):[2,s({message:"refresh_token must not be empty"})]);case 2:return c=M.apply(void 0,[h.sent(),2]),p=c[0],l=c[1],p?[2,s(p)]:[4,this.saveLoginState(l)];case 3:return[2,i(h.sent())]}}))}))},e.prototype.updatePassword=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p,l,h,d;return W(this,(function(f){switch(f.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[f.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:e.passwordEncryptType&&"none"!==e.passwordEncryptType?this.encryptFunction?[4,this.getPublicKey(e.passwordEncryptType)]:[2,s({message:'encryptFunction is required, if passwordEncryptType is not "none"'})]:[3,3]);case 2:if(u=M.apply(void 0,[f.sent(),2]),c=u[0],p=u[1],c)return[2,s(c)];e.newPassword=this.encryptFunction(e.newPassword,p),f.label=3;case 3:return[4,q({method:"POST",url:this.options.host+"/api/v3/update-password",data:e,header:{"x-authing-userpool-id":this.options.userPoolId,Authorization:a}})];case 4:return l=M.apply(void 0,[f.sent(),2]),h=l[0],d=l[1],h?[2,s(h)]:[2,i(d)]}}))}))},e.prototype.getUserInfo=function(e){return void 0===e&&(e={withCustomData:!1,withDepartmentIds:!1,withIdentities:!1}),U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"GET",url:this.options.host+"/api/v3/get-profile",header:{"x-authing-userpool-id":this.options.userPoolId,Authorization:a},data:e})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.updateAvatar=function(){return U(this,void 0,void 0,(function(){var e,t,n,o;return W(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,r.chooseImage({count:1,sourceType:["album","camera"],sizeType:["original"]})];case 1:return e=a.sent(),[4,r.uploadFile({url:this.options.host+"/api/v2/upload?folder=avatar",name:"file",filePath:e.tempFiles[0].tempFilePath})];case 2:return t=a.sent(),n=JSON.parse(t.data),[4,this.updateUserInfo({photo:n.data.url})];case 3:return a.sent(),[2,i(n)];case 4:return o=a.sent(),[2,s({message:JSON.stringify(o)})];case 5:return[2]}}))}))},e.prototype.updateUserInfo=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/update-profile",data:e,header:{"x-authing-userpool-id":this.options.userPoolId,Authorization:a}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.bindEmail=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/bind-email",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.updateEmailRequest=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/verify-update-email-request",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.updateEmail=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/update-email",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.bindPhone=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/bind-phone",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.updatePhoneRequest=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/verify-update-phone-request",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.updatePhone=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/update-phone",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.deleteAccountRequest=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/verify-delete-account-request",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.deleteAccount=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/delete-account",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e.prototype.getPhone=function(e){return U(this,void 0,void 0,(function(){var t,n,o;return W(this,(function(r){switch(r.label){case 0:return[4,q({method:"POST",url:this.options.host+"/api/v3/get-wechat-miniprogram-phone",data:e,header:{"x-authing-userpool-id":this.options.userPoolId}})];case 1:return t=M.apply(void 0,[r.sent(),2]),n=t[0],o=t[1],n?[2,s(n)]:o.phone_info?[2,i(o.phone_info)]:[2,s(o)]}}))}))},e.prototype.decryptData=function(e){return U(this,void 0,void 0,(function(){var t,n,o;return W(this,(function(r){switch(r.label){case 0:return[4,q({method:"POST",url:this.options.host+"/api/v3/decrypt-wechat-miniprogram-data",data:e,header:{"x-authing-userpool-id":this.options.userPoolId}})];case 1:return t=M.apply(void 0,[r.sent(),2]),n=t[0],o=t[1],n?[2,s(n)]:[2,i(o)]}}))}))},e.prototype.getAccessToken=function(e){return U(this,void 0,void 0,(function(){var t,n,o,r,a,u,c,p;return W(this,(function(l){switch(l.label){case 0:return[4,this.getLoginState()];case 1:return t=M.apply(void 0,[l.sent(),2]),n=t[0],o=t[1],n?[2,s({message:"Token has expired, please login again"})]:(a=(r=o).access_token,r.expires_at<Date.now()?[2,s({message:"Token has expired, please login again"})]:[4,q({method:"POST",url:this.options.host+"/api/v3/get-wechat-access-token",data:e,header:{Authorization:a,"x-authing-userpool-id":this.options.userPoolId}})]);case 2:return u=M.apply(void 0,[l.sent(),2]),c=u[0],p=u[1],c?[2,s(c)]:[2,i(p)]}}))}))},e}(),K=t.e;if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });Object.defineProperty(exports, 'Authing', { enumerable: true, configurable: true, get: function() { return K; } });
}, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1689906741546);
})()
//miniprogram-npm-outsideDeps=[]
//# sourceMappingURL=index.js.map