@socketsecurity/lib 5.1.0 → 5.1.2
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 +26 -0
- package/dist/paths/socket.d.ts +31 -12
- package/dist/paths/socket.js +34 -34
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ 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.2](https://github.com/SocketDev/socket-lib/releases/tag/v5.1.2) - 2025-12-28
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **paths**: Fixed missing `getPathValue()` caching in `getSocketDlxDir()`
|
|
13
|
+
- Now uses `getPathValue()` for performance, consistent with `getSocketUserDir()` and `getSocketCacacheDir()`
|
|
14
|
+
- Adds test override support via `setPath('socket-dlx-dir', ...)`
|
|
15
|
+
- Test helper `mockHomeDir()` now properly invalidates path cache with `resetPaths()` calls
|
|
16
|
+
- Resolves cache persistence issues in test environments
|
|
17
|
+
|
|
18
|
+
## [5.1.1](https://github.com/SocketDev/socket-lib/releases/tag/v5.1.1) - 2025-12-28
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **paths**: Added `SOCKET_HOME` environment variable support to customize Socket base directory
|
|
23
|
+
- `getSocketUserDir()` now checks `SOCKET_HOME` before defaulting to `~/.socket`
|
|
24
|
+
- `getSocketDlxDir()` inherits `SOCKET_HOME` support (priority: `SOCKET_DLX_DIR` > `SOCKET_HOME/_dlx` > `~/.socket/_dlx`)
|
|
25
|
+
- Enables flexible directory configuration for restricted or custom environments
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **paths**: Enhanced directory resolution with temporary directory fallback
|
|
30
|
+
- `getUserHomeDir()` now falls back to `os.tmpdir()` when home directory is unavailable
|
|
31
|
+
- Improves resilience in containerized and restricted environments
|
|
32
|
+
- Priority order: `HOME` > `USERPROFILE` > `os.homedir()` > `os.tmpdir()`
|
|
33
|
+
|
|
8
34
|
## [5.1.0](https://github.com/SocketDev/socket-lib/releases/tag/v5.1.0) - 2025-12-17
|
|
9
35
|
|
|
10
36
|
### 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,26 @@ 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 SOCKET_DLX_DIR environment variable for testing.
|
|
45
|
+
* Can be overridden with SOCKET_DLX_DIR environment variable or via setPath() for testing.
|
|
46
|
+
* Result is cached via getPathValue for performance.
|
|
47
|
+
*
|
|
48
|
+
* Priority order:
|
|
49
|
+
* 1. Test override via setPath('socket-dlx-dir', ...)
|
|
50
|
+
* 2. SOCKET_DLX_DIR - Full override of DLX cache directory
|
|
51
|
+
* 3. SOCKET_HOME/_dlx - Base directory override (inherits from getSocketUserDir)
|
|
52
|
+
* 4. Default: $HOME/.socket/_dlx
|
|
53
|
+
* 5. Fallback: /tmp/.socket/_dlx (Unix) or %TEMP%\.socket\_dlx (Windows)
|
|
34
54
|
*/
|
|
35
55
|
export declare function getSocketDlxDir(): string;
|
|
36
56
|
/**
|
|
@@ -56,13 +76,12 @@ export declare function getSocketRegistryGithubCacheDir(): string;
|
|
|
56
76
|
/**
|
|
57
77
|
* Get the user's home directory.
|
|
58
78
|
* 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.
|
|
79
|
+
* Falls back to temporary directory if home is not available.
|
|
65
80
|
*
|
|
66
|
-
*
|
|
81
|
+
* Priority order:
|
|
82
|
+
* 1. HOME environment variable (Unix)
|
|
83
|
+
* 2. USERPROFILE environment variable (Windows)
|
|
84
|
+
* 3. os.homedir()
|
|
85
|
+
* 4. Fallback: os.tmpdir() (rarely used, for restricted environments)
|
|
67
86
|
*/
|
|
68
|
-
export declare function
|
|
87
|
+
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,42 +63,42 @@ 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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
return (0, import_rewire.getPathValue)("socket-dlx-dir", () => {
|
|
92
|
+
if ((0, import_socket2.getSocketDlxDirEnv)()) {
|
|
93
|
+
return (0, import_normalize.normalizePath)((0, import_socket2.getSocketDlxDirEnv)());
|
|
94
|
+
}
|
|
95
|
+
return (0, import_normalize.normalizePath)(
|
|
96
|
+
path.join(
|
|
97
|
+
getSocketUserDir(),
|
|
98
|
+
`${import_socket.SOCKET_APP_PREFIX}${import_socket.SOCKET_DLX_APP_NAME}`
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
});
|
|
103
102
|
}
|
|
104
103
|
function getSocketAppCacheDir(appName) {
|
|
105
104
|
return (0, import_normalize.normalizePath)(path.join(getSocketAppDir(appName), import_dirnames.CACHE_DIR));
|
|
@@ -130,13 +129,15 @@ function getUserHomeDir() {
|
|
|
130
129
|
if (userProfile) {
|
|
131
130
|
return userProfile;
|
|
132
131
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
try {
|
|
133
|
+
const osHome = getOsHomeDir();
|
|
134
|
+
if (osHome) {
|
|
135
|
+
return osHome;
|
|
136
|
+
}
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
return getOsTmpDir();
|
|
138
140
|
}
|
|
139
|
-
(0, import_rewire.registerCacheInvalidation)(invalidateCache);
|
|
140
141
|
// Annotate the CommonJS export names for ESM import in node:
|
|
141
142
|
0 && (module.exports = {
|
|
142
143
|
getOsHomeDir,
|
|
@@ -151,6 +152,5 @@ function invalidateCache() {
|
|
|
151
152
|
getSocketRegistryDir,
|
|
152
153
|
getSocketRegistryGithubCacheDir,
|
|
153
154
|
getSocketUserDir,
|
|
154
|
-
getUserHomeDir
|
|
155
|
-
invalidateCache
|
|
155
|
+
getUserHomeDir
|
|
156
156
|
});
|
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.2",
|
|
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.
|
|
717
|
+
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@5.1.1",
|
|
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",
|