@alipay/ams-checkout 0.0.1751254427-dev.0 → 0.0.1751254427-dev.2

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.
Files changed (40) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.inline.style.js +1 -1
  3. package/esm/component/component.popup.style.d.ts +1 -0
  4. package/esm/component/component.popup.style.js +1 -1
  5. package/esm/component/popupWindow.style.d.ts +4 -1
  6. package/esm/component/popupWindow.style.js +33 -1
  7. package/esm/config/index.d.ts +8 -7
  8. package/esm/config/index.js +8 -7
  9. package/esm/constant/index.d.ts +21 -0
  10. package/esm/constant/index.js +23 -0
  11. package/esm/core/component/element/elementController/index.js +22 -14
  12. package/esm/core/component/element/type.d.ts +29 -15
  13. package/esm/core/component/element/type.js +20 -12
  14. package/esm/core/component/index.d.ts +5 -2
  15. package/esm/core/component/index.js +105 -2
  16. package/esm/foundation/product-processor/autoDebit/deps.d.ts +14 -0
  17. package/esm/foundation/product-processor/autoDebit/deps.js +12 -0
  18. package/esm/foundation/product-processor/autoDebit/index.d.ts +48 -0
  19. package/esm/foundation/product-processor/autoDebit/index.js +466 -0
  20. package/esm/foundation/service/container/index.d.ts +2 -0
  21. package/esm/foundation/service/container/index.js +48 -24
  22. package/esm/foundation/service/container/popup.d.ts +9 -6
  23. package/esm/foundation/service/container/popup.js +3 -1
  24. package/esm/foundation/service/requester/requester.js +2 -2
  25. package/esm/foundation/utils/web_app_url_utils.d.ts +3 -3
  26. package/esm/foundation/utils/web_app_url_utils.js +15 -11
  27. package/esm/index.d.ts +18 -6
  28. package/esm/index.js +116 -53
  29. package/esm/plugin/component/cashierApp.js +2 -2
  30. package/esm/plugin/component/index.d.ts +2 -0
  31. package/esm/plugin/component/index.js +44 -8
  32. package/esm/plugin/paypal/index.js +5 -2
  33. package/esm/request/index.js +2 -2
  34. package/esm/types/index.d.ts +17 -6
  35. package/esm/types/index.js +2 -1
  36. package/esm/util/index.d.ts +12 -1
  37. package/esm/util/index.js +39 -3
  38. package/esm/util/spm-map.d.ts +18 -4
  39. package/esm/util/spm-map.js +20 -6
  40. package/package.json +2 -2
@@ -35,7 +35,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
35
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
36
36
  */
37
37
  import { v4 as uuid } from 'uuid';
38
- import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
38
+ import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT, SENDEVENT } from "../../constant";
39
+ import PreloadHelper from "../../foundation/utils/preload_helper";
39
40
  import { ApplePayBusSubscriber } from "../../plugin/applepay";
40
41
  import ComponentApp from "../../plugin/component";
41
42
  import { ExtendPlugin } from "../../plugin/const";
@@ -50,7 +51,6 @@ import { SecurityBusSubscriber } from "../bus/ability/security";
50
51
  import { TrackerBusSubscriber } from "../bus/ability/tracker";
51
52
  import CoreInstance from "../instance/index";
52
53
  import { loadChannelPneumaticControl } from "./appPreloadProcessing";
53
- import PreloadHelper from "../../foundation/utils/preload_helper";
54
54
  export var getComponentSign = function getComponentSign(params) {
55
55
  var _params$paymentSessio = params.paymentSessionConfig,
56
56
  _params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
@@ -140,6 +140,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
140
140
  _defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
141
141
  _defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
142
142
  _defineProperty(_assertThisInitialized(_this2), "timer", void 0);
143
+ _defineProperty(_assertThisInitialized(_this2), "_validateResolveMap", new Map());
143
144
  var ComponentPlugin = new ComponentApp({
144
145
  appVersion: options.appVersion
145
146
  });
@@ -526,6 +527,108 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
526
527
  }
527
528
  });
528
529
  }
530
+
531
+ // 预留给AMSVaulting复用
532
+ }, {
533
+ key: "_validateFields",
534
+ value: function _validateFields() {
535
+ var _this9 = this;
536
+ return new Promise(function (resolve) {
537
+ // 收银台应用渲染表单后,才允许发送校验消息,三端约定一致
538
+ if (!_this9._componentApp.shouldValidateFields()) {
539
+ resolve({
540
+ isValid: false
541
+ });
542
+ _this9.logger.logInfo({
543
+ title: 'sdk_event_validateFields'
544
+ }, {
545
+ processResult: 'notRenderComponent'
546
+ });
547
+ return;
548
+ }
549
+ var timeoutId;
550
+ var validationPromise = new Promise(function (validationResolve) {
551
+ var eventCallbackId = uuid();
552
+ _this9._validateResolveMap.set(eventCallbackId, validationResolve);
553
+ // 发送validateFields消息
554
+ _this9._sendMessageToAPP({
555
+ event: SENDEVENT.validateFields.name,
556
+ data: {},
557
+ eventCallbackId: eventCallbackId
558
+ });
559
+ var isValidationResult = function isValidationResult(data) {
560
+ return _typeof(data) === 'object' && data !== null && typeof data.isValid === 'boolean';
561
+ };
562
+ var callback = /*#__PURE__*/function () {
563
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
564
+ var currentEventCallbackId, currentResolve, result;
565
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
566
+ while (1) switch (_context2.prev = _context2.next) {
567
+ case 0:
568
+ currentEventCallbackId = (payload === null || payload === void 0 ? void 0 : payload.eventCallbackId) || ''; // 事件一一对应,处理异步商户调用多次可能导致乱序的问题
569
+ currentResolve = _this9._validateResolveMap.get(currentEventCallbackId);
570
+ result = {
571
+ isValid: false
572
+ };
573
+ if (isValidationResult(payload === null || payload === void 0 ? void 0 : payload.data)) {
574
+ result = payload === null || payload === void 0 ? void 0 : payload.data;
575
+ }
576
+ _this9.logger.logInfo({
577
+ title: 'sdk_event_validateFields'
578
+ }, {
579
+ processResult: result.isValid ? 'true' : 'false'
580
+ });
581
+ // 收银台应用保证数据格式,三端SDK负责透传
582
+ if (!!currentResolve) {
583
+ currentResolve(result);
584
+ _this9._validateResolveMap.delete(currentEventCallbackId);
585
+ }
586
+ case 6:
587
+ case "end":
588
+ return _context2.stop();
589
+ }
590
+ }, _callee2);
591
+ }));
592
+ return function callback(_x2) {
593
+ return _ref5.apply(this, arguments);
594
+ };
595
+ }();
596
+ // 接收收银台应用的返回validateFieldsResult消息
597
+ // validateFieldsResultForward处理订阅eventCallbackId为空的问题
598
+ _this9._overrideSubscription(EVENT.validateFieldsResult.forwardName, callback, EVENT.validateFieldsResult.uniqueKey);
599
+ });
600
+
601
+ // 兜底场景,三端约定超时时间15秒,兼容cpf网络校验超时场景
602
+ var timeoutPromise = new Promise(function (timeoutResolve) {
603
+ timeoutId = setTimeout(function () {
604
+ _this9.logger.logInfo({
605
+ title: 'sdk_event_validateFields'
606
+ }, {
607
+ processResult: 'timeout'
608
+ });
609
+ timeoutResolve({
610
+ isValid: false
611
+ });
612
+ }, 15000);
613
+ });
614
+ Promise.race([validationPromise, timeoutPromise]).then(function (result) {
615
+ clearTimeout(timeoutId);
616
+ resolve(result);
617
+ }).catch(function () {
618
+ clearTimeout(timeoutId);
619
+ resolve({
620
+ isValid: false
621
+ });
622
+ });
623
+ });
624
+ }
625
+ }, {
626
+ key: "_sendMessageToAPP",
627
+ value: function _sendMessageToAPP(eventContext) {
628
+ this._componentApp.dispatchToApp({
629
+ context: eventContext
630
+ });
631
+ }
529
632
  }]);
530
633
  return AMSComponent;
531
634
  }(CoreInstance);
@@ -0,0 +1,14 @@
1
+ export type { BizFlowStartBehavior, PaymentContext, ProductProcessor, RedirectBehaviorPayload, RenderBehaviorPayload, SDKMetaData, } from '../..';
2
+ export { v2AppMarmotMap } from '../../../config';
3
+ export { COMPONENT_CONTAINER_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LOADTIME_LIMIT } from '../../../constant';
4
+ export { getComponentSign } from '../../../core/component';
5
+ export { ComponentSignEnum, eventCodeEnum, PlatformEnum } from '../../../types';
6
+ export type { CashierSdkActionQueryRequest, IoptionsParams } from '../../../types';
7
+ export { isPC, isTrue, queryParse } from '../../../util';
8
+ export { isLocalMock } from '../../../util/mock';
9
+ export { EventCenter } from '../..//service/event-center';
10
+ export { ServiceProvider } from '../../service';
11
+ export { LogService } from '../../service/log';
12
+ export { RequesterService } from '../../service/requester/requester';
13
+ export { SecurityService } from '../../service/security';
14
+ export { getWebAppV2Url } from '../../utils/web_app_url_utils';
@@ -0,0 +1,12 @@
1
+ export { v2AppMarmotMap } from "../../../config";
2
+ export { COMPONENT_CONTAINER_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LOADTIME_LIMIT } from "../../../constant";
3
+ export { getComponentSign } from "../../../core/component";
4
+ export { ComponentSignEnum, eventCodeEnum, PlatformEnum } from "../../../types";
5
+ export { isPC, isTrue, queryParse } from "../../../util";
6
+ export { isLocalMock } from "../../../util/mock";
7
+ export { EventCenter } from "../..//service/event-center";
8
+ export { ServiceProvider } from "../../service";
9
+ export { LogService } from "../../service/log";
10
+ export { RequesterService } from "../../service/requester/requester";
11
+ export { SecurityService } from "../../service/security";
12
+ export { getWebAppV2Url } from "../../utils/web_app_url_utils";
@@ -0,0 +1,48 @@
1
+ import { BizFlowStartBehavior, IoptionsParams, PaymentContext, ProductProcessor, SDKMetaData } from './deps';
2
+ export declare class AutoDebitProcessor implements ProductProcessor {
3
+ private paymentContext?;
4
+ private initConfig;
5
+ private logger;
6
+ private eventCenter;
7
+ private securityService;
8
+ private instanceId;
9
+ private componentSign;
10
+ private hostSign;
11
+ private _performanceData;
12
+ private SECURITY_SDK_INIT_TIMEOUT;
13
+ init(config: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
14
+ startBizFlow(paymentContext: PaymentContext): Promise<BizFlowStartBehavior>;
15
+ private acquireApdidToken;
16
+ /**
17
+ * 获取SDK操作查询请求
18
+ * @returns {Promise<CashierSdkActionQueryRequest | { message?: string; success: boolean }>} 返回SDK操作查询请求或错误信息
19
+ */
20
+ private getSdkActionQuery;
21
+ /**
22
+ * webLaunchPromise方法用于返回一个Promise对象,用于异步加载Web App
23
+ * @returns {Promise} 返回一个Promise对象
24
+ */
25
+ private webLaunchPromise;
26
+ private sendRequestAndWaitWebLaunch;
27
+ private buildRedirectResult;
28
+ /**
29
+ * 构建 Web App 的 URL
30
+ * @returns {string} Web App 的 URL
31
+ */
32
+ private buildWebAppUrl;
33
+ /**
34
+ * 初始化安全SDK
35
+ * @returns {Promise}
36
+ */
37
+ private initSecuritySDK;
38
+ /**
39
+ * 设置容器宽度
40
+ * 如果是 Trustly 支付方式,并且显示平台为桌面端,则设置组件区块和容器的最大宽度为 656px
41
+ */
42
+ private setAchAutoDebitContainerWidth;
43
+ /**
44
+ * 判断是否为Trustly支付方式
45
+ * @returns {boolean} true 表示是Trustly支付方式
46
+ */
47
+ private get isTrustly();
48
+ }