@alipay/ams-checkout 0.0.1763724075-dev.4 → 0.0.1764137859-dev.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.
Files changed (140) hide show
  1. package/LEGAL.md +6 -0
  2. package/LICENSE +6 -0
  3. package/README.md +49 -0
  4. package/dist/umd/ams-checkout.min.js +1 -1
  5. package/esm/component/channel.d.ts +21 -0
  6. package/esm/component/component.inline.style.d.ts +10 -0
  7. package/esm/component/component.popup.style.d.ts +26 -0
  8. package/esm/component/popupWindow.style.d.ts +24 -0
  9. package/esm/component/popupWindow.style.js +3 -2
  10. package/esm/config/index.d.ts +16 -0
  11. package/esm/config/request.d.ts +21 -0
  12. package/esm/constant/easysafepay.d.ts +16 -0
  13. package/esm/constant/index.d.ts +341 -0
  14. package/esm/constant/index.js +0 -3
  15. package/esm/core/bus/ability/callback.d.ts +9 -0
  16. package/esm/core/bus/ability/security.d.ts +10 -0
  17. package/esm/core/bus/ability/tracker.d.ts +9 -0
  18. package/esm/core/bus/index.d.ts +125 -0
  19. package/esm/core/bus/interface.d.ts +36 -0
  20. package/esm/core/component/address.d.ts +8 -0
  21. package/esm/core/component/appPreloadProcessing.d.ts +1 -0
  22. package/esm/core/component/ckp/index.d.ts +29 -0
  23. package/esm/core/component/element/EventCenter/index.d.ts +31 -0
  24. package/esm/core/component/element/elementContainerService/containerService.d.ts +34 -0
  25. package/esm/core/component/element/elementContainerService/index.d.ts +20 -0
  26. package/esm/core/component/element/elementController/index.d.ts +48 -0
  27. package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +20 -0
  28. package/esm/core/component/element/elementProcessor/addressProcessor.js +3 -2
  29. package/esm/core/component/element/elementProcessor/authProcessor.d.ts +20 -0
  30. package/esm/core/component/element/elementProcessor/authProcessor.js +3 -2
  31. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +41 -0
  32. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +22 -0
  33. package/esm/core/component/element/elementProcessor/paymentProcessor.js +28 -30
  34. package/esm/core/component/element/index.d.ts +13 -0
  35. package/esm/core/component/element/mock.d.ts +10 -0
  36. package/esm/core/component/element/type.d.ts +443 -0
  37. package/esm/core/component/element/util.d.ts +85 -0
  38. package/esm/core/component/index.d.ts +58 -0
  39. package/esm/core/drop-in/index.d.ts +22 -0
  40. package/esm/core/instance/index.d.ts +89 -0
  41. package/esm/foundation/core/index.d.ts +36 -0
  42. package/esm/foundation/core/index.js +0 -27
  43. package/esm/foundation/index.d.ts +97 -0
  44. package/esm/foundation/product-processor/autoDebit/deps.d.ts +14 -0
  45. package/esm/foundation/product-processor/autoDebit/index.d.ts +48 -0
  46. package/esm/foundation/product-processor/easysafepay/deps.d.ts +20 -0
  47. package/esm/foundation/product-processor/easysafepay/index.d.ts +29 -0
  48. package/esm/foundation/product-processor/element/index.d.ts +7 -0
  49. package/esm/foundation/service/api-bus/ability/callback.d.ts +9 -0
  50. package/esm/foundation/service/api-bus/ability/globalData.d.ts +10 -0
  51. package/esm/foundation/service/api-bus/ability/request.d.ts +10 -0
  52. package/esm/foundation/service/api-bus/ability/security.d.ts +12 -0
  53. package/esm/foundation/service/api-bus/ability/tracker.d.ts +9 -0
  54. package/esm/foundation/service/api-bus/busManager.d.ts +127 -0
  55. package/esm/foundation/service/api-bus/index.d.ts +20 -0
  56. package/esm/foundation/service/api-bus/interface.d.ts +48 -0
  57. package/esm/foundation/service/container/index.d.ts +41 -0
  58. package/esm/foundation/service/container/index.js +2 -33
  59. package/esm/foundation/service/container/popup.d.ts +31 -0
  60. package/esm/foundation/service/container/utils.d.ts +7 -0
  61. package/esm/foundation/service/event-center.d.ts +82 -0
  62. package/esm/foundation/service/global-data/index.d.ts +11 -0
  63. package/esm/foundation/service/index.d.ts +19 -0
  64. package/esm/foundation/service/log/index.d.ts +43 -0
  65. package/esm/foundation/service/log/keys.d.ts +13 -0
  66. package/esm/foundation/service/log/processor.d.ts +9 -0
  67. package/esm/foundation/service/log/types.d.ts +33 -0
  68. package/esm/foundation/service/requester/deps.d.ts +17 -0
  69. package/esm/foundation/service/requester/requester.d.ts +22 -0
  70. package/esm/foundation/service/security/index.d.ts +28 -0
  71. package/esm/foundation/service/security/security.d.ts +33 -0
  72. package/esm/foundation/utils/gray_scale_utils.d.ts +7 -0
  73. package/esm/foundation/utils/payment_context_utils.d.ts +13 -0
  74. package/esm/foundation/utils/payment_product_utils.d.ts +13 -0
  75. package/esm/foundation/utils/preload_helper.d.ts +21 -0
  76. package/esm/foundation/utils/redirect_utils.d.ts +11 -0
  77. package/esm/foundation/utils/system_events.d.ts +4 -0
  78. package/esm/foundation/utils/web_app_url_utils.d.ts +116 -0
  79. package/esm/foundation/utils/web_app_url_utils.js +15 -10
  80. package/esm/index.d.ts +54 -0
  81. package/esm/index.js +341 -5
  82. package/esm/plugin/applepay/component.d.ts +50 -0
  83. package/esm/plugin/applepay/index.d.ts +17 -0
  84. package/esm/plugin/applepay/interface.d.ts +161 -0
  85. package/esm/plugin/applepay/service.d.ts +54 -0
  86. package/esm/plugin/component/cashierApp.d.ts +38 -0
  87. package/esm/plugin/component/cashierApp.js +4 -7
  88. package/esm/plugin/component/channel.d.ts +57 -0
  89. package/esm/plugin/component/component.inline.style.d.ts +10 -0
  90. package/esm/plugin/component/component.popup.style.d.ts +25 -0
  91. package/esm/plugin/component/index.d.ts +133 -0
  92. package/esm/plugin/component/popupWindow.style.d.ts +11 -0
  93. package/esm/plugin/component/popupWindow.style.js +4 -3
  94. package/esm/plugin/const.d.ts +2 -0
  95. package/esm/plugin/drop-in/index.d.ts +71 -0
  96. package/esm/plugin/payment-element/utils.d.ts +2 -0
  97. package/esm/plugin/paypal/index.d.ts +20 -0
  98. package/esm/plugin/type.d.ts +34 -0
  99. package/esm/plugin/utils.d.ts +6 -0
  100. package/esm/request/index.d.ts +9 -0
  101. package/esm/request/utils.d.ts +28 -0
  102. package/esm/service/index.d.ts +13 -0
  103. package/esm/types/index.d.ts +854 -0
  104. package/esm/util/createIframeNode.d.ts +6 -0
  105. package/esm/util/debug.d.ts +1 -0
  106. package/esm/util/get.d.ts +25 -0
  107. package/esm/util/getBackScheme.d.ts +5 -0
  108. package/esm/util/index.d.ts +61 -0
  109. package/esm/util/intl-callapp/es/browser.d.ts +21 -0
  110. package/esm/util/intl-callapp/es/evoke.d.ts +13 -0
  111. package/esm/util/intl-callapp/es/generate.d.ts +29 -0
  112. package/esm/util/intl-callapp/es/index.d.ts +43 -0
  113. package/esm/util/intl-callapp/es/main.d.ts +41 -0
  114. package/esm/util/intl-callapp/es/openWallet.d.ts +15 -0
  115. package/esm/util/intl-callapp/es/types.d.ts +46 -0
  116. package/esm/util/intl-callapp/es/utils/config.d.ts +24 -0
  117. package/esm/util/intl-callapp/es/utils/index.d.ts +15 -0
  118. package/esm/util/logger.d.ts +64 -0
  119. package/esm/util/logger.js +1 -1
  120. package/esm/util/mock.d.ts +1 -0
  121. package/esm/util/redirect.d.ts +6 -0
  122. package/esm/util/security.d.ts +34 -0
  123. package/esm/util/spm-map.d.ts +211 -0
  124. package/esm/util/storage.d.ts +2 -0
  125. package/esm/util/upgrade.d.ts +39 -0
  126. package/esm/util/versionCompare.d.ts +15 -0
  127. package/package.json +1 -7
  128. package/ams-checkout.js +0 -1
  129. package/esm/constant/auto-debit.js +0 -15
  130. package/esm/constant/element.js +0 -30
  131. package/esm/loader/Proxy.js +0 -364
  132. package/esm/loader/constant.js +0 -36
  133. package/esm/loader/index.js +0 -23
  134. package/esm/loader/utils/common.js +0 -63
  135. package/esm/loader/utils/debugger.js +0 -15
  136. package/esm/loader/utils/loadSDK.js +0 -92
  137. package/esm/loader/utils/logger.js +0 -59
  138. package/esm/loader/utils/proxyPerformance.js +0 -66
  139. package/esm/main.js +0 -329
  140. package/esm/util/integrationType.js +0 -48
@@ -0,0 +1,31 @@
1
+ import { PlatformEnum } from '../../../types';
2
+ export type IPopUpParams = {
3
+ url: string;
4
+ widthPadding: number;
5
+ heightPadding: number;
6
+ platform: PlatformEnum;
7
+ showCloseOnLoading: boolean;
8
+ onCloseOnLoading: () => void;
9
+ textDirection?: 'ltr' | 'rtl';
10
+ loadingConfig?: {
11
+ theme?: string;
12
+ backgroundPrimary?: string;
13
+ };
14
+ };
15
+ /**
16
+ * @author 谦彧 <zhangmian.zm@alipay.com>
17
+ * @date 2024/9/22
18
+ */
19
+ export declare class PopupManager {
20
+ private popupUrlQuery;
21
+ popupApp: HTMLIFrameElement;
22
+ setPopupUrlQuery(queryParams: string): void;
23
+ /**
24
+ * 合并URL参数, 优先加载弹窗参数作为基准, 用baseUrl参数覆盖弹窗参数
25
+ * @param baseUrl 基础URL
26
+ * @returns 合并后的URL
27
+ */
28
+ private mergeUrlParams;
29
+ popup(data: IPopUpParams): Promise<void>;
30
+ pop(): void;
31
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @author 谦彧 <zhangmian.zm@alipay.com>
3
+ * @date 2024/9/17
4
+ */
5
+ export declare const createPreloadIframe: (containerId: string) => HTMLIFrameElement;
6
+ export declare const createIframe: (containerId: string) => HTMLIFrameElement;
7
+ export declare const startSizeChangeAnim: (target: HTMLDivElement, height: number, animationStyleId: string) => void;
@@ -0,0 +1,82 @@
1
+ import { EventPayload, EventPayloadContext, IoptionsParams } from '../../types';
2
+ import { SDKMetaData, Service } from '../index';
3
+ /**
4
+ * @author 江跃 <jiangbin.gjb@antgroup.com>
5
+ * @date 2024/9/17
6
+ */
7
+ export declare class EventCenter implements Service {
8
+ private events;
9
+ private iframes;
10
+ private instanceId;
11
+ constructor();
12
+ /**
13
+ * Initializes the event center
14
+ */
15
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
16
+ /**
17
+ * Cleans up event listeners when the event center is destroyed.
18
+ */
19
+ destroy(): void;
20
+ /**
21
+ * Placeholder for future update logic.
22
+ */
23
+ update(): void;
24
+ /**
25
+ * Sets the iframe container and its domain.
26
+ * @param iframe - The HTMLIFrameElement that serves as the container.
27
+ * @param domain - The domain of the app.
28
+ */
29
+ addIFrame(iframe: HTMLIFrameElement): void;
30
+ /**
31
+ * Cleans iframes when web app close
32
+ */
33
+ cleanIFrames(): void;
34
+ removeIFrame(iframe: HTMLIFrameElement): void;
35
+ /**
36
+ * Handles messages received from the app.
37
+ * @param e - The message event.
38
+ */
39
+ private handleAppMessage;
40
+ private checkEventCompliant;
41
+ /**
42
+ * Processes the application message and emits the associated event.
43
+ * @param data - Parsed EventPayload from the app.
44
+ */
45
+ private _handleAppMessage;
46
+ /**
47
+ * Listens to an event by adding a callback function.
48
+ * @param name - The name of the event to listen for.
49
+ * @param func - The callback function to execute when the event is emitted.
50
+ * @param isAppend - Append to event handlers as chain, default value is false
51
+ */
52
+ listen(name: string, func: IListener, isAppend?: boolean): void;
53
+ /**
54
+ * Unsubscribes from an event. If a function is provided, only that function is removed.
55
+ * @param name - The name of the event to unlisten to.
56
+ * @param func - The optional callback function to remove.
57
+ */
58
+ unlisten(name: string, func?: IListener): void;
59
+ /**
60
+ * Emits an event, executing all associated callback functions.
61
+ * @param name - The name of the event to emit.
62
+ * @param data - The event data to pass to the event listeners.
63
+ */
64
+ emit(name: string, data: any, eventPayload?: EventPayload): void;
65
+ /**
66
+ * Registers a callback for an event and immediately dispatches the event to the app.
67
+ * @param payloadContext - The context containing event information and callback ID.
68
+ * @param func - The callback function to execute when the event is emitted.
69
+ */
70
+ emitAndListen(payloadContext: EventPayloadContext, func: IListener): void;
71
+ queryParse(url?: string): Record<string, any>;
72
+ /**
73
+ * Dispatches the event payload to the app via postMessage.
74
+ * @param payloadContext - The context containing event to be dispatched.
75
+ */
76
+ dispatchToApp(payloadContext: EventPayloadContext): void;
77
+ isExist(name: string): boolean;
78
+ }
79
+ interface IListener {
80
+ (data: any, eventPayload?: EventPayload): void;
81
+ }
82
+ export {};
@@ -0,0 +1,11 @@
1
+ import { IoptionsParams } from "../../../types";
2
+ import { Service } from "../../index";
3
+ export declare class GlobalDataService implements Service {
4
+ private globalData;
5
+ init(initOptions: IoptionsParams, instanceId: string): void;
6
+ destroy(): void;
7
+ update(): void;
8
+ getGlobalData(dataKey: string): any;
9
+ setGlobalData(dataKey: string, data: any): void;
10
+ clearGlobalData(): void;
11
+ }
@@ -0,0 +1,19 @@
1
+ import { IoptionsParams } from '../../types';
2
+ import { PaymentContext, SDKMetaData, Service } from '../index';
3
+ /**
4
+ * @author 谦彧 <zhangmian.zm@alipay.com>
5
+ * @date 2024/9/17
6
+ */
7
+ export type ServiceName = 'Container' | 'EventCenter' | 'Log' | 'ApiBusManager' | 'Requester' | 'Security' | 'GlobalData';
8
+ export declare class ServiceProvider {
9
+ private static ProvidersMapping;
10
+ static getInstance(instanceId: string): ServiceProvider;
11
+ private readonly instanceId;
12
+ private services;
13
+ private extendServices;
14
+ private constructor();
15
+ init(initOptions: IoptionsParams, sdkMetaData: SDKMetaData): void;
16
+ update(paymentContext: PaymentContext): void;
17
+ getService<T>(serviceName: ServiceName): T;
18
+ registerService(serviceName: string, service: Service): void;
19
+ }
@@ -0,0 +1,43 @@
1
+ import { PaymentContext, SDKMetaData, Service } from '../../index';
2
+ import { IoptionsParams } from '../../../types';
3
+ import { LogExtra, LogMetaData, LogPayload } from './types';
4
+ /**
5
+ * @author 谦彧 <zhangmian.zm@alipay.com>
6
+ * @date 2024/9/18
7
+ */
8
+ interface Config {
9
+ scriptUrl: string;
10
+ spmConfig: object;
11
+ appId: string;
12
+ server?: string;
13
+ bizType: string;
14
+ batchCount: number;
15
+ productId: string;
16
+ mdata?: LogMetaData;
17
+ version?: string;
18
+ }
19
+ export declare class LogService implements Service {
20
+ private instanceId;
21
+ private logs;
22
+ private config;
23
+ private debug;
24
+ private componentStartTime;
25
+ private isLoaded;
26
+ private trackId;
27
+ constructor();
28
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
29
+ update(paymentContext: PaymentContext): void;
30
+ destroy(): void;
31
+ setMetaData(metaData: LogMetaData): void;
32
+ getLogConfig(): Config;
33
+ logError(error: LogPayload, extra?: LogExtra, enableExtractCompliance?: boolean): LogService;
34
+ logInfo(info: LogPayload, extra?: LogExtra): LogService;
35
+ log(type: string, payload: LogPayload, extra?: LogExtra, enableExtractCompliance?: boolean): LogService;
36
+ private reportLogs;
37
+ private loadScript;
38
+ private initTracker;
39
+ send(): void;
40
+ setComponentStartTime(val: number): void;
41
+ getComponentStartTime(): number;
42
+ }
43
+ export {};
@@ -0,0 +1,13 @@
1
+ export declare class LogComplianceExtendKeys {
2
+ static complianceExtParams: Record<string, string>;
3
+ }
4
+ export declare const KEYS: {
5
+ EVENT_SDK_ON_ABNORMAL_EVENT_NAME: {
6
+ spmId: string;
7
+ alias: string;
8
+ };
9
+ EVENT_SDK_ON_ABNORMAL_EVENT_EXT_INFO: {
10
+ spmId: string;
11
+ alias: string;
12
+ };
13
+ };
@@ -0,0 +1,9 @@
1
+ import { LogExtra, LogPayload } from './types';
2
+ export declare class LogComplianceProcessor {
3
+ private static abnormalEventNameSet;
4
+ private static nonComplianceEventKeys;
5
+ static extractComplianceParams(eventName: string, params: Record<string, any>, errorLogCallback?: (error: LogPayload, extra?: LogExtra) => void): Record<string, string>;
6
+ private static reportHasAbnormalEventName;
7
+ private static reportHasIllegalExtendInfoKey;
8
+ static flushAbnormalInfo(errorLogCallback?: (error: LogPayload, extra?: LogExtra) => void): void;
9
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @author 谦彧 <zhangmian.zm@alipay.com>
3
+ * @date 2024/9/18
4
+ */
5
+ export interface LogPayload {
6
+ title?: string;
7
+ msg?: string;
8
+ errorMessage?: string;
9
+ name?: string;
10
+ label?: string;
11
+ time?: number;
12
+ success?: boolean;
13
+ code?: string;
14
+ traceId?: string;
15
+ }
16
+ export type LogExtra = Record<string, any>;
17
+ export interface LogMetaData {
18
+ platform?: string;
19
+ sdkVersion?: string;
20
+ webAppVersion?: string;
21
+ firstLogTime?: number;
22
+ fsDuration?: number;
23
+ instanceId?: string;
24
+ deviceId?: string;
25
+ renderDisplayType?: string;
26
+ merchantId?: string;
27
+ productScene?: string;
28
+ productSceneVersion?: string;
29
+ paymentMethodType?: string;
30
+ paymentMethodCategoryType?: string;
31
+ requestSeq?: string;
32
+ trackId?: string;
33
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 这个文件暂时先用来存放架构升级时不稳定的依赖。
3
+ * 以及方便单测时mock外部依赖
4
+ */
5
+ export type { SDKMetaData } from "../..";
6
+ export type { LogPayload, LogExtra } from '../log/types';
7
+ export type { LogService } from '../log';
8
+ export type { Service, PaymentContext } from '../../index';
9
+ export { fomatGetwayError } from '../../../request/utils';
10
+ export type { IoptionsParams, IPaymentSessionMetaData } from '../../../types';
11
+ export { sdkVersion } from '../../../config/index';
12
+ export { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from '../../../config/request';
13
+ export type { RequestConfig } from '../../../types';
14
+ export { errorEnum } from '../../../types';
15
+ export { get } from '../../../util/get';
16
+ export { device, isPC, queryParse, safeJson } from '../../../util';
17
+ export type { Logger } from '../../../util/logger';
@@ -0,0 +1,22 @@
1
+ import { IoptionsParams, PaymentContext, RequestConfig, SDKMetaData, Service } from './deps';
2
+ /**
3
+ * @author congle.zzq <congle.zzq@alipay.com>
4
+ * @date 2024/9/18
5
+ */
6
+ export declare class RequesterService implements Service {
7
+ private sandboxFlag?;
8
+ private instanceId;
9
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
10
+ /**
11
+ *
12
+ * @param requestData 请求参数
13
+ * @param options 请求配置
14
+ * @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
15
+ */
16
+ request<T>(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<T>;
17
+ getEnvInfo(options: RequestConfig): any;
18
+ private reportRequestTimeCost;
19
+ update(paymentSession: PaymentContext): void;
20
+ destroy(): void;
21
+ private createRequestInstance;
22
+ }
@@ -0,0 +1,28 @@
1
+ import { DeviceIdParameter, IoptionsParams } from '../../../types';
2
+ import { PaymentContext, SDKMetaData, Service } from '../../index';
3
+ import { Security } from './security';
4
+ export declare class SecurityService implements Service {
5
+ private logger;
6
+ private productScene;
7
+ static securitySdkMap: Map<string, Security>;
8
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
9
+ update(paymentContext: PaymentContext): void;
10
+ destroy(): void;
11
+ getDeviceId(deviceIdParameter?: DeviceIdParameter, isPolling?: boolean): Promise<string>;
12
+ preInitSecurity(timeout?: number): Promise<void>;
13
+ initSecurity(timeout?: number): Promise<void>;
14
+ private _initSecurity;
15
+ private logDeviceId;
16
+ /**
17
+ * @description Obtain security SDK through scenario identification
18
+ */
19
+ private _getSecuritySDKByProductScene;
20
+ /**
21
+ * @description New security SDK through scenario identification
22
+ */
23
+ private _newSecuritySDKByScene;
24
+ /**
25
+ * @description Obtain risk control configuration in local storage
26
+ */
27
+ private _getSecurityConfigStorage;
28
+ }
@@ -0,0 +1,33 @@
1
+ import { IsecurityConfig, ProductSceneEnum, DeviceIdParameter } from '../../../types';
2
+ export declare const getSecurityConfigStorageKey: (scene: ProductSceneEnum) => string;
3
+ export declare enum SecurityRegionEnum {
4
+ SG = "SG",
5
+ US = "US",
6
+ DE = "DE"
7
+ }
8
+ export declare const securityHost: {
9
+ SG: string;
10
+ US: string;
11
+ DE: string;
12
+ };
13
+ export declare const sceneMap: {
14
+ CASHIER_PAYMENT: string;
15
+ AUTO_DEBIT: string;
16
+ VAULTING: string;
17
+ CARD_APPLE_PAY: string;
18
+ EASYPAY: string;
19
+ EASY_PAY: string;
20
+ FLASH_BUY: string;
21
+ ELEMENT_PAYMENT: string;
22
+ };
23
+ export declare const getSecurityHost: (region: string) => string;
24
+ export declare const getSecurityScene: (product: string) => string;
25
+ export declare class Security {
26
+ scene: string;
27
+ h5gateway: string;
28
+ constructor(options: IsecurityConfig);
29
+ initSecurity(successCallback: any, failCallback: any): void;
30
+ private initToken;
31
+ pollingGetApdidToken(config?: DeviceIdParameter): Promise<string>;
32
+ getApdidToken(): Promise<string>;
33
+ }
@@ -0,0 +1,7 @@
1
+ import { WebAppMatchConfig } from './web_app_url_utils';
2
+ /**
3
+ * @author 谦彧 <zhangmian.zm@alipay.com>
4
+ * @date 2024/9/18
5
+ */
6
+ export declare function getGrayscaleId(): number;
7
+ export declare function isGreyscaleMatch(configEntry: WebAppMatchConfig, grayScaleId: number): boolean;
@@ -0,0 +1,13 @@
1
+ import { IPaymentSessionMetaData } from '../../types';
2
+ import { WebAppMatchConfig } from './web_app_url_utils';
3
+ import { SDKMetaData } from '../index';
4
+ /**
5
+ * @author 谦彧 <zhangmian.zm@alipay.com>
6
+ * @date 2024/9/17
7
+ */
8
+ export declare function convertPaymentSession(sessionData: string): {
9
+ id: string;
10
+ data: IPaymentSessionMetaData;
11
+ };
12
+ export declare const getWebAppVersion: (currentSDKMetaData: Pick<SDKMetaData, 'sdkVersion' | 'productScene' | 'greyscaleId'>, mid?: string, config?: WebAppMatchConfig[]) => string;
13
+ export declare const saveWebAppVersion: (webAppVersion: string, currentSDKMetaData: Pick<SDKMetaData, 'sdkVersion' | 'productScene'>) => void;
@@ -0,0 +1,13 @@
1
+ import { ProductSceneEnum } from "../../types";
2
+ export declare class ProductInfoCacheUtil {
3
+ static savePreviousProductInfo(productScene: ProductSceneEnum, info: {
4
+ productSceneVersion: string;
5
+ paymentMethodCategoryType: string;
6
+ hostSign: string;
7
+ }): void;
8
+ static getPreviousProductInfo(productScene: ProductSceneEnum): {
9
+ productSceneVersion: string;
10
+ paymentMethodCategoryType: string;
11
+ hostSign: string;
12
+ } | null;
13
+ }
@@ -0,0 +1,21 @@
1
+ import { PaymentMethodCategoryTypeEnum, ProductSceneEnum } from "../../types";
2
+ import { Security } from '../../util/security';
3
+ export default class PreloadHelper {
4
+ static isWebAppPreloaded: boolean;
5
+ static isSecuritySDKPreloaded: boolean;
6
+ private static securitySdkMap;
7
+ static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): void;
8
+ static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
9
+ static getSecuritySdk(scene: any): Security;
10
+ static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string, useV2?: boolean): {
11
+ preloadUrl: string;
12
+ containerId: string;
13
+ };
14
+ /**
15
+ * @description Obtain risk control configuration in local storage
16
+ */
17
+ static getSecurityConfigStorage(product: ProductSceneEnum): {
18
+ scene: string;
19
+ h5gateway: string;
20
+ };
21
+ }
@@ -0,0 +1,11 @@
1
+ import { RedirectBehaviorPayload } from '../index';
2
+ import { LogService } from '../service/log';
3
+ /**
4
+ * @author 谦彧 <zhangmian.zm@alipay.com>
5
+ * @date 2024/9/19
6
+ */
7
+ export declare const redirect: (payload: RedirectBehaviorPayload, instanceId: string) => void;
8
+ /**
9
+ * 通过配置规则检测 UA 和获得回跳 scheme
10
+ */
11
+ export declare function getBackScheme(mockUa?: string, logger?: LogService): any;
@@ -0,0 +1,4 @@
1
+ import { EventCenter } from '../service/event-center';
2
+ export declare const registerSystemEvents: (eventCenter: EventCenter) => void;
3
+ export declare const unRegisterSystemEvents: (eventCenter: EventCenter) => void;
4
+ export declare const getIframeOrigin: (iframe: HTMLIFrameElement) => string;
@@ -0,0 +1,116 @@
1
+ import { ESP_PAGE_NAME } from '../../constant/easysafepay';
2
+ import { DisplayTypeEnum, IPaymentSessionMetaData, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
3
+ import { SDKMetaData } from '../index';
4
+ /**
5
+ * Tell the SDK which version of the Web App to load.
6
+ * Sent by server inside paymentSession.
7
+ */
8
+ export interface WebAppMatchConfig {
9
+ /**
10
+ * SDK support version range, '{minVer}|{maxVer}', such as '1.0.0' or '1.0.0|2.0.0' or '2.0.0'
11
+ * If SDK version < maxVer and > minVer, then will use this config entry.
12
+ */
13
+ v: string;
14
+ appVersion: string;
15
+ productScene?: string;
16
+ platform?: string;
17
+ mid?: string;
18
+ greyscale?: string;
19
+ }
20
+ /**
21
+ * Tell the SDK which Web App URL to load.
22
+ * Sent by server inside paymentSession.
23
+ */
24
+ export interface WebAppUrlMatchConfig {
25
+ minSDKVersion: string;
26
+ url: string;
27
+ doubleFa: string;
28
+ mids?: string[];
29
+ }
30
+ export interface QueryParams {
31
+ displayType: DisplayTypeEnum;
32
+ locale: string;
33
+ instanceId: string;
34
+ analyticsEnabled: boolean;
35
+ isPreload?: string;
36
+ hostSign?: string;
37
+ }
38
+ export declare const getWebAppUrlInfo: (params: {
39
+ environment: string;
40
+ sdkMetaData: SDKMetaData;
41
+ productScene: ProductSceneEnum;
42
+ productSceneVersion: string;
43
+ paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
44
+ isPreload?: boolean;
45
+ query: QueryParams;
46
+ v2Url?: string;
47
+ }) => {
48
+ path: string;
49
+ locationSearch: string;
50
+ };
51
+ export declare const getWebAppV2Url: (params: {
52
+ environment: string;
53
+ sdkMetaData: SDKMetaData;
54
+ productScene: ProductSceneEnum;
55
+ productSceneVersion: string;
56
+ paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
57
+ isPreload?: boolean;
58
+ query: QueryParams;
59
+ mid?: string;
60
+ extendInfo?: string;
61
+ }) => string;
62
+ export declare const getWebAppUrl: (params: {
63
+ environment: string;
64
+ sdkMetaData: SDKMetaData;
65
+ productScene: ProductSceneEnum;
66
+ productSceneVersion: string;
67
+ paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
68
+ isPreload?: boolean;
69
+ query: QueryParams;
70
+ v2Url?: string;
71
+ }) => string;
72
+ export declare const parseWebAppMatchConfig: (extendInfo: string) => WebAppMatchConfig[];
73
+ export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUrlMatchConfig[];
74
+ /**
75
+ * Save the current checkout URL to localStorage for the specified product scene.
76
+ *
77
+ * @param productScene - The product scene for which the checkout URL should be saved.
78
+ */
79
+ export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url: string) => void;
80
+ /**
81
+ * 获取从外部动态下发的V2AppUrl.
82
+ *
83
+ * @param config - sessionData解析来的checkoutInfo列表.
84
+ */
85
+ export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, configs: WebAppUrlMatchConfig[], env: string) => string;
86
+ /**
87
+ * 获取ESP从sessionData.checkoutInfo内动态下发的Url.
88
+ */
89
+ export declare const matchEasySafePayV2Url: (params: {
90
+ configs: WebAppUrlMatchConfig[];
91
+ mid: string;
92
+ env: string;
93
+ pageName: ESP_PAGE_NAME;
94
+ }) => string;
95
+ /**
96
+ * Retrieve the saved checkout URL from localStorage for the specified product scene.
97
+ * If no url is found, a default checkout url string is returned.
98
+ *
99
+ * @param productScene - The product scene for which the checkout URL should be retrieved.
100
+ */
101
+ export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, environment: string) => string;
102
+ /**
103
+ * Provide default checkout URL for the specified product scene.
104
+ * Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
105
+ *
106
+ * @param productScene - The product scene for which the default checkout URL should be provided.
107
+ */
108
+ export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
109
+ /**
110
+ * V2应用EasySafePay 热更新兜底URL构建规则
111
+ * 1. 兜底URL版本与sdk版本保持一致
112
+ * 2. DEV环境下html新增版本前缀
113
+ **/
114
+ export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
115
+ /**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
116
+ export declare const getDoubleFaUrlFromSession: (paymentSessionObj: IPaymentSessionMetaData, env?: string) => string;
@@ -5,7 +5,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { marmotMap, sdkVersion, v2AppMarmotMap } from "../../config";
8
- import { AUTO_DEBIT_PAGE_URL } from "../../constant/auto-debit";
9
8
  import { ESP_PAGE_NAME } from "../../constant/easysafepay";
10
9
  import { ComponentSignEnum, ProductSceneEnum } from "../../types";
11
10
  import { queryParse, serialize } from "../../util";
@@ -72,8 +71,11 @@ export var getWebAppUrlInfo = function getWebAppUrlInfo(params) {
72
71
  export var getWebAppV2Url = function getWebAppV2Url(params) {
73
72
  var productScene = params.productScene,
74
73
  isPreload = params.isPreload,
74
+ mid = params.mid,
75
+ extendInfo = params.extendInfo,
75
76
  environment = params.environment;
76
- var v2Url = isPreload ? getLocalCheckoutUrl(productScene, environment) : defaultCheckoutUrl(productScene, environment);
77
+ var webAppUrlMatchConfig = parseWebAppUrlMatchConfig(extendInfo);
78
+ var v2Url = isPreload ? getLocalCheckoutUrl(productScene, environment) : getMatchedWebAppV2Url(productScene, mid, webAppUrlMatchConfig, environment);
77
79
  var info = getWebAppUrlInfo(_objectSpread(_objectSpread({}, params), {}, {
78
80
  v2Url: v2Url
79
81
  }));
@@ -115,14 +117,15 @@ var getAppPath = function getAppPath() {
115
117
  }
116
118
  var validProductSceneVersion = getValidProductSceneVersion(sdkMetaData.productScene, productSceneVersion, paymentMethodCategoryType);
117
119
  var productSceneWithPaymentMethodCategoryType = "".concat(sdkMetaData.productScene, "_").concat(paymentMethodCategoryType);
120
+ var webAppVersion = sdkMetaData.webAppVersion;
118
121
  if (productSceneWithPaymentMethodCategoryType === ComponentSignEnum.AUTO_DEBIT_APM) {
119
- return "".concat(v2AppMarmotMap[environment]).concat(AUTO_DEBIT_PAGE_URL.TRUSTLY);
122
+ return "".concat(v2AppMarmotMap[environment], "/auto-debit/").concat(webAppVersion, "/pages/trustly/index.html");
120
123
  }
121
124
  switch (productScene) {
122
125
  case ProductSceneEnum.EASY_PAY:
123
126
  return v2Url !== null && v2Url !== void 0 ? v2Url : defaultCheckoutUrl(productScene, environment);
124
127
  default:
125
- return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.html");
128
+ return "".concat(marmotMap[environment], "/").concat(productSceneWithPaymentMethodCategoryType, "/").concat(validProductSceneVersion, "/index.").concat(webAppVersion, ".html");
126
129
  }
127
130
  };
128
131
  export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo) {
@@ -287,18 +290,20 @@ export var defaultCheckoutUrl = function defaultCheckoutUrl(productScene) {
287
290
 
288
291
  /**
289
292
  * V2应用EasySafePay 热更新兜底URL构建规则
293
+ * 1. 兜底URL版本与sdk版本保持一致
294
+ * 2. DEV环境下html新增版本前缀
290
295
  **/
291
296
  export var getDefaultEasySafePayPageUrl = function getDefaultEasySafePayPageUrl(pageName, env) {
292
297
  // 生成的URL EXAMPLE:
293
298
  // const DEFAULT_DOUBLE_FA_URL_MAPPING = {
294
- // local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
295
- // dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
296
- // sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
297
- // pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/pages/double-fa/index.html',
298
- // prod: 'https://checkout.antom.com/easysafepay/pages/double-fa/index.html',
299
+ // local: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
300
+ // dev: 'http://page.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index-1.36.0.html',
301
+ // sit: 'http://page.test.alipay.net/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
302
+ // pre: 'https://pre.ac.alipay.com/page/antom-web-checkout-v2/easysafepay/1.36.0/pages/double-fa/index.html',
303
+ // prod: 'https://checkout.antom.com/easysafepay/1.36.0/pages/double-fa/index.html',
299
304
  // };
300
305
  var environment = env || 'prod';
301
- return "".concat(v2AppMarmotMap[environment], "/easysafepay/pages/").concat(pageName, "/index.html");
306
+ if (environment === 'dev') return "".concat(v2AppMarmotMap[environment], "/easysafepay/").concat(sdkVersion, "/pages/").concat(pageName, "/index-").concat(sdkVersion, ".html");else return "".concat(v2AppMarmotMap[environment], "/easysafepay/").concat(sdkVersion, "/pages/").concat(pageName, "/index.html");
302
307
  };
303
308
 
304
309
  /**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/