diff --git a/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-jsencrypt/index.js b/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-jsencrypt/index.js index e4d16469..8f2a097e 100644 --- a/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-jsencrypt/index.js +++ b/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-jsencrypt/index.js @@ -4,7 +4,7 @@ var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexport 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__(1678692122197, function(require, module, exports) { +__DEFINE__(1682418705264, function(require, module, exports) { var __TEMP__ = require('./jsencrypt');var JSEncrypt = __TEMP__['JSEncrypt']; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });function encryptFunction (plainText, publicKey) { @@ -17,8 +17,8 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t return encStr.toString() };exports.encryptFunction = encryptFunction -}, function(modId) {var map = {"./jsencrypt":1678692122198}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1678692122198, function(require, module, exports) { +}, function(modId) {var map = {"./jsencrypt":1682418705265}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1682418705265, function(require, module, exports) { var window = {} ; (function (global, factory) { typeof exports === "object" && typeof module !== "undefined" @@ -5645,7 +5645,7 @@ var window = {} Object.defineProperty(exports, "__esModule", { value: true }) }) }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -return __REQUIRE__(1678692122197); +return __REQUIRE__(1682418705264); })() //miniprogram-npm-outsideDeps=[] //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-sm2encrypt/index.js b/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-sm2encrypt/index.js index 92ca57cc..ee4e3962 100644 --- a/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-sm2encrypt/index.js +++ b/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-sm2encrypt/index.js @@ -4,15 +4,15 @@ var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexport 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__(1678692122199, function(require, module, exports) { +__DEFINE__(1682418705266, function(require, module, exports) { var __TEMP__ = require('./sm2');var doEncrypt = __TEMP__['doEncrypt']; if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });function encryptFunction (plainText, publicKey) { return doEncrypt(plainText, publicKey) };exports.encryptFunction = encryptFunction -}, function(modId) {var map = {"./sm2":1678692122200}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1678692122200, function(require, module, exports) { +}, function(modId) {var map = {"./sm2":1682418705267}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1682418705267, function(require, module, exports) { /* eslint-disable no-use-before-define */ var __TEMP__ = require('jsbn');var BigInteger = __TEMP__['BigInteger']; var __TEMP__ = require('./utils');var _ = __REQUIRE_WILDCARD__(__TEMP__); @@ -71,8 +71,8 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t -}, function(modId) { var map = {"./utils":1678692122201,"./sm3":1678692122203}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1678692122201, function(require, module, exports) { +}, function(modId) { var map = {"./utils":1682418705268,"./sm3":1682418705270}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1682418705268, function(require, module, exports) { /* eslint-disable no-bitwise, no-mixed-operators, no-use-before-define, max-len */ var __TEMP__ = require('jsbn');var BigInteger = __TEMP__['BigInteger'];var SecureRandom = __TEMP__['SecureRandom']; var __TEMP__ = require('./ec');var ECCurveFp = __TEMP__['ECCurveFp']; @@ -268,8 +268,8 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t -}, function(modId) { var map = {"./ec":1678692122202}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1678692122202, function(require, module, exports) { +}, function(modId) { var map = {"./ec":1682418705269}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1682418705269, function(require, module, exports) { /* eslint-disable no-case-declarations, max-len */ var __TEMP__ = require('jsbn');var BigInteger = __TEMP__['BigInteger']; @@ -604,7 +604,7 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1678692122203, function(require, module, exports) { +__DEFINE__(1682418705270, function(require, module, exports) { /** * 循环左移 */ @@ -851,7 +851,7 @@ if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: t }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); }) -return __REQUIRE__(1678692122199); +return __REQUIRE__(1682418705266); })() //miniprogram-npm-outsideDeps=["jsbn"] //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-wx/index.js b/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-wx/index.js index 95c6b323..9eeb354b 100644 --- a/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-wx/index.js +++ b/examples/miniapp-wx/miniapp/miniprogram_npm/@authing/miniapp-wx/index.js @@ -4,10 +4,10 @@ var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexport 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__(1678692122204, 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:()=>T,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 T(e={}){return _.chooseMedia(e)}const P=l();function k(e={}){return P.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.5-alpha.1"}');var A,j=function(){return j=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]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]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(z(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(z(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()-72e5}),[4,this.storage.set(z(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($(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($(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($(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,o;return U(this,void 0,void 0,(function(){var r,i,a,u;return W(this,(function(c){switch(c.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(null===(o=e.options)||void 0===o?void 0:o.passwordEncryptType)]:[2,s({message:'encryptFunction is required, if passwordEncryptType is not "none"'})]:[3,2];case 1:if(r=M.apply(void 0,[c.sent(),2]),i=r[0],a=r[1],i)return[2,s(i)];e.passwordPayload.password=this.encryptFunction(e.passwordPayload.password,a),c.label=2;case 2:return u=F(F({},e),{connection:"PASSWORD"}),[4,this.login(u,"password")];case 3:return[2,c.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{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:()=>T,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 T(e={}){return _.chooseMedia(e)}const P=l();function k(e={}){return P.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.6-alpha.0"}');var A,j=function(){return j=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]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]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(z(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(z(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(z(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($(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($(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($(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,o;return U(this,void 0,void 0,(function(){var r,i,a,u;return W(this,(function(c){switch(c.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(null===(o=e.options)||void 0===o?void 0:o.passwordEncryptType)]:[2,s({message:'encryptFunction is required, if passwordEncryptType is not "none"'})]:[3,2];case 1:if(r=M.apply(void 0,[c.sent(),2]),i=r[0],a=r[1],i)return[2,s(i)];e.passwordPayload.password=this.encryptFunction(e.passwordPayload.password,a),c.label=2;case 2:return u=F(F({},e),{connection:"PASSWORD"}),[4,this.login(u,"password")];case 3:return[2,c.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{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:()=>T,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 T(e={}){return _.chooseMedia(e)}const P=l();function k(e={}){return P.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.5-alpha.1\"}');var A,j=function(){return j=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]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]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(z(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(z(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()-72e5}),[4,this.storage.set(z(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($(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($(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($(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,o;return U(this,void 0,void 0,(function(){var r,i,a,u;return W(this,(function(c){switch(c.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(null===(o=e.options)||void 0===o?void 0:o.passwordEncryptType)]:[2,s({message:'encryptFunction is required, if passwordEncryptType is not \"none\"'})]:[3,2];case 1:if(r=M.apply(void 0,[c.sent(),2]),i=r[0],a=r[1],i)return[2,s(i)];e.passwordPayload.password=this.encryptFunction(e.passwordPayload.password,a),c.label=2;case 2:return u=F(F({},e),{connection:\"PASSWORD\"}),[4,this.login(u,\"password\")];case 3:return[2,c.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{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:()=>T,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 T(e={}){return _.chooseMedia(e)}const P=l();function k(e={}){return P.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.6-alpha.0\"}');var A,j=function(){return j=Object.assign||function(e){for(var t,n=1,o=arguments.length;n0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]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]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(z(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(z(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(z(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($(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($(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($(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,o;return U(this,void 0,void 0,(function(){var r,i,a,u;return W(this,(function(c){switch(c.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(null===(o=e.options)||void 0===o?void 0:o.passwordEncryptType)]:[2,s({message:'encryptFunction is required, if passwordEncryptType is not \"none\"'})]:[3,2];case 1:if(r=M.apply(void 0,[c.sent(),2]),i=r[0],a=r[1],i)return[2,s(i)];e.passwordPayload.password=this.encryptFunction(e.passwordPayload.password,a),c.label=2;case 2:return u=F(F({},e),{connection:\"PASSWORD\"}),[4,this.login(u,\"password\")];case 3:return[2,c.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 { const _loginState: LoginState = { ...loginState, - expires_at: loginState.expires_in * 1000 + Date.now() - 3600 * 1000 * 2 + expires_at: loginState.expires_in * 1000 + Date.now() } await this.storage.set( diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index 6d536490..e0c8b1e0 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/web", - "version": "5.1.5", + "version": "5.1.6-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/web", - "version": "5.1.5", + "version": "5.1.6-alpha.0", "license": "MIT", "dependencies": { "axios": "^0.26.1" diff --git a/packages/web/package.json b/packages/web/package.json index f8be77cd..1f72bb58 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@authing/web", - "version": "5.1.5", + "version": "5.1.6-alpha.0", "description": "Official SDK of Authing for Browser", "main": "dist/global/index.global.js", "module": "dist/esm/index.esm.js", diff --git a/packages/weixin-official-account/package-lock.json b/packages/weixin-official-account/package-lock.json index 6b62c0b0..9244e168 100644 --- a/packages/weixin-official-account/package-lock.json +++ b/packages/weixin-official-account/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/weixin-official-account", - "version": "5.1.5", + "version": "5.1.6-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/weixin-official-account", - "version": "5.1.5", + "version": "5.1.6-alpha.0", "license": "MIT" } } diff --git a/packages/weixin-official-account/package.json b/packages/weixin-official-account/package.json index 270f1658..7603eb75 100644 --- a/packages/weixin-official-account/package.json +++ b/packages/weixin-official-account/package.json @@ -1,6 +1,6 @@ { "name": "@authing/weixin-official-account", - "version": "5.1.5", + "version": "5.1.6-alpha.0", "description": "Authing SDK for Weixin official account", "module": "dist/esm/weixin-official-account.min.js", "types": "dist/typings/index.d.ts",