You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bundle shared helpers into injected scripts to avoid duplicated copies #7
src/auth-header-utils.js is the canonical home for the Authorization header helpers (hasAuthorizationHeader, fetchCallHasAuthorization, setAuthorizationOnOptions, normalizeFetchCall) and is unit-tested via Node ESM.
But src/injected.js (content script, isolated world) and src/nip98-interceptor.js (injected into page context) both duplicate the bodies inline because they run as classic scripts and can't import. Injected.js and nip98-interceptor.js also run in different global scopes, so a window.__podkeyAuthHeaderUtils cache can't be shared between them.
This means future changes to the helper logic have to be made in three places and kept in sync manually.
Proposed fix
Extend scripts/bundle.js to bundle src/injected.js and src/nip98-interceptor.js via esbuild (like background.js already is), pulling auth-header-utils.js in as an imported module. Output to .bundle.js files and point the manifest / the dynamic <script> injection at the bundled URLs.
Scope note
Not fixing in #6 because that PR is scoped to the auth-overwrite bug and this is a build-system change with its own test surface (manifest updates, script-URL changes, CI).
Still valid, with a narrower scope than when this was filed (checked at bd39ce8):
src/injected.js no longer carries copies of the helpers. Only src/nip98-interceptor.js does: four functions on main, six with Retry a signed GET/HEAD unsigned when it fails before a response (#33) #34. None has drifted from src/auth-header-utils.js (compared function by function, ignoring comments and whitespace).
The sharper reason to do it: src/auth-header-utils.js is imported by no runtime code, so test/auth-header-utils.test.js tests a module that never ships. The copies that actually run are covered only through the vm-sandbox tests.
Smallest change:
scripts/bundle.js: one more esbuild entry, src/nip98-interceptor.js to src/nip98-interceptor.bundle.js, format: 'iife'.
Replace the duplicated bodies in the interceptor with an import from ./auth-header-utils.js, keeping the __podkey_nip98_intercepted guard.
Point web_accessible_resources in manifest.json and the getURL call at src/injected.js:13 at the bundle; add it to .gitignore.
Done in 0.0.13 (a2265b7). src/nip98-interceptor.js is bundled with esbuild and imports src/auth-header-utils.js, so there is one copy and the tests run the shipped code.
Activity
jjohare commentedon Nov 28, 2026
Still valid, with a narrower scope than when this was filed (checked at bd39ce8):
src/injected.jsno longer carries copies of the helpers. Onlysrc/nip98-interceptor.jsdoes: four functions onmain, six with Retry a signed GET/HEAD unsigned when it fails before a response (#33) #34. None has drifted fromsrc/auth-header-utils.js(compared function by function, ignoring comments and whitespace).src/auth-header-utils.jsis imported by no runtime code, sotest/auth-header-utils.test.jstests a module that never ships. The copies that actually run are covered only through the vm-sandbox tests.Smallest change:
scripts/bundle.js: one more esbuild entry,src/nip98-interceptor.jstosrc/nip98-interceptor.bundle.js,format: 'iife'.importfrom./auth-header-utils.js, keeping the__podkey_nip98_interceptedguard.web_accessible_resourcesinmanifest.jsonand thegetURLcall atsrc/injected.js:13at the bundle; add it to.gitignore.test/body-hash.test.js:26(andtest/unsigned-retry.test.jsfrom Retry a signed GET/HEAD unsigned when it fails before a response (#33) #34) read the raw file withreadFileSyncand would trip onimport: build in-test with esbuildwrite: false, or addpretest: npm run bundle.injected.jsitself does not need bundling. Best done straight after #34 lands, since that PR adds two more copies.Retry a signed GET/HEAD unsigned when it fails before a response (#33) (
Page side: dynamic content scripts, state-driven bridge, interceptor …
jjohare commentedon Nov 28, 2026
Done in 0.0.13 (a2265b7).
src/nip98-interceptor.jsis bundled with esbuild and importssrc/auth-header-utils.js, so there is one copy and the tests run the shipped code.