@alipay/ams-checkout 0.0.1708315090-dev.6 → 0.0.1708315090-dev.7

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.
@@ -222,7 +222,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
222
222
  var _this3 = this;
223
223
  this.channelType = channelType;
224
224
  this.productSceneVersion = productSceneVersion;
225
- var MAX_CLEAR_TIME = 90000;
225
+ var MAX_CLEAR_TIME = 10000;
226
226
  if (Array.isArray(channelType)) {
227
227
  for (var i = 0; i < channelType.length; i++) {
228
228
  this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
@@ -22,6 +22,7 @@ import { queryPaymentInfo, submitPayInfo } from "../../service";
22
22
  import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
23
23
  import { getType, isJsonString, isPC } from "../../util";
24
24
  import { isLocalMock } from "../../util/mock";
25
+ import { matchVersion } from "../../util/versionCompare";
25
26
  import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
27
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
27
28
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
@@ -347,7 +348,6 @@ var ComponentApp = /*#__PURE__*/function () {
347
348
  return Promise.reject(error);
348
349
  });
349
350
  }
350
-
351
351
  /**
352
352
  * @description Interface request
353
353
  */
@@ -364,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
364
364
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
365
365
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
366
366
  var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
367
- var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, extendInfoData, _this5$_renderParams6, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams7, _action$web, _action$wap, action, signType;
367
+ var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, _this5$_renderParams$2, skipSdkQuery, skipSdkQueryConfig, extendInfoData, ifSkip, _this5$_renderParams6, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams7, _action$web, _action$wap, action, signType;
368
368
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
369
369
  while (1) switch (_context2.prev = _context2.next) {
370
370
  case 0:
@@ -382,93 +382,128 @@ var ComponentApp = /*#__PURE__*/function () {
382
382
  */
383
383
  _this5$_renderParams$ = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData, extendInfo = _this5$_renderParams$.extendInfo;
384
384
  enableVaultingApiOptimize = false;
385
+ enableEasypayApiOptimize = false;
386
+ _this5$_renderParams$2 = (_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action, skipSdkQuery = _this5$_renderParams$2.skipSdkQuery, skipSdkQueryConfig = _this5$_renderParams$2.skipSdkQueryConfig;
385
387
  try {
386
388
  extendInfoData = JSON.parse(extendInfo);
387
389
  enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
390
+ enableEasypayApiOptimize = extendInfoData.enableEasypayApiOptimize || false;
388
391
  } catch (error) {
389
392
  console.log(error);
390
393
  }
394
+ /**
395
+ * @description Simulated or unnecessary scenarios
396
+ */
391
397
  if (!isLocalMock()) {
392
- _context2.next = 7;
398
+ _context2.next = 9;
393
399
  break;
394
400
  }
395
401
  return _context2.abrupt("return", resolve({
396
402
  message: 'sdk no need to make query request',
397
403
  success: true
398
404
  }));
399
- case 7:
400
- if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign && (_this5$_renderParams5 = _this5._renderParams) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.action) !== null && _this5$_renderParams5 !== void 0 && _this5$_renderParams5.skipSdkQuery && enableVaultingApiOptimize)) {
401
- _context2.next = 9;
405
+ case 9:
406
+ if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
407
+ _context2.next = 17;
408
+ break;
409
+ }
410
+ if (!(skipSdkQueryConfig && enableVaultingApiOptimize)) {
411
+ _context2.next = 15;
412
+ break;
413
+ }
414
+ // 优先判断skipSdkQueryConfig
415
+ ifSkip = matchVersion(skipSdkQueryConfig, _this5._appVersion);
416
+ if (!ifSkip) {
417
+ _context2.next = 15;
418
+ break;
419
+ }
420
+ resolve({
421
+ message: 'sdk no need to make query request',
422
+ success: true
423
+ });
424
+ return _context2.abrupt("return");
425
+ case 15:
426
+ if (!(skipSdkQuery && enableVaultingApiOptimize)) {
427
+ _context2.next = 17;
402
428
  break;
403
429
  }
404
430
  return _context2.abrupt("return", resolve({
405
431
  message: 'sdk no need to make query request',
406
432
  success: true
407
433
  }));
408
- case 9:
434
+ case 17:
409
435
  if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
410
- _context2.next = 15;
436
+ _context2.next = 23;
411
437
  break;
412
438
  }
413
439
  params.paymentMethodType = 'CARD';
414
- _context2.next = 13;
440
+ _context2.next = 21;
415
441
  return _this5.getDeviceIdAndLog();
416
- case 13:
442
+ case 21:
417
443
  envInfo.deviceId = _context2.sent;
418
444
  if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
419
445
  envInfo.extendInfo = {
420
446
  WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
421
447
  };
422
448
  }
423
- case 15:
449
+ case 23:
424
450
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
425
- _context2.next = 23;
451
+ _context2.next = 33;
426
452
  break;
427
453
  }
428
454
  _ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
429
- _ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
455
+ _ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb; // easyPay跳过actionQuery接口
456
+ if (!(skipSdkQuery && enableEasypayApiOptimize)) {
457
+ _context2.next = 28;
458
+ break;
459
+ }
460
+ return _context2.abrupt("return", resolve({
461
+ message: 'sdk no need to make query request',
462
+ success: true
463
+ }));
464
+ case 28:
430
465
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
431
- _context2.next = 20;
466
+ _context2.next = 30;
432
467
  break;
433
468
  }
434
469
  return _context2.abrupt("return", resolve({
435
470
  message: 'sdk no need to make query request',
436
471
  success: true
437
472
  }));
438
- case 20:
439
- _context2.next = 22;
473
+ case 30:
474
+ _context2.next = 32;
440
475
  return _this5.getDeviceIdAndLog();
441
- case 22:
476
+ case 32:
442
477
  envInfo.deviceId = _context2.sent;
443
- case 23:
478
+ case 33:
444
479
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
445
- _context2.next = 33;
480
+ _context2.next = 43;
446
481
  break;
447
482
  }
448
483
  action = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 || (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.action) || {};
449
484
  signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
450
485
  if (!(signType === 'SMS')) {
451
- _context2.next = 28;
486
+ _context2.next = 38;
452
487
  break;
453
488
  }
454
489
  return _context2.abrupt("return", resolve({
455
490
  message: 'sdk no need to make query request',
456
491
  success: true
457
492
  }));
458
- case 28:
493
+ case 38:
459
494
  if (!(!signType || signType !== 'REDIRECT')) {
460
- _context2.next = 30;
495
+ _context2.next = 40;
461
496
  break;
462
497
  }
463
498
  return _context2.abrupt("return", resolve({
464
499
  success: false
465
500
  }));
466
- case 30:
467
- _context2.next = 32;
501
+ case 40:
502
+ _context2.next = 42;
468
503
  return _this5.getDeviceIdAndLog();
469
- case 32:
504
+ case 42:
470
505
  envInfo.deviceId = _context2.sent;
471
- case 33:
506
+ case 43:
472
507
  _this5.AMSSDK.logger.logInfo({
473
508
  title: 'sdk_event_sdkQuery'
474
509
  }, {
@@ -500,7 +535,7 @@ var ComponentApp = /*#__PURE__*/function () {
500
535
  paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
501
536
  }).send();
502
537
  });
503
- case 35:
538
+ case 45:
504
539
  case "end":
505
540
  return _context2.stop();
506
541
  }
@@ -133,6 +133,11 @@ export interface IpaymentSessionMetaData {
133
133
  action?: {
134
134
  autoDebitWithToken: boolean;
135
135
  skipSdkQuery: boolean;
136
+ skipSdkQueryConfig?: {
137
+ value: boolean;
138
+ version: string;
139
+ platform: string;
140
+ };
136
141
  };
137
142
  paymentSessionFactor?: {
138
143
  applePay?: {
@@ -8,3 +8,5 @@
8
8
  * @param v2
9
9
  */
10
10
  export declare function compareVersion(v1: string, v2: string): 1 | -1 | 0;
11
+ export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
12
+ export declare function matchVersion(config: any, currentVersion: any): boolean;
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  /**
2
8
  * @author 谦彧 <zhangmian.zm@alipay.com>
3
9
  * @date 2023/11/1
@@ -47,4 +53,71 @@ export function compareVersion(v1, v2) {
47
53
  } else {
48
54
  return 1;
49
55
  }
56
+ }
57
+ export function isVersionInRange(currentVersion, minVersion, maxVersion) {
58
+ function splitVersion(version) {
59
+ return version.split('.').map(function (num) {
60
+ return parseInt(num, 10);
61
+ });
62
+ }
63
+ function compareVersions(v1, v2) {
64
+ for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
65
+ var num1 = v1[i] === undefined ? 0 : v1[i];
66
+ var num2 = v2[i] === undefined ? 0 : v2[i];
67
+ if (num1 > num2) return 1;
68
+ if (num1 < num2) return -1;
69
+ }
70
+ return 0;
71
+ }
72
+ var current = splitVersion(currentVersion);
73
+ var min = minVersion ? splitVersion(minVersion) : null;
74
+ var max = maxVersion ? splitVersion(maxVersion) : null;
75
+ if (min && compareVersions(current, min) < 0) {
76
+ // 当前版本小于最小允许版本
77
+ return false;
78
+ }
79
+ if (max && compareVersions(current, max) > 0) {
80
+ // 当前版本大于最大允许版本
81
+ return false;
82
+ }
83
+ // 当前版本在允许的版本范围内
84
+ return true;
85
+ }
86
+ export function matchVersion(config, currentVersion) {
87
+ var value = config.value,
88
+ version = config.version,
89
+ platform = config.platform;
90
+ var CURRENT_PLATFORM = 'WEB';
91
+ var isMatchVersion = false;
92
+ var isMatchPlatform = false;
93
+
94
+ // 平台判断
95
+ if (platform) {
96
+ var platformList = platform.split('|').map(function (platform) {
97
+ return platform.toLocaleUpperCase();
98
+ });
99
+ isMatchPlatform = platformList.includes(CURRENT_PLATFORM);
100
+ } else {
101
+ // 没有表示平台全匹配
102
+ isMatchPlatform = true;
103
+ }
104
+ // 版本判断
105
+ if (!version) {
106
+ // 为空全匹配
107
+ isMatchVersion = true;
108
+ } else if (version.indexOf('|') !== -1) {
109
+ // | 范围匹配
110
+ var _version$split = version.split('|'),
111
+ _version$split2 = _slicedToArray(_version$split, 2),
112
+ _version$split2$ = _version$split2[0],
113
+ minVersion = _version$split2$ === void 0 ? '' : _version$split2$,
114
+ _version$split2$2 = _version$split2[1],
115
+ maxVersion = _version$split2$2 === void 0 ? '' : _version$split2$2;
116
+ isMatchVersion = isVersionInRange(currentVersion, minVersion, maxVersion);
117
+ } else if (version.indexOf(',') !== -1) {
118
+ // , 枚举匹配
119
+ var versionList = version.split(',');
120
+ isMatchVersion = versionList.includes(currentVersion);
121
+ }
122
+ return value && isMatchPlatform && isMatchVersion;
50
123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1708315090-dev.6",
3
+ "version": "0.0.1708315090-dev.7",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",