@alipay/ams-checkout 0.0.1697942541-dev.5 → 0.0.1697942541-dev.6
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/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/instance/index.d.ts +13 -1
- package/esm/core/instance/index.js +70 -2
- package/esm/plugin/component/index.d.ts +6 -2
- package/esm/plugin/component/index.js +334 -172
- package/esm/request/index.d.ts +2 -1
- package/esm/request/index.js +57 -34
- package/esm/service/index.d.ts +9 -1
- package/esm/service/index.js +4 -3
- package/esm/types/index.d.ts +18 -8
- package/esm/types/index.js +5 -0
- package/esm/util/logger.d.ts +54 -0
- package/esm/util/logger.js +172 -0
- package/esm/util/security.d.ts +6 -3
- package/esm/util/security.js +98 -72
- package/package.json +1 -1
package/esm/constant/index.d.ts
CHANGED
@@ -149,6 +149,9 @@ export declare const EVENT: {
|
|
149
149
|
threedReady: {
|
150
150
|
name: string;
|
151
151
|
};
|
152
|
+
getDeviceId: {
|
153
|
+
name: string;
|
154
|
+
};
|
152
155
|
};
|
153
156
|
export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
|
154
157
|
export declare const COMPONENT_SECTION_ID = "ams-component-section";
|
package/esm/constant/index.js
CHANGED
@@ -1,16 +1,28 @@
|
|
1
|
-
import
|
1
|
+
import { Logger } from '../../util/logger';
|
2
|
+
import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams, IsecurityConfig } from '../../types/index';
|
2
3
|
import { EventCenter } from '../../util/index';
|
3
4
|
export default class AMSSDK {
|
4
5
|
options: AMSCheckoutOptions;
|
5
6
|
checkoutState: IcheckoutState;
|
7
|
+
securityConfig: IsecurityConfig;
|
6
8
|
_eventCenter: EventCenter;
|
7
9
|
protected plugins: Map<string, any>;
|
8
10
|
_instanceId: string;
|
11
|
+
_storageId: string;
|
12
|
+
logger: Logger;
|
9
13
|
constructor(options: IoptionsParams);
|
10
14
|
/**
|
11
15
|
* @description Destroy and process some contents of the plug-in
|
12
16
|
*/
|
13
17
|
unmount(): void;
|
18
|
+
/**
|
19
|
+
* @description set STORAGE_ID for a user session
|
20
|
+
*/
|
21
|
+
getStorageId(instanceId: string): any;
|
22
|
+
/**
|
23
|
+
* @description init initSecurity SDK
|
24
|
+
*/
|
25
|
+
initSecurity(securityConfig: IsecurityConfig): void;
|
14
26
|
/**
|
15
27
|
* @description Set the sdk basic configuration
|
16
28
|
*/
|
@@ -17,25 +17,46 @@ 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 { LogConfig, Logger } from "../../util/logger";
|
20
21
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
21
22
|
import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
|
22
23
|
import { device, EventCenter, getType, queryParse } from "../../util/index";
|
23
24
|
import CallApp from "../../util/intl-callapp/es/main";
|
25
|
+
import { initAPSecurity } from "../../util/security";
|
26
|
+
|
27
|
+
// TODO Faster initialization of buried point tools
|
24
28
|
var AMSSDK = /*#__PURE__*/function () {
|
25
29
|
function AMSSDK(options) {
|
26
30
|
_classCallCheck(this, AMSSDK);
|
27
31
|
_defineProperty(this, "options", void 0);
|
28
32
|
_defineProperty(this, "checkoutState", void 0);
|
33
|
+
_defineProperty(this, "securityConfig", void 0);
|
29
34
|
_defineProperty(this, "_eventCenter", void 0);
|
30
35
|
_defineProperty(this, "plugins", void 0);
|
31
36
|
_defineProperty(this, "_instanceId", void 0);
|
37
|
+
_defineProperty(this, "_storageId", void 0);
|
38
|
+
_defineProperty(this, "logger", void 0);
|
32
39
|
this._instanceId = uuid();
|
40
|
+
this._storageId = this.getStorageId(this._instanceId);
|
41
|
+
// TODO Consumption data analysis control parameters
|
42
|
+
this.logger = new Logger(LogConfig, (options === null || options === void 0 ? void 0 : options.environment) !== environmentEnum.prod);
|
43
|
+
this.logger.setMedta({
|
44
|
+
instanceId: this._instanceId
|
45
|
+
});
|
46
|
+
this.logger.initTracker();
|
47
|
+
this.logger.logInfo({
|
48
|
+
title: 'NEW_AMSSDK_BY_MECHANT',
|
49
|
+
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
|
50
|
+
});
|
51
|
+
|
33
52
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
34
53
|
this.options = {};
|
35
54
|
this._eventCenter = new EventCenter();
|
36
55
|
this._initEvent(options);
|
37
56
|
this._setOptions(options);
|
38
57
|
this.plugins = new Map();
|
58
|
+
this.securityConfig = null;
|
59
|
+
this.logger.send();
|
39
60
|
}
|
40
61
|
/**
|
41
62
|
* @description Destroy and process some contents of the plug-in
|
@@ -61,6 +82,53 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
61
82
|
_iterator.f();
|
62
83
|
}
|
63
84
|
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* @description set STORAGE_ID for a user session
|
88
|
+
*/
|
89
|
+
}, {
|
90
|
+
key: "getStorageId",
|
91
|
+
value: function getStorageId(instanceId) {
|
92
|
+
var storageKey = 'AMSSDK_STORAGE_ID';
|
93
|
+
if (window.localStorage) {
|
94
|
+
var storageId = window.localStorage.getItem(storageKey);
|
95
|
+
if (storageId) {
|
96
|
+
return storageId;
|
97
|
+
} else {
|
98
|
+
window.localStorage.setItem(storageKey, instanceId);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
return instanceId;
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* @description init initSecurity SDK
|
106
|
+
*/
|
107
|
+
}, {
|
108
|
+
key: "initSecurity",
|
109
|
+
value: function initSecurity(securityConfig) {
|
110
|
+
var _this = this;
|
111
|
+
try {
|
112
|
+
console.log("-----------Risk control project test: \u4E3B\u52A8\u521D\u59CB\u5316\u5B89\u5168sdk");
|
113
|
+
this.securityConfig = securityConfig;
|
114
|
+
initAPSecurity(securityConfig, function () {
|
115
|
+
_this.logger.logInfo({
|
116
|
+
title: 'sdk_event_securitySdkPreInitSuccess'
|
117
|
+
}).send();
|
118
|
+
}, function (msg) {
|
119
|
+
_this.logger.logError({
|
120
|
+
title: 'sdk_error_securitySdkInitFailed',
|
121
|
+
msg: msg
|
122
|
+
}).send();
|
123
|
+
});
|
124
|
+
this.logger.logInfo({
|
125
|
+
title: 'sdk_event_securitySdkPreInit'
|
126
|
+
}).send();
|
127
|
+
} catch (e) {
|
128
|
+
console.log("-----------Risk control project test: \u4E3B\u52A8\u521D\u59CB\u5316\u5B89\u5168sdk\u5931\u8D25");
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
64
132
|
/**
|
65
133
|
* @description Set the sdk basic configuration
|
66
134
|
*/
|
@@ -173,9 +241,9 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
173
241
|
}, {
|
174
242
|
key: "_redirect",
|
175
243
|
value: function _redirect(data) {
|
176
|
-
var
|
244
|
+
var _this2 = this;
|
177
245
|
return new Promise(function (resolve, reject) {
|
178
|
-
var isWeb =
|
246
|
+
var isWeb = _this2.options.env.terminalType === terminalTypeEnum.WEB;
|
179
247
|
var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';
|
180
248
|
var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';
|
181
249
|
var applinkUrl = (data === null || data === void 0 ? void 0 : data.applinkUrl) || '';
|
@@ -30,11 +30,14 @@ export default class ComponentApp {
|
|
30
30
|
* @description When SDK registers plug-ins, it is a required function to receive SDK instances
|
31
31
|
*/
|
32
32
|
applyPlugin(AMSSDK: AMSCheckout): void;
|
33
|
+
private initLoggerMeta;
|
33
34
|
/**
|
34
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
|
35
36
|
*/
|
36
37
|
setRender(renderFunc: IrenderFuncParams): void;
|
37
|
-
initAPSecurity
|
38
|
+
private initAPSecurity;
|
39
|
+
private logDeviceId;
|
40
|
+
private getDeviceIdAndLog;
|
38
41
|
/**
|
39
42
|
* @description render iframe content
|
40
43
|
*/
|
@@ -54,6 +57,7 @@ export default class ComponentApp {
|
|
54
57
|
private listener;
|
55
58
|
private resizeListener;
|
56
59
|
private createPopupWindow;
|
60
|
+
private getDeviceIdAndCallback;
|
57
61
|
/**
|
58
62
|
* @description Initialize subscription iframe message
|
59
63
|
*/
|
@@ -76,7 +80,7 @@ export default class ComponentApp {
|
|
76
80
|
*/
|
77
81
|
dispatchToApp(payload: {
|
78
82
|
context: eventPayloadContext;
|
79
|
-
},
|
83
|
+
}, targetElement?: any): any;
|
80
84
|
/**
|
81
85
|
* @description Subscribe to messages from SDK
|
82
86
|
*/
|