@alipay/ams-checkout 0.0.1699585541-dev.8 → 0.0.1699863258-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.
@@ -19,8 +19,9 @@ import axios from 'axios';
19
19
  import { sdkVersion } from "../config/index";
20
20
  import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
21
21
  import { errorEnum } from "../types";
22
+ import { device, isPC, queryParse, safeJson } from "../util";
22
23
  import { get } from "../util/get";
23
- import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
24
+ import { fomatGetwayError } from "./utils";
24
25
  var _queryParse = queryParse(),
25
26
  _sandbox = _queryParse._sandbox;
26
27
  function requestInstance(options) {
@@ -47,7 +48,7 @@ function requestInstance(options) {
47
48
  timeout: (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : 15000,
48
49
  headers: _headers,
49
50
  withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
50
- method: 'POST'
51
+ method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
51
52
  });
52
53
  return instance.request;
53
54
  }
@@ -88,12 +89,12 @@ function _request() {
88
89
  // eslint-disable-next-line no-empty
89
90
  } catch (error) {}
90
91
  if (envInfo.terminalType === 'WAP') envInfo.osType = device.iOS ? 'IOS' : 'ANDROID';
91
- _data = options.needEnvInfo ? [_objectSpread(_objectSpread({}, requestData), {}, {
92
+ _data = [_objectSpread(_objectSpread({}, requestData), {}, {
92
93
  envInfo: envInfo,
93
94
  extParams: {
94
95
  refUrl: window.location.href
95
96
  }
96
- })] : [requestData];
97
+ })];
97
98
  startTime = Date.now();
98
99
  _context.prev = 5;
99
100
  myRequest = requestInstance(options);
@@ -123,8 +124,6 @@ function _request() {
123
124
  code: errorCode,
124
125
  msg: errorMessage,
125
126
  traceId: traceId
126
- }, {
127
- // TODO Concerned input data
128
127
  }).send();
129
128
  throw new Error(JSON.stringify({
130
129
  errorMessage: errorMessage,
@@ -158,9 +157,7 @@ function _request() {
158
157
  time: Date.now() - startTime,
159
158
  success: false,
160
159
  code: _errorCode,
161
- msg: _error === null || _error === void 0 ? void 0 : _error.message
162
- }, {
163
- // TODO Concerned input data
160
+ msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
164
161
  }).send();
165
162
  return _context.abrupt("return", Promise.reject({
166
163
  success: false,
@@ -5,11 +5,9 @@
5
5
  * 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
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
+ /* eslint-disable @typescript-eslint/no-explicit-any */
9
9
  import { errorEnum } from "../types";
10
10
  import { get } from "../util/get";
11
-
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
11
  export var safeJson = function safeJson(data, obj) {
14
12
  try {
15
13
  return JSON.parse(data) || obj;
@@ -19,7 +17,6 @@ export var safeJson = function safeJson(data, obj) {
19
17
  };
20
18
 
21
19
  // 判断header 中的resultStatus
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
20
  export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
24
21
  var resultStatus = get(headers, 'Result-Status') || get(headers, 'result-status', '');
25
22
  // 请求静态数据情况
@@ -1,4 +1,4 @@
1
- import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
1
+ import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, IrequestConfig } from '../types';
2
2
  import { Logger } from '../util/logger';
3
- export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
4
- export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
3
+ export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: IrequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
4
+ export declare function antomConfig(options: IrequestConfig, logger: Logger): Promise<any>;
@@ -14,6 +14,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
14
14
  * 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
15
15
  * 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.
16
16
  */
17
+ import { marmotConfigMap } from "../config";
17
18
  import { request } from "../request";
18
19
  export function queryPaymentInfo(_x, _x2, _x3) {
19
20
  return _queryPaymentInfo.apply(this, arguments);
@@ -27,7 +28,6 @@ function _queryPaymentInfo() {
27
28
  hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
28
29
  return _context.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
29
30
  hostSign: hostSign,
30
- needEnvInfo: true,
31
31
  'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
32
32
  }), logger));
33
33
  case 2:
@@ -38,26 +38,40 @@ function _queryPaymentInfo() {
38
38
  }));
39
39
  return _queryPaymentInfo.apply(this, arguments);
40
40
  }
41
- export function submitPayInfo(_x4, _x5, _x6) {
42
- return _submitPayInfo.apply(this, arguments);
41
+ export function antomConfig(_x4, _x5) {
42
+ return _antomConfig.apply(this, arguments);
43
43
  }
44
- function _submitPayInfo() {
45
- _submitPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params, options, logger) {
46
- var hostSign;
44
+ function _antomConfig() {
45
+ _antomConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, logger) {
46
+ var res, json;
47
47
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
48
48
  while (1) switch (_context2.prev = _context2.next) {
49
49
  case 0:
50
- hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
51
- return _context2.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
52
- hostSign: hostSign,
53
- needEnvInfo: true,
54
- 'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
55
- }), logger));
56
- case 2:
50
+ _context2.prev = 0;
51
+ _context2.next = 3;
52
+ return fetch(marmotConfigMap[options.env]);
53
+ case 3:
54
+ res = _context2.sent;
55
+ _context2.next = 6;
56
+ return res.json();
57
+ case 6:
58
+ json = _context2.sent;
59
+ logger.logInfo({
60
+ title: 'Successfully obtained marmot emergency configuration'
61
+ });
62
+ return _context2.abrupt("return", json);
63
+ case 11:
64
+ _context2.prev = 11;
65
+ _context2.t0 = _context2["catch"](0);
66
+ logger.logError({
67
+ title: 'Abnormal acquisition of marmot emergency configuration'
68
+ });
69
+ return _context2.abrupt("return", '{}');
70
+ case 15:
57
71
  case "end":
58
72
  return _context2.stop();
59
73
  }
60
- }, _callee2);
74
+ }, _callee2, null, [[0, 11]]);
61
75
  }));
62
- return _submitPayInfo.apply(this, arguments);
76
+ return _antomConfig.apply(this, arguments);
63
77
  }
@@ -22,7 +22,7 @@ export interface IoptionsParams {
22
22
  analytics?: {
23
23
  enabled: boolean;
24
24
  };
25
- securityConfig?: IsecurityConfig;
25
+ product?: string;
26
26
  }
27
27
  export type Iselector = string;
28
28
  export declare enum renderDisplayTypeEnum {
@@ -50,13 +50,21 @@ export declare enum productSceneEnum {
50
50
  'EASY_PAY' = "EASY_PAY",
51
51
  'CASHIER_PAYMENT' = "CASHIER_PAYMENT",
52
52
  'AUTO_DEBIT' = "AUTO_DEBIT",
53
- 'VAULTING' = "VAULTING"
53
+ 'VAULTING' = "VAULTING",
54
+ 'FLASH_BUY' = "FLASH_BUY"
54
55
  }
55
56
  export declare enum paymentMethodCategoryTypeEnum {
56
57
  'CARD' = "CARD",
57
58
  'WALLET' = "WALLET",
58
59
  'BANK' = "BANK"
59
60
  }
61
+ export interface DeviceIdParameter {
62
+ scene?: string;
63
+ productScene?: productSceneEnum;
64
+ paymentMethodCategoryType?: paymentMethodCategoryTypeEnum;
65
+ tokenCollectTime?: string;
66
+ dataPollingInterval?: string;
67
+ }
60
68
  export interface IcreateComponent {
61
69
  sessionData: string;
62
70
  paymentSessionData?: string;
@@ -94,6 +102,14 @@ export interface IpaymentSecurityConfig {
94
102
  dataPollingInterval?: string;
95
103
  workSpaceId: string;
96
104
  }
105
+ export interface IsecurityConfig {
106
+ scene: string;
107
+ h5gateway: string;
108
+ }
109
+ export interface InitSecurityConfig {
110
+ product: productSceneEnum;
111
+ region?: string;
112
+ }
97
113
  export interface IpaymentSessionMetaData {
98
114
  clientId?: string;
99
115
  renderDisplayType?: string;
@@ -104,7 +120,6 @@ export interface IpaymentSessionMetaData {
104
120
  paymentMethodInfoView?: any;
105
121
  action?: {
106
122
  autoDebitWithToken: boolean;
107
- skipSdkQuery: boolean;
108
123
  };
109
124
  }
110
125
  export declare enum localeEnum {
@@ -217,6 +232,7 @@ export interface AMSCheckoutOptions {
217
232
  networkMode: string;
218
233
  mode: string;
219
234
  analytics?: Ianalytics;
235
+ product: string;
220
236
  }
221
237
  export interface Ianalytics {
222
238
  enabled: boolean;
@@ -240,7 +256,7 @@ export declare enum errorEnum {
240
256
  SIGNIN = "SIGNIN",
241
257
  GETSIGNPARAMSERROR = "GETSIGNPARAMSERROR"
242
258
  }
243
- export interface RequestConfig {
259
+ export interface IrequestConfig {
244
260
  env?: string;
245
261
  baseURL?: string;
246
262
  timeout?: number;
@@ -252,11 +268,8 @@ export interface RequestConfig {
252
268
  beforerRequest?: () => void;
253
269
  afterRequest?: () => void;
254
270
  needEnvInfo?: boolean;
255
- hostSign?: string;
256
- appId?: string;
257
- sandbox?: boolean;
258
- deviceId?: string;
259
271
  locale?: string;
272
+ hostSign?: string;
260
273
  envInfo?: Record<string, any>;
261
274
  }
262
275
  export interface CashierSdkActionQueryRequest {
@@ -266,29 +279,6 @@ export interface CashierSdkActionQueryRequest {
266
279
  notRedirectAfterComplete?: boolean;
267
280
  extParams?: any;
268
281
  }
269
- export interface CashierSubmitPayRequest {
270
- /**
271
- * @description payment method type
272
- */
273
- paymentMethodType?: string;
274
- /**
275
- * @description payment factors
276
- */
277
- paymentFactors?: Record<string, string>;
278
- /**
279
- * @description 需要验证的场景
280
- */
281
- verifyFactors?: Record<string, string>;
282
- paymentSessionData: string;
283
- paymentSessionConfig?: any;
284
- }
285
- export interface CashierSubmitPayRequest {
286
- paymentMethodType?: string;
287
- paymentFactors?: Record<string, string>;
288
- verifyFactors?: Record<string, string>;
289
- paymentSessionData: string;
290
- paymentSessionConfig?: any;
291
- }
292
282
  export interface CashierSdkActionQueryResult {
293
283
  supportedLanguages?: any[];
294
284
  amountConfirmRequired?: boolean;
@@ -306,30 +296,6 @@ export interface CashierSdkActionQueryResult {
306
296
  schemeUrl?: string;
307
297
  authUrl?: string;
308
298
  }
309
- export declare enum redirectTypeEnum {
310
- UNSAFE_BROWSER = "UNSAFE_BROWSER",
311
- SAFETY_BROWSER = "SAFETY_BROWSER",
312
- INVOKE_SDK = "INVOKE_SDK"
313
- }
314
- export interface ActionForm {
315
- parameters: any;
316
- redirectUrl: any;
317
- elementValue?: string;
318
- redirectType?: redirectTypeEnum;
319
- }
320
- export interface CashierSubmitPayResult {
321
- success: boolean;
322
- resultCode?: string;
323
- resultMessage?: string;
324
- errorActions?: Record<string, string>;
325
- errorCode?: string;
326
- errorMessage?: string;
327
- extendInfo?: Record<string, string>;
328
- actionForm?: ActionForm;
329
- normalUrl?: string;
330
- errorStatus?: string;
331
- message?: string;
332
- }
333
299
  export declare enum eventCodeEnum {
334
300
  SDK_START_OF_LOADING = "SDK_START_OF_LOADING",
335
301
  SDK_END_OF_LOADING = "SDK_END_OF_LOADING",
@@ -347,14 +313,6 @@ export interface ThreedData {
347
313
  pti?: number;
348
314
  pt?: number;
349
315
  }
350
- export declare enum SecuritySceneEnum {
351
- CARD = "CARD",
352
- EASYPAY = "EASYPAY"
353
- }
354
- export interface IsecurityConfig {
355
- scene: string;
356
- region: string;
357
- }
358
316
  export declare enum RedirectType {
359
317
  ApplinkUrl = "ApplinkUrl",
360
318
  SchemeUrl = "SchemeUrl",
@@ -29,6 +29,7 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
29
29
  productSceneEnum["CASHIER_PAYMENT"] = "CASHIER_PAYMENT";
30
30
  productSceneEnum["AUTO_DEBIT"] = "AUTO_DEBIT";
31
31
  productSceneEnum["VAULTING"] = "VAULTING";
32
+ productSceneEnum["FLASH_BUY"] = "FLASH_BUY";
32
33
  return productSceneEnum;
33
34
  }({});
34
35
  export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
@@ -124,12 +125,6 @@ export var errorEnum = /*#__PURE__*/function (errorEnum) {
124
125
  errorEnum["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
125
126
  return errorEnum;
126
127
  }({});
127
- export var redirectTypeEnum = /*#__PURE__*/function (redirectTypeEnum) {
128
- redirectTypeEnum["UNSAFE_BROWSER"] = "UNSAFE_BROWSER";
129
- redirectTypeEnum["SAFETY_BROWSER"] = "SAFETY_BROWSER";
130
- redirectTypeEnum["INVOKE_SDK"] = "INVOKE_SDK";
131
- return redirectTypeEnum;
132
- }({}); // 拉SDK
133
128
  export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
134
129
  eventCodeEnum["SDK_START_OF_LOADING"] = "SDK_START_OF_LOADING";
135
130
  eventCodeEnum["SDK_END_OF_LOADING"] = "SDK_END_OF_LOADING";
@@ -141,11 +136,6 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
141
136
  eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
142
137
  return eventCodeEnum;
143
138
  }({});
144
- export var SecuritySceneEnum = /*#__PURE__*/function (SecuritySceneEnum) {
145
- SecuritySceneEnum["CARD"] = "CARD";
146
- SecuritySceneEnum["EASYPAY"] = "EASYPAY";
147
- return SecuritySceneEnum;
148
- }({});
149
139
  export var RedirectType = /*#__PURE__*/function (RedirectType) {
150
140
  RedirectType["ApplinkUrl"] = "ApplinkUrl";
151
141
  RedirectType["SchemeUrl"] = "SchemeUrl";
@@ -4,7 +4,6 @@
4
4
  * 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
5
5
  * 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.
6
6
  */
7
- import { errorEnum } from '../types';
8
7
  declare const getType: (target: any) => string;
9
8
  declare class EventCenter {
10
9
  private events;
@@ -28,28 +27,14 @@ declare const device: {
28
27
  isMobile: boolean;
29
28
  };
30
29
  declare const safeJson: (data: any, obj: any) => any;
31
- declare const fomatGetwayError: (headers: Record<string, any>, traceId: string) => {
32
- success: boolean;
33
- traceId: string;
34
- errorCode: errorEnum;
35
- resultStatus: any;
36
- errorMessage?: undefined;
37
- result?: undefined;
38
- } | {
39
- success: boolean;
40
- traceId: string;
41
- errorCode: errorEnum;
42
- errorMessage: string;
43
- result: {
44
- resultStatus: any;
45
- tips: string;
46
- memo: string;
47
- };
48
- resultStatus: any;
49
- };
50
30
  declare const isPC: () => boolean;
51
31
  declare const queryParse: (url?: string) => Record<string, any>;
52
32
  declare const getDesignFontSize: () => number;
53
33
  declare const amsSetSize: (event?: any, dom?: any) => void;
54
34
  declare const addSetFontSizeEvent: () => void;
55
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };
35
+ /**
36
+ * @description get or set STORAGE
37
+ */
38
+ declare const getOrSetStorageId: (key: string, value?: string) => string;
39
+ declare const checkTimeElapsed: () => boolean;
40
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, };
package/esm/util/index.js CHANGED
@@ -12,8 +12,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
12
12
  * 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.
13
13
  */
14
14
  /* eslint-disable @typescript-eslint/no-explicit-any */
15
- import { errorEnum } from "../types";
16
- import { get } from "./get";
15
+
17
16
  var getType = function getType(target) {
18
17
  return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
19
18
  };
@@ -160,48 +159,6 @@ var safeJson = function safeJson(data, obj) {
160
159
  return obj;
161
160
  }
162
161
  };
163
-
164
- // 判断header 中的resultStatus
165
- var fomatGetwayError = function fomatGetwayError(headers, traceId) {
166
- var resultStatus = get(headers, 'Result-Status') || get(headers, 'result-status', '');
167
- // 请求静态数据情况
168
- if (!resultStatus) return null;
169
- // 未登录
170
- if (+resultStatus === 2000) {
171
- return {
172
- success: false,
173
- traceId: traceId,
174
- errorCode: errorEnum.LOGIN,
175
- resultStatus: resultStatus
176
- };
177
- }
178
- // 网关超时
179
- if (+resultStatus === 4001) {
180
- return {
181
- success: false,
182
- traceId: traceId,
183
- errorCode: errorEnum.TIMEOUT,
184
- resultStatus: resultStatus
185
- };
186
- }
187
- if (+resultStatus !== 1000) {
188
- var tips = get(headers, 'Tips') || get(headers, 'tips', '');
189
- var memo = get(headers, 'Memo') || get(headers, 'memo', '');
190
- return {
191
- success: false,
192
- traceId: traceId,
193
- errorCode: errorEnum.GATEWAY,
194
- errorMessage: decodeURIComponent(tips || ''),
195
- result: {
196
- resultStatus: resultStatus || '',
197
- tips: decodeURIComponent(tips || ''),
198
- memo: decodeURIComponent(memo || '')
199
- },
200
- resultStatus: resultStatus
201
- };
202
- }
203
- return null;
204
- };
205
162
  var isPC = function isPC() {
206
163
  var userAgentInfo = navigator.userAgent;
207
164
  var agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPod'];
@@ -248,4 +205,40 @@ var addSetFontSizeEvent = function addSetFontSizeEvent() {
248
205
  window.addEventListener('pageShow', amsSetSize);
249
206
  window.addEventListener('DOMContentLoaded', amsSetSize);
250
207
  };
251
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };
208
+
209
+ /**
210
+ * @description get or set STORAGE
211
+ */
212
+ var getOrSetStorageId = function getOrSetStorageId(key, value) {
213
+ try {
214
+ if (key && !value) {
215
+ var storageValue = window.localStorage.getItem(key);
216
+ if (storageValue) {
217
+ return storageValue;
218
+ } else return '';
219
+ }
220
+ if (key && value) {
221
+ window.localStorage.setItem(key, value);
222
+ }
223
+ } catch (error) {
224
+ return '';
225
+ }
226
+ };
227
+ var checkTimeElapsed = function checkTimeElapsed() {
228
+ try {
229
+ var key = 'antomSDKConfiglastCallTime';
230
+ var currentTime = new Date().getTime();
231
+ var lastCallTime = localStorage.getItem(key);
232
+ if (lastCallTime) {
233
+ var elapsedTime = currentTime - parseInt(lastCallTime);
234
+ if (elapsedTime >= 10 * 60 * 1000) {
235
+ // 超过10分钟
236
+ return true;
237
+ } else return false;
238
+ }
239
+ // 记录当前调用时间
240
+ localStorage.setItem(key, currentTime.toString());
241
+ } catch (error) {/* empty */}
242
+ return true;
243
+ };
244
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed };
@@ -1,15 +1,31 @@
1
- import type { IpaymentSecurityConfig, IsecurityConfig } from '../types';
1
+ import { IsecurityConfig, productSceneEnum, DeviceIdParameter } from '../types';
2
+ export declare const getSecurityConfigStorageKey: (scene: productSceneEnum) => string;
3
+ export declare enum SecurityRegionEnum {
4
+ SG = "SG",
5
+ US = "US",
6
+ DE = "DE"
7
+ }
2
8
  export declare const securityHost: {
3
9
  SG: string;
4
10
  US: string;
5
11
  DE: string;
6
12
  };
7
- export declare const getSecurityHost: (region: string) => string;
8
- export declare const appName: {
9
- CARD: string;
13
+ export declare const sceneMap: {
14
+ CASHIER_PAYMENT: string;
15
+ AUTO_DEBIT: string;
16
+ VAULTING: string;
10
17
  EASYPAY: string;
18
+ EASY_PAY: string;
19
+ FLASH_BUY: string;
11
20
  };
12
- export declare const initAPSecurity: (securityConfig: IsecurityConfig, successCallback: any, failCallback: any) => void;
13
- export declare const initSecuritySDK: (appName: string, h5gateway: string, successCallback: () => void, failCallback: (errMsg?: string) => void) => void;
14
- export declare const getAppname: (scene: string) => string;
15
- export declare const getApdidToken: (scene: string, securityConfig?: IpaymentSecurityConfig) => Promise<string>;
21
+ export declare const getSecurityHost: (region: string) => string;
22
+ export declare const getSecurityScene: (product: string) => string;
23
+ export declare class Security {
24
+ scene: string;
25
+ h5gateway: string;
26
+ constructor(options: IsecurityConfig);
27
+ initSecurity(successCallback: any, failCallback: any): void;
28
+ private initToken;
29
+ pollingGetApdidToken(config?: DeviceIdParameter): Promise<string>;
30
+ getApdidToken(): Promise<string>;
31
+ }