@alipay/ams-checkout 0.0.1726734012-dev.18 → 0.0.1726734012-dev.19
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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/component/index.js +5 -0
- package/esm/core/instance/index.js +4 -3
- package/esm/foundation/product-processor/easysafepay/index.js +1 -1
- package/esm/foundation/utils/preload_helper.d.ts +4 -4
- package/esm/foundation/utils/preload_helper.js +52 -40
- package/esm/index.d.ts +6 -7
- package/esm/index.js +29 -14
- package/esm/types/index.d.ts +4 -0
- package/package.json +1 -1
@@ -50,6 +50,7 @@ import { SecurityBusSubscriber } from "../bus/ability/security";
|
|
50
50
|
import { TrackerBusSubscriber } from "../bus/ability/tracker";
|
51
51
|
import CoreInstance from "../instance/index";
|
52
52
|
import { loadChannelPneumaticControl } from "./appPreloadProcessing";
|
53
|
+
import PreloadHelper from "../../foundation/utils/preload_helper";
|
53
54
|
export var getComponentSign = function getComponentSign(params) {
|
54
55
|
var _params$paymentSessio = params.paymentSessionConfig,
|
55
56
|
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
@@ -388,6 +389,10 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
388
389
|
key: "preloadComponent",
|
389
390
|
value: function preloadComponent(channelType, productSceneVersion) {
|
390
391
|
var _this6 = this;
|
392
|
+
if (PreloadHelper.isWebAppPreloaded) {
|
393
|
+
console.log('[web-sdk] web app already preloaded');
|
394
|
+
return;
|
395
|
+
}
|
391
396
|
this.channelType = channelType;
|
392
397
|
this.productSceneVersion = productSceneVersion;
|
393
398
|
var MAX_CLEAR_TIME = 10000;
|
@@ -202,9 +202,10 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
202
202
|
var scene = storage.scene || getSecurityScene(securityConfig.product);
|
203
203
|
var securitySdk = this.securitySdkMap.get(scene);
|
204
204
|
if (!securitySdk) {
|
205
|
-
|
206
|
-
if (
|
207
|
-
|
205
|
+
securitySdk = PreloadHelper.getSecuritySdk(scene);
|
206
|
+
if (securitySdk) {
|
207
|
+
console.log('[web-sdk] return security sdk from preloaded');
|
208
|
+
this.securitySdkMap.set(scene, securitySdk);
|
208
209
|
}
|
209
210
|
}
|
210
211
|
return securitySdk;
|
@@ -16,7 +16,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
16
16
|
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; }
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
18
18
|
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); }
|
19
|
-
import PreloadHelper from "
|
19
|
+
import PreloadHelper from "../../../foundation/utils/preload_helper";
|
20
20
|
import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, PaymentMethodCategoryTypeEnum, ProductInfoCacheUtil, ProductSceneEnum, RiskSdkInfoEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
|
21
21
|
export var EasySafePayProcessor = /*#__PURE__*/function () {
|
22
22
|
function EasySafePayProcessor() {
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { PaymentMethodCategoryTypeEnum, ProductSceneEnum } from "../../types";
|
2
|
-
import { Security
|
2
|
+
import { Security } from '../../util/security';
|
3
3
|
export default class PreloadHelper {
|
4
|
-
|
5
|
-
|
4
|
+
static isWebAppPreloaded: boolean;
|
5
|
+
static isSecuritySDKPreloaded: boolean;
|
6
6
|
private static securitySdkMap;
|
7
7
|
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
|
8
|
-
static preloadSecuritySDK(product: ProductSceneEnum, securityRegion
|
8
|
+
static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
|
9
9
|
static getSecuritySdk(scene: any): Security;
|
10
10
|
static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
|
11
11
|
preloadUrl: string;
|
@@ -22,55 +22,67 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
22
22
|
key: "preloadWebApp",
|
23
23
|
value: function preloadWebApp(productScene, paymentMethodCategoryType) {
|
24
24
|
var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
setTimeout(function () {
|
41
|
-
var container = document.getElementById(containerId);
|
42
|
-
if (container) {
|
43
|
-
console.log('[web-sdk] remove preload web app');
|
44
|
-
document.body.removeChild(container);
|
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;
|
45
40
|
}
|
46
|
-
|
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
|
+
}
|
47
51
|
}
|
48
52
|
}, {
|
49
53
|
key: "preloadSecuritySDK",
|
50
|
-
value: function preloadSecuritySDK(product
|
54
|
+
value: function preloadSecuritySDK(product) {
|
51
55
|
var _this = this;
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
+
var h5gateway = storage.h5gateway || getSecurityHost(securityRegion);
|
65
|
+
var securitySdk = new Security({
|
66
|
+
scene: scene,
|
67
|
+
h5gateway: h5gateway
|
68
|
+
});
|
69
|
+
debugger;
|
70
|
+
securitySdk.initSecurity(function () {
|
71
|
+
_this.securitySdkMap.set(scene, securitySdk);
|
72
|
+
_this.isSecuritySDKPreloaded = true;
|
73
|
+
console.log('[web-sdk] preload security sdk succeed');
|
74
|
+
}, function () {
|
75
|
+
console.error('[web-sdk] preload security sdk failed');
|
76
|
+
});
|
77
|
+
} catch (error) {
|
78
|
+
console.error('[web-sdk] preload security sdk failed', error);
|
55
79
|
}
|
56
|
-
var storage = PreloadHelper.getSecurityConfigStorage(product);
|
57
|
-
var scene = storage.scene || getSecurityScene(product);
|
58
|
-
var h5gateway = storage.h5gateway || getSecurityHost(securityRegion);
|
59
|
-
var securitySdk = new Security({
|
60
|
-
scene: scene,
|
61
|
-
h5gateway: h5gateway
|
62
|
-
});
|
63
|
-
securitySdk.initSecurity(function () {
|
64
|
-
_this.securitySdkMap.set(scene, securitySdk);
|
65
|
-
_this.isSecuritySDKPreloaded = true;
|
66
|
-
}, function () {
|
67
|
-
console.error('[web-sdk] securitySdk init failed');
|
68
|
-
});
|
69
80
|
}
|
70
81
|
}, {
|
71
82
|
key: "getSecuritySdk",
|
72
83
|
value: function getSecuritySdk(scene) {
|
73
|
-
|
84
|
+
var result = this.securitySdkMap.get(scene);
|
85
|
+
return result;
|
74
86
|
}
|
75
87
|
}, {
|
76
88
|
key: "buildWebAppPreloadUrl",
|
@@ -125,5 +137,5 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
125
137
|
}();
|
126
138
|
_defineProperty(PreloadHelper, "isWebAppPreloaded", false);
|
127
139
|
_defineProperty(PreloadHelper, "isSecuritySDKPreloaded", false);
|
128
|
-
_defineProperty(PreloadHelper, "securitySdkMap",
|
140
|
+
_defineProperty(PreloadHelper, "securitySdkMap", new Map());
|
129
141
|
export { PreloadHelper as default };
|
package/esm/index.d.ts
CHANGED
@@ -1,28 +1,27 @@
|
|
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
|
-
import { SecurityRegionEnum } from './util/security';
|
8
7
|
export declare class AMSCheckout extends AMSComponent {
|
9
8
|
constructor(_options: IoptionsParams, channelType?: ComponentSignEnum[], productSceneVersion?: string);
|
10
9
|
}
|
11
10
|
export declare class AMSAutoDebit extends AMSCheckout {
|
12
11
|
constructor(options: IoptionsParams);
|
13
|
-
static preload(
|
12
|
+
static preload(options?: IPreloadOptions): void;
|
14
13
|
}
|
15
14
|
export declare class AMSAutoDebitPay extends AMSCheckout {
|
16
15
|
constructor(options: IoptionsParams);
|
17
|
-
static preload(
|
16
|
+
static preload(options?: IPreloadOptions): void;
|
18
17
|
}
|
19
18
|
export declare class AMSCashierPayment extends AMSCheckout {
|
20
19
|
constructor(options: IoptionsParams);
|
21
|
-
static preload(
|
20
|
+
static preload(options?: IPreloadOptions): void;
|
22
21
|
}
|
23
22
|
export declare class AMSVaulting extends AMSCheckout {
|
24
23
|
constructor(options: IoptionsParams);
|
25
|
-
static preload(
|
24
|
+
static preload(options?: IPreloadOptions): void;
|
26
25
|
}
|
27
26
|
export declare class AntomElement extends AMSCheckout {
|
28
27
|
constructor(options: IoptionsParams);
|
@@ -36,7 +35,7 @@ export declare class Element extends ElementComponent {
|
|
36
35
|
export declare class AMSEasyPay {
|
37
36
|
private core;
|
38
37
|
constructor(options: IoptionsParams);
|
39
|
-
static preload(): void;
|
38
|
+
static preload(options?: IPreloadOptions): void;
|
40
39
|
createComponent(params: IcreateComponent): void;
|
41
40
|
unmount(): void;
|
42
41
|
}
|
package/esm/index.js
CHANGED
@@ -37,7 +37,6 @@ export { AMSCheckoutPage } from "./core/component/ckp";
|
|
37
37
|
export * from "./types";
|
38
38
|
import { AntomSDKCore } from "./foundation/core";
|
39
39
|
import { EasySafePayProcessor } from "./foundation/product-processor/easysafepay";
|
40
|
-
import { SecurityRegionEnum } from "./util/security";
|
41
40
|
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
42
41
|
_inherits(AMSCheckout, _AMSComponent);
|
43
42
|
var _super = _createSuper(AMSCheckout);
|
@@ -67,9 +66,12 @@ export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
|
67
66
|
_createClass(AMSAutoDebit, null, [{
|
68
67
|
key: "preload",
|
69
68
|
value: function preload() {
|
70
|
-
var
|
71
|
-
|
72
|
-
|
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);
|
73
75
|
}
|
74
76
|
}]);
|
75
77
|
return AMSAutoDebit;
|
@@ -87,9 +89,12 @@ export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
|
|
87
89
|
_createClass(AMSAutoDebitPay, null, [{
|
88
90
|
key: "preload",
|
89
91
|
value: function preload() {
|
90
|
-
var
|
91
|
-
|
92
|
-
|
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);
|
93
98
|
}
|
94
99
|
}]);
|
95
100
|
return AMSAutoDebitPay;
|
@@ -127,7 +132,10 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
|
127
132
|
_createClass(AMSCashierPayment, null, [{
|
128
133
|
key: "preload",
|
129
134
|
value: function preload() {
|
130
|
-
var
|
135
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
136
|
+
securityRegion: 'SG',
|
137
|
+
environment: 'prod'
|
138
|
+
};
|
131
139
|
try {
|
132
140
|
var channelTypes;
|
133
141
|
var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
|
@@ -149,7 +157,7 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
|
149
157
|
try {
|
150
158
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
151
159
|
var _channelType = _step.value;
|
152
|
-
PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, _channelType);
|
160
|
+
PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, _channelType, options.environment);
|
153
161
|
}
|
154
162
|
} catch (err) {
|
155
163
|
_iterator.e(err);
|
@@ -159,7 +167,7 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
|
159
167
|
} catch (error) {
|
160
168
|
console.error('[web-sdk] preload web app error', error);
|
161
169
|
}
|
162
|
-
PreloadHelper.preloadSecuritySDK(ProductSceneEnum.CASHIER_PAYMENT, securityRegion);
|
170
|
+
PreloadHelper.preloadSecuritySDK(ProductSceneEnum.CASHIER_PAYMENT, options.securityRegion);
|
163
171
|
}
|
164
172
|
}]);
|
165
173
|
return AMSCashierPayment;
|
@@ -178,9 +186,12 @@ export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
|
|
178
186
|
_createClass(AMSVaulting, null, [{
|
179
187
|
key: "preload",
|
180
188
|
value: function preload() {
|
181
|
-
var
|
182
|
-
|
183
|
-
|
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);
|
184
195
|
}
|
185
196
|
}]);
|
186
197
|
return AMSVaulting;
|
@@ -255,7 +266,11 @@ export var AMSEasyPay = /*#__PURE__*/function () {
|
|
255
266
|
}], [{
|
256
267
|
key: "preload",
|
257
268
|
value: function preload() {
|
258
|
-
|
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);
|
259
274
|
}
|
260
275
|
}]);
|
261
276
|
return AMSEasyPay;
|
package/esm/types/index.d.ts
CHANGED
@@ -39,6 +39,10 @@ export interface IoptionsParams {
|
|
39
39
|
mode?: string;
|
40
40
|
securityRegion?: 'US' | 'SG' | 'DE';
|
41
41
|
}
|
42
|
+
export interface IPreloadOptions {
|
43
|
+
environment?: string;
|
44
|
+
securityRegion?: 'US' | 'SG' | 'DE';
|
45
|
+
}
|
42
46
|
export interface IApplePayOptionsParams extends Pick<IoptionsParams, 'locale' | 'environment' | 'onEventCallback' | 'analytics'> {
|
43
47
|
}
|
44
48
|
export type Iselector = string;
|