@alipay/ams-checkout 0.0.1788166152-dev.7 → 0.0.1788166152-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.
Files changed (171) hide show
  1. package/ams-checkout.js +3 -3
  2. package/dist/ams-checkout.min.js +1 -1
  3. package/dist/ams-checkout.min.js.map +1 -1
  4. package/esm/config/index.js +1 -1
  5. package/esm/core/component/element/modernElementController/index.js +2 -2
  6. package/esm/modern/component/channel.d.ts +21 -0
  7. package/esm/modern/component/component.inline.style.d.ts +10 -0
  8. package/esm/modern/component/component.popup.style.d.ts +26 -0
  9. package/esm/modern/component/popupWindow.style.d.ts +27 -0
  10. package/esm/modern/config/index.d.ts +23 -0
  11. package/esm/modern/config/request.d.ts +21 -0
  12. package/esm/modern/constant/auto-debit.d.ts +12 -0
  13. package/esm/modern/constant/easysafepay.d.ts +16 -0
  14. package/esm/modern/constant/element.d.ts +27 -0
  15. package/esm/modern/constant/index.d.ts +331 -0
  16. package/esm/modern/core/bus/ability/callback.d.ts +9 -0
  17. package/esm/modern/core/bus/ability/security.d.ts +10 -0
  18. package/esm/modern/core/bus/ability/tracker.d.ts +9 -0
  19. package/esm/modern/core/bus/index.d.ts +125 -0
  20. package/esm/modern/core/bus/interface.d.ts +36 -0
  21. package/esm/modern/core/component/address.d.ts +8 -0
  22. package/esm/modern/core/component/appPreloadProcessing.d.ts +1 -0
  23. package/esm/modern/core/component/ckp/index.d.ts +29 -0
  24. package/esm/modern/core/component/element/EventCenter/index.d.ts +41 -0
  25. package/esm/modern/core/component/element/config.d.ts +10 -0
  26. package/esm/modern/core/component/element/elementContainerService/containerService.d.ts +34 -0
  27. package/esm/modern/core/component/element/elementContainerService/index.d.ts +20 -0
  28. package/esm/modern/core/component/element/elementController/index.d.ts +54 -0
  29. package/esm/modern/core/component/element/elementProcessor/addressProcessor.d.ts +20 -0
  30. package/esm/modern/core/component/element/elementProcessor/authProcessor.d.ts +20 -0
  31. package/esm/modern/core/component/element/elementProcessor/baseElementProcessor.d.ts +42 -0
  32. package/esm/modern/core/component/element/elementProcessor/convertPaymentMethods.d.ts +22 -0
  33. package/esm/modern/core/component/element/elementProcessor/paymentProcessor.d.ts +37 -0
  34. package/esm/modern/core/component/element/index.d.ts +17 -0
  35. package/esm/modern/core/component/element/mock.d.ts +10 -0
  36. package/esm/modern/core/component/element/modernElementController/adapter.d.ts +19 -0
  37. package/esm/modern/core/component/element/modernElementController/index.d.ts +172 -0
  38. package/esm/modern/core/component/element/type.d.ts +586 -0
  39. package/esm/modern/core/component/element/util.d.ts +93 -0
  40. package/esm/modern/core/component/index.d.ts +58 -0
  41. package/esm/modern/core/instance/index.d.ts +97 -0
  42. package/esm/modern/core/utils/connectConfig.d.ts +11 -0
  43. package/esm/modern/foundation/core/index.d.ts +36 -0
  44. package/esm/modern/foundation/index.d.ts +93 -0
  45. package/esm/modern/foundation/product-processor/autoDebit/deps.d.ts +14 -0
  46. package/esm/modern/foundation/product-processor/autoDebit/index.d.ts +48 -0
  47. package/esm/modern/foundation/product-processor/easysafepay/deps.d.ts +20 -0
  48. package/esm/modern/foundation/product-processor/easysafepay/index.d.ts +29 -0
  49. package/esm/modern/foundation/product-processor/element/index.d.ts +7 -0
  50. package/esm/modern/foundation/service/api-bus/ability/globalData.d.ts +10 -0
  51. package/esm/modern/foundation/service/api-bus/ability/request.d.ts +10 -0
  52. package/esm/modern/foundation/service/api-bus/ability/security.d.ts +12 -0
  53. package/esm/modern/foundation/service/api-bus/ability/tracker.d.ts +9 -0
  54. package/esm/modern/foundation/service/api-bus/busManager.d.ts +127 -0
  55. package/esm/modern/foundation/service/api-bus/index.d.ts +20 -0
  56. package/esm/modern/foundation/service/api-bus/interface.d.ts +48 -0
  57. package/esm/modern/foundation/service/container/index.d.ts +42 -0
  58. package/esm/modern/foundation/service/container/popup.d.ts +31 -0
  59. package/esm/modern/foundation/service/container/utils.d.ts +7 -0
  60. package/esm/modern/foundation/service/event-center.d.ts +82 -0
  61. package/esm/modern/foundation/service/global-data/index.d.ts +11 -0
  62. package/esm/modern/foundation/service/index.d.ts +19 -0
  63. package/esm/modern/foundation/service/log/index.d.ts +44 -0
  64. package/esm/modern/foundation/service/log/keys.d.ts +13 -0
  65. package/esm/modern/foundation/service/log/processor.d.ts +9 -0
  66. package/esm/modern/foundation/service/log/types.d.ts +33 -0
  67. package/esm/modern/foundation/service/requester/deps.d.ts +17 -0
  68. package/esm/modern/foundation/service/requester/requester.d.ts +22 -0
  69. package/esm/modern/foundation/service/security/index.d.ts +33 -0
  70. package/esm/modern/foundation/service/security/security.d.ts +54 -0
  71. package/esm/modern/foundation/utils/gray_scale_utils.d.ts +7 -0
  72. package/esm/modern/foundation/utils/payment_context_utils.d.ts +13 -0
  73. package/esm/modern/foundation/utils/payment_product_utils.d.ts +13 -0
  74. package/esm/modern/foundation/utils/preload_helper.d.ts +24 -0
  75. package/esm/modern/foundation/utils/redirect_utils.d.ts +11 -0
  76. package/esm/modern/foundation/utils/system_events.d.ts +4 -0
  77. package/esm/modern/foundation/utils/web_app_url_utils.d.ts +114 -0
  78. package/esm/modern/index.js +1 -1
  79. package/esm/modern/loader/constant.d.ts +36 -0
  80. package/esm/modern/loader/utils/proxyPerformance.d.ts +20 -0
  81. package/esm/modern/main.d.ts +54 -0
  82. package/esm/modern/{index.d.ts → modern/index.d.ts} +1 -1
  83. package/esm/modern/modern/loadAntomTracker.d.ts +7 -0
  84. package/esm/modern/modern/preload/antomManifestAdapter.d.ts +11 -0
  85. package/esm/modern/modern/preload/config.d.ts +10 -0
  86. package/esm/modern/modern/preload/gatewayPreconnection.d.ts +53 -0
  87. package/esm/modern/modern/preload/preloadAntomElements.d.ts +9 -0
  88. package/esm/modern/modern/preload/startAntomPreload.d.ts +2 -0
  89. package/esm/modern/modern/sdk/applepay-core/ApplePayHostService.d.ts +102 -0
  90. package/esm/modern/modern/sdk/elements/CVVElement.d.ts +144 -0
  91. package/esm/modern/modern/sdk/elements/PaymentElement.d.ts +204 -0
  92. package/esm/modern/modern/sdk/elements/appearanceRules.d.ts +59 -0
  93. package/esm/modern/modern/sdk/elements/appearanceRulesDefaults.d.ts +2 -0
  94. package/esm/modern/modern/sdk/eventsMap.d.ts +135 -0
  95. package/esm/modern/modern/sdk/oneapi/iexpfront/PaymentSessionService.d.ts +69 -0
  96. package/esm/modern/modern/sdk/oneapi/iexpfront/definitions.d.ts +5311 -0
  97. package/esm/modern/modern/sdk/oneapi/iexpfront/preConnection.d.ts +6 -0
  98. package/esm/modern/modern/sdk/stageName.d.ts +3 -0
  99. package/esm/modern/modern/sdk/tools/awaitWrap.d.ts +14 -0
  100. package/esm/modern/modern/sdk/tools/buildPageUrl.d.ts +4 -0
  101. package/esm/modern/modern/sdk/tools/checkSessionData.d.ts +1 -0
  102. package/esm/modern/modern/sdk/tools/expressElement/applePay.d.ts +9 -0
  103. package/esm/modern/modern/sdk/tools/expressElement/applePayHostToken.d.ts +32 -0
  104. package/esm/modern/modern/sdk/tools/expressElement/types.d.ts +277 -0
  105. package/esm/modern/modern/sdk/tools/getDevReqConfig.d.ts +2 -0
  106. package/esm/modern/modern/sdk/tools/getLocaleFromRenderData.d.ts +6 -0
  107. package/esm/modern/modern/sdk/tools/getMetaData.d.ts +126 -0
  108. package/esm/modern/modern/sdk/tools/modalMessageMonitor.d.ts +41 -0
  109. package/esm/modern/modern/sdk/tools/openModal.d.ts +20 -0
  110. package/esm/modern/modern/sdk/tools/paymentElement/applePayHostToken.d.ts +38 -0
  111. package/esm/modern/modern/sdk/tools/paymentElement/googlePayHostToken.d.ts +38 -0
  112. package/esm/modern/modern/sdk/tools/paymentElement/tracker.d.ts +16 -0
  113. package/esm/modern/modern/sdk/tools/paymentElement/walletHostListeners.d.ts +19 -0
  114. package/esm/modern/modern/sdk/tools/preloadTracking.d.ts +5 -0
  115. package/esm/modern/modern/sdk/tools/showToast.d.ts +33 -0
  116. package/esm/modern/modern/sdk/tools/validatePaymentAmount.d.ts +19 -0
  117. package/esm/modern/modern/sdk/tracking/elementTracker.d.ts +65 -0
  118. package/esm/modern/modern/sdk/types.d.ts +310 -0
  119. package/esm/modern/modern/tools.d.ts +26 -0
  120. package/esm/modern/plugin/applepay/component.d.ts +50 -0
  121. package/esm/modern/plugin/applepay/index.d.ts +17 -0
  122. package/esm/modern/plugin/applepay/interface.d.ts +161 -0
  123. package/esm/modern/plugin/applepay/service.d.ts +54 -0
  124. package/esm/modern/plugin/component/cashierApp.d.ts +38 -0
  125. package/esm/modern/plugin/component/channel.d.ts +73 -0
  126. package/esm/modern/plugin/component/component.inline.style.d.ts +10 -0
  127. package/esm/modern/plugin/component/component.popup.style.d.ts +25 -0
  128. package/esm/modern/plugin/component/index.d.ts +133 -0
  129. package/esm/modern/plugin/component/popupWindow.style.d.ts +11 -0
  130. package/esm/modern/plugin/const.d.ts +2 -0
  131. package/esm/modern/plugin/payment-element/utils.d.ts +2 -0
  132. package/esm/modern/plugin/paypal/index.d.ts +20 -0
  133. package/esm/modern/plugin/type.d.ts +34 -0
  134. package/esm/modern/plugin/utils.d.ts +6 -0
  135. package/esm/modern/preload/antomManifestAdapter.d.ts +11 -0
  136. package/esm/modern/preload/antomManifestAdapter.js +117 -0
  137. package/esm/modern/preload/config.d.ts +10 -0
  138. package/esm/modern/preload/config.js +37 -0
  139. package/esm/modern/preload/gatewayPreconnection.d.ts +53 -0
  140. package/esm/modern/preload/gatewayPreconnection.js +213 -0
  141. package/esm/modern/preload/preloadAntomElements.d.ts +9 -0
  142. package/esm/modern/preload/preloadAntomElements.js +95 -0
  143. package/esm/modern/preload/startAntomPreload.d.ts +2 -0
  144. package/esm/modern/preload/startAntomPreload.js +9 -0
  145. package/esm/modern/request/index.d.ts +9 -0
  146. package/esm/modern/request/utils.d.ts +28 -0
  147. package/esm/modern/service/index.d.ts +13 -0
  148. package/esm/modern/tools.js +1 -1
  149. package/esm/modern/types/index.d.ts +856 -0
  150. package/esm/modern/util/beforeConfirm.d.ts +14 -0
  151. package/esm/modern/util/createIframeNode.d.ts +6 -0
  152. package/esm/modern/util/debug.d.ts +1 -0
  153. package/esm/modern/util/get.d.ts +25 -0
  154. package/esm/modern/util/getBackScheme.d.ts +5 -0
  155. package/esm/modern/util/index.d.ts +61 -0
  156. package/esm/modern/util/jshield-apdid/apdid-loader.d.ts +89 -0
  157. package/esm/modern/util/jshield-apdid/index.d.ts +21 -0
  158. package/esm/modern/util/logger.d.ts +67 -0
  159. package/esm/modern/util/mock.d.ts +1 -0
  160. package/esm/modern/util/redirect.d.ts +6 -0
  161. package/esm/modern/util/security-registry.d.ts +72 -0
  162. package/esm/modern/util/security.d.ts +55 -0
  163. package/esm/modern/util/spm-map.d.ts +217 -0
  164. package/esm/modern/util/storage.d.ts +2 -0
  165. package/esm/modern/util/timezone.d.ts +1 -0
  166. package/esm/modern/util/upgrade.d.ts +39 -0
  167. package/esm/modern/util/versionCompare.d.ts +15 -0
  168. package/esm/util/logger.js +1 -1
  169. package/package.json +2 -1
  170. package/types.d.ts +17 -2
  171. package/types.untrimmed.d.ts +35 -2
@@ -0,0 +1,42 @@
1
+ import { IoptionsParams } from '../../../types';
2
+ import { DisplayInfo, SDKMetaData, Service } from '../../index';
3
+ import { PopupManager } from './popup';
4
+ export declare class ContainerService implements Service {
5
+ private instanceId;
6
+ private sdkMetaData;
7
+ private initMessageEvent;
8
+ private clearTimerIdMapping;
9
+ popupManager: PopupManager;
10
+ private eventCenter;
11
+ private logService;
12
+ private displayInfo;
13
+ private webApp;
14
+ private _webAppHeartBeatTimeoutFn;
15
+ private clientHeight;
16
+ private boundFocusResizeChange;
17
+ private customizedLoadingListener;
18
+ destroy(): void;
19
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
20
+ update(): void;
21
+ load(displayInfo: DisplayInfo, url: string, closeBtnFunc?: () => void): HTMLDivElement;
22
+ cleanContainer(displayInfo: DisplayInfo): void;
23
+ showLoading(container: HTMLDivElement, displayInfo: DisplayInfo): void;
24
+ dismissLoading(isKeepMockup?: boolean): void;
25
+ customizeLoading(listener: (event: 'SDK_START_OF_LOADING' | 'SDK_END_OF_LOADING') => void): void;
26
+ startHideAnim(): void;
27
+ private handleAccountFocus;
28
+ private addCapabilityToEventCenter;
29
+ private addCapabilityToApiBusManager;
30
+ private updateMaskCloseBtn;
31
+ private handleSizeChanged;
32
+ private focusResizeChange;
33
+ private focusScrollFixed;
34
+ private handleAppHeartBeat;
35
+ private changeCloseBtnVisibility;
36
+ private handleMaskCloseBtnShow;
37
+ private handleCloseButtonTheme;
38
+ private handlePopupWindow;
39
+ private handlePopWindow;
40
+ private handleCanIUse;
41
+ getWebApp(): HTMLIFrameElement;
42
+ }
@@ -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,44 @@
1
+ import { IoptionsParams } from '../../../types';
2
+ import { PaymentContext, SDKMetaData, Service } from '../../index';
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 fallbackLoadScript;
39
+ private initTracker;
40
+ send(): void;
41
+ setComponentStartTime(val: number): void;
42
+ getComponentStartTime(): number;
43
+ }
44
+ 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 { formateGatewayError } 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,33 @@
1
+ import { DeviceIdParameter, IoptionsParams } from '../../../types';
2
+ import { PaymentContext, SDKMetaData, Service } from '../../index';
3
+ export declare class SecurityService implements Service {
4
+ private logger;
5
+ private productScene;
6
+ private environment?;
7
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
8
+ update(paymentContext: PaymentContext): void;
9
+ destroy(): void;
10
+ getDeviceId(deviceIdParameter?: DeviceIdParameter, isPolling?: boolean): Promise<string>;
11
+ preInitSecurity(timeout?: number): Promise<void>;
12
+ initSecurity(timeout?: number): Promise<void>;
13
+ private _initSecurity;
14
+ private logDeviceId;
15
+ /**
16
+ * Get the scene string from product enum
17
+ */
18
+ private _getSceneByProduct;
19
+ /**
20
+ * @description Obtain security SDK through scenario identification (async-aware)
21
+ * Handles three states: ready, loading, not found
22
+ */
23
+ private _getSecuritySDKByProductScene;
24
+ /**
25
+ * @description New security SDK through scenario identification (async)
26
+ * Uses shared SecuritySdkRegistry to avoid duplicate initialization
27
+ */
28
+ private _newSecuritySDKByScene;
29
+ /**
30
+ * @description Obtain risk control configuration in local storage
31
+ */
32
+ private _getSecurityConfigStorage;
33
+ }
@@ -0,0 +1,54 @@
1
+ import { IsecurityConfig, ProductSceneEnum, DeviceIdParameter } from '../../../types';
2
+ import type { ApdidEnvironment } from '../../../util/jshield-apdid';
3
+ export declare const getSecurityConfigStorageKey: (scene: ProductSceneEnum) => string;
4
+ export declare enum SecurityRegionEnum {
5
+ SG = "SG",
6
+ US = "US",
7
+ DE = "DE"
8
+ }
9
+ export declare const securityHost: {
10
+ SG: string;
11
+ US: string;
12
+ DE: string;
13
+ };
14
+ export declare const sceneMap: {
15
+ CASHIER_PAYMENT: string;
16
+ AUTO_DEBIT: string;
17
+ VAULTING: string;
18
+ CARD_APPLE_PAY: string;
19
+ EASYPAY: string;
20
+ EASY_PAY: string;
21
+ FLASH_BUY: string;
22
+ ELEMENT_PAYMENT: string;
23
+ };
24
+ export declare const getSecurityHost: (region: string) => string;
25
+ export declare const getSecurityScene: (product: string) => string;
26
+ /**
27
+ * Map SDK environment string to ApdidEnvironment for CDN URL selection.
28
+ */
29
+ export declare const mapEnvironment: (env?: string) => ApdidEnvironment;
30
+ export declare class Security {
31
+ scene: string;
32
+ h5gateway: string;
33
+ private environment?;
34
+ private apdidLoaded;
35
+ private apdidLoadFailed;
36
+ constructor(options: IsecurityConfig & {
37
+ environment?: string;
38
+ });
39
+ /**
40
+ * Ensure the apdid-core script is loaded async.
41
+ * Returns true if loaded successfully, false otherwise.
42
+ * On failure, sets apdidLoadFailed flag for graceful degradation.
43
+ */
44
+ private ensureApdidLoaded;
45
+ /**
46
+ * Get the APDID module from the loader.
47
+ * Returns undefined if not loaded.
48
+ */
49
+ private getAPDIDModule;
50
+ initSecurity(successCallback: any, failCallback: any): void;
51
+ private initToken;
52
+ pollingGetApdidToken(config?: DeviceIdParameter): Promise<string>;
53
+ getApdidToken(): Promise<string>;
54
+ }
@@ -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,24 @@
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
+ static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): void;
7
+ /**
8
+ * Preload security SDK asynchronously.
9
+ * Triggers ApdidLoader.load() for async script loading and registers in SecuritySdkRegistry.
10
+ */
11
+ static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string, environment?: string): Promise<void>;
12
+ static getSecuritySdk(scene: string): Security | undefined;
13
+ static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string, useV2?: boolean): {
14
+ preloadUrl: string;
15
+ containerId: string;
16
+ };
17
+ /**
18
+ * @description Obtain risk control configuration in local storage
19
+ */
20
+ static getSecurityConfigStorage(product: ProductSceneEnum): {
21
+ scene: string;
22
+ h5gateway: string;
23
+ };
24
+ }
@@ -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,114 @@
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
+ **/
112
+ export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
113
+ /**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
114
+ export declare const getDoubleFaUrlFromSession: (paymentSessionObj: IPaymentSessionMetaData, env?: string) => string;