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

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.
@@ -8,6 +8,7 @@ import { useIconLink } from '../components/SxpPageRender/useIconLink';
8
8
  import SXP_EVENT_BUS, { SXP_EVENT_TYPE } from '../utils/event';
9
9
  import Consent from '../components/Consent';
10
10
  import { getCookie, splitUrlParams } from '../utils/tool';
11
+ import { encrypt } from '../utils/cryptojs';
11
12
  export const SxpDataSourceContext = createContext({
12
13
  rtcList: [],
13
14
  tagList: []
@@ -114,9 +115,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
114
115
  }
115
116
  if (options.type === 'beacon' && navigator.sendBeacon) {
116
117
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
117
- JSON.stringify({
118
- body: encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })))
119
- })
118
+ encrypt(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })), 'dcAR82I0b8sgwCku')
120
119
  ], {
121
120
  type: 'application/json;charset=UTF-8'
122
121
  }));
@@ -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 };
@@ -11,6 +11,7 @@ const useIconLink_1 = require("../components/SxpPageRender/useIconLink");
11
11
  const event_1 = tslib_1.__importStar(require("../utils/event"));
12
12
  const Consent_1 = tslib_1.__importDefault(require("../components/Consent"));
13
13
  const tool_1 = require("../utils/tool");
14
+ const cryptojs_1 = require("../utils/cryptojs");
14
15
  exports.SxpDataSourceContext = (0, react_1.createContext)({
15
16
  rtcList: [],
16
17
  tagList: []
@@ -117,9 +118,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
117
118
  }
118
119
  if (options.type === 'beacon' && navigator.sendBeacon) {
119
120
  return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
120
- JSON.stringify({
121
- body: encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })))
122
- })
121
+ (0, cryptojs_1.encrypt)(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })), 'dcAR82I0b8sgwCku')
123
122
  ], {
124
123
  type: 'application/json;charset=UTF-8'
125
124
  }));
@@ -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.6",
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",