@jayfong/x-server-client-helper 2.119.0 → 3.0.0

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/lib/index.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function processXServerResponse<T>(data: any): T;
1
+ export declare function processXServerResponse<T>(data: any): T;
package/lib/index.js CHANGED
@@ -1,31 +1,18 @@
1
- import LZString from 'lz-string';
2
- import { DataPacker, base64UrlDecode, rot13 } from 'vtils';
3
-
4
- // _#
5
- var obfuscateKey = [90, 30].map(function (v) {
6
- return String.fromCharCode(v + 5);
7
- }).join('');
8
- // _$
9
- var encryptKeySimple = [90, 31].map(function (v) {
10
- return String.fromCharCode(v + 5);
11
- }).join('');
12
- export function processXServerResponse(data) {
13
- if (data && typeof data === 'object') {
14
- // 处理混淆
15
- if (data[obfuscateKey] != null) {
16
- try {
17
- data = JSON.parse(LZString.decompress(data[obfuscateKey]));
18
- } catch (_unused) {}
19
- }
20
- // 简单加密
21
- else if (data[encryptKeySimple] != null) {
22
- try {
23
- data = JSON.parse(base64UrlDecode(rot13(data[encryptKeySimple])).substring(13));
24
- } catch (_unused2) {}
25
- }
26
- }
27
-
28
- // 处理数组打包
29
- data = DataPacker.unpackIfNeeded(data);
30
- return data;
31
- }
1
+ import LZString from "lz-string";
2
+ import { DataPacker, base64UrlDecode, rot13 } from "vtils";
3
+ // src/index.ts
4
+ const obfuscateKey = [90, 30].map((v) => String.fromCharCode(v + 5)).join("");
5
+ const encryptKeySimple = [90, 31].map((v) => String.fromCharCode(v + 5)).join("");
6
+ function processXServerResponse(data) {
7
+ if (data && typeof data === "object") {
8
+ if (data[obfuscateKey] != null) try {
9
+ data = JSON.parse(LZString.decompress(data[obfuscateKey]));
10
+ } catch {}
11
+ else if (data[encryptKeySimple] != null) try {
12
+ data = JSON.parse(base64UrlDecode(rot13(data[encryptKeySimple])).substring(13));
13
+ } catch {}
14
+ }
15
+ data = DataPacker.unpackIfNeeded(data);
16
+ return data;
17
+ }
18
+ export { processXServerResponse };
package/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "@jayfong/x-server-client-helper",
3
- "version": "2.119.0",
3
+ "version": "3.0.0",
4
4
  "license": "ISC",
5
+ "type": "module",
5
6
  "sideEffects": false,
6
- "main": "lib/_cjs/index.js",
7
- "module": "lib/index.js",
8
- "types": "lib/index.d.ts",
9
7
  "files": [
10
8
  "lib"
11
9
  ],
@@ -19,7 +17,11 @@
19
17
  "publishConfig": {
20
18
  "access": "public"
21
19
  },
20
+ "exports": {
21
+ ".": "./lib/index.js",
22
+ "./package.json": "./package.json"
23
+ },
22
24
  "scripts": {
23
- "build": "haoma compile"
25
+ "build": "tsdown"
24
26
  }
25
27
  }
package/lib/_cjs/index.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- exports.__esModule = true;
5
- exports.processXServerResponse = processXServerResponse;
6
- var _lzString = _interopRequireDefault(require("lz-string"));
7
- var _vtils = require("vtils");
8
- // _#
9
- var obfuscateKey = [90, 30].map(function (v) {
10
- return String.fromCharCode(v + 5);
11
- }).join('');
12
- // _$
13
- var encryptKeySimple = [90, 31].map(function (v) {
14
- return String.fromCharCode(v + 5);
15
- }).join('');
16
- function processXServerResponse(data) {
17
- if (data && typeof data === 'object') {
18
- // 处理混淆
19
- if (data[obfuscateKey] != null) {
20
- try {
21
- data = JSON.parse(_lzString.default.decompress(data[obfuscateKey]));
22
- } catch (_unused) {}
23
- }
24
- // 简单加密
25
- else if (data[encryptKeySimple] != null) {
26
- try {
27
- data = JSON.parse((0, _vtils.base64UrlDecode)((0, _vtils.rot13)(data[encryptKeySimple])).substring(13));
28
- } catch (_unused2) {}
29
- }
30
- }
31
-
32
- // 处理数组打包
33
- data = _vtils.DataPacker.unpackIfNeeded(data);
34
- return data;
35
- }