@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.
@@ -1,2 +1,3 @@
1
1
  export declare const marmotMap: Record<string, string>;
2
+ export declare const marmotConfigMap: Record<string, string>;
2
3
  export declare const sdkVersion: string;
@@ -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, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
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, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
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 { Logger } from '../../util/logger';
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
- checkoutState: IcheckoutState;
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
- logger: Logger;
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 set STORAGE_ID for a user session
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
- getStorageId(instanceId: string): any;
34
+ _newSecuritySDKByScene(securityConfig: InitSecurityConfig, successCallback?: () => void, failCallback?: (errMsg?: string) => void): Security;
22
35
  /**
23
- * @description init initSecurity SDK
36
+ * @description Obtain risk control configuration in local storage
24
37
  */
25
- initSecurity(securityConfig: IsecurityConfig): void;
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 { LogConfig, Logger } from "../../util/logger";
20
+ import { sdkVersion } from "../../config/index";
21
21
  import { ERRORMESSAGE, EVENT } from "../../constant";
22
- import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
23
- import { device, EventCenter, getType, queryParse } from "../../util/index";
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 { initAPSecurity } from "../../util/security";
26
-
27
- // TODO Faster initialization of buried point tools
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, "checkoutState", void 0);
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, "logger", void 0);
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.securityConfig = null;
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
- if (options !== null && options !== void 0 && options.securityConfig) {
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 set STORAGE_ID for a user session
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: "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;
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 init initSecurity SDK
167
+ * @description Obtain security SDK through scenario identification
112
168
  */
113
169
  }, {
114
- key: "initSecurity",
115
- value: function initSecurity(securityConfig) {
116
- var _this = this;
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
- 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();
187
+ var securitySdk = new Security({
188
+ scene: scene,
189
+ h5gateway: h5gateway
128
190
  });
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();
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 initAPSecurity;
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, SecuritySceneEnum, targetEnum } from "../../types";
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.0';
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: "initAPSecurity",
118
- value: function initAPSecurity() {
115
+ key: "initSecurity",
116
+ value: function initSecurity() {
119
117
  var _this$_renderParams2,
120
118
  _this = this;
121
- if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
122
- return;
123
- }
124
- var securityConfig = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.securityConfig;
125
- if (!securityConfig) {
126
- return;
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.logger.logInfo({
138
- title: 'sdk_event_securitySdkInit'
127
+ var securitySDK = this.AMSSDK._getSecuritySDKByProductScene({
128
+ product: product
139
129
  });
140
- initSecuritySDK(appName, h5gateway, function () {
141
- _this.AMSSDK.logger.logInfo({
142
- title: 'sdk_event_securitySdkInitSuccess'
130
+ if (!securitySDK) {
131
+ this.AMSSDK.logger.logInfo({
132
+ title: 'sdk_event_securitySdkInit'
143
133
  });
144
- }, function () {
145
- // TODO Distinguishing Call Scenarios of Security SDK Failures
146
- _this.AMSSDK.logger.logError({
147
- title: 'sdk_error_securitySdkInitFailed'
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 securityConfig, getDeviceIdStartTime, deviceId;
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
- securityConfig = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.securityConfig;
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
- _context.next = 4;
186
- return getApdidToken(getAppname(SecuritySceneEnum.CARD), securityConfig);
187
- case 4:
188
- deviceId = _context.sent;
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 7:
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.initAPSecurity();
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 = 16;
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 = 23;
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 = 21;
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 21:
395
+ case 24:
369
396
  if (!(!signType || signType !== 'REDIRECT')) {
370
- _context2.next = 23;
397
+ _context2.next = 26;
371
398
  break;
372
399
  }
373
400
  return _context2.abrupt("return", resolve({
374
401
  success: false
375
402
  }));
376
- case 23:
403
+ case 26:
377
404
  if (!isLocalMock()) {
378
- _context2.next = 25;
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 25:
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 26:
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.SDK_CALL_URL_SUCCESS,
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({