@eric8810/catcher-napi-http
Advanced tools
+22
-9
@@ -49,18 +49,31 @@ "use strict"; | ||
| } | ||
| function isMusl() { | ||
| const report = typeof process.report?.getReport === "function" ? process.report.getReport() : null; | ||
| if (report?.header?.glibcVersionRuntime) return false; | ||
| try { | ||
| const lddPath = require("child_process").execSync("which ldd", { encoding: "utf8" }).trim(); | ||
| return require("fs").readFileSync(lddPath, "utf8").includes("musl"); | ||
| } catch { | ||
| return true; | ||
| } | ||
| } | ||
| function getAbi() { | ||
| if (process.env.npm_config_libc) return process.env.npm_config_libc; | ||
| const platform = import_os.default.platform(); | ||
| if (platform === "win32") return "msvc"; | ||
| if (platform === "linux") return isMusl() ? "musl" : "gnu"; | ||
| return ""; | ||
| } | ||
| function loadNativeAddon(pkgName) { | ||
| const platform = import_os.default.platform(); | ||
| const arch = import_os.default.arch(); | ||
| const libc = process.env.npm_config_libc ?? (platform === "linux" ? "gnu" : ""); | ||
| const abi = getAbi(); | ||
| const platformKey = abi ? `${platform}-${arch}-${abi}` : `${platform}-${arch}`; | ||
| const root = import_path.default.join(__dirname, ".."); | ||
| const subPkg = tryRequire(`@eric8810/${pkgName}-${platformKey}`); | ||
| if (subPkg) return subPkg; | ||
| const napiJs = tryRequire(import_path.default.join(root, "index.js")); | ||
| if (napiJs) return napiJs; | ||
| const libName = pkgName.replace(/-/g, "_"); | ||
| const addon = ( | ||
| // npm/ 目录:linux-x64-gnu / darwin-arm64 / win32-x64-msvc | ||
| tryRequire(import_path.default.join(root, "npm", `${platform}-${arch}${libc ? "-" + libc : ""}`, `${pkgName}.node`)) ?? // 根目录:完整 triple 命名 (napi prepublish 新格式) | ||
| tryRequire(import_path.default.join(root, `${pkgName}.${platform}-${arch}${libc ? "-" + libc : ""}.node`)) ?? // 根目录:旧格式 platform-arch (无 libc 后缀) | ||
| tryRequire(import_path.default.join(root, `${pkgName}.${platform}-${arch}.node`)) ?? // 根目录:无平台后缀 | ||
| tryRequire(import_path.default.join(root, `${pkgName}.node`)) ?? // cargo build 产物 | ||
| tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.so`)) ?? tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.dylib`)) ?? tryRequire(import_path.default.join(root, "target", "release", `${libName}.dll`)) | ||
| ); | ||
| const addon = tryRequire(import_path.default.join(root, `${pkgName}.${platformKey}.node`)) ?? tryRequire(import_path.default.join(root, `${pkgName}.${platform}-${arch}.node`)) ?? tryRequire(import_path.default.join(root, `${pkgName}.node`)) ?? tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.so`)) ?? tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.dylib`)) ?? tryRequire(import_path.default.join(root, "target", "release", `${libName}.dll`)); | ||
| if (!addon) { | ||
@@ -67,0 +80,0 @@ throw new Error( |
+22
-9
@@ -50,18 +50,31 @@ "use strict"; | ||
| } | ||
| function isMusl() { | ||
| const report = typeof process.report?.getReport === "function" ? process.report.getReport() : null; | ||
| if (report?.header?.glibcVersionRuntime) return false; | ||
| try { | ||
| const lddPath = require("child_process").execSync("which ldd", { encoding: "utf8" }).trim(); | ||
| return require("fs").readFileSync(lddPath, "utf8").includes("musl"); | ||
| } catch { | ||
| return true; | ||
| } | ||
| } | ||
| function getAbi() { | ||
| if (process.env.npm_config_libc) return process.env.npm_config_libc; | ||
| const platform = import_os.default.platform(); | ||
| if (platform === "win32") return "msvc"; | ||
| if (platform === "linux") return isMusl() ? "musl" : "gnu"; | ||
| return ""; | ||
| } | ||
| function loadNativeAddon(pkgName) { | ||
| const platform = import_os.default.platform(); | ||
| const arch = import_os.default.arch(); | ||
| const libc = process.env.npm_config_libc ?? (platform === "linux" ? "gnu" : ""); | ||
| const abi = getAbi(); | ||
| const platformKey = abi ? `${platform}-${arch}-${abi}` : `${platform}-${arch}`; | ||
| const root = import_path.default.join(__dirname, ".."); | ||
| const subPkg = tryRequire(`@eric8810/${pkgName}-${platformKey}`); | ||
| if (subPkg) return subPkg; | ||
| const napiJs = tryRequire(import_path.default.join(root, "index.js")); | ||
| if (napiJs) return napiJs; | ||
| const libName = pkgName.replace(/-/g, "_"); | ||
| const addon = ( | ||
| // npm/ 目录:linux-x64-gnu / darwin-arm64 / win32-x64-msvc | ||
| tryRequire(import_path.default.join(root, "npm", `${platform}-${arch}${libc ? "-" + libc : ""}`, `${pkgName}.node`)) ?? // 根目录:完整 triple 命名 (napi prepublish 新格式) | ||
| tryRequire(import_path.default.join(root, `${pkgName}.${platform}-${arch}${libc ? "-" + libc : ""}.node`)) ?? // 根目录:旧格式 platform-arch (无 libc 后缀) | ||
| tryRequire(import_path.default.join(root, `${pkgName}.${platform}-${arch}.node`)) ?? // 根目录:无平台后缀 | ||
| tryRequire(import_path.default.join(root, `${pkgName}.node`)) ?? // cargo build 产物 | ||
| tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.so`)) ?? tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.dylib`)) ?? tryRequire(import_path.default.join(root, "target", "release", `${libName}.dll`)) | ||
| ); | ||
| const addon = tryRequire(import_path.default.join(root, `${pkgName}.${platformKey}.node`)) ?? tryRequire(import_path.default.join(root, `${pkgName}.${platform}-${arch}.node`)) ?? tryRequire(import_path.default.join(root, `${pkgName}.node`)) ?? tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.so`)) ?? tryRequire(import_path.default.join(root, "target", "release", `lib${libName}.dylib`)) ?? tryRequire(import_path.default.join(root, "target", "release", `${libName}.dll`)); | ||
| if (!addon) { | ||
@@ -68,0 +81,0 @@ throw new Error( |
+21
-8
| { | ||
| "name": "@eric8810/catcher-napi-http", | ||
| "version": "0.3.6", | ||
| "version": "0.3.7", | ||
| "description": "catcher HTTP native addon for Node.js via napi-rs", | ||
@@ -27,5 +27,3 @@ "main": "dist/client.js", | ||
| "index.js", | ||
| "index.d.ts", | ||
| "*.node", | ||
| "npm/" | ||
| "index.d.ts" | ||
| ], | ||
@@ -35,3 +33,10 @@ "napi": { | ||
| "triples": { | ||
| "defaults": true | ||
| "defaults": true, | ||
| "additional": [ | ||
| "aarch64-apple-darwin", | ||
| "x86_64-unknown-linux-musl", | ||
| "aarch64-unknown-linux-gnu", | ||
| "aarch64-unknown-linux-musl", | ||
| "aarch64-pc-windows-msvc" | ||
| ] | ||
| } | ||
@@ -51,8 +56,16 @@ }, | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "license": "MIT", | ||
| "optionalDependencies": { | ||
| "@eric8810/catcher-napi-http-win32-x64-msvc": "0.3.6", | ||
| "@eric8810/catcher-napi-http-darwin-x64": "0.3.6", | ||
| "@eric8810/catcher-napi-http-linux-x64-gnu": "0.3.6" | ||
| "@eric8810/catcher-napi-http-win32-x64-msvc": "0.3.7", | ||
| "@eric8810/catcher-napi-http-darwin-x64": "0.3.7", | ||
| "@eric8810/catcher-napi-http-linux-x64-gnu": "0.3.7", | ||
| "@eric8810/catcher-napi-http-darwin-arm64": "0.3.7", | ||
| "@eric8810/catcher-napi-http-linux-x64-musl": "0.3.7", | ||
| "@eric8810/catcher-napi-http-linux-arm64-gnu": "0.3.7", | ||
| "@eric8810/catcher-napi-http-linux-arm64-musl": "0.3.7", | ||
| "@eric8810/catcher-napi-http-win32-arm64-msvc": "0.3.7" | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
659
4.44%2
-60%33335
-99.94%8
166.67%9
-35.71%10
100%