
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
@socketsecurity/lib
Advanced tools
Core infrastructure library for Socket.dev security tools โ utilities, constants, and helpers with zero dependencies.
pnpm add @socketsecurity/lib
// Import what you need - tree-shakeable exports
import { Spinner } from '@socketsecurity/lib/spinner'
import { readJsonFile } from '@socketsecurity/lib/fs'
import { NODE_MODULES } from '@socketsecurity/lib/constants/packages'
const spinner = Spinner({ text: 'Loading...' })
spinner.start()
const pkg = await readJsonFile('./package.json')
spinner.stop()
@socketsecurity/lib
โโโ Visual Effects โ 5 themes, spinners, shimmer, logger
โโโ File System โ fs, paths, globs, temp files
โโโ Package Management โ 11 utilities (npm, pnpm, yarn, dlx)
โโโ Process & Spawn โ Safe process spawning, IPC
โโโ Environment โ 22 modules with 68 typed env getters
โโโ Constants โ 14 modules (Node.js, npm, platform)
โโโ Utilities โ Arrays, objects, strings, promises
โโโ Types โ Full TypeScript definitions
Themed spinners and text effects:
import { Spinner, setTheme } from '@socketsecurity/lib'
setTheme('ultra') // ๐ Rainbow shimmer!
const spinner = Spinner({ text: 'Processing...' })
spinner.start()
5 Built-in Themes: socket (violet) ยท sunset (twilight) ยท terracotta (warm) ยท lush (steel blue) ยท ultra (rainbow)
๐ Theme System Docs
Safe, typed file operations:
import { readJsonFile, writeJsonFile } from '@socketsecurity/lib/fs'
const pkg = await readJsonFile<PackageJson>('./package.json')
await writeJsonFile('./output.json', { data: pkg })
Parse and validate package specs:
import { parsePackageSpec } from '@socketsecurity/lib/packages'
const spec = parsePackageSpec('lodash@^4.17.0')
// { name: 'lodash', version: '^4.17.0', type: 'range', ... }
68 typed environment getters:
import { getCI } from '@socketsecurity/lib/env/ci'
import { getHome } from '@socketsecurity/lib/env/home'
import { getNodeEnv } from '@socketsecurity/lib/env/node-env'
if (getCI()) {
console.log('Running in CI')
}
Access platform and Node.js constants:
import {
NODE_MODULES,
PACKAGE_JSON,
NPM_REGISTRY_URL,
} from '@socketsecurity/lib/constants/packages'
import { DARWIN, WIN32 } from '@socketsecurity/lib/constants/platform'
import { withSpinner, Spinner } from '@socketsecurity/lib/spinner'
await withSpinner({
message: 'Installing packages...',
spinner: Spinner({ color: [140, 82, 255] }),
operation: async () => {
await installPackages()
}
})
import { spawn } from '@socketsecurity/lib/spawn'
const result = await spawn('npm', ['install'], {
cwd: '/path/to/project',
timeout: 30000
})
import { readJsonFile, writeJsonFile } from '@socketsecurity/lib/fs'
const data = await readJsonFile('./config.json')
data.version = '2.0.0'
await writeJsonFile('./config.json', data)
import { timeout, retry } from '@socketsecurity/lib/promises'
// Timeout after 5 seconds
const result = await timeout(fetchData(), 5000)
// Retry up to 3 times
const data = await retry(() => fetchData(), { maxAttempts: 3 })
120+ granular exports organized by category:
/constants/ โ Node.js, npm, platform constants
โโ packages โ PACKAGE_JSON, NODE_MODULES, etc.
โโ platform โ DARWIN, WIN32, S_IXUSR, etc.
โโ node โ NODE_VERSION, NODE_PATH, etc.
โโ time โ MILLISECONDS_PER_*, DLX_BINARY_CACHE_TTL
โโ encoding โ UTF8, CHAR_* codes
/env/ โ 22 modules providing 68 typed getters
โโ ci โ getCI() - Detect CI environment
โโ home โ getHome() - User home directory
โโ node-env โ getNodeEnv() - NODE_ENV value
โโ ... โ And 19 more modules!
/packages/ โ Package management utilities (11 modules)
โโ validation โ Package name/version validation
โโ operations โ Install, extract, manifest, dlx
โโ registry โ npm registry utilities
โโ editable โ Editable installs detection
/effects/ โ Visual effects for CLI
โโ text-shimmer โ Animated gradient text
โโ pulse-frames โ Pulsing text effect
โโ ultra โ Rainbow gradients
/stdio/ โ Terminal I/O utilities
โโ stdout โ Safe stdout operations
โโ stderr โ Safe stderr operations
โโ clear โ Clear terminal
โโ footer โ Terminal footers
/themes/ โ Theme system for consistent branding (5 modules)
โโ types โ Theme type definitions
โโ themes โ 5 themes (socket, sunset, terracotta, lush, ultra)
โโ context โ Global theme management
โโ utils โ Color resolution, theme creation
| Doc | Description |
|---|---|
| Getting Started | Quick start for contributors (5 min setup) |
| Theme System | Themed spinners, colors, and effects |
| Build Architecture | Vendored dependencies, build system |
| CLAUDE.md | Coding standards and patterns |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ @socketsecurity/lib โ
โ Zero runtime dependencies โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ src/ โ
โ โโโ constants/ 14 modules โ
โ โโโ env/ 22 modules (68 getters) โ
โ โโโ packages/ 11 utilities โ
โ โโโ effects/ 4 visual effects โ
โ โโโ stdio/ 9 I/O utilities โ
โ โโโ themes/ 5 theme definitions โ
โ โโโ external/ 16 vendored deps โ
โ โโโ ... 62+ more modules โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Build: esbuild โ CommonJS (ES2022) โ
โ Types: tsgo (TypeScript Native Preview) โ
โ Tests: Vitest (4600+ tests, 100% coverage) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
New to the project? See the Getting Started Guide for setup, workflow, and contribution guidelines.
Quick commands:
pnpm install # Install dependencies
pnpm run dev # Watch mode
pnpm test # Run tests
pnpm run fix # Auto-fix issues
Ready to contribute? Start with the Getting Started Guide for a quick setup walkthrough.
See CLAUDE.md for:
MIT
Built by Socket.dev โ socket.dev | @SocketSecurity
FAQs
Core utilities and infrastructure for Socket.dev security tools
The npm package @socketsecurity/lib receives a total of 17,236 weekly downloads. As such, @socketsecurity/lib popularity was classified as popular.
We found that @socketsecurity/lib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.