@alipay/ams-checkout 0.0.1699863258-dev.0 → 0.0.1700804278-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +0 -1
- package/esm/config/index.js +0 -8
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/component/index.d.ts +1 -3
- package/esm/core/component/index.js +3 -10
- package/esm/core/instance/index.d.ts +10 -23
- package/esm/core/instance/index.js +57 -136
- package/esm/plugin/component/index.d.ts +3 -1
- package/esm/plugin/component/index.js +76 -78
- package/esm/request/index.js +10 -7
- package/esm/request/utils.js +4 -1
- package/esm/service/index.d.ts +8 -2
- package/esm/service/index.js +2 -38
- package/esm/types/index.d.ts +18 -19
- package/esm/types/index.js +5 -1
- package/esm/util/index.d.ts +21 -6
- package/esm/util/index.js +45 -38
- package/esm/util/security.d.ts +8 -24
- package/esm/util/security.js +112 -165
- package/package.json +1 -1
- package/esm/util/versionCompare.d.ts +0 -10
- package/esm/util/versionCompare.js +0 -50
package/esm/config/index.d.ts
CHANGED
package/esm/config/index.js
CHANGED
@@ -14,12 +14,4 @@ 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
|
-
};
|
25
17
|
export var sdkVersion = json.version;
|
package/esm/constant/index.d.ts
CHANGED
@@ -152,6 +152,9 @@ export declare const EVENT: {
|
|
152
152
|
getDeviceId: {
|
153
153
|
name: string;
|
154
154
|
};
|
155
|
+
declareEventCallbackInfo: {
|
156
|
+
name: string;
|
157
|
+
};
|
155
158
|
};
|
156
159
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
157
160
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -13,14 +13,12 @@ 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, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
17
|
-
* @param selector - Necessary element selector ID
|
16
|
+
* @param params - The data source created by the component, necessary sessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
18
17
|
*/
|
19
18
|
mountComponent(params: IcreateComponent, selector: Iselector): Promise<void>;
|
20
19
|
/**
|
21
20
|
* @description Execute payment submission process
|
22
21
|
* @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)
|
24
22
|
*/
|
25
23
|
submit(data?: Isubmit): Promise<unknown>;
|
26
24
|
}
|
@@ -29,9 +29,8 @@ 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 {
|
32
|
+
import { isPC } from "../../util";
|
33
33
|
import { createIframeNode } from "../../util/createIframeNode";
|
34
|
-
import { getSecurityConfigStorageKey } from "../../util/security";
|
35
34
|
import CoreInstance from "../instance/index";
|
36
35
|
var getComponentSign = function getComponentSign(params) {
|
37
36
|
var _params$paymentSessio = params.paymentSessionConfig,
|
@@ -85,11 +84,6 @@ var handleParams = function handleParams(params) {
|
|
85
84
|
message: "Abnormal response data, interface failure, or unsupported payment method"
|
86
85
|
});
|
87
86
|
}
|
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
|
-
}
|
93
87
|
_params.sessionData = sessionData;
|
94
88
|
_params.paymentSessionMetaData = parseData;
|
95
89
|
return Promise.resolve({
|
@@ -146,6 +140,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
146
140
|
return Promise.reject(error);
|
147
141
|
}
|
148
142
|
}
|
143
|
+
|
149
144
|
/**
|
150
145
|
* @description Create component application
|
151
146
|
* @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.
|
@@ -168,8 +163,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
168
163
|
}
|
169
164
|
/**
|
170
165
|
* @description Create and render components in the specified element area
|
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
|
166
|
+
* @param params - The data source created by the component, necessary sessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
173
167
|
*/
|
174
168
|
}, {
|
175
169
|
key: "mountComponent",
|
@@ -191,7 +185,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
191
185
|
/**
|
192
186
|
* @description Execute payment submission process
|
193
187
|
* @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)
|
195
188
|
*/
|
196
189
|
}, {
|
197
190
|
key: "submit",
|
@@ -1,41 +1,28 @@
|
|
1
|
-
import type { AMSCheckoutOptions, InitSecurityConfig, IoptionsParams } from '../../types/index';
|
2
|
-
import { EventCenter } from '../../util/index';
|
3
1
|
import { Logger } from '../../util/logger';
|
4
|
-
import {
|
2
|
+
import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams, IsecurityConfig } from '../../types/index';
|
3
|
+
import { EventCenter } from '../../util/index';
|
5
4
|
export default class AMSSDK {
|
6
5
|
options: AMSCheckoutOptions;
|
7
|
-
|
6
|
+
checkoutState: IcheckoutState;
|
7
|
+
securityConfig: IsecurityConfig;
|
8
8
|
_eventCenter: EventCenter;
|
9
|
+
protected plugins: Map<string, any>;
|
9
10
|
_instanceId: string;
|
10
11
|
_storageId: string;
|
11
|
-
|
12
|
-
protected plugins: Map<string, any>;
|
12
|
+
logger: Logger;
|
13
13
|
constructor(options: IoptionsParams);
|
14
|
-
private preInitSecurity;
|
15
14
|
/**
|
16
15
|
* @description Destroy and process some contents of the plug-in
|
17
16
|
*/
|
18
17
|
unmount(): void;
|
19
18
|
/**
|
20
|
-
* @description
|
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
|
19
|
+
* @description set STORAGE_ID for a user session
|
33
20
|
*/
|
34
|
-
|
21
|
+
getStorageId(instanceId: string): any;
|
35
22
|
/**
|
36
|
-
* @description
|
23
|
+
* @description init initSecurity SDK
|
37
24
|
*/
|
38
|
-
|
25
|
+
initSecurity(securityConfig: IsecurityConfig): void;
|
39
26
|
/**
|
40
27
|
* @description Set the sdk basic configuration
|
41
28
|
*/
|
@@ -17,39 +17,33 @@ 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 { LogConfig, Logger } from "../../util/logger";
|
21
21
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
22
|
-
import {
|
23
|
-
import {
|
24
|
-
import { checkTimeElapsed, device, EventCenter, getOrSetStorageId, getType, queryParse, safeJson } from "../../util/index";
|
22
|
+
import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
|
23
|
+
import { device, EventCenter, getType, queryParse } from "../../util/index";
|
25
24
|
import CallApp from "../../util/intl-callapp/es/main";
|
26
|
-
import {
|
27
|
-
|
28
|
-
|
25
|
+
import { initAPSecurity } from "../../util/security";
|
26
|
+
|
27
|
+
// TODO Faster initialization of buried point tools
|
29
28
|
var AMSSDK = /*#__PURE__*/function () {
|
30
29
|
function AMSSDK(options) {
|
31
30
|
_classCallCheck(this, AMSSDK);
|
32
31
|
_defineProperty(this, "options", void 0);
|
33
|
-
_defineProperty(this, "
|
32
|
+
_defineProperty(this, "checkoutState", void 0);
|
33
|
+
_defineProperty(this, "securityConfig", void 0);
|
34
34
|
_defineProperty(this, "_eventCenter", void 0);
|
35
|
+
_defineProperty(this, "plugins", void 0);
|
35
36
|
_defineProperty(this, "_instanceId", void 0);
|
36
37
|
_defineProperty(this, "_storageId", void 0);
|
37
|
-
_defineProperty(this, "
|
38
|
-
_defineProperty(this, "plugins", void 0);
|
38
|
+
_defineProperty(this, "logger", void 0);
|
39
39
|
this._instanceId = uuid();
|
40
|
+
this._storageId = this.getStorageId(this._instanceId);
|
40
41
|
this.options = {};
|
41
42
|
this._eventCenter = new EventCenter();
|
42
43
|
this._initEvent(options);
|
43
44
|
this._setOptions(options);
|
44
45
|
this.plugins = new Map();
|
45
|
-
this.
|
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;
|
46
|
+
this.securityConfig = null;
|
53
47
|
|
54
48
|
// TODO Consumption data analysis control parameters
|
55
49
|
this.logger = new Logger(LogConfig, (options === null || options === void 0 ? void 0 : options.environment) !== environmentEnum.prod);
|
@@ -61,44 +55,14 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
61
55
|
title: 'NEW_AMSSDK_BY_MECHANT',
|
62
56
|
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
|
63
57
|
}).send();
|
64
|
-
|
58
|
+
if (options !== null && options !== void 0 && options.securityConfig) {
|
59
|
+
this.initSecurity(options === null || options === void 0 ? void 0 : options.securityConfig);
|
60
|
+
}
|
65
61
|
}
|
62
|
+
/**
|
63
|
+
* @description Destroy and process some contents of the plug-in
|
64
|
+
*/
|
66
65
|
_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
|
-
}, {
|
102
66
|
key: "unmount",
|
103
67
|
value: function unmount() {
|
104
68
|
this.logger.logInfo({
|
@@ -122,98 +86,56 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
122
86
|
_iterator.f();
|
123
87
|
}
|
124
88
|
}
|
89
|
+
|
125
90
|
/**
|
126
|
-
* @description
|
127
|
-
* @param product Product Scenarios
|
128
|
-
* @param scene Scenario of the product (compatible with old version parameters, about to be deleted)
|
129
|
-
*/
|
130
|
-
}, {
|
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
|
-
});
|
165
|
-
}
|
166
|
-
/**
|
167
|
-
* @description Obtain security SDK through scenario identification
|
91
|
+
* @description set STORAGE_ID for a user session
|
168
92
|
*/
|
169
93
|
}, {
|
170
|
-
key: "
|
171
|
-
value: function
|
172
|
-
var
|
173
|
-
|
174
|
-
|
175
|
-
|
94
|
+
key: "getStorageId",
|
95
|
+
value: function getStorageId(instanceId) {
|
96
|
+
var storageKey = 'AMSSDK_STORAGE_ID';
|
97
|
+
try {
|
98
|
+
if (window.localStorage) {
|
99
|
+
var storageId = window.localStorage.getItem(storageKey);
|
100
|
+
if (storageId) {
|
101
|
+
return storageId;
|
102
|
+
} else {
|
103
|
+
window.localStorage.setItem(storageKey, instanceId);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
} catch (error) {/* empty */}
|
107
|
+
return instanceId;
|
176
108
|
}
|
109
|
+
|
177
110
|
/**
|
178
|
-
* @description
|
111
|
+
* @description init initSecurity SDK
|
179
112
|
*/
|
180
113
|
}, {
|
181
|
-
key: "
|
182
|
-
value: function
|
183
|
-
var
|
184
|
-
var scene = storage.scene || getSecurityScene(securityConfig.product);
|
185
|
-
var h5gateway = storage.h5gateway || getSecurityHost(securityConfig.region);
|
114
|
+
key: "initSecurity",
|
115
|
+
value: function initSecurity(securityConfig) {
|
116
|
+
var _this = this;
|
186
117
|
try {
|
187
|
-
|
188
|
-
|
189
|
-
|
118
|
+
this.securityConfig = securityConfig;
|
119
|
+
initAPSecurity(securityConfig, function () {
|
120
|
+
_this.logger.logInfo({
|
121
|
+
title: 'sdk_event_securitySdkPreInitSuccess'
|
122
|
+
}).send();
|
123
|
+
}, function (msg) {
|
124
|
+
_this.logger.logError({
|
125
|
+
title: 'sdk_error_securitySdkInitFailed',
|
126
|
+
msg: msg
|
127
|
+
}).send();
|
190
128
|
});
|
191
|
-
this.
|
192
|
-
|
193
|
-
|
194
|
-
} catch (
|
195
|
-
|
196
|
-
|
197
|
-
|
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;
|
129
|
+
this.logger.logInfo({
|
130
|
+
title: 'sdk_event_securitySdkPreInit'
|
131
|
+
}).send();
|
132
|
+
} catch (e) {
|
133
|
+
this.logger.logError({
|
134
|
+
title: 'sdk_error_securitySdkInitFailed'
|
135
|
+
}).send();
|
211
136
|
}
|
212
|
-
return {
|
213
|
-
scene: scene,
|
214
|
-
h5gateway: h5gateway
|
215
|
-
};
|
216
137
|
}
|
138
|
+
|
217
139
|
/**
|
218
140
|
* @description Set the sdk basic configuration
|
219
141
|
*/
|
@@ -223,7 +145,6 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
223
145
|
this._setMode(options);
|
224
146
|
this._setEnv(options);
|
225
147
|
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;
|
227
148
|
}
|
228
149
|
/**
|
229
150
|
* @description Set environment variables
|
@@ -21,6 +21,7 @@ export default class ComponentApp {
|
|
21
21
|
private _componentSign;
|
22
22
|
private _appLocationSearch;
|
23
23
|
private _renderDisplayType;
|
24
|
+
private _multipleCallbackEvents;
|
24
25
|
constructor();
|
25
26
|
/**
|
26
27
|
* @description Cancel listening and destroy the dom
|
@@ -35,7 +36,7 @@ export default class ComponentApp {
|
|
35
36
|
* @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
37
|
*/
|
37
38
|
setRender(renderFunc: IrenderFuncParams): void;
|
38
|
-
private
|
39
|
+
private initAPSecurity;
|
39
40
|
private logDeviceId;
|
40
41
|
private getDeviceIdAndLog;
|
41
42
|
/**
|
@@ -70,6 +71,7 @@ export default class ComponentApp {
|
|
70
71
|
private handleSizeChanged;
|
71
72
|
private handleRedirect;
|
72
73
|
private handleDeclareInfo;
|
74
|
+
private handleDeclarePopWindowCallback;
|
73
75
|
private handleCloseBtnShow;
|
74
76
|
/**
|
75
77
|
* @description Send message to SDK
|