Skip to content

chore: bump version to 4.0.0#562

Closed
John-David Dalton (jdalton) wants to merge 6 commits intomainfrom
release/v4.0.0
Closed

chore: bump version to 4.0.0#562
John-David Dalton (jdalton) wants to merge 6 commits intomainfrom
release/v4.0.0

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

@jdalton John-David Dalton (jdalton) commented Apr 7, 2026

Summary

Bump version to 4.0.0 with comprehensive breaking changes, performance improvements, and dependency cleanup.

Breaking Changes

  • HTTP client refactored: All HTTP methods return HttpResponse from @socketsecurity/lib/http-request instead of IncomingMessage
  • Unified HTTP transport: File uploads migrated from node:http/getResponse() to httpRequest() — single transport stack
  • Trimmed public API: Removed internal helpers, utilities, and constants from main entry point (use source imports)
  • Removed: getHttpModule, getResponse, getSupportedScanFiles(), PromiseQueue
  • Removed deps: @socketregistry/packageurl-js (unused), http2-wrapper (replaced by native node:http2)

Performance (-471 lines, net)

  • NDJSON: .split('\n') → single-pass linear scan (4 locations)
  • queryToSearchParams: avoid double URLSearchParams instantiation
  • sanitizeHeaders: deferred behind if guards (6 locations)
  • batchPackageStream: findIndex+spliceMap for O(1) operations
  • Alert processing: filter+map → single-pass reduce

Test plan

  • pnpm build passes
  • pnpm test — 20 test files, 568 tests pass
  • Pre-commit hooks pass (lint, type check, full test suite)
  • Verify changelog accuracy

Breaking changes:
- Remove unused @socketregistry/packageurl-js dependency
- Remove deprecated getSupportedScanFiles() (use getSupportedFiles())
- Unify file-upload onto httpRequest() transport, remove getHttpModule/getResponse
- Replace http2-wrapper type with native node:http2 ClientHttp2Session
- Trim public API surface: remove internal helpers, utilities, and constants from exports
- Remove http2-wrapper devDependency

Performance:
- NDJSON linear scan replaces .split('\n') in 4 locations
- queryToSearchParams avoids double URLSearchParams instantiation
- sanitizeHeaders deferred behind if guards (6 locations)
- batchPackageStream generator queue uses Map for O(1) operations
- Alert filter+map replaced with single-pass reduce
Bug fixes:
- Fix streamFullScan using MAX_STREAM_SIZE (100MB) instead of
  MAX_RESPONSE_SIZE (10MB) when buffering response in memory
- Add missing maxResponseSize to createUploadRequest

Performance:
- Cache reqOptionsWithHooks object — eliminates 60 object spreads per
  session (one per API method call)
- Precompute allowedActions as Set in reshapeArtifactForPublicPolicy
  for O(1) membership checks instead of Array.includes O(n)

Dead code removal:
- Remove unused getErrorResponseBody (was just response.text() wrapper)
- Remove unused createRequestBodyForJson (never called)
- Remove stale createUserAgentFromPkgJson re-export from utils.ts
FormData is a pipeable Stream with getHeaders() for multipart boundary.
httpRequest from lib duck-types getHeaders() to auto-merge Content-Type.
- Fix test description: "IncomingMessage" → "HttpResponse" in getApi tests
- Add hook deferral tests: verify hooks/sanitizeHeaders not called when absent
- Add queryToSearchParams early-return path test (no normalization needed)
- Add allowedActions Set exact-match test (spaces in comma-separated values)
- Fix stale comment referencing removed getErrorResponseBody
The pre-commit formatter reverted all v4 source changes during
subsequent commits. This restores the correct state with all v4
breaking changes, perf optimizations, and test updates intact.
@jdalton
Copy link
Copy Markdown
Contributor Author

Superseded by #564 (code changes) + #565 (version bump + changelog). Split for independent review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant