@alipay/ams-checkout 0.0.1783663570-dev.5 → 0.0.1784095668-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.
@@ -9,24 +9,20 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
9
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
10
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
11
  import { ProductSceneEnum } from "../../../types";
12
- import { Security, SecurityRegionEnum, getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, mapEnvironment } from "./security";
12
+ import { Security, SecurityRegionEnum, getSecurityConfigStorageKey, getSecurityHost, getSecurityScene } from "./security";
13
13
  import { getOrSetStorageId, safeJson } from "../../../util";
14
- import { SecuritySdkRegistry } from "../../../util/security-registry";
15
- import { ApdidLoader } from "../../../util/jshield-apdid";
16
14
  import { ServiceProvider } from '..';
17
15
  export var SecurityService = /*#__PURE__*/function () {
18
16
  function SecurityService() {
19
17
  _classCallCheck(this, SecurityService);
20
18
  _defineProperty(this, "logger", void 0);
21
19
  _defineProperty(this, "productScene", ProductSceneEnum.EASY_PAY);
22
- _defineProperty(this, "environment", void 0);
23
20
  }
24
21
  _createClass(SecurityService, [{
25
22
  key: "init",
26
23
  value: function init(initOptions, instanceId, sdkMetaData) {
27
24
  this.logger = ServiceProvider.getInstance(instanceId).getService('Log');
28
25
  this.productScene = sdkMetaData.productScene;
29
- this.environment = initOptions === null || initOptions === void 0 ? void 0 : initOptions.environment;
30
26
  }
31
27
  }, {
32
28
  key: "update",
@@ -50,44 +46,40 @@ export var SecurityService = /*#__PURE__*/function () {
50
46
  return _context2.abrupt("return", new Promise(function (resolve) {
51
47
  // To avoid rendering being blocked, move the logic to the next event loop for processing
52
48
  setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
53
- var getDeviceIdStartTime, product, securitySDK, deviceId;
49
+ var getDeviceIdStartTime, securitySDK, deviceId;
54
50
  return _regeneratorRuntime().wrap(function _callee$(_context) {
55
51
  while (1) switch (_context.prev = _context.next) {
56
52
  case 0:
57
53
  getDeviceIdStartTime = Date.now();
58
- product = (deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.productScene) || _this.productScene;
59
- _context.next = 4;
60
- return _this._getSecuritySDKByProductScene({
61
- product: product
54
+ securitySDK = _this._getSecuritySDKByProductScene({
55
+ product: (deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.productScene) || _this.productScene
62
56
  });
63
- case 4:
64
- securitySDK = _context.sent;
65
57
  deviceId = '';
66
58
  if (!securitySDK) {
67
- _context.next = 18;
59
+ _context.next = 15;
68
60
  break;
69
61
  }
70
62
  if (!(isPolling && parseInt(deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.tokenCollectTime) > 0)) {
71
- _context.next = 13;
63
+ _context.next = 10;
72
64
  break;
73
65
  }
74
- _context.next = 10;
66
+ _context.next = 7;
75
67
  return securitySDK.pollingGetApdidToken(deviceIdParameter);
76
- case 10:
68
+ case 7:
77
69
  _context.t0 = _context.sent;
78
- _context.next = 16;
70
+ _context.next = 13;
79
71
  break;
80
- case 13:
81
- _context.next = 15;
72
+ case 10:
73
+ _context.next = 12;
82
74
  return securitySDK.getApdidToken();
83
- case 15:
75
+ case 12:
84
76
  _context.t0 = _context.sent;
85
- case 16:
77
+ case 13:
86
78
  deviceId = _context.t0;
87
79
  _this.logDeviceId(deviceId, getDeviceIdStartTime);
88
- case 18:
80
+ case 15:
89
81
  resolve(deviceId);
90
- case 19:
82
+ case 16:
91
83
  case "end":
92
84
  return _context.stop();
93
85
  }
@@ -153,10 +145,6 @@ export var SecurityService = /*#__PURE__*/function () {
153
145
  var isPre,
154
146
  timeout,
155
147
  sdkAction,
156
- scene,
157
- existing,
158
- apdidEnv,
159
- loader,
160
148
  _args5 = arguments;
161
149
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
162
150
  while (1) switch (_context5.prev = _context5.next) {
@@ -164,78 +152,17 @@ export var SecurityService = /*#__PURE__*/function () {
164
152
  isPre = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : false;
165
153
  timeout = _args5.length > 1 ? _args5[1] : undefined;
166
154
  sdkAction = isPre ? 'PreInit' : 'Init';
167
- scene = this._getSceneByProduct(this.productScene); // Check if already ready
168
- if (!SecuritySdkRegistry.isReady(scene)) {
169
- _context5.next = 6;
155
+ if (!this._getSecuritySDKByProductScene({
156
+ product: this.productScene
157
+ })) {
158
+ _context5.next = 5;
170
159
  break;
171
160
  }
172
161
  return _context5.abrupt("return", Promise.resolve());
173
- case 6:
174
- if (!SecuritySdkRegistry.isLoading(scene)) {
175
- _context5.next = 19;
176
- break;
177
- }
178
- existing = SecuritySdkRegistry.get(scene);
179
- if (!(existing && existing.status === 'loading')) {
180
- _context5.next = 19;
181
- break;
182
- }
183
- _context5.prev = 9;
184
- _context5.next = 12;
185
- return existing.loadingPromise;
186
- case 12:
187
- this.logger.logInfo({
188
- title: "sdk_event_securitySdk".concat(sdkAction, "Success")
189
- }).send();
190
- _context5.next = 18;
191
- break;
192
- case 15:
193
- _context5.prev = 15;
194
- _context5.t0 = _context5["catch"](9);
195
- this.logger.logError({
196
- title: 'sdk_error_securitySdkInitFailed'
197
- }, {
198
- productScene: this.productScene,
199
- sign: isPre ? 'Active initialization' : 'SDK internal initialization'
200
- }).send();
201
- case 18:
202
- return _context5.abrupt("return");
203
- case 19:
162
+ case 5:
204
163
  this.logger.logInfo({
205
164
  title: "sdk_event_securitySdk".concat(sdkAction)
206
165
  });
207
-
208
- // 非阻塞调度 ApdidLoader 加载,在浏览器空闲时发起,2s 超时兜底
209
- // Security 内部的 ensureApdidLoaded() 会在需要 token 时按需等待加载完成
210
- apdidEnv = mapEnvironment(this.environment);
211
- loader = ApdidLoader.getInstance();
212
- loader.scheduleLoad({
213
- environment: apdidEnv,
214
- callbacks: {
215
- onLoad: function onLoad(duration) {
216
- _this2.logger.logInfo({
217
- title: 'sdk_event_securitySdkScriptLoaded'
218
- }, {
219
- eventMessage: "".concat(duration)
220
- }).send();
221
- },
222
- onLoadFailed: function onLoadFailed(error) {
223
- _this2.logger.logError({
224
- title: 'sdk_event_securitySdkLoadFailed',
225
- msg: error.message
226
- }, {
227
- productScene: _this2.productScene
228
- }).send();
229
- },
230
- onLoadTimeout: function onLoadTimeout() {
231
- _this2.logger.logError({
232
- title: 'sdk_event_securitySdkScriptLoadTimeout'
233
- }, {
234
- productScene: _this2.productScene
235
- }).send();
236
- }
237
- }
238
- });
239
166
  return _context5.abrupt("return", new Promise(function (resolve, reject) {
240
167
  if (timeout) {
241
168
  setTimeout(function () {
@@ -269,11 +196,11 @@ export var SecurityService = /*#__PURE__*/function () {
269
196
  reject();
270
197
  });
271
198
  }));
272
- case 24:
199
+ case 7:
273
200
  case "end":
274
201
  return _context5.stop();
275
202
  }
276
- }, _callee5, this, [[9, 15]]);
203
+ }, _callee5, this);
277
204
  }));
278
205
  function _initSecurity() {
279
206
  return _initSecurity3.apply(this, arguments);
@@ -300,85 +227,34 @@ export var SecurityService = /*#__PURE__*/function () {
300
227
  }
301
228
 
302
229
  /**
303
- * Get the scene string from product enum
230
+ * @description Obtain security SDK through scenario identification
304
231
  */
305
232
  }, {
306
- key: "_getSceneByProduct",
307
- value: function _getSceneByProduct(product) {
308
- var storage = this._getSecurityConfigStorage(product);
309
- return storage.scene || getSecurityScene(product);
233
+ key: "_getSecuritySDKByProductScene",
234
+ value: function _getSecuritySDKByProductScene(securityConfig) {
235
+ var storage = this._getSecurityConfigStorage(securityConfig.product);
236
+ var scene = storage.scene || getSecurityScene(securityConfig.product);
237
+ var securitySdk = SecurityService.securitySdkMap.get(scene);
238
+ return securitySdk;
310
239
  }
311
240
 
312
241
  /**
313
- * @description Obtain security SDK through scenario identification (async-aware)
314
- * Handles three states: ready, loading, not found
242
+ * @description New security SDK through scenario identification
315
243
  */
316
- }, {
317
- key: "_getSecuritySDKByProductScene",
318
- value: (function () {
319
- var _getSecuritySDKByProductScene2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(securityConfig) {
320
- var scene;
321
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
322
- while (1) switch (_context6.prev = _context6.next) {
323
- case 0:
324
- scene = this._getSceneByProduct(securityConfig.product);
325
- return _context6.abrupt("return", SecuritySdkRegistry.getInstance(scene));
326
- case 2:
327
- case "end":
328
- return _context6.stop();
329
- }
330
- }, _callee6, this);
331
- }));
332
- function _getSecuritySDKByProductScene(_x3) {
333
- return _getSecuritySDKByProductScene2.apply(this, arguments);
334
- }
335
- return _getSecuritySDKByProductScene;
336
- }()
337
- /**
338
- * @description New security SDK through scenario identification (async)
339
- * Uses shared SecuritySdkRegistry to avoid duplicate initialization
340
- */
341
- )
342
244
  }, {
343
245
  key: "_newSecuritySDKByScene",
344
246
  value: function _newSecuritySDKByScene(securityConfig, successCallback, failCallback) {
345
247
  var storage = this._getSecurityConfigStorage(securityConfig.product);
346
248
  var scene = storage.scene || getSecurityScene(securityConfig.product);
347
249
  var h5gateway = storage.h5gateway || getSecurityHost(securityConfig.region);
348
-
349
- // Check if already exists in registry (avoid duplicates)
350
- var existingEntry = SecuritySdkRegistry.get(scene);
351
- if (existingEntry && (existingEntry.status === 'ready' || existingEntry.status === 'loading')) {
352
- if (existingEntry.status === 'ready') {
353
- successCallback && successCallback();
354
- }
355
- // If loading, the existing callbacks will handle it
356
- return;
357
- }
358
250
  try {
359
251
  var securitySdk = new Security({
360
252
  scene: scene,
361
- h5gateway: h5gateway,
362
- environment: this.environment
253
+ h5gateway: h5gateway
363
254
  });
364
-
365
- // Create loading promise and register in registry
366
- var loadingPromise = new Promise(function (resolveLoading, rejectLoading) {
367
- securitySdk.initSecurity(function () {
368
- SecuritySdkRegistry.setReady(scene, securitySdk);
369
- successCallback && successCallback();
370
- resolveLoading(securitySdk);
371
- }, function (msg) {
372
- SecuritySdkRegistry.setFailed(scene, new Error(msg || 'Security init failed'));
373
- failCallback && failCallback(msg);
374
- rejectLoading(new Error(msg || 'Security init failed'));
375
- });
376
- });
377
-
378
- // Register as loading in the shared registry
379
- SecuritySdkRegistry.setLoading(scene, loadingPromise);
255
+ SecurityService.securitySdkMap.set(scene, securitySdk);
256
+ securitySdk.initSecurity(successCallback, failCallback);
380
257
  } catch (error) {
381
- SecuritySdkRegistry.setFailed(scene, new Error(error === null || error === void 0 ? void 0 : error.toString()));
382
258
  failCallback && failCallback(error === null || error === void 0 ? void 0 : error.toString());
383
259
  }
384
260
  }
@@ -404,4 +280,5 @@ export var SecurityService = /*#__PURE__*/function () {
404
280
  }
405
281
  }]);
406
282
  return SecurityService;
407
- }();
283
+ }();
284
+ _defineProperty(SecurityService, "securitySdkMap", new Map());
@@ -1,5 +1,4 @@
1
1
  import { IsecurityConfig, ProductSceneEnum, DeviceIdParameter } from '../../../types';
2
- import type { ApdidEnvironment } from '../../../util/jshield-apdid';
3
2
  export declare const getSecurityConfigStorageKey: (scene: ProductSceneEnum) => string;
4
3
  export declare enum SecurityRegionEnum {
5
4
  SG = "SG",
@@ -23,30 +22,10 @@ export declare const sceneMap: {
23
22
  };
24
23
  export declare const getSecurityHost: (region: string) => string;
25
24
  export declare const getSecurityScene: (product: string) => string;
26
- /**
27
- * Map SDK environment string to ApdidEnvironment for CDN URL selection.
28
- */
29
- export declare const mapEnvironment: (env?: string) => ApdidEnvironment;
30
25
  export declare class Security {
31
26
  scene: string;
32
27
  h5gateway: string;
33
- private environment?;
34
- private apdidLoaded;
35
- private apdidLoadFailed;
36
- constructor(options: IsecurityConfig & {
37
- environment?: string;
38
- });
39
- /**
40
- * Ensure the apdid-core script is loaded async.
41
- * Returns true if loaded successfully, false otherwise.
42
- * On failure, sets apdidLoadFailed flag for graceful degradation.
43
- */
44
- private ensureApdidLoaded;
45
- /**
46
- * Get the APDID module from the loader.
47
- * Returns undefined if not loaded.
48
- */
49
- private getAPDIDModule;
28
+ constructor(options: IsecurityConfig);
50
29
  initSecurity(successCallback: any, failCallback: any): void;
51
30
  private initToken;
52
31
  pollingGetApdidToken(config?: DeviceIdParameter): Promise<string>;
@@ -9,7 +9,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
9
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
10
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
11
  import { ProductSceneEnum } from "../../../types";
12
- import { ApdidLoader } from "../../../util/jshield-apdid";
12
+ import APDID from "../../../util/jshield-apdid/apdid-core.umd.min";
13
13
  export var getSecurityConfigStorageKey = function getSecurityConfigStorageKey(scene) {
14
14
  return "AMSSDK_SECURITY_CONFIG_".concat(scene);
15
15
  };
@@ -31,108 +31,17 @@ export var getSecurityHost = function getSecurityHost(region) {
31
31
  export var getSecurityScene = function getSecurityScene(product) {
32
32
  return sceneMap[product] || '';
33
33
  };
34
-
35
- /**
36
- * Map SDK environment string to ApdidEnvironment for CDN URL selection.
37
- */
38
- export var mapEnvironment = function mapEnvironment(env) {
39
- if (!env) return 'production';
40
- var lower = env.toLowerCase();
41
- if (lower === 'pre' || lower === 'light_sandbox') return 'pre';
42
- if (lower === 'dev' || lower === 'test' || lower === 'local') return 'dev';
43
- return 'production';
44
- };
45
34
  export var Security = /*#__PURE__*/function () {
46
35
  function Security(options) {
47
36
  _classCallCheck(this, Security);
48
37
  _defineProperty(this, "scene", void 0);
49
38
  _defineProperty(this, "h5gateway", void 0);
50
- _defineProperty(this, "environment", void 0);
51
- _defineProperty(this, "apdidLoaded", false);
52
- _defineProperty(this, "apdidLoadFailed", false);
53
39
  this.scene = options.scene;
54
40
  this.h5gateway = options.h5gateway || securityHost[SecurityRegionEnum.SG];
55
- this.environment = options.environment;
56
41
  }
57
-
58
- /**
59
- * Ensure the apdid-core script is loaded async.
60
- * Returns true if loaded successfully, false otherwise.
61
- * On failure, sets apdidLoadFailed flag for graceful degradation.
62
- */
63
42
  _createClass(Security, [{
64
- key: "ensureApdidLoaded",
65
- value: (function () {
66
- var _ensureApdidLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
67
- var loader, apdidEnv;
68
- return _regeneratorRuntime().wrap(function _callee$(_context) {
69
- while (1) switch (_context.prev = _context.next) {
70
- case 0:
71
- if (!this.apdidLoaded) {
72
- _context.next = 2;
73
- break;
74
- }
75
- return _context.abrupt("return", true);
76
- case 2:
77
- if (!this.apdidLoadFailed) {
78
- _context.next = 4;
79
- break;
80
- }
81
- return _context.abrupt("return", false);
82
- case 4:
83
- loader = ApdidLoader.getInstance();
84
- apdidEnv = mapEnvironment(this.environment);
85
- _context.prev = 6;
86
- _context.next = 9;
87
- return loader.load({
88
- environment: apdidEnv,
89
- callbacks: {
90
- onLoad: function onLoad(duration) {
91
- console.log("[Security] apdid-core script loaded in ".concat(duration, "ms"));
92
- },
93
- onLoadFailed: function onLoadFailed(error) {
94
- console.error('[Security] apdid-core script load failed:', error.message);
95
- },
96
- onLoadTimeout: function onLoadTimeout() {
97
- console.error('[Security] apdid-core script load timeout');
98
- }
99
- }
100
- });
101
- case 9:
102
- this.apdidLoaded = true;
103
- return _context.abrupt("return", true);
104
- case 13:
105
- _context.prev = 13;
106
- _context.t0 = _context["catch"](6);
107
- console.error('[Security] apdid-core load error, degrading:', _context.t0);
108
- this.apdidLoadFailed = true;
109
- return _context.abrupt("return", false);
110
- case 18:
111
- case "end":
112
- return _context.stop();
113
- }
114
- }, _callee, this, [[6, 13]]);
115
- }));
116
- function ensureApdidLoaded() {
117
- return _ensureApdidLoaded.apply(this, arguments);
118
- }
119
- return ensureApdidLoaded;
120
- }()
121
- /**
122
- * Get the APDID module from the loader.
123
- * Returns undefined if not loaded.
124
- */
125
- )
126
- }, {
127
- key: "getAPDIDModule",
128
- value: function getAPDIDModule() {
129
- var loader = ApdidLoader.getInstance();
130
- return loader.getApdidModule();
131
- }
132
- }, {
133
43
  key: "initSecurity",
134
44
  value: function initSecurity(successCallback, failCallback) {
135
- var _this = this;
136
45
  if (!this.scene) {
137
46
  throw new Error('securityConfig parameter error');
138
47
  }
@@ -141,23 +50,12 @@ export var Security = /*#__PURE__*/function () {
141
50
  console.error(errorMsg);
142
51
  throw new Error(errorMsg);
143
52
  }
144
-
145
- // Async: ensure script is loaded before calling initToken
146
- this.ensureApdidLoaded().then(function (loaded) {
147
- if (!loaded) {
148
- failCallback && failCallback('apdid-core script load failed');
149
- return;
150
- }
151
- _this.initToken(successCallback, failCallback);
152
- }).catch(function () {
153
- failCallback && failCallback('apdid-core script load failed');
154
- });
53
+ this.initToken(successCallback, failCallback);
155
54
  }
156
55
  }, {
157
56
  key: "initToken",
158
57
  value: function initToken(successCallback, failCallback) {
159
58
  try {
160
- var APDID = this.getAPDIDModule();
161
59
  APDID === null || APDID === void 0 || APDID.initToken(this.scene, {
162
60
  host: this.h5gateway
163
61
  }, function (success, tokenResult, msg) {
@@ -166,6 +64,7 @@ export var Security = /*#__PURE__*/function () {
166
64
  } else {
167
65
  failCallback && failCallback(msg);
168
66
  }
67
+ console.log('initToken result tokenResult', JSON.stringify(tokenResult), msg);
169
68
  });
170
69
  } catch (error) {
171
70
  failCallback && failCallback(error === null || error === void 0 ? void 0 : error.toString());
@@ -174,48 +73,48 @@ export var Security = /*#__PURE__*/function () {
174
73
  }, {
175
74
  key: "pollingGetApdidToken",
176
75
  value: function () {
177
- var _pollingGetApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(config) {
178
- var _this2 = this;
76
+ var _pollingGetApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(config) {
77
+ var _this = this;
179
78
  var tokenCollectTime, dataPollingInterval, asyncFunc;
180
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
181
- while (1) switch (_context4.prev = _context4.next) {
79
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
80
+ while (1) switch (_context3.prev = _context3.next) {
182
81
  case 0:
183
82
  tokenCollectTime = parseInt((config === null || config === void 0 ? void 0 : config.tokenCollectTime) || '0', 10);
184
83
  dataPollingInterval = parseInt((config === null || config === void 0 ? void 0 : config.dataPollingInterval) || '500', 10);
185
84
  asyncFunc = /*#__PURE__*/function () {
186
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
85
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
187
86
  var deviceId, interval, polling;
188
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
189
- while (1) switch (_context3.prev = _context3.next) {
87
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
88
+ while (1) switch (_context2.prev = _context2.next) {
190
89
  case 0:
191
- _context3.next = 2;
192
- return _this2.getApdidToken();
90
+ _context2.next = 2;
91
+ return _this.getApdidToken();
193
92
  case 2:
194
- deviceId = _context3.sent;
93
+ deviceId = _context2.sent;
195
94
  if (!deviceId) {
196
- _context3.next = 5;
95
+ _context2.next = 5;
197
96
  break;
198
97
  }
199
- return _context3.abrupt("return", resolve(deviceId));
98
+ return _context2.abrupt("return", resolve(deviceId));
200
99
  case 5:
201
100
  polling = /*#__PURE__*/function () {
202
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
203
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
204
- while (1) switch (_context2.prev = _context2.next) {
101
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
102
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
103
+ while (1) switch (_context.prev = _context.next) {
205
104
  case 0:
206
- _context2.next = 2;
207
- return _this2.getApdidToken();
105
+ _context.next = 2;
106
+ return _this.getApdidToken();
208
107
  case 2:
209
- deviceId = _context2.sent;
108
+ deviceId = _context.sent;
210
109
  if (deviceId) {
211
110
  clearInterval(interval);
212
111
  resolve(deviceId);
213
112
  }
214
113
  case 4:
215
114
  case "end":
216
- return _context2.stop();
115
+ return _context.stop();
217
116
  }
218
- }, _callee2);
117
+ }, _callee);
219
118
  }));
220
119
  return function polling() {
221
120
  return _ref2.apply(this, arguments);
@@ -228,22 +127,22 @@ export var Security = /*#__PURE__*/function () {
228
127
  }, tokenCollectTime);
229
128
  case 8:
230
129
  case "end":
231
- return _context3.stop();
130
+ return _context2.stop();
232
131
  }
233
- }, _callee3);
132
+ }, _callee2);
234
133
  }));
235
134
  return function asyncFunc(_x2) {
236
135
  return _ref.apply(this, arguments);
237
136
  };
238
137
  }();
239
- return _context4.abrupt("return", new Promise(function (resolve) {
138
+ return _context3.abrupt("return", new Promise(function (resolve) {
240
139
  asyncFunc(resolve);
241
140
  }));
242
141
  case 4:
243
142
  case "end":
244
- return _context4.stop();
143
+ return _context3.stop();
245
144
  }
246
- }, _callee4);
145
+ }, _callee3);
247
146
  }));
248
147
  function pollingGetApdidToken(_x) {
249
148
  return _pollingGetApdidToken.apply(this, arguments);
@@ -253,37 +152,25 @@ export var Security = /*#__PURE__*/function () {
253
152
  }, {
254
153
  key: "getApdidToken",
255
154
  value: function () {
256
- var _getApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
257
- var _this3 = this;
258
- var loaded;
259
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
260
- while (1) switch (_context5.prev = _context5.next) {
155
+ var _getApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
156
+ var _this2 = this;
157
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
158
+ while (1) switch (_context4.prev = _context4.next) {
261
159
  case 0:
262
- _context5.next = 2;
263
- return this.ensureApdidLoaded();
264
- case 2:
265
- loaded = _context5.sent;
266
- if (loaded) {
267
- _context5.next = 5;
268
- break;
269
- }
270
- return _context5.abrupt("return", '');
271
- case 5:
272
- return _context5.abrupt("return", new Promise(function (resolve) {
160
+ return _context4.abrupt("return", new Promise(function (resolve) {
273
161
  try {
274
- var APDID = _this3.getAPDIDModule();
275
- APDID === null || APDID === void 0 || APDID.getApdidToken(_this3.scene, function (tokenResult) {
162
+ APDID === null || APDID === void 0 || APDID.getApdidToken(_this2.scene, function (tokenResult) {
276
163
  resolve(tokenResult === null || tokenResult === void 0 ? void 0 : tokenResult.token);
277
164
  });
278
165
  } catch (error) {
279
166
  resolve('');
280
167
  }
281
168
  }));
282
- case 6:
169
+ case 1:
283
170
  case "end":
284
- return _context5.stop();
171
+ return _context4.stop();
285
172
  }
286
- }, _callee5, this);
173
+ }, _callee4);
287
174
  }));
288
175
  function getApdidToken() {
289
176
  return _getApdidToken.apply(this, arguments);
@@ -3,13 +3,10 @@ import { Security } from '../../util/security';
3
3
  export default class PreloadHelper {
4
4
  static isWebAppPreloaded: boolean;
5
5
  static isSecuritySDKPreloaded: boolean;
6
+ private static securitySdkMap;
6
7
  static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): void;
7
- /**
8
- * Preload security SDK asynchronously.
9
- * Triggers ApdidLoader.load() for async script loading and registers in SecuritySdkRegistry.
10
- */
11
- static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string, environment?: string): Promise<void>;
12
- static getSecuritySdk(scene: string): Security | undefined;
8
+ static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
9
+ static getSecuritySdk(scene: any): Security;
13
10
  static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string, useV2?: boolean): {
14
11
  preloadUrl: string;
15
12
  containerId: string;