hylid-bridge 6.4.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import fill from '../../../common/apis/custom/web/h5/getSystemInfo';
1
+ import fill from '../../../common/apis/custom/web/kaspi/getSystemInfo';
2
2
  export default fill;
@@ -1,3 +1,3 @@
1
1
  // auto-generated
2
- import fill from '../../../common/apis/custom/web/h5/getSystemInfo';
2
+ import fill from '../../../common/apis/custom/web/kaspi/getSystemInfo';
3
3
  export default fill;
@@ -195,14 +195,14 @@ var authLoginPromise;
195
195
  var checkIsLoginPromise = null;
196
196
  var sendLoginHttp = function sendLoginHttp(params) {
197
197
  return __awaiter(void 0, void 0, void 0, function () {
198
- var sessionIdPreTime, clientKeyPreTime, httpRequest, getAuthParams, saveAuthParams, getAuthCode, getAppId, siteName, AUTH_LOGIN, tokenRes, token, requestParams, appId, authCodeRes, httpParams, signData, res, walletAuthCodeRes, _requestParams, _httpParams, _signData;
198
+ var sessionIdPreTime, clientKeyPreTime, httpRequest, getAuthParams, saveAuthParams, getAuthCode, getAppId, siteName, _loginModeBase, AUTH_LOGIN, tokenRes, token, requestParams, appId, authCodeRes, httpParams, signData, res, walletAuthCodeRes, _requestParams, _httpParams, _signData;
199
199
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
200
200
  return __generator(this, function (_k) {
201
201
  switch (_k.label) {
202
202
  case 0:
203
203
  sessionIdPreTime = 60 * 1000;
204
204
  clientKeyPreTime = 3600 * 1000;
205
- httpRequest = params.httpRequest, getAuthParams = params.getAuthParams, saveAuthParams = params.saveAuthParams, getAuthCode = params.getAuthCode, getAppId = params.getAppId, siteName = params.siteName;
205
+ httpRequest = params.httpRequest, getAuthParams = params.getAuthParams, saveAuthParams = params.saveAuthParams, getAuthCode = params.getAuthCode, getAppId = params.getAppId, siteName = params.siteName, _loginModeBase = params._loginModeBase;
206
206
  AUTH_LOGIN = authLoginApiMap[siteName];
207
207
  _k.label = 1;
208
208
  case 1:
@@ -238,7 +238,7 @@ var sendLoginHttp = function sendLoginHttp(params) {
238
238
  }
239
239
  requestParams.authCode = authCodeRes.authCode || '';
240
240
  if (siteName === "HUAWEI_ATOMIC") {
241
- requestParams.loginMode = "AUTH_LOGIN";
241
+ requestParams.loginMode = _loginModeBase ? _loginModeBase : "GUEST_LOGIN";
242
242
  requestParams.trafficSideId = authCodeRes.trafficSideId;
243
243
  }
244
244
  httpParams = {
@@ -326,28 +326,34 @@ var sendLoginHttp = function sendLoginHttp(params) {
326
326
  * @param saveAuthParams 保持auth相关参数
327
327
  * @param getAuthCode 获取系统AuthCode
328
328
  * @param getAppId 获取小程序的appId
329
+ * @param _loginModeBase 外部传过来的登录模式
329
330
  */
330
331
  export var checkIsLogin = function checkIsLogin(params) {
331
332
  return __awaiter(void 0, void 0, void 0, function () {
332
- var _a, isForceLogin, getAuthParams, authParamsRes, _b, sessionIdExpiresTime, sessionIdLastTime;
333
+ var _a, isForceLogin, getAuthParams, _loginModeBase, authParamsRes, _b, sessionIdExpiresTime, sessionIdLastTime, hasValidSession;
333
334
  return __generator(this, function (_c) {
334
335
  switch (_c.label) {
335
336
  case 0:
336
- _a = params.isForceLogin, isForceLogin = _a === void 0 ? false : _a, getAuthParams = params.getAuthParams;
337
+ _a = params.isForceLogin, isForceLogin = _a === void 0 ? false : _a, getAuthParams = params.getAuthParams, _loginModeBase = params._loginModeBase;
337
338
  return [4 /*yield*/, getAuthParams()];
338
339
  case 1:
339
340
  authParamsRes = _c.sent();
340
341
  _b = authParamsRes.data || {}, sessionIdExpiresTime = _b.sessionIdExpiresTime, sessionIdLastTime = _b.sessionIdLastTime;
341
- // 如果sessionId未过期
342
- if (!isForceLogin && sessionIdLastTime && sessionIdExpiresTime && Date.now() - sessionIdLastTime < sessionIdExpiresTime) {
342
+ hasValidSession = !isForceLogin && sessionIdLastTime && sessionIdExpiresTime && Date.now() - sessionIdLastTime < sessionIdExpiresTime;
343
+ if (hasValidSession && !_loginModeBase) {
343
344
  return [2 /*return*/];
344
345
  }
345
346
  if (client === CLIENT.HUAWEI_ATOMIC) {
346
- // 如果已有正在执行的checkIsLogin,直接返回共享的Promise
347
+ // 如果已有正在执行的checkIsLogin,且不需要切换登录模式,直接返回共享的Promise
347
348
  // 所有并发请求等待同一个结果:成功则继续,超时/失败则都被拦截
348
- if (checkIsLoginPromise) {
349
+ if (checkIsLoginPromise && !_loginModeBase) {
349
350
  return [2 /*return*/, checkIsLoginPromise];
350
351
  }
352
+ // _loginModeBase存在时,废弃旧的登录Promise,强制重新执行
353
+ if (_loginModeBase) {
354
+ authLoginPromise = undefined;
355
+ checkIsLoginPromise = null;
356
+ }
351
357
  // 用Promise包起整个登录流程,所有并发请求共享同一个Promise
352
358
  checkIsLoginPromise = new Promise(function (resolve, reject) {
353
359
  authLoginPromise = authLoginPromise || sendLoginHttp(params);
@@ -357,7 +363,8 @@ export var checkIsLogin = function checkIsLogin(params) {
357
363
  resolve();
358
364
  }).catch(function (error) {
359
365
  // getAuthCode授权超时,拦截所有排队的接口请求
360
- if (error.errorCode !== "GET_WALLET_AUTHCODE_TIMEOUT") {
366
+ // _loginModeBase 参数存在时,超时需要释放锁,不然会导致第二次无法发起
367
+ if (error.errorCode !== "GET_WALLET_AUTHCODE_TIMEOUT" || _loginModeBase) {
361
368
  // 非超时授权异常解锁,允许后续新的登录请求
362
369
  checkIsLoginPromise = null;
363
370
  }