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

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.
@@ -22,7 +22,6 @@ 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";
26
25
  import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
27
26
  import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
28
27
  import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
@@ -348,6 +347,7 @@ var ComponentApp = /*#__PURE__*/function () {
348
347
  return Promise.reject(error);
349
348
  });
350
349
  }
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, 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;
367
+ var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _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:
@@ -383,7 +383,6 @@ var ComponentApp = /*#__PURE__*/function () {
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
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;
387
386
  try {
388
387
  extendInfoData = JSON.parse(extendInfo);
389
388
  enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
@@ -391,119 +390,96 @@ var ComponentApp = /*#__PURE__*/function () {
391
390
  } catch (error) {
392
391
  console.log(error);
393
392
  }
394
- /**
395
- * @description Simulated or unnecessary scenarios
396
- */
397
393
  if (!isLocalMock()) {
398
- _context2.next = 9;
394
+ _context2.next = 8;
399
395
  break;
400
396
  }
401
397
  return _context2.abrupt("return", resolve({
402
398
  message: 'sdk no need to make query request',
403
399
  success: true
404
400
  }));
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;
401
+ case 8:
402
+ 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)) {
403
+ _context2.next = 10;
428
404
  break;
429
405
  }
430
406
  return _context2.abrupt("return", resolve({
431
407
  message: 'sdk no need to make query request',
432
408
  success: true
433
409
  }));
434
- case 17:
410
+ case 10:
435
411
  if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
436
- _context2.next = 23;
412
+ _context2.next = 16;
437
413
  break;
438
414
  }
439
415
  params.paymentMethodType = 'CARD';
440
- _context2.next = 21;
416
+ _context2.next = 14;
441
417
  return _this5.getDeviceIdAndLog();
442
- case 21:
418
+ case 14:
443
419
  envInfo.deviceId = _context2.sent;
444
420
  if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
445
421
  envInfo.extendInfo = {
446
422
  WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
447
423
  };
448
424
  }
449
- case 23:
425
+ case 16:
450
426
  if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
451
- _context2.next = 33;
427
+ _context2.next = 26;
452
428
  break;
453
429
  }
454
430
  _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;
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;
431
+ _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;
432
+ if (!((_this5$_renderParams7 = _this5._renderParams) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.action) !== null && _this5$_renderParams7 !== void 0 && _this5$_renderParams7.skipSdkQuery && enableEasypayApiOptimize)) {
433
+ _context2.next = 21;
458
434
  break;
459
435
  }
460
436
  return _context2.abrupt("return", resolve({
461
437
  message: 'sdk no need to make query request',
462
438
  success: true
463
439
  }));
464
- case 28:
440
+ case 21:
465
441
  if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
466
- _context2.next = 30;
442
+ _context2.next = 23;
467
443
  break;
468
444
  }
469
445
  return _context2.abrupt("return", resolve({
470
446
  message: 'sdk no need to make query request',
471
447
  success: true
472
448
  }));
473
- case 30:
474
- _context2.next = 32;
449
+ case 23:
450
+ _context2.next = 25;
475
451
  return _this5.getDeviceIdAndLog();
476
- case 32:
452
+ case 25:
477
453
  envInfo.deviceId = _context2.sent;
478
- case 33:
454
+ case 26:
479
455
  if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
480
- _context2.next = 43;
456
+ _context2.next = 36;
481
457
  break;
482
458
  }
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) || {};
459
+ action = ((_this5$_renderParams8 = _this5._renderParams) === null || _this5$_renderParams8 === void 0 || (_this5$_renderParams8 = _this5$_renderParams8.paymentSessionMetaData) === null || _this5$_renderParams8 === void 0 ? void 0 : _this5$_renderParams8.action) || {};
484
460
  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;
485
461
  if (!(signType === 'SMS')) {
486
- _context2.next = 38;
462
+ _context2.next = 31;
487
463
  break;
488
464
  }
489
465
  return _context2.abrupt("return", resolve({
490
466
  message: 'sdk no need to make query request',
491
467
  success: true
492
468
  }));
493
- case 38:
469
+ case 31:
494
470
  if (!(!signType || signType !== 'REDIRECT')) {
495
- _context2.next = 40;
471
+ _context2.next = 33;
496
472
  break;
497
473
  }
498
474
  return _context2.abrupt("return", resolve({
499
475
  success: false
500
476
  }));
501
- case 40:
502
- _context2.next = 42;
477
+ case 33:
478
+ _context2.next = 35;
503
479
  return _this5.getDeviceIdAndLog();
504
- case 42:
480
+ case 35:
505
481
  envInfo.deviceId = _context2.sent;
506
- case 43:
482
+ case 36:
507
483
  _this5.AMSSDK.logger.logInfo({
508
484
  title: 'sdk_event_sdkQuery'
509
485
  }, {
@@ -535,7 +511,7 @@ var ComponentApp = /*#__PURE__*/function () {
535
511
  paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
536
512
  }).send();
537
513
  });
538
- case 45:
514
+ case 38:
539
515
  case "end":
540
516
  return _context2.stop();
541
517
  }
@@ -133,11 +133,6 @@ 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
- };
141
136
  };
142
137
  paymentSessionFactor?: {
143
138
  applePay?: {
@@ -8,5 +8,3 @@
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,9 +1,3 @@
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; }
7
1
  /**
8
2
  * @author 谦彧 <zhangmian.zm@alipay.com>
9
3
  * @date 2023/11/1
@@ -53,71 +47,4 @@ export function compareVersion(v1, v2) {
53
47
  } else {
54
48
  return 1;
55
49
  }
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;
123
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1708315090-dev.7",
3
+ "version": "0.0.1708315090-dev.8",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",