@alipay/ams-checkout 0.0.1698890614-dev.1 → 0.0.1699863258-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 +1 -0
- package/esm/config/index.js +8 -0
- package/esm/core/component/index.d.ts +3 -1
- package/esm/core/component/index.js +10 -3
- package/esm/core/instance/index.d.ts +23 -10
- package/esm/core/instance/index.js +136 -57
- package/esm/plugin/component/index.d.ts +1 -1
- package/esm/plugin/component/index.js +77 -50
- package/esm/request/index.js +7 -10
- package/esm/request/utils.js +1 -4
- package/esm/service/index.d.ts +2 -8
- package/esm/service/index.js +38 -2
- package/esm/types/index.d.ts +19 -10
- package/esm/types/index.js +1 -5
- package/esm/util/index.d.ts +6 -21
- package/esm/util/index.js +38 -45
- package/esm/util/security.d.ts +24 -8
- package/esm/util/security.js +165 -112
- package/esm/util/versionCompare.d.ts +10 -0
- package/esm/util/versionCompare.js +50 -0
- package/package.json +1 -1
package/esm/config/index.d.ts
CHANGED
package/esm/config/index.js
CHANGED
@@ -14,4 +14,12 @@ export var marmotMap = {
|
|
14
14
|
light_sandbox: 'https://cdn.marmot-cloud.com/page/antom-web-checkout/src/component-app',
|
15
15
|
prod: 'https://cdn.marmot-cloud.com/page/antom-web-checkout/src/component-app'
|
16
16
|
};
|
17
|
+
export var marmotConfigMap = {
|
18
|
+
dev: 'https://config-dev.marmot-cloud.com/config/data/antom-sdk-config/en_US.json',
|
19
|
+
sit: 'https://config-test.marmot-cloud.com/config/data/antom-sdk-config/en_US.json',
|
20
|
+
pre: 'https://config-pre.marmot-cloud.com/config/data/antom-sdk-config/en_US.json',
|
21
|
+
sandbox: 'https://config.marmot-cloud.com/config/data/antom-sdk-config/en_US.json',
|
22
|
+
light_sandbox: 'https://config.marmot-cloud.com/config/data/antom-sdk-config/en_US.json',
|
23
|
+
prod: 'https://config.marmot-cloud.com/config/data/antom-sdk-config/en_US.json'
|
24
|
+
};
|
17
25
|
export var sdkVersion = json.version;
|
@@ -13,12 +13,14 @@ export declare class AMSComponent extends CoreInstance {
|
|
13
13
|
createComponent(params: IcreateComponent): Promise<void>;
|
14
14
|
/**
|
15
15
|
* @description Create and render components in the specified element area
|
16
|
-
* @param params - The data source created by the component, necessary sessionData,
|
16
|
+
* @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.
|
17
|
+
* @param selector - Necessary element selector ID
|
17
18
|
*/
|
18
19
|
mountComponent(params: IcreateComponent, selector: Iselector): Promise<void>;
|
19
20
|
/**
|
20
21
|
* @description Execute payment submission process
|
21
22
|
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
23
|
+
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
22
24
|
*/
|
23
25
|
submit(data?: Isubmit): Promise<unknown>;
|
24
26
|
}
|
@@ -29,8 +29,9 @@ import { v4 as uuid } from 'uuid';
|
|
29
29
|
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
30
30
|
import ComponentApp from "../../plugin/component";
|
31
31
|
import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
|
32
|
-
import { isPC } from "../../util";
|
32
|
+
import { getOrSetStorageId, isPC } from "../../util";
|
33
33
|
import { createIframeNode } from "../../util/createIframeNode";
|
34
|
+
import { getSecurityConfigStorageKey } from "../../util/security";
|
34
35
|
import CoreInstance from "../instance/index";
|
35
36
|
var getComponentSign = function getComponentSign(params) {
|
36
37
|
var _params$paymentSessio = params.paymentSessionConfig,
|
@@ -84,6 +85,11 @@ var handleParams = function handleParams(params) {
|
|
84
85
|
message: "Abnormal response data, interface failure, or unsupported payment method"
|
85
86
|
});
|
86
87
|
}
|
88
|
+
if (parseData && parseData !== null && parseData !== void 0 && parseData.securityConfig) {
|
89
|
+
var _parseData$paymentSes;
|
90
|
+
var product = parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene;
|
91
|
+
getOrSetStorageId(getSecurityConfigStorageKey(product), JSON.stringify(parseData === null || parseData === void 0 ? void 0 : parseData.securityConfig));
|
92
|
+
}
|
87
93
|
_params.sessionData = sessionData;
|
88
94
|
_params.paymentSessionMetaData = parseData;
|
89
95
|
return Promise.resolve({
|
@@ -140,7 +146,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
140
146
|
return Promise.reject(error);
|
141
147
|
}
|
142
148
|
}
|
143
|
-
|
144
149
|
/**
|
145
150
|
* @description Create component application
|
146
151
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
|
@@ -163,7 +168,8 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
163
168
|
}
|
164
169
|
/**
|
165
170
|
* @description Create and render components in the specified element area
|
166
|
-
* @param params - The data source created by the component, necessary sessionData,
|
171
|
+
* @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.
|
172
|
+
* @param selector - Necessary element selector ID
|
167
173
|
*/
|
168
174
|
}, {
|
169
175
|
key: "mountComponent",
|
@@ -185,6 +191,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
185
191
|
/**
|
186
192
|
* @description Execute payment submission process
|
187
193
|
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
|
194
|
+
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
188
195
|
*/
|
189
196
|
}, {
|
190
197
|
key: "submit",
|
@@ -1,28 +1,41 @@
|
|
1
|
-
import {
|
2
|
-
import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams, IsecurityConfig } from '../../types/index';
|
1
|
+
import type { AMSCheckoutOptions, InitSecurityConfig, IoptionsParams } from '../../types/index';
|
3
2
|
import { EventCenter } from '../../util/index';
|
3
|
+
import { Logger } from '../../util/logger';
|
4
|
+
import { Security } from '../../util/security';
|
4
5
|
export default class AMSSDK {
|
5
6
|
options: AMSCheckoutOptions;
|
6
|
-
|
7
|
-
securityConfig: IsecurityConfig;
|
7
|
+
logger: Logger;
|
8
8
|
_eventCenter: EventCenter;
|
9
|
-
protected plugins: Map<string, any>;
|
10
9
|
_instanceId: string;
|
11
10
|
_storageId: string;
|
12
|
-
|
11
|
+
protected securitySdkMap: Map<string, Security>;
|
12
|
+
protected plugins: Map<string, any>;
|
13
13
|
constructor(options: IoptionsParams);
|
14
|
+
private preInitSecurity;
|
14
15
|
/**
|
15
16
|
* @description Destroy and process some contents of the plug-in
|
16
17
|
*/
|
17
18
|
unmount(): void;
|
18
19
|
/**
|
19
|
-
* @description
|
20
|
+
* @description init security SDK
|
21
|
+
* @param product Product Scenarios
|
22
|
+
* @param scene Scenario of the product (compatible with old version parameters, about to be deleted)
|
23
|
+
*/
|
24
|
+
initSecurity({ product, scene, }: InitSecurityConfig & {
|
25
|
+
scene?: string;
|
26
|
+
}): void;
|
27
|
+
/**
|
28
|
+
* @description Obtain security SDK through scenario identification
|
29
|
+
*/
|
30
|
+
_getSecuritySDKByProductScene(securityConfig: InitSecurityConfig): Security;
|
31
|
+
/**
|
32
|
+
* @description New security SDK through scenario identification
|
20
33
|
*/
|
21
|
-
|
34
|
+
_newSecuritySDKByScene(securityConfig: InitSecurityConfig, successCallback?: () => void, failCallback?: (errMsg?: string) => void): Security;
|
22
35
|
/**
|
23
|
-
* @description
|
36
|
+
* @description Obtain risk control configuration in local storage
|
24
37
|
*/
|
25
|
-
|
38
|
+
private getSecurityConfigStorage;
|
26
39
|
/**
|
27
40
|
* @description Set the sdk basic configuration
|
28
41
|
*/
|
@@ -17,33 +17,39 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
*/
|
18
18
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
19
|
import { v4 as uuid } from 'uuid';
|
20
|
-
import {
|
20
|
+
import { sdkVersion } from "../../config/index";
|
21
21
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
22
|
-
import {
|
23
|
-
import {
|
22
|
+
import { antomConfig } from "../../service";
|
23
|
+
import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, productSceneEnum, terminalTypeEnum } from "../../types/index";
|
24
|
+
import { checkTimeElapsed, device, EventCenter, getOrSetStorageId, getType, queryParse, safeJson } from "../../util/index";
|
24
25
|
import CallApp from "../../util/intl-callapp/es/main";
|
25
|
-
import {
|
26
|
-
|
27
|
-
|
26
|
+
import { LogConfig, Logger } from "../../util/logger";
|
27
|
+
import { compareVersion } from "../../util/versionCompare";
|
28
|
+
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security, SecurityRegionEnum } from "../../util/security";
|
28
29
|
var AMSSDK = /*#__PURE__*/function () {
|
29
30
|
function AMSSDK(options) {
|
30
31
|
_classCallCheck(this, AMSSDK);
|
31
32
|
_defineProperty(this, "options", void 0);
|
32
|
-
_defineProperty(this, "
|
33
|
-
_defineProperty(this, "securityConfig", void 0);
|
33
|
+
_defineProperty(this, "logger", void 0);
|
34
34
|
_defineProperty(this, "_eventCenter", void 0);
|
35
|
-
_defineProperty(this, "plugins", void 0);
|
36
35
|
_defineProperty(this, "_instanceId", void 0);
|
37
36
|
_defineProperty(this, "_storageId", void 0);
|
38
|
-
_defineProperty(this, "
|
37
|
+
_defineProperty(this, "securitySdkMap", void 0);
|
38
|
+
_defineProperty(this, "plugins", void 0);
|
39
39
|
this._instanceId = uuid();
|
40
|
-
this._storageId = this.getStorageId(this._instanceId);
|
41
40
|
this.options = {};
|
42
41
|
this._eventCenter = new EventCenter();
|
43
42
|
this._initEvent(options);
|
44
43
|
this._setOptions(options);
|
45
44
|
this.plugins = new Map();
|
46
|
-
this.
|
45
|
+
this.securitySdkMap = new Map();
|
46
|
+
var storageIdKey = 'AMSSDK_STORAGE_ID';
|
47
|
+
var _storageId = getOrSetStorageId(storageIdKey);
|
48
|
+
if (!_storageId) {
|
49
|
+
getOrSetStorageId(storageIdKey, this._instanceId);
|
50
|
+
_storageId = this._instanceId;
|
51
|
+
}
|
52
|
+
this._storageId = _storageId;
|
47
53
|
|
48
54
|
// TODO Consumption data analysis control parameters
|
49
55
|
this.logger = new Logger(LogConfig, (options === null || options === void 0 ? void 0 : options.environment) !== environmentEnum.prod);
|
@@ -55,14 +61,44 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
55
61
|
title: 'NEW_AMSSDK_BY_MECHANT',
|
56
62
|
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
|
57
63
|
}).send();
|
58
|
-
|
59
|
-
this.initSecurity(options === null || options === void 0 ? void 0 : options.securityConfig);
|
60
|
-
}
|
64
|
+
this.preInitSecurity();
|
61
65
|
}
|
62
|
-
/**
|
63
|
-
* @description Destroy and process some contents of the plug-in
|
64
|
-
*/
|
65
66
|
_createClass(AMSSDK, [{
|
67
|
+
key: "preInitSecurity",
|
68
|
+
value: function preInitSecurity() {
|
69
|
+
var _this$options;
|
70
|
+
var antomSDKConfigKey = 'antomSDKConfigKey';
|
71
|
+
var config = safeJson(getOrSetStorageId(antomSDKConfigKey), {});
|
72
|
+
if (checkTimeElapsed()) {
|
73
|
+
antomConfig({
|
74
|
+
env: this.options.env.environment
|
75
|
+
}, this.logger).then(function (res) {
|
76
|
+
getOrSetStorageId(antomSDKConfigKey, JSON.stringify(res));
|
77
|
+
});
|
78
|
+
}
|
79
|
+
var product = ((_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.product) || productSceneEnum.EASY_PAY;
|
80
|
+
var enable = true;
|
81
|
+
try {
|
82
|
+
var matchingConfig = config['pl_sec'].find(function (item) {
|
83
|
+
var _item$v, _item$v2, _item$platform;
|
84
|
+
var minVersion = item === null || item === void 0 || (_item$v = item.v) === null || _item$v === void 0 ? void 0 : _item$v.split('|')[0];
|
85
|
+
var maxVersion = (item === null || item === void 0 || (_item$v2 = item.v) === null || _item$v2 === void 0 ? void 0 : _item$v2.split('|')[1]) || '999.9.9';
|
86
|
+
var matchVersion = compareVersion(sdkVersion, minVersion) >= 0 && compareVersion(maxVersion, sdkVersion) >= 0;
|
87
|
+
return ((item === null || item === void 0 || (_item$platform = item.platform) === null || _item$platform === void 0 ? void 0 : _item$platform.includes('Web')) || (item === null || item === void 0 ? void 0 : item.platform) === '') && (item === null || item === void 0 ? void 0 : item.product) === product && (!(item !== null && item !== void 0 && item.v) || matchVersion);
|
88
|
+
});
|
89
|
+
enable = (matchingConfig === null || matchingConfig === void 0 ? void 0 : matchingConfig.enable) === false ? false : true;
|
90
|
+
} catch (error) {
|
91
|
+
/* empty */
|
92
|
+
}
|
93
|
+
if (!enable) return;
|
94
|
+
this.initSecurity({
|
95
|
+
product: product
|
96
|
+
});
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* @description Destroy and process some contents of the plug-in
|
100
|
+
*/
|
101
|
+
}, {
|
66
102
|
key: "unmount",
|
67
103
|
value: function unmount() {
|
68
104
|
this.logger.logInfo({
|
@@ -86,56 +122,98 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
86
122
|
_iterator.f();
|
87
123
|
}
|
88
124
|
}
|
89
|
-
|
90
125
|
/**
|
91
|
-
* @description
|
126
|
+
* @description init security SDK
|
127
|
+
* @param product Product Scenarios
|
128
|
+
* @param scene Scenario of the product (compatible with old version parameters, about to be deleted)
|
92
129
|
*/
|
93
130
|
}, {
|
94
|
-
key: "
|
95
|
-
value: function
|
96
|
-
var
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
131
|
+
key: "initSecurity",
|
132
|
+
value: function initSecurity(_ref) {
|
133
|
+
var _this = this;
|
134
|
+
var _ref$product = _ref.product,
|
135
|
+
product = _ref$product === void 0 ? productSceneEnum.EASY_PAY : _ref$product,
|
136
|
+
_ref$scene = _ref.scene,
|
137
|
+
scene = _ref$scene === void 0 ? productSceneEnum.EASY_PAY : _ref$scene;
|
138
|
+
this.logger.logInfo({
|
139
|
+
title: 'sdk_event_securitySdkPreInit'
|
140
|
+
}, {
|
141
|
+
product: product
|
142
|
+
}).send();
|
143
|
+
var sdk = this._getSecuritySDKByProductScene({
|
144
|
+
product: product || scene
|
145
|
+
});
|
146
|
+
if (sdk) return;
|
147
|
+
this._newSecuritySDKByScene({
|
148
|
+
product: product || scene,
|
149
|
+
region: SecurityRegionEnum.SG
|
150
|
+
}, function () {
|
151
|
+
_this.logger.logInfo({
|
152
|
+
title: 'sdk_event_securitySdkPreInitSuccess'
|
153
|
+
}, {
|
154
|
+
product: product
|
155
|
+
}).send();
|
156
|
+
}, function (msg) {
|
157
|
+
_this.logger.logError({
|
158
|
+
title: 'sdk_error_securitySdkInitFailed',
|
159
|
+
msg: msg
|
160
|
+
}, {
|
161
|
+
product: product,
|
162
|
+
sign: 'Active initialization'
|
163
|
+
}).send();
|
164
|
+
});
|
108
165
|
}
|
109
|
-
|
110
166
|
/**
|
111
|
-
* @description
|
167
|
+
* @description Obtain security SDK through scenario identification
|
112
168
|
*/
|
113
169
|
}, {
|
114
|
-
key: "
|
115
|
-
value: function
|
116
|
-
var
|
170
|
+
key: "_getSecuritySDKByProductScene",
|
171
|
+
value: function _getSecuritySDKByProductScene(securityConfig) {
|
172
|
+
var storage = this.getSecurityConfigStorage(securityConfig.product);
|
173
|
+
var scene = storage.scene || getSecurityScene(securityConfig.product);
|
174
|
+
var securitySdk = this.securitySdkMap.get(scene);
|
175
|
+
return securitySdk;
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* @description New security SDK through scenario identification
|
179
|
+
*/
|
180
|
+
}, {
|
181
|
+
key: "_newSecuritySDKByScene",
|
182
|
+
value: function _newSecuritySDKByScene(securityConfig, successCallback, failCallback) {
|
183
|
+
var storage = this.getSecurityConfigStorage(securityConfig.product);
|
184
|
+
var scene = storage.scene || getSecurityScene(securityConfig.product);
|
185
|
+
var h5gateway = storage.h5gateway || getSecurityHost(securityConfig.region);
|
117
186
|
try {
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
title: 'sdk_event_securitySdkPreInitSuccess'
|
122
|
-
}).send();
|
123
|
-
}, function (msg) {
|
124
|
-
_this.logger.logError({
|
125
|
-
title: 'sdk_error_securitySdkInitFailed',
|
126
|
-
msg: msg
|
127
|
-
}).send();
|
187
|
+
var securitySdk = new Security({
|
188
|
+
scene: scene,
|
189
|
+
h5gateway: h5gateway
|
128
190
|
});
|
129
|
-
this.
|
130
|
-
|
131
|
-
|
132
|
-
} catch (
|
133
|
-
|
134
|
-
title: 'sdk_error_securitySdkInitFailed'
|
135
|
-
}).send();
|
191
|
+
this.securitySdkMap.set(scene, securitySdk);
|
192
|
+
securitySdk.initSecurity(successCallback, failCallback);
|
193
|
+
return securitySdk;
|
194
|
+
} catch (error) {
|
195
|
+
failCallback && failCallback(JSON.stringify(error));
|
136
196
|
}
|
137
197
|
}
|
138
|
-
|
198
|
+
/**
|
199
|
+
* @description Obtain risk control configuration in local storage
|
200
|
+
*/
|
201
|
+
}, {
|
202
|
+
key: "getSecurityConfigStorage",
|
203
|
+
value: function getSecurityConfigStorage(product) {
|
204
|
+
var scene = '';
|
205
|
+
var h5gateway = '';
|
206
|
+
var securityConfigStorage = getOrSetStorageId(getSecurityConfigStorageKey(product));
|
207
|
+
if (securityConfigStorage) {
|
208
|
+
var config = safeJson(securityConfigStorage, {});
|
209
|
+
scene = config === null || config === void 0 ? void 0 : config.appName;
|
210
|
+
h5gateway = config === null || config === void 0 ? void 0 : config.h5gateway;
|
211
|
+
}
|
212
|
+
return {
|
213
|
+
scene: scene,
|
214
|
+
h5gateway: h5gateway
|
215
|
+
};
|
216
|
+
}
|
139
217
|
/**
|
140
218
|
* @description Set the sdk basic configuration
|
141
219
|
*/
|
@@ -145,6 +223,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
145
223
|
this._setMode(options);
|
146
224
|
this._setEnv(options);
|
147
225
|
this.options.locale = (options === null || options === void 0 ? void 0 : options.locale) || '';
|
226
|
+
this.options.product = options === null || options === void 0 ? void 0 : options.product;
|
148
227
|
}
|
149
228
|
/**
|
150
229
|
* @description Set environment variables
|
@@ -35,7 +35,7 @@ export default class ComponentApp {
|
|
35
35
|
* @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
|
36
36
|
*/
|
37
37
|
setRender(renderFunc: IrenderFuncParams): void;
|
38
|
-
private
|
38
|
+
private initSecurity;
|
39
39
|
private logDeviceId;
|
40
40
|
private getDeviceIdAndLog;
|
41
41
|
/**
|
@@ -18,10 +18,9 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
18
18
|
import { marmotMap } from "../../config/index";
|
19
19
|
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
20
20
|
import { queryPaymentInfo } from "../../service";
|
21
|
-
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum,
|
21
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
22
22
|
import { getType, isJsonString, isPC } from "../../util";
|
23
23
|
import { isLocalMock } from "../../util/mock";
|
24
|
-
import { getApdidToken, getAppname, getSecurityHost, initSecuritySDK } from "../../util/security";
|
25
24
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
26
25
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
27
26
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
@@ -48,7 +47,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
48
47
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
49
48
|
_defineProperty(this, "_appLocationSearch", void 0);
|
50
49
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
51
|
-
this._appVersion = '1.6.
|
50
|
+
this._appVersion = '1.6.1';
|
52
51
|
this._isInitComponent = false;
|
53
52
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
54
53
|
this.createIframeNode = function () {
|
@@ -85,7 +84,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
85
84
|
key: "initLoggerMeta",
|
86
85
|
value: function initLoggerMeta() {
|
87
86
|
var _this$_renderParams, _paymentSessionMetaDa;
|
88
|
-
console.log('this._renderParams', JSON.stringify(this._renderParams), null, 3);
|
89
87
|
var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
|
90
88
|
var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
|
91
89
|
this.AMSSDK.logger.setMedta({
|
@@ -114,39 +112,39 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
114
112
|
this.createIframeNode = renderFunc;
|
115
113
|
}
|
116
114
|
}, {
|
117
|
-
key: "
|
118
|
-
value: function
|
115
|
+
key: "initSecurity",
|
116
|
+
value: function initSecurity() {
|
119
117
|
var _this$_renderParams2,
|
120
118
|
_this = this;
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
|
129
|
-
var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
|
130
|
-
|
131
|
-
// if merchant have init securitySDK and same as service paymentSessionMetaData, no need init again
|
132
|
-
if (this.AMSSDK.securityConfig) {
|
133
|
-
if (appName === getAppname(this.AMSSDK.securityConfig.scene) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
|
134
|
-
return;
|
135
|
-
}
|
119
|
+
var product = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionConfig) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.productScene;
|
120
|
+
if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
|
121
|
+
this.AMSSDK.logger.logInfo({
|
122
|
+
title: 'sdk_event_security_unneeded_scenarios'
|
123
|
+
}, {
|
124
|
+
product: product
|
125
|
+
});
|
136
126
|
}
|
137
|
-
this.AMSSDK.
|
138
|
-
|
127
|
+
var securitySDK = this.AMSSDK._getSecuritySDKByProductScene({
|
128
|
+
product: product
|
139
129
|
});
|
140
|
-
|
141
|
-
|
142
|
-
title: '
|
130
|
+
if (!securitySDK) {
|
131
|
+
this.AMSSDK.logger.logInfo({
|
132
|
+
title: 'sdk_event_securitySdkInit'
|
143
133
|
});
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
134
|
+
this.AMSSDK._newSecuritySDKByScene({
|
135
|
+
product: product
|
136
|
+
}, function () {
|
137
|
+
_this.AMSSDK.logger.logInfo({
|
138
|
+
title: 'sdk_event_securitySdkInitSuccess'
|
139
|
+
});
|
140
|
+
}, function () {
|
141
|
+
_this.AMSSDK.logger.logError({
|
142
|
+
title: 'sdk_error_securitySdkInitFailed'
|
143
|
+
}, {
|
144
|
+
sign: 'SDK internal initialization'
|
145
|
+
});
|
148
146
|
});
|
149
|
-
}
|
147
|
+
}
|
150
148
|
}
|
151
149
|
}, {
|
152
150
|
key: "logDeviceId",
|
@@ -172,23 +170,47 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
172
170
|
key: "getDeviceIdAndLog",
|
173
171
|
value: function getDeviceIdAndLog() {
|
174
172
|
var _this2 = this;
|
173
|
+
var deviceIdParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
174
|
+
var isPolling = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
175
175
|
return new Promise(function (resolve) {
|
176
176
|
// To avoid rendering being blocked, move the logic to the next event loop for processing
|
177
177
|
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
178
178
|
var _this2$_renderParams;
|
179
|
-
var
|
179
|
+
var productScene, getDeviceIdStartTime, securitySDK, deviceId;
|
180
180
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
181
181
|
while (1) switch (_context.prev = _context.next) {
|
182
182
|
case 0:
|
183
|
-
|
183
|
+
productScene = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionConfig) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.productScene;
|
184
184
|
getDeviceIdStartTime = Date.now();
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
deviceId =
|
185
|
+
securitySDK = _this2.AMSSDK._getSecuritySDKByProductScene({
|
186
|
+
product: (deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.productScene) || productScene
|
187
|
+
});
|
188
|
+
deviceId = '';
|
189
|
+
if (!securitySDK) {
|
190
|
+
_context.next = 16;
|
191
|
+
break;
|
192
|
+
}
|
193
|
+
if (!(isPolling && parseInt(deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.tokenCollectTime) > 0)) {
|
194
|
+
_context.next = 11;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
_context.next = 8;
|
198
|
+
return securitySDK.pollingGetApdidToken(deviceIdParameter);
|
199
|
+
case 8:
|
200
|
+
_context.t0 = _context.sent;
|
201
|
+
_context.next = 14;
|
202
|
+
break;
|
203
|
+
case 11:
|
204
|
+
_context.next = 13;
|
205
|
+
return securitySDK.getApdidToken();
|
206
|
+
case 13:
|
207
|
+
_context.t0 = _context.sent;
|
208
|
+
case 14:
|
209
|
+
deviceId = _context.t0;
|
189
210
|
_this2.logDeviceId(deviceId, getDeviceIdStartTime);
|
211
|
+
case 16:
|
190
212
|
resolve(deviceId);
|
191
|
-
case
|
213
|
+
case 17:
|
192
214
|
case "end":
|
193
215
|
return _context.stop();
|
194
216
|
}
|
@@ -214,7 +236,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
214
236
|
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
215
237
|
this._renderDisplayType = renderParams.renderDisplayType;
|
216
238
|
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
217
|
-
this.
|
239
|
+
this.initSecurity();
|
218
240
|
this.initLoggerMeta();
|
219
241
|
this._performanceData.push({
|
220
242
|
key: 'sdk_create_component',
|
@@ -337,7 +359,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
337
359
|
envInfo.deviceId = _context2.sent;
|
338
360
|
case 11:
|
339
361
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
340
|
-
_context2.next =
|
362
|
+
_context2.next = 19;
|
341
363
|
break;
|
342
364
|
}
|
343
365
|
_ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
|
@@ -351,38 +373,43 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
351
373
|
success: true
|
352
374
|
}));
|
353
375
|
case 16:
|
376
|
+
_context2.next = 18;
|
377
|
+
return _this5.getDeviceIdAndLog();
|
378
|
+
case 18:
|
379
|
+
envInfo.deviceId = _context2.sent;
|
380
|
+
case 19:
|
354
381
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
355
|
-
_context2.next =
|
382
|
+
_context2.next = 26;
|
356
383
|
break;
|
357
384
|
}
|
358
385
|
action = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 || (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.action) || {};
|
359
386
|
signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
360
387
|
if (!(signType === 'SMS')) {
|
361
|
-
_context2.next =
|
388
|
+
_context2.next = 24;
|
362
389
|
break;
|
363
390
|
}
|
364
391
|
return _context2.abrupt("return", resolve({
|
365
392
|
message: 'sdk no need to make query request',
|
366
393
|
success: true
|
367
394
|
}));
|
368
|
-
case
|
395
|
+
case 24:
|
369
396
|
if (!(!signType || signType !== 'REDIRECT')) {
|
370
|
-
_context2.next =
|
397
|
+
_context2.next = 26;
|
371
398
|
break;
|
372
399
|
}
|
373
400
|
return _context2.abrupt("return", resolve({
|
374
401
|
success: false
|
375
402
|
}));
|
376
|
-
case
|
403
|
+
case 26:
|
377
404
|
if (!isLocalMock()) {
|
378
|
-
_context2.next =
|
405
|
+
_context2.next = 28;
|
379
406
|
break;
|
380
407
|
}
|
381
408
|
return _context2.abrupt("return", resolve({
|
382
409
|
message: 'sdk no need to make query request',
|
383
410
|
success: true
|
384
411
|
}));
|
385
|
-
case
|
412
|
+
case 28:
|
386
413
|
queryPaymentInfo(params, {
|
387
414
|
env: _this5.AMSSDK.options.env.environment,
|
388
415
|
envInfo: envInfo
|
@@ -407,7 +434,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
407
434
|
});
|
408
435
|
reject(err);
|
409
436
|
});
|
410
|
-
case
|
437
|
+
case 29:
|
411
438
|
case "end":
|
412
439
|
return _context2.stop();
|
413
440
|
}
|
@@ -557,7 +584,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
557
584
|
break;
|
558
585
|
}
|
559
586
|
_context3.next = 3;
|
560
|
-
return this.getDeviceIdAndLog();
|
587
|
+
return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
|
561
588
|
case 3:
|
562
589
|
deviceId = _context3.sent;
|
563
590
|
this.dispatchToApp({
|
@@ -769,7 +796,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
769
796
|
};
|
770
797
|
var failCallback = function failCallback(type, url) {
|
771
798
|
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
772
|
-
code: eventCodeEnum.
|
799
|
+
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
773
800
|
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
774
801
|
});
|
775
802
|
_this6.AMSSDK.logger.logInfo({
|