feat(service-identity): register through the dialect of the running release

Registration now goes through a registration dialect module: the paths of
the challenge and the registration, the bytes scrypt runs over and the body
and headers of the request. Each stable release will carry the dialect the
TREK services issuer writes for it; until the first such release the module
speaks the original registration, so nothing changes on the wire.

An issuer that no longer takes the release's dialect answers 410. TREK then
says so once per process, waits a day (or what Retry-After asks) and keeps
searching through the shared pool. The issuer client only lets a dialect
register at the issuer's own paths, with X-TREK-* headers that are not the
gate's and a body of registration size.

Renewal needs no dialect, and an expired key may now be renewed for a year
instead of 30 days, the same period the issuer allows, so an installation
that was offline for long comes back without an update. The key format
ignores the new optional dialect claim; the shared vectors gain one key that
carries it.
This commit is contained in:
Maurice
2026-10-29 17:34:09 +01:00
parent e6c8fee3e5
commit 3ca73d432b
17 changed files with 870 additions and 64 deletions
+10 -2
View File
@@ -16,7 +16,8 @@
* npm run lint:format -- --update take formatted and deleted files off the list;
* it never adds one
*
* src/db/entities/ is generated and checked by check:entities instead.
* src/db/entities/ is generated and checked by check:entities instead, and the
* registration dialect is written by the TREK services issuer for each release.
*
* To format a file: npx prettier --write <file>. The comparison lives in
* scripts/lib/format.mjs at the repository root; Prettier and its config come
@@ -33,12 +34,19 @@ const root = fileURLToPath(new URL('..', import.meta.url));
// byte to its output by check:entities, so their layout is the generator's, not
// Prettier's. .prettierignore keeps `npm run format` off them for the same reason.
const GENERATED = 'src/db/entities/';
// The registration dialect and the issuer's sample of one are written by the
// TREK services issuer and committed as it wrote them (the release job takes
// the dialect over unchanged), so their layout is the issuer's generator's.
const ISSUER_WRITTEN = [
'src/nest/service-identity/registration-dialect.ts',
'tests/fixtures/service-identity/registration-dialect.sample.ts',
];
await runCli('lint:format', (args) =>
check({
prettier,
root,
dirs: ['src', 'tests'],
accepts: (key) => key.endsWith('.ts') && !key.startsWith(GENERATED),
accepts: (key) => key.endsWith('.ts') && !key.startsWith(GENERATED) && !ISSUER_WRITTEN.includes(key),
update: args.includes('--update'),
list: args.includes('--list'),
}),