@alipay/ams-checkout 0.0.1697942541-dev.9 → 0.0.1698676929-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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/plugin/component/index.js +21 -14
- package/esm/types/index.d.ts +6 -0
- package/esm/types/index.js +7 -0
- package/esm/util/security.js +15 -11
- package/package.json +1 -1
@@ -19,7 +19,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
19
19
|
import { marmotMap } from "../../config/index";
|
20
20
|
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";
|
21
21
|
import { queryPaymentInfo } from "../../service";
|
22
|
-
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, SecuritySceneEnum, targetEnum } from "../../types";
|
22
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, SecuritySceneEnum, targetEnum, RedirectType } from "../../types";
|
23
23
|
import { getType, isJsonString, isPC } from "../../util";
|
24
24
|
import { isLocalMock } from "../../util/mock";
|
25
25
|
import { getApdidToken, getAppname, getSecurityHost, initSecuritySDK } from "../../util/security";
|
@@ -746,7 +746,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
746
746
|
normalUrl: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
|
747
747
|
target: data === null || data === void 0 ? void 0 : data.target
|
748
748
|
};
|
749
|
-
|
749
|
+
this.AMSSDK.logger.logInfo({
|
750
|
+
title: 'sdk_event_call_url_start'
|
751
|
+
}, {
|
752
|
+
redirectInfo: JSON.stringify(_data)
|
753
|
+
}).send();
|
750
754
|
var successCallback = function successCallback(type, url) {
|
751
755
|
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
752
756
|
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
@@ -755,13 +759,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
755
759
|
_this6.AMSSDK.logger.logInfo({
|
756
760
|
title: 'sdk_event_call_url_success'
|
757
761
|
}, {
|
758
|
-
redirectInfo: JSON.stringify(
|
759
|
-
|
760
|
-
|
761
|
-
})
|
762
|
+
redirectInfo: JSON.stringify(_data),
|
763
|
+
openType: type,
|
764
|
+
url: url
|
762
765
|
}).send();
|
763
766
|
};
|
764
|
-
var failCallback = function failCallback() {
|
767
|
+
var failCallback = function failCallback(type, url) {
|
765
768
|
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
766
769
|
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
767
770
|
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)
|
@@ -769,14 +772,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
769
772
|
_this6.AMSSDK.logger.logInfo({
|
770
773
|
title: 'sdk_error_call_url_failed'
|
771
774
|
}, {
|
772
|
-
redirectInfo: JSON.stringify(_data)
|
775
|
+
redirectInfo: JSON.stringify(_data),
|
776
|
+
openType: type,
|
777
|
+
url: url
|
773
778
|
}).send();
|
774
779
|
};
|
775
780
|
|
776
781
|
// 支持 target: _blank,新开tab页打开
|
777
782
|
if (_data.target === targetEnum.BLANK) {
|
778
|
-
if (!_data.normalUrl) return failCallback();
|
779
|
-
successCallback(
|
783
|
+
if (!_data.normalUrl) return failCallback(RedirectType.NormalUrl, '');
|
784
|
+
successCallback(RedirectType.NormalUrl, _data.normalUrl);
|
780
785
|
window.open(_data.normalUrl);
|
781
786
|
return;
|
782
787
|
}
|
@@ -784,21 +789,23 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
784
789
|
this.AMSSDK._redirect({
|
785
790
|
applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
|
786
791
|
}).then(function () {
|
787
|
-
successCallback(
|
792
|
+
successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
788
793
|
}).catch(function () {
|
794
|
+
failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
789
795
|
return _this6.AMSSDK._redirect({
|
790
796
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
791
797
|
});
|
792
798
|
}).then(function () {
|
793
|
-
successCallback(
|
799
|
+
successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
794
800
|
}).catch(function () {
|
801
|
+
failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
795
802
|
return _this6.AMSSDK._redirect({
|
796
803
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
797
804
|
});
|
798
805
|
}).then(function () {
|
799
|
-
successCallback(
|
806
|
+
successCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
|
800
807
|
}).catch(function () {
|
801
|
-
failCallback();
|
808
|
+
failCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
|
802
809
|
});
|
803
810
|
}
|
804
811
|
}, {
|
package/esm/types/index.d.ts
CHANGED
@@ -304,6 +304,12 @@ export interface IsecurityConfig {
|
|
304
304
|
scene: string;
|
305
305
|
region: string;
|
306
306
|
}
|
307
|
+
export declare enum RedirectType {
|
308
|
+
ApplinkUrl = "ApplinkUrl",
|
309
|
+
SchemeUrl = "SchemeUrl",
|
310
|
+
NormalUrl = "NormalUrl",
|
311
|
+
Unknown = "Unknown"
|
312
|
+
}
|
307
313
|
declare global {
|
308
314
|
interface Window {
|
309
315
|
[key: string]: any;
|
package/esm/types/index.js
CHANGED
@@ -139,4 +139,11 @@ export var SecuritySceneEnum = /*#__PURE__*/function (SecuritySceneEnum) {
|
|
139
139
|
SecuritySceneEnum["CARD"] = "CARD";
|
140
140
|
SecuritySceneEnum["EASYPAY"] = "EASYPAY";
|
141
141
|
return SecuritySceneEnum;
|
142
|
+
}({});
|
143
|
+
export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
144
|
+
RedirectType["ApplinkUrl"] = "ApplinkUrl";
|
145
|
+
RedirectType["SchemeUrl"] = "SchemeUrl";
|
146
|
+
RedirectType["NormalUrl"] = "NormalUrl";
|
147
|
+
RedirectType["Unknown"] = "Unknown";
|
148
|
+
return RedirectType;
|
142
149
|
}({});
|
package/esm/util/security.js
CHANGED
@@ -27,16 +27,20 @@ export var initAPSecurity = function initAPSecurity(securityConfig, successCallb
|
|
27
27
|
initSecuritySDK(curAppName, h5gateway, successCallback, failCallback);
|
28
28
|
};
|
29
29
|
export var initSecuritySDK = function initSecuritySDK(appName, h5gateway, successCallback, failCallback) {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
try {
|
31
|
+
APDID === null || APDID === void 0 || APDID.initToken(appName, {
|
32
|
+
host: h5gateway
|
33
|
+
}, function (success, tokenResult, msg) {
|
34
|
+
if (success) {
|
35
|
+
successCallback && successCallback();
|
36
|
+
} else {
|
37
|
+
failCallback && failCallback(msg);
|
38
|
+
}
|
39
|
+
console.log('initToken result tokenResult', JSON.stringify(tokenResult), msg);
|
40
|
+
});
|
41
|
+
} catch (error) {
|
42
|
+
failCallback && failCallback();
|
43
|
+
}
|
40
44
|
};
|
41
45
|
export var getAppname = function getAppname(scene) {
|
42
46
|
return appName[scene] || '';
|
@@ -107,7 +111,7 @@ var tryGetDeviceId = /*#__PURE__*/function () {
|
|
107
111
|
case 0:
|
108
112
|
return _context3.abrupt("return", new Promise(function (resolve) {
|
109
113
|
try {
|
110
|
-
APDID.getApdidToken(scene, function (tokenResult) {
|
114
|
+
APDID === null || APDID === void 0 || APDID.getApdidToken(scene, function (tokenResult) {
|
111
115
|
resolve(tokenResult === null || tokenResult === void 0 ? void 0 : tokenResult.token);
|
112
116
|
});
|
113
117
|
} catch (error) {
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@alipay/ams-checkout","version":"0.0.
|
1
|
+
{"name":"@alipay/ams-checkout","version":"0.0.1698676929-dev.0","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"@alipay/jshield-apdid":"^2.0.3","axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
|