message: fix(login): udpate loginByCode, cache wx login code
diff: @@ -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,11 +159,13 @@ export class Authing {
  const { extIdpConnidentifier, connection, wechatMiniProgramCodePayload, options } = data
  - let retryCount = 0
  -
  - const login = async (): Promise<Maybe<LoginState>> => {
  const code = await this.resetWxLoginCode()
  + if (!code) {
  + error('loginByCode', 'get wx login code error')
  + return null
  + }
  +
  const _data: WxCodeLoginOptions = {
  connection: connection || 'wechat_mini_program_code',
  extIdpConnidentifier,
  @@ -174,65 +176,39 @@ export class Authing {
  options
  }
  - const loginRes = await this.login(_data, 'code')
  -
  - if (loginRes) {
  - return loginRes
  + return await this.login(_data, 'code')
  }
  - if (retryCount <= 1) {
  - retryCount += 1
  - return await login()
  - }
  + // async loginByPhone(
  + // data: LoginByPhoneOptions
  + // ): Promise<Maybe<LoginState>> {
  + // const loginState = await this.getLoginState()
  - return null
  - }
  + // if (loginState && loginState.expires_at > Date.now()) {
  + // return loginState
  + // }
  - return await login()
  - }
  -
  - async loginByPhone(
  - data: LoginByPhoneOptions
  - ): Promise<Maybe<LoginState>> {
  - const loginState = await this.getLoginState()
  + // const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data
  - if (loginState && loginState.expires_at > Date.now()) {
  - return loginState
  - }
  + // const code = await this.resetWxLoginCode()
  - const { extIdpConnidentifier, connection, wechatMiniProgramPhonePayload, options } = data
  + // if (!code) {
  + // error('loginByPhone', 'get wx login code error')
  + // return null
  + // }
  - let retryCount = 0
  + // const _data: WxPhoneLoginOptions = {
  + // connection: connection || 'wechat_mini_program_phone',
  + // extIdpConnidentifier,
  + // wechatMiniProgramPhonePayload: {
  + // ...wechatMiniProgramPhonePayload,
  + // code
  + // },
  + // options
  + // }
  - const login = async (): Promise<Maybe<LoginState>> => {
  - const code = await this.resetWxLoginCode()
  -
  - const _data: WxPhoneLoginOptions = {
  - connection: connection || 'wechat_mini_program_phone',
  - extIdpConnidentifier,
  - wechatMiniProgramPhonePayload: {
  - ...wechatMiniProgramPhonePayload,
  - code
  - },
  - options
  - }
  -
  - const loginRes = await this.login(_data, 'phone')
  -
  - if (loginRes) {
  - return loginRes
  - }
  -
  - if (retryCount <= 1) {
  - retryCount += 1
  - return await login()
  - }
  -
  - return null
  - }
  -
  - return await login()
  - }
  + // return await this.login(_data, 'phone')
  + // }
  async loginByPassword(
  data: PasswordLoginOptions
  