@alipay/ams-checkout 0.0.1697942541-dev.4 → 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.
@@ -1,2 +1,2 @@
1
- export declare const marmptMap: Record<string, string>;
1
+ export declare const marmotMap: Record<string, string>;
2
2
  export declare const sdkVersion: string;
@@ -6,12 +6,12 @@
6
6
  * 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.
7
7
  */
8
8
  import json from "../../package.json";
9
- export var marmptMap = {
9
+ export var marmotMap = {
10
10
  dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
11
11
  sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
12
12
  pre: 'https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app',
13
- sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
14
- light_sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
15
- prod: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app'
13
+ sandbox: 'https://cdn.marmot-cloud.com/page/antom-web-checkout/src/component-app',
14
+ light_sandbox: 'https://cdn.marmot-cloud.com/page/antom-web-checkout/src/component-app',
15
+ prod: 'https://cdn.marmot-cloud.com/page/antom-web-checkout/src/component-app'
16
16
  };
17
17
  export var sdkVersion = json.version;
@@ -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";
@@ -148,6 +148,9 @@ export var EVENT = {
148
148
  },
149
149
  threedReady: {
150
150
  name: 'threedReady'
151
+ },
152
+ getDeviceId: {
153
+ name: 'getDeviceId'
151
154
  }
152
155
  };
153
156
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -1,16 +1,28 @@
1
- import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams } from '../../types/index';
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 _this = this;
244
+ var _this2 = this;
177
245
  return new Promise(function (resolve, reject) {
178
- var isWeb = _this.options.env.terminalType === terminalTypeEnum.WEB;
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) || '';
@@ -9,7 +9,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
9
9
  * 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
10
10
  * 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.
11
11
  */
12
- import { marmptMap, sdkVersion } from "../../config/index";
12
+ import { marmotMap, sdkVersion } from "../../config/index";
13
13
  import { componentSignEnum } from "../../types";
14
14
  import { getViewPort, queryParse, serialize } from "../../util/index";
15
15
  var getAppVersion = function getAppVersion(_extendInfo) {
@@ -46,7 +46,7 @@ export var getAppPath = function getAppPath() {
46
46
  if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
47
47
  return urlTestHost;
48
48
  }
49
- return "".concat(marmptMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
49
+ return "".concat(marmotMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
50
50
  };
51
51
  export var getAppDomain = function getAppDomain(domainParams) {
52
52
  var environment = domainParams.environment,
@@ -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(): void;
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
- }, element?: any): any;
83
+ }, targetElement?: any): any;
80
84
  /**
81
85
  * @description Subscribe to messages from SDK
82
86
  */