Skip to content

deps: upgrade to aegir v48#3495

Draft
tabcat wants to merge 6 commits into
libp2p:mainfrom
tabcat:deps/aegir-v48
Draft

deps: upgrade to aegir v48#3495
tabcat wants to merge 6 commits into
libp2p:mainfrom
tabcat:deps/aegir-v48

Conversation

@tabcat
Copy link
Copy Markdown
Member

@tabcat tabcat commented May 10, 2026

Description

aegir 48 ships TypeScript 6.x with a generic Uint8Array and runs Node tests directly against .ts sources without a build step.

Changes in this PR:

  • bump aegir to ^48.0.4 across all package.json files (51)
  • rewrite ~700 relative .js imports to .ts in .ts sources — Node strip-types resolves paths literally, so .js on a TS source breaks tests when no build step has run
  • merge @libp2p/crypto's node and browser webcrypto shims into one file using globalThis.crypto — the Electron 18 workaround that motivated splitting them is obsolete now that aegir ships Electron 41/42
  • cast Uint8Array at WebCrypto / WebSocket / RTCDataChannel / X509 / WebTransport boundaries — TS 6's default Uint8Array<ArrayBufferLike> is no longer assignable to BufferSource
  • import Debugger from weald in @libp2p/logger — the ambient @types/debug namespace is no longer auto-included now that aegir restricts types: ["@types/mocha", "@types/node"]
  • implement [Symbol.dispose] / [Symbol.asyncDispose] on the OpenTelemetry generator wrappers — TS 6's Generator / AsyncGenerator interfaces require them

The bulk of the diff (~700 lines) is the mechanical .js.ts import rewrite. Code changes are concentrated in @libp2p/crypto, @libp2p/keychain, @libp2p/logger, @libp2p/metrics-opentelemetry, @libp2p/connection-encrypter-tls, @libp2p/transport-{websockets,webrtc,webtransport}.

Notes & open questions

There are 28 as Uint8Array<ArrayBuffer> casts at WebCrypto / native-API call sites. Eliminating them would require either (a) tightening the function/iterator input type (e.g. msg: Uint8Array<ArrayBuffer> | Uint8ArrayList in hashAndSign, or Uint8ArrayList itself yielding Uint8Array<ArrayBuffer> from upstream) — a breaking change for callers that currently pass a generic Uint8Array<ArrayBufferLike> — or (b) copying via new Uint8Array(buf), which adds a memcpy in hot paths (websocket/datachannel send, signing). Casts are the pragmatic answer; runtime is correct because libp2p never uses SharedArrayBuffer.

A follow-up PR will tighten @libp2p/crypto's output types (e.g. privateKeyToProtobuf) to return Uint8Array<ArrayBuffer> — non-breaking (subtype) and lets downstream consumers drop @ts-expect-error workarounds when feeding crypto outputs into native APIs like new Blob([...]).

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

tabcat and others added 2 commits May 10, 2026 15:10
aegir 48 ships TypeScript 6.x with a generic `Uint8Array` and runs Node
tests directly against `.ts` sources without a build step. Rewrite
relative `.js` imports to `.ts`, cast `Uint8Array` at WebCrypto / WebSocket
/ DataChannel / X509 boundaries, and drop the node webcrypto type leak in
@libp2p/crypto. Logger now imports `Debugger` from weald (the @types/debug
ambient namespace is no longer auto-included), and the OpenTelemetry
generator wrappers expose `[Symbol.dispose]` / `[Symbol.asyncDispose]` to
satisfy TS 6's tighter Generator interfaces.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous commit's import-rewrite script only matched `import ... from`
forms, missing bare `import './foo.js'` side-effect imports.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tabcat tabcat requested a review from a team as a code owner May 10, 2026 12:42
@tabcat tabcat marked this pull request as draft May 10, 2026 12:44
tabcat and others added 4 commits May 10, 2026 20:19
The node-side import existed only because Electron 18 lacked
`globalThis.crypto`. Aegir 48 ships Electron 41/42 (Node 22-based) so the
workaround is obsolete. Both files now collapse to a single module that
returns `globalThis.crypto`, keeping the browser-side insecure-context
check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous Symbol.dispose impl delegated to the inner iterator's
dispose without running the wrapper's return path, leaving the span
unended when callers used `using gen = ...` or called `gen.return()`
directly. return() now ends the span with OK status, and dispose funnels
through return() for consistent cleanup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts:
#	interop/package.json
#	packages/connection-encrypter-plaintext/package.json
#	packages/connection-encrypter-tls/package.json
#	packages/keychain/package.json
#	packages/libp2p-daemon-client/package.json
#	packages/logger/package.json
#	packages/metrics-opentelemetry/package.json
#	packages/metrics-prometheus/package.json
#	packages/peer-discovery-bootstrap/package.json
#	packages/peer-discovery-mdns/package.json
#	packages/protocol-autonat-v2/package.json
#	packages/protocol-autonat/package.json
#	packages/protocol-fetch/package.json
#	packages/protocol-identify/package.json
#	packages/protocol-perf/package.json
#	packages/protocol-ping/package.json
#	packages/stream-multiplexer-mplex/package.json
#	packages/transport-circuit-relay-v2/package.json
#	packages/transport-memory/package.json
#	packages/upnp-nat/package.json
@tabcat tabcat marked this pull request as ready for review May 12, 2026 15:12
@tabcat
Copy link
Copy Markdown
Member Author

tabcat commented May 12, 2026

@dozyio could split this up into separate prs, lmk

@tabcat tabcat marked this pull request as draft May 25, 2026 10:49
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