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.
@@ -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,3 @@
1
+ declare function encrypt(text: string, key: string): string;
2
+ declare function decrypt(encryptedBase64: string, key: string): string;
3
+ export { encrypt, decrypt };
@@ -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,3 @@
1
+ declare function encrypt(text: string, key: string): string;
2
+ declare function decrypt(encryptedBase64: string, key: string): string;
3
+ export { encrypt, decrypt };
@@ -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.1",
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",