refactor: migrate to @socketsecurity/lib/primordials#71
Merged
John-David Dalton (jdalton) merged 1 commit intomainfrom Apr 27, 2026
Merged
refactor: migrate to @socketsecurity/lib/primordials#71John-David Dalton (jdalton) merged 1 commit intomainfrom
John-David Dalton (jdalton) merged 1 commit intomainfrom
Conversation
Swaps direct Error constructor usage for ErrorCtor primordial across
the core SDK source, hardening against prototype tampering on Error.
Sites converted (9):
src/compare.ts: 1 site
src/package-url.ts: 5 sites
src/purl-types/npm.ts: 3 sites
src/result.ts: 3 sites (kept `instanceof Error` runtime checks
unchanged — those need the global identity)
The browser-side files in src/pages/ that use Symbol.for() (10 sites)
are intentionally left as-is — pulling @socketsecurity/lib into the
browser bundle would add unnecessary weight for cosmetic page glue.
Also adds a `catalog:` block to pnpm-workspace.yaml so the
.claude/hooks/check-new-deps hook (which references @socketsecurity/lib
via "catalog:") resolves cleanly. Without this, pnpm install fails
with ERR_PNPM_CATALOG_ENTRY_NOT_FOUND_FOR_SPEC. socket-packageurl-js
already pins @socketsecurity/lib at 5.25.1 in root package.json, so
the catalog entry just mirrors that.
Verification:
pnpm install ✓
pnpm run check --all ✓
pnpm test ✓ all tests pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Swaps direct
Errorconstructor usage forErrorCtorprimordial across the core SDK, hardening against prototype tampering onError. Also adds acatalog:block topnpm-workspace.yamlso the existing.claude/hooks/check-new-depshook (which references@socketsecurity/libviacatalog:) resolves cleanly — pre-existing scaffolding bug.Audit
Used
prim audit(thesocket-lib/tools/primtool):node /path/to/socket-lib/tools/prim/bin/prim.mts \ audit --target . --dir src \ --surface /path/to/socket-lib/src/primordials.tsInitial audit: 19 sites total — 9
ErrorCtorin core.tsfiles, 10SymbolForin browser-sidesrc/pages/*.jsfiles.After conversion: 0 sites remain in the core; pages/ intentionally untouched.
Sites converted (9 in 4 files)
src/compare.tsError→ErrorCtorsrc/package-url.tsError→ErrorCtorsrc/purl-types/npm.tsError→ErrorCtorsrc/result.tsError→ErrorCtor(keptinstanceof Errorruntime checks unchanged — those need the global identity)Out of scope
src/pages/*.js— 10Symbol.for()sites in browser-side page glue. Pulling@socketsecurity/libinto the browser bundle would add weight for cosmetic page tokens. Skipped.Verification
Test plan