Files
podsteadr-player/njs/fips.test.js
ssmithxandClaude Opus 5.5 cbf50fa64b feat: carry the FIPS gateway in the image
So the player works as a self-contained app install, not only behind a
host nginx that provides /fips/.

- nginx.conf: full main config with the /fips/ gateway — podsteadr
  catalogs/feeds on 8095 and blossom blobs on 8098 only, GET/HEAD only,
  no client cookies or credentials, everything else under /fips/ 404s
- njs/fips.js: computes an npub.fips host's mesh address
  (fd || sha256(pubkey)[:15], bech32 checksum verified), so the gateway
  needs IPv6 egress to the mesh but no DNS; fips.test.js checks it
  against three real nodes' addresses
- runtime image is nginx-unprivileged 1.30.6 (uid 101): no capabilities,
  read-only root with writable state in /tmp, /healthz for probes
- the app explains that only npub.fips hosts can be relayed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 17:49:02 +00:00

27 lines
1.3 KiB
JavaScript

// Run in the image's njs (see deploy/README.md):
// podman run --rm -v ./njs:/t:ro --entrypoint njs <image> -p /t /t/fips.test.js
import fips from 'fips.js';
const cases = [
// Known npub -> FIPS address pairs, read off real nodes' fips0 interfaces.
['npub1ttuu24hncq0l4gvyl26pc6aa94k442mnm5z2yrfmu55es5nd0ztsgkc96k.fips', 'fd86:64e0:74b1:5940:ade8:ad00:f722:e770'],
['npub10yffd020a4ag8zcy75f9pruq3rnghvvhd5hphl9s62zgp35s560qrksp9u.fips', 'fd68:9863:d40b:c5ec:4756:339f:39c0:aa1c'],
['npub1s6ktsdp2hptm55v49lpek07wp9ryqxxhhwaq2wl789h5rkzd5ycst3t5nu.fips', 'fd15:3972:ecdb:5b72:c039:855a:7fd6:781e'],
// Bad checksum (last char changed), non-npub alias, empty.
['npub1ttuu24hncq0l4gvyl26pc6aa94k442mnm5z2yrfmu55es5nd0ztsgkc96q.fips', ''],
['podcasts.fips', ''],
['', ''],
];
const norm = (a) => (a ? a.split(':').map((g) => g.padStart(4, '0')).join(':') : '');
let failed = 0;
for (let i = 0; i < cases.length; i++) {
const got = fips.address({ variables: { fips_host: cases[i][0] } });
if (norm(got) !== norm(cases[i][1])) {
failed++;
console.log(`FAIL ${cases[i][0] || '(empty)'}: got ${JSON.stringify(got)}, want ${JSON.stringify(cases[i][1])}`);
}
}
console.log(failed ? `${failed} of ${cases.length} failed` : `all ${cases.length} passed`);
if (failed) throw new Error('fips.js tests failed');