@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730706734-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +6 -1
- package/esm/constant/index.js +80 -3
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/{foundation/service/api-bus → core/bus}/ability/callback.js +1 -1
- package/esm/core/bus/ability/globalData.d.ts +10 -0
- package/esm/{foundation/service/api-bus → core/bus}/ability/globalData.js +2 -2
- package/esm/{foundation/service/api-bus → core/bus}/ability/request.d.ts +1 -1
- package/esm/{foundation/service/api-bus → core/bus}/ability/request.js +2 -2
- package/esm/core/bus/ability/security.d.ts +10 -0
- package/esm/core/bus/ability/security.js +104 -0
- package/esm/core/bus/ability/tracker.d.ts +9 -0
- package/esm/core/bus/ability/tracker.js +77 -0
- package/esm/core/bus/index.d.ts +125 -0
- package/esm/core/bus/index.js +366 -0
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/appPreloadProcessing.d.ts +1 -0
- package/esm/core/component/appPreloadProcessing.js +91 -0
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +166 -0
- package/esm/core/component/element/components/address.d.ts +19 -0
- package/esm/core/component/element/components/address.js +68 -0
- package/esm/core/component/element/components/auth.d.ts +17 -0
- package/esm/core/component/element/components/auth.js +59 -0
- package/esm/core/component/element/components/payment.d.ts +19 -0
- package/esm/core/component/element/components/payment.js +74 -0
- package/esm/core/component/element/element-mock.d.ts +2 -0
- package/esm/core/component/element/element-mock.js +263 -0
- package/esm/core/component/element/index.d.ts +47 -0
- package/esm/core/component/element/index.js +776 -0
- package/esm/core/component/element/mock.d.ts +3 -0
- package/esm/core/component/element/mock.js +1156 -0
- package/esm/core/component/element/type.d.ts +176 -0
- package/esm/core/component/element/type.js +34 -0
- package/esm/core/component/element/utils.d.ts +13 -0
- package/esm/core/component/element/utils.js +6 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +535 -0
- package/esm/core/drop-in/index.d.ts +22 -0
- package/esm/core/drop-in/index.js +104 -0
- package/esm/core/instance/index.d.ts +89 -0
- package/esm/core/instance/index.js +500 -0
- package/esm/foundation/core/index.d.ts +3 -3
- package/esm/foundation/core/index.js +51 -114
- package/esm/foundation/index.d.ts +3 -5
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +4 -7
- package/esm/foundation/product-processor/easysafepay/deps.js +2 -5
- package/esm/foundation/product-processor/easysafepay/index.d.ts +4 -5
- package/esm/foundation/product-processor/easysafepay/index.js +114 -174
- package/esm/foundation/service/container/index.js +5 -5
- package/esm/foundation/service/container/popup.js +1 -1
- package/esm/foundation/service/event-bus/ability/callback.js +55 -0
- package/esm/foundation/service/{api-bus → event-bus}/ability/globalData.d.ts +1 -1
- package/esm/foundation/service/event-bus/ability/globalData.js +89 -0
- package/esm/foundation/service/event-bus/ability/request.d.ts +10 -0
- package/esm/foundation/service/event-bus/ability/request.js +151 -0
- package/esm/foundation/service/{api-bus → event-bus}/ability/security.js +19 -29
- package/esm/foundation/service/{api-bus → event-bus}/ability/tracker.js +1 -1
- package/esm/foundation/service/{api-bus → event-bus}/busManager.js +1 -1
- package/esm/foundation/service/event-center.d.ts +5 -4
- package/esm/foundation/service/event-center.js +39 -8
- package/esm/foundation/service/global-data/index.js +5 -4
- package/esm/foundation/service/index.js +1 -1
- package/esm/foundation/service/requester/requester.js +11 -14
- package/esm/foundation/service/security/index.d.ts +7 -9
- package/esm/foundation/service/security/index.js +44 -113
- package/esm/foundation/utils/redirect_utils.js +8 -24
- package/esm/foundation/utils/web_app_url_utils.d.ts +2 -11
- package/esm/foundation/utils/web_app_url_utils.js +2 -17
- package/esm/index.d.ts +30 -1
- package/esm/index.js +147 -7
- package/esm/plugin/applepay/component.d.ts +50 -0
- package/esm/plugin/applepay/component.js +339 -0
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/plugin/applepay/interface.d.ts +161 -0
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/plugin/applepay/service.d.ts +54 -0
- package/esm/plugin/applepay/service.js +289 -0
- package/esm/plugin/component/cashierApp.d.ts +36 -0
- package/esm/plugin/component/cashierApp.js +245 -0
- package/esm/{component → plugin/component}/channel.d.ts +2 -1
- package/esm/{component → plugin/component}/channel.js +37 -1
- package/esm/{component → plugin/component}/component.inline.style.d.ts +2 -2
- package/esm/{component → plugin/component}/component.inline.style.js +7 -6
- package/esm/{component → plugin/component}/component.popup.style.d.ts +1 -1
- package/esm/{component → plugin/component}/component.popup.style.js +4 -4
- package/esm/plugin/component/index.d.ts +126 -0
- package/esm/plugin/component/index.js +1862 -0
- package/esm/{component → plugin/component}/popupWindow.style.js +2 -2
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/drop-in/index.d.ts +71 -0
- package/esm/plugin/drop-in/index.js +324 -0
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +7 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +390 -0
- package/esm/plugin/type.d.ts +34 -0
- package/esm/plugin/type.js +1 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/service/element.d.ts +4 -0
- package/esm/service/element.js +51 -0
- package/esm/service/index.d.ts +1 -0
- package/esm/service/index.js +2 -0
- package/esm/types/index.d.ts +218 -22
- package/esm/types/index.js +47 -4
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +2 -2
- package/esm/util/getBackScheme.js +2 -94
- package/esm/util/index.d.ts +11 -1
- package/esm/util/index.js +84 -4
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/util/ua/index.d.ts +2 -0
- package/esm/util/ua/index.js +2 -0
- package/esm/util/ua/isAndroid.d.ts +4 -0
- package/esm/util/ua/isAndroid.js +7 -0
- package/esm/util/ua/isIOS.d.ts +4 -0
- package/esm/util/ua/isIOS.js +7 -0
- package/package.json +2 -1
- package/esm/foundation/utils/payment_product_utils.d.ts +0 -13
- package/esm/foundation/utils/payment_product_utils.js +0 -38
- /package/esm/{foundation/service/api-bus → core/bus}/interface.d.ts +0 -0
- /package/esm/{foundation/service/api-bus → core/bus}/interface.js +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/ability/callback.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/ability/security.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/ability/tracker.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/busManager.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/index.d.ts +0 -0
- /package/esm/foundation/service/{api-bus → event-bus}/index.js +0 -0
- /package/esm/{component → plugin/component}/popupWindow.style.d.ts +0 -0
@@ -0,0 +1,166 @@
|
|
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 { v4 as uuid } from 'uuid';
|
9
|
+
import { EnvironmentEnum } from "../../../types";
|
10
|
+
import { queryParse } from "../../../util";
|
11
|
+
import { LogConfig, Logger } from "../../../util/logger";
|
12
|
+
var CKP_PAYMENT_PAGE_HOST = {
|
13
|
+
DEV: 'https://dev.page.alipay.net',
|
14
|
+
TEST: 'https://test.page.alipay.net',
|
15
|
+
PRE: 'https://pre.ac.alipay.com',
|
16
|
+
PROD: 'https://ac.alipay.com'
|
17
|
+
};
|
18
|
+
|
19
|
+
// for local development
|
20
|
+
|
21
|
+
var CKP_PAGE_ADDRESS = '/page/antom-web-checkout-v2/checkout-page/pages/payment/index.html';
|
22
|
+
export var getCKPPageAddress = function getCKPPageAddress(env) {
|
23
|
+
switch (env) {
|
24
|
+
case 'dev':
|
25
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.DEV).concat(CKP_PAGE_ADDRESS);
|
26
|
+
case 'sit':
|
27
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.TEST).concat(CKP_PAGE_ADDRESS);
|
28
|
+
case 'pre':
|
29
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.PRE).concat(CKP_PAGE_ADDRESS);
|
30
|
+
case 'prod':
|
31
|
+
case 'sandbox':
|
32
|
+
case 'light_sandbox':
|
33
|
+
return "".concat(CKP_PAYMENT_PAGE_HOST.PROD).concat(CKP_PAGE_ADDRESS);
|
34
|
+
default:
|
35
|
+
// for local development, e.g. http://localhost:5173/checkout-page/src/pages/payment/index.html
|
36
|
+
return env;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
export var AMSCheckoutPage = /*#__PURE__*/function () {
|
40
|
+
function AMSCheckoutPage(options) {
|
41
|
+
var _this = this;
|
42
|
+
_classCallCheck(this, AMSCheckoutPage);
|
43
|
+
_defineProperty(this, "logger", void 0);
|
44
|
+
_defineProperty(this, "_instanceId", void 0);
|
45
|
+
_defineProperty(this, "originOptions", void 0);
|
46
|
+
_defineProperty(this, "APP_IFRAME_ID", 'antom-checkout-page-sub-page-iframe');
|
47
|
+
_defineProperty(this, "eventListener", void 0);
|
48
|
+
_defineProperty(this, "generateIframeSrc", function (sessionData) {
|
49
|
+
var env = _this.originOptions.environment || 'prod';
|
50
|
+
var session = sessionData || '';
|
51
|
+
var lang = _this.originOptions.locale || 'en_US';
|
52
|
+
var ckpPageAddress = getCKPPageAddress(env);
|
53
|
+
console.log('[antom-web-sdk] <antom-checkout-page> generateIframeSrc', _this.originOptions, env, session, lang, ckpPageAddress);
|
54
|
+
|
55
|
+
// 先获取去除的 query 参数的 url
|
56
|
+
var url = ckpPageAddress.split('?')[0];
|
57
|
+
var queryObj = queryParse(ckpPageAddress);
|
58
|
+
queryObj.sessionData = session;
|
59
|
+
queryObj.lang = lang;
|
60
|
+
queryObj.mode = 'embed';
|
61
|
+
if (env === 'sandbox') {
|
62
|
+
queryObj.shadow = 'true';
|
63
|
+
}
|
64
|
+
Object.keys(queryObj).forEach(function (key) {
|
65
|
+
url += "".concat(url.includes('?') ? '&' : '?').concat(key, "=").concat(encodeURIComponent(queryObj[key]));
|
66
|
+
});
|
67
|
+
return url;
|
68
|
+
});
|
69
|
+
_defineProperty(this, "eventListenerWrapper", function (event) {
|
70
|
+
var _ref = JSON.parse(event.data) || {},
|
71
|
+
code = _ref.code,
|
72
|
+
message = _ref.message,
|
73
|
+
result = _ref.result;
|
74
|
+
if (code && code.startsWith('SDK_PAYMENT')) {
|
75
|
+
var _this$eventListener;
|
76
|
+
console.log('[antom-web-sdk] <antom-checkout-page> eventListenerWrapper', event, message, result);
|
77
|
+
(_this$eventListener = _this.eventListener) === null || _this$eventListener === void 0 || _this$eventListener.call(_this, {
|
78
|
+
code: code,
|
79
|
+
message: message,
|
80
|
+
result: result
|
81
|
+
});
|
82
|
+
}
|
83
|
+
});
|
84
|
+
_defineProperty(this, "addListener", function () {
|
85
|
+
window.addEventListener('message', _this.eventListenerWrapper);
|
86
|
+
});
|
87
|
+
_defineProperty(this, "removeListener", function () {
|
88
|
+
window.removeEventListener('message', _this.eventListenerWrapper);
|
89
|
+
});
|
90
|
+
options.environment = options.environment || EnvironmentEnum.prod;
|
91
|
+
this._instanceId = uuid();
|
92
|
+
this.originOptions = options;
|
93
|
+
this.eventListener = options.onEventCallback;
|
94
|
+
this.logger = new Logger(LogConfig, ![EnvironmentEnum.prod, EnvironmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
|
95
|
+
Logger.setInstance(this.logger);
|
96
|
+
this.logger.setMedta({
|
97
|
+
instanceId: this._instanceId
|
98
|
+
});
|
99
|
+
this.logger.initTracker();
|
100
|
+
this.logger.setComponentStartTime(Date.now());
|
101
|
+
this.logger.setTrackId(this._instanceId);
|
102
|
+
this.logger.logInfo({
|
103
|
+
title: 'NEW_AMSSDK_BY_MECHANT',
|
104
|
+
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
|
105
|
+
}).send();
|
106
|
+
}
|
107
|
+
_createClass(AMSCheckoutPage, [{
|
108
|
+
key: "mountComponent",
|
109
|
+
value:
|
110
|
+
/**
|
111
|
+
* 挂载组件
|
112
|
+
*/
|
113
|
+
function mountComponent(params, selector) {
|
114
|
+
if (params.sessionData === undefined || params.sessionData === '' || typeof params.sessionData !== 'string') {
|
115
|
+
this.logger.logError({
|
116
|
+
title: 'PARAMS_ERROR_INVALID_SESSION_DATA'
|
117
|
+
});
|
118
|
+
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: sessionData is required and must be a string');
|
119
|
+
throw new Error('PARAMS_ERROR_INVALID_SESSION_DATA');
|
120
|
+
}
|
121
|
+
if (document.querySelector(this.APP_IFRAME_ID)) {
|
122
|
+
this.logger.logError({
|
123
|
+
title: 'PARAMS_ERROR_ALREADY_MOUNTED'
|
124
|
+
});
|
125
|
+
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: already mounted, please unmount first');
|
126
|
+
throw new Error('PARAMS_ERROR_ALREADY_MOUNTED');
|
127
|
+
}
|
128
|
+
this.addListener();
|
129
|
+
var ckpPageAddress = this.generateIframeSrc(params.sessionData);
|
130
|
+
var iframe = document.createElement('iframe');
|
131
|
+
iframe.id = this.APP_IFRAME_ID;
|
132
|
+
iframe.src = ckpPageAddress;
|
133
|
+
iframe.width = '100%';
|
134
|
+
iframe.height = '100%';
|
135
|
+
iframe.style.border = 'none';
|
136
|
+
var wrapper = document.querySelector(selector);
|
137
|
+
if (wrapper) {
|
138
|
+
wrapper.innerHTML = '';
|
139
|
+
wrapper.appendChild(iframe);
|
140
|
+
} else {
|
141
|
+
this.logger.logError({
|
142
|
+
title: 'PARAMS_ERROR_INVALID_SELECTOR'
|
143
|
+
});
|
144
|
+
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: invalid selector');
|
145
|
+
this.removeListener();
|
146
|
+
throw new Error('PARAMS_ERROR_INVALID_SELECTOR');
|
147
|
+
}
|
148
|
+
return Promise.resolve();
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* 卸载组件
|
153
|
+
*/
|
154
|
+
}, {
|
155
|
+
key: "unmount",
|
156
|
+
value: function unmount() {
|
157
|
+
this.removeListener();
|
158
|
+
var iframe = document.getElementById(this.APP_IFRAME_ID);
|
159
|
+
if (iframe) {
|
160
|
+
iframe.remove();
|
161
|
+
}
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
}]);
|
165
|
+
return AMSCheckoutPage;
|
166
|
+
}();
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { AddressMountComponentsParams } from '../type';
|
2
|
+
interface ElementAddressMountOptions extends Omit<AddressMountComponentsParams, 'type'> {
|
3
|
+
selector: string;
|
4
|
+
}
|
5
|
+
export declare class ElementAddressComponent {
|
6
|
+
private sdk;
|
7
|
+
private elementContainer;
|
8
|
+
private isConnect;
|
9
|
+
constructor();
|
10
|
+
create(options: {
|
11
|
+
environment: string;
|
12
|
+
locale: string;
|
13
|
+
appVersion: string;
|
14
|
+
}, isConnect: boolean): void;
|
15
|
+
mount(sessionData: string, options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
|
16
|
+
update(): void;
|
17
|
+
unmount(): void;
|
18
|
+
}
|
19
|
+
export {};
|
@@ -0,0 +1,68 @@
|
|
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 { AddressComponent } from "../../address";
|
9
|
+
export var ElementAddressComponent = /*#__PURE__*/function () {
|
10
|
+
function ElementAddressComponent() {
|
11
|
+
_classCallCheck(this, ElementAddressComponent);
|
12
|
+
_defineProperty(this, "sdk", void 0);
|
13
|
+
_defineProperty(this, "elementContainer", void 0);
|
14
|
+
_defineProperty(this, "isConnect", void 0);
|
15
|
+
}
|
16
|
+
_createClass(ElementAddressComponent, [{
|
17
|
+
key: "create",
|
18
|
+
value: function create(options, isConnect) {
|
19
|
+
this.isConnect = isConnect;
|
20
|
+
this.sdk = new AddressComponent(options);
|
21
|
+
}
|
22
|
+
}, {
|
23
|
+
key: "mount",
|
24
|
+
value: function mount(sessionData, options) {
|
25
|
+
var _this = this;
|
26
|
+
var elementContainer = document.querySelector(options.selector);
|
27
|
+
if (this.isConnect) {
|
28
|
+
elementContainer.style.display = 'none';
|
29
|
+
}
|
30
|
+
return new Promise(function (resolve) {
|
31
|
+
_this.sdk.mountComponent({
|
32
|
+
sessionData: sessionData,
|
33
|
+
debugProps: options.debugProps,
|
34
|
+
configParams: options.configParams,
|
35
|
+
appearance: options.appearance,
|
36
|
+
prefillValue: options.prefillValue,
|
37
|
+
appendAliasContainerId: true
|
38
|
+
}, options.selector).then(function () {
|
39
|
+
var _elementContainer$get;
|
40
|
+
_this.elementContainer = elementContainer;
|
41
|
+
var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
|
42
|
+
resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
|
43
|
+
}, function () {
|
44
|
+
resolve(undefined);
|
45
|
+
});
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}, {
|
49
|
+
key: "update",
|
50
|
+
value: function update() {
|
51
|
+
if (this.elementContainer && this.isConnect) {
|
52
|
+
this.elementContainer.style.display = '';
|
53
|
+
}
|
54
|
+
// 下发数据
|
55
|
+
}
|
56
|
+
}, {
|
57
|
+
key: "unmount",
|
58
|
+
value: function unmount() {
|
59
|
+
var _this$elementContaine, _this$elementContaine2;
|
60
|
+
var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
|
61
|
+
if (containers !== null && containers !== void 0 && containers[0]) {
|
62
|
+
var _containers$, _containers$$remove;
|
63
|
+
(_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}]);
|
67
|
+
return ElementAddressComponent;
|
68
|
+
}();
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { LinkAuthMountOptions } from '../type';
|
2
|
+
interface ElementAuthMountOptions extends Omit<LinkAuthMountOptions, 'type' | 'debugProps'> {
|
3
|
+
selector: string;
|
4
|
+
url: string;
|
5
|
+
}
|
6
|
+
export declare class ElementAuthComponent {
|
7
|
+
private elementContainer;
|
8
|
+
constructor();
|
9
|
+
create(options: {
|
10
|
+
environment: string;
|
11
|
+
locale: string;
|
12
|
+
}): void;
|
13
|
+
mount(options: ElementAuthMountOptions): Promise<HTMLIFrameElement | undefined>;
|
14
|
+
update(height?: number): void;
|
15
|
+
unmount(): void;
|
16
|
+
}
|
17
|
+
export {};
|
@@ -0,0 +1,59 @@
|
|
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 { createIframe } from "../../../../foundation/service/container/utils";
|
9
|
+
import { createInlineBaseElement } from "../../../../plugin/component/component.inline.style";
|
10
|
+
export var ElementAuthComponent = /*#__PURE__*/function () {
|
11
|
+
function ElementAuthComponent() {
|
12
|
+
_classCallCheck(this, ElementAuthComponent);
|
13
|
+
_defineProperty(this, "elementContainer", void 0);
|
14
|
+
}
|
15
|
+
_createClass(ElementAuthComponent, [{
|
16
|
+
key: "create",
|
17
|
+
value: function create(options) {}
|
18
|
+
}, {
|
19
|
+
key: "mount",
|
20
|
+
value: function mount(options) {
|
21
|
+
var _this = this;
|
22
|
+
return new Promise(function (resolve) {
|
23
|
+
try {
|
24
|
+
var selector = options.selector,
|
25
|
+
url = options.url;
|
26
|
+
var containerSelector = "antom-sdk-web-app-".concat(selector);
|
27
|
+
var container = createInlineBaseElement(selector);
|
28
|
+
var webApp = createIframe(containerSelector);
|
29
|
+
webApp.src = url;
|
30
|
+
container.appendChild(webApp);
|
31
|
+
_this.elementContainer = container;
|
32
|
+
resolve(webApp);
|
33
|
+
} catch (error) {
|
34
|
+
resolve(undefined);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}
|
38
|
+
}, {
|
39
|
+
key: "update",
|
40
|
+
value: function update() {
|
41
|
+
var _this$elementContaine, _this$elementContaine2;
|
42
|
+
var height = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
43
|
+
var iframes = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'iframe');
|
44
|
+
if (iframes !== null && iframes !== void 0 && iframes[0]) {
|
45
|
+
var iframe = iframes[0];
|
46
|
+
iframe.style.opacity = '1';
|
47
|
+
iframe.style.overflow = 'visible';
|
48
|
+
iframe.style.height = "".concat(height, "px");
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}, {
|
52
|
+
key: "unmount",
|
53
|
+
value: function unmount() {
|
54
|
+
var _this$elementContaine3, _this$elementContaine4;
|
55
|
+
(_this$elementContaine3 = this.elementContainer) === null || _this$elementContaine3 === void 0 || (_this$elementContaine4 = _this$elementContaine3.remove) === null || _this$elementContaine4 === void 0 || _this$elementContaine4.call(_this$elementContaine3);
|
56
|
+
}
|
57
|
+
}]);
|
58
|
+
return ElementAuthComponent;
|
59
|
+
}();
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { PaymentMountOptions } from '../type';
|
2
|
+
interface ElementPaymentMountOptions extends Omit<PaymentMountOptions, 'type'> {
|
3
|
+
selector: string;
|
4
|
+
}
|
5
|
+
export declare class ElementPaymentComponent {
|
6
|
+
private sdk;
|
7
|
+
private elementContainer;
|
8
|
+
private isConnect;
|
9
|
+
constructor();
|
10
|
+
create(options: {
|
11
|
+
environment: string;
|
12
|
+
locale: string;
|
13
|
+
appVersion: string;
|
14
|
+
}, isConnect: boolean): void;
|
15
|
+
mount(sessionData: string, options: ElementPaymentMountOptions): Promise<HTMLIFrameElement | undefined>;
|
16
|
+
update(): void;
|
17
|
+
unmount(): void;
|
18
|
+
}
|
19
|
+
export {};
|
@@ -0,0 +1,74 @@
|
|
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 _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; }
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
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
|
+
import AMSPaymentElement from "../../../../index";
|
11
|
+
export var ElementPaymentComponent = /*#__PURE__*/function () {
|
12
|
+
function ElementPaymentComponent() {
|
13
|
+
_classCallCheck(this, ElementPaymentComponent);
|
14
|
+
_defineProperty(this, "sdk", void 0);
|
15
|
+
_defineProperty(this, "elementContainer", void 0);
|
16
|
+
_defineProperty(this, "isConnect", void 0);
|
17
|
+
}
|
18
|
+
_createClass(ElementPaymentComponent, [{
|
19
|
+
key: "create",
|
20
|
+
value: function create(options, isConnect) {
|
21
|
+
this.isConnect = isConnect;
|
22
|
+
this.sdk = new AMSPaymentElement(_objectSpread(_objectSpread({}, options), {}, {
|
23
|
+
analytics: {
|
24
|
+
enabled: true
|
25
|
+
},
|
26
|
+
onEventCallback: function onEventCallback(state) {}
|
27
|
+
}));
|
28
|
+
}
|
29
|
+
}, {
|
30
|
+
key: "mount",
|
31
|
+
value: function mount(sessionData, options) {
|
32
|
+
var _this = this;
|
33
|
+
var elementContainer = document.querySelector(options.selector);
|
34
|
+
if (this.isConnect) {
|
35
|
+
elementContainer.style.display = 'none';
|
36
|
+
}
|
37
|
+
return new Promise(function (resolve) {
|
38
|
+
_this.sdk.mountComponent({
|
39
|
+
sessionData: sessionData,
|
40
|
+
appearance: options.appearance,
|
41
|
+
debugProps: options.debugProps,
|
42
|
+
notRedirectAfterComplete: true,
|
43
|
+
appendAliasContainerId: true
|
44
|
+
}, options.selector).then(function () {
|
45
|
+
var _elementContainer$get;
|
46
|
+
_this.elementContainer = elementContainer;
|
47
|
+
var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
|
48
|
+
resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
|
49
|
+
}, function () {
|
50
|
+
resolve(undefined);
|
51
|
+
});
|
52
|
+
});
|
53
|
+
}
|
54
|
+
}, {
|
55
|
+
key: "update",
|
56
|
+
value: function update() {
|
57
|
+
if (this.elementContainer && this.isConnect) {
|
58
|
+
this.elementContainer.style.display = 'initial';
|
59
|
+
}
|
60
|
+
// 下发数据
|
61
|
+
}
|
62
|
+
}, {
|
63
|
+
key: "unmount",
|
64
|
+
value: function unmount() {
|
65
|
+
var _this$elementContaine, _this$elementContaine2;
|
66
|
+
var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
|
67
|
+
if (containers !== null && containers !== void 0 && containers[0]) {
|
68
|
+
var _containers$, _containers$$remove;
|
69
|
+
(_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}]);
|
73
|
+
return ElementPaymentComponent;
|
74
|
+
}();
|