pb-sxp-ui 1.15.20-alpha.5 → 1.15.21
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 +43 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -6
- 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 +43 -6
- 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 +41 -6
- package/lib/core/context/SxpDataSourceProvider.js +41 -6
- package/package.json +1 -2
- package/es/core/utils/cryptojs.d.ts +0 -3
- package/es/core/utils/cryptojs.js +0 -18
- package/lib/core/utils/cryptojs.d.ts +0 -3
- package/lib/core/utils/cryptojs.js +0 -23
@@ -105,6 +105,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
105
105
|
return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
|
106
106
|
}, [bffDataSource]);
|
107
107
|
const bffFetch = useCallback((path, options) => {
|
108
|
+
var _a, _b;
|
108
109
|
if (!bffDataSource)
|
109
110
|
return;
|
110
111
|
const url = bffDataSource.url;
|
@@ -112,13 +113,47 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
112
113
|
const queryString = qs.stringify(options.query);
|
113
114
|
path = `${path}?${queryString}`;
|
114
115
|
}
|
116
|
+
let isTikTokChannel = false;
|
117
|
+
const params = {};
|
118
|
+
const queryString = location.search.slice(1);
|
119
|
+
(_a = splitUrlParams(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
|
120
|
+
const key = val.split('=')[0];
|
121
|
+
const value = val.split('=')[1];
|
122
|
+
params[key] = value;
|
123
|
+
});
|
124
|
+
const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
|
125
|
+
if (cl_source &&
|
126
|
+
((_b = [
|
127
|
+
'40A-SPRK--DRESS_EYEWEAR-',
|
128
|
+
'41A-SPRK--MADRAGUE-',
|
129
|
+
'42A-SPRK--MOOD-',
|
130
|
+
'43A-SPRK--SUMMER-',
|
131
|
+
'44A-SPRK--DRESS_EYEWEAR-',
|
132
|
+
'45A-SPRK--MADRAGUE-',
|
133
|
+
'46A-SPRK--MOOD-',
|
134
|
+
'47A-SPRK--SUMMER-',
|
135
|
+
'48A-SPRK--DRESS_EYEWEAR-',
|
136
|
+
'49A-SPRK--MADRAGUE-',
|
137
|
+
'50A-SPRK--MOOD-',
|
138
|
+
'51A-SPRK--SUMMER-'
|
139
|
+
]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
|
140
|
+
isTikTokChannel = true;
|
141
|
+
}
|
142
|
+
if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
|
143
|
+
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
144
|
+
JSON.stringify({
|
145
|
+
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
146
|
+
})
|
147
|
+
], {
|
148
|
+
type: 'application/json;charset=UTF-8'
|
149
|
+
}));
|
150
|
+
}
|
115
151
|
return window
|
116
|
-
.fetch(`${url}/api/${path}`, {
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
})
|
152
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
|
153
|
+
? JSON.stringify({
|
154
|
+
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
155
|
+
})
|
156
|
+
: JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
|
122
157
|
.then((res) => res.json())
|
123
158
|
.catch((err) => Promise.reject(err));
|
124
159
|
}, [bffDataSource, fakeUserId]);
|
@@ -108,6 +108,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
108
108
|
return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + (0, localStore_1.storeAndLoadFeUserId)();
|
109
109
|
}, [bffDataSource]);
|
110
110
|
const bffFetch = (0, react_1.useCallback)((path, options) => {
|
111
|
+
var _a, _b;
|
111
112
|
if (!bffDataSource)
|
112
113
|
return;
|
113
114
|
const url = bffDataSource.url;
|
@@ -115,13 +116,47 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
|
|
115
116
|
const queryString = qs_1.default.stringify(options.query);
|
116
117
|
path = `${path}?${queryString}`;
|
117
118
|
}
|
119
|
+
let isTikTokChannel = false;
|
120
|
+
const params = {};
|
121
|
+
const queryString = location.search.slice(1);
|
122
|
+
(_a = (0, tool_1.splitUrlParams)(queryString)) === null || _a === void 0 ? void 0 : _a.forEach((val) => {
|
123
|
+
const key = val.split('=')[0];
|
124
|
+
const value = val.split('=')[1];
|
125
|
+
params[key] = value;
|
126
|
+
});
|
127
|
+
const cl_source = params === null || params === void 0 ? void 0 : params.cl_source;
|
128
|
+
if (cl_source &&
|
129
|
+
((_b = [
|
130
|
+
'40A-SPRK--DRESS_EYEWEAR-',
|
131
|
+
'41A-SPRK--MADRAGUE-',
|
132
|
+
'42A-SPRK--MOOD-',
|
133
|
+
'43A-SPRK--SUMMER-',
|
134
|
+
'44A-SPRK--DRESS_EYEWEAR-',
|
135
|
+
'45A-SPRK--MADRAGUE-',
|
136
|
+
'46A-SPRK--MOOD-',
|
137
|
+
'47A-SPRK--SUMMER-',
|
138
|
+
'48A-SPRK--DRESS_EYEWEAR-',
|
139
|
+
'49A-SPRK--MADRAGUE-',
|
140
|
+
'50A-SPRK--MOOD-',
|
141
|
+
'51A-SPRK--SUMMER-'
|
142
|
+
]) === null || _b === void 0 ? void 0 : _b.includes(cl_source))) {
|
143
|
+
isTikTokChannel = true;
|
144
|
+
}
|
145
|
+
if (options.type === 'beacon' && navigator.sendBeacon && !isTikTokChannel) {
|
146
|
+
return navigator.sendBeacon(`${url}/api/${path}`, new Blob([
|
147
|
+
JSON.stringify({
|
148
|
+
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
149
|
+
})
|
150
|
+
], {
|
151
|
+
type: 'application/json;charset=UTF-8'
|
152
|
+
}));
|
153
|
+
}
|
118
154
|
return window
|
119
|
-
.fetch(`${url}/api/${path}`, {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
})
|
155
|
+
.fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: isTikTokChannel
|
156
|
+
? JSON.stringify({
|
157
|
+
body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
|
158
|
+
})
|
159
|
+
: JSON.stringify(options.body) }, (isTikTokChannel && { keepalive: true })))
|
125
160
|
.then((res) => res.json())
|
126
161
|
.catch((err) => Promise.reject(err));
|
127
162
|
}, [bffDataSource, fakeUserId]);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "pb-sxp-ui",
|
3
|
-
"version": "1.15.
|
3
|
+
"version": "1.15.21",
|
4
4
|
"description": "React enterprise-class UI components",
|
5
5
|
"main": "dist/index.cjs",
|
6
6
|
"module": "dist/index.js",
|
@@ -37,7 +37,6 @@
|
|
37
37
|
"license": "MIT",
|
38
38
|
"dependencies": {
|
39
39
|
"@emotion/css": "^11.11.2",
|
40
|
-
"crypto-js": "^4.2.0",
|
41
40
|
"eslint": "^8.48.0",
|
42
41
|
"eventemitter3": "^5.0.1",
|
43
42
|
"less": "^4.2.0",
|
@@ -1,18 +0,0 @@
|
|
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 };
|
@@ -1,23 +0,0 @@
|
|
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;
|