Skip to content

Releases: SocketDev/socket-lib

v6.0.9

19 Jun 13:17
Immutable release. Only release title and notes can be modified.
31b4d7c

Choose a tag to compare

Added

  • external-tools/uv — uv resolver. Resolves Astral's uv Python package manager across three tiers (embedded VFS, then system PATH, then a downloaded GitHub release), matching the shape of the other external-tools/* tool resolvers. Exports resolveUv, ResolvedUv, UvSource, plus the per-platform asset map and download helpers.
  • external-tools/python/uv-install — reproducible uv-project install helpers. uvSyncProject installs a uv project at its exact pinned versions and refuses to proceed when those have drifted, so every machine gets the same result. uvExportMaterialize installs the same pinned versions into a content-addressed directory with no virtualenv, so the result is relocatable and embeddable in a single-file build. Concurrent callers serialize so two installs can't collide. The Python analog of the npm dlx install model.
  • external-tools/skillspector — pinned-project resolution tier. skillspectorFromUv installs SkillSpector from a fully pinned uv project (every version fixed) and returns its entry point, resolved ahead of the existing git-SHA fallback when a project directory and uv binary are supplied. Adds a 'uv' source to the resolution result.
  • config/layers — generic layered-config reader. readConfigLayers(name, { dirs }) reads a named config file from an ordered list of layer directories (lowest precedence first) and returns the layers that exist; absent or unparseable layers are skipped. mergeConfigArray concatenates one array-valued key across all layers, for lists that higher layers extend rather than replace. It carries no project-convention knowledge: the caller supplies the directories and the merge policy.
  • paths_wheelhouse tool-layout dirs and the agent-clone dir. getSocketRackDir and getSocketRackToolDir locate the racked tool store, getSocketWheelhouseBinDir the PATH-handle directory that points into it, and getSocketRepoClonesDir the directory where agents clone external repos for reference (kept out of the projects tree so sibling-walking tooling never treats a clone as a fleet member).
  • ai — offline/gated-model detection and fall-over. spawnTierWithFallback walks a tier's cross-engine equivalence chain and runs the first engine that is both installed and authenticated, so a request still completes when the preferred model is down, gated, or unkeyed. isModelUnavailable recognizes a down-or-gated model from the engine's actual output rather than a brittle literal-string match. The ai/route resolver and ai/subagent-status reader are exposed as their own entry points.
  • fs/copy — recursive copy with three destination modes. copy(from, to, { mode }) copies a file or directory tree. CopyMode chooses how an existing destination is treated: 'overlay' (the default: overwrite collisions, keep destination-only files), 'pave' (the destination becomes an exact mirror of the source via an atomic sibling-temp-then-rename swap, so no stale files survive and a partial tree is never observed), or 'fill' (no-clobber: add only what is missing, never overwrite). Also accepts filter, dereference, and an abort signal.
  • node/requireFrom — relative require bound to the caller's directory. requireFrom(fromUrl, specifier) resolves a relative specifier (./x, ../y) from the caller's own directory, passed as import.meta.url, so relative loads bind to the right base when modules run unbundled (for example AOT-compiled from source, where each module sits at its own nested path). Builtins and bare packages resolve as before.
  • secrets — proteus broker credential tier. The credential resolver gains a broker layer in the documented order (explicit, then env, then broker, then keychain): it connects to the broker's runtime socket, requests the value, and self-gates. No socket means no broker, so it returns undefined and falls through to the keychain. Async only (absent from resolveSync) and skipped under allowEnvOnly. Existing resolveProviderCredential call sites are unchanged.
  • pathsgetRuntimeSocketPath and getXdgRuntimeDir for daemon sockets. One resolver a daemon and its clients both call to locate a runtime socket: the XDG runtime dir when present, a $TMPDIR/<name>-<uid> fallback, or a named pipe on Windows.
  • llms.txt — discovery index for AI agents. pnpm run docs now also emits a publish-safe llms.txt at the package root that links each export subpath to its shipped .d.mts declaration, giving an agent one file to read after installing. It ships in the published tarball.
  • packages/manifesttrimPublishManifest. Returns a shallow copy of a package.json that omits dev/build-only top-level fields (devDependencies, scripts by default) so a published tarball and its npm metadata stay lean. drop overrides the field set; keep retains a field even when dropped (e.g. a runtime postinstall). The original object is left intact.

Changed

  • integrity — one Hash currency (breaking). Hashes are modeled as a single concept, a Hash carrying algorithm, hex, and sri, rather than an integrity-vs-checksum type duality, so the algorithm is explicit on every value. Adds parseHash (encoding- and length-aware), computeHash (sha512 default), verifyHash(bytes, expected) (verifies against the expected hash's declared algorithm), equalHashes (encoding-agnostic, and never equal across algorithms), makeHash, and HashMismatchError. Breaking: verifyHash now takes (bytes, expected), not (expected, computed), and DlxHashMismatchError is a deprecated alias of HashMismatchError. Back-compat shims remain: checksumToIntegrity, integrityToChecksum, normalizeHash, computeHashes, isChecksum, isIntegrity, parseIntegrity.
  • fleet/repo-config is now a thin wrapper over config/layers. resolveRepoConfig (the fleet default layered under a per-repo override) and mergeRepoConfigArray stay at fleet/repo-config; the generic, convention-free primitives moved to the new config/layers entry. resolveRepoConfig callers see no behavior change.

v5.7.0

12 Feb 22:48
Immutable release. Only release title and notes can be modified.

Choose a tag to compare

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 true even 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
  • dlx: Added new exported helper functions

    • downloadBinaryFile() - Downloads a binary file from a URL to the dlx cache directory
    • ensurePackageInstalled() - Ensures an npm package is installed and cached via Arborist
    • getBinaryCacheMetadataPath() - 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 timestamp
    • makePackageBinsExecutable() - Makes npm package binaries executable on Unix systems
    • parsePackageSpec() - Parses npm package spec strings (e.g., pkg@1.0.0) into name and version
    • resolveBinaryPath() - Resolves the absolute path to a binary within an installed package
    • writeBinaryCacheMetadata() - 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 use isInEnv() for more accurate CI detection
    • Now returns true whenever the CI key 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

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/package was incorrectly parsed

    • Changed condition from startsWith('@') to atIndex === 0 for more precise detection
    • Fixes installation failures for scoped packages like @socketregistry/lib
  • cache-with-ttl: Added clock skew detection to TTL cache

    • Far-future expiresAt values (>2x TTL) are now treated as expired
    • Protects against cache poisoning from clock skew
  • packages/specs: Fixed unconditional .git truncation in Git URL parsing

    • Now only removes .git suffix when URL actually ends with .git
    • Prevents incorrect truncation of URLs containing .git in the middle
  • 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/lib to @socketsecurity/lib

5.6.0 - 2026-02-08

Added

  • http-request: Added automatic default headers for JSON and text requests
    • httpJson() now automatically sets Accept: application/json header
    • httpJson() automatically sets Content-Type: application/json when body is present
    • httpText() now automatically sets Accept: text/plain header
    • httpText() automatically sets Content-Type: text/plain when 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 via method option
    • Functions now accept method parameter in options (defaults to 'GET')
    • More flexible API that matches modern fetch-style conventions
    • Migration: Replace httpGetJson() calls with httpJson() and httpGetText() with httpText()

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) to if (body) for semantic correctness
    • Empty string represents "no content" and should not declare a Content-Type
    • Affects httpJson() and httpText() functions
    • Fixes potential API compatibility issues with servers expecting no Content-Type for empty bodies
    • Added comprehensive test coverage for empty string edge case

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 of getPacoteCachePath() 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

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/ directory
    • detectExecutableType(): Generic entry point that routes to appropriate detection strategy
    • detectLocalExecutableType(): Detects executables on local filesystem by checking package.json bin field or file extension
    • isJsFilePath(): Validates if a file path has .js, .mjs, or .cjs extension
    • isNativeBinary(): Simplified helper that returns true for native binary executables
    • isNodePackage(): 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() and disable() 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 discovery
    • getLatestRelease() 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 patterns

    • asset parameter 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 systems
    • getBinaryAssetName(): Get GitHub asset name for platform/arch
    • getBinaryName(): Get binary filename with platform-appropriate extension
    • getPlatformArch(): Get platform-arch identifier for directory structure
  • releases/github: Exported getAuthHeaders() for GitHub API authentication

    • Returns headers with Accept, X-GitHub-Api-Version, and optional Authorization
    • Checks GH_TOKEN and GITHUB_TOKEN environment variables

5.2.1 - 2026-01-06

Fixed

  • releases: Fixed "Text file busy" errors when executing downloaded binaries
    • Changed downloadGitHubRelease() to use synchronous chmodSync() instead of async chmod()
    • Ensures file system operations complete before binary execution
    • Prevents race conditions in CI/CD environments where async operations may not fully flush to disk

5.2.0 - 2026-01-06

Added

  • releases: Added GitHub release download uti...
Read more