✨ types(auth): Admin-Login-, MFA- und WebAuthn-Verträge

Eine Quelle für Server und Admin-UI:
- `AdminLoginResponse`: Union aus `AdminMfaChallenge` (`mfaRequired: true`)
  und `AdminLoginSession` (`token`, `user`, `amr`, `mfaEnrollmentRecommended`).
  Die Diskriminante ist `mfaRequired`, damit Clients sauber narrowen.
- `AdminAuthMethod` (`pwd|totp|recovery|webauthn`) vs. `AdminMfaMethod`
  (ohne `pwd`) — Go schreibt `pwd` immer in `amr`, bietet es aber nie als
  Faktor an.
- `AdminMfaStatus`, `AdminMfaTotpEnrollment`, `AdminMfaConfirmResult`,
  `AdminStepUpResult`.
- WebAuthn: `AdminWebAuthnCreationOptions`,
  `AdminWebAuthnRequestOptions`, `AdminWebAuthnCredentialJSON`,
  `AdminWebAuthnCredentialView`, `AdminAuthenticatorTransport`.

Type-Tests in `types-test/admin-auth.ts`: `Expect<Equal<…>>`-Assertions und
`@ts-expect-error` für die nicht möglichen Felder der Challenge. `npm test`
führt jetzt Schemas **und** `tsc` aus (TypeScript als devDependency).
This commit is contained in:
apairon committed 2026-11-06 19:09:14 +00:00
1 parent 24c2d34b3a
commit 2546d05b25
5 files changed
+198 -4

No files matched your search

+4 -2
View File
@@ -5,13 +5,15 @@
"types": "index.d.ts",
"scripts": {
"validate:schemas": "node scripts/validate-schemas.mjs",
"test": "npm run validate:schemas"
"typecheck": "tsc -p tsconfig.json",
"test": "npm run validate:schemas && npm run typecheck"
},
"devDependencies": {
"ajv": "^8.20.0",
"ajv-formats": "^3.0.1",
"glob": "^11.1.0",
"js-yaml": "^4.1.1"
"js-yaml": "^4.1.1",
"typescript": "^5.9.3"
},
"repository": {
"type": "git",