pb-sxp-ui 1.15.12-alpha.5 → 1.15.12-alpha.7

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.
@@ -115,7 +115,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
115
115
  if (options.type === 'beacon' && navigator.sendBeacon) {
116
116
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
117
117
  JSON.stringify({
118
- body: encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })))
118
+ body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
119
119
  })
120
120
  ], {
121
121
  type: 'application/json;charset=UTF-8'
@@ -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 };
@@ -118,7 +118,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
118
118
  if (options.type === 'beacon' && navigator.sendBeacon) {
119
119
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
120
120
  JSON.stringify({
121
- body: encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })))
121
+ body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
122
122
  })
123
123
  ], {
124
124
  type: 'application/json;charset=UTF-8'
@@ -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.12-alpha.5",
3
+ "version": "1.15.12-alpha.7",
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",