@alipay/ams-checkout 1.6.0 → 1.6.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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +1 -0
- package/esm/config/index.js +8 -0
- package/esm/constant/index.d.ts +3 -0
- package/esm/constant/index.js +3 -0
- package/esm/core/component/index.d.ts +3 -1
- package/esm/core/component/index.js +20 -3
- package/esm/core/instance/index.d.ts +23 -10
- package/esm/core/instance/index.js +136 -57
- package/esm/index.d.ts +9 -7
- package/esm/index.js +41 -1
- package/esm/plugin/component/cashierApp.js +2 -1
- package/esm/plugin/component/index.d.ts +5 -1
- package/esm/plugin/component/index.js +275 -126
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +7 -10
- package/esm/request/utils.js +1 -4
- package/esm/service/index.d.ts +4 -9
- package/esm/service/index.js +61 -2
- package/esm/types/index.d.ts +80 -12
- package/esm/types/index.js +7 -5
- package/esm/util/index.d.ts +6 -21
- package/esm/util/index.js +43 -45
- package/esm/util/security.d.ts +24 -8
- package/esm/util/security.js +165 -112
- package/esm/util/versionCompare.d.ts +10 -0
- package/esm/util/versionCompare.js +50 -0
- package/package.json +1 -1
package/esm/request/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { RequestConfig } from '../types';
|
2
2
|
import { Logger } from '../util/logger';
|
3
3
|
/**
|
4
4
|
*
|
@@ -6,4 +6,4 @@ import { Logger } from '../util/logger';
|
|
6
6
|
* @param options 请求配置
|
7
7
|
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
8
8
|
*/
|
9
|
-
export declare function request<T>(requestData: Record<string, any> | undefined, options:
|
9
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: RequestConfig, logger: Logger): Promise<T>;
|
package/esm/request/index.js
CHANGED
@@ -15,12 +15,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
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
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
|
+
import axios from 'axios';
|
18
19
|
import { sdkVersion } from "../config/index";
|
19
20
|
import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
|
20
21
|
import { errorEnum } from "../types";
|
21
22
|
import { get } from "../util/get";
|
22
|
-
import
|
23
|
-
import {
|
23
|
+
import { device, 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 =
|
92
|
+
_data = [_objectSpread(_objectSpread({}, requestData), {}, {
|
92
93
|
envInfo: envInfo,
|
93
94
|
extParams: {
|
94
95
|
refUrl: window.location.href
|
95
96
|
}
|
96
|
-
})]
|
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,
|
package/esm/request/utils.js
CHANGED
@@ -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
|
// 请求静态数据情况
|
package/esm/service/index.d.ts
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
-
*
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
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
|
-
* 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
|
-
*/
|
1
|
+
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
|
8
2
|
import { Logger } from '../util/logger';
|
9
|
-
|
10
|
-
export declare function
|
3
|
+
export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
|
4
|
+
export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
|
5
|
+
export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
|
package/esm/service/index.js
CHANGED
@@ -14,7 +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
|
-
|
17
|
+
import { marmotConfigMap } from "../config";
|
18
18
|
import { request } from "../request";
|
19
19
|
export function queryPaymentInfo(_x, _x2, _x3) {
|
20
20
|
return _queryPaymentInfo.apply(this, arguments);
|
@@ -28,7 +28,6 @@ function _queryPaymentInfo() {
|
|
28
28
|
hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
|
29
29
|
return _context.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
30
30
|
hostSign: hostSign,
|
31
|
-
needEnvInfo: true,
|
32
31
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
33
32
|
}), logger));
|
34
33
|
case 2:
|
@@ -38,4 +37,64 @@ function _queryPaymentInfo() {
|
|
38
37
|
}, _callee);
|
39
38
|
}));
|
40
39
|
return _queryPaymentInfo.apply(this, arguments);
|
40
|
+
}
|
41
|
+
export function antomConfig(_x4, _x5) {
|
42
|
+
return _antomConfig.apply(this, arguments);
|
43
|
+
}
|
44
|
+
function _antomConfig() {
|
45
|
+
_antomConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, logger) {
|
46
|
+
var res, json;
|
47
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
48
|
+
while (1) switch (_context2.prev = _context2.next) {
|
49
|
+
case 0:
|
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:
|
71
|
+
case "end":
|
72
|
+
return _context2.stop();
|
73
|
+
}
|
74
|
+
}, _callee2, null, [[0, 11]]);
|
75
|
+
}));
|
76
|
+
return _antomConfig.apply(this, arguments);
|
77
|
+
}
|
78
|
+
export function submitPayInfo(_x6, _x7, _x8) {
|
79
|
+
return _submitPayInfo.apply(this, arguments);
|
80
|
+
}
|
81
|
+
function _submitPayInfo() {
|
82
|
+
_submitPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params, options, logger) {
|
83
|
+
var hostSign;
|
84
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
85
|
+
while (1) switch (_context3.prev = _context3.next) {
|
86
|
+
case 0:
|
87
|
+
hostSign = ((params === null || params === void 0 ? void 0 : params.paymentSessionData) || '').split('&&')[1] || '';
|
88
|
+
return _context3.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
89
|
+
hostSign: hostSign,
|
90
|
+
needEnvInfo: true,
|
91
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
92
|
+
}), logger));
|
93
|
+
case 2:
|
94
|
+
case "end":
|
95
|
+
return _context3.stop();
|
96
|
+
}
|
97
|
+
}, _callee3);
|
98
|
+
}));
|
99
|
+
return _submitPayInfo.apply(this, arguments);
|
41
100
|
}
|
package/esm/types/index.d.ts
CHANGED
@@ -22,7 +22,7 @@ export interface IoptionsParams {
|
|
22
22
|
analytics?: {
|
23
23
|
enabled: boolean;
|
24
24
|
};
|
25
|
-
|
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,6 +120,7 @@ export interface IpaymentSessionMetaData {
|
|
104
120
|
paymentMethodInfoView?: any;
|
105
121
|
action?: {
|
106
122
|
autoDebitWithToken: boolean;
|
123
|
+
skipSdkQuery: boolean;
|
107
124
|
};
|
108
125
|
}
|
109
126
|
export declare enum localeEnum {
|
@@ -216,6 +233,7 @@ export interface AMSCheckoutOptions {
|
|
216
233
|
networkMode: string;
|
217
234
|
mode: string;
|
218
235
|
analytics?: Ianalytics;
|
236
|
+
product: string;
|
219
237
|
}
|
220
238
|
export interface Ianalytics {
|
221
239
|
enabled: boolean;
|
@@ -239,7 +257,7 @@ export declare enum errorEnum {
|
|
239
257
|
SIGNIN = "SIGNIN",
|
240
258
|
GETSIGNPARAMSERROR = "GETSIGNPARAMSERROR"
|
241
259
|
}
|
242
|
-
export interface
|
260
|
+
export interface RequestConfig {
|
243
261
|
env?: string;
|
244
262
|
baseURL?: string;
|
245
263
|
timeout?: number;
|
@@ -251,8 +269,11 @@ export interface IrequestConfig {
|
|
251
269
|
beforerRequest?: () => void;
|
252
270
|
afterRequest?: () => void;
|
253
271
|
needEnvInfo?: boolean;
|
254
|
-
locale?: string;
|
255
272
|
hostSign?: string;
|
273
|
+
appId?: string;
|
274
|
+
sandbox?: boolean;
|
275
|
+
deviceId?: string;
|
276
|
+
locale?: string;
|
256
277
|
envInfo?: Record<string, any>;
|
257
278
|
}
|
258
279
|
export interface CashierSdkActionQueryRequest {
|
@@ -262,6 +283,29 @@ export interface CashierSdkActionQueryRequest {
|
|
262
283
|
notRedirectAfterComplete?: boolean;
|
263
284
|
extParams?: any;
|
264
285
|
}
|
286
|
+
export interface CashierSubmitPayRequest {
|
287
|
+
/**
|
288
|
+
* @description payment method type
|
289
|
+
*/
|
290
|
+
paymentMethodType?: string;
|
291
|
+
/**
|
292
|
+
* @description payment factors
|
293
|
+
*/
|
294
|
+
paymentFactors?: Record<string, string>;
|
295
|
+
/**
|
296
|
+
* @description 需要验证的场景
|
297
|
+
*/
|
298
|
+
verifyFactors?: Record<string, string>;
|
299
|
+
paymentSessionData: string;
|
300
|
+
paymentSessionConfig?: any;
|
301
|
+
}
|
302
|
+
export interface CashierSubmitPayRequest {
|
303
|
+
paymentMethodType?: string;
|
304
|
+
paymentFactors?: Record<string, string>;
|
305
|
+
verifyFactors?: Record<string, string>;
|
306
|
+
paymentSessionData: string;
|
307
|
+
paymentSessionConfig?: any;
|
308
|
+
}
|
265
309
|
export interface CashierSdkActionQueryResult {
|
266
310
|
supportedLanguages?: any[];
|
267
311
|
amountConfirmRequired?: boolean;
|
@@ -279,6 +323,30 @@ export interface CashierSdkActionQueryResult {
|
|
279
323
|
schemeUrl?: string;
|
280
324
|
authUrl?: string;
|
281
325
|
}
|
326
|
+
export declare enum redirectTypeEnum {
|
327
|
+
UNSAFE_BROWSER = "UNSAFE_BROWSER",
|
328
|
+
SAFETY_BROWSER = "SAFETY_BROWSER",
|
329
|
+
INVOKE_SDK = "INVOKE_SDK"
|
330
|
+
}
|
331
|
+
export interface ActionForm {
|
332
|
+
parameters: any;
|
333
|
+
redirectUrl: any;
|
334
|
+
elementValue?: string;
|
335
|
+
redirectType?: redirectTypeEnum;
|
336
|
+
}
|
337
|
+
export interface CashierSubmitPayResult {
|
338
|
+
success: boolean;
|
339
|
+
resultCode?: string;
|
340
|
+
resultMessage?: string;
|
341
|
+
errorActions?: Record<string, string>;
|
342
|
+
errorCode?: string;
|
343
|
+
errorMessage?: string;
|
344
|
+
extendInfo?: Record<string, string>;
|
345
|
+
actionForm?: ActionForm;
|
346
|
+
normalUrl?: string;
|
347
|
+
errorStatus?: string;
|
348
|
+
message?: string;
|
349
|
+
}
|
282
350
|
export declare enum eventCodeEnum {
|
283
351
|
SDK_START_OF_LOADING = "SDK_START_OF_LOADING",
|
284
352
|
SDK_END_OF_LOADING = "SDK_END_OF_LOADING",
|
@@ -296,14 +364,6 @@ export interface ThreedData {
|
|
296
364
|
pti?: number;
|
297
365
|
pt?: number;
|
298
366
|
}
|
299
|
-
export declare enum SecuritySceneEnum {
|
300
|
-
CARD = "CARD",
|
301
|
-
EASYPAY = "EASYPAY"
|
302
|
-
}
|
303
|
-
export interface IsecurityConfig {
|
304
|
-
scene: string;
|
305
|
-
region: string;
|
306
|
-
}
|
307
367
|
export declare enum RedirectType {
|
308
368
|
ApplinkUrl = "ApplinkUrl",
|
309
369
|
SchemeUrl = "SchemeUrl",
|
@@ -315,4 +375,12 @@ declare global {
|
|
315
375
|
[key: string]: any;
|
316
376
|
}
|
317
377
|
}
|
378
|
+
export interface CallbackEventInfo {
|
379
|
+
enableCallback: boolean;
|
380
|
+
eventName: string;
|
381
|
+
eventResult?: any;
|
382
|
+
}
|
383
|
+
export interface MultipleCallbackEvents {
|
384
|
+
[key: string]: CallbackEventInfo;
|
385
|
+
}
|
318
386
|
export {};
|
package/esm/types/index.js
CHANGED
@@ -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,6 +125,12 @@ export var errorEnum = /*#__PURE__*/function (errorEnum) {
|
|
124
125
|
errorEnum["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
|
125
126
|
return errorEnum;
|
126
127
|
}({});
|
128
|
+
export var redirectTypeEnum = /*#__PURE__*/function (redirectTypeEnum) {
|
129
|
+
redirectTypeEnum["UNSAFE_BROWSER"] = "UNSAFE_BROWSER";
|
130
|
+
redirectTypeEnum["SAFETY_BROWSER"] = "SAFETY_BROWSER";
|
131
|
+
redirectTypeEnum["INVOKE_SDK"] = "INVOKE_SDK";
|
132
|
+
return redirectTypeEnum;
|
133
|
+
}({}); // 拉SDK
|
127
134
|
export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
|
128
135
|
eventCodeEnum["SDK_START_OF_LOADING"] = "SDK_START_OF_LOADING";
|
129
136
|
eventCodeEnum["SDK_END_OF_LOADING"] = "SDK_END_OF_LOADING";
|
@@ -135,11 +142,6 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
|
|
135
142
|
eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
|
136
143
|
return eventCodeEnum;
|
137
144
|
}({});
|
138
|
-
export var SecuritySceneEnum = /*#__PURE__*/function (SecuritySceneEnum) {
|
139
|
-
SecuritySceneEnum["CARD"] = "CARD";
|
140
|
-
SecuritySceneEnum["EASYPAY"] = "EASYPAY";
|
141
|
-
return SecuritySceneEnum;
|
142
|
-
}({});
|
143
145
|
export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
144
146
|
RedirectType["ApplinkUrl"] = "ApplinkUrl";
|
145
147
|
RedirectType["SchemeUrl"] = "SchemeUrl";
|
package/esm/util/index.d.ts
CHANGED
@@ -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
|
-
|
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
|
-
|
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,45 @@ var addSetFontSizeEvent = function addSetFontSizeEvent() {
|
|
248
205
|
window.addEventListener('pageShow', amsSetSize);
|
249
206
|
window.addEventListener('DOMContentLoaded', amsSetSize);
|
250
207
|
};
|
251
|
-
|
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
|
+
var key = 'antomSDKConfiglastCallTime';
|
229
|
+
var currentTime = new Date().getTime();
|
230
|
+
try {
|
231
|
+
var lastCallTime = localStorage.getItem(key);
|
232
|
+
if (lastCallTime) {
|
233
|
+
var elapsedTime = currentTime - parseInt(lastCallTime);
|
234
|
+
if (elapsedTime >= 10 * 60 * 1000) {
|
235
|
+
// 记录当前调用时间
|
236
|
+
localStorage.setItem(key, currentTime.toString());
|
237
|
+
// 超过10分钟
|
238
|
+
return true;
|
239
|
+
}
|
240
|
+
return false;
|
241
|
+
}
|
242
|
+
} catch (error) {
|
243
|
+
/* empty */
|
244
|
+
}
|
245
|
+
// 记录当前调用时间
|
246
|
+
localStorage.setItem(key, currentTime.toString());
|
247
|
+
return true;
|
248
|
+
};
|
249
|
+
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed };
|
package/esm/util/security.d.ts
CHANGED
@@ -1,15 +1,31 @@
|
|
1
|
-
import
|
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
|
8
|
-
|
9
|
-
|
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
|
13
|
-
export declare const
|
14
|
-
export declare
|
15
|
-
|
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
|
+
}
|