mslxdff 0.1.187 → 0.1.188

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.
Files changed (111) hide show
  1. package/bin/mslxdff.js +3 -3
  2. package/docs/cli_help_mini.md +145 -0
  3. package/package.json +1 -1
  4. package/src/auto.js +254 -254
  5. package/src/autostart.js +5 -2
  6. package/src/bench/cline-bench.js +42 -42
  7. package/src/bench/probe.js +70 -70
  8. package/src/bench/report.js +162 -162
  9. package/src/bench/runner.js +77 -77
  10. package/src/bench/via-probe.js +124 -124
  11. package/src/bench/via-routes.js +87 -87
  12. package/src/bench/workbuddy-bench.js +54 -54
  13. package/src/chat/engine.js +160 -160
  14. package/src/chat/gateway.js +163 -163
  15. package/src/chat/orchestrator.js +234 -234
  16. package/src/chat/prompt.js +70 -70
  17. package/src/chat/repl.js +88 -88
  18. package/src/chat/terminal.js +135 -135
  19. package/src/chat/tools.js +306 -306
  20. package/src/chat-pipeline/index.js +173 -131
  21. package/src/chat-pipeline/policy.js +84 -84
  22. package/src/chat-pipeline/serial-trial.js +6 -3
  23. package/src/chat-pipeline/terminal-verdict.js +29 -0
  24. package/src/cli/commands/daemon.js +55 -18
  25. package/src/cli/commands/group.js +249 -249
  26. package/src/cli/commands/model/picks.js +50 -50
  27. package/src/cli/commands/provider/bench-via.js +247 -247
  28. package/src/cli/commands/provider/bench.js +141 -141
  29. package/src/cli/commands/provider/index.js +136 -136
  30. package/src/cli/commands/provider/models.js +145 -145
  31. package/src/cli/commands/provider/qwenwork-login.js +119 -119
  32. package/src/cli/commands/sync.js +310 -310
  33. package/src/cli/commands/system.js +23 -7
  34. package/src/cli/join-wizard.js +8 -4
  35. package/src/cli/policy.js +14 -2
  36. package/src/cli/status.js +279 -279
  37. package/src/daemon.js +232 -195
  38. package/src/logs.js +27 -11
  39. package/src/model-capabilities/enrich.js +86 -86
  40. package/src/model-capabilities/index.js +183 -183
  41. package/src/model-capabilities/parse.js +70 -70
  42. package/src/model-trace.js +35 -4
  43. package/src/models.js +225 -225
  44. package/src/peers.js +20 -1
  45. package/src/providers/AGENTS.md +49 -0
  46. package/src/providers/cline/auth.js +228 -228
  47. package/src/providers/cline/chat.js +307 -307
  48. package/src/providers/cline.js +2 -2
  49. package/src/providers/codearts/chat.js +182 -182
  50. package/src/providers/globalqwenwork/cosy.js +123 -123
  51. package/src/providers/globalqwenwork/crypto.js +218 -218
  52. package/src/providers/globalqwenwork/http.js +20 -20
  53. package/src/providers/globalqwenwork/rsa.js +54 -54
  54. package/src/providers/globalqwenwork/sse.js +268 -268
  55. package/src/providers/globalqwenwork/stream.js +130 -130
  56. package/src/providers/globalqwenwork/upstream.js +122 -122
  57. package/src/providers/keyring.js +60 -60
  58. package/src/providers/qoder/chat.js +203 -203
  59. package/src/providers/qoder/index.js +249 -249
  60. package/src/providers/qoder/sse.js +145 -145
  61. package/src/providers/qwenwork/account-store.js +133 -133
  62. package/src/providers/qwenwork/constants.js +67 -67
  63. package/src/providers/qwenwork/cosy.js +120 -120
  64. package/src/providers/qwenwork/crypto.js +218 -218
  65. package/src/providers/qwenwork/http.js +20 -20
  66. package/src/providers/qwenwork/index.js +337 -327
  67. package/src/providers/qwenwork/payload.js +144 -144
  68. package/src/providers/qwenwork/rsa.js +54 -54
  69. package/src/providers/qwenwork/sse.js +268 -268
  70. package/src/providers/qwenwork/stream.js +130 -130
  71. package/src/providers/qwenwork/upstream.js +120 -120
  72. package/src/providers/qwenwork.js +1 -1
  73. package/src/providers/registry.js +79 -79
  74. package/src/providers/traework/chat.js +7 -1
  75. package/src/providers/workbuddy/chat.js +248 -248
  76. package/src/providers/workbuddy/reshape.js +152 -152
  77. package/src/providers/workbuddy.js +2 -2
  78. package/src/reasoning.js +32 -32
  79. package/src/routes/AGENTS.md +37 -0
  80. package/src/routes/chat/empty-turn-report.js +31 -0
  81. package/src/routes/chat/gateway.js +46 -46
  82. package/src/routes/chat/peer-handler.js +3 -2
  83. package/src/routes/chat/relay-pipeline.js +282 -294
  84. package/src/routes/chat/via-route-handler.js +146 -146
  85. package/src/routes/hedge.js +253 -255
  86. package/src/routes/index.js +14 -6
  87. package/src/routes/models-route.js +167 -167
  88. package/src/routes/peers.js +335 -273
  89. package/src/routes/responses-route.js +44 -2
  90. package/src/routes/stream-body.js +84 -0
  91. package/src/routes/stream-hold.js +152 -4
  92. package/src/routes/stream-scan.js +27 -2
  93. package/src/routes/stream.js +343 -385
  94. package/src/runtime/bootstrap.js +67 -67
  95. package/src/runtime/group-sync.js +70 -17
  96. package/src/runtime/provider-gate.js +36 -36
  97. package/src/runtime/providers-setup.js +168 -168
  98. package/src/runtime/server-lifecycle.js +1 -1
  99. package/src/server.js +78 -78
  100. package/src/state/schemas/allowlist.js +92 -92
  101. package/src/sync-opencode.js +280 -280
  102. package/src/transport/index.js +244 -244
  103. package/src/transport/pool.js +56 -56
  104. package/src/transport/retry.js +24 -24
  105. package/src/transport/sse.js +93 -93
  106. package/src/upstream-engine/sdk/attempt.js +9 -1
  107. package/src/upstream-probe/display.js +52 -52
  108. package/src/upstream-probe/probe.js +49 -49
  109. package/src/upstream-probe/rotate.js +110 -110
  110. package/src/upstream-probe/start.js +45 -45
  111. package/src/upstream.js +293 -293
@@ -1,218 +1,218 @@
1
- // vendor 自 qwenwork2api-makers 的 edge-functions/_shared/crypto.js(逐字搬,仅加 webcrypto 兜底)。
2
- // 原作者手写 AES/RSA/MD5 是因为 Cloudflare Workers 无 node:crypto;**不要**"顺手优化"成原生实现 ——
3
- // 实测换成 node:crypto 后上游回 `code 101 Signature invalid`(RSA/AES 材料与上游期望不等价)。
4
- // Node 侧需要 globalThis.crypto(getRandomValues / subtle.digest);<19 用 node:crypto 的 webcrypto 兜底。
5
- if (!globalThis.crypto || !globalThis.crypto.subtle) {
6
- const { webcrypto } = await import("node:crypto");
7
- globalThis.crypto = webcrypto;
8
- }
9
-
10
- const SBOX = (() => {
11
- const s = new Uint8Array(256);
12
- let p = 1;
13
- let q = 1;
14
- do {
15
- p = p ^ ((p << 1) & 0xff) ^ (p & 0x80 ? 0x1b : 0);
16
- q ^= q << 1;
17
- q ^= q << 2;
18
- q ^= q << 4;
19
- if (q & 0x80) q ^= 0x09;
20
- q &= 0xff;
21
- const x = q ^ ((q << 1) | (q >> 7)) ^ ((q << 2) | (q >> 6)) ^ ((q << 3) | (q >> 5)) ^ ((q << 4) | (q >> 4));
22
- s[p] = (x ^ 0x63) & 0xff;
23
- } while (p !== 1);
24
- s[0] = 0x63;
25
- return s;
26
- })();
27
-
28
- const RCON = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
29
-
30
- export function utf8(str) {
31
- return new TextEncoder().encode(str);
32
- }
33
-
34
- export function hex(bytes) {
35
- let out = "";
36
- for (let i = 0; i < bytes.length; i++) out += bytes[i].toString(16).padStart(2, "0");
37
- return out;
38
- }
39
-
40
- export function b64(bytes) {
41
- let s = "";
42
- for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
43
- return btoa(s);
44
- }
45
-
46
- export function unb64(str) {
47
- const s = atob(str);
48
- const out = new Uint8Array(s.length);
49
- for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i);
50
- return out;
51
- }
52
-
53
- export function b64url(bytes) {
54
- return b64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
55
- }
56
-
57
- export function uuid() {
58
- const r = new Uint8Array(16);
59
- crypto.getRandomValues(r);
60
- r[6] = (r[6] & 0x0f) | 0x40;
61
- r[8] = (r[8] & 0x3f) | 0x80;
62
- const h = hex(r);
63
- return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
64
- }
65
-
66
- const MD5_S = [
67
- 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
68
- 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,
69
- ];
70
-
71
- const MD5_K = new Int32Array(64);
72
- for (let i = 0; i < 64; i++) MD5_K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296) | 0;
73
-
74
- function rotl(x, n) {
75
- return (x << n) | (x >>> (32 - n));
76
- }
77
-
78
- export function md5(input) {
79
- const msg = typeof input === "string" ? utf8(input) : input;
80
- const len = msg.length;
81
- const bitLen = len * 8;
82
- const padLen = (56 - ((len + 1) % 64) + 64) % 64;
83
- const total = len + 1 + padLen + 8;
84
- const buf = new Uint8Array(total);
85
- buf.set(msg, 0);
86
- buf[len] = 0x80;
87
- const view = new DataView(buf.buffer);
88
- view.setUint32(total - 8, bitLen >>> 0, true);
89
- view.setUint32(total - 4, Math.floor(bitLen / 4294967296), true);
90
-
91
- let a0 = 0x67452301;
92
- let b0 = 0xefcdab89;
93
- let c0 = 0x98badcfe;
94
- let d0 = 0x10325476;
95
-
96
- for (let i = 0; i < total; i += 64) {
97
- const m = new Int32Array(16);
98
- for (let j = 0; j < 16; j++) m[j] = view.getInt32(i + j * 4, true);
99
- let a = a0;
100
- let b = b0;
101
- let c = c0;
102
- let d = d0;
103
- for (let j = 0; j < 64; j++) {
104
- let f;
105
- let g;
106
- if (j < 16) {
107
- f = (b & c) | (~b & d);
108
- g = j;
109
- } else if (j < 32) {
110
- f = (d & b) | (~d & c);
111
- g = (5 * j + 1) % 16;
112
- } else if (j < 48) {
113
- f = b ^ c ^ d;
114
- g = (3 * j + 5) % 16;
115
- } else {
116
- f = c ^ (b | ~d);
117
- g = (7 * j) % 16;
118
- }
119
- f = (f + a + MD5_K[j] + m[g]) | 0;
120
- a = d;
121
- d = c;
122
- c = b;
123
- b = (b + rotl(f, MD5_S[j])) | 0;
124
- }
125
- a0 = (a0 + a) | 0;
126
- b0 = (b0 + b) | 0;
127
- c0 = (c0 + c) | 0;
128
- d0 = (d0 + d) | 0;
129
- }
130
-
131
- const out = new Uint8Array(16);
132
- const ov = new DataView(out.buffer);
133
- ov.setInt32(0, a0, true);
134
- ov.setInt32(4, b0, true);
135
- ov.setInt32(8, c0, true);
136
- ov.setInt32(12, d0, true);
137
- return hex(out);
138
- }
139
-
140
- function xtime(a) {
141
- return ((a << 1) ^ (a & 0x80 ? 0x1b : 0)) & 0xff;
142
- }
143
-
144
- function keyExpansion(key) {
145
- const w = new Uint8Array(176);
146
- w.set(key, 0);
147
- for (let i = 4; i < 44; i++) {
148
- const t = [w[(i - 1) * 4], w[(i - 1) * 4 + 1], w[(i - 1) * 4 + 2], w[(i - 1) * 4 + 3]];
149
- if (i % 4 === 0) {
150
- const r = t[0];
151
- t[0] = t[1];
152
- t[1] = t[2];
153
- t[2] = t[3];
154
- t[3] = r;
155
- for (let j = 0; j < 4; j++) t[j] = SBOX[t[j]];
156
- t[0] ^= RCON[i / 4 - 1];
157
- }
158
- for (let j = 0; j < 4; j++) w[i * 4 + j] = w[(i - 4) * 4 + j] ^ t[j];
159
- }
160
- return w;
161
- }
162
-
163
- function addRoundKey(state, w, round) {
164
- for (let c = 0; c < 4; c++) {
165
- for (let r = 0; r < 4; r++) state[c * 4 + r] ^= w[round * 16 + c * 4 + r];
166
- }
167
- }
168
-
169
- function subBytes(state) {
170
- for (let i = 0; i < 16; i++) state[i] = SBOX[state[i]];
171
- }
172
-
173
- function shiftRows(s) {
174
- const t = s.slice();
175
- const map = [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11];
176
- for (let i = 0; i < 16; i++) s[i] = t[map[i]];
177
- }
178
-
179
- function mixColumns(s) {
180
- for (let c = 0; c < 4; c++) {
181
- const i = c * 4;
182
- const a0 = s[i];
183
- const a1 = s[i + 1];
184
- const a2 = s[i + 2];
185
- const a3 = s[i + 3];
186
- s[i] = xtime(a0) ^ (xtime(a1) ^ a1) ^ a2 ^ a3;
187
- s[i + 1] = a0 ^ xtime(a1) ^ (xtime(a2) ^ a2) ^ a3;
188
- s[i + 2] = a0 ^ a1 ^ xtime(a2) ^ (xtime(a3) ^ a3);
189
- s[i + 3] = (xtime(a0) ^ a0) ^ a1 ^ a2 ^ xtime(a3);
190
- }
191
- }
192
-
193
- export function aesCbcEncrypt(plain, key) {
194
- const w = keyExpansion(key);
195
- const padLen = 16 - (plain.length % 16);
196
- const data = new Uint8Array(plain.length + padLen);
197
- data.set(plain, 0);
198
- for (let i = plain.length; i < data.length; i++) data[i] = padLen;
199
- const out = new Uint8Array(data.length);
200
- const block = new Uint8Array(16);
201
- let prev = key.slice(0, 16);
202
- for (let off = 0; off < data.length; off += 16) {
203
- for (let i = 0; i < 16; i++) block[i] = data[off + i] ^ prev[i];
204
- addRoundKey(block, w, 0);
205
- for (let round = 1; round < 10; round++) {
206
- subBytes(block);
207
- shiftRows(block);
208
- mixColumns(block);
209
- addRoundKey(block, w, round);
210
- }
211
- subBytes(block);
212
- shiftRows(block);
213
- addRoundKey(block, w, 10);
214
- out.set(block, off);
215
- prev = block.slice(0, 16);
216
- }
217
- return out;
218
- }
1
+ // vendor 自 qwenwork2api-makers 的 edge-functions/_shared/crypto.js(逐字搬,仅加 webcrypto 兜底)。
2
+ // 原作者手写 AES/RSA/MD5 是因为 Cloudflare Workers 无 node:crypto;**不要**"顺手优化"成原生实现 ——
3
+ // 实测换成 node:crypto 后上游回 `code 101 Signature invalid`(RSA/AES 材料与上游期望不等价)。
4
+ // Node 侧需要 globalThis.crypto(getRandomValues / subtle.digest);<19 用 node:crypto 的 webcrypto 兜底。
5
+ if (!globalThis.crypto || !globalThis.crypto.subtle) {
6
+ const { webcrypto } = await import("node:crypto");
7
+ globalThis.crypto = webcrypto;
8
+ }
9
+
10
+ const SBOX = (() => {
11
+ const s = new Uint8Array(256);
12
+ let p = 1;
13
+ let q = 1;
14
+ do {
15
+ p = p ^ ((p << 1) & 0xff) ^ (p & 0x80 ? 0x1b : 0);
16
+ q ^= q << 1;
17
+ q ^= q << 2;
18
+ q ^= q << 4;
19
+ if (q & 0x80) q ^= 0x09;
20
+ q &= 0xff;
21
+ const x = q ^ ((q << 1) | (q >> 7)) ^ ((q << 2) | (q >> 6)) ^ ((q << 3) | (q >> 5)) ^ ((q << 4) | (q >> 4));
22
+ s[p] = (x ^ 0x63) & 0xff;
23
+ } while (p !== 1);
24
+ s[0] = 0x63;
25
+ return s;
26
+ })();
27
+
28
+ const RCON = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
29
+
30
+ export function utf8(str) {
31
+ return new TextEncoder().encode(str);
32
+ }
33
+
34
+ export function hex(bytes) {
35
+ let out = "";
36
+ for (let i = 0; i < bytes.length; i++) out += bytes[i].toString(16).padStart(2, "0");
37
+ return out;
38
+ }
39
+
40
+ export function b64(bytes) {
41
+ let s = "";
42
+ for (let i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
43
+ return btoa(s);
44
+ }
45
+
46
+ export function unb64(str) {
47
+ const s = atob(str);
48
+ const out = new Uint8Array(s.length);
49
+ for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i);
50
+ return out;
51
+ }
52
+
53
+ export function b64url(bytes) {
54
+ return b64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
55
+ }
56
+
57
+ export function uuid() {
58
+ const r = new Uint8Array(16);
59
+ crypto.getRandomValues(r);
60
+ r[6] = (r[6] & 0x0f) | 0x40;
61
+ r[8] = (r[8] & 0x3f) | 0x80;
62
+ const h = hex(r);
63
+ return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
64
+ }
65
+
66
+ const MD5_S = [
67
+ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
68
+ 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,
69
+ ];
70
+
71
+ const MD5_K = new Int32Array(64);
72
+ for (let i = 0; i < 64; i++) MD5_K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296) | 0;
73
+
74
+ function rotl(x, n) {
75
+ return (x << n) | (x >>> (32 - n));
76
+ }
77
+
78
+ export function md5(input) {
79
+ const msg = typeof input === "string" ? utf8(input) : input;
80
+ const len = msg.length;
81
+ const bitLen = len * 8;
82
+ const padLen = (56 - ((len + 1) % 64) + 64) % 64;
83
+ const total = len + 1 + padLen + 8;
84
+ const buf = new Uint8Array(total);
85
+ buf.set(msg, 0);
86
+ buf[len] = 0x80;
87
+ const view = new DataView(buf.buffer);
88
+ view.setUint32(total - 8, bitLen >>> 0, true);
89
+ view.setUint32(total - 4, Math.floor(bitLen / 4294967296), true);
90
+
91
+ let a0 = 0x67452301;
92
+ let b0 = 0xefcdab89;
93
+ let c0 = 0x98badcfe;
94
+ let d0 = 0x10325476;
95
+
96
+ for (let i = 0; i < total; i += 64) {
97
+ const m = new Int32Array(16);
98
+ for (let j = 0; j < 16; j++) m[j] = view.getInt32(i + j * 4, true);
99
+ let a = a0;
100
+ let b = b0;
101
+ let c = c0;
102
+ let d = d0;
103
+ for (let j = 0; j < 64; j++) {
104
+ let f;
105
+ let g;
106
+ if (j < 16) {
107
+ f = (b & c) | (~b & d);
108
+ g = j;
109
+ } else if (j < 32) {
110
+ f = (d & b) | (~d & c);
111
+ g = (5 * j + 1) % 16;
112
+ } else if (j < 48) {
113
+ f = b ^ c ^ d;
114
+ g = (3 * j + 5) % 16;
115
+ } else {
116
+ f = c ^ (b | ~d);
117
+ g = (7 * j) % 16;
118
+ }
119
+ f = (f + a + MD5_K[j] + m[g]) | 0;
120
+ a = d;
121
+ d = c;
122
+ c = b;
123
+ b = (b + rotl(f, MD5_S[j])) | 0;
124
+ }
125
+ a0 = (a0 + a) | 0;
126
+ b0 = (b0 + b) | 0;
127
+ c0 = (c0 + c) | 0;
128
+ d0 = (d0 + d) | 0;
129
+ }
130
+
131
+ const out = new Uint8Array(16);
132
+ const ov = new DataView(out.buffer);
133
+ ov.setInt32(0, a0, true);
134
+ ov.setInt32(4, b0, true);
135
+ ov.setInt32(8, c0, true);
136
+ ov.setInt32(12, d0, true);
137
+ return hex(out);
138
+ }
139
+
140
+ function xtime(a) {
141
+ return ((a << 1) ^ (a & 0x80 ? 0x1b : 0)) & 0xff;
142
+ }
143
+
144
+ function keyExpansion(key) {
145
+ const w = new Uint8Array(176);
146
+ w.set(key, 0);
147
+ for (let i = 4; i < 44; i++) {
148
+ const t = [w[(i - 1) * 4], w[(i - 1) * 4 + 1], w[(i - 1) * 4 + 2], w[(i - 1) * 4 + 3]];
149
+ if (i % 4 === 0) {
150
+ const r = t[0];
151
+ t[0] = t[1];
152
+ t[1] = t[2];
153
+ t[2] = t[3];
154
+ t[3] = r;
155
+ for (let j = 0; j < 4; j++) t[j] = SBOX[t[j]];
156
+ t[0] ^= RCON[i / 4 - 1];
157
+ }
158
+ for (let j = 0; j < 4; j++) w[i * 4 + j] = w[(i - 4) * 4 + j] ^ t[j];
159
+ }
160
+ return w;
161
+ }
162
+
163
+ function addRoundKey(state, w, round) {
164
+ for (let c = 0; c < 4; c++) {
165
+ for (let r = 0; r < 4; r++) state[c * 4 + r] ^= w[round * 16 + c * 4 + r];
166
+ }
167
+ }
168
+
169
+ function subBytes(state) {
170
+ for (let i = 0; i < 16; i++) state[i] = SBOX[state[i]];
171
+ }
172
+
173
+ function shiftRows(s) {
174
+ const t = s.slice();
175
+ const map = [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11];
176
+ for (let i = 0; i < 16; i++) s[i] = t[map[i]];
177
+ }
178
+
179
+ function mixColumns(s) {
180
+ for (let c = 0; c < 4; c++) {
181
+ const i = c * 4;
182
+ const a0 = s[i];
183
+ const a1 = s[i + 1];
184
+ const a2 = s[i + 2];
185
+ const a3 = s[i + 3];
186
+ s[i] = xtime(a0) ^ (xtime(a1) ^ a1) ^ a2 ^ a3;
187
+ s[i + 1] = a0 ^ xtime(a1) ^ (xtime(a2) ^ a2) ^ a3;
188
+ s[i + 2] = a0 ^ a1 ^ xtime(a2) ^ (xtime(a3) ^ a3);
189
+ s[i + 3] = (xtime(a0) ^ a0) ^ a1 ^ a2 ^ xtime(a3);
190
+ }
191
+ }
192
+
193
+ export function aesCbcEncrypt(plain, key) {
194
+ const w = keyExpansion(key);
195
+ const padLen = 16 - (plain.length % 16);
196
+ const data = new Uint8Array(plain.length + padLen);
197
+ data.set(plain, 0);
198
+ for (let i = plain.length; i < data.length; i++) data[i] = padLen;
199
+ const out = new Uint8Array(data.length);
200
+ const block = new Uint8Array(16);
201
+ let prev = key.slice(0, 16);
202
+ for (let off = 0; off < data.length; off += 16) {
203
+ for (let i = 0; i < 16; i++) block[i] = data[off + i] ^ prev[i];
204
+ addRoundKey(block, w, 0);
205
+ for (let round = 1; round < 10; round++) {
206
+ subBytes(block);
207
+ shiftRows(block);
208
+ mixColumns(block);
209
+ addRoundKey(block, w, round);
210
+ }
211
+ subBytes(block);
212
+ shiftRows(block);
213
+ addRoundKey(block, w, 10);
214
+ out.set(block, off);
215
+ prev = block.slice(0, 16);
216
+ }
217
+ return out;
218
+ }
@@ -1,20 +1,20 @@
1
- // vendor 自 _shared/http.js(只保留本 provider 用得上的部分;CORS/preflight 属原项目的边缘层,不带)。
2
- export function cleanErrorText(value) {
3
- let s = String(value === undefined || value === null ? "" : value);
4
- s = s
5
- .replace(/<script[\s\S]*?<\/script>/gi, " ")
6
- .replace(/<style[\s\S]*?<\/style>/gi, " ")
7
- .replace(/<[^>]*>/g, " ")
8
- .replace(/[\r\n\t]+/g, " ")
9
- .replace(/[^\S ]+/g, "")
10
- .replace(/\s+/g, " ")
11
- .trim();
12
- if (s.length > 200) s = s.slice(0, 200);
13
- return s;
14
- }
15
-
16
- export function timeoutSignal(ms) {
17
- const controller = new AbortController();
18
- const timer = setTimeout(() => controller.abort(), ms);
19
- return { signal: controller.signal, done: () => clearTimeout(timer) };
20
- }
1
+ // vendor 自 _shared/http.js(只保留本 provider 用得上的部分;CORS/preflight 属原项目的边缘层,不带)。
2
+ export function cleanErrorText(value) {
3
+ let s = String(value === undefined || value === null ? "" : value);
4
+ s = s
5
+ .replace(/<script[\s\S]*?<\/script>/gi, " ")
6
+ .replace(/<style[\s\S]*?<\/style>/gi, " ")
7
+ .replace(/<[^>]*>/g, " ")
8
+ .replace(/[\r\n\t]+/g, " ")
9
+ .replace(/[^\S ]+/g, "")
10
+ .replace(/\s+/g, " ")
11
+ .trim();
12
+ if (s.length > 200) s = s.slice(0, 200);
13
+ return s;
14
+ }
15
+
16
+ export function timeoutSignal(ms) {
17
+ const controller = new AbortController();
18
+ const timer = setTimeout(() => controller.abort(), ms);
19
+ return { signal: controller.signal, done: () => clearTimeout(timer) };
20
+ }