mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-12 23:31:02 +00:00
3ca73d432b
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.
54 lines
2.4 KiB
JavaScript
54 lines
2.4 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* lint:format: new server code is formatted with Prettier.
|
|
*
|
|
* `npm run format:check` was never part of CI, and most files differ from what
|
|
* .prettierrc asks for. Formatting all of them belongs in one mechanical
|
|
* commit of its own; until it lands, the files that were unformatted when
|
|
* this check came in are listed in scripts/format-baseline.json and the list
|
|
* only shrinks: every file outside it, a new one in particular, must be
|
|
* formatted, and a listed file leaves the list once it has been. After the
|
|
* mass reformat, --update empties the list and the check is a plain
|
|
* prettier --check over src/ and tests/.
|
|
*
|
|
* npm run lint:format check against the baseline (CI)
|
|
* npm run lint:format -- --list print every unformatted file
|
|
* 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, 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
|
|
* from this workspace.
|
|
*/
|
|
import { check } from '../../scripts/lib/format.mjs';
|
|
import { runCli } from '../../scripts/lib/ratchet.mjs';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
import * as prettier from 'prettier';
|
|
|
|
const root = fileURLToPath(new URL('..', import.meta.url));
|
|
// The entity files are written by scripts/generate-entities.ts and held byte for
|
|
// 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) && !ISSUER_WRITTEN.includes(key),
|
|
update: args.includes('--update'),
|
|
list: args.includes('--list'),
|
|
}),
|
|
);
|