@alipay/ams-checkout 0.0.1723203704-dev.3 → 0.0.1724309103-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +0 -1
- package/esm/config/index.js +0 -8
- package/esm/constant/index.d.ts +1 -10
- package/esm/constant/index.js +0 -9
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +163 -0
- package/esm/core/component/index.js +6 -14
- package/esm/index.d.ts +2 -12
- package/esm/index.js +2 -39
- package/esm/plugin/applepay/component.js +1 -1
- package/esm/plugin/component/cashierApp.d.ts +3 -3
- package/esm/plugin/component/cashierApp.js +3 -29
- package/esm/plugin/component/component.inline.style.d.ts +9 -8
- package/esm/plugin/component/component.inline.style.js +6 -87
- package/esm/plugin/component/component.popup.style.d.ts +0 -1
- package/esm/plugin/component/component.popup.style.js +0 -3
- package/esm/plugin/component/index.js +47 -59
- package/esm/plugin/component/popupWindow.style.d.ts +2 -5
- package/esm/plugin/component/popupWindow.style.js +7 -55
- package/esm/plugin/paypal/index.js +0 -1
- package/esm/plugin/type.d.ts +0 -1
- package/esm/types/index.d.ts +4 -11
- package/esm/types/index.js +2 -10
- package/esm/util/security.d.ts +0 -1
- package/esm/util/security.js +1 -1
- package/package.json +1 -1
- package/esm/core/component/address.d.ts +0 -34
- package/esm/core/component/address.js +0 -298
- package/esm/core/instance/address.d.ts +0 -76
- package/esm/core/instance/address.js +0 -283
- package/esm/plugin/address/cashierApp.d.ts +0 -34
- package/esm/plugin/address/cashierApp.js +0 -218
- package/esm/plugin/address/channel.d.ts +0 -20
- package/esm/plugin/address/channel.js +0 -52
- package/esm/plugin/address/component.inline.style.d.ts +0 -11
- package/esm/plugin/address/component.inline.style.js +0 -38
- package/esm/plugin/address/component.popup.style.d.ts +0 -16
- package/esm/plugin/address/component.popup.style.js +0 -174
- package/esm/plugin/address/index.d.ts +0 -108
- package/esm/plugin/address/index.js +0 -862
- package/esm/plugin/address/popupWindow.style.d.ts +0 -8
- package/esm/plugin/address/popupWindow.style.js +0 -65
- package/esm/plugin/payment-element/utils.d.ts +0 -2
- package/esm/plugin/payment-element/utils.js +0 -6
- package/esm/types/address.d.ts +0 -92
- package/esm/types/address.js +0 -7
package/esm/types/index.js
CHANGED
@@ -15,11 +15,6 @@ export var renderDisplayTypeEnum = /*#__PURE__*/function (renderDisplayTypeEnum)
|
|
15
15
|
renderDisplayTypeEnum["inline"] = "inline";
|
16
16
|
return renderDisplayTypeEnum;
|
17
17
|
}({});
|
18
|
-
export var ComponentSignEnumV2 = /*#__PURE__*/function (ComponentSignEnumV2) {
|
19
|
-
ComponentSignEnumV2["ELEMENT_PAYMENT"] = "ELEMENT_PAYMENT_ALL";
|
20
|
-
ComponentSignEnumV2["ELEMENT_ADDRESS"] = "ELEMENT_ADDRESS_ALL";
|
21
|
-
return ComponentSignEnumV2;
|
22
|
-
}({});
|
23
18
|
export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
|
24
19
|
componentSignEnum["EASY_PAY_WALLET"] = "EASY_PAY_WALLET";
|
25
20
|
componentSignEnum["EASY_PAY_APM"] = "EASY_PAY_APM";
|
@@ -30,8 +25,7 @@ export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
|
|
30
25
|
componentSignEnum["AUTO_DEBIT_PAY_WALLET"] = "AUTO_DEBIT_PAY_WALLET";
|
31
26
|
componentSignEnum["NONE"] = "NONE";
|
32
27
|
componentSignEnum["VAULTING_CARD"] = "VAULTING_CARD";
|
33
|
-
componentSignEnum["
|
34
|
-
componentSignEnum["ELEMENT_ADDRESS"] = "ELEMENT_ADDRESS_ALL";
|
28
|
+
componentSignEnum["CHECKOUT_PAYMENT"] = "CHECKOUT_PAYMENT";
|
35
29
|
return componentSignEnum;
|
36
30
|
}({});
|
37
31
|
export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
@@ -42,8 +36,7 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
|
42
36
|
productSceneEnum["VAULTING"] = "VAULTING";
|
43
37
|
productSceneEnum["FLASH_BUY"] = "FLASH_BUY";
|
44
38
|
productSceneEnum["CARD_APPLE_PAY"] = "CARD_APPLE_PAY";
|
45
|
-
productSceneEnum["
|
46
|
-
productSceneEnum["ELEMENT_ADDRESS"] = "ELEMENT_ADDRESS";
|
39
|
+
productSceneEnum["CHECKOUT_PAYMENT"] = "CHECKOUT_PAYMENT";
|
47
40
|
return productSceneEnum;
|
48
41
|
}({});
|
49
42
|
export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
|
@@ -51,7 +44,6 @@ export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodC
|
|
51
44
|
paymentMethodCategoryTypeEnum["WALLET"] = "WALLET";
|
52
45
|
paymentMethodCategoryTypeEnum["BANK"] = "BANK";
|
53
46
|
paymentMethodCategoryTypeEnum["APM"] = "APM";
|
54
|
-
paymentMethodCategoryTypeEnum["ALL"] = "ALL";
|
55
47
|
return paymentMethodCategoryTypeEnum;
|
56
48
|
}({});
|
57
49
|
export var payPalConfigurationIntentEnum = /*#__PURE__*/function (payPalConfigurationIntentEnum) {
|
package/esm/util/security.d.ts
CHANGED
@@ -18,7 +18,6 @@ export declare const sceneMap: {
|
|
18
18
|
EASYPAY: string;
|
19
19
|
EASY_PAY: string;
|
20
20
|
FLASH_BUY: string;
|
21
|
-
ELEMENT_PAYMENT: string;
|
22
21
|
};
|
23
22
|
export declare const getSecurityHost: (region: string) => string;
|
24
23
|
export declare const getSecurityScene: (product: string) => string;
|
package/esm/util/security.js
CHANGED
@@ -24,7 +24,7 @@ export var securityHost = {
|
|
24
24
|
US: 'https://open-na-global.alipay.com/api/open/risk_client',
|
25
25
|
DE: 'https://open-de-global.alipay.com/api/open/risk_client'
|
26
26
|
};
|
27
|
-
export var sceneMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(
|
27
|
+
export var sceneMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, productSceneEnum.CASHIER_PAYMENT, 'Acquirer'), productSceneEnum.AUTO_DEBIT, 'Acquirer'), productSceneEnum.VAULTING, 'Acquirer'), productSceneEnum.CARD_APPLE_PAY, 'Acquirer'), "EASYPAY", 'EasyPay'), productSceneEnum.EASY_PAY, 'EasyPay'), productSceneEnum.FLASH_BUY, 'OneAccount');
|
28
28
|
export var getSecurityHost = function getSecurityHost(region) {
|
29
29
|
return securityHost[region] || securityHost[SecurityRegionEnum.SG];
|
30
30
|
};
|
package/package.json
CHANGED
@@ -1,34 +0,0 @@
|
|
1
|
-
import ComponentApp from '../../plugin/address';
|
2
|
-
import { componentSignEnum, IoptionsParams, IpaymentSessionMetaData, Iselector } from '../../types';
|
3
|
-
import { addressInitOption } from '../../types/address';
|
4
|
-
import CoreInstance from '../instance/address';
|
5
|
-
export declare const getComponentSign: (params: IpaymentSessionMetaData) => componentSignEnum;
|
6
|
-
export declare class AddressComponent extends CoreInstance {
|
7
|
-
_componentApp: ComponentApp;
|
8
|
-
channelType: componentSignEnum[];
|
9
|
-
productSceneVersion: string;
|
10
|
-
timer: any;
|
11
|
-
constructor(options: IoptionsParams);
|
12
|
-
private parameterInitAndCheck;
|
13
|
-
private pluginAppendIframe;
|
14
|
-
private savePreviousChannel;
|
15
|
-
/**
|
16
|
-
* 初始化 Bus总线的能力
|
17
|
-
*/
|
18
|
-
private registerBusAbility;
|
19
|
-
preloadComponent(channelType: any, productSceneVersion: any): void;
|
20
|
-
private clearPreloadIframe;
|
21
|
-
/**
|
22
|
-
* @description Create and render components in the specified element area
|
23
|
-
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
24
|
-
* @param selector - Necessary element selector ID
|
25
|
-
*/
|
26
|
-
mountComponent(params: addressInitOption, selector: Iselector): Promise<void>;
|
27
|
-
private mountComponentProcess;
|
28
|
-
/**
|
29
|
-
* @description Execute payment submission process
|
30
|
-
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
31
|
-
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
32
|
-
*/
|
33
|
-
getValue(data?: any): Promise<unknown>;
|
34
|
-
}
|
@@ -1,298 +0,0 @@
|
|
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 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
|
-
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
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5
|
-
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); } }
|
6
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
7
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
8
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
10
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
11
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
12
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
13
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
14
|
-
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; }
|
15
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
16
|
-
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); }
|
17
|
-
/**
|
18
|
-
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
19
|
-
*
|
20
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
21
|
-
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
22
|
-
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
23
|
-
*/
|
24
|
-
import { v4 as uuid } from 'uuid';
|
25
|
-
import { COMPONENTPLUGINID, EVENT } from "../../constant";
|
26
|
-
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
27
|
-
import ComponentApp from "../../plugin/address";
|
28
|
-
import { PaypalBusSubscriber } from "../../plugin/paypal";
|
29
|
-
import { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, renderDisplayTypeEnum } from "../../types";
|
30
|
-
import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
|
31
|
-
import { BusManager, BusMessage } from "../bus";
|
32
|
-
import { SDKCallbackBusSubscriber } from "../bus/ability/callback";
|
33
|
-
import { SecurityBusSubscriber } from "../bus/ability/security";
|
34
|
-
import { TrackerBusSubscriber } from "../bus/ability/tracker";
|
35
|
-
import CoreInstance from "../instance/address";
|
36
|
-
export var getComponentSign = function getComponentSign(params) {
|
37
|
-
var _params$paymentSessio = params.paymentSessionConfig,
|
38
|
-
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
39
|
-
_params$paymentSessio3 = _params$paymentSessio2.productScene,
|
40
|
-
productScene = _params$paymentSessio3 === void 0 ? '' : _params$paymentSessio3,
|
41
|
-
_params$paymentSessio4 = _params$paymentSessio2.paymentMethodCategoryType,
|
42
|
-
paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
|
43
|
-
if (productScene && paymentMethodCategoryType) return "".concat(productScene, "_").concat(paymentMethodCategoryType);
|
44
|
-
if (productScene) return "".concat(productScene);
|
45
|
-
return componentSignEnum.NONE;
|
46
|
-
};
|
47
|
-
var handleParams = function handleParams(params) {
|
48
|
-
var _params = Object.assign(params);
|
49
|
-
// 地址组件不通过传参 固定
|
50
|
-
var componentSign = componentSignEnum.ELEMENT_ADDRESS;
|
51
|
-
return Promise.resolve({
|
52
|
-
iframeNodesParams: _params,
|
53
|
-
componentSign: componentSign
|
54
|
-
});
|
55
|
-
};
|
56
|
-
export var AddressComponent = /*#__PURE__*/function (_CoreInstance) {
|
57
|
-
_inherits(AddressComponent, _CoreInstance);
|
58
|
-
var _super = _createSuper(AddressComponent);
|
59
|
-
function AddressComponent(options) {
|
60
|
-
var _this;
|
61
|
-
_classCallCheck(this, AddressComponent);
|
62
|
-
_this = _super.call(this, options);
|
63
|
-
// Instantiate the plug-in and set render
|
64
|
-
_defineProperty(_assertThisInitialized(_this), "_componentApp", void 0);
|
65
|
-
_defineProperty(_assertThisInitialized(_this), "channelType", void 0);
|
66
|
-
_defineProperty(_assertThisInitialized(_this), "productSceneVersion", void 0);
|
67
|
-
_defineProperty(_assertThisInitialized(_this), "timer", void 0);
|
68
|
-
var ComponentPlugin = new ComponentApp();
|
69
|
-
ComponentPlugin.setRender(createIframeNode);
|
70
|
-
ComponentPlugin.setPreloadRender(createPreloadIframeNode);
|
71
|
-
// Register Cashier Application Plug in
|
72
|
-
_this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
|
73
|
-
_this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
|
74
|
-
_this.registerBusAbility();
|
75
|
-
return _this;
|
76
|
-
}
|
77
|
-
_createClass(AddressComponent, [{
|
78
|
-
key: "parameterInitAndCheck",
|
79
|
-
value: function parameterInitAndCheck(_ref) {
|
80
|
-
var params = _ref.params,
|
81
|
-
selector = _ref.selector,
|
82
|
-
renderDisplayType = _ref.renderDisplayType;
|
83
|
-
this.options.mode = modeEnum.component;
|
84
|
-
this.options.networkMode = this.options.networkMode || networkModeEnum.session;
|
85
|
-
var _params = Object.assign({
|
86
|
-
selector: selector,
|
87
|
-
renderDisplayType: renderDisplayType
|
88
|
-
}, params);
|
89
|
-
return Promise.resolve(_params);
|
90
|
-
}
|
91
|
-
}, {
|
92
|
-
key: "pluginAppendIframe",
|
93
|
-
value: function pluginAppendIframe(appendParams) {
|
94
|
-
try {
|
95
|
-
return this._componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
|
96
|
-
} catch (error) {
|
97
|
-
return Promise.reject(error);
|
98
|
-
}
|
99
|
-
}
|
100
|
-
}, {
|
101
|
-
key: "savePreviousChannel",
|
102
|
-
value: function savePreviousChannel(iframeNodesParams) {
|
103
|
-
var _ref2 = iframeNodesParams || {},
|
104
|
-
componentSign = _ref2.componentSign;
|
105
|
-
var channelType = componentSign;
|
106
|
-
if (Array.isArray(this.channelType) && this.channelType.includes(channelType)) {
|
107
|
-
this.logger.logInfo({
|
108
|
-
title: 'preload_match'
|
109
|
-
}, {
|
110
|
-
preloadChannel: this.channelType,
|
111
|
-
preloadVersion: this.productSceneVersion,
|
112
|
-
sessionDataChannel: channelType
|
113
|
-
});
|
114
|
-
} else {
|
115
|
-
this.logger.logInfo({
|
116
|
-
title: 'preload_no_match'
|
117
|
-
}, {
|
118
|
-
preloadChannel: this.channelType,
|
119
|
-
preloadVersion: this.productSceneVersion,
|
120
|
-
sessionDataChannel: channelType
|
121
|
-
});
|
122
|
-
}
|
123
|
-
var previousChannel = {
|
124
|
-
channelType: channelType,
|
125
|
-
productSceneVersion: this.productSceneVersion
|
126
|
-
};
|
127
|
-
localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
|
128
|
-
}
|
129
|
-
/**
|
130
|
-
* 初始化 Bus总线的能力
|
131
|
-
*/
|
132
|
-
}, {
|
133
|
-
key: "registerBusAbility",
|
134
|
-
value: function registerBusAbility() {
|
135
|
-
var _this$originOptions,
|
136
|
-
_this2 = this;
|
137
|
-
BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod, this.logger);
|
138
|
-
BusManager.clear();
|
139
|
-
BusManager.addInterceptor({
|
140
|
-
onPublishException: function onPublishException(message, e) {
|
141
|
-
_this2.logger.logError({
|
142
|
-
title: 'onBusPublishException'
|
143
|
-
}, _objectSpread(_objectSpread({}, message), {}, {
|
144
|
-
errorMessage: JSON.stringify(e)
|
145
|
-
}));
|
146
|
-
}
|
147
|
-
});
|
148
|
-
// subscribe basic ablility
|
149
|
-
BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
|
150
|
-
var _this2$_componentApp;
|
151
|
-
(_this2$_componentApp = _this2._componentApp) === null || _this2$_componentApp === void 0 || (_this2$_componentApp = _this2$_componentApp.AMSSDK) === null || _this2$_componentApp === void 0 || _this2$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
|
152
|
-
}));
|
153
|
-
BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
|
154
|
-
var _this2$_componentApp2;
|
155
|
-
return (_this2$_componentApp2 = _this2._componentApp) === null || _this2$_componentApp2 === void 0 ? void 0 : _this2$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
|
156
|
-
}));
|
157
|
-
BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
158
|
-
// subscribe plugin
|
159
|
-
BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
|
160
|
-
BusManager.subscribe(new PaypalBusSubscriber(this.logger));
|
161
|
-
}
|
162
|
-
}, {
|
163
|
-
key: "preloadComponent",
|
164
|
-
value: function preloadComponent(channelType, productSceneVersion) {
|
165
|
-
var _this3 = this;
|
166
|
-
this.channelType = channelType;
|
167
|
-
this.productSceneVersion = productSceneVersion;
|
168
|
-
var MAX_CLEAR_TIME = 10000;
|
169
|
-
if (Array.isArray(channelType)) {
|
170
|
-
for (var i = 0; i < channelType.length; i++) {
|
171
|
-
this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
|
172
|
-
}
|
173
|
-
} else {
|
174
|
-
this.logger.logError({
|
175
|
-
title: 'performance_optimization_channelType_error'
|
176
|
-
}, {
|
177
|
-
channelType: channelType
|
178
|
-
});
|
179
|
-
}
|
180
|
-
this.timer = setTimeout(function () {
|
181
|
-
_this3.clearPreloadIframe(true);
|
182
|
-
}, MAX_CLEAR_TIME);
|
183
|
-
}
|
184
|
-
}, {
|
185
|
-
key: "clearPreloadIframe",
|
186
|
-
value: function clearPreloadIframe() {
|
187
|
-
var isTimeOut = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
188
|
-
!isTimeOut && clearTimeout(this.timer);
|
189
|
-
if (Array.isArray(this.channelType)) {
|
190
|
-
for (var i = 0; i < this.channelType.length; i++) {
|
191
|
-
var iframe = document.getElementById("ams-checkout-component-".concat(this.channelType[i], "-").concat(this.productSceneVersion));
|
192
|
-
iframe && document.body.removeChild(iframe);
|
193
|
-
}
|
194
|
-
}
|
195
|
-
if (!isTimeOut) {
|
196
|
-
this.logger.logInfo({
|
197
|
-
title: 'performance_optimization_clearPreloadIframe'
|
198
|
-
});
|
199
|
-
} else {
|
200
|
-
this.logger.logInfo({
|
201
|
-
title: 'performance_optimization_clearPreloadIframe_timeout'
|
202
|
-
});
|
203
|
-
}
|
204
|
-
}
|
205
|
-
/**
|
206
|
-
* @description Create and render components in the specified element area
|
207
|
-
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
208
|
-
* @param selector - Necessary element selector ID
|
209
|
-
*/
|
210
|
-
}, {
|
211
|
-
key: "mountComponent",
|
212
|
-
value: function mountComponent(params, selector) {
|
213
|
-
var _this4 = this;
|
214
|
-
this.clearPreloadIframe();
|
215
|
-
this.logger.setComponentStartTime(Date.now());
|
216
|
-
return this.parameterInitAndCheck({
|
217
|
-
params: params,
|
218
|
-
renderDisplayType: renderDisplayTypeEnum.inline,
|
219
|
-
selector: selector
|
220
|
-
}).then(function (_params) {
|
221
|
-
return handleParams(_params);
|
222
|
-
}).catch(function (error) {
|
223
|
-
_this4.logger.logError({
|
224
|
-
title: 'sdk_error_parameter'
|
225
|
-
}, {
|
226
|
-
params: JSON.stringify(params)
|
227
|
-
}).send();
|
228
|
-
_this4._eventCenter.emit(EVENT.error.name, error);
|
229
|
-
return Promise.reject(error);
|
230
|
-
}).then(function (appendParams) {
|
231
|
-
return _this4.mountComponentProcess(appendParams);
|
232
|
-
});
|
233
|
-
}
|
234
|
-
}, {
|
235
|
-
key: "mountComponentProcess",
|
236
|
-
value: function mountComponentProcess(appendParams) {
|
237
|
-
var _this$getBusActionNam;
|
238
|
-
this._appendParams = appendParams;
|
239
|
-
var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.mountComponent;
|
240
|
-
if (actionName && BusManager.isSubscribed(actionName)) {
|
241
|
-
// 执行出错了,在通用拦截器返回
|
242
|
-
BusManager.publish(new BusMessage(actionName, JSON.stringify({
|
243
|
-
appendParams: appendParams,
|
244
|
-
options: this.originOptions
|
245
|
-
})));
|
246
|
-
return Promise.resolve();
|
247
|
-
}
|
248
|
-
this.savePreviousChannel(appendParams);
|
249
|
-
return this.pluginAppendIframe(appendParams);
|
250
|
-
}
|
251
|
-
|
252
|
-
/**
|
253
|
-
* @description Execute payment submission process
|
254
|
-
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
255
|
-
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
256
|
-
*/
|
257
|
-
}, {
|
258
|
-
key: "getValue",
|
259
|
-
value: function getValue(data) {
|
260
|
-
var _this5 = this;
|
261
|
-
return new Promise(function (resolve, reject) {
|
262
|
-
try {
|
263
|
-
var _this5$getBusActionNa;
|
264
|
-
var eventCallbackId = uuid();
|
265
|
-
_this5.logger.logInfo({
|
266
|
-
title: 'sdk_event_apiGetValue'
|
267
|
-
});
|
268
|
-
var actionName = (_this5$getBusActionNa = _this5.getBusActionNames()) === null || _this5$getBusActionNa === void 0 ? void 0 : _this5$getBusActionNa.getValue;
|
269
|
-
if (actionName && BusManager.isSubscribed(actionName)) {
|
270
|
-
// 执行出错了,在通用拦截器返回
|
271
|
-
BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
|
272
|
-
appendParams: _this5._appendParams,
|
273
|
-
options: _this5.originOptions,
|
274
|
-
data: data
|
275
|
-
}))).then(function (busMessage) {
|
276
|
-
resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
|
277
|
-
});
|
278
|
-
} else {
|
279
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
280
|
-
_this5._eventCenter.once(eventCallbackId, function (_data) {
|
281
|
-
resolve(_data);
|
282
|
-
});
|
283
|
-
_this5._componentApp.dispatchToApp({
|
284
|
-
context: {
|
285
|
-
event: 'getValue',
|
286
|
-
eventCallbackId: eventCallbackId,
|
287
|
-
data: data
|
288
|
-
}
|
289
|
-
});
|
290
|
-
}
|
291
|
-
} catch (error) {
|
292
|
-
reject(error);
|
293
|
-
}
|
294
|
-
});
|
295
|
-
}
|
296
|
-
}]);
|
297
|
-
return AddressComponent;
|
298
|
-
}(CoreInstance);
|
@@ -1,76 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
-
*
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
-
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
6
|
-
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
|
-
*/
|
8
|
-
import { ComponentActionNamesType } from 'src/plugin/type';
|
9
|
-
import type { AMSCheckoutOptions, InitSecurityConfig } from '../../types/index';
|
10
|
-
import { IAppendAddressParams } from '../../types/address';
|
11
|
-
import { IoptionsAddressParams } from '../../types/address';
|
12
|
-
import { EventCenter } from '../../util/index';
|
13
|
-
import { Logger } from '../../util/logger';
|
14
|
-
import { Security } from '../../util/security';
|
15
|
-
export default class AMSADDRESSSDK {
|
16
|
-
options: AMSCheckoutOptions;
|
17
|
-
originOptions: IoptionsAddressParams;
|
18
|
-
logger: Logger;
|
19
|
-
_eventCenter: EventCenter;
|
20
|
-
_instanceId: string;
|
21
|
-
_storageId: string;
|
22
|
-
_appendParams: IAppendAddressParams;
|
23
|
-
protected securitySdkMap: Map<string, Security>;
|
24
|
-
protected plugins: Map<string, any>;
|
25
|
-
constructor(options: IoptionsAddressParams);
|
26
|
-
private preInitSecurity;
|
27
|
-
/**
|
28
|
-
* @description init security SDK
|
29
|
-
* @param product Product Scenarios
|
30
|
-
* @param scene Scenario of the product (compatible with old version parameters, about to be deleted)
|
31
|
-
*/
|
32
|
-
initSecurity({ product, scene, }: InitSecurityConfig & {
|
33
|
-
scene?: string;
|
34
|
-
}): void;
|
35
|
-
/**
|
36
|
-
* @description Obtain security SDK through scenario identification
|
37
|
-
*/
|
38
|
-
_getSecuritySDKByProductScene(securityConfig: InitSecurityConfig): Security;
|
39
|
-
/**
|
40
|
-
* @description New security SDK through scenario identification
|
41
|
-
*/
|
42
|
-
_newSecuritySDKByScene(securityConfig: InitSecurityConfig, successCallback?: () => void, failCallback?: (errMsg?: string) => void): Security;
|
43
|
-
/**
|
44
|
-
* @description Obtain risk control configuration in local storage
|
45
|
-
*/
|
46
|
-
private getSecurityConfigStorage;
|
47
|
-
/**
|
48
|
-
* @description Set the sdk basic configuration
|
49
|
-
*/
|
50
|
-
private _setOptions;
|
51
|
-
/**
|
52
|
-
* @description Set environment variables
|
53
|
-
*/
|
54
|
-
private _setEnv;
|
55
|
-
/**
|
56
|
-
* @description Set UI and Network Mode
|
57
|
-
*/
|
58
|
-
private _setMode;
|
59
|
-
/**
|
60
|
-
* @description Initialize event related tasks
|
61
|
-
*/
|
62
|
-
private _initEvent;
|
63
|
-
/**
|
64
|
-
* @description Register plug-in
|
65
|
-
*/
|
66
|
-
protected _registerPlugin(pluginId: string, plugin: any): void;
|
67
|
-
/**
|
68
|
-
* @description Get Plug-in
|
69
|
-
*/
|
70
|
-
protected _getPlugin(pluginId: string): any;
|
71
|
-
/**
|
72
|
-
* @description Overlay Subscription
|
73
|
-
*/
|
74
|
-
protected _overrideSubscription(name: string, func: any, funcKey: string): void;
|
75
|
-
protected getBusActionNames(): ComponentActionNamesType;
|
76
|
-
}
|