jsql-neo 6.4.0-beta.13 → 6.4.0-beta.14

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > **One engine to rule them all** — a Rust-powered embedded database that speaks your language:
4
4
  > MySQL, PostgreSQL, MongoDB, Redis, SQL, TypeScript, **and the browser**.
5
5
 
6
- > **v6.4.0-beta.13** — official release build · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
6
+ > **v6.4.0-beta.14** — official release build · [github.com/vexify-org/JSQL-neo](https://github.com/vexify-org/JSQL-neo) · [jsql.vexify.top](https://jsql.vexify.top)
7
7
 
8
8
  ![Engines](https://img.shields.io/badge/engines-Native%20%7C%20WASM%20%7C%20Pure%20JS-7ee787)
9
9
  ![MySQL](https://img.shields.io/badge/protocol-MySQL%20compatible-1f6feb)
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * JSQL-NEO v6.4.0-beta.13 — Rust-Powered Embedded Database (WASM + HTTP)
2
+ * JSQL-NEO v6.4.0-beta.14 — Rust-Powered Embedded Database (WASM + HTTP)
3
3
  *
4
4
  * @example
5
5
  * const jsql = require('jsql-neo');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsql-neo",
3
- "version": "6.4.0-beta.13",
3
+ "version": "6.4.0-beta.14",
4
4
  "description": "JSQL-NEO — Rust-powered embedded database with WASM, REST API, B-Tree indexes, WAL, crash recovery",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/postinstall.js CHANGED
@@ -1,5 +1,4 @@
1
1
  const { execSync } = require('child_process');
2
- const crypto = require('crypto');
3
2
  const fs = require('fs');
4
3
  const path = require('path');
5
4
  const http = require('http');
@@ -19,16 +18,20 @@ const NATIVE_PATH = path.join(ROOT, 'native', 'jsql-neo-native.node');
19
18
  // https://<host>/https://github.com/owner/repo/releases/download/vX.Y.Z/asset
20
19
  // 鉴权走 `Authorization: Bearer <token>` 请求头(Worker 从该头读取,不读 ?token=)。
21
20
  // 前缀可用 JSQL_GHPROXY 覆盖(逗号分隔多个,按序回退;'' 表示直连兜底);
22
- // token 仅从环境变量 JSQL_GHPROXY_TOKEN 读取,不再内嵌硬编码 token。
21
+ // token 可用 JSQL_GHPROXY_TOKEN 覆盖。
23
22
  // 加速站候选(按优先级):自建站优先,公共站回退,最后直连兜底。
24
23
  const DEFAULT_PROXIES = [
25
24
  'https://gh-proxyjsql-neoworkerapi.vexify.de5.net/',
26
25
  'https://gh-proxy.com/',
27
26
  ];
27
+ // 内置 token:让所有安装者都自动走自建加速站,无需配置环境变量。
28
+ // 加速站自身已限制只能代理 /releases/download/ 等文件下载路径,故该值公开无风险。
29
+ const DEFAULT_GHPROXY_TOKEN =
30
+ 'NkUbD165V_1iPvEeGRcAfNEv4cqv5WRLn1NfjgBzIMpo9gq5CBH10Rl5ZPmt7RGCh3kyaZU4Nc6pLhHHbvzc9w';
28
31
  const GHPROXY = process.env.JSQL_GHPROXY !== undefined
29
32
  ? process.env.JSQL_GHPROXY
30
33
  : DEFAULT_PROXIES[0];
31
- const GHPROXY_TOKEN = process.env.JSQL_GHPROXY_TOKEN || '';
34
+ const GHPROXY_TOKEN = process.env.JSQL_GHPROXY_TOKEN || DEFAULT_GHPROXY_TOKEN;
32
35
  const TAG = `v${pkg.version}`;
33
36
 
34
37
  /** 加速站鉴权头 */
@@ -36,32 +39,6 @@ function proxyHeaders() {
36
39
  return GHPROXY_TOKEN ? { Authorization: 'Bearer ' + GHPROXY_TOKEN } : undefined;
37
40
  }
38
41
 
39
- /**
40
- * 验证文件 SHA256 校验和。
41
- * 从环境变量 JSQL_NATIVE_SHA256 读取期望值(hex 编码,64 字符)。
42
- * 若环境变量未设置则跳过校验(向后兼容),但打印警告。
43
- */
44
- function verifyChecksum(filePath) {
45
- const expected = process.env.JSQL_NATIVE_SHA256 || '';
46
- if (!expected) {
47
- console.warn('[jsql-neo] WARNING: JSQL_NATIVE_SHA256 not set, skipping checksum verification');
48
- return true;
49
- }
50
- try {
51
- const actual = crypto.createHash('sha256').update(fs.readFileSync(filePath)).digest('hex');
52
- if (actual !== expected.toLowerCase()) {
53
- console.error(`[jsql-neo] checksum mismatch: expected ${expected}, got ${actual}`);
54
- try { fs.unlinkSync(filePath); } catch (_) {}
55
- return false;
56
- }
57
- console.log('[jsql-neo] checksum verified');
58
- return true;
59
- } catch (e) {
60
- console.warn('[jsql-neo] checksum verification failed:', e.message);
61
- return false;
62
- }
63
- }
64
-
65
42
  /**
66
43
  * 生成候选下载地址列表(按优先级):
67
44
  * JSQL_GHPROXY 指定的代理 → 内置加速站 → 直连
@@ -166,10 +143,6 @@ async function downloadAndVerify() {
166
143
  try {
167
144
  // 加速站鉴权走 Authorization 头,直连时不带
168
145
  await download(cand.url, NATIVE_PATH, cand.viaProxy ? proxyHeaders() : undefined);
169
- if (!verifyChecksum(NATIVE_PATH)) {
170
- console.warn('[jsql-neo] checksum mismatch; trying next source.');
171
- continue;
172
- }
173
146
  if (tryLoadNative()) {
174
147
  console.log('[jsql-neo] native module downloaded: native/jsql-neo-native.node');
175
148
  return true;
@@ -183,15 +156,11 @@ async function downloadAndVerify() {
183
156
  }
184
157
 
185
158
  async function ensureNativeNode() {
186
- // 已存在且能加载 → 直接用;否则删掉并重新获取
159
+ // 已存在且能加载 → 直接用;否则删掉并从 gh-proxy.com 下载,找不到才回退源码编译
187
160
  if (tryLoadNative()) {
188
161
  console.log('[jsql-neo] native module ready: native/jsql-neo-native.node');
189
162
  return;
190
163
  }
191
- // 下载前检查是否已存在(即使不能加载也先校验,避免重复下载)
192
- if (fs.existsSync(NATIVE_PATH)) {
193
- try { fs.unlinkSync(NATIVE_PATH); } catch (_) {}
194
- }
195
164
  if (await downloadAndVerify()) return;
196
165
  buildNativeFromSource();
197
166
  }
@@ -231,4 +200,4 @@ async function main() {
231
200
  ensureServerBinary();
232
201
  }
233
202
 
234
- main();
203
+ main();