@alipay/ams-checkout 1.29.0 → 1.31.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 (43) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +7 -7
  3. package/esm/config/index.js +7 -7
  4. package/esm/core/component/element/components/address.d.ts +1 -1
  5. package/esm/core/component/element/components/address.js +2 -2
  6. package/esm/core/component/element/components/payment.d.ts +1 -1
  7. package/esm/core/component/element/components/payment.js +2 -2
  8. package/esm/core/component/element/index.d.ts +9 -6
  9. package/esm/core/component/element/index.js +361 -230
  10. package/esm/core/component/element/type.d.ts +171 -12
  11. package/esm/core/component/element/type.js +48 -3
  12. package/esm/core/component/index.js +5 -0
  13. package/esm/core/instance/index.js +12 -1
  14. package/esm/foundation/index.d.ts +1 -1
  15. package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -2
  16. package/esm/foundation/product-processor/easysafepay/index.js +29 -73
  17. package/esm/foundation/service/container/index.d.ts +0 -2
  18. package/esm/foundation/service/container/index.js +20 -47
  19. package/esm/foundation/utils/payment_product_utils.d.ts +1 -1
  20. package/esm/foundation/utils/payment_product_utils.js +2 -2
  21. package/esm/foundation/utils/preload_helper.d.ts +21 -0
  22. package/esm/foundation/utils/preload_helper.js +143 -0
  23. package/esm/index.d.ts +7 -2
  24. package/esm/index.js +94 -7
  25. package/esm/plugin/component/channel.d.ts +20 -26
  26. package/esm/plugin/component/channel.js +392 -428
  27. package/esm/plugin/component/index.d.ts +1 -0
  28. package/esm/plugin/component/index.js +51 -20
  29. package/esm/plugin/const.js +1 -1
  30. package/esm/service/index.d.ts +0 -1
  31. package/esm/service/index.js +0 -2
  32. package/esm/types/index.d.ts +11 -116
  33. package/esm/types/index.js +3 -33
  34. package/esm/util/index.d.ts +2 -1
  35. package/esm/util/index.js +16 -1
  36. package/esm/util/security.d.ts +1 -0
  37. package/esm/util/security.js +3 -1
  38. package/esm/util/spm-map.d.ts +3 -0
  39. package/esm/util/spm-map.js +3 -0
  40. package/esm/util/versionCompare.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/esm/service/element.d.ts +0 -4
  43. package/esm/service/element.js +0 -51
@@ -8,7 +8,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
9
  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); }
10
10
  import { DisplayTypeEnum } from "../../../types";
11
- import { createIframe, createPreloadIframe, startSizeChangeAnim } from "./utils";
11
+ import { createIframe, startSizeChangeAnim } from "./utils";
12
12
  import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
13
13
  import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
14
14
  import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, LOADING_ID, MOCKUP_ID } from "../../../constant";
@@ -88,33 +88,6 @@ export var ContainerService = /*#__PURE__*/function () {
88
88
  // animation
89
89
  (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
90
90
  }
91
- }, {
92
- key: "preload",
93
- value: function preload(taskId, url) {
94
- var _this = this;
95
- var preloadIframe = createPreloadIframe(taskId);
96
- preloadIframe.src = url;
97
- var body = document.body || null;
98
- if (body) {
99
- body.appendChild(preloadIframe);
100
- }
101
- var timerId = setTimeout(function () {
102
- _this.clearPreloadContainer(taskId);
103
- }, MAX_CLEAR_TIME);
104
- this.clearTimerIdMapping[taskId] = timerId;
105
- }
106
- }, {
107
- key: "clearPreloadContainer",
108
- value: function clearPreloadContainer(taskId) {
109
- var timerId = this.clearTimerIdMapping[taskId];
110
- if (timerId) {
111
- clearTimeout(timerId);
112
- }
113
- var container = document.getElementById(taskId);
114
- if (container) {
115
- document.body.removeChild(container);
116
- }
117
- }
118
91
  }, {
119
92
  key: "showLoading",
120
93
  value: function showLoading(container, displayInfo) {
@@ -168,13 +141,13 @@ export var ContainerService = /*#__PURE__*/function () {
168
141
  }, {
169
142
  key: "addCapabilityToEventCenter",
170
143
  value: function addCapabilityToEventCenter() {
171
- var _this2 = this;
144
+ var _this = this;
172
145
  this.eventCenter.listen(EVENT.dismissLoading.name, function () {
173
- _this2.dismissLoading();
146
+ _this.dismissLoading();
174
147
  });
175
148
  this.eventCenter.listen(EVENT.getUserAgentFromSdk.name, function (data, payload) {
176
149
  var _payload$context;
177
- _this2.eventCenter.dispatchToApp({
150
+ _this.eventCenter.dispatchToApp({
178
151
  event: 'appEventCallback',
179
152
  eventCallbackId: (_payload$context = payload.context) === null || _payload$context === void 0 ? void 0 : _payload$context.eventCallbackId,
180
153
  data: {
@@ -183,34 +156,34 @@ export var ContainerService = /*#__PURE__*/function () {
183
156
  });
184
157
  });
185
158
  this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
186
- var _this2$displayInfo;
159
+ var _this$displayInfo2;
187
160
  if (data.paymentElementOldModel) return;
188
- _this2.popupManager.popup(_objectSpread({
189
- platform: (_this2$displayInfo = _this2.displayInfo) === null || _this2$displayInfo === void 0 ? void 0 : _this2$displayInfo.platform
161
+ _this.popupManager.popup(_objectSpread({
162
+ platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
190
163
  }, data)).catch(function (error) {
191
- _this2.logService.logError({
164
+ _this.logService.logError({
192
165
  title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
193
166
  }, error);
194
- _this2.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
167
+ _this.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
195
168
  });
196
169
  });
197
170
  this.eventCenter.listen(EVENT.popWindow.name, function () {
198
- _this2.popupManager.pop();
171
+ _this.popupManager.pop();
199
172
  });
200
173
  this.eventCenter.listen(EVENT.sizeChanged.name, function (data) {
201
- _this2.handleSizeChanged(_objectSpread({}, data));
174
+ _this.handleSizeChanged(_objectSpread({}, data));
202
175
  });
203
176
  this.eventCenter.listen(EVENT.showCloseButton.name, function () {
204
- _this2.changeCloseBtnVisibility(true);
177
+ _this.changeCloseBtnVisibility(true);
205
178
  });
206
179
  this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
207
- _this2.changeCloseBtnVisibility(false);
180
+ _this.changeCloseBtnVisibility(false);
208
181
  });
209
182
  this.eventCenter.listen(EVENT.setMaskCloseButton.name, function (data) {
210
- _this2.handleMaskCloseBtnShow(data);
183
+ _this.handleMaskCloseBtnShow(data);
211
184
  });
212
185
  this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
213
- _this2.handleAppHeartBeat();
186
+ _this.handleAppHeartBeat();
214
187
  });
215
188
  }
216
189
  }, {
@@ -271,12 +244,12 @@ export var ContainerService = /*#__PURE__*/function () {
271
244
  }, {
272
245
  key: "handleAppHeartBeat",
273
246
  value: function handleAppHeartBeat() {
274
- var _this3 = this;
247
+ var _this2 = this;
275
248
  try {
276
249
  if (!this._webAppHeartBeatTimeoutFn) {
277
250
  this._webAppHeartBeatTimeoutFn = function () {
278
- if (_this3.webApp && _this3.displayInfo) {
279
- _this3.logService.logError({
251
+ if (_this2.webApp && _this2.displayInfo) {
252
+ _this2.logService.logError({
280
253
  title: 'sdk_error_appHeartBeatTimeout'
281
254
  });
282
255
  }
@@ -290,8 +263,8 @@ export var ContainerService = /*#__PURE__*/function () {
290
263
  window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
291
264
  }
292
265
  setTimeout(function () {
293
- if (_this3.webApp && _this3.displayInfo) {
294
- _this3.eventCenter.dispatchToApp({
266
+ if (_this2.webApp && _this2.displayInfo) {
267
+ _this2.eventCenter.dispatchToApp({
295
268
  event: 'sdkHeartBeat',
296
269
  data: {}
297
270
  });
@@ -5,7 +5,7 @@ export declare class ProductInfoCacheUtil {
5
5
  paymentMethodCategoryType: string;
6
6
  hostSign: string;
7
7
  }): void;
8
- static getPreviousProductInfo(productScene: ProductSceneEnum, onError: (msg: string) => void): {
8
+ static getPreviousProductInfo(productScene: ProductSceneEnum): {
9
9
  productSceneVersion: string;
10
10
  paymentMethodCategoryType: string;
11
11
  hostSign: string;
@@ -21,14 +21,14 @@ export var ProductInfoCacheUtil = /*#__PURE__*/function () {
21
21
  }
22
22
  }, {
23
23
  key: "getPreviousProductInfo",
24
- value: function getPreviousProductInfo(productScene, onError) {
24
+ value: function getPreviousProductInfo(productScene) {
25
25
  var key = KEY_PREVIOUS_PRODUCT_INFO + '_' + productScene;
26
26
  var previousProductInfoString = localStorage.getItem(key);
27
27
  if (previousProductInfoString) {
28
28
  try {
29
29
  return JSON.parse(previousProductInfoString);
30
30
  } catch (error) {
31
- onError(error === null || error === void 0 ? void 0 : error.message);
31
+ return null;
32
32
  }
33
33
  }
34
34
  return null;
@@ -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): void;
8
+ static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
9
+ static getSecuritySdk(scene: any): Security;
10
+ static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
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,143 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ import { sdkVersion } from "../../config";
9
+ import { createPreloadIframe } from "../service/container/utils";
10
+ import { ProductSceneEnum } from "../../types";
11
+ import { getWebAppUrl } from "../utils/web_app_url_utils";
12
+ import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
13
+ import { getWebAppVersion } from "./payment_context_utils";
14
+ import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
15
+ import { getOrSetStorageId, safeJson } from "../../util";
16
+ var MAX_CLEAR_TIME = 10000;
17
+ var PreloadHelper = /*#__PURE__*/function () {
18
+ function PreloadHelper() {
19
+ _classCallCheck(this, PreloadHelper);
20
+ }
21
+ _createClass(PreloadHelper, null, [{
22
+ key: "preloadWebApp",
23
+ value: function preloadWebApp(productScene, paymentMethodCategoryType) {
24
+ var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
25
+ try {
26
+ if (this.isWebAppPreloaded) {
27
+ console.log('[web-sdk] web app already preloaded');
28
+ return;
29
+ }
30
+ var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
31
+ preloadUrl = _this$buildWebAppPrel.preloadUrl,
32
+ containerId = _this$buildWebAppPrel.containerId;
33
+ var preloadIframe = createPreloadIframe(containerId);
34
+ preloadIframe.src = preloadUrl;
35
+ var body = document.body || null;
36
+ if (body) {
37
+ console.log('[web-sdk] preload web app, url: ', preloadUrl);
38
+ body.appendChild(preloadIframe);
39
+ this.isWebAppPreloaded = true;
40
+ }
41
+ setTimeout(function () {
42
+ var container = document.getElementById(containerId);
43
+ if (container) {
44
+ console.log('[web-sdk] remove preload web app');
45
+ document.body.removeChild(container);
46
+ }
47
+ }, MAX_CLEAR_TIME);
48
+ } catch (error) {
49
+ console.error('[web-sdk] preload web app failed', error);
50
+ }
51
+ }
52
+ }, {
53
+ key: "preloadSecuritySDK",
54
+ value: function preloadSecuritySDK(product) {
55
+ var _this = this;
56
+ var securityRegion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'SG';
57
+ try {
58
+ if (this.isSecuritySDKPreloaded) {
59
+ console.log('[web-sdk] security sdk is already loaded');
60
+ return;
61
+ }
62
+ var storage = PreloadHelper.getSecurityConfigStorage(product);
63
+ var scene = storage.scene || getSecurityScene(product);
64
+ console.log('getSecurityScene', scene);
65
+ var h5gateway = storage.h5gateway || getSecurityHost(securityRegion);
66
+ console.log('preloadSecuritySDK', scene);
67
+ var securitySdk = new Security({
68
+ scene: scene,
69
+ h5gateway: h5gateway
70
+ });
71
+ securitySdk.initSecurity(function () {
72
+ console.log(_this.securitySdkMap, 'this.securitySdkMap');
73
+ _this.securitySdkMap.set(scene, securitySdk);
74
+ _this.isSecuritySDKPreloaded = true;
75
+ console.log('[web-sdk] preload security sdk succeed');
76
+ }, function () {
77
+ console.error('[web-sdk] preload security sdk failed');
78
+ });
79
+ } catch (error) {
80
+ console.error('[web-sdk] preload security sdk failed', error);
81
+ }
82
+ }
83
+ }, {
84
+ key: "getSecuritySdk",
85
+ value: function getSecuritySdk(scene) {
86
+ var result = this.securitySdkMap.get(scene);
87
+ return result;
88
+ }
89
+ }, {
90
+ key: "buildWebAppPreloadUrl",
91
+ value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
92
+ var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
93
+ var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
94
+ if (previousProductInfo) {
95
+ productSceneVersion = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.productSceneVersion;
96
+ }
97
+ var containerId = "ams-checkout-component-".concat(productScene, "_").concat(paymentMethodCategoryType);
98
+ var sdkMetaData = {
99
+ productScene: productScene,
100
+ sdkVersion: sdkVersion,
101
+ webAppVersion: ''
102
+ };
103
+ sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
104
+ var preloadUrl = getWebAppUrl({
105
+ environment: environment,
106
+ sdkMetaData: sdkMetaData,
107
+ paymentMethodCategoryType: paymentMethodCategoryType,
108
+ isPreload: true,
109
+ productSceneVersion: productSceneVersion,
110
+ query: undefined
111
+ });
112
+ return {
113
+ preloadUrl: preloadUrl,
114
+ containerId: containerId
115
+ };
116
+ }
117
+
118
+ /**
119
+ * @description Obtain risk control configuration in local storage
120
+ */
121
+ }, {
122
+ key: "getSecurityConfigStorage",
123
+ value: function getSecurityConfigStorage(product) {
124
+ var scene = '';
125
+ var h5gateway = '';
126
+ var securityConfigStorage = getOrSetStorageId(getSecurityConfigStorageKey(product));
127
+ if (securityConfigStorage) {
128
+ var config = safeJson(securityConfigStorage, {});
129
+ scene = config === null || config === void 0 ? void 0 : config.appName;
130
+ h5gateway = config === null || config === void 0 ? void 0 : config.h5gateway;
131
+ }
132
+ return {
133
+ scene: scene,
134
+ h5gateway: h5gateway
135
+ };
136
+ }
137
+ }]);
138
+ return PreloadHelper;
139
+ }();
140
+ _defineProperty(PreloadHelper, "isWebAppPreloaded", false);
141
+ _defineProperty(PreloadHelper, "isSecuritySDKPreloaded", false);
142
+ _defineProperty(PreloadHelper, "securitySdkMap", new Map());
143
+ export { PreloadHelper as default };
package/esm/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AddressComponent } from './core/component/address';
2
2
  import { ElementComponent } from './core/component/element';
3
3
  import { AMSComponent } from './core/component/index';
4
- import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams } from './types';
4
+ import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
5
5
  export { AMSCheckoutPage } from './core/component/ckp';
6
6
  export * from './types';
7
7
  export declare class AMSCheckout extends AMSComponent {
@@ -9,15 +9,19 @@ export declare class AMSCheckout extends AMSComponent {
9
9
  }
10
10
  export declare class AMSAutoDebit extends AMSCheckout {
11
11
  constructor(options: IoptionsParams);
12
+ static preload(options?: IPreloadOptions): void;
12
13
  }
13
14
  export declare class AMSAutoDebitPay extends AMSCheckout {
14
15
  constructor(options: IoptionsParams);
16
+ static preload(options?: IPreloadOptions): void;
15
17
  }
16
18
  export declare class AMSCashierPayment extends AMSCheckout {
17
19
  constructor(options: IoptionsParams);
20
+ static preload(options?: IPreloadOptions): void;
18
21
  }
19
22
  export declare class AMSVaulting extends AMSCheckout {
20
23
  constructor(options: IoptionsParams);
24
+ static preload(options?: IPreloadOptions): void;
21
25
  }
22
26
  export declare class AntomElement extends AMSCheckout {
23
27
  constructor(options: IoptionsParams);
@@ -28,10 +32,11 @@ export declare class AddressElement extends AddressComponent {
28
32
  export declare class Element extends ElementComponent {
29
33
  constructor(options: IElementOptions);
30
34
  }
31
- export default AMSCheckout;
32
35
  export declare class AMSEasyPay {
33
36
  private core;
34
37
  constructor(options: IoptionsParams);
38
+ static preload(options?: IPreloadOptions): void;
35
39
  createComponent(params: IcreateComponent): void;
36
40
  unmount(): void;
37
41
  }
42
+ export default AMSCheckout;
package/esm/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
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; }
2
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -25,9 +28,10 @@ import { ADDRESSElementAppVersion, AMSAutoDebitAppVersion, AMSCashierPaymentAppV
25
28
  import { AddressComponent } from "./core/component/address";
26
29
  import { ElementComponent } from "./core/component/element";
27
30
  import { AMSComponent } from "./core/component/index";
28
- import { ComponentSignEnum, DisplayTypeEnum } from "./types";
31
+ import { ComponentSignEnum, DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from "./types";
29
32
  import { ProductSceneEnum } from "./types/index";
30
33
  import { LogConfig, Logger } from "./util/logger";
34
+ import PreloadHelper from "./foundation/utils/preload_helper";
31
35
  var logger = new Logger(LogConfig, true);
32
36
  export { AMSCheckoutPage } from "./core/component/ckp";
33
37
  export * from "./types";
@@ -59,7 +63,18 @@ export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
59
63
  });
60
64
  return _super2.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_WALLET]);
61
65
  }
62
- return _createClass(AMSAutoDebit);
66
+ _createClass(AMSAutoDebit, null, [{
67
+ key: "preload",
68
+ value: function preload() {
69
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
70
+ securityRegion: 'SG',
71
+ environment: 'prod'
72
+ };
73
+ PreloadHelper.preloadWebApp(ProductSceneEnum.AUTO_DEBIT, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
74
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.AUTO_DEBIT, options.securityRegion);
75
+ }
76
+ }]);
77
+ return AMSAutoDebit;
63
78
  }(AMSCheckout);
64
79
  export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
65
80
  _inherits(AMSAutoDebitPay, _AMSCheckout2);
@@ -71,7 +86,18 @@ export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
71
86
  });
72
87
  return _super3.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_PAY_WALLET]);
73
88
  }
74
- return _createClass(AMSAutoDebitPay);
89
+ _createClass(AMSAutoDebitPay, null, [{
90
+ key: "preload",
91
+ value: function preload() {
92
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
93
+ securityRegion: 'SG',
94
+ environment: 'prod'
95
+ };
96
+ PreloadHelper.preloadWebApp(ProductSceneEnum.AUTO_DEBIT_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
97
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.AUTO_DEBIT_PAY, options.securityRegion);
98
+ }
99
+ }]);
100
+ return AMSAutoDebitPay;
75
101
  }(AMSCheckout);
76
102
  export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
77
103
  _inherits(AMSCashierPayment, _AMSCheckout3);
@@ -103,7 +129,48 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
103
129
  }
104
130
  return _super4.call(this, _options, currentChannelType);
105
131
  }
106
- return _createClass(AMSCashierPayment);
132
+ _createClass(AMSCashierPayment, null, [{
133
+ key: "preload",
134
+ value: function preload() {
135
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
136
+ securityRegion: 'SG',
137
+ environment: 'prod'
138
+ };
139
+ try {
140
+ var channelTypes;
141
+ var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
142
+ var previousChannel = JSON.parse(previousChannelStr) || {};
143
+ var _ref2 = previousChannel || {},
144
+ _ref2$channelType = _ref2.channelType,
145
+ channelType = _ref2$channelType === void 0 ? '' : _ref2$channelType;
146
+ if (ComponentSignEnum.CASHIER_PAYMENT_CARD === channelType) {
147
+ channelTypes = [PaymentMethodCategoryTypeEnum.CARD];
148
+ } else if (ComponentSignEnum.CASHIER_PAYMENT_APM === channelType) {
149
+ channelTypes = [PaymentMethodCategoryTypeEnum.APM];
150
+ } else if (ComponentSignEnum.CASHIER_PAYMENT_BANK === channelType) {
151
+ channelTypes = [PaymentMethodCategoryTypeEnum.BANK];
152
+ } else {
153
+ channelTypes = [PaymentMethodCategoryTypeEnum.CARD, PaymentMethodCategoryTypeEnum.APM];
154
+ }
155
+ var _iterator = _createForOfIteratorHelper(channelTypes),
156
+ _step;
157
+ try {
158
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
159
+ var _channelType = _step.value;
160
+ PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, _channelType, options.environment);
161
+ }
162
+ } catch (err) {
163
+ _iterator.e(err);
164
+ } finally {
165
+ _iterator.f();
166
+ }
167
+ } catch (error) {
168
+ console.error('[web-sdk] preload web app error', error);
169
+ }
170
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.CASHIER_PAYMENT, options.securityRegion);
171
+ }
172
+ }]);
173
+ return AMSCashierPayment;
107
174
  }(AMSCheckout);
108
175
  export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
109
176
  _inherits(AMSVaulting, _AMSCheckout4);
@@ -116,7 +183,18 @@ export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
116
183
  });
117
184
  return _super5.call(this, _options, [ComponentSignEnum.CASHIER_PAYMENT_CARD]);
118
185
  }
119
- return _createClass(AMSVaulting);
186
+ _createClass(AMSVaulting, null, [{
187
+ key: "preload",
188
+ value: function preload() {
189
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
190
+ securityRegion: 'SG',
191
+ environment: 'prod'
192
+ };
193
+ PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, PaymentMethodCategoryTypeEnum.CARD, options.environment);
194
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.VAULTING, options.securityRegion);
195
+ }
196
+ }]);
197
+ return AMSVaulting;
120
198
  }(AMSCheckout);
121
199
  export var AntomElement = /*#__PURE__*/function (_AMSCheckout5) {
122
200
  _inherits(AntomElement, _AMSCheckout5);
@@ -157,7 +235,6 @@ export var Element = /*#__PURE__*/function (_ElementComponent) {
157
235
  }
158
236
  return _createClass(Element);
159
237
  }(ElementComponent);
160
- export default AMSCheckout;
161
238
  export var AMSEasyPay = /*#__PURE__*/function () {
162
239
  function AMSEasyPay(options) {
163
240
  _classCallCheck(this, AMSEasyPay);
@@ -186,6 +263,16 @@ export var AMSEasyPay = /*#__PURE__*/function () {
186
263
  value: function unmount() {
187
264
  this.core.destroy();
188
265
  }
266
+ }], [{
267
+ key: "preload",
268
+ value: function preload() {
269
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
270
+ securityRegion: 'SG',
271
+ environment: 'prod'
272
+ };
273
+ PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
274
+ }
189
275
  }]);
190
276
  return AMSEasyPay;
191
- }();
277
+ }();
278
+ export default AMSCheckout;
@@ -1,4 +1,4 @@
1
- import { EventPayloadContext, type EventPayload, type IPaymentMethod, type IPaymentSessionMetaData } from '../../types';
1
+ import { type EventPayload, type IPaymentSessionMetaData } from '../../types';
2
2
  import { Logger } from '../../util/logger';
3
3
  export type IChannelBehavior = {
4
4
  usePaymentSessionAsQueryResult: boolean;
@@ -19,43 +19,37 @@ type GetDoubleFaParams = {
19
19
  export declare function getChannelBehavior(paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
20
20
  export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
21
21
  export declare const handleGooglePay: (data: EventPayload) => Promise<unknown>;
22
- export declare class ApplePayService {
22
+ export declare class ApplePaySdk {
23
23
  private APPLESDKURL;
24
- private applePaySession;
24
+ private session;
25
25
  private paymentSessionData;
26
- private sessionResult;
26
+ private parseData;
27
27
  /**
28
28
  * @description 支付状态,pending:支付中,normal:正常
29
29
  */
30
30
  private paymentStatus;
31
- /**
32
- * @description paymentRequest
33
- */
34
- private paymentRequest;
35
31
  private logger;
36
- private dispatchToApp;
37
- private paymentMethod;
38
- constructor({ sessionData, paymentSessionMetaData, paymentMethod, logger, dispatchToApp, }: {
39
- sessionData: string;
40
- paymentSessionMetaData: IPaymentSessionMetaData;
41
- paymentMethod: IPaymentMethod;
32
+ constructor({ paymentSessionData, parseData, logger, }: {
33
+ paymentSessionData: string;
34
+ parseData: IPaymentSessionMetaData;
42
35
  logger: Logger;
43
- dispatchToApp: (payload: {
44
- context: EventPayloadContext;
45
- }) => void;
46
36
  });
47
- private startPay;
48
- private setApplePayStatus;
37
+ startPay(): Promise<unknown>;
38
+ begin(): Promise<unknown>;
49
39
  private submitPay;
50
- submit(): Promise<void>;
51
- private getDeviceId;
52
- private initApplePaySession;
53
- private isCanMakePayments;
54
- private loadApplePaySdk;
55
- private abortPaySession;
56
- private addEventListener;
40
+ private setPayStatus;
41
+ initApplePaySession(): Promise<never>;
42
+ private abortSession;
57
43
  private get initSessionParams();
58
44
  private get isRequiredParameters();
45
+ private isCanMakePayments;
46
+ private loadApplePaySdk;
59
47
  private get checkScriptIsLoaded();
48
+ /**
49
+ * @description 非标方案,sdk目前无法直接监听国内不支持弹窗的关闭操作
50
+ */
51
+ private addEventListener;
52
+ private getDeviceId;
60
53
  }
54
+ export declare const isSkipRenderPaymentMethod: (parseData: IPaymentSessionMetaData) => boolean;
61
55
  export {};