@socketsecurity/lib 5.1.0 → 5.1.1
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/CHANGELOG.md +16 -0
- package/dist/paths/socket.d.ts +29 -12
- package/dist/paths/socket.js +23 -28
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [5.1.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.1.1) - 2025-12-28
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **paths**: Added `SOCKET_HOME` environment variable support to customize Socket base directory
|
|
13
|
+
- `getSocketUserDir()` now checks `SOCKET_HOME` before defaulting to `~/.socket`
|
|
14
|
+
- `getSocketDlxDir()` inherits `SOCKET_HOME` support (priority: `SOCKET_DLX_DIR` > `SOCKET_HOME/_dlx` > `~/.socket/_dlx`)
|
|
15
|
+
- Enables flexible directory configuration for restricted or custom environments
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **paths**: Enhanced directory resolution with temporary directory fallback
|
|
20
|
+
- `getUserHomeDir()` now falls back to `os.tmpdir()` when home directory is unavailable
|
|
21
|
+
- Improves resilience in containerized and restricted environments
|
|
22
|
+
- Priority order: `HOME` > `USERPROFILE` > `os.homedir()` > `os.tmpdir()`
|
|
23
|
+
|
|
8
24
|
## [5.1.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.1.0) - 2025-12-17
|
|
9
25
|
|
|
10
26
|
### Added
|
package/dist/paths/socket.d.ts
CHANGED
|
@@ -15,7 +15,14 @@ export declare function getOsTmpDir(): string;
|
|
|
15
15
|
export declare function getSocketHomePath(): string;
|
|
16
16
|
/**
|
|
17
17
|
* Get the Socket user directory (~/.socket).
|
|
18
|
-
*
|
|
18
|
+
* Can be overridden with SOCKET_HOME environment variable or via setPath() for testing.
|
|
19
|
+
* Result is cached via getPathValue for performance.
|
|
20
|
+
*
|
|
21
|
+
* Priority order:
|
|
22
|
+
* 1. Test override via setPath('socket-user-dir', ...)
|
|
23
|
+
* 2. SOCKET_HOME - Base directory override
|
|
24
|
+
* 3. Default: $HOME/.socket
|
|
25
|
+
* 4. Fallback: /tmp/.socket (Unix) or %TEMP%\.socket (Windows)
|
|
19
26
|
*/
|
|
20
27
|
export declare function getSocketUserDir(): string;
|
|
21
28
|
/**
|
|
@@ -24,13 +31,24 @@ export declare function getSocketUserDir(): string;
|
|
|
24
31
|
export declare function getSocketAppDir(appName: string): string;
|
|
25
32
|
/**
|
|
26
33
|
* Get the Socket cacache directory (~/.socket/_cacache).
|
|
27
|
-
* Can be overridden with SOCKET_CACACHE_DIR environment variable for testing.
|
|
28
|
-
* Result is
|
|
34
|
+
* Can be overridden with SOCKET_CACACHE_DIR environment variable or via setPath() for testing.
|
|
35
|
+
* Result is cached via getPathValue for performance.
|
|
36
|
+
*
|
|
37
|
+
* Priority order:
|
|
38
|
+
* 1. Test override via setPath('socket-cacache-dir', ...)
|
|
39
|
+
* 2. SOCKET_CACACHE_DIR - Full override of cacache directory
|
|
40
|
+
* 3. Default: $SOCKET_HOME/_cacache or $HOME/.socket/_cacache
|
|
29
41
|
*/
|
|
30
42
|
export declare function getSocketCacacheDir(): string;
|
|
31
43
|
/**
|
|
32
44
|
* Get the Socket DLX directory (~/.socket/_dlx).
|
|
33
|
-
* Can be overridden with
|
|
45
|
+
* Can be overridden with environment variables.
|
|
46
|
+
*
|
|
47
|
+
* Priority order:
|
|
48
|
+
* 1. SOCKET_DLX_DIR - Full override of DLX cache directory
|
|
49
|
+
* 2. SOCKET_HOME/_dlx - Base directory override (inherits from getSocketUserDir)
|
|
50
|
+
* 3. Default: $HOME/.socket/_dlx
|
|
51
|
+
* 4. Fallback: /tmp/.socket/_dlx (Unix) or %TEMP%\.socket\_dlx (Windows)
|
|
34
52
|
*/
|
|
35
53
|
export declare function getSocketDlxDir(): string;
|
|
36
54
|
/**
|
|
@@ -56,13 +74,12 @@ export declare function getSocketRegistryGithubCacheDir(): string;
|
|
|
56
74
|
/**
|
|
57
75
|
* Get the user's home directory.
|
|
58
76
|
* Uses environment variables directly to support test mocking.
|
|
59
|
-
* Falls back to
|
|
60
|
-
*/
|
|
61
|
-
export declare function getUserHomeDir(): string;
|
|
62
|
-
/**
|
|
63
|
-
* Invalidate all cached path values.
|
|
64
|
-
* Called automatically by the paths/rewire module when setPath/clearPath/resetPaths are used.
|
|
77
|
+
* Falls back to temporary directory if home is not available.
|
|
65
78
|
*
|
|
66
|
-
*
|
|
79
|
+
* Priority order:
|
|
80
|
+
* 1. HOME environment variable (Unix)
|
|
81
|
+
* 2. USERPROFILE environment variable (Windows)
|
|
82
|
+
* 3. os.homedir()
|
|
83
|
+
* 4. Fallback: os.tmpdir() (rarely used, for restricted environments)
|
|
67
84
|
*/
|
|
68
|
-
export declare function
|
|
85
|
+
export declare function getUserHomeDir(): string;
|
package/dist/paths/socket.js
CHANGED
|
@@ -41,8 +41,7 @@ __export(socket_exports, {
|
|
|
41
41
|
getSocketRegistryDir: () => getSocketRegistryDir,
|
|
42
42
|
getSocketRegistryGithubCacheDir: () => getSocketRegistryGithubCacheDir,
|
|
43
43
|
getSocketUserDir: () => getSocketUserDir,
|
|
44
|
-
getUserHomeDir: () => getUserHomeDir
|
|
45
|
-
invalidateCache: () => invalidateCache
|
|
44
|
+
getUserHomeDir: () => getUserHomeDir
|
|
46
45
|
});
|
|
47
46
|
module.exports = __toCommonJS(socket_exports);
|
|
48
47
|
var os = __toESM(require("os"));
|
|
@@ -64,34 +63,29 @@ function getOsTmpDir() {
|
|
|
64
63
|
function getSocketHomePath() {
|
|
65
64
|
return getSocketUserDir();
|
|
66
65
|
}
|
|
67
|
-
let _cachedSocketUserDir;
|
|
68
66
|
function getSocketUserDir() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
return (0, import_rewire.getPathValue)("socket-user-dir", () => {
|
|
68
|
+
const socketHome = (0, import_socket2.getSocketHome)();
|
|
69
|
+
if (socketHome) {
|
|
70
|
+
return (0, import_normalize.normalizePath)(socketHome);
|
|
71
|
+
}
|
|
72
|
+
return (0, import_normalize.normalizePath)(path.join(getUserHomeDir(), import_dirnames.DOT_SOCKET_DIR));
|
|
73
|
+
});
|
|
75
74
|
}
|
|
76
75
|
function getSocketAppDir(appName) {
|
|
77
76
|
return (0, import_normalize.normalizePath)(
|
|
78
77
|
path.join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}${appName}`)
|
|
79
78
|
);
|
|
80
79
|
}
|
|
81
|
-
let _cachedSocketCacacheDir;
|
|
82
80
|
function getSocketCacacheDir() {
|
|
83
|
-
|
|
81
|
+
return (0, import_rewire.getPathValue)("socket-cacache-dir", () => {
|
|
84
82
|
if ((0, import_socket2.getSocketCacacheDir)()) {
|
|
85
|
-
|
|
86
|
-
(0, import_socket2.getSocketCacacheDir)()
|
|
87
|
-
);
|
|
88
|
-
} else {
|
|
89
|
-
_cachedSocketCacacheDir = (0, import_normalize.normalizePath)(
|
|
90
|
-
path.join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
|
|
91
|
-
);
|
|
83
|
+
return (0, import_normalize.normalizePath)((0, import_socket2.getSocketCacacheDir)());
|
|
92
84
|
}
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
return (0, import_normalize.normalizePath)(
|
|
86
|
+
path.join(getSocketUserDir(), `${import_socket.SOCKET_APP_PREFIX}cacache`)
|
|
87
|
+
);
|
|
88
|
+
});
|
|
95
89
|
}
|
|
96
90
|
function getSocketDlxDir() {
|
|
97
91
|
if ((0, import_socket2.getSocketDlxDirEnv)()) {
|
|
@@ -130,13 +124,15 @@ function getUserHomeDir() {
|
|
|
130
124
|
if (userProfile) {
|
|
131
125
|
return userProfile;
|
|
132
126
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
127
|
+
try {
|
|
128
|
+
const osHome = getOsHomeDir();
|
|
129
|
+
if (osHome) {
|
|
130
|
+
return osHome;
|
|
131
|
+
}
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
return getOsTmpDir();
|
|
138
135
|
}
|
|
139
|
-
(0, import_rewire.registerCacheInvalidation)(invalidateCache);
|
|
140
136
|
// Annotate the CommonJS export names for ESM import in node:
|
|
141
137
|
0 && (module.exports = {
|
|
142
138
|
getOsHomeDir,
|
|
@@ -151,6 +147,5 @@ function invalidateCache() {
|
|
|
151
147
|
getSocketRegistryDir,
|
|
152
148
|
getSocketRegistryGithubCacheDir,
|
|
153
149
|
getSocketUserDir,
|
|
154
|
-
getUserHomeDir
|
|
155
|
-
invalidateCache
|
|
150
|
+
getUserHomeDir
|
|
156
151
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/lib",
|
|
3
|
-
"version": "5.1.
|
|
4
|
-
"packageManager": "pnpm@10.26.
|
|
3
|
+
"version": "5.1.1",
|
|
4
|
+
"packageManager": "pnpm@10.26.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Core utilities and infrastructure for Socket.dev security tools",
|
|
7
7
|
"keywords": [
|
|
@@ -714,7 +714,7 @@
|
|
|
714
714
|
"@socketregistry/is-unicode-supported": "1.0.5",
|
|
715
715
|
"@socketregistry/packageurl-js": "1.3.5",
|
|
716
716
|
"@socketregistry/yocto-spinner": "1.0.25",
|
|
717
|
-
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.0
|
|
717
|
+
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.1.0",
|
|
718
718
|
"@types/node": "24.9.2",
|
|
719
719
|
"@typescript/native-preview": "7.0.0-dev.20250920.1",
|
|
720
720
|
"@vitest/coverage-v8": "4.0.3",
|