Skip to content

fix(deps): mark S3 SDK peer deps as optional and raise floor#316

Open
naorpeled wants to merge 3 commits into
mainfrom
fix/peer-deps-optional-s3-sdk
Open

fix(deps): mark S3 SDK peer deps as optional and raise floor#316
naorpeled wants to merge 3 commits into
mainfrom
fix/peer-deps-optional-s3-sdk

Conversation

@naorpeled
Copy link
Copy Markdown
Collaborator

@naorpeled naorpeled commented May 30, 2026

Closes #315.

Summary

  • Mark @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner as optional peer dependencies via peerDependenciesMeta. The S3 helpers are loaded lazily in index.js (const S3 = () => require('./lib/s3-service')), so consumers who never call them shouldn't be forced to install the S3 SDK or trip npm audit on its transitives.
  • Raise the peer range floor from ^3.0.0 to ^3.980.0. The wide ^3.0.0 range let npm resolve old @aws-sdk/core versions whose transitive fast-xml-parser@4.4.1 is flagged by GHSA-6w63-h3fj-q4vw. I verified the floor empirically by installing @aws-sdk/client-s3 + @aws-sdk/s3-request-presigner at multiple versions and running npm ls fast-xml-parser --all:
@aws-sdk/client-s3 resolved fast-xml-parser
3.840.0 4.4.1 (vulnerable, direct dep of @aws-sdk/core)
3.972.0 5.2.5 (still in the affected <=5.6.0 range)
3.978.0 5.7.3 at one depth, 5.2.5 at another (vulnerable through @aws-sdk/middleware-sdk-s3 -> @aws-sdk/core@3.972.0)
3.980.0 5.7.3 only — clean
3.1057.0 (latest) 5.7.3 only — clean

Test plan

  • npm run test:unit — 478 passing, 4 skipped (unchanged)
  • npx prettier --check package.json passes
  • Manually verified the resolved fast-xml-parser tree for the new floor

The S3 SDK packages are only loaded lazily from index.js when the S3
helpers or s3Config are used, so consumers who don't use S3 should not
be required to install them. Marking them optional via
peerDependenciesMeta lets npm skip the install in that case.

The previous ^3.0.0 range also let npm resolve old @aws-sdk/core
versions whose transitive fast-xml-parser is flagged by npm audit
(GHSA-6w63-h3fj-q4vw). Raising the floor to ^3.980.0 pins the S3 SDK
to a line where every transitive @aws-sdk/core resolves a non-affected
fast-xml-parser.

Refs #315

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 30, 2026 19:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Marks the AWS S3 SDK peer dependencies as optional and raises their minimum version floor from ^3.0.0 to ^3.980.0 to avoid pulling in vulnerable transitive fast-xml-parser versions for consumers who don't use the S3 helpers.

Changes:

  • Add peerDependenciesMeta marking both S3 SDK peers as optional.
  • Raise peer version floor to ^3.980.0 to ensure clean fast-xml-parser resolution.

@naorpeled
Copy link
Copy Markdown
Collaborator Author

@copilot fix CI failures

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

@copilot fix CI failures

Fixed in commit fix(ci): add S3 SDK devDeps and node: protocol shims for Jest 26.

Two issues were causing CI failures:

  1. tsd — "Cannot find module @aws-sdk/client-s3": Marking the packages optional meant npm ci no longer installed them, but index.d.ts imports S3ClientConfig from @aws-sdk/client-s3. Fixed by adding both packages to devDependencies at ^3.980.0 (matching the peer dep floor).

  2. Jest 26 — ENOENT: node:stream: AWS SDK v3.980+ uses node: protocol imports (e.g. require('node:stream')), which Jest 26 can't resolve. Fixed by adding a moduleNameMapper (^node:(.*)$<rootDir>/__node_builtins__/$1) with small shim files that re-export the corresponding Node.js built-ins.

All 27 suites pass, 478 tests passing, 4 skipped — unchanged from baseline.

@naorpeled naorpeled force-pushed the fix/peer-deps-optional-s3-sdk branch from 2777695 to 5364e48 Compare May 31, 2026 19:22
…floor

The S3 helper tests (getLink, download, responses, sendFile) load the real
@aws-sdk/client-s3 and s3-request-presigner, so both are needed as
devDependencies for CI.

Pin to 3.470.0 (peer floor ^3.470.0): the newest line that is both
- free of the GHSA-6w63-h3fj-q4vw fast-xml-parser advisory (bundles 4.2.5,
  fixed in 4.2.4), and
- compatible with the Node 14 CI matrix entry — the modern SDK (3.9xx) emits
  `??=` logical-assignment syntax that Node 14 cannot parse, and dropped Node 14
  support at ~3.567.

This also avoids the node:-protocol imports of newer SDK lines, so no Jest
config or builtin shims are required. Full unit suite (27 suites, 478 tests)
passes unchanged on Jest 26.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@naorpeled naorpeled force-pushed the fix/peer-deps-optional-s3-sdk branch from 5364e48 to b7a3feb Compare May 31, 2026 19:28
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.

Peer deps @aws-sdk/client-s3 ^3.0.0 can resolve to vulnerable fast-xml-parser via old @aws-sdk/core

3 participants