pb-sxp-ui 1.15.20-alpha.1 → 1.15.20-alpha.2

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.js CHANGED
@@ -4,6 +4,7 @@ import pako from 'pako';
4
4
  import React, { useContext, useMemo, memo, useEffect, createContext, useState, useRef, useCallback, forwardRef, useImperativeHandle, useLayoutEffect } from 'react';
5
5
  import qs from 'qs';
6
6
  import EventEmitter from 'eventemitter3';
7
+ import CryptoJS from 'crypto-js';
7
8
  import { css } from '@emotion/css';
8
9
  import * as ReactDOM from 'react-dom';
9
10
  import ReactDOM__default from 'react-dom';
@@ -22,7 +23,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
23
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
24
  PERFORMANCE OF THIS SOFTWARE.
24
25
  ***************************************************************************** */
25
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
26
+ /* global Reflect, Promise, SuppressedError, Symbol */
26
27
 
27
28
 
28
29
  function __rest(s, e) {
@@ -610,6 +611,25 @@ const Consent$3 = ({ width = window.innerWidth, height = window.innerHeight, pri
610
611
  };
611
612
  var Consent$4 = memo(Consent$3);
612
613
 
614
+ /*
615
+ * @Author: binruan@chatlabs.com
616
+ * @Date: 2025-03-24 17:20:35
617
+ * @LastEditors: binruan@chatlabs.com
618
+ * @LastEditTime: 2025-04-27 13:43:15
619
+ * @FilePath: \pb-sxp-ui\src\core\utils\cryptojs.ts
620
+ *
621
+ */
622
+ // 使用CryptoJS实现
623
+ function encrypt(text, key) {
624
+ const encrypted = CryptoJS.AES.encrypt(text, CryptoJS.enc.Utf8.parse(key), // 密钥
625
+ {
626
+ iv: CryptoJS.enc.Utf8.parse(key), // IV是密钥的字节
627
+ mode: CryptoJS.mode.CBC,
628
+ padding: CryptoJS.pad.Pkcs7
629
+ });
630
+ return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
631
+ }
632
+
613
633
  const SxpDataSourceContext = createContext({
614
634
  rtcList: [],
615
635
  tagList: []
@@ -723,25 +743,13 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
723
743
  }
724
744
  // 事件上报优化
725
745
  // Beacon API 用于发送异步和非阻塞请求到服务器。这类请求不需要响应。
726
- // if (options.type === 'beacon' && navigator.sendBeacon) {
727
- // return navigator.sendBeacon(
728
- // `${url}/api/${path}`,
729
- // new Blob(
730
- // [
731
- // JSON.stringify({
732
- // body: btoa(
733
- // encodeURIComponent(
734
- // JSON.stringify({ ...options.body, ...bffDataSource.headers, 'x-user-id': fakeUserId })
735
- // )
736
- // )
737
- // })
738
- // ],
739
- // {
740
- // type: 'application/json;charset=UTF-8'
741
- // }
742
- // )
743
- // );
744
- // }
746
+ if (options.type === 'beacon' && navigator.sendBeacon) {
747
+ return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
748
+ encrypt(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId })), 'dcAR82I0b8sgwCku')
749
+ ], {
750
+ type: 'application/json;charset=UTF-8'
751
+ }));
752
+ }
745
753
  return window
746
754
  .fetch(`${url}/api/${path}`, {
747
755
  headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers),