pb-sxp-ui 1.15.20-alpha.1 → 1.15.20-alpha.3
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/index.cjs +6 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -20
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +4 -4
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +4 -4
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +6 -20
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +4 -4
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/context/SxpDataSourceProvider.js +5 -0
- package/es/core/utils/cryptojs.d.ts +3 -0
- package/es/core/utils/cryptojs.js +18 -0
- package/lib/core/context/SxpDataSourceProvider.js +5 -0
- package/lib/core/utils/cryptojs.d.ts +3 -0
- package/lib/core/utils/cryptojs.js +23 -0
- package/package.json +2 -1
@@ -112,6 +112,11 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
112
112
|
const queryString = qs.stringify(options.query);
|
113
113
|
path = `${path}?${queryString}`;
|
114
114
|
}
|
115
|
+
if (options.type === 'beacon' && navigator.sendBeacon) {
|
116
|
+
const formData = new FormData();
|
117
|
+
formData.append('data', JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })));
|
118
|
+
return navigator.sendBeacon(`${url}/api/${path}`, formData);
|
119
|
+
}
|
115
120
|
return window
|
116
121
|
.fetch(`${url}/api/${path}`, {
|
117
122
|
headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import CryptoJS from 'crypto-js';
|
2
|
+
function encrypt(text, key) {
|
3
|
+
const encrypted = CryptoJS.AES.encrypt(text, CryptoJS.enc.Utf8.parse(key), {
|
4
|
+
iv: CryptoJS.enc.Utf8.parse(key),
|
5
|
+
mode: CryptoJS.mode.CBC,
|
6
|
+
padding: CryptoJS.pad.Pkcs7
|
7
|
+
});
|
8
|
+
return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
|
9
|
+
}
|
10
|
+
function decrypt(encryptedBase64, key) {
|
11
|
+
const bytes = CryptoJS.AES.decrypt(encryptedBase64, CryptoJS.enc.Utf8.parse(key), {
|
12
|
+
iv: CryptoJS.enc.Utf8.parse(key),
|
13
|
+
mode: CryptoJS.mode.CBC,
|
14
|
+
padding: CryptoJS.pad.Pkcs7
|
15
|
+
});
|
16
|
+
return bytes.toString(CryptoJS.enc.Utf8);
|
17
|
+
}
|
18
|
+
export { encrypt, decrypt };
|
@@ -115,6 +115,11 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
115
115
|
const queryString = qs_1.default.stringify(options.query);
|
116
116
|
path = `${path}?${queryString}`;
|
117
117
|
}
|
118
|
+
if (options.type === 'beacon' && navigator.sendBeacon) {
|
119
|
+
const formData = new FormData();
|
120
|
+
formData.append('data', JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })));
|
121
|
+
return navigator.sendBeacon(`${url}/api/${path}`, formData);
|
122
|
+
}
|
118
123
|
return window
|
119
124
|
.fetch(`${url}/api/${path}`, {
|
120
125
|
headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.decrypt = exports.encrypt = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const crypto_js_1 = tslib_1.__importDefault(require("crypto-js"));
|
6
|
+
function encrypt(text, key) {
|
7
|
+
const encrypted = crypto_js_1.default.AES.encrypt(text, crypto_js_1.default.enc.Utf8.parse(key), {
|
8
|
+
iv: crypto_js_1.default.enc.Utf8.parse(key),
|
9
|
+
mode: crypto_js_1.default.mode.CBC,
|
10
|
+
padding: crypto_js_1.default.pad.Pkcs7
|
11
|
+
});
|
12
|
+
return encrypted.ciphertext.toString(crypto_js_1.default.enc.Base64);
|
13
|
+
}
|
14
|
+
exports.encrypt = encrypt;
|
15
|
+
function decrypt(encryptedBase64, key) {
|
16
|
+
const bytes = crypto_js_1.default.AES.decrypt(encryptedBase64, crypto_js_1.default.enc.Utf8.parse(key), {
|
17
|
+
iv: crypto_js_1.default.enc.Utf8.parse(key),
|
18
|
+
mode: crypto_js_1.default.mode.CBC,
|
19
|
+
padding: crypto_js_1.default.pad.Pkcs7
|
20
|
+
});
|
21
|
+
return bytes.toString(crypto_js_1.default.enc.Utf8);
|
22
|
+
}
|
23
|
+
exports.decrypt = decrypt;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "pb-sxp-ui",
|
3
|
-
"version": "1.15.20-alpha.
|
3
|
+
"version": "1.15.20-alpha.3",
|
4
4
|
"description": "React enterprise-class UI components",
|
5
5
|
"main": "dist/index.cjs",
|
6
6
|
"module": "dist/index.js",
|
@@ -37,6 +37,7 @@
|
|
37
37
|
"license": "MIT",
|
38
38
|
"dependencies": {
|
39
39
|
"@emotion/css": "^11.11.2",
|
40
|
+
"crypto-js": "^4.2.0",
|
40
41
|
"eslint": "^8.48.0",
|
41
42
|
"eventemitter3": "^5.0.1",
|
42
43
|
"less": "^4.2.0",
|