From 4289e372b71950dce6d4b61ea9a23506c5d02d2a Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Tue, 27 Sep 2022 20:14:26 +0800 Subject: [PATCH 01/15] feat: login by phone --- packages/miniapp/src/Authing.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/miniapp/src/Authing.ts b/packages/miniapp/src/Authing.ts index 8904466b..78adaccc 100644 --- a/packages/miniapp/src/Authing.ts +++ b/packages/miniapp/src/Authing.ts @@ -17,7 +17,8 @@ import { UpdatePasswordOptions, UploadFileResponseData, LoginByCodeOptions, - Maybe + Maybe, + LoginByPhoneOptions } from './types' import { error, getLoginStateKey, request, StorageProvider } from './helpers' @@ -128,6 +129,32 @@ export class Authing { return await this.login(_data, 'code') } + async loginByPhone( + data: LoginByPhoneOptions + ): Promise> { + const loginState = await this.getLoginState() + + if (loginState && loginState.expires_at > Date.now()) { + return loginState + } + + const { code } = await AuthingMove.login() + + const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data + + const _data: WxPhoneLoginOptions = { + connection: connection || 'wechat_mini_program_phone', + extIdpConnidentifier, + wechatMiniProgramPhonePayload: { + ...wechatMiniProgramPhonePayload, + code + }, + options + } + + return await this.login(_data, 'phone') + } + async loginByPassword( data: PasswordLoginOptions ): Promise> { From 73f2ece51b3fa8dafdc0949962fa27057eace989 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Tue, 27 Sep 2022 22:03:54 +0800 Subject: [PATCH 02/15] fixed types --- packages/miniapp/src/Authing.ts | 5 +++-- packages/miniapp/src/types.ts | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/miniapp/src/Authing.ts b/packages/miniapp/src/Authing.ts index 78adaccc..ce573c20 100644 --- a/packages/miniapp/src/Authing.ts +++ b/packages/miniapp/src/Authing.ts @@ -18,7 +18,8 @@ import { UploadFileResponseData, LoginByCodeOptions, Maybe, - LoginByPhoneOptions + LoginByPhoneOptions, + UpdateUserInfo } from './types' import { error, getLoginStateKey, request, StorageProvider } from './helpers' @@ -456,7 +457,7 @@ export class Authing { } } - async updateUserInfo(data: UserInfo): Promise> { + async updateUserInfo(data: UpdateUserInfo): Promise> { const loginState = await this.getLoginState() if (!loginState) { diff --git a/packages/miniapp/src/types.ts b/packages/miniapp/src/types.ts index c1ab988d..b2f11fc8 100644 --- a/packages/miniapp/src/types.ts +++ b/packages/miniapp/src/types.ts @@ -167,6 +167,25 @@ export interface PassCodeLoginOptions { } } +export interface UpdateUserInfo { + name?: string + nickname?: string + photo?: string + externalId?: string + birthdate?: string + country?: string + province?: string + city?: string + address?: string + streetAddress?: string + postalCode?: string + gender?: Gender + username?: string + customData?: Record +} + +export type Gender = 'M' | 'F' | 'U' + export interface UserInfo { name?: string nickname?: string @@ -179,7 +198,8 @@ export interface UserInfo { address?: string streetAddress?: string postalCode?: string - gender?: string + gender?: Gender + phone?: string username?: string customData?: any createdAt?: string From 739e9c00211772b54f13f63561f084a1b05c784d Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Wed, 28 Sep 2022 14:40:31 +0800 Subject: [PATCH 03/15] feat: retry login with code or phone --- .eslintrc.js | 3 +- packages/miniapp/src/Authing.ts | 82 ++++++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 23 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d19d6f00..fb678f60 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -39,6 +39,7 @@ module.exports = { '@typescript-eslint/no-empty-interface': 'off', 'prefer-const': 'off', '@typescript-eslint/ban-ts-comment': 'off', - 'prettier/prettier': 'off' + 'prettier/prettier': 'off', + '@typescript-eslint/no-this-alias': 'off' } } \ No newline at end of file diff --git a/packages/miniapp/src/Authing.ts b/packages/miniapp/src/Authing.ts index ce573c20..96a8a005 100644 --- a/packages/miniapp/src/Authing.ts +++ b/packages/miniapp/src/Authing.ts @@ -113,21 +113,40 @@ export class Authing { return loginState } - const { code } = await AuthingMove.login() - const { extIdpConnidentifier, connection, wechatMiniProgramCodePayload, options } = data - const _data: WxCodeLoginOptions = { - connection: connection || 'wechat_mini_program_code', - extIdpConnidentifier, - wechatMiniProgramCodePayload: { - ...wechatMiniProgramCodePayload, - code - }, - options + const _this = this + + let retryCount = 0 + + async function login (): Promise> { + const { code } = await AuthingMove.login() + + const _data: WxCodeLoginOptions = { + connection: connection || 'wechat_mini_program_code', + extIdpConnidentifier, + wechatMiniProgramCodePayload: { + ...wechatMiniProgramCodePayload, + code + }, + options + } + + const res = await _this.login(_data, 'code') + + if (res) { + return res + } + + if (retryCount === 0) { + retryCount += 1 + return await login() + } + + return null } - return await this.login(_data, 'code') + return await login() } async loginByPhone( @@ -139,21 +158,40 @@ export class Authing { return loginState } - const { code } = await AuthingMove.login() - const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data - const _data: WxPhoneLoginOptions = { - connection: connection || 'wechat_mini_program_phone', - extIdpConnidentifier, - wechatMiniProgramPhonePayload: { - ...wechatMiniProgramPhonePayload, - code - }, - options + const _this = this + + let retryCount = 0 + + async function login (): Promise> { + const { code } = await AuthingMove.login() + + const _data: WxPhoneLoginOptions = { + connection: connection || 'wechat_mini_program_phone', + extIdpConnidentifier, + wechatMiniProgramPhonePayload: { + ...wechatMiniProgramPhonePayload, + code + }, + options + } + + const res = await _this.login(_data, 'phone') + + if (res) { + return res + } + + if (retryCount === 0) { + retryCount += 1 + return await login() + } + + return null } - return await this.login(_data, 'phone') + return await login() } async loginByPassword( From ee8cba68d9cf318568c445b7ea702c6bfae5438a Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Wed, 28 Sep 2022 06:42:36 +0000 Subject: [PATCH 04/15] v5.0.7-alpha.0 --- lerna.json | 2 +- package-lock.json | 16 ++++++++-------- packages/miniapp-jsencrypt/package.json | 2 +- packages/miniapp-sm2encrypt/package-lock.json | 4 ++-- packages/miniapp-sm2encrypt/package.json | 2 +- packages/miniapp-taro/package.json | 2 +- packages/miniapp-uniapp/package.json | 2 +- packages/miniapp-wx/package.json | 2 +- packages/miniapp/package-lock.json | 4 ++-- packages/miniapp/package.json | 2 +- packages/web/package-lock.json | 4 ++-- packages/web/package.json | 2 +- .../weixin-official-account/package-lock.json | 4 ++-- packages/weixin-official-account/package.json | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lerna.json b/lerna.json index 23d4ce7a..f2e8e941 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ "packages/*" ], "useWorkspaces": true, - "version": "5.0.6" + "version": "5.0.7-alpha.0" } diff --git a/package-lock.json b/package-lock.json index 0fdee826..56c6a98f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6824,7 +6824,7 @@ }, "packages/miniapp": { "name": "@authing/miniapp", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", @@ -6836,7 +6836,7 @@ }, "packages/miniapp-jsencrypt": { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT" }, "packages/miniapp-platform-taro": { @@ -6862,7 +6862,7 @@ }, "packages/miniapp-sm2encrypt": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" @@ -6870,17 +6870,17 @@ }, "packages/miniapp-taro": { "name": "@authing/miniapp-taro", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT" }, "packages/miniapp-uniapp": { "name": "@authing/miniapp-uniapp", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT" }, "packages/miniapp-wx": { "name": "@authing/miniapp-wx", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT" }, "packages/node": { @@ -6891,7 +6891,7 @@ }, "packages/web": { "name": "@authing/web", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT", "dependencies": { "axios": "^0.26.1" @@ -6927,7 +6927,7 @@ }, "packages/weixin-official-account": { "name": "@authing/weixin-official-account", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT" } }, diff --git a/packages/miniapp-jsencrypt/package.json b/packages/miniapp-jsencrypt/package.json index 90d34eaa..2f6a3b7d 100644 --- a/packages/miniapp-jsencrypt/package.json +++ b/packages/miniapp-jsencrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "description": "JavaScript encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-sm2encrypt/package-lock.json b/packages/miniapp-sm2encrypt/package-lock.json index 2d5a12dd..06ba5790 100644 --- a/packages/miniapp-sm2encrypt/package-lock.json +++ b/packages/miniapp-sm2encrypt/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" diff --git a/packages/miniapp-sm2encrypt/package.json b/packages/miniapp-sm2encrypt/package.json index 8bcdeca8..b0900cac 100644 --- a/packages/miniapp-sm2encrypt/package.json +++ b/packages/miniapp-sm2encrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "description": "JavaScript sm2 encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-taro/package.json b/packages/miniapp-taro/package.json index f3e0e515..23e3916c 100644 --- a/packages/miniapp-taro/package.json +++ b/packages/miniapp-taro/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-taro", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "description": "Authing miniapp JS SDK for Taro", "main": "dist/bundle-taro.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-uniapp/package.json b/packages/miniapp-uniapp/package.json index e0ce0122..38a69db8 100644 --- a/packages/miniapp-uniapp/package.json +++ b/packages/miniapp-uniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-uniapp", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "description": "Authing miniapp JS SDK for uniapp", "main": "dist/bundle-uniapp.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-wx/package.json b/packages/miniapp-wx/package.json index 1d045e01..9929759f 100644 --- a/packages/miniapp-wx/package.json +++ b/packages/miniapp-wx/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-wx", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "description": "Authing miniapp JS SDK for WX", "main": "dist/bundle-wx.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp/package-lock.json b/packages/miniapp/package-lock.json index 7d18bf99..67c7db7a 100644 --- a/packages/miniapp/package-lock.json +++ b/packages/miniapp/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", diff --git a/packages/miniapp/package.json b/packages/miniapp/package.json index 9c1a6a4e..17363551 100644 --- a/packages/miniapp/package.json +++ b/packages/miniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "description": "Authing miniapp sdk source code", "main": "src/index.ts", "module": "src/index.ts", diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index f89912ee..4a6e5347 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/web", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/web", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT", "dependencies": { "axios": "^0.26.1" diff --git a/packages/web/package.json b/packages/web/package.json index 8b711598..950a6c94 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@authing/web", - "version": "5.0.6", + "version": "5.0.7-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 fd553f32..f84b8690 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.0.6", + "version": "5.0.7-alpha.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/weixin-official-account", - "version": "5.0.6", + "version": "5.0.7-alpha.0", "license": "MIT" } } diff --git a/packages/weixin-official-account/package.json b/packages/weixin-official-account/package.json index 6619cc67..247e9787 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.0.6", + "version": "5.0.7-alpha.0", "description": "Authing SDK for Weixin official account", "module": "dist/esm/weixin-official-account.min.js", "types": "dist/typings/index.d.ts", From c26d348b19d0f7099a70b84a2700fbbbb4a08b29 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Wed, 28 Sep 2022 14:52:08 +0800 Subject: [PATCH 05/15] test: run examples for version 5.0.7-alpha.0 --- examples/miniapp-taro/package-lock.json | 14 ++++++------- examples/miniapp-taro/package.json | 2 +- .../@authing/miniapp-jsencrypt/index.js | 8 ++++---- .../@authing/miniapp-sm2encrypt/index.js | 18 ++++++++--------- .../@authing/miniapp-wx/index.js | 6 +++--- .../@authing/miniapp-wx/index.js.map | 2 +- .../miniapp/miniprogram_npm/jsbn/index.js | 4 ++-- examples/miniapp-wx/miniapp/package-lock.json | 14 ++++++------- examples/miniapp-wx/miniapp/package.json | 2 +- .../miniapp-wx/miniapp/pages/index/index.ts | 20 +++++++++++++++++++ .../miniapp-wx/miniapp/pages/index/index.wxml | 1 + 11 files changed, 56 insertions(+), 35 deletions(-) diff --git a/examples/miniapp-taro/package-lock.json b/examples/miniapp-taro/package-lock.json index a96dfa98..8a0291bb 100644 --- a/examples/miniapp-taro/package-lock.json +++ b/examples/miniapp-taro/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "@authing/miniapp-jsencrypt": "^5.0.0-alpha.26", "@authing/miniapp-sm2encrypt": "^5.0.0-alpha.26", - "@authing/miniapp-taro": "^5.0.6-alpha.2", + "@authing/miniapp-taro": "^5.0.7-alpha.0", "@authing/miniapp-wx": "^5.0.4-alpha.2", "@babel/runtime": "^7.7.7", "@tarojs/components": "3.5.4", @@ -84,9 +84,9 @@ "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==" }, "node_modules/@authing/miniapp-taro": { - "version": "5.0.6-alpha.2", - "resolved": "https://registry.npmjs.org/@authing/miniapp-taro/-/miniapp-taro-5.0.6-alpha.2.tgz", - "integrity": "sha512-i9z0zKssfg69S6xAiCcVOIK3kvVJMF+4atlp4fDLDbDF1n0WdTGFwVwuEqYcRZFn3PIQbhkwJ92iFDZBlPnwSQ==" + "version": "5.0.7-alpha.0", + "resolved": "https://registry.npmjs.org/@authing/miniapp-taro/-/miniapp-taro-5.0.7-alpha.0.tgz", + "integrity": "sha512-k8oQZVQ8WzcPcTg5u+9wyHA2FDylLGNsaRG2sgBxa2c3UOYK0SmSS4O7VKyL0D6BvQVk4UYBteUNxzzRQLJDrA==" }, "node_modules/@authing/miniapp-wx": { "version": "5.0.4-alpha.2", @@ -24995,9 +24995,9 @@ } }, "@authing/miniapp-taro": { - "version": "5.0.6-alpha.2", - "resolved": "https://registry.npmjs.org/@authing/miniapp-taro/-/miniapp-taro-5.0.6-alpha.2.tgz", - "integrity": "sha512-i9z0zKssfg69S6xAiCcVOIK3kvVJMF+4atlp4fDLDbDF1n0WdTGFwVwuEqYcRZFn3PIQbhkwJ92iFDZBlPnwSQ==" + "version": "5.0.7-alpha.0", + "resolved": "https://registry.npmjs.org/@authing/miniapp-taro/-/miniapp-taro-5.0.7-alpha.0.tgz", + "integrity": "sha512-k8oQZVQ8WzcPcTg5u+9wyHA2FDylLGNsaRG2sgBxa2c3UOYK0SmSS4O7VKyL0D6BvQVk4UYBteUNxzzRQLJDrA==" }, "@authing/miniapp-wx": { "version": "5.0.4-alpha.2", diff --git a/examples/miniapp-taro/package.json b/examples/miniapp-taro/package.json index f8ab0113..9b9a4c14 100644 --- a/examples/miniapp-taro/package.json +++ b/examples/miniapp-taro/package.json @@ -37,7 +37,7 @@ "dependencies": { "@authing/miniapp-jsencrypt": "^5.0.0-alpha.26", "@authing/miniapp-sm2encrypt": "^5.0.0-alpha.26", - "@authing/miniapp-taro": "^5.0.6-alpha.2", + "@authing/miniapp-taro": "^5.0.7-alpha.0", "@authing/miniapp-wx": "^5.0.4-alpha.2", "@babel/runtime": "^7.7.7", "@tarojs/components": "3.5.4", 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 923e5265..c6d11d0f 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__(1664187471873, function(require, module, exports) { +__DEFINE__(1664336657652, 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":1664187471874}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664187471874, function(require, module, exports) { +}, function(modId) {var map = {"./jsencrypt":1664336657653}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664336657653, 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__(1664187471873); +return __REQUIRE__(1664336657652); })() //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 a7b24096..09ef02ae 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__(1664187471875, function(require, module, exports) { +__DEFINE__(1664336657654, 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":1664187471876}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664187471876, function(require, module, exports) { +}, function(modId) {var map = {"./sm2":1664336657655}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664336657655, 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":1664187471877,"./sm3":1664187471879}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664187471877, function(require, module, exports) { +}, function(modId) { var map = {"./utils":1664336657656,"./sm3":1664336657658}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664336657656, 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":1664187471878}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664187471878, function(require, module, exports) { +}, function(modId) { var map = {"./ec":1664336657657}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664336657657, 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__(1664187471879, function(require, module, exports) { +__DEFINE__(1664336657658, 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__(1664187471875); +return __REQUIRE__(1664336657654); })() //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 09cdd7b8..e007b3aa 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__(1664187471880, function(require, module, exports) { -var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{e:()=>B});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>C,chooseImage:()=>P,clearStorage:()=>m,getStorage:()=>w,getUserProfile:()=>O,login:()=>l,removeStorage:()=>b,request:()=>d,scanCode:()=>y,setStorage:()=>v,uploadFile:()=>_}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),"function"==typeof t.install?t.install.apply(t,o):"function"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function s(){return["wx","ali","baidu","qq","tt","jd","ks","qa_webview","qa_ux","Mpx","Taro","uni"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function i(t){console.error&&console.error(`[AuthingMove/api-proxy error in "wx"]:\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const p=c();function l(t={}){return p.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function y(t={}){return f.scanCode(t)}const g=c();function v(t={}){const e=u(t,{},{encrypt:!1});return g.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return g.getStorage(e)}function b(t={}){return g.removeStorage(t)}function m(t={}){return g.clearStorage(t)}const x=c();function P(t={}){return x.chooseMedia(t)}const S=c();function _(t={}){return S.uploadFile(t)}const k=c();function O(t={}){return k.getUserProfile(t)}const T=c();function C(t={}){return T.checkSession(t)}const I=s();const j=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((s=>{"function"==typeof o[s]?r[s]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),"string"==typeof r&&I[r]||(o.push(r),r=t.from));const u=function(t="",e=""){return`${I[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][s]?t.custom[u][s].apply(this,o):n[s]?n[s].apply(this,o):e[s]?e[s].apply(this,o):void i(`"${s}" method does not exist in the current context`)}:r[s]=o[s]})),r}({from:"wx",to:"wx",custom:o}),u=Object.assign({},r,function(t){const e=s();return Object.keys(t).reduce(((n,o)=>("function"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\w*Manager$/.test(t)||/^create\w*Context$/.test(t)||/^(on|off)/.test(t)||/\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let s;const i=new Promise(((e,i)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),i(t)},s=t[o].apply(j,n)}));return i.__returned=s,i}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if("function"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){i(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var L=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const E=JSON.parse('{"i8":"5.0.6-alpha.2"}');var F=function(){return F=Object.assign||function(t){for(var e,n=1,o=arguments.length;n0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]Date.now()?[2,e]:(q("getLoginState","loginState has expired, please login again"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return M(this,void 0,void 0,(function(){return K(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(U(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return q("clearLoginState",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return M(this,void 0,void 0,(function(){var e;return K(this,(function(n){switch(n.label){case 0:return e=A(A({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(U(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return M(this,void 0,void 0,(function(){return K(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:"GET",url:this.options.host+"/api/v3/system"})];case 1:return[2,e.sent()[t].publicKey];case 2:return q("getPublicKey",e.sent()),[2,""];case 3:return[2]}}))}))},t.prototype.resetWxCode=function(){return M(this,void 0,void 0,(function(){var t;return K(this,(function(e){switch(e.label){case 0:return[4,r.login()];case 1:return t=e.sent().code,[4,this.storage.set($(this.options.appId),t)];case 2:return e.sent(),[2,t]}}))}))},t.prototype.getCachedWxLoginCode=function(){return M(this,void 0,void 0,(function(){return K(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.get($(this.options.appId))];case 1:return[2,t.sent().data];case 2:return t.sent(),[2,""];case 3:return[2]}}))}))},t.prototype.loginByCode=function(t){return M(this,void 0,void 0,(function(){var e,n,o,s,i,a,u;return K(this,(function(c){switch(c.label){case 0:return[4,this.getLoginState()];case 1:return(e=c.sent())&&e.expires_at>Date.now()?[2,e]:[4,this.getCachedWxLoginCode()];case 2:if(!(n=c.sent()))return[3,8];c.label=3;case 3:return c.trys.push([3,5,,7]),[4,r.checkSession()];case 4:return c.sent(),[3,7];case 5:return c.sent(),[4,this.resetWxCode()];case 6:return n=c.sent(),[3,7];case 7:return[3,10];case 8:return[4,this.resetWxCode()];case 9:n=c.sent(),c.label=10;case 10:return o=t.extIdpConnidentifier,s=t.connection,i=t.wechatMiniProgramCodePayload,a=t.options,u={connection:s||"wechat_mini_program_code",extIdpConnidentifier:o,wechatMiniProgramCodePayload:A(A({},i),{code:n}),options:a},[4,this.login(u,"code")];case 11:return[2,c.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return M(this,void 0,void 0,(function(){var r,s;return K(this,(function(i){switch(i.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&"none"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:(q("loginByPassword",'encryptFunction is required, if passwordEncryptType is not "none"'),[2,null]):[3,2];case 1:if(!(r=i.sent()))return q("loginByPassword","publicKey is invalid"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),i.label=2;case 2:return s=A(A({},t),{connection:"PASSWORD"}),[4,this.login(s,"password")];case 3:return[2,i.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return M(this,void 0,void 0,(function(){var e;return K(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||"+86"),e=A(A({},t),{connection:"PASSCODE"}),[4,this.login(e,"passCode")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return M(this,void 0,void 0,(function(){var t,e,n;return K(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||n{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{e:()=>K});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>I,chooseImage:()=>_,clearStorage:()=>m,getStorage:()=>w,getUserProfile:()=>O,login:()=>p,removeStorage:()=>b,request:()=>d,scanCode:()=>y,setStorage:()=>v,uploadFile:()=>S}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),"function"==typeof t.install?t.install.apply(t,o):"function"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function i(){return["wx","ali","baidu","qq","tt","jd","ks","qa_webview","qa_ux","Mpx","Taro","uni"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function s(t){console.error&&console.error(`[AuthingMove/api-proxy error in "wx"]:\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const l=c();function p(t={}){return l.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function y(t={}){return f.scanCode(t)}const g=c();function v(t={}){const e=u(t,{},{encrypt:!1});return g.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return g.getStorage(e)}function b(t={}){return g.removeStorage(t)}function m(t={}){return g.clearStorage(t)}const P=c();function _(t={}){return P.chooseMedia(t)}const x=c();function S(t={}){return x.uploadFile(t)}const k=c();function O(t={}){return k.getUserProfile(t)}const T=c();function I(t={}){return T.checkSession(t)}const C=i();const j=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((i=>{"function"==typeof o[i]?r[i]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),"string"==typeof r&&C[r]||(o.push(r),r=t.from));const u=function(t="",e=""){return`${C[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][i]?t.custom[u][i].apply(this,o):n[i]?n[i].apply(this,o):e[i]?e[i].apply(this,o):void s(`"${i}" method does not exist in the current context`)}:r[i]=o[i]})),r}({from:"wx",to:"wx",custom:o}),u=Object.assign({},r,function(t){const e=i();return Object.keys(t).reduce(((n,o)=>("function"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\w*Manager$/.test(t)||/^create\w*Context$/.test(t)||/^(on|off)/.test(t)||/\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let i;const s=new Promise(((e,s)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),s(t)},i=t[o].apply(j,n)}));return s.__returned=i,s}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if("function"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){s(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var E=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const L=JSON.parse('{"i8":"5.0.7-alpha.0"}');var F=function(){return F=Object.assign||function(t){for(var e,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]Date.now()?[2,e]:(U("getLoginState","loginState has expired, please login again"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return q(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(M(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return U("clearLoginState",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return e=$($({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(M(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return q(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:"GET",url:this.options.host+"/api/v3/system"})];case 1:return[2,e.sent()[t].publicKey];case 2:return U("getPublicKey",e.sent()),[2,""];case 3:return[2]}}))}))},t.prototype.loginByCode=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||"wechat_mini_program_code",extIdpConnidentifier:o,wechatMiniProgramCodePayload:$($({},s),{code:t}),options:a},[4,u.login(n,"code")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramCodePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPhone=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||"wechat_mini_program_phone",extIdpConnidentifier:o,wechatMiniProgramPhonePayload:$($({},s),{code:t}),options:a},[4,u.login(n,"phone")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramPhonePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return q(this,void 0,void 0,(function(){var r,i;return A(this,(function(s){switch(s.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&"none"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:(U("loginByPassword",'encryptFunction is required, if passwordEncryptType is not "none"'),[2,null]):[3,2];case 1:if(!(r=s.sent()))return U("loginByPassword","publicKey is invalid"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),s.label=2;case 2:return i=$($({},t),{connection:"PASSWORD"}),[4,this.login(i,"password")];case 3:return[2,s.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||"+86"),e=$($({},t),{connection:"PASSCODE"}),[4,this.login(e,"passCode")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return q(this,void 0,void 0,(function(){var t,e,n;return A(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||n{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})}},e={};t.d(e,{e:()=>B});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>C,chooseImage:()=>P,clearStorage:()=>m,getStorage:()=>w,getUserProfile:()=>O,login:()=>l,removeStorage:()=>b,request:()=>d,scanCode:()=>y,setStorage:()=>v,uploadFile:()=>_}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),\"function\"==typeof t.install?t.install.apply(t,o):\"function\"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function s(){return[\"wx\",\"ali\",\"baidu\",\"qq\",\"tt\",\"jd\",\"ks\",\"qa_webview\",\"qa_ux\",\"Mpx\",\"Taro\",\"uni\"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function i(t){console.error&&console.error(`[AuthingMove/api-proxy error in \"wx\"]:\\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const p=c();function l(t={}){return p.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function y(t={}){return f.scanCode(t)}const g=c();function v(t={}){const e=u(t,{},{encrypt:!1});return g.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return g.getStorage(e)}function b(t={}){return g.removeStorage(t)}function m(t={}){return g.clearStorage(t)}const x=c();function P(t={}){return x.chooseMedia(t)}const S=c();function _(t={}){return S.uploadFile(t)}const k=c();function O(t={}){return k.getUserProfile(t)}const T=c();function C(t={}){return T.checkSession(t)}const I=s();const j=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((s=>{\"function\"==typeof o[s]?r[s]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),\"string\"==typeof r&&I[r]||(o.push(r),r=t.from));const u=function(t=\"\",e=\"\"){return`${I[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][s]?t.custom[u][s].apply(this,o):n[s]?n[s].apply(this,o):e[s]?e[s].apply(this,o):void i(`\"${s}\" method does not exist in the current context`)}:r[s]=o[s]})),r}({from:\"wx\",to:\"wx\",custom:o}),u=Object.assign({},r,function(t){const e=s();return Object.keys(t).reduce(((n,o)=>(\"function\"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\\w*Manager$/.test(t)||/^create\\w*Context$/.test(t)||/^(on|off)/.test(t)||/\\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let s;const i=new Promise(((e,i)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),i(t)},s=t[o].apply(j,n)}));return i.__returned=s,i}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if(\"function\"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){i(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var L=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const E=JSON.parse('{\"i8\":\"5.0.6-alpha.2\"}');var F=function(){return F=Object.assign||function(t){for(var e,n=1,o=arguments.length;n0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]Date.now()?[2,e]:(q(\"getLoginState\",\"loginState has expired, please login again\"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return M(this,void 0,void 0,(function(){return K(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(U(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return q(\"clearLoginState\",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return M(this,void 0,void 0,(function(){var e;return K(this,(function(n){switch(n.label){case 0:return e=A(A({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(U(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return M(this,void 0,void 0,(function(){return K(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:\"GET\",url:this.options.host+\"/api/v3/system\"})];case 1:return[2,e.sent()[t].publicKey];case 2:return q(\"getPublicKey\",e.sent()),[2,\"\"];case 3:return[2]}}))}))},t.prototype.resetWxCode=function(){return M(this,void 0,void 0,(function(){var t;return K(this,(function(e){switch(e.label){case 0:return[4,r.login()];case 1:return t=e.sent().code,[4,this.storage.set($(this.options.appId),t)];case 2:return e.sent(),[2,t]}}))}))},t.prototype.getCachedWxLoginCode=function(){return M(this,void 0,void 0,(function(){return K(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.get($(this.options.appId))];case 1:return[2,t.sent().data];case 2:return t.sent(),[2,\"\"];case 3:return[2]}}))}))},t.prototype.loginByCode=function(t){return M(this,void 0,void 0,(function(){var e,n,o,s,i,a,u;return K(this,(function(c){switch(c.label){case 0:return[4,this.getLoginState()];case 1:return(e=c.sent())&&e.expires_at>Date.now()?[2,e]:[4,this.getCachedWxLoginCode()];case 2:if(!(n=c.sent()))return[3,8];c.label=3;case 3:return c.trys.push([3,5,,7]),[4,r.checkSession()];case 4:return c.sent(),[3,7];case 5:return c.sent(),[4,this.resetWxCode()];case 6:return n=c.sent(),[3,7];case 7:return[3,10];case 8:return[4,this.resetWxCode()];case 9:n=c.sent(),c.label=10;case 10:return o=t.extIdpConnidentifier,s=t.connection,i=t.wechatMiniProgramCodePayload,a=t.options,u={connection:s||\"wechat_mini_program_code\",extIdpConnidentifier:o,wechatMiniProgramCodePayload:A(A({},i),{code:n}),options:a},[4,this.login(u,\"code\")];case 11:return[2,c.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return M(this,void 0,void 0,(function(){var r,s;return K(this,(function(i){switch(i.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&\"none\"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:(q(\"loginByPassword\",'encryptFunction is required, if passwordEncryptType is not \"none\"'),[2,null]):[3,2];case 1:if(!(r=i.sent()))return q(\"loginByPassword\",\"publicKey is invalid\"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),i.label=2;case 2:return s=A(A({},t),{connection:\"PASSWORD\"}),[4,this.login(s,\"password\")];case 3:return[2,i.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return M(this,void 0,void 0,(function(){var e;return K(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||\"+86\"),e=A(A({},t),{connection:\"PASSCODE\"}),[4,this.login(e,\"passCode\")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return M(this,void 0,void 0,(function(){var t,e,n;return K(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||n{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})}},e={};t.d(e,{e:()=>K});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>I,chooseImage:()=>_,clearStorage:()=>m,getStorage:()=>w,getUserProfile:()=>O,login:()=>p,removeStorage:()=>b,request:()=>d,scanCode:()=>y,setStorage:()=>v,uploadFile:()=>S}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),\"function\"==typeof t.install?t.install.apply(t,o):\"function\"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function i(){return[\"wx\",\"ali\",\"baidu\",\"qq\",\"tt\",\"jd\",\"ks\",\"qa_webview\",\"qa_ux\",\"Mpx\",\"Taro\",\"uni\"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function s(t){console.error&&console.error(`[AuthingMove/api-proxy error in \"wx\"]:\\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const l=c();function p(t={}){return l.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function y(t={}){return f.scanCode(t)}const g=c();function v(t={}){const e=u(t,{},{encrypt:!1});return g.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return g.getStorage(e)}function b(t={}){return g.removeStorage(t)}function m(t={}){return g.clearStorage(t)}const P=c();function _(t={}){return P.chooseMedia(t)}const x=c();function S(t={}){return x.uploadFile(t)}const k=c();function O(t={}){return k.getUserProfile(t)}const T=c();function I(t={}){return T.checkSession(t)}const C=i();const j=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((i=>{\"function\"==typeof o[i]?r[i]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),\"string\"==typeof r&&C[r]||(o.push(r),r=t.from));const u=function(t=\"\",e=\"\"){return`${C[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][i]?t.custom[u][i].apply(this,o):n[i]?n[i].apply(this,o):e[i]?e[i].apply(this,o):void s(`\"${i}\" method does not exist in the current context`)}:r[i]=o[i]})),r}({from:\"wx\",to:\"wx\",custom:o}),u=Object.assign({},r,function(t){const e=i();return Object.keys(t).reduce(((n,o)=>(\"function\"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\\w*Manager$/.test(t)||/^create\\w*Context$/.test(t)||/^(on|off)/.test(t)||/\\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let i;const s=new Promise(((e,s)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),s(t)},i=t[o].apply(j,n)}));return s.__returned=i,s}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if(\"function\"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){s(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var E=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const L=JSON.parse('{\"i8\":\"5.0.7-alpha.0\"}');var F=function(){return F=Object.assign||function(t){for(var e,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]Date.now()?[2,e]:(U(\"getLoginState\",\"loginState has expired, please login again\"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return q(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(M(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return U(\"clearLoginState\",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return e=$($({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(M(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return q(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:\"GET\",url:this.options.host+\"/api/v3/system\"})];case 1:return[2,e.sent()[t].publicKey];case 2:return U(\"getPublicKey\",e.sent()),[2,\"\"];case 3:return[2]}}))}))},t.prototype.loginByCode=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||\"wechat_mini_program_code\",extIdpConnidentifier:o,wechatMiniProgramCodePayload:$($({},s),{code:t}),options:a},[4,u.login(n,\"code\")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramCodePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPhone=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||\"wechat_mini_program_phone\",extIdpConnidentifier:o,wechatMiniProgramPhonePayload:$($({},s),{code:t}),options:a},[4,u.login(n,\"phone\")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramPhonePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return q(this,void 0,void 0,(function(){var r,i;return A(this,(function(s){switch(s.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&\"none\"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:(U(\"loginByPassword\",'encryptFunction is required, if passwordEncryptType is not \"none\"'),[2,null]):[3,2];case 1:if(!(r=s.sent()))return U(\"loginByPassword\",\"publicKey is invalid\"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),s.label=2;case 2:return i=$($({},t),{connection:\"PASSWORD\"}),[4,this.login(i,\"password\")];case 3:return[2,s.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||\"+86\"),e=$($({},t),{connection:\"PASSCODE\"}),[4,this.login(e,\"passCode\")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return q(this,void 0,void 0,(function(){var t,e,n;return A(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||nloginByCode + From ba68b5ae2fd6442535a194d262b76e158f10392b Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Wed, 28 Sep 2022 17:51:17 +0800 Subject: [PATCH 06/15] feat: reset wx login code --- packages/miniapp/src/Authing.ts | 127 +++++++++++++++----------- packages/miniapp/src/helpers/utils.ts | 4 + 2 files changed, 76 insertions(+), 55 deletions(-) diff --git a/packages/miniapp/src/Authing.ts b/packages/miniapp/src/Authing.ts index 96a8a005..1243d8bb 100644 --- a/packages/miniapp/src/Authing.ts +++ b/packages/miniapp/src/Authing.ts @@ -22,7 +22,7 @@ import { UpdateUserInfo } from './types' -import { error, getLoginStateKey, request, StorageProvider } from './helpers' +import { error, getLoginStateKey, getWxLoginCodeKey, request, StorageProvider } from './helpers' import { AuthingMove } from './AuthingMove' @@ -40,6 +40,8 @@ export class Authing { this.storage = new StorageProvider() this.encryptFunction = options.encryptFunction + + this.resetWxLoginCode() } async getLoginState(): Promise { @@ -104,6 +106,43 @@ export class Authing { } } + private async getCachedWxLoginCode (): Promise { + try { + const res = await this.storage.get(getWxLoginCodeKey(this.options.appId)) + return res.data + } catch (e) { + return '' + } + } + + private async cacheWxLoginCode (code: string): Promise { + try { + await this.storage.set(getWxLoginCodeKey(this.options.appId), code) + return code + } catch (e) { + return '' + } + } + + private async resetWxLoginCode (): Promise { + const next = async () => { + const { code } = await AuthingMove.login() + await this.cacheWxLoginCode(code) + } + + try { + await AuthingMove.checkSession() + const code = await this.getCachedWxLoginCode() + if (!code) { + await next() + } + } catch (e) { + await next() + } finally { + return await this.getCachedWxLoginCode() + } + } + async loginByCode( data: LoginByCodeOptions ): Promise> { @@ -115,38 +154,27 @@ export class Authing { const { extIdpConnidentifier, connection, wechatMiniProgramCodePayload, options } = data - const _this = this - - let retryCount = 0 - - async function login (): Promise> { - const { code } = await AuthingMove.login() - - const _data: WxCodeLoginOptions = { - connection: connection || 'wechat_mini_program_code', - extIdpConnidentifier, - wechatMiniProgramCodePayload: { - ...wechatMiniProgramCodePayload, - code - }, - options - } + const code = await this.resetWxLoginCode() - const res = await _this.login(_data, 'code') - - if (res) { - return res - } + const _data: WxCodeLoginOptions = { + connection: connection || 'wechat_mini_program_code', + extIdpConnidentifier, + wechatMiniProgramCodePayload: { + ...wechatMiniProgramCodePayload, + code + }, + options + } - if (retryCount === 0) { - retryCount += 1 - return await login() - } + const loginRes = await this.login(_data, 'code') - return null + if (loginRes) { + return loginRes } - return await login() + await this.resetWxLoginCode() + + return null } async loginByPhone( @@ -160,38 +188,27 @@ export class Authing { const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data - const _this = this - - let retryCount = 0 + const { code } = await AuthingMove.login() - async function login (): Promise> { - const { code } = await AuthingMove.login() - - const _data: WxPhoneLoginOptions = { - connection: connection || 'wechat_mini_program_phone', - extIdpConnidentifier, - wechatMiniProgramPhonePayload: { - ...wechatMiniProgramPhonePayload, - code - }, - options - } - - const res = await _this.login(_data, 'phone') - - if (res) { - return res - } + const _data: WxPhoneLoginOptions = { + connection: connection || 'wechat_mini_program_phone', + extIdpConnidentifier, + wechatMiniProgramPhonePayload: { + ...wechatMiniProgramPhonePayload, + code + }, + options + } - if (retryCount === 0) { - retryCount += 1 - return await login() - } + const loginRes = await this.login(_data, 'phone') - return null + if (loginRes) { + return loginRes } - return await login() + await this.resetWxLoginCode() + + return null } async loginByPassword( diff --git a/packages/miniapp/src/helpers/utils.ts b/packages/miniapp/src/helpers/utils.ts index 548da05e..6e337c30 100644 --- a/packages/miniapp/src/helpers/utils.ts +++ b/packages/miniapp/src/helpers/utils.ts @@ -1,3 +1,7 @@ export function getLoginStateKey(appId: string): string { return ['authing', appId, 'login-state'].join(':') } + +export function getWxLoginCodeKey (appId: string): string { + return ['authing', appId, 'wx-login-code'].join(':') +} From c23853cb4a34f52c2f08e711ccc05d934ed50f10 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Wed, 28 Sep 2022 09:52:52 +0000 Subject: [PATCH 07/15] v5.0.7-alpha.1 --- lerna.json | 2 +- package-lock.json | 16 ++++++++-------- packages/miniapp-jsencrypt/package.json | 2 +- packages/miniapp-sm2encrypt/package-lock.json | 4 ++-- packages/miniapp-sm2encrypt/package.json | 2 +- packages/miniapp-taro/package.json | 2 +- packages/miniapp-uniapp/package.json | 2 +- packages/miniapp-wx/package.json | 2 +- packages/miniapp/package-lock.json | 4 ++-- packages/miniapp/package.json | 2 +- packages/web/package-lock.json | 4 ++-- packages/web/package.json | 2 +- .../weixin-official-account/package-lock.json | 4 ++-- packages/weixin-official-account/package.json | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lerna.json b/lerna.json index f2e8e941..025bb965 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ "packages/*" ], "useWorkspaces": true, - "version": "5.0.7-alpha.0" + "version": "5.0.7-alpha.1" } diff --git a/package-lock.json b/package-lock.json index 56c6a98f..f6bc262a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6824,7 +6824,7 @@ }, "packages/miniapp": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", @@ -6836,7 +6836,7 @@ }, "packages/miniapp-jsencrypt": { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT" }, "packages/miniapp-platform-taro": { @@ -6862,7 +6862,7 @@ }, "packages/miniapp-sm2encrypt": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" @@ -6870,17 +6870,17 @@ }, "packages/miniapp-taro": { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT" }, "packages/miniapp-uniapp": { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT" }, "packages/miniapp-wx": { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT" }, "packages/node": { @@ -6891,7 +6891,7 @@ }, "packages/web": { "name": "@authing/web", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT", "dependencies": { "axios": "^0.26.1" @@ -6927,7 +6927,7 @@ }, "packages/weixin-official-account": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT" } }, diff --git a/packages/miniapp-jsencrypt/package.json b/packages/miniapp-jsencrypt/package.json index 2f6a3b7d..694c2d97 100644 --- a/packages/miniapp-jsencrypt/package.json +++ b/packages/miniapp-jsencrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "description": "JavaScript encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-sm2encrypt/package-lock.json b/packages/miniapp-sm2encrypt/package-lock.json index 06ba5790..853c25db 100644 --- a/packages/miniapp-sm2encrypt/package-lock.json +++ b/packages/miniapp-sm2encrypt/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" diff --git a/packages/miniapp-sm2encrypt/package.json b/packages/miniapp-sm2encrypt/package.json index b0900cac..43b94903 100644 --- a/packages/miniapp-sm2encrypt/package.json +++ b/packages/miniapp-sm2encrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "description": "JavaScript sm2 encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-taro/package.json b/packages/miniapp-taro/package.json index 23e3916c..028fd768 100644 --- a/packages/miniapp-taro/package.json +++ b/packages/miniapp-taro/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "description": "Authing miniapp JS SDK for Taro", "main": "dist/bundle-taro.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-uniapp/package.json b/packages/miniapp-uniapp/package.json index 38a69db8..f70b2c50 100644 --- a/packages/miniapp-uniapp/package.json +++ b/packages/miniapp-uniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "description": "Authing miniapp JS SDK for uniapp", "main": "dist/bundle-uniapp.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-wx/package.json b/packages/miniapp-wx/package.json index 9929759f..20b881e0 100644 --- a/packages/miniapp-wx/package.json +++ b/packages/miniapp-wx/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "description": "Authing miniapp JS SDK for WX", "main": "dist/bundle-wx.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp/package-lock.json b/packages/miniapp/package-lock.json index 67c7db7a..b27e5589 100644 --- a/packages/miniapp/package-lock.json +++ b/packages/miniapp/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", diff --git a/packages/miniapp/package.json b/packages/miniapp/package.json index 17363551..c14043ba 100644 --- a/packages/miniapp/package.json +++ b/packages/miniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "description": "Authing miniapp sdk source code", "main": "src/index.ts", "module": "src/index.ts", diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index 4a6e5347..e0249281 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/web", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT", "dependencies": { "axios": "^0.26.1" diff --git a/packages/web/package.json b/packages/web/package.json index 950a6c94..b061f101 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "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 f84b8690..f3cf04ba 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.0.7-alpha.0", + "version": "5.0.7-alpha.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.0", + "version": "5.0.7-alpha.1", "license": "MIT" } } diff --git a/packages/weixin-official-account/package.json b/packages/weixin-official-account/package.json index 247e9787..08a49523 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.0.7-alpha.0", + "version": "5.0.7-alpha.1", "description": "Authing SDK for Weixin official account", "module": "dist/esm/weixin-official-account.min.js", "types": "dist/typings/index.d.ts", From 104458f6f0fde52659f244c33d164f3148ea7cc6 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Thu, 29 Sep 2022 10:55:19 +0800 Subject: [PATCH 08/15] feat: handle wx login code --- packages/miniapp/src/Authing.ts | 91 +++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 34 deletions(-) diff --git a/packages/miniapp/src/Authing.ts b/packages/miniapp/src/Authing.ts index 1243d8bb..54dd0715 100644 --- a/packages/miniapp/src/Authing.ts +++ b/packages/miniapp/src/Authing.ts @@ -120,14 +120,19 @@ export class Authing { await this.storage.set(getWxLoginCodeKey(this.options.appId), code) return code } catch (e) { + error('cacheWxLoginCode', e) return '' } } private async resetWxLoginCode (): Promise { const next = async () => { - const { code } = await AuthingMove.login() - await this.cacheWxLoginCode(code) + try { + const wxLoginRes = await AuthingMove.login() + await this.cacheWxLoginCode(wxLoginRes.code) + } catch (e) { + error('resetWxLoginCode', e) + } } try { @@ -154,27 +159,36 @@ export class Authing { const { extIdpConnidentifier, connection, wechatMiniProgramCodePayload, options } = data - const code = await this.resetWxLoginCode() + let retryCount = 0 - const _data: WxCodeLoginOptions = { - connection: connection || 'wechat_mini_program_code', - extIdpConnidentifier, - wechatMiniProgramCodePayload: { - ...wechatMiniProgramCodePayload, - code - }, - options - } + const login = async (): Promise> => { + const code = await this.resetWxLoginCode() - const loginRes = await this.login(_data, 'code') + const _data: WxCodeLoginOptions = { + connection: connection || 'wechat_mini_program_code', + extIdpConnidentifier, + wechatMiniProgramCodePayload: { + ...wechatMiniProgramCodePayload, + code + }, + options + } - if (loginRes) { - return loginRes - } + const loginRes = await this.login(_data, 'code') + + if (loginRes) { + return loginRes + } - await this.resetWxLoginCode() + if (retryCount === 0) { + retryCount += 1 + return await login() + } - return null + return null + } + + return await login() } async loginByPhone( @@ -188,27 +202,36 @@ export class Authing { const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data - const { code } = await AuthingMove.login() + let retryCount = 0 - const _data: WxPhoneLoginOptions = { - connection: connection || 'wechat_mini_program_phone', - extIdpConnidentifier, - wechatMiniProgramPhonePayload: { - ...wechatMiniProgramPhonePayload, - code - }, - options - } + const login = async (): Promise> => { + const code = await this.resetWxLoginCode() - const loginRes = await this.login(_data, 'phone') + const _data: WxPhoneLoginOptions = { + connection: connection || 'wechat_mini_program_phone', + extIdpConnidentifier, + wechatMiniProgramPhonePayload: { + ...wechatMiniProgramPhonePayload, + code + }, + options + } - if (loginRes) { - return loginRes - } + const loginRes = await this.login(_data, 'phone') - await this.resetWxLoginCode() + if (loginRes) { + return loginRes + } - return null + if (retryCount === 0) { + retryCount += 1 + return await login() + } + + return null + } + + return await login() } async loginByPassword( From 140d96c854ffe4e911bd15c01e8a58f9c7ecda51 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Thu, 29 Sep 2022 02:57:18 +0000 Subject: [PATCH 09/15] v5.0.7-alpha.2 --- lerna.json | 2 +- package-lock.json | 16 ++++++++-------- packages/miniapp-jsencrypt/package.json | 2 +- packages/miniapp-sm2encrypt/package-lock.json | 4 ++-- packages/miniapp-sm2encrypt/package.json | 2 +- packages/miniapp-taro/package.json | 2 +- packages/miniapp-uniapp/package.json | 2 +- packages/miniapp-wx/package.json | 2 +- packages/miniapp/package-lock.json | 4 ++-- packages/miniapp/package.json | 2 +- packages/web/package-lock.json | 4 ++-- packages/web/package.json | 2 +- .../weixin-official-account/package-lock.json | 4 ++-- packages/weixin-official-account/package.json | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lerna.json b/lerna.json index 025bb965..deed6229 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ "packages/*" ], "useWorkspaces": true, - "version": "5.0.7-alpha.1" + "version": "5.0.7-alpha.2" } diff --git a/package-lock.json b/package-lock.json index f6bc262a..ca1cd0f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6824,7 +6824,7 @@ }, "packages/miniapp": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", @@ -6836,7 +6836,7 @@ }, "packages/miniapp-jsencrypt": { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT" }, "packages/miniapp-platform-taro": { @@ -6862,7 +6862,7 @@ }, "packages/miniapp-sm2encrypt": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" @@ -6870,17 +6870,17 @@ }, "packages/miniapp-taro": { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT" }, "packages/miniapp-uniapp": { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT" }, "packages/miniapp-wx": { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT" }, "packages/node": { @@ -6891,7 +6891,7 @@ }, "packages/web": { "name": "@authing/web", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT", "dependencies": { "axios": "^0.26.1" @@ -6927,7 +6927,7 @@ }, "packages/weixin-official-account": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT" } }, diff --git a/packages/miniapp-jsencrypt/package.json b/packages/miniapp-jsencrypt/package.json index 694c2d97..ea2db7b0 100644 --- a/packages/miniapp-jsencrypt/package.json +++ b/packages/miniapp-jsencrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "description": "JavaScript encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-sm2encrypt/package-lock.json b/packages/miniapp-sm2encrypt/package-lock.json index 853c25db..d43ee43b 100644 --- a/packages/miniapp-sm2encrypt/package-lock.json +++ b/packages/miniapp-sm2encrypt/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" diff --git a/packages/miniapp-sm2encrypt/package.json b/packages/miniapp-sm2encrypt/package.json index 43b94903..c9301a4c 100644 --- a/packages/miniapp-sm2encrypt/package.json +++ b/packages/miniapp-sm2encrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "description": "JavaScript sm2 encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-taro/package.json b/packages/miniapp-taro/package.json index 028fd768..e0aa5b80 100644 --- a/packages/miniapp-taro/package.json +++ b/packages/miniapp-taro/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "description": "Authing miniapp JS SDK for Taro", "main": "dist/bundle-taro.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-uniapp/package.json b/packages/miniapp-uniapp/package.json index f70b2c50..b20edfa1 100644 --- a/packages/miniapp-uniapp/package.json +++ b/packages/miniapp-uniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "description": "Authing miniapp JS SDK for uniapp", "main": "dist/bundle-uniapp.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-wx/package.json b/packages/miniapp-wx/package.json index 20b881e0..68727bcf 100644 --- a/packages/miniapp-wx/package.json +++ b/packages/miniapp-wx/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "description": "Authing miniapp JS SDK for WX", "main": "dist/bundle-wx.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp/package-lock.json b/packages/miniapp/package-lock.json index b27e5589..cdbb35d5 100644 --- a/packages/miniapp/package-lock.json +++ b/packages/miniapp/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", diff --git a/packages/miniapp/package.json b/packages/miniapp/package.json index c14043ba..c47cb410 100644 --- a/packages/miniapp/package.json +++ b/packages/miniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "description": "Authing miniapp sdk source code", "main": "src/index.ts", "module": "src/index.ts", diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index e0249281..8f8f1537 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/web", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT", "dependencies": { "axios": "^0.26.1" diff --git a/packages/web/package.json b/packages/web/package.json index b061f101..dd1aa5c1 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "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 f3cf04ba..69cf5509 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.0.7-alpha.1", + "version": "5.0.7-alpha.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.1", + "version": "5.0.7-alpha.2", "license": "MIT" } } diff --git a/packages/weixin-official-account/package.json b/packages/weixin-official-account/package.json index 08a49523..0b0b545e 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.0.7-alpha.1", + "version": "5.0.7-alpha.2", "description": "Authing SDK for Weixin official account", "module": "dist/esm/weixin-official-account.min.js", "types": "dist/typings/index.d.ts", From 801b50d0d864eea2d2a3cd241371c9a38603bafd Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Thu, 29 Sep 2022 14:25:18 +0800 Subject: [PATCH 10/15] feat: adjust retry count --- packages/miniapp/src/Authing.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/miniapp/src/Authing.ts b/packages/miniapp/src/Authing.ts index 54dd0715..02742645 100644 --- a/packages/miniapp/src/Authing.ts +++ b/packages/miniapp/src/Authing.ts @@ -180,7 +180,7 @@ export class Authing { return loginRes } - if (retryCount === 0) { + if (retryCount <= 1) { retryCount += 1 return await login() } @@ -223,7 +223,7 @@ export class Authing { return loginRes } - if (retryCount === 0) { + if (retryCount <= 1) { retryCount += 1 return await login() } From 43f53afa0ffe26d84483c89d2961152dbcdc8727 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Thu, 29 Sep 2022 06:29:30 +0000 Subject: [PATCH 11/15] v5.0.7-alpha.3 --- lerna.json | 2 +- package-lock.json | 16 ++++++++-------- packages/miniapp-jsencrypt/package.json | 2 +- packages/miniapp-sm2encrypt/package-lock.json | 4 ++-- packages/miniapp-sm2encrypt/package.json | 2 +- packages/miniapp-taro/package.json | 2 +- packages/miniapp-uniapp/package.json | 2 +- packages/miniapp-wx/package.json | 2 +- packages/miniapp/package-lock.json | 4 ++-- packages/miniapp/package.json | 2 +- packages/web/package-lock.json | 4 ++-- packages/web/package.json | 2 +- .../weixin-official-account/package-lock.json | 4 ++-- packages/weixin-official-account/package.json | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lerna.json b/lerna.json index deed6229..29b026bf 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ "packages/*" ], "useWorkspaces": true, - "version": "5.0.7-alpha.2" + "version": "5.0.7-alpha.3" } diff --git a/package-lock.json b/package-lock.json index ca1cd0f6..82f7fa09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6824,7 +6824,7 @@ }, "packages/miniapp": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", @@ -6836,7 +6836,7 @@ }, "packages/miniapp-jsencrypt": { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT" }, "packages/miniapp-platform-taro": { @@ -6862,7 +6862,7 @@ }, "packages/miniapp-sm2encrypt": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" @@ -6870,17 +6870,17 @@ }, "packages/miniapp-taro": { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT" }, "packages/miniapp-uniapp": { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT" }, "packages/miniapp-wx": { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT" }, "packages/node": { @@ -6891,7 +6891,7 @@ }, "packages/web": { "name": "@authing/web", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT", "dependencies": { "axios": "^0.26.1" @@ -6927,7 +6927,7 @@ }, "packages/weixin-official-account": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT" } }, diff --git a/packages/miniapp-jsencrypt/package.json b/packages/miniapp-jsencrypt/package.json index ea2db7b0..613e2f29 100644 --- a/packages/miniapp-jsencrypt/package.json +++ b/packages/miniapp-jsencrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "description": "JavaScript encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-sm2encrypt/package-lock.json b/packages/miniapp-sm2encrypt/package-lock.json index d43ee43b..5a87a438 100644 --- a/packages/miniapp-sm2encrypt/package-lock.json +++ b/packages/miniapp-sm2encrypt/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" diff --git a/packages/miniapp-sm2encrypt/package.json b/packages/miniapp-sm2encrypt/package.json index c9301a4c..e60e6bfe 100644 --- a/packages/miniapp-sm2encrypt/package.json +++ b/packages/miniapp-sm2encrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "description": "JavaScript sm2 encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-taro/package.json b/packages/miniapp-taro/package.json index e0aa5b80..aad84683 100644 --- a/packages/miniapp-taro/package.json +++ b/packages/miniapp-taro/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "description": "Authing miniapp JS SDK for Taro", "main": "dist/bundle-taro.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-uniapp/package.json b/packages/miniapp-uniapp/package.json index b20edfa1..c2b62d61 100644 --- a/packages/miniapp-uniapp/package.json +++ b/packages/miniapp-uniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "description": "Authing miniapp JS SDK for uniapp", "main": "dist/bundle-uniapp.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-wx/package.json b/packages/miniapp-wx/package.json index 68727bcf..6d9737f3 100644 --- a/packages/miniapp-wx/package.json +++ b/packages/miniapp-wx/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "description": "Authing miniapp JS SDK for WX", "main": "dist/bundle-wx.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp/package-lock.json b/packages/miniapp/package-lock.json index cdbb35d5..13bce7cf 100644 --- a/packages/miniapp/package-lock.json +++ b/packages/miniapp/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", diff --git a/packages/miniapp/package.json b/packages/miniapp/package.json index c47cb410..b4b4d1ad 100644 --- a/packages/miniapp/package.json +++ b/packages/miniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "description": "Authing miniapp sdk source code", "main": "src/index.ts", "module": "src/index.ts", diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index 8f8f1537..c820650e 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/web", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT", "dependencies": { "axios": "^0.26.1" diff --git a/packages/web/package.json b/packages/web/package.json index dd1aa5c1..61cf1747 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "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 69cf5509..bc6ee5d6 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.0.7-alpha.2", + "version": "5.0.7-alpha.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.2", + "version": "5.0.7-alpha.3", "license": "MIT" } } diff --git a/packages/weixin-official-account/package.json b/packages/weixin-official-account/package.json index 0b0b545e..5db3340a 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.0.7-alpha.2", + "version": "5.0.7-alpha.3", "description": "Authing SDK for Weixin official account", "module": "dist/esm/weixin-official-account.min.js", "types": "dist/typings/index.d.ts", From 6fbd829c8878379db17fce7e2669111162541449 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Fri, 30 Sep 2022 20:32:49 +0800 Subject: [PATCH 12/15] fix(login): udpate loginByCode, cache wx login code --- packages/miniapp/src/Authing.ts | 100 ++++++++++++-------------------- 1 file changed, 38 insertions(+), 62 deletions(-) diff --git a/packages/miniapp/src/Authing.ts b/packages/miniapp/src/Authing.ts index 02742645..2d9e3856 100644 --- a/packages/miniapp/src/Authing.ts +++ b/packages/miniapp/src/Authing.ts @@ -18,7 +18,6 @@ import { UploadFileResponseData, LoginByCodeOptions, Maybe, - LoginByPhoneOptions, UpdateUserInfo } from './types' @@ -142,6 +141,7 @@ export class Authing { await next() } } catch (e) { + this.storage.remove(getWxLoginCodeKey(this.options.appId)) await next() } finally { return await this.getCachedWxLoginCode() @@ -159,80 +159,56 @@ export class Authing { const { extIdpConnidentifier, connection, wechatMiniProgramCodePayload, options } = data - let retryCount = 0 - - const login = async (): Promise> => { - const code = await this.resetWxLoginCode() - - const _data: WxCodeLoginOptions = { - connection: connection || 'wechat_mini_program_code', - extIdpConnidentifier, - wechatMiniProgramCodePayload: { - ...wechatMiniProgramCodePayload, - code - }, - options - } - - const loginRes = await this.login(_data, 'code') - - if (loginRes) { - return loginRes - } - - if (retryCount <= 1) { - retryCount += 1 - return await login() - } + const code = await this.resetWxLoginCode() + if (!code) { + error('loginByCode', 'get wx login code error') return null } - return await login() - } - - async loginByPhone( - data: LoginByPhoneOptions - ): Promise> { - const loginState = await this.getLoginState() - - if (loginState && loginState.expires_at > Date.now()) { - return loginState + const _data: WxCodeLoginOptions = { + connection: connection || 'wechat_mini_program_code', + extIdpConnidentifier, + wechatMiniProgramCodePayload: { + ...wechatMiniProgramCodePayload, + code + }, + options } - const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data - - let retryCount = 0 + return await this.login(_data, 'code') + } - const login = async (): Promise> => { - const code = await this.resetWxLoginCode() + // async loginByPhone( + // data: LoginByPhoneOptions + // ): Promise> { + // const loginState = await this.getLoginState() - const _data: WxPhoneLoginOptions = { - connection: connection || 'wechat_mini_program_phone', - extIdpConnidentifier, - wechatMiniProgramPhonePayload: { - ...wechatMiniProgramPhonePayload, - code - }, - options - } + // if (loginState && loginState.expires_at > Date.now()) { + // return loginState + // } - const loginRes = await this.login(_data, 'phone') + // const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data - if (loginRes) { - return loginRes - } + // const code = await this.resetWxLoginCode() - if (retryCount <= 1) { - retryCount += 1 - return await login() - } + // if (!code) { + // error('loginByPhone', 'get wx login code error') + // return null + // } - return null - } + // const _data: WxPhoneLoginOptions = { + // connection: connection || 'wechat_mini_program_phone', + // extIdpConnidentifier, + // wechatMiniProgramPhonePayload: { + // ...wechatMiniProgramPhonePayload, + // code + // }, + // options + // } - return await login() - } + // return await this.login(_data, 'phone') + // } async loginByPassword( data: PasswordLoginOptions From d1750dbb80769812d18e453e0d8e6d4bfdb8d823 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Fri, 30 Sep 2022 12:35:40 +0000 Subject: [PATCH 13/15] v5.0.7-alpha.4 --- lerna.json | 2 +- package-lock.json | 16 ++++++++-------- packages/miniapp-jsencrypt/package.json | 2 +- packages/miniapp-sm2encrypt/package-lock.json | 4 ++-- packages/miniapp-sm2encrypt/package.json | 2 +- packages/miniapp-taro/package.json | 2 +- packages/miniapp-uniapp/package.json | 2 +- packages/miniapp-wx/package.json | 2 +- packages/miniapp/package-lock.json | 4 ++-- packages/miniapp/package.json | 2 +- packages/web/package-lock.json | 4 ++-- packages/web/package.json | 2 +- .../weixin-official-account/package-lock.json | 4 ++-- packages/weixin-official-account/package.json | 2 +- 14 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lerna.json b/lerna.json index 29b026bf..99e5ea4a 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,5 @@ "packages/*" ], "useWorkspaces": true, - "version": "5.0.7-alpha.3" + "version": "5.0.7-alpha.4" } diff --git a/package-lock.json b/package-lock.json index 82f7fa09..d5fa4892 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6824,7 +6824,7 @@ }, "packages/miniapp": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", @@ -6836,7 +6836,7 @@ }, "packages/miniapp-jsencrypt": { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT" }, "packages/miniapp-platform-taro": { @@ -6862,7 +6862,7 @@ }, "packages/miniapp-sm2encrypt": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" @@ -6870,17 +6870,17 @@ }, "packages/miniapp-taro": { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT" }, "packages/miniapp-uniapp": { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT" }, "packages/miniapp-wx": { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT" }, "packages/node": { @@ -6891,7 +6891,7 @@ }, "packages/web": { "name": "@authing/web", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT", "dependencies": { "axios": "^0.26.1" @@ -6927,7 +6927,7 @@ }, "packages/weixin-official-account": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT" } }, diff --git a/packages/miniapp-jsencrypt/package.json b/packages/miniapp-jsencrypt/package.json index 613e2f29..b9de4a2d 100644 --- a/packages/miniapp-jsencrypt/package.json +++ b/packages/miniapp-jsencrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-jsencrypt", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "description": "JavaScript encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-sm2encrypt/package-lock.json b/packages/miniapp-sm2encrypt/package-lock.json index 5a87a438..98ed17f0 100644 --- a/packages/miniapp-sm2encrypt/package-lock.json +++ b/packages/miniapp-sm2encrypt/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT", "dependencies": { "jsbn": "^1.1.0" diff --git a/packages/miniapp-sm2encrypt/package.json b/packages/miniapp-sm2encrypt/package.json index e60e6bfe..d031c310 100644 --- a/packages/miniapp-sm2encrypt/package.json +++ b/packages/miniapp-sm2encrypt/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-sm2encrypt", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "description": "JavaScript sm2 encrypt module for miniapp", "main": "lib/index.js", "module": "lib/index.js", diff --git a/packages/miniapp-taro/package.json b/packages/miniapp-taro/package.json index aad84683..e5372a48 100644 --- a/packages/miniapp-taro/package.json +++ b/packages/miniapp-taro/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-taro", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "description": "Authing miniapp JS SDK for Taro", "main": "dist/bundle-taro.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-uniapp/package.json b/packages/miniapp-uniapp/package.json index c2b62d61..4abad7a0 100644 --- a/packages/miniapp-uniapp/package.json +++ b/packages/miniapp-uniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-uniapp", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "description": "Authing miniapp JS SDK for uniapp", "main": "dist/bundle-uniapp.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp-wx/package.json b/packages/miniapp-wx/package.json index 6d9737f3..7d67fb8f 100644 --- a/packages/miniapp-wx/package.json +++ b/packages/miniapp-wx/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp-wx", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "description": "Authing miniapp JS SDK for WX", "main": "dist/bundle-wx.js", "types": "dist/typings/src/index.d.ts", diff --git a/packages/miniapp/package-lock.json b/packages/miniapp/package-lock.json index 13bce7cf..cf30af9f 100644 --- a/packages/miniapp/package-lock.json +++ b/packages/miniapp/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/miniapp", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT", "dependencies": { "@authing/authingmove-api-proxy": "^1.0.1-alpha.14", diff --git a/packages/miniapp/package.json b/packages/miniapp/package.json index b4b4d1ad..2201afa7 100644 --- a/packages/miniapp/package.json +++ b/packages/miniapp/package.json @@ -1,6 +1,6 @@ { "name": "@authing/miniapp", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "description": "Authing miniapp sdk source code", "main": "src/index.ts", "module": "src/index.ts", diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index c820650e..891fe7a8 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/web", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT", "dependencies": { "axios": "^0.26.1" diff --git a/packages/web/package.json b/packages/web/package.json index 61cf1747..7244729d 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@authing/web", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "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 bc6ee5d6..8bcd11a7 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.0.7-alpha.3", + "version": "5.0.7-alpha.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@authing/weixin-official-account", - "version": "5.0.7-alpha.3", + "version": "5.0.7-alpha.4", "license": "MIT" } } diff --git a/packages/weixin-official-account/package.json b/packages/weixin-official-account/package.json index 5db3340a..596586e1 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.0.7-alpha.3", + "version": "5.0.7-alpha.4", "description": "Authing SDK for Weixin official account", "module": "dist/esm/weixin-official-account.min.js", "types": "dist/typings/index.d.ts", From 2e25940e04dcd52295343f6fa32431f8fde1eaa9 Mon Sep 17 00:00:00 2001 From: zhaoyiming0803 Date: Fri, 30 Sep 2022 20:39:58 +0800 Subject: [PATCH 14/15] test: run examples for version 5.0.7-alpha.4 --- .../@authing/miniapp-jsencrypt/index.js | 8 ++++---- .../@authing/miniapp-sm2encrypt/index.js | 18 +++++++++--------- .../@authing/miniapp-wx/index.js | 6 +++--- .../@authing/miniapp-wx/index.js.map | 2 +- .../miniapp/miniprogram_npm/jsbn/index.js | 4 ++-- examples/miniapp-wx/miniapp/package-lock.json | 14 +++++++------- examples/miniapp-wx/miniapp/package.json | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) 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 c6d11d0f..1d5adc7d 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__(1664336657652, function(require, module, exports) { +__DEFINE__(1664435123982, 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":1664336657653}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664336657653, function(require, module, exports) { +}, function(modId) {var map = {"./jsencrypt":1664435123983}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664435123983, 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__(1664336657652); +return __REQUIRE__(1664435123982); })() //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 09ef02ae..d2487e1b 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__(1664336657654, function(require, module, exports) { +__DEFINE__(1664435123984, 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":1664336657655}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664336657655, function(require, module, exports) { +}, function(modId) {var map = {"./sm2":1664435123985}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664435123985, 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":1664336657656,"./sm3":1664336657658}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664336657656, function(require, module, exports) { +}, function(modId) { var map = {"./utils":1664435123986,"./sm3":1664435123988}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664435123986, 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":1664336657657}; return __REQUIRE__(map[modId], modId); }) -__DEFINE__(1664336657657, function(require, module, exports) { +}, function(modId) { var map = {"./ec":1664435123987}; return __REQUIRE__(map[modId], modId); }) +__DEFINE__(1664435123987, 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__(1664336657658, function(require, module, exports) { +__DEFINE__(1664435123988, 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__(1664336657654); +return __REQUIRE__(1664435123984); })() //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 e007b3aa..cfd9e15f 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__(1664336657659, function(require, module, exports) { -var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{e:()=>K});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>I,chooseImage:()=>_,clearStorage:()=>m,getStorage:()=>w,getUserProfile:()=>O,login:()=>p,removeStorage:()=>b,request:()=>d,scanCode:()=>y,setStorage:()=>v,uploadFile:()=>S}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),"function"==typeof t.install?t.install.apply(t,o):"function"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function i(){return["wx","ali","baidu","qq","tt","jd","ks","qa_webview","qa_ux","Mpx","Taro","uni"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function s(t){console.error&&console.error(`[AuthingMove/api-proxy error in "wx"]:\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const l=c();function p(t={}){return l.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function y(t={}){return f.scanCode(t)}const g=c();function v(t={}){const e=u(t,{},{encrypt:!1});return g.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return g.getStorage(e)}function b(t={}){return g.removeStorage(t)}function m(t={}){return g.clearStorage(t)}const P=c();function _(t={}){return P.chooseMedia(t)}const x=c();function S(t={}){return x.uploadFile(t)}const k=c();function O(t={}){return k.getUserProfile(t)}const T=c();function I(t={}){return T.checkSession(t)}const C=i();const j=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((i=>{"function"==typeof o[i]?r[i]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),"string"==typeof r&&C[r]||(o.push(r),r=t.from));const u=function(t="",e=""){return`${C[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][i]?t.custom[u][i].apply(this,o):n[i]?n[i].apply(this,o):e[i]?e[i].apply(this,o):void s(`"${i}" method does not exist in the current context`)}:r[i]=o[i]})),r}({from:"wx",to:"wx",custom:o}),u=Object.assign({},r,function(t){const e=i();return Object.keys(t).reduce(((n,o)=>("function"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\w*Manager$/.test(t)||/^create\w*Context$/.test(t)||/^(on|off)/.test(t)||/\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let i;const s=new Promise(((e,s)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),s(t)},i=t[o].apply(j,n)}));return s.__returned=i,s}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if("function"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){s(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var E=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const L=JSON.parse('{"i8":"5.0.7-alpha.0"}');var F=function(){return F=Object.assign||function(t){for(var e,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]Date.now()?[2,e]:(U("getLoginState","loginState has expired, please login again"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return q(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(M(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return U("clearLoginState",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return e=$($({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(M(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return q(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:"GET",url:this.options.host+"/api/v3/system"})];case 1:return[2,e.sent()[t].publicKey];case 2:return U("getPublicKey",e.sent()),[2,""];case 3:return[2]}}))}))},t.prototype.loginByCode=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||"wechat_mini_program_code",extIdpConnidentifier:o,wechatMiniProgramCodePayload:$($({},s),{code:t}),options:a},[4,u.login(n,"code")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramCodePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPhone=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||"wechat_mini_program_phone",extIdpConnidentifier:o,wechatMiniProgramPhonePayload:$($({},s),{code:t}),options:a},[4,u.login(n,"phone")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramPhonePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return q(this,void 0,void 0,(function(){var r,i;return A(this,(function(s){switch(s.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&"none"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:(U("loginByPassword",'encryptFunction is required, if passwordEncryptType is not "none"'),[2,null]):[3,2];case 1:if(!(r=s.sent()))return U("loginByPassword","publicKey is invalid"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),s.label=2;case 2:return i=$($({},t),{connection:"PASSWORD"}),[4,this.login(i,"password")];case 3:return[2,s.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||"+86"),e=$($({},t),{connection:"PASSCODE"}),[4,this.login(e,"passCode")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return q(this,void 0,void 0,(function(){var t,e,n;return A(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||n{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{e:()=>K});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>T,chooseImage:()=>P,clearStorage:()=>x,getStorage:()=>w,getUserProfile:()=>C,login:()=>l,removeStorage:()=>b,request:()=>d,scanCode:()=>g,setStorage:()=>v,uploadFile:()=>_}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),"function"==typeof t.install?t.install.apply(t,o):"function"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function s(){return["wx","ali","baidu","qq","tt","jd","ks","qa_webview","qa_ux","Mpx","Taro","uni"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function i(t){console.error&&console.error(`[AuthingMove/api-proxy error in "wx"]:\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const p=c();function l(t={}){return p.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function g(t={}){return f.scanCode(t)}const y=c();function v(t={}){const e=u(t,{},{encrypt:!1});return y.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return y.getStorage(e)}function b(t={}){return y.removeStorage(t)}function x(t={}){return y.clearStorage(t)}const m=c();function P(t={}){return m.chooseMedia(t)}const S=c();function _(t={}){return S.uploadFile(t)}const k=c();function C(t={}){return k.getUserProfile(t)}const O=c();function T(t={}){return O.checkSession(t)}const I=s();const L=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((s=>{"function"==typeof o[s]?r[s]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),"string"==typeof r&&I[r]||(o.push(r),r=t.from));const u=function(t="",e=""){return`${I[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][s]?t.custom[u][s].apply(this,o):n[s]?n[s].apply(this,o):e[s]?e[s].apply(this,o):void i(`"${s}" method does not exist in the current context`)}:r[s]=o[s]})),r}({from:"wx",to:"wx",custom:o}),u=Object.assign({},r,function(t){const e=s();return Object.keys(t).reduce(((n,o)=>("function"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\w*Manager$/.test(t)||/^create\w*Context$/.test(t)||/^(on|off)/.test(t)||/\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let s;const i=new Promise(((e,i)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),i(t)},s=t[o].apply(L,n)}));return i.__returned=s,i}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if("function"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){i(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var j=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const E=JSON.parse('{"i8":"5.0.7-alpha.4"}');var F=function(){return F=Object.assign||function(t){for(var e,n=1,o=arguments.length;n0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]Date.now()?[2,e]:($("getLoginState","loginState has expired, please login again"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return A(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(U(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return $("clearLoginState",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return A(this,void 0,void 0,(function(){var e;return M(this,(function(n){switch(n.label){case 0:return e=q(q({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(U(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return A(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:"GET",url:this.options.host+"/api/v3/system"})];case 1:return[2,e.sent()[t].publicKey];case 2:return $("getPublicKey",e.sent()),[2,""];case 3:return[2]}}))}))},t.prototype.getCachedWxLoginCode=function(){return A(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.get(W(this.options.appId))];case 1:return[2,t.sent().data];case 2:return t.sent(),[2,""];case 3:return[2]}}))}))},t.prototype.cacheWxLoginCode=function(t){return A(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.storage.set(W(this.options.appId),t)];case 1:return e.sent(),[2,t];case 2:return $("cacheWxLoginCode",e.sent()),[2,""];case 3:return[2]}}))}))},t.prototype.resetWxLoginCode=function(){return A(this,void 0,void 0,(function(){var t,e=this;return M(this,(function(n){switch(n.label){case 0:t=function(){return A(e,void 0,void 0,(function(){var t;return M(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,r.login()];case 1:return t=e.sent(),[4,this.cacheWxLoginCode(t.code)];case 2:return e.sent(),[3,4];case 3:return $("resetWxLoginCode",e.sent()),[3,4];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,t()];case 4:n.sent(),n.label=5;case 5:return[3,10];case 6:return n.sent(),this.storage.remove(W(this.options.appId)),[4,t()];case 7:return n.sent(),[3,10];case 8:return[4,this.getCachedWxLoginCode()];case 9:return[2,n.sent()];case 10:return[2]}}))}))},t.prototype.loginByCode=function(t){return A(this,void 0,void 0,(function(){var e,n,o,r,s,i,a;return M(this,(function(u){switch(u.label){case 0:return[4,this.getLoginState()];case 1:return(e=u.sent())&&e.expires_at>Date.now()?[2,e]:(n=t.extIdpConnidentifier,o=t.connection,r=t.wechatMiniProgramCodePayload,s=t.options,[4,this.resetWxLoginCode()]);case 2:return(i=u.sent())?(a={connection:o||"wechat_mini_program_code",extIdpConnidentifier:n,wechatMiniProgramCodePayload:q(q({},r),{code:i}),options:s},[4,this.login(a,"code")]):($("loginByCode","get wx login code error"),[2,null]);case 3:return[2,u.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return A(this,void 0,void 0,(function(){var r,s;return M(this,(function(i){switch(i.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&"none"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:($("loginByPassword",'encryptFunction is required, if passwordEncryptType is not "none"'),[2,null]):[3,2];case 1:if(!(r=i.sent()))return $("loginByPassword","publicKey is invalid"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),i.label=2;case 2:return s=q(q({},t),{connection:"PASSWORD"}),[4,this.login(s,"password")];case 3:return[2,i.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return A(this,void 0,void 0,(function(){var e;return M(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||"+86"),e=q(q({},t),{connection:"PASSCODE"}),[4,this.login(e,"passCode")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return A(this,void 0,void 0,(function(){var t,e,n;return M(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||n{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})}},e={};t.d(e,{e:()=>K});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>I,chooseImage:()=>_,clearStorage:()=>m,getStorage:()=>w,getUserProfile:()=>O,login:()=>p,removeStorage:()=>b,request:()=>d,scanCode:()=>y,setStorage:()=>v,uploadFile:()=>S}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),\"function\"==typeof t.install?t.install.apply(t,o):\"function\"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function i(){return[\"wx\",\"ali\",\"baidu\",\"qq\",\"tt\",\"jd\",\"ks\",\"qa_webview\",\"qa_ux\",\"Mpx\",\"Taro\",\"uni\"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function s(t){console.error&&console.error(`[AuthingMove/api-proxy error in \"wx\"]:\\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const l=c();function p(t={}){return l.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function y(t={}){return f.scanCode(t)}const g=c();function v(t={}){const e=u(t,{},{encrypt:!1});return g.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return g.getStorage(e)}function b(t={}){return g.removeStorage(t)}function m(t={}){return g.clearStorage(t)}const P=c();function _(t={}){return P.chooseMedia(t)}const x=c();function S(t={}){return x.uploadFile(t)}const k=c();function O(t={}){return k.getUserProfile(t)}const T=c();function I(t={}){return T.checkSession(t)}const C=i();const j=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((i=>{\"function\"==typeof o[i]?r[i]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),\"string\"==typeof r&&C[r]||(o.push(r),r=t.from));const u=function(t=\"\",e=\"\"){return`${C[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][i]?t.custom[u][i].apply(this,o):n[i]?n[i].apply(this,o):e[i]?e[i].apply(this,o):void s(`\"${i}\" method does not exist in the current context`)}:r[i]=o[i]})),r}({from:\"wx\",to:\"wx\",custom:o}),u=Object.assign({},r,function(t){const e=i();return Object.keys(t).reduce(((n,o)=>(\"function\"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\\w*Manager$/.test(t)||/^create\\w*Context$/.test(t)||/^(on|off)/.test(t)||/\\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let i;const s=new Promise(((e,s)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),s(t)},i=t[o].apply(j,n)}));return s.__returned=i,s}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if(\"function\"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){s(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var E=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const L=JSON.parse('{\"i8\":\"5.0.7-alpha.0\"}');var F=function(){return F=Object.assign||function(t){for(var e,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]Date.now()?[2,e]:(U(\"getLoginState\",\"loginState has expired, please login again\"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return q(this,void 0,void 0,(function(){return A(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(M(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return U(\"clearLoginState\",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return e=$($({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(M(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return q(this,void 0,void 0,(function(){return A(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:\"GET\",url:this.options.host+\"/api/v3/system\"})];case 1:return[2,e.sent()[t].publicKey];case 2:return U(\"getPublicKey\",e.sent()),[2,\"\"];case 3:return[2]}}))}))},t.prototype.loginByCode=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||\"wechat_mini_program_code\",extIdpConnidentifier:o,wechatMiniProgramCodePayload:$($({},s),{code:t}),options:a},[4,u.login(n,\"code\")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramCodePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPhone=function(t){return q(this,void 0,void 0,(function(){function e(){return q(this,void 0,void 0,(function(){var t,n,l;return A(this,(function(p){switch(p.label){case 0:return[4,r.login()];case 1:return t=p.sent().code,n={connection:i||\"wechat_mini_program_phone\",extIdpConnidentifier:o,wechatMiniProgramPhonePayload:$($({},s),{code:t}),options:a},[4,u.login(n,\"phone\")];case 2:return(l=p.sent())?[2,l]:0!==c?[3,4]:(c+=1,[4,e()]);case 3:return[2,p.sent()];case 4:return[2,null]}}))}))}var n,o,i,s,a,u,c;return A(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(n=r.sent())&&n.expires_at>Date.now()?[2,n]:(o=t.extIdpConnidentifier,i=t.connection,s=t.wechatMiniProgramPhonePayload,a=t.options,u=this,c=0,[4,e()]);case 2:return[2,r.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return q(this,void 0,void 0,(function(){var r,i;return A(this,(function(s){switch(s.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&\"none\"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:(U(\"loginByPassword\",'encryptFunction is required, if passwordEncryptType is not \"none\"'),[2,null]):[3,2];case 1:if(!(r=s.sent()))return U(\"loginByPassword\",\"publicKey is invalid\"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),s.label=2;case 2:return i=$($({},t),{connection:\"PASSWORD\"}),[4,this.login(i,\"password\")];case 3:return[2,s.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return q(this,void 0,void 0,(function(){var e;return A(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||\"+86\"),e=$($({},t),{connection:\"PASSCODE\"}),[4,this.login(e,\"passCode\")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return q(this,void 0,void 0,(function(){var t,e,n;return A(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||n{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(t,\"__esModule\",{value:!0})}},e={};t.d(e,{e:()=>K});var n={};function o(){}t.r(n),t.d(n,{checkSession:()=>T,chooseImage:()=>P,clearStorage:()=>x,getStorage:()=>w,getUserProfile:()=>C,login:()=>l,removeStorage:()=>b,request:()=>d,scanCode:()=>g,setStorage:()=>v,uploadFile:()=>_}),function(t){!function(t){t.use=function(t,e={}){const n=this._installedPlugins||(this._installedPlugins=[]);if(n.indexOf(t)>-1)return this;const o=[e];return o.unshift(this),\"function\"==typeof t.install?t.install.apply(t,o):\"function\"==typeof t&&t.apply(null,o),n.push(t),this}}(t)}(o);const r=o;function s(){return[\"wx\",\"ali\",\"baidu\",\"qq\",\"tt\",\"jd\",\"ks\",\"qa_webview\",\"qa_ux\",\"Mpx\",\"Taro\",\"uni\"].reduce(((t,e)=>(t[`__authing_move_src_mode_${e}__`]=e,t)),{})}function i(t){console.error&&console.error(`[AuthingMove/api-proxy error in \"wx\"]:\\n ${t}`)}function a(){}function u(t,e={},n={}){let o={};return Object.keys(t).forEach((n=>{const r=e.hasOwnProperty(n)?e[n]:n;r&&(o[r]=t[n])})),o=Object.assign({},o,n),o}function c(){return wx}const p=c();function l(t={}){return p.login(t)}const h=c();function d(t={}){return h.request(t)}const f=c();function g(t={}){return f.scanCode(t)}const y=c();function v(t={}){const e=u(t,{},{encrypt:!1});return y.setStorage(e)}function w(t={}){const e=u(t,{},{encrypt:!1});return y.getStorage(e)}function b(t={}){return y.removeStorage(t)}function x(t={}){return y.clearStorage(t)}const m=c();function P(t={}){return m.chooseMedia(t)}const S=c();function _(t={}){return S.uploadFile(t)}const k=c();function C(t={}){return k.getUserProfile(t)}const O=c();function T(t={}){return O.checkSession(t)}const I=s();const L=c();r.use((function(t,e={}){const{custom:o={}}=e,r=function(t){const e=c(),o=Object.create(null);Object.keys(n).forEach((t=>{o[t]=e[t]||n[t]}));const r=Object.create(null);return Object.keys(o).forEach((s=>{\"function\"==typeof o[s]?r[s]=(...o)=>{let r=t.from;const a=t.to;o.length&&(r=o.pop(),\"string\"==typeof r&&I[r]||(o.push(r),r=t.from));const u=function(t=\"\",e=\"\"){return`${I[`__authing_move_src_mode_${t}__`]}_${e}`}(r,a);return t.custom[u]&&t.custom[u][s]?t.custom[u][s].apply(this,o):n[s]?n[s].apply(this,o):e[s]?e[s].apply(this,o):void i(`\"${s}\" method does not exist in the current context`)}:r[s]=o[s]})),r}({from:\"wx\",to:\"wx\",custom:o}),u=Object.assign({},r,function(t){const e=s();return Object.keys(t).reduce(((n,o)=>(\"function\"!=typeof t[o]||(n[o]=function(...n){if(function(t){return/^get\\w*Manager$/.test(t)||/^create\\w*Context$/.test(t)||/^(on|off)/.test(t)||/\\w+Sync$/.test(t)}(o))return t[o].apply(t,n);n[0]&&!e[n[0]]||n.unshift({success:a,fail:a});const r=n[0];let s;const i=new Promise(((e,i)=>{const a=r.success,u=r.fail;r.success=function(t){a&&a.call(this,t),e(t)},r.fail=function(t){u&&u.call(this,t),i(t)},s=t[o].apply(L,n)}));return i.__returned=s,i}),n)),{})}(r));Object.keys(u).forEach((e=>{try{if(\"function\"!=typeof u[e])return void(t[e]=u[e]);t[e]=(...n)=>u[e].apply(t,n)}catch(n){i(`Call ${t}.${e} error:`+JSON.stringify(n))}}))}));var j=function(){function t(){}return t.prototype.get=function(t){return r.getStorage({key:t})},t.prototype.set=function(t,e){return r.setStorage({key:t,data:e})},t.prototype.remove=function(t){return r.removeStorage({key:t})},t}();const E=JSON.parse('{\"i8\":\"5.0.7-alpha.4\"}');var F=function(){return F=Object.assign||function(t){for(var e,n=1,o=arguments.length;n0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]0&&r[r.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]Date.now()?[2,e]:($(\"getLoginState\",\"loginState has expired, please login again\"),[2,null]);case 2:return n.sent(),[2,null];case 3:return[2]}}))}))},t.prototype.clearLoginState=function(){return A(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.remove(U(this.options.appId))];case 1:return t.sent(),[2,!0];case 2:return $(\"clearLoginState\",t.sent()),[2,!1];case 3:return[2]}}))}))},t.prototype.saveLoginState=function(t){return A(this,void 0,void 0,(function(){var e;return M(this,(function(n){switch(n.label){case 0:return e=q(q({},t),{expires_at:1e3*t.expires_in+Date.now()-72e5}),[4,this.storage.set(U(this.options.appId),e)];case 1:return n.sent(),[2,e]}}))}))},t.prototype.getPublicKey=function(t){return A(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,D({method:\"GET\",url:this.options.host+\"/api/v3/system\"})];case 1:return[2,e.sent()[t].publicKey];case 2:return $(\"getPublicKey\",e.sent()),[2,\"\"];case 3:return[2]}}))}))},t.prototype.getCachedWxLoginCode=function(){return A(this,void 0,void 0,(function(){return M(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.storage.get(W(this.options.appId))];case 1:return[2,t.sent().data];case 2:return t.sent(),[2,\"\"];case 3:return[2]}}))}))},t.prototype.cacheWxLoginCode=function(t){return A(this,void 0,void 0,(function(){return M(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.storage.set(W(this.options.appId),t)];case 1:return e.sent(),[2,t];case 2:return $(\"cacheWxLoginCode\",e.sent()),[2,\"\"];case 3:return[2]}}))}))},t.prototype.resetWxLoginCode=function(){return A(this,void 0,void 0,(function(){var t,e=this;return M(this,(function(n){switch(n.label){case 0:t=function(){return A(e,void 0,void 0,(function(){var t;return M(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,r.login()];case 1:return t=e.sent(),[4,this.cacheWxLoginCode(t.code)];case 2:return e.sent(),[3,4];case 3:return $(\"resetWxLoginCode\",e.sent()),[3,4];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,t()];case 4:n.sent(),n.label=5;case 5:return[3,10];case 6:return n.sent(),this.storage.remove(W(this.options.appId)),[4,t()];case 7:return n.sent(),[3,10];case 8:return[4,this.getCachedWxLoginCode()];case 9:return[2,n.sent()];case 10:return[2]}}))}))},t.prototype.loginByCode=function(t){return A(this,void 0,void 0,(function(){var e,n,o,r,s,i,a;return M(this,(function(u){switch(u.label){case 0:return[4,this.getLoginState()];case 1:return(e=u.sent())&&e.expires_at>Date.now()?[2,e]:(n=t.extIdpConnidentifier,o=t.connection,r=t.wechatMiniProgramCodePayload,s=t.options,[4,this.resetWxLoginCode()]);case 2:return(i=u.sent())?(a={connection:o||\"wechat_mini_program_code\",extIdpConnidentifier:n,wechatMiniProgramCodePayload:q(q({},r),{code:i}),options:s},[4,this.login(a,\"code\")]):($(\"loginByCode\",\"get wx login code error\"),[2,null]);case 3:return[2,u.sent()]}}))}))},t.prototype.loginByPassword=function(t){var e,n,o;return A(this,void 0,void 0,(function(){var r,s;return M(this,(function(i){switch(i.label){case 0:return(null===(e=t.options)||void 0===e?void 0:e.passwordEncryptType)&&\"none\"!==(null===(n=t.options)||void 0===n?void 0:n.passwordEncryptType)?this.encryptFunction?[4,this.getPublicKey(null===(o=t.options)||void 0===o?void 0:o.passwordEncryptType)]:($(\"loginByPassword\",'encryptFunction is required, if passwordEncryptType is not \"none\"'),[2,null]):[3,2];case 1:if(!(r=i.sent()))return $(\"loginByPassword\",\"publicKey is invalid\"),[2,null];t.passwordPayload.password=this.encryptFunction(t.passwordPayload.password,r),i.label=2;case 2:return s=q(q({},t),{connection:\"PASSWORD\"}),[4,this.login(s,\"password\")];case 3:return[2,i.sent()]}}))}))},t.prototype.loginByPassCode=function(t){return A(this,void 0,void 0,(function(){var e;return M(this,(function(n){switch(n.label){case 0:return t.passCodePayload.phone&&(t.passCodePayload.phoneCountryCode=t.passCodePayload.phoneCountryCode||\"+86\"),e=q(q({},t),{connection:\"PASSCODE\"}),[4,this.login(e,\"passCode\")];case 1:return[2,n.sent()]}}))}))},t.prototype.logout=function(){return A(this,void 0,void 0,(function(){var t,e,n;return M(this,(function(o){switch(o.label){case 0:return[4,this.getLoginState()];case 1:return(t=o.sent())?(e=t.access_token,n=t.expires_at,!e||n Date: Fri, 30 Sep 2022 20:42:17 +0800 Subject: [PATCH 15/15] chore: delete useless codes --- .../miniapp-wx/miniapp/pages/index/index.ts | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/examples/miniapp-wx/miniapp/pages/index/index.ts b/examples/miniapp-wx/miniapp/pages/index/index.ts index 0be5f155..3de7ba20 100644 --- a/examples/miniapp-wx/miniapp/pages/index/index.ts +++ b/examples/miniapp-wx/miniapp/pages/index/index.ts @@ -38,26 +38,6 @@ Page({ console.log('authing.loginByCode res: ', res) }, - async loginByPhone () { - const { encryptedData, iv } = await wx.getUserProfile({ - desc: 'getUserProfile1' - }) - - const res = await authing.loginByPhone({ - connection: 'wechat_mini_program_phone', - extIdpConnidentifier: 'authing-zhaoyiming-miniprogram', - wechatMiniProgramPhonePayload: { - encryptedData, - iv - }, - options: { - scope: 'openid profile offline_access' - } - }) - - console.log('authing.loginByPhone res: ', res) - }, - /** * 需要在真机上测试,微信开发者工具不会返回 code * @param {*} e