@alipay/ams-checkout 0.0.1730107332-dev.3 → 0.0.1730107332-dev.30
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/component/channel.d.ts +2 -3
- package/esm/component/channel.js +65 -30
- package/esm/component/component.inline.style.js +1 -1
- package/esm/component/component.popup.style.d.ts +1 -3
- package/esm/component/component.popup.style.js +1 -3
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/core/bus/ability/callback.js +55 -0
- 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/bus/interface.d.ts +36 -0
- package/esm/core/bus/interface.js +40 -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 +89 -0
- package/esm/core/component/ckp/index.d.ts +27 -0
- package/esm/core/component/ckp/index.js +166 -0
- package/esm/core/component/index.d.ts +51 -0
- package/esm/core/component/index.js +531 -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 +499 -0
- package/esm/foundation/core/index.d.ts +2 -2
- package/esm/foundation/core/index.js +8 -4
- package/esm/foundation/index.d.ts +8 -5
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +5 -4
- package/esm/foundation/product-processor/easysafepay/deps.js +3 -2
- package/esm/foundation/product-processor/easysafepay/index.d.ts +2 -3
- package/esm/foundation/product-processor/easysafepay/index.js +115 -231
- package/esm/foundation/service/api-bus/index.d.ts +2 -2
- package/esm/foundation/service/container/index.d.ts +2 -2
- package/esm/foundation/service/container/index.js +0 -1
- package/esm/foundation/service/event-center.d.ts +4 -4
- package/esm/foundation/service/event-center.js +10 -10
- package/esm/foundation/service/global-data/index.d.ts +2 -2
- package/esm/foundation/service/index.d.ts +2 -2
- package/esm/foundation/service/log/index.d.ts +2 -2
- package/esm/foundation/service/requester/deps.d.ts +1 -1
- package/esm/foundation/service/requester/requester.d.ts +2 -2
- package/esm/foundation/service/security/index.d.ts +2 -2
- package/esm/foundation/service/security/index.js +1 -0
- package/esm/foundation/utils/redirect_utils.d.ts +5 -0
- package/esm/foundation/utils/redirect_utils.js +178 -24
- package/esm/foundation/utils/web_app_url_utils.js +1 -1
- package/esm/index.d.ts +27 -2
- package/esm/index.js +133 -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 +34 -0
- package/esm/plugin/component/cashierApp.js +237 -0
- package/esm/plugin/component/channel.d.ts +21 -0
- package/esm/plugin/component/channel.js +89 -0
- package/esm/plugin/component/component.inline.style.d.ts +10 -0
- package/esm/plugin/component/component.inline.style.js +119 -0
- package/esm/plugin/component/component.popup.style.d.ts +16 -0
- package/esm/plugin/component/component.popup.style.js +174 -0
- package/esm/plugin/component/index.d.ts +126 -0
- package/esm/plugin/component/index.js +1839 -0
- package/esm/plugin/component/popupWindow.style.d.ts +11 -0
- package/esm/plugin/component/popupWindow.style.js +121 -0
- 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 +6 -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/types/index.d.ts +10 -11
- package/esm/types/index.js +2 -1
- package/esm/util/createIframeNode.d.ts +6 -0
- package/esm/util/createIframeNode.js +48 -0
- package/esm/util/getBackScheme.d.ts +5 -0
- package/esm/util/getBackScheme.js +134 -0
- package/esm/util/index.d.ts +1 -1
- package/esm/util/index.js +4 -3
- package/esm/util/intl-callapp/es/index.js +0 -1
- package/esm/util/security.d.ts +33 -0
- package/esm/util/security.js +182 -0
- package/package.json +2 -2
- package/esm/foundation/types/index.d.ts +0 -4
- package/esm/foundation/types/index.js +0 -4
@@ -7,7 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
7
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
8
|
import { v4 as uuid } from 'uuid';
|
9
9
|
import { ERRORMESSAGE } from "../../constant";
|
10
|
-
import { MessageName } from "../../types";
|
10
|
+
import { EventPayload, MessageName } from "../../types";
|
11
11
|
import { isJsonString } from "../../util";
|
12
12
|
import { getIframeOrigin, registerSystemEvents, unRegisterSystemEvents } from "../utils/system_events";
|
13
13
|
|
@@ -88,12 +88,12 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
88
88
|
}
|
89
89
|
var isJson = isJsonString(e.data);
|
90
90
|
if (isJson) {
|
91
|
-
var
|
92
|
-
console.log('handleAppMessage',
|
93
|
-
if (
|
91
|
+
var _EventPayload = JSON.parse(e.data);
|
92
|
+
console.log('handleAppMessage', _EventPayload);
|
93
|
+
if (_EventPayload.name !== MessageName.APP_TO_SDK) {
|
94
94
|
return;
|
95
95
|
}
|
96
|
-
this._handleAppMessage(
|
96
|
+
this._handleAppMessage(_EventPayload);
|
97
97
|
} else {
|
98
98
|
console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
|
99
99
|
// TODO: 异常上报
|
@@ -106,11 +106,11 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
106
106
|
*/
|
107
107
|
}, {
|
108
108
|
key: "_handleAppMessage",
|
109
|
-
value: function _handleAppMessage(
|
110
|
-
var context =
|
109
|
+
value: function _handleAppMessage(EventPayload) {
|
110
|
+
var context = EventPayload.context;
|
111
111
|
var event = context.event,
|
112
112
|
data = context.data;
|
113
|
-
this.emit(event, data,
|
113
|
+
this.emit(event, data, EventPayload);
|
114
114
|
}
|
115
115
|
|
116
116
|
/**
|
@@ -156,11 +156,11 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
156
156
|
*/
|
157
157
|
}, {
|
158
158
|
key: "emit",
|
159
|
-
value: function emit(name, data,
|
159
|
+
value: function emit(name, data, EventPayload) {
|
160
160
|
if (this.events.has(name)) {
|
161
161
|
var eventList = this.events.get(name);
|
162
162
|
eventList.forEach(function (item) {
|
163
|
-
item.func(data,
|
163
|
+
item.func(data, EventPayload);
|
164
164
|
});
|
165
165
|
}
|
166
166
|
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { IoptionsParams } from "../../../types";
|
2
2
|
import { Service } from "../../index";
|
3
3
|
export declare class GlobalDataService implements Service {
|
4
4
|
private globalData;
|
5
|
-
init(initOptions:
|
5
|
+
init(initOptions: IoptionsParams, instanceId: string): void;
|
6
6
|
destroy(): void;
|
7
7
|
update(): void;
|
8
8
|
getGlobalData(dataKey: string): any;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { IoptionsParams } from '../../types';
|
2
2
|
import { PaymentContext, SDKMetaData, Service } from '../index';
|
3
3
|
/**
|
4
4
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
@@ -12,7 +12,7 @@ export declare class ServiceProvider {
|
|
12
12
|
private services;
|
13
13
|
private extendServices;
|
14
14
|
private constructor();
|
15
|
-
init(initOptions:
|
15
|
+
init(initOptions: IoptionsParams, sdkMetaData: SDKMetaData): void;
|
16
16
|
update(paymentContext: PaymentContext): void;
|
17
17
|
getService<T>(serviceName: ServiceName): T;
|
18
18
|
registerService(serviceName: string, service: Service): void;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { PaymentContext, SDKMetaData, Service } from '../../index';
|
2
|
-
import {
|
2
|
+
import { IoptionsParams } from '../../../types';
|
3
3
|
import { LogExtra, LogMetaData, LogPayload } from './types';
|
4
4
|
/**
|
5
5
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
@@ -25,7 +25,7 @@ export declare class LogService implements Service {
|
|
25
25
|
private isLoaded;
|
26
26
|
private trackId;
|
27
27
|
constructor();
|
28
|
-
init(initOptions:
|
28
|
+
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
29
29
|
update(paymentContext: PaymentContext): void;
|
30
30
|
destroy(): void;
|
31
31
|
setMetaData(metaData: LogMetaData): void;
|
@@ -7,7 +7,7 @@ export type { LogPayload, LogExtra } from '../log/types';
|
|
7
7
|
export type { LogService } from '../log';
|
8
8
|
export type { Service, PaymentContext } from '../../index';
|
9
9
|
export { fomatGetwayError } from '../../../request/utils';
|
10
|
-
export type {
|
10
|
+
export type { IoptionsParams, IPaymentSessionMetaData } from '../../../types';
|
11
11
|
export { sdkVersion } from '../../../config/index';
|
12
12
|
export { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from '../../../config/request';
|
13
13
|
export type { RequestConfig } from '../../../types';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { IoptionsParams, PaymentContext, RequestConfig, SDKMetaData, Service } from './deps';
|
2
2
|
/**
|
3
3
|
* @author congle.zzq <congle.zzq@alipay.com>
|
4
4
|
* @date 2024/9/18
|
@@ -6,7 +6,7 @@ import { IOptionsParams, PaymentContext, RequestConfig, SDKMetaData, Service } f
|
|
6
6
|
export declare class RequesterService implements Service {
|
7
7
|
private sandboxFlag?;
|
8
8
|
private instanceId;
|
9
|
-
init(initOptions:
|
9
|
+
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
10
10
|
/**
|
11
11
|
*
|
12
12
|
* @param requestData 请求参数
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { DeviceIdParameter,
|
1
|
+
import { DeviceIdParameter, IoptionsParams } from '../../../types';
|
2
2
|
import { PaymentContext, SDKMetaData, Service } from '../../index';
|
3
3
|
import { Security } from './security';
|
4
4
|
export declare class SecurityService implements Service {
|
5
5
|
private logger;
|
6
6
|
private productScene;
|
7
7
|
static securitySdkMap: Map<string, Security>;
|
8
|
-
init(initOptions:
|
8
|
+
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
9
9
|
update(paymentContext: PaymentContext): void;
|
10
10
|
destroy(): void;
|
11
11
|
getDeviceId(deviceIdParameter?: DeviceIdParameter, isPolling?: boolean): Promise<string>;
|
@@ -1,6 +1,11 @@
|
|
1
1
|
import { RedirectBehaviorPayload } from '../index';
|
2
|
+
import { LogService } from '../service/log';
|
2
3
|
/**
|
3
4
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
4
5
|
* @date 2024/9/19
|
5
6
|
*/
|
6
7
|
export declare const redirect: (payload: RedirectBehaviorPayload, instanceId: string) => void;
|
8
|
+
/**
|
9
|
+
* 通过配置规则检测 UA 和获得回跳 scheme
|
10
|
+
*/
|
11
|
+
export declare function getBackScheme(mockUa?: string, logger?: LogService): any;
|
@@ -20,15 +20,31 @@ export var redirect = function redirect(payload, instanceId) {
|
|
20
20
|
logService.logInfo({
|
21
21
|
title: 'sdk_event_call_url_start'
|
22
22
|
}, _objectSpread({}, payload)).send();
|
23
|
+
if (payload.isCallApp && payload.schemeUrl) {
|
24
|
+
var detectSuccessDelay = payload.callAppDetectSuccessDelay;
|
25
|
+
var _callAppLib = new CallApp({
|
26
|
+
successCb: function successCb() {
|
27
|
+
successCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
28
|
+
},
|
29
|
+
resultJudgmentTime: detectSuccessDelay
|
30
|
+
});
|
31
|
+
_callAppLib.open({
|
32
|
+
scheme: payload.schemeUrl,
|
33
|
+
fallback: function fallback() {
|
34
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
return;
|
38
|
+
}
|
23
39
|
// 支持 target: _blank,新开tab页打开
|
24
40
|
if (payload.browserLinkTarget === TargetEnum.BLANK) {
|
25
|
-
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '',
|
41
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
26
42
|
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
27
43
|
window.open(payload.url);
|
28
44
|
return;
|
29
45
|
}
|
30
46
|
if (payload.browserLinkTarget === TargetEnum.REPLACE && !(payload !== null && payload !== void 0 && payload.applinkUrl) && !(payload !== null && payload !== void 0 && payload.schemeUrl)) {
|
31
|
-
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '',
|
47
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
32
48
|
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
33
49
|
window.location.replace(payload.url);
|
34
50
|
return;
|
@@ -41,35 +57,39 @@ export var redirect = function redirect(payload, instanceId) {
|
|
41
57
|
if (!payload.schemeUrl && !payload.applinkUrl) {
|
42
58
|
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
43
59
|
window.location.href = payload.url;
|
60
|
+
return;
|
44
61
|
}
|
45
62
|
// Use callApp lib to evoke
|
46
|
-
// TODO replace to npm
|
47
63
|
var callAppLib = new CallApp({
|
48
64
|
successCb: function successCb(evokeAppBy) {
|
49
65
|
var type = evokeAppBy.type == 'Scheme' ? RedirectType.SchemeUrl : RedirectType.ApplinkUrl;
|
50
66
|
successCallback(payload, type, evokeAppBy.url, serviceProvider);
|
51
67
|
}
|
52
68
|
});
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
}
|
60
|
-
callAppLib.open({
|
61
|
-
scheme: payload.schemeUrl,
|
62
|
-
fallback: function fallback() {
|
63
|
-
// SchemeUrl evoke failed
|
64
|
-
if (payload.schemeUrl) {
|
65
|
-
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, payload, serviceProvider);
|
66
|
-
}
|
67
|
-
window.location.href = payload.url;
|
69
|
+
var callSchemeUrl = function callSchemeUrl() {
|
70
|
+
callAppLib.open({
|
71
|
+
scheme: payload.schemeUrl,
|
72
|
+
fallback: function fallback() {
|
73
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
74
|
+
if (payload.url) {
|
68
75
|
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
76
|
+
window.location.href = payload.url;
|
69
77
|
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
78
|
+
}
|
79
|
+
});
|
80
|
+
};
|
81
|
+
if (payload.applinkUrl) {
|
82
|
+
callAppLib.open({
|
83
|
+
link: payload.applinkUrl,
|
84
|
+
fallback: function fallback() {
|
85
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
86
|
+
// Applink evoke failed, try to use scheme url
|
87
|
+
callSchemeUrl();
|
88
|
+
}
|
89
|
+
});
|
90
|
+
} else if (payload.schemeUrl) {
|
91
|
+
callSchemeUrl();
|
92
|
+
}
|
73
93
|
};
|
74
94
|
var successCallback = function successCallback(payload, type, url, serviceProvider) {
|
75
95
|
serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
|
@@ -84,10 +104,10 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
|
|
84
104
|
url: url
|
85
105
|
}).send();
|
86
106
|
};
|
87
|
-
var failCallback = function failCallback(payload, type, url,
|
107
|
+
var failCallback = function failCallback(payload, type, url, serviceProvider) {
|
88
108
|
serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
|
89
109
|
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
90
|
-
message: "Failed to open app,applinkUrl: ".concat(
|
110
|
+
message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
|
91
111
|
});
|
92
112
|
serviceProvider.getService('Log').logInfo({
|
93
113
|
title: 'sdk_error_call_url_failed'
|
@@ -96,4 +116,138 @@ var failCallback = function failCallback(payload, type, url, behaviorData, servi
|
|
96
116
|
openType: type,
|
97
117
|
url: url
|
98
118
|
}).send();
|
99
|
-
};
|
119
|
+
};
|
120
|
+
var UA_MATCH_RULES = [{
|
121
|
+
matchRule: 'AppleWebKit\\/([0-9\\.]+).* Version\\/([0-9\\._]+) Mobile\\/([0-9\\._A-Z]+) Safari\\/([0-9\\._]+)$',
|
122
|
+
iosScheme: 'https',
|
123
|
+
andScheme: ''
|
124
|
+
}, {
|
125
|
+
matchRule: 'HeyTapBrowser',
|
126
|
+
iosScheme: '',
|
127
|
+
andScheme: ''
|
128
|
+
}, {
|
129
|
+
matchRule: 'HuaweiBrowser',
|
130
|
+
iosScheme: '',
|
131
|
+
andScheme: ''
|
132
|
+
}, {
|
133
|
+
matchRule: 'Kwai',
|
134
|
+
iosScheme: 'kwai',
|
135
|
+
andScheme: ''
|
136
|
+
}, {
|
137
|
+
matchRule: 'MQQBrowser',
|
138
|
+
iosScheme: 'mttbrowser',
|
139
|
+
andScheme: ''
|
140
|
+
}, {
|
141
|
+
matchRule: 'MicroMessenger',
|
142
|
+
iosScheme: '',
|
143
|
+
andScheme: ''
|
144
|
+
}, {
|
145
|
+
matchRule: 'MiuiBrowser',
|
146
|
+
iosScheme: '',
|
147
|
+
andScheme: ''
|
148
|
+
}, {
|
149
|
+
matchRule: 'Mozilla\\/([0-9\\.]+).* AppleWebKit\\/([0-9\\.]+).* CriOS\\/([0-9\\._]+) Mobile\\/([0-9\\._A-Z\\._a-z]+) Safari\\/([0-9\\._]+)$',
|
150
|
+
iosScheme: 'googlechrome',
|
151
|
+
andScheme: ''
|
152
|
+
}, {
|
153
|
+
matchRule: 'Mozilla\\/([0-9\\.]+).* AppleWebKit\\/([0-9\\.]+).* Version\\/([0-9\\._]+) Mobile Safari\\/([0-9\\._]+)$',
|
154
|
+
iosScheme: 'googlechrome',
|
155
|
+
andScheme: ''
|
156
|
+
}, {
|
157
|
+
matchRule: 'NewsArticle',
|
158
|
+
iosScheme: 'snssdk141',
|
159
|
+
andScheme: ''
|
160
|
+
}, {
|
161
|
+
matchRule: 'UCBrowser',
|
162
|
+
iosScheme: 'ucbrowser',
|
163
|
+
andScheme: ''
|
164
|
+
}, {
|
165
|
+
matchRule: 'VideoArticle',
|
166
|
+
iosScheme: 'snssdk32',
|
167
|
+
andScheme: ''
|
168
|
+
}, {
|
169
|
+
matchRule: 'VivoBrowser',
|
170
|
+
iosScheme: '',
|
171
|
+
andScheme: ''
|
172
|
+
}, {
|
173
|
+
matchRule: 'ZhongAnWebView',
|
174
|
+
iosScheme: 'zaapp',
|
175
|
+
andScheme: ''
|
176
|
+
}, {
|
177
|
+
matchRule: 'aweme',
|
178
|
+
iosScheme: 'snssdk1128',
|
179
|
+
andScheme: ''
|
180
|
+
}, {
|
181
|
+
matchRule: 'aweme_lite',
|
182
|
+
iosScheme: 'snssdk2329',
|
183
|
+
andScheme: ''
|
184
|
+
}, {
|
185
|
+
matchRule: 'com.xs.fm',
|
186
|
+
iosScheme: 'novelfm3040',
|
187
|
+
andScheme: ''
|
188
|
+
}, {
|
189
|
+
matchRule: 'netdisk',
|
190
|
+
iosScheme: '',
|
191
|
+
andScheme: ''
|
192
|
+
}, {
|
193
|
+
matchRule: 'qqnews',
|
194
|
+
iosScheme: 'qqnews',
|
195
|
+
andScheme: ''
|
196
|
+
}];
|
197
|
+
|
198
|
+
/**
|
199
|
+
* 通过配置规则检测 UA 和获得回跳 scheme
|
200
|
+
*/
|
201
|
+
export function getBackScheme(mockUa, logger) {
|
202
|
+
var ua = mockUa || window.navigator.userAgent || '';
|
203
|
+
// 获取规则
|
204
|
+
var uaMatchedRule = UA_MATCH_RULES;
|
205
|
+
var matchedRule;
|
206
|
+
var matched = null;
|
207
|
+
for (var i = 0; i < uaMatchedRule.length; i++) {
|
208
|
+
var rule = uaMatchedRule[i];
|
209
|
+
matched = ua.match(rule.matchRule);
|
210
|
+
if (matched) {
|
211
|
+
matchedRule = rule;
|
212
|
+
break;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
if (!matchedRule) {
|
216
|
+
logBackScheme(logger, ua, '');
|
217
|
+
return;
|
218
|
+
}
|
219
|
+
if (isAndroid(ua)) {
|
220
|
+
logBackScheme(logger, ua, matchedRule.andScheme);
|
221
|
+
return matchedRule.andScheme;
|
222
|
+
}
|
223
|
+
if (isIOS(ua)) {
|
224
|
+
logBackScheme(logger, ua, matchedRule.iosScheme);
|
225
|
+
return matchedRule.iosScheme;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
function logBackScheme(logger, userAgent, scheme) {
|
229
|
+
if (logger) {
|
230
|
+
logger.logInfo({
|
231
|
+
title: 'a3753.b101271.c377460'
|
232
|
+
}, {
|
233
|
+
userAgent: userAgent,
|
234
|
+
backScheme: scheme
|
235
|
+
});
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
/**
|
240
|
+
* 当前运行环境是否 Android
|
241
|
+
*/
|
242
|
+
function isAndroid(mockUA) {
|
243
|
+
var ua = (mockUA || navigator.userAgent).toLowerCase();
|
244
|
+
return /android|adr|linux/.test(ua);
|
245
|
+
}
|
246
|
+
|
247
|
+
/**
|
248
|
+
* 当前运行环境是否 IOS
|
249
|
+
*/
|
250
|
+
function isIOS(mockUA) {
|
251
|
+
var ua = (mockUA || navigator.userAgent).toLowerCase();
|
252
|
+
return /iphone|ipad|ipod|ios|macintosh/.test(ua);
|
253
|
+
}
|
@@ -98,7 +98,7 @@ export var parseWebAppMatchConfig = function parseWebAppMatchConfig(extendInfo)
|
|
98
98
|
};
|
99
99
|
var getValidProductSceneVersion = function getValidProductSceneVersion(productScene, productSceneVer, paymentMethodCategoryType) {
|
100
100
|
var _supportMapping;
|
101
|
-
var supportMapping = (_supportMapping = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.NONE, ['']), ComponentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), ComponentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), ComponentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), ComponentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), ComponentSignEnum.EASY_PAY_APM, ['2.0']), ComponentSignEnum.VAULTING_CARD, ['1.0']), ComponentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_supportMapping, ComponentSignEnum.ELEMENT_ADDRESS, ['1.0']));
|
101
|
+
var supportMapping = (_supportMapping = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.NONE, ['']), ComponentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), ComponentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), ComponentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), ComponentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), ComponentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), ComponentSignEnum.EASY_PAY_APM, ['2.0']), ComponentSignEnum.VAULTING_CARD, ['1.0']), ComponentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_defineProperty(_supportMapping, ComponentSignEnum.ELEMENT_ADDRESS, ['1.0']), ComponentSignEnum.CHECKOUT_PAYMENT, ['1.0']));
|
102
102
|
var targetVersions = supportMapping[productScene + '_' + paymentMethodCategoryType];
|
103
103
|
if (!targetVersions) {
|
104
104
|
return '';
|
package/esm/index.d.ts
CHANGED
@@ -1,7 +1,32 @@
|
|
1
|
-
import {
|
1
|
+
import { AddressComponent } from './core/component/address';
|
2
|
+
import { AMSComponent } from './core/component/index';
|
3
|
+
import { ComponentSignEnum, IoptionsAddressParams, IoptionsParams, IcreateComponent } from './types';
|
4
|
+
export { AMSCheckoutPage } from './core/component/ckp';
|
2
5
|
export * from './types';
|
6
|
+
export declare class AMSCheckout extends AMSComponent {
|
7
|
+
constructor(_options: IoptionsParams, channelType?: ComponentSignEnum[], productSceneVersion?: string);
|
8
|
+
}
|
9
|
+
export declare class AMSAutoDebit extends AMSCheckout {
|
10
|
+
constructor(options: IoptionsParams);
|
11
|
+
}
|
12
|
+
export declare class AMSAutoDebitPay extends AMSCheckout {
|
13
|
+
constructor(options: IoptionsParams);
|
14
|
+
}
|
15
|
+
export declare class AMSCashierPayment extends AMSCheckout {
|
16
|
+
constructor(options: IoptionsParams);
|
17
|
+
}
|
18
|
+
export declare class AMSVaulting extends AMSCheckout {
|
19
|
+
constructor(options: IoptionsParams);
|
20
|
+
}
|
21
|
+
export declare class AntomElement extends AMSCheckout {
|
22
|
+
constructor(options: IoptionsParams);
|
23
|
+
}
|
24
|
+
export declare class AddressElement extends AddressComponent {
|
25
|
+
constructor(options: IoptionsAddressParams);
|
26
|
+
}
|
27
|
+
export default AMSCheckout;
|
3
28
|
export declare class AMSEasyPay {
|
4
29
|
private core;
|
5
|
-
constructor(options:
|
30
|
+
constructor(options: IoptionsParams);
|
6
31
|
createComponent(params: IcreateComponent): void;
|
7
32
|
}
|
package/esm/index.js
CHANGED
@@ -1,10 +1,19 @@
|
|
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
|
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 _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; }
|
3
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); } }
|
4
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; }
|
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
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
7
8
|
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); }
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10
|
+
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); }
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
12
|
+
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); }; }
|
13
|
+
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); }
|
14
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
15
|
+
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; } }
|
16
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
8
17
|
/**
|
9
18
|
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
10
19
|
*
|
@@ -12,12 +21,128 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
12
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
|
13
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.
|
14
23
|
*/
|
15
|
-
|
24
|
+
import { ADDRESSElementAppVersion, AMSAutoDebitAppVersion, AMSCashierPaymentAppVersion, AMSCheckoutAppVersion, AMSPaymentElementAppVersion, AMSVaultingAppVersion } from "./config/index";
|
25
|
+
import { AddressComponent } from "./core/component/address";
|
26
|
+
import { AMSComponent } from "./core/component/index";
|
27
|
+
import { ComponentSignEnum, ProductSceneEnum, DisplayTypeEnum } from "./types";
|
28
|
+
import { LogConfig, Logger } from "./util/logger";
|
29
|
+
var logger = new Logger(LogConfig, true);
|
30
|
+
export { AMSCheckoutPage } from "./core/component/ckp";
|
31
|
+
export * from "./types";
|
16
32
|
import { AntomSDKCore } from "./foundation/core";
|
17
33
|
import { EasySafePayProcessor } from "./foundation/product-processor/easysafepay";
|
18
|
-
|
19
|
-
|
20
|
-
|
34
|
+
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
35
|
+
_inherits(AMSCheckout, _AMSComponent);
|
36
|
+
var _super = _createSuper(AMSCheckout);
|
37
|
+
function AMSCheckout(_options, channelType) {
|
38
|
+
var _this;
|
39
|
+
var productSceneVersion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '1.0';
|
40
|
+
_classCallCheck(this, AMSCheckout);
|
41
|
+
_this = _super.call(this, _objectSpread({
|
42
|
+
appVersion: AMSCheckoutAppVersion
|
43
|
+
}, _options));
|
44
|
+
_this.preloadComponent(channelType, productSceneVersion);
|
45
|
+
return _this;
|
46
|
+
}
|
47
|
+
return _createClass(AMSCheckout);
|
48
|
+
}(AMSComponent);
|
49
|
+
export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
50
|
+
_inherits(AMSAutoDebit, _AMSCheckout);
|
51
|
+
var _super2 = _createSuper(AMSAutoDebit);
|
52
|
+
function AMSAutoDebit(options) {
|
53
|
+
_classCallCheck(this, AMSAutoDebit);
|
54
|
+
var _options = Object.assign({}, options, {
|
55
|
+
product: ProductSceneEnum.AUTO_DEBIT,
|
56
|
+
appVersion: AMSAutoDebitAppVersion
|
57
|
+
});
|
58
|
+
return _super2.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_WALLET]);
|
59
|
+
}
|
60
|
+
return _createClass(AMSAutoDebit);
|
61
|
+
}(AMSCheckout);
|
62
|
+
export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
|
63
|
+
_inherits(AMSAutoDebitPay, _AMSCheckout2);
|
64
|
+
var _super3 = _createSuper(AMSAutoDebitPay);
|
65
|
+
function AMSAutoDebitPay(options) {
|
66
|
+
_classCallCheck(this, AMSAutoDebitPay);
|
67
|
+
var _options = Object.assign({}, options, {
|
68
|
+
product: ProductSceneEnum.AUTO_DEBIT_PAY
|
69
|
+
});
|
70
|
+
return _super3.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_PAY_WALLET]);
|
71
|
+
}
|
72
|
+
return _createClass(AMSAutoDebitPay);
|
73
|
+
}(AMSCheckout);
|
74
|
+
export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
75
|
+
_inherits(AMSCashierPayment, _AMSCheckout3);
|
76
|
+
var _super4 = _createSuper(AMSCashierPayment);
|
77
|
+
function AMSCashierPayment(options) {
|
78
|
+
_classCallCheck(this, AMSCashierPayment);
|
79
|
+
var _options = Object.assign({}, options, {
|
80
|
+
product: ProductSceneEnum.CASHIER_PAYMENT,
|
81
|
+
appVersion: AMSCashierPaymentAppVersion
|
82
|
+
});
|
83
|
+
var currentChannelType;
|
84
|
+
try {
|
85
|
+
var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
|
86
|
+
var previousChannel = JSON.parse(previousChannelStr) || {};
|
87
|
+
var _ref = previousChannel || {},
|
88
|
+
_ref$channelType = _ref.channelType,
|
89
|
+
channelType = _ref$channelType === void 0 ? '' : _ref$channelType;
|
90
|
+
if ([ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM, ComponentSignEnum.CASHIER_PAYMENT_BANK].includes(channelType)) {
|
91
|
+
currentChannelType = [channelType];
|
92
|
+
} else {
|
93
|
+
currentChannelType = [ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM];
|
94
|
+
}
|
95
|
+
} catch (error) {
|
96
|
+
logger.logError({
|
97
|
+
title: 'performance_optimization_get_previousChannel_error'
|
98
|
+
}, {
|
99
|
+
error: error
|
100
|
+
});
|
101
|
+
}
|
102
|
+
return _super4.call(this, _options, currentChannelType);
|
103
|
+
}
|
104
|
+
return _createClass(AMSCashierPayment);
|
105
|
+
}(AMSCheckout);
|
106
|
+
export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
|
107
|
+
_inherits(AMSVaulting, _AMSCheckout4);
|
108
|
+
var _super5 = _createSuper(AMSVaulting);
|
109
|
+
function AMSVaulting(options) {
|
110
|
+
_classCallCheck(this, AMSVaulting);
|
111
|
+
var _options = Object.assign({}, options, {
|
112
|
+
product: ProductSceneEnum.VAULTING,
|
113
|
+
appVersion: AMSVaultingAppVersion
|
114
|
+
});
|
115
|
+
return _super5.call(this, _options, [ComponentSignEnum.CASHIER_PAYMENT_CARD]);
|
116
|
+
}
|
117
|
+
return _createClass(AMSVaulting);
|
118
|
+
}(AMSCheckout);
|
119
|
+
export var AntomElement = /*#__PURE__*/function (_AMSCheckout5) {
|
120
|
+
_inherits(AntomElement, _AMSCheckout5);
|
121
|
+
var _super6 = _createSuper(AntomElement);
|
122
|
+
function AntomElement(options) {
|
123
|
+
_classCallCheck(this, AntomElement);
|
124
|
+
var _options = Object.assign({}, options, {
|
125
|
+
product: ProductSceneEnum.ELEMENT_PAYMENT,
|
126
|
+
appVersion: AMSPaymentElementAppVersion
|
127
|
+
});
|
128
|
+
return _super6.call(this, _options, [ComponentSignEnum.ELEMENT_PAYMENT]);
|
129
|
+
}
|
130
|
+
return _createClass(AntomElement);
|
131
|
+
}(AMSCheckout);
|
132
|
+
export var AddressElement = /*#__PURE__*/function (_AddressComponent) {
|
133
|
+
_inherits(AddressElement, _AddressComponent);
|
134
|
+
var _super7 = _createSuper(AddressElement);
|
135
|
+
function AddressElement(options) {
|
136
|
+
_classCallCheck(this, AddressElement);
|
137
|
+
var _options = Object.assign({}, options, {
|
138
|
+
product: ProductSceneEnum.ELEMENT_ADDRESS,
|
139
|
+
appVersion: ADDRESSElementAppVersion
|
140
|
+
});
|
141
|
+
return _super7.call(this, _options);
|
142
|
+
}
|
143
|
+
return _createClass(AddressElement);
|
144
|
+
}(AddressComponent);
|
145
|
+
export default AMSCheckout;
|
21
146
|
export var AMSEasyPay = /*#__PURE__*/function () {
|
22
147
|
function AMSEasyPay(options) {
|
23
148
|
_classCallCheck(this, AMSEasyPay);
|
@@ -37,7 +162,8 @@ export var AMSEasyPay = /*#__PURE__*/function () {
|
|
37
162
|
paymentSession: params.sessionData || params.paymentSessionData,
|
38
163
|
displayInfo: {
|
39
164
|
type: DisplayTypeEnum.popup
|
40
|
-
}
|
165
|
+
},
|
166
|
+
isAppWebview: params.isAppWebview
|
41
167
|
});
|
42
168
|
}
|
43
169
|
}]);
|