Releases: SocketDev/socket-lib
v5.7.0
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.
5.7.0 - 2026-02-12
Added
-
env: Added
isInEnv()helper function to check if an environment variable key exists, regardless of its value- Returns
trueeven for empty strings,"false","0", etc. - Follows same override resolution order as
getEnvValue()(isolated overrides → shared overrides → process.env) - Useful for detecting presence of environment variables independent of their value
- Returns
-
dlx: Added new exported helper functions
downloadBinaryFile()- Downloads a binary file from a URL to the dlx cache directoryensurePackageInstalled()- Ensures an npm package is installed and cached via ArboristgetBinaryCacheMetadataPath()- Gets the file path to dlx binary cache metadata (.dlx-metadata.json)isBinaryCacheValid()- Checks if a cached dlx binary is still valid based on TTL and timestampmakePackageBinsExecutable()- Makes npm package binaries executable on Unix systemsparsePackageSpec()- Parses npm package spec strings (e.g.,pkg@1.0.0) into name and versionresolveBinaryPath()- Resolves the absolute path to a binary within an installed packagewriteBinaryCacheMetadata()- Writes dlx binary cache metadata with integrity, size, and source info
-
releases: Added
createAssetMatcher()utility function for GitHub release asset pattern matching- Creates matcher functions that test strings against glob patterns, prefix/suffix, or RegExp
- Used for dynamic asset discovery in GitHub releases (e.g., matching platform-specific binaries)
Changed
- env: Updated
getCI()to useisInEnv()for more accurate CI detection- Now returns
truewhenever theCIkey exists in the environment, not just when truthy - Matches standard CI detection behavior where the presence of the key (not its value) indicates a CI environment
- Now returns
Fixed
-
github: Fixed JSON parsing crash vulnerability by adding try-catch around
JSON.parse()in GitHub API responses- Prevents crashes on malformed, incomplete, or binary responses
- Error messages now include the response URL for better debugging
-
dlx/binary: Fixed clock skew vulnerabilities in cache validation
- Cache entries with future timestamps (clock skew) are now treated as expired
- Metadata writes now use atomic write-then-rename pattern to prevent corruption
- Added TOCTOU race protection by re-checking binary existence after metadata read
-
dlx/cache cleanup: Fixed handling of future timestamps during cache cleanup
- Entries with future timestamps (due to clock skew) are now properly treated as expired
-
dlx/package: Fixed scoped package parsing bug where
@scope/packagewas incorrectly parsed- Changed condition from
startsWith('@')toatIndex === 0for more precise detection - Fixes installation failures for scoped packages like
@socketregistry/lib
- Changed condition from
-
cache-with-ttl: Added clock skew detection to TTL cache
- Far-future
expiresAtvalues (>2x TTL) are now treated as expired - Protects against cache poisoning from clock skew
- Far-future
-
packages/specs: Fixed unconditional
.gittruncation in Git URL parsing- Now only removes
.gitsuffix when URL actually ends with.git - Prevents incorrect truncation of URLs containing
.gitin the middle
- Now only removes
-
releases/github: Fixed TOCTOU race condition in binary download verification
- Re-checks binary existence after reading version file
- Ensures binary is re-downloaded if missing despite version file presence
-
provenance: Fixed incorrect package name in provenance workflow
- Changed from
@socketregistry/libto@socketsecurity/lib
- Changed from
5.6.0 - 2026-02-08
Added
- http-request: Added automatic default headers for JSON and text requests
httpJson()now automatically setsAccept: application/jsonheaderhttpJson()automatically setsContent-Type: application/jsonwhen body is presenthttpText()now automatically setsAccept: text/plainheaderhttpText()automatically setsContent-Type: text/plainwhen body is present- User-provided headers always override defaults
- Simplifies API usage - no need to manually set common headers
Changed
- http-request: Renamed HTTP helper functions to support all HTTP methods (BREAKING CHANGE)
httpGetJson()→httpJson()- Now supports GET, POST, PUT, DELETE, PATCH, etc.httpGetText()→httpText()- Now supports all HTTP methods viamethodoption- Functions now accept
methodparameter in options (defaults to 'GET') - More flexible API that matches modern fetch-style conventions
- Migration: Replace
httpGetJson()calls withhttpJson()andhttpGetText()withhttpText()
Fixed
- http-request: Fixed Content-Type header incorrectly sent with empty string body
- Empty string body (
"") no longer triggers Content-Type header - Changed condition from
if (body !== undefined)toif (body)for semantic correctness - Empty string represents "no content" and should not declare a Content-Type
- Affects
httpJson()andhttpText()functions - Fixes potential API compatibility issues with servers expecting no Content-Type for empty bodies
- Added comprehensive test coverage for empty string edge case
- Empty string body (
5.5.3 - 2026-01-20
Fixed
- deps: Added patch for execa@2.1.0 to fix signal-exit v4 compatibility. The package was using default import syntax with signal-exit v4, which now exports onExit as a named export.
5.5.2 - 2026-01-20
Changed
- dlx/package: Use
getSocketCacacheDir()instead ofgetPacoteCachePath()for Arborist cache configuration- Ensures consistent use of Socket's shared cacache directory (
~/.socket/_cacache) - Removes dependency on pacote cache path extraction which could fail
- Simplifies cache configuration by using reliable Socket path utility
- Ensures consistent use of Socket's shared cacache directory (
5.5.1 - 2026-01-12
Fixed
- Fixed dotenvx compatibility with pre-commit hooks
- Fixed empty releases being returned when finding latest release
5.5.0 - 2026-01-12
Added
- dlx/detect: Executable type detection utilities for DLX cache and local file paths
detectDlxExecutableType(): Detects Node.js packages vs native binaries in DLX cache by checking for node_modules/ directorydetectExecutableType(): Generic entry point that routes to appropriate detection strategydetectLocalExecutableType(): Detects executables on local filesystem by checking package.json bin field or file extensionisJsFilePath(): Validates if a file path has .js, .mjs, or .cjs extensionisNativeBinary(): Simplified helper that returns true for native binary executablesisNodePackage(): Simplified helper that returns true for Node.js packages
Fixed
- releases/github: Sort releases by published_at to reliably find latest release instead of relying on creation order
5.4.1 - 2026-01-10
Fixed
- build: Removed debug module stub to bundle real debug package. The stub was missing
enable()anddisable()methods, causing errors when downstream projects re-bundled the lib.
5.4.0 - 2026-01-07
Added
-
releases/github: Extended release functions to accept glob patterns for asset discovery
getReleaseAssetUrl()now accepts glob patterns:'yoga-sync-*.mjs','models-*.tar.gz'downloadReleaseAsset()now accepts glob patterns for automatic asset discoverygetLatestRelease()now accepts asset patterns to find releases with matching assets- Supports wildcards, brace expansion, RegExp patterns, and prefix/suffix objects
- Uses picomatch for robust glob pattern matching
-
releases/socket-btm: Extended
downloadSocketBtmRelease()to accept glob patternsassetparameter now accepts wildcards:'yoga-sync-*.mjs','models-*.tar.gz'- Automatically discovers and downloads latest matching asset
- Eliminates need for hardcoded asset names in build scripts
5.3.0 - 2026-01-07
Added
-
releases/socket-btm: Exported helper functions for external use
detectLibc(): Detect musl vs glibc on Linux systemsgetBinaryAssetName(): Get GitHub asset name for platform/archgetBinaryName(): Get binary filename with platform-appropriate extensiongetPlatformArch(): Get platform-arch identifier for directory structure
-
releases/github: Exported
getAuthHeaders()for GitHub API authentication- Returns headers with
Accept,X-GitHub-Api-Version, and optionalAuthorization - Checks
GH_TOKENandGITHUB_TOKENenvironment variables
- Returns headers with
5.2.1 - 2026-01-06
Fixed
- releases: Fixed "Text file busy" errors when executing downloaded binaries
- Changed
downloadGitHubRelease()to use synchronouschmodSync()instead of asyncchmod() - Ensures file system operations complete before binary execution
- Prevents race conditions in CI/CD environments where async operations may not fully flush to disk
- Changed
5.2.0 - 2026-01-06
Added
- releases: Added GitHub release download uti...