asherah 4.0.0-beta.4 → 4.0.0-beta.5
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/npm/index.js +50 -8
- package/package.json +24 -7
package/npm/index.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const os = require('os');
|
|
3
3
|
|
|
4
|
+
// Detect musl libc (Alpine Linux, etc.)
|
|
5
|
+
function isMusl() {
|
|
6
|
+
if (os.platform() !== 'linux') return false;
|
|
7
|
+
try {
|
|
8
|
+
// Node 18+: process.report.getReport() exposes glibc version
|
|
9
|
+
const report = process.report.getReport();
|
|
10
|
+
const header = typeof report === 'string' ? JSON.parse(report).header : report.header;
|
|
11
|
+
return !header.glibcVersionRuntime;
|
|
12
|
+
} catch {
|
|
13
|
+
// Fallback: check for musl dynamic linker
|
|
14
|
+
try {
|
|
15
|
+
return require('fs').readdirSync('/lib').some(f => f.startsWith('ld-musl-'));
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
4
22
|
// Determine current platform
|
|
5
23
|
function getPlatform() {
|
|
6
24
|
const type = os.platform();
|
|
@@ -11,11 +29,13 @@ function getPlatform() {
|
|
|
11
29
|
if (arch === 'arm64') return 'darwin-arm64';
|
|
12
30
|
}
|
|
13
31
|
if (type === 'linux') {
|
|
14
|
-
|
|
15
|
-
if (arch === '
|
|
32
|
+
const libc = isMusl() ? 'musl' : 'gnu';
|
|
33
|
+
if (arch === 'x64') return `linux-x64-${libc}`;
|
|
34
|
+
if (arch === 'arm64') return `linux-arm64-${libc}`;
|
|
16
35
|
}
|
|
17
36
|
if (type === 'win32') {
|
|
18
37
|
if (arch === 'x64') return 'win32-x64-msvc';
|
|
38
|
+
if (arch === 'arm64') return 'win32-arm64-msvc';
|
|
19
39
|
}
|
|
20
40
|
|
|
21
41
|
throw new Error(`Unsupported platform: ${type}-${arch}`);
|
|
@@ -23,17 +43,36 @@ function getPlatform() {
|
|
|
23
43
|
|
|
24
44
|
const platform = getPlatform();
|
|
25
45
|
|
|
26
|
-
//
|
|
46
|
+
// Map platform to npm package name (win32 needed a different name to avoid npm spam filter)
|
|
47
|
+
const PLATFORM_PACKAGES = {
|
|
48
|
+
'darwin-arm64': 'asherah-darwin-arm64',
|
|
49
|
+
'darwin-x64': 'asherah-darwin-x64',
|
|
50
|
+
'linux-x64-gnu': 'asherah-linux-x64-gnu',
|
|
51
|
+
'linux-arm64-gnu': 'asherah-linux-arm64-gnu',
|
|
52
|
+
'linux-x64-musl': 'asherah-linux-x64-musl',
|
|
53
|
+
'linux-arm64-musl': 'asherah-linux-arm64-musl',
|
|
54
|
+
'win32-x64-msvc': 'asherah-windows-x64',
|
|
55
|
+
'win32-arm64-msvc': 'asherah-windows-arm64',
|
|
56
|
+
};
|
|
57
|
+
const packageName = PLATFORM_PACKAGES[platform] || `asherah-${platform}`;
|
|
58
|
+
|
|
59
|
+
// Try to load the native module:
|
|
60
|
+
// 1. Installed platform package (optionalDependency) — normal npm install
|
|
61
|
+
// 2. Bundled in platform subdirectory — development / CI builds
|
|
62
|
+
// 3. Legacy single-binary fallback
|
|
63
|
+
let native = null;
|
|
64
|
+
let lastErr = null;
|
|
65
|
+
|
|
27
66
|
const attempts = [
|
|
28
|
-
// Platform
|
|
67
|
+
// Platform package installed as optionalDependency (e.g., asherah-darwin-arm64)
|
|
68
|
+
packageName,
|
|
69
|
+
// Bundled in platform subdirectory (development builds)
|
|
29
70
|
path.join(__dirname, platform, `index.${platform}.node`),
|
|
30
|
-
// Fallback to old single-binary
|
|
71
|
+
// Fallback to old single-binary locations
|
|
31
72
|
path.join(__dirname, 'asherah.node'),
|
|
32
73
|
path.join(__dirname, '..', 'index.node'),
|
|
33
74
|
];
|
|
34
75
|
|
|
35
|
-
let native = null;
|
|
36
|
-
let lastErr = null;
|
|
37
76
|
for (const candidate of attempts) {
|
|
38
77
|
try {
|
|
39
78
|
native = require(candidate);
|
|
@@ -53,7 +92,10 @@ for (const candidate of attempts) {
|
|
|
53
92
|
|
|
54
93
|
if (!native) {
|
|
55
94
|
const detail = lastErr ? `: ${lastErr.message || String(lastErr)}` : '';
|
|
56
|
-
throw new Error(
|
|
95
|
+
throw new Error(
|
|
96
|
+
`Failed to load Asherah native addon for ${platform}. ` +
|
|
97
|
+
`Ensure the platform package '${packageName}' is installed${detail}`
|
|
98
|
+
);
|
|
57
99
|
}
|
|
58
100
|
|
|
59
101
|
// --- Canonical godaddy/asherah-node compatibility layer ---
|
package/package.json
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asherah",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Asherah envelope encryption and key rotation library",
|
|
6
6
|
"main": "npm/index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"npm
|
|
9
|
+
"npm/index.js",
|
|
10
10
|
"index.d.ts",
|
|
11
11
|
"README.md",
|
|
12
12
|
"LICENSE"
|
|
13
13
|
],
|
|
14
|
+
"napi": {
|
|
15
|
+
"binaryName": "index",
|
|
16
|
+
"targets": [
|
|
17
|
+
"x86_64-apple-darwin",
|
|
18
|
+
"aarch64-apple-darwin",
|
|
19
|
+
"x86_64-unknown-linux-gnu",
|
|
20
|
+
"aarch64-unknown-linux-gnu",
|
|
21
|
+
"x86_64-unknown-linux-musl",
|
|
22
|
+
"aarch64-unknown-linux-musl",
|
|
23
|
+
"x86_64-pc-windows-msvc",
|
|
24
|
+
"aarch64-pc-windows-msvc"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
14
27
|
"scripts": {
|
|
15
28
|
"build": "napi build",
|
|
16
29
|
"build:release": "napi build --release",
|
|
17
|
-
"prepublishOnly": "napi prepublish -t npm",
|
|
18
30
|
"test": "node test/roundtrip.js",
|
|
19
31
|
"test:bun": "bun test/roundtrip.js"
|
|
20
32
|
},
|
|
@@ -25,8 +37,13 @@
|
|
|
25
37
|
"node": ">= 18"
|
|
26
38
|
},
|
|
27
39
|
"optionalDependencies": {
|
|
28
|
-
"asherah-
|
|
29
|
-
"asherah-darwin-x64": "4.0.0-beta.
|
|
30
|
-
"asherah-linux-x64-gnu": "4.0.0-beta.
|
|
40
|
+
"asherah-darwin-arm64": "4.0.0-beta.5",
|
|
41
|
+
"asherah-darwin-x64": "4.0.0-beta.5",
|
|
42
|
+
"asherah-linux-x64-gnu": "4.0.0-beta.5",
|
|
43
|
+
"asherah-linux-arm64-gnu": "4.0.0-beta.5",
|
|
44
|
+
"asherah-linux-x64-musl": "4.0.0-beta.5",
|
|
45
|
+
"asherah-linux-arm64-musl": "4.0.0-beta.5",
|
|
46
|
+
"asherah-windows-x64": "4.0.0-beta.5",
|
|
47
|
+
"asherah-windows-arm64": "4.0.0-beta.5"
|
|
31
48
|
}
|
|
32
|
-
}
|
|
49
|
+
}
|