@_mustachio/openauth 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/adapters/d1/audit-log.js +15 -0
- package/dist/esm/adapters/d1/config-store.js +45 -0
- package/dist/esm/adapters/d1/index.js +12 -0
- package/dist/esm/adapters/d1/key-store.js +116 -0
- package/dist/esm/adapters/d1/method-store.js +52 -0
- package/dist/esm/adapters/d1/migrations.js +77 -0
- package/dist/esm/adapters/d1/session-store.js +134 -0
- package/dist/esm/adapters/d1/session.js +18 -0
- package/dist/esm/adapters/d1/token-store.js +140 -0
- package/dist/esm/adapters/durable-object/index.js +3 -0
- package/dist/esm/adapters/durable-object/session-store.js +139 -0
- package/dist/esm/adapters/durable-object/types.js +0 -0
- package/dist/esm/adapters/dynamo/audit-log.js +23 -0
- package/dist/esm/adapters/dynamo/client.js +0 -0
- package/dist/esm/adapters/dynamo/config-store.js +57 -0
- package/dist/esm/adapters/dynamo/index.js +10 -0
- package/dist/esm/adapters/dynamo/key-store.js +188 -0
- package/dist/esm/adapters/dynamo/method-store.js +72 -0
- package/dist/esm/adapters/dynamo/passkey-credential-store.js +83 -0
- package/dist/esm/adapters/dynamo/sdk.js +128 -0
- package/dist/esm/adapters/dynamo/session-store.js +173 -0
- package/dist/esm/adapters/dynamo/token-store.js +178 -0
- package/dist/esm/adapters/kms/in-memory-backing.js +28 -0
- package/dist/esm/adapters/kms/index.js +5 -0
- package/dist/esm/adapters/kms/key-store.js +129 -0
- package/dist/esm/adapters/kms/sdk.js +23 -0
- package/dist/esm/adapters/kms/types.js +0 -0
- package/dist/esm/adapters/kv/audit-log.js +21 -0
- package/dist/esm/adapters/kv/config-store.js +43 -0
- package/dist/esm/adapters/kv/index.js +5 -0
- package/dist/esm/adapters/kv/method-store.js +63 -0
- package/dist/esm/adapters/kv/types.js +0 -0
- package/dist/esm/adapters/memory/audit-log.js +16 -0
- package/dist/esm/adapters/memory/clock.js +5 -0
- package/dist/esm/adapters/memory/config-store.js +31 -0
- package/dist/esm/adapters/memory/index.js +10 -0
- package/dist/esm/adapters/memory/key-store.js +78 -0
- package/dist/esm/adapters/memory/method-store.js +43 -0
- package/dist/esm/adapters/memory/passkey-credential-store.js +53 -0
- package/dist/esm/adapters/memory/session-store.js +104 -0
- package/dist/esm/adapters/memory/token-store.js +104 -0
- package/dist/esm/adapters/postgres/audit-log.js +16 -0
- package/dist/esm/adapters/postgres/config-store.js +48 -0
- package/dist/esm/adapters/postgres/executor.js +21 -0
- package/dist/esm/adapters/postgres/index.js +13 -0
- package/dist/esm/adapters/postgres/key-store.js +191 -0
- package/dist/esm/adapters/postgres/method-store.js +61 -0
- package/dist/esm/adapters/postgres/migrations.js +111 -0
- package/dist/esm/adapters/postgres/passkey-credential-store.js +80 -0
- package/dist/esm/adapters/postgres/session-store.js +135 -0
- package/dist/esm/adapters/postgres/token-store.js +151 -0
- package/dist/esm/client.js +35 -12
- package/dist/esm/domain/audit.js +13 -0
- package/dist/esm/domain/authorize.js +217 -0
- package/dist/esm/domain/callback.js +176 -0
- package/dist/esm/domain/client-auth.js +61 -0
- package/dist/esm/domain/client-credentials.js +91 -0
- package/dist/esm/domain/crypto.js +97 -0
- package/dist/esm/domain/discovery.js +83 -0
- package/dist/esm/domain/dpop.js +122 -0
- package/dist/esm/domain/id-token.js +94 -0
- package/dist/esm/domain/introspect.js +55 -0
- package/dist/esm/domain/jwt.js +71 -0
- package/dist/esm/domain/logout.js +75 -0
- package/dist/esm/domain/method-cache.js +136 -0
- package/dist/esm/domain/method-dispatch.js +36 -0
- package/dist/esm/domain/method-route.js +111 -0
- package/dist/esm/domain/par.js +51 -0
- package/dist/esm/domain/pkce.js +16 -0
- package/dist/esm/domain/refresh.js +102 -0
- package/dist/esm/domain/register.js +74 -0
- package/dist/esm/domain/revoke.js +81 -0
- package/dist/esm/domain/state-envelope.js +80 -0
- package/dist/esm/domain/token-exchange.js +102 -0
- package/dist/esm/domain/token.js +246 -0
- package/dist/esm/domain/userinfo.js +62 -0
- package/dist/esm/http/context.js +7 -0
- package/dist/esm/http/cookies.js +98 -0
- package/dist/esm/http/errors.js +71 -0
- package/dist/esm/http/handlers/authorize.js +250 -0
- package/dist/esm/http/handlers/callback.js +53 -0
- package/dist/esm/http/handlers/end-session.js +64 -0
- package/dist/esm/http/handlers/metadata.js +37 -0
- package/dist/esm/http/handlers/method-route.js +87 -0
- package/dist/esm/http/handlers/par.js +53 -0
- package/dist/esm/http/handlers/register.js +46 -0
- package/dist/esm/http/handlers/revocation.js +98 -0
- package/dist/esm/http/handlers/token.js +197 -0
- package/dist/esm/http/handlers/userinfo.js +60 -0
- package/dist/esm/http/middleware/error.js +15 -0
- package/dist/esm/http/middleware/tenant.js +102 -0
- package/dist/esm/http/resolver.js +15 -0
- package/dist/esm/http/router.js +45 -0
- package/dist/esm/http/schemas/authorize.js +30 -0
- package/dist/esm/http/schemas/end-session.js +13 -0
- package/dist/esm/http/schemas/par.js +9 -0
- package/dist/esm/http/schemas/register.js +16 -0
- package/dist/esm/http/schemas/revocation.js +18 -0
- package/dist/esm/http/schemas/token.js +57 -0
- package/dist/esm/index.js +126 -9
- package/dist/esm/methods/code.js +221 -0
- package/dist/esm/methods/m2m.js +41 -0
- package/dist/esm/methods/oauth2-factory.js +84 -0
- package/dist/esm/methods/oauth2-generic.js +196 -0
- package/dist/esm/methods/oidc-generic.js +53 -0
- package/dist/esm/methods/passkey.js +275 -0
- package/dist/esm/methods/password-hash.js +79 -0
- package/dist/esm/methods/password.js +166 -0
- package/dist/esm/methods/providers/apple.js +29 -0
- package/dist/esm/methods/providers/cognito.js +37 -0
- package/dist/esm/methods/providers/discord.js +28 -0
- package/dist/esm/methods/providers/facebook.js +42 -0
- package/dist/esm/methods/providers/github.js +29 -0
- package/dist/esm/methods/providers/google.js +29 -0
- package/dist/esm/methods/providers/index.js +17 -0
- package/dist/esm/methods/providers/jumpcloud.js +27 -0
- package/dist/esm/methods/providers/keycloak.js +32 -0
- package/dist/esm/methods/providers/linkedin.js +28 -0
- package/dist/esm/methods/providers/microsoft.js +28 -0
- package/dist/esm/methods/providers/slack.js +30 -0
- package/dist/esm/methods/providers/spotify.js +28 -0
- package/dist/esm/methods/providers/twitch.js +28 -0
- package/dist/esm/methods/providers/x.js +28 -0
- package/dist/esm/methods/providers/yahoo.js +27 -0
- package/dist/esm/pkce.js +4 -16
- package/dist/esm/ports/audit-log.js +0 -0
- package/dist/esm/ports/config-store.js +0 -0
- package/dist/esm/ports/key-store.js +0 -0
- package/dist/esm/ports/method-store.js +0 -0
- package/dist/esm/ports/session-store.js +0 -0
- package/dist/esm/ports/token-store.js +0 -0
- package/dist/esm/types/authorization.js +0 -0
- package/dist/esm/types/error.js +70 -0
- package/dist/esm/types/flow.js +0 -0
- package/dist/esm/types/idp.js +0 -0
- package/dist/esm/types/method.js +0 -0
- package/dist/esm/types/picker.js +0 -0
- package/dist/esm/types/result.js +11 -0
- package/dist/esm/types/subject.js +0 -0
- package/dist/esm/types/tenant.js +5 -0
- package/dist/esm/types/token.js +0 -0
- package/dist/esm/ui/forms.js +253 -0
- package/dist/esm/ui/index.js +8 -0
- package/dist/esm/ui/picker.js +49 -0
- package/dist/types/adapters/d1/audit-log.d.ts +19 -0
- package/dist/types/adapters/d1/audit-log.d.ts.map +1 -0
- package/dist/types/adapters/d1/config-store.d.ts +20 -0
- package/dist/types/adapters/d1/config-store.d.ts.map +1 -0
- package/dist/types/adapters/d1/index.d.ts +35 -0
- package/dist/types/adapters/d1/index.d.ts.map +1 -0
- package/dist/types/adapters/d1/key-store.d.ts +17 -0
- package/dist/types/adapters/d1/key-store.d.ts.map +1 -0
- package/dist/types/adapters/d1/method-store.d.ts +21 -0
- package/dist/types/adapters/d1/method-store.d.ts.map +1 -0
- package/dist/types/adapters/d1/migrations.d.ts +18 -0
- package/dist/types/adapters/d1/migrations.d.ts.map +1 -0
- package/dist/types/adapters/d1/session-store.d.ts +20 -0
- package/dist/types/adapters/d1/session-store.d.ts.map +1 -0
- package/dist/types/adapters/d1/session.d.ts +18 -0
- package/dist/types/adapters/d1/session.d.ts.map +1 -0
- package/dist/types/adapters/d1/token-store.d.ts +29 -0
- package/dist/types/adapters/d1/token-store.d.ts.map +1 -0
- package/dist/types/adapters/d1/types.d.ts +43 -0
- package/dist/types/adapters/d1/types.d.ts.map +1 -0
- package/dist/types/adapters/durable-object/index.d.ts +17 -0
- package/dist/types/adapters/durable-object/index.d.ts.map +1 -0
- package/dist/types/adapters/durable-object/session-store.d.ts +21 -0
- package/dist/types/adapters/durable-object/session-store.d.ts.map +1 -0
- package/dist/types/adapters/durable-object/types.d.ts +23 -0
- package/dist/types/adapters/durable-object/types.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/audit-log.d.ts +19 -0
- package/dist/types/adapters/dynamo/audit-log.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/client.d.ts +111 -0
- package/dist/types/adapters/dynamo/client.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/config-store.d.ts +21 -0
- package/dist/types/adapters/dynamo/config-store.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/index.d.ts +60 -0
- package/dist/types/adapters/dynamo/index.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/key-store.d.ts +23 -0
- package/dist/types/adapters/dynamo/key-store.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/method-store.d.ts +20 -0
- package/dist/types/adapters/dynamo/method-store.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/passkey-credential-store.d.ts +47 -0
- package/dist/types/adapters/dynamo/passkey-credential-store.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/sdk.d.ts +23 -0
- package/dist/types/adapters/dynamo/sdk.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/session-store.d.ts +20 -0
- package/dist/types/adapters/dynamo/session-store.d.ts.map +1 -0
- package/dist/types/adapters/dynamo/token-store.d.ts +29 -0
- package/dist/types/adapters/dynamo/token-store.d.ts.map +1 -0
- package/dist/types/adapters/kms/in-memory-backing.d.ts +9 -0
- package/dist/types/adapters/kms/in-memory-backing.d.ts.map +1 -0
- package/dist/types/adapters/kms/index.d.ts +35 -0
- package/dist/types/adapters/kms/index.d.ts.map +1 -0
- package/dist/types/adapters/kms/key-store.d.ts +20 -0
- package/dist/types/adapters/kms/key-store.d.ts.map +1 -0
- package/dist/types/adapters/kms/sdk.d.ts +16 -0
- package/dist/types/adapters/kms/sdk.d.ts.map +1 -0
- package/dist/types/adapters/kms/types.d.ts +58 -0
- package/dist/types/adapters/kms/types.d.ts.map +1 -0
- package/dist/types/adapters/kv/audit-log.d.ts +22 -0
- package/dist/types/adapters/kv/audit-log.d.ts.map +1 -0
- package/dist/types/adapters/kv/config-store.d.ts +25 -0
- package/dist/types/adapters/kv/config-store.d.ts.map +1 -0
- package/dist/types/adapters/kv/index.d.ts +21 -0
- package/dist/types/adapters/kv/index.d.ts.map +1 -0
- package/dist/types/adapters/kv/method-store.d.ts +23 -0
- package/dist/types/adapters/kv/method-store.d.ts.map +1 -0
- package/dist/types/adapters/kv/types.d.ts +28 -0
- package/dist/types/adapters/kv/types.d.ts.map +1 -0
- package/dist/types/adapters/memory/audit-log.d.ts +18 -0
- package/dist/types/adapters/memory/audit-log.d.ts.map +1 -0
- package/dist/types/adapters/memory/clock.d.ts +7 -0
- package/dist/types/adapters/memory/clock.d.ts.map +1 -0
- package/dist/types/adapters/memory/config-store.d.ts +19 -0
- package/dist/types/adapters/memory/config-store.d.ts.map +1 -0
- package/dist/types/adapters/memory/index.d.ts +15 -0
- package/dist/types/adapters/memory/index.d.ts.map +1 -0
- package/dist/types/adapters/memory/key-store.d.ts +17 -0
- package/dist/types/adapters/memory/key-store.d.ts.map +1 -0
- package/dist/types/adapters/memory/method-store.d.ts +26 -0
- package/dist/types/adapters/memory/method-store.d.ts.map +1 -0
- package/dist/types/adapters/memory/passkey-credential-store.d.ts +43 -0
- package/dist/types/adapters/memory/passkey-credential-store.d.ts.map +1 -0
- package/dist/types/adapters/memory/session-store.d.ts +21 -0
- package/dist/types/adapters/memory/session-store.d.ts.map +1 -0
- package/dist/types/adapters/memory/token-store.d.ts +29 -0
- package/dist/types/adapters/memory/token-store.d.ts.map +1 -0
- package/dist/types/adapters/postgres/audit-log.d.ts +18 -0
- package/dist/types/adapters/postgres/audit-log.d.ts.map +1 -0
- package/dist/types/adapters/postgres/config-store.d.ts +21 -0
- package/dist/types/adapters/postgres/config-store.d.ts.map +1 -0
- package/dist/types/adapters/postgres/executor.d.ts +48 -0
- package/dist/types/adapters/postgres/executor.d.ts.map +1 -0
- package/dist/types/adapters/postgres/index.d.ts +39 -0
- package/dist/types/adapters/postgres/index.d.ts.map +1 -0
- package/dist/types/adapters/postgres/key-store.d.ts +23 -0
- package/dist/types/adapters/postgres/key-store.d.ts.map +1 -0
- package/dist/types/adapters/postgres/method-store.d.ts +21 -0
- package/dist/types/adapters/postgres/method-store.d.ts.map +1 -0
- package/dist/types/adapters/postgres/migrations.d.ts +22 -0
- package/dist/types/adapters/postgres/migrations.d.ts.map +1 -0
- package/dist/types/adapters/postgres/passkey-credential-store.d.ts +48 -0
- package/dist/types/adapters/postgres/passkey-credential-store.d.ts.map +1 -0
- package/dist/types/adapters/postgres/session-store.d.ts +20 -0
- package/dist/types/adapters/postgres/session-store.d.ts.map +1 -0
- package/dist/types/adapters/postgres/token-store.d.ts +30 -0
- package/dist/types/adapters/postgres/token-store.d.ts.map +1 -0
- package/dist/types/client.d.ts +20 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/domain/audit.d.ts +17 -0
- package/dist/types/domain/audit.d.ts.map +1 -0
- package/dist/types/domain/authorize.d.ts +125 -0
- package/dist/types/domain/authorize.d.ts.map +1 -0
- package/dist/types/domain/callback.d.ts +70 -0
- package/dist/types/domain/callback.d.ts.map +1 -0
- package/dist/types/domain/client-auth.d.ts +57 -0
- package/dist/types/domain/client-auth.d.ts.map +1 -0
- package/dist/types/domain/client-credentials.d.ts +54 -0
- package/dist/types/domain/client-credentials.d.ts.map +1 -0
- package/dist/types/domain/crypto.d.ts +53 -0
- package/dist/types/domain/crypto.d.ts.map +1 -0
- package/dist/types/domain/discovery.d.ts +81 -0
- package/dist/types/domain/discovery.d.ts.map +1 -0
- package/dist/types/domain/dpop.d.ts +61 -0
- package/dist/types/domain/dpop.d.ts.map +1 -0
- package/dist/types/domain/id-token.d.ts +83 -0
- package/dist/types/domain/id-token.d.ts.map +1 -0
- package/dist/types/domain/introspect.d.ts +79 -0
- package/dist/types/domain/introspect.d.ts.map +1 -0
- package/dist/types/domain/jwt.d.ts +74 -0
- package/dist/types/domain/jwt.d.ts.map +1 -0
- package/dist/types/domain/logout.d.ts +69 -0
- package/dist/types/domain/logout.d.ts.map +1 -0
- package/dist/types/domain/method-cache.d.ts +42 -0
- package/dist/types/domain/method-cache.d.ts.map +1 -0
- package/dist/types/domain/method-dispatch.d.ts +37 -0
- package/dist/types/domain/method-dispatch.d.ts.map +1 -0
- package/dist/types/domain/method-route.d.ts +77 -0
- package/dist/types/domain/method-route.d.ts.map +1 -0
- package/dist/types/domain/par.d.ts +62 -0
- package/dist/types/domain/par.d.ts.map +1 -0
- package/dist/types/domain/pkce.d.ts +15 -0
- package/dist/types/domain/pkce.d.ts.map +1 -0
- package/dist/types/domain/refresh.d.ts +52 -0
- package/dist/types/domain/refresh.d.ts.map +1 -0
- package/dist/types/domain/register.d.ts +33 -0
- package/dist/types/domain/register.d.ts.map +1 -0
- package/dist/types/domain/revoke.d.ts +61 -0
- package/dist/types/domain/revoke.d.ts.map +1 -0
- package/dist/types/domain/state-envelope.d.ts +30 -0
- package/dist/types/domain/state-envelope.d.ts.map +1 -0
- package/dist/types/domain/token-exchange.d.ts +69 -0
- package/dist/types/domain/token-exchange.d.ts.map +1 -0
- package/dist/types/domain/token.d.ts +140 -0
- package/dist/types/domain/token.d.ts.map +1 -0
- package/dist/types/domain/userinfo.d.ts +61 -0
- package/dist/types/domain/userinfo.d.ts.map +1 -0
- package/dist/types/http/context.d.ts +66 -0
- package/dist/types/http/context.d.ts.map +1 -0
- package/dist/types/http/cookies.d.ts +45 -0
- package/dist/types/http/cookies.d.ts.map +1 -0
- package/dist/types/http/errors.d.ts +36 -0
- package/dist/types/http/errors.d.ts.map +1 -0
- package/dist/types/http/handlers/authorize.d.ts +3 -0
- package/dist/types/http/handlers/authorize.d.ts.map +1 -0
- package/dist/types/http/handlers/callback.d.ts +3 -0
- package/dist/types/http/handlers/callback.d.ts.map +1 -0
- package/dist/types/http/handlers/end-session.d.ts +3 -0
- package/dist/types/http/handlers/end-session.d.ts.map +1 -0
- package/dist/types/http/handlers/metadata.d.ts +4 -0
- package/dist/types/http/handlers/metadata.d.ts.map +1 -0
- package/dist/types/http/handlers/method-route.d.ts +3 -0
- package/dist/types/http/handlers/method-route.d.ts.map +1 -0
- package/dist/types/http/handlers/par.d.ts +3 -0
- package/dist/types/http/handlers/par.d.ts.map +1 -0
- package/dist/types/http/handlers/register.d.ts +3 -0
- package/dist/types/http/handlers/register.d.ts.map +1 -0
- package/dist/types/http/handlers/revocation.d.ts +4 -0
- package/dist/types/http/handlers/revocation.d.ts.map +1 -0
- package/dist/types/http/handlers/token.d.ts +3 -0
- package/dist/types/http/handlers/token.d.ts.map +1 -0
- package/dist/types/http/handlers/userinfo.d.ts +3 -0
- package/dist/types/http/handlers/userinfo.d.ts.map +1 -0
- package/dist/types/http/middleware/error.d.ts +9 -0
- package/dist/types/http/middleware/error.d.ts.map +1 -0
- package/dist/types/http/middleware/tenant.d.ts +30 -0
- package/dist/types/http/middleware/tenant.d.ts.map +1 -0
- package/dist/types/http/resolver.d.ts +22 -0
- package/dist/types/http/resolver.d.ts.map +1 -0
- package/dist/types/http/router.d.ts +21 -0
- package/dist/types/http/router.d.ts.map +1 -0
- package/dist/types/http/schemas/authorize.d.ts +92 -0
- package/dist/types/http/schemas/authorize.d.ts.map +1 -0
- package/dist/types/http/schemas/end-session.d.ts +31 -0
- package/dist/types/http/schemas/end-session.d.ts.map +1 -0
- package/dist/types/http/schemas/par.d.ts +20 -0
- package/dist/types/http/schemas/par.d.ts.map +1 -0
- package/dist/types/http/schemas/register.d.ts +42 -0
- package/dist/types/http/schemas/register.d.ts.map +1 -0
- package/dist/types/http/schemas/revocation.d.ts +41 -0
- package/dist/types/http/schemas/revocation.d.ts.map +1 -0
- package/dist/types/http/schemas/token.d.ts +227 -0
- package/dist/types/http/schemas/token.d.ts.map +1 -0
- package/dist/types/index.d.ts +63 -13
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/methods/code.d.ts +96 -0
- package/dist/types/methods/code.d.ts.map +1 -0
- package/dist/types/methods/m2m.d.ts +41 -0
- package/dist/types/methods/m2m.d.ts.map +1 -0
- package/dist/types/methods/oauth2-factory.d.ts +133 -0
- package/dist/types/methods/oauth2-factory.d.ts.map +1 -0
- package/dist/types/methods/oauth2-generic.d.ts +75 -0
- package/dist/types/methods/oauth2-generic.d.ts.map +1 -0
- package/dist/types/methods/oidc-generic.d.ts +26 -0
- package/dist/types/methods/oidc-generic.d.ts.map +1 -0
- package/dist/types/methods/passkey.d.ts +106 -0
- package/dist/types/methods/passkey.d.ts.map +1 -0
- package/dist/types/methods/password-hash.d.ts +25 -0
- package/dist/types/methods/password-hash.d.ts.map +1 -0
- package/dist/types/methods/password.d.ts +70 -0
- package/dist/types/methods/password.d.ts.map +1 -0
- package/dist/types/methods/providers/apple.d.ts +29 -0
- package/dist/types/methods/providers/apple.d.ts.map +1 -0
- package/dist/types/methods/providers/cognito.d.ts +36 -0
- package/dist/types/methods/providers/cognito.d.ts.map +1 -0
- package/dist/types/methods/providers/discord.d.ts +22 -0
- package/dist/types/methods/providers/discord.d.ts.map +1 -0
- package/dist/types/methods/providers/facebook.d.ts +29 -0
- package/dist/types/methods/providers/facebook.d.ts.map +1 -0
- package/dist/types/methods/providers/github.d.ts +25 -0
- package/dist/types/methods/providers/github.d.ts.map +1 -0
- package/dist/types/methods/providers/google.d.ts +28 -0
- package/dist/types/methods/providers/google.d.ts.map +1 -0
- package/dist/types/methods/providers/index.d.ts +24 -0
- package/dist/types/methods/providers/index.d.ts.map +1 -0
- package/dist/types/methods/providers/jumpcloud.d.ts +22 -0
- package/dist/types/methods/providers/jumpcloud.d.ts.map +1 -0
- package/dist/types/methods/providers/keycloak.d.ts +30 -0
- package/dist/types/methods/providers/keycloak.d.ts.map +1 -0
- package/dist/types/methods/providers/linkedin.d.ts +22 -0
- package/dist/types/methods/providers/linkedin.d.ts.map +1 -0
- package/dist/types/methods/providers/microsoft.d.ts +30 -0
- package/dist/types/methods/providers/microsoft.d.ts.map +1 -0
- package/dist/types/methods/providers/slack.d.ts +25 -0
- package/dist/types/methods/providers/slack.d.ts.map +1 -0
- package/dist/types/methods/providers/spotify.d.ts +22 -0
- package/dist/types/methods/providers/spotify.d.ts.map +1 -0
- package/dist/types/methods/providers/twitch.d.ts +23 -0
- package/dist/types/methods/providers/twitch.d.ts.map +1 -0
- package/dist/types/methods/providers/x.d.ts +25 -0
- package/dist/types/methods/providers/x.d.ts.map +1 -0
- package/dist/types/methods/providers/yahoo.d.ts +22 -0
- package/dist/types/methods/providers/yahoo.d.ts.map +1 -0
- package/dist/types/pkce.d.ts +1 -2
- package/dist/types/pkce.d.ts.map +1 -1
- package/dist/types/ports/audit-log.d.ts +166 -0
- package/dist/types/ports/audit-log.d.ts.map +1 -0
- package/dist/types/ports/config-store.d.ts +32 -0
- package/dist/types/ports/config-store.d.ts.map +1 -0
- package/dist/types/ports/key-store.d.ts +98 -0
- package/dist/types/ports/key-store.d.ts.map +1 -0
- package/dist/types/ports/method-store.d.ts +29 -0
- package/dist/types/ports/method-store.d.ts.map +1 -0
- package/dist/types/ports/session-store.d.ts +109 -0
- package/dist/types/ports/session-store.d.ts.map +1 -0
- package/dist/types/ports/token-store.d.ts +105 -0
- package/dist/types/ports/token-store.d.ts.map +1 -0
- package/dist/types/types/authorization.d.ts +75 -0
- package/dist/types/types/authorization.d.ts.map +1 -0
- package/dist/types/types/error.d.ts +101 -0
- package/dist/types/types/error.d.ts.map +1 -0
- package/dist/types/types/flow.d.ts +97 -0
- package/dist/types/types/flow.d.ts.map +1 -0
- package/dist/types/types/idp.d.ts +324 -0
- package/dist/types/types/idp.d.ts.map +1 -0
- package/dist/types/types/method.d.ts +256 -0
- package/dist/types/types/method.d.ts.map +1 -0
- package/dist/types/types/picker.d.ts +31 -0
- package/dist/types/types/picker.d.ts.map +1 -0
- package/dist/types/types/result.d.ts +29 -0
- package/dist/types/types/result.d.ts.map +1 -0
- package/dist/types/types/subject.d.ts +47 -0
- package/dist/types/types/subject.d.ts.map +1 -0
- package/dist/types/types/tenant.d.ts +276 -0
- package/dist/types/types/tenant.d.ts.map +1 -0
- package/dist/types/types/token.d.ts +231 -0
- package/dist/types/types/token.d.ts.map +1 -0
- package/dist/types/ui/forms.d.ts +35 -0
- package/dist/types/ui/forms.d.ts.map +1 -0
- package/dist/types/ui/index.d.ts +14 -0
- package/dist/types/ui/index.d.ts.map +1 -0
- package/dist/types/ui/picker.d.ts +18 -0
- package/dist/types/ui/picker.d.ts.map +1 -0
- package/package.json +41 -6
- package/src/adapters/d1/audit-log.ts +32 -0
- package/src/adapters/d1/config-store.ts +67 -0
- package/src/adapters/d1/index.ts +41 -0
- package/src/adapters/d1/key-store.ts +218 -0
- package/src/adapters/d1/method-store.ts +103 -0
- package/src/adapters/d1/migrations.ts +89 -0
- package/src/adapters/d1/session-store.ts +230 -0
- package/src/adapters/d1/session.ts +38 -0
- package/src/adapters/d1/token-store.ts +251 -0
- package/src/adapters/d1/types.ts +53 -0
- package/src/adapters/durable-object/index.ts +23 -0
- package/src/adapters/durable-object/session-store.ts +227 -0
- package/src/adapters/durable-object/types.ts +25 -0
- package/src/adapters/dynamo/audit-log.ts +35 -0
- package/src/adapters/dynamo/client.ts +118 -0
- package/src/adapters/dynamo/config-store.ts +72 -0
- package/src/adapters/dynamo/index.ts +81 -0
- package/src/adapters/dynamo/key-store.ts +267 -0
- package/src/adapters/dynamo/method-store.ts +105 -0
- package/src/adapters/dynamo/passkey-credential-store.ts +132 -0
- package/src/adapters/dynamo/sdk.ts +189 -0
- package/src/adapters/dynamo/session-store.ts +229 -0
- package/src/adapters/dynamo/token-store.ts +248 -0
- package/src/adapters/kms/in-memory-backing.ts +36 -0
- package/src/adapters/kms/index.ts +39 -0
- package/src/adapters/kms/key-store.ts +176 -0
- package/src/adapters/kms/sdk.ts +39 -0
- package/src/adapters/kms/types.ts +61 -0
- package/src/adapters/kv/audit-log.ts +40 -0
- package/src/adapters/kv/config-store.ts +63 -0
- package/src/adapters/kv/index.ts +20 -0
- package/src/adapters/kv/method-store.ts +98 -0
- package/src/adapters/kv/types.ts +26 -0
- package/src/adapters/memory/audit-log.ts +28 -0
- package/src/adapters/memory/clock.ts +7 -0
- package/src/adapters/memory/config-store.ts +41 -0
- package/src/adapters/memory/index.ts +26 -0
- package/src/adapters/memory/key-store.ts +102 -0
- package/src/adapters/memory/method-store.ts +75 -0
- package/src/adapters/memory/passkey-credential-store.ts +97 -0
- package/src/adapters/memory/session-store.ts +171 -0
- package/src/adapters/memory/token-store.ts +181 -0
- package/src/adapters/postgres/audit-log.ts +34 -0
- package/src/adapters/postgres/config-store.ts +72 -0
- package/src/adapters/postgres/executor.ts +76 -0
- package/src/adapters/postgres/index.ts +60 -0
- package/src/adapters/postgres/key-store.ts +334 -0
- package/src/adapters/postgres/method-store.ts +104 -0
- package/src/adapters/postgres/migrations.ts +131 -0
- package/src/adapters/postgres/passkey-credential-store.ts +150 -0
- package/src/adapters/postgres/session-store.ts +216 -0
- package/src/adapters/postgres/token-store.ts +263 -0
- package/src/client.ts +82 -16
- package/src/domain/audit.ts +28 -0
- package/src/domain/authorize.ts +414 -0
- package/src/domain/callback.ts +268 -0
- package/src/domain/client-auth.ts +116 -0
- package/src/domain/client-credentials.ts +180 -0
- package/src/domain/crypto.ts +168 -0
- package/src/domain/discovery.ts +161 -0
- package/src/domain/dpop.ts +293 -0
- package/src/domain/id-token.ts +213 -0
- package/src/domain/introspect.ts +155 -0
- package/src/domain/jwt.ts +185 -0
- package/src/domain/logout.ts +180 -0
- package/src/domain/method-cache.ts +220 -0
- package/src/domain/method-dispatch.ts +95 -0
- package/src/domain/method-route.ts +213 -0
- package/src/domain/par.ts +141 -0
- package/src/domain/pkce.ts +37 -0
- package/src/domain/refresh.ts +210 -0
- package/src/domain/register.ts +168 -0
- package/src/domain/revoke.ts +161 -0
- package/src/domain/state-envelope.ts +142 -0
- package/src/domain/token-exchange.ts +243 -0
- package/src/domain/token.ts +483 -0
- package/src/domain/userinfo.ts +171 -0
- package/src/http/context.ts +90 -0
- package/src/http/cookies.ts +167 -0
- package/src/http/errors.ts +98 -0
- package/src/http/handlers/authorize.ts +362 -0
- package/src/http/handlers/callback.ts +77 -0
- package/src/http/handlers/end-session.ts +106 -0
- package/src/http/handlers/metadata.ts +49 -0
- package/src/http/handlers/method-route.ts +115 -0
- package/src/http/handlers/par.ts +84 -0
- package/src/http/handlers/register.ts +70 -0
- package/src/http/handlers/revocation.ts +151 -0
- package/src/http/handlers/token.ts +300 -0
- package/src/http/handlers/userinfo.ts +90 -0
- package/src/http/middleware/error.ts +26 -0
- package/src/http/middleware/tenant.ts +165 -0
- package/src/http/resolver.ts +34 -0
- package/src/http/router.ts +85 -0
- package/src/http/schemas/authorize.ts +85 -0
- package/src/http/schemas/end-session.ts +23 -0
- package/src/http/schemas/par.ts +23 -0
- package/src/http/schemas/register.ts +29 -0
- package/src/http/schemas/revocation.ts +23 -0
- package/src/http/schemas/token.ts +85 -0
- package/src/index.ts +283 -20
- package/src/methods/code.ts +359 -0
- package/src/methods/m2m.ts +82 -0
- package/src/methods/oauth2-factory.ts +151 -0
- package/src/methods/oauth2-generic.ts +360 -0
- package/src/methods/oidc-generic.ts +109 -0
- package/src/methods/passkey.ts +419 -0
- package/src/methods/password-hash.ts +134 -0
- package/src/methods/password.ts +298 -0
- package/src/methods/providers/apple.ts +42 -0
- package/src/methods/providers/cognito.ts +55 -0
- package/src/methods/providers/discord.ts +37 -0
- package/src/methods/providers/facebook.ts +54 -0
- package/src/methods/providers/github.ts +42 -0
- package/src/methods/providers/google.ts +43 -0
- package/src/methods/providers/index.ts +23 -0
- package/src/methods/providers/jumpcloud.ts +36 -0
- package/src/methods/providers/keycloak.ts +42 -0
- package/src/methods/providers/linkedin.ts +37 -0
- package/src/methods/providers/microsoft.ts +42 -0
- package/src/methods/providers/slack.ts +42 -0
- package/src/methods/providers/spotify.ts +37 -0
- package/src/methods/providers/twitch.ts +38 -0
- package/src/methods/providers/x.ts +40 -0
- package/src/methods/providers/yahoo.ts +36 -0
- package/src/pkce.ts +20 -21
- package/src/ports/CONSISTENCY.md +119 -0
- package/src/ports/audit-log.ts +177 -0
- package/src/ports/config-store.ts +34 -0
- package/src/ports/key-store.ts +106 -0
- package/src/ports/method-store.ts +41 -0
- package/src/ports/session-store.ts +131 -0
- package/src/ports/token-store.ts +116 -0
- package/src/types/authorization.ts +78 -0
- package/src/types/error.ts +146 -0
- package/src/types/flow.ts +99 -0
- package/src/types/idp.ts +365 -0
- package/src/types/method.ts +270 -0
- package/src/types/picker.ts +32 -0
- package/src/types/result.ts +23 -0
- package/src/types/subject.ts +50 -0
- package/src/types/tenant.ts +285 -0
- package/src/types/token.ts +236 -0
- package/src/ui/forms.ts +289 -0
- package/src/ui/index.ts +14 -0
- package/src/ui/picker.ts +63 -0
- package/dist/esm/issuer.js +0 -691
- package/dist/esm/jwt.js +0 -16
- package/dist/esm/keys.js +0 -113
- package/dist/esm/provider/apple.js +0 -28
- package/dist/esm/provider/arctic.js +0 -43
- package/dist/esm/provider/code.js +0 -58
- package/dist/esm/provider/cognito.js +0 -16
- package/dist/esm/provider/discord.js +0 -15
- package/dist/esm/provider/facebook.js +0 -24
- package/dist/esm/provider/github.js +0 -15
- package/dist/esm/provider/google.js +0 -25
- package/dist/esm/provider/index.js +0 -3
- package/dist/esm/provider/jumpcloud.js +0 -15
- package/dist/esm/provider/keycloak.js +0 -15
- package/dist/esm/provider/linkedin.js +0 -15
- package/dist/esm/provider/m2m.js +0 -16
- package/dist/esm/provider/microsoft.js +0 -24
- package/dist/esm/provider/oauth2.js +0 -119
- package/dist/esm/provider/oidc.js +0 -69
- package/dist/esm/provider/passkey.js +0 -315
- package/dist/esm/provider/password.js +0 -306
- package/dist/esm/provider/provider.js +0 -10
- package/dist/esm/provider/slack.js +0 -15
- package/dist/esm/provider/spotify.js +0 -15
- package/dist/esm/provider/twitch.js +0 -15
- package/dist/esm/provider/x.js +0 -16
- package/dist/esm/provider/yahoo.js +0 -15
- package/dist/esm/random.js +0 -27
- package/dist/esm/storage/aws.js +0 -39
- package/dist/esm/storage/cloudflare.js +0 -42
- package/dist/esm/storage/dynamo.js +0 -116
- package/dist/esm/storage/memory.js +0 -88
- package/dist/esm/storage/storage.js +0 -36
- package/dist/esm/subject.js +0 -7
- package/dist/esm/ui/base.js +0 -407
- package/dist/esm/ui/code.js +0 -151
- package/dist/esm/ui/form.js +0 -43
- package/dist/esm/ui/icon.js +0 -92
- package/dist/esm/ui/passkey.js +0 -329
- package/dist/esm/ui/password.js +0 -338
- package/dist/esm/ui/select.js +0 -187
- package/dist/esm/ui/theme.js +0 -115
- package/dist/esm/util.js +0 -54
- package/dist/types/issuer.d.ts +0 -607
- package/dist/types/issuer.d.ts.map +0 -1
- package/dist/types/jwt.d.ts +0 -6
- package/dist/types/jwt.d.ts.map +0 -1
- package/dist/types/keys.d.ts +0 -18
- package/dist/types/keys.d.ts.map +0 -1
- package/dist/types/provider/apple.d.ts +0 -108
- package/dist/types/provider/apple.d.ts.map +0 -1
- package/dist/types/provider/arctic.d.ts +0 -16
- package/dist/types/provider/arctic.d.ts.map +0 -1
- package/dist/types/provider/code.d.ts +0 -74
- package/dist/types/provider/code.d.ts.map +0 -1
- package/dist/types/provider/cognito.d.ts +0 -64
- package/dist/types/provider/cognito.d.ts.map +0 -1
- package/dist/types/provider/discord.d.ts +0 -38
- package/dist/types/provider/discord.d.ts.map +0 -1
- package/dist/types/provider/facebook.d.ts +0 -74
- package/dist/types/provider/facebook.d.ts.map +0 -1
- package/dist/types/provider/github.d.ts +0 -38
- package/dist/types/provider/github.d.ts.map +0 -1
- package/dist/types/provider/google.d.ts +0 -74
- package/dist/types/provider/google.d.ts.map +0 -1
- package/dist/types/provider/index.d.ts +0 -4
- package/dist/types/provider/index.d.ts.map +0 -1
- package/dist/types/provider/jumpcloud.d.ts +0 -38
- package/dist/types/provider/jumpcloud.d.ts.map +0 -1
- package/dist/types/provider/keycloak.d.ts +0 -67
- package/dist/types/provider/keycloak.d.ts.map +0 -1
- package/dist/types/provider/linkedin.d.ts +0 -6
- package/dist/types/provider/linkedin.d.ts.map +0 -1
- package/dist/types/provider/m2m.d.ts +0 -34
- package/dist/types/provider/m2m.d.ts.map +0 -1
- package/dist/types/provider/microsoft.d.ts +0 -89
- package/dist/types/provider/microsoft.d.ts.map +0 -1
- package/dist/types/provider/oauth2.d.ts +0 -133
- package/dist/types/provider/oauth2.d.ts.map +0 -1
- package/dist/types/provider/oidc.d.ts +0 -91
- package/dist/types/provider/oidc.d.ts.map +0 -1
- package/dist/types/provider/passkey.d.ts +0 -143
- package/dist/types/provider/passkey.d.ts.map +0 -1
- package/dist/types/provider/password.d.ts +0 -210
- package/dist/types/provider/password.d.ts.map +0 -1
- package/dist/types/provider/provider.d.ts +0 -29
- package/dist/types/provider/provider.d.ts.map +0 -1
- package/dist/types/provider/slack.d.ts +0 -59
- package/dist/types/provider/slack.d.ts.map +0 -1
- package/dist/types/provider/spotify.d.ts +0 -38
- package/dist/types/provider/spotify.d.ts.map +0 -1
- package/dist/types/provider/twitch.d.ts +0 -38
- package/dist/types/provider/twitch.d.ts.map +0 -1
- package/dist/types/provider/x.d.ts +0 -38
- package/dist/types/provider/x.d.ts.map +0 -1
- package/dist/types/provider/yahoo.d.ts +0 -38
- package/dist/types/provider/yahoo.d.ts.map +0 -1
- package/dist/types/random.d.ts +0 -3
- package/dist/types/random.d.ts.map +0 -1
- package/dist/types/storage/aws.d.ts +0 -4
- package/dist/types/storage/aws.d.ts.map +0 -1
- package/dist/types/storage/cloudflare.d.ts +0 -34
- package/dist/types/storage/cloudflare.d.ts.map +0 -1
- package/dist/types/storage/dynamo.d.ts +0 -65
- package/dist/types/storage/dynamo.d.ts.map +0 -1
- package/dist/types/storage/memory.d.ts +0 -49
- package/dist/types/storage/memory.d.ts.map +0 -1
- package/dist/types/storage/storage.d.ts +0 -15
- package/dist/types/storage/storage.d.ts.map +0 -1
- package/dist/types/subject.d.ts +0 -122
- package/dist/types/subject.d.ts.map +0 -1
- package/dist/types/ui/base.d.ts +0 -5
- package/dist/types/ui/base.d.ts.map +0 -1
- package/dist/types/ui/code.d.ts +0 -104
- package/dist/types/ui/code.d.ts.map +0 -1
- package/dist/types/ui/form.d.ts +0 -6
- package/dist/types/ui/form.d.ts.map +0 -1
- package/dist/types/ui/icon.d.ts +0 -6
- package/dist/types/ui/icon.d.ts.map +0 -1
- package/dist/types/ui/passkey.d.ts +0 -5
- package/dist/types/ui/passkey.d.ts.map +0 -1
- package/dist/types/ui/password.d.ts +0 -139
- package/dist/types/ui/password.d.ts.map +0 -1
- package/dist/types/ui/select.d.ts +0 -55
- package/dist/types/ui/select.d.ts.map +0 -1
- package/dist/types/ui/theme.d.ts +0 -207
- package/dist/types/ui/theme.d.ts.map +0 -1
- package/dist/types/util.d.ts +0 -8
- package/dist/types/util.d.ts.map +0 -1
- package/src/css.d.ts +0 -4
- package/src/issuer.ts +0 -1628
- package/src/jwt.ts +0 -17
- package/src/keys.ts +0 -139
- package/src/provider/apple.ts +0 -127
- package/src/provider/arctic.ts +0 -66
- package/src/provider/code.ts +0 -227
- package/src/provider/cognito.ts +0 -74
- package/src/provider/discord.ts +0 -45
- package/src/provider/facebook.ts +0 -84
- package/src/provider/github.ts +0 -45
- package/src/provider/google.ts +0 -85
- package/src/provider/index.ts +0 -3
- package/src/provider/jumpcloud.ts +0 -45
- package/src/provider/keycloak.ts +0 -75
- package/src/provider/linkedin.ts +0 -12
- package/src/provider/m2m.ts +0 -56
- package/src/provider/microsoft.ts +0 -100
- package/src/provider/oauth2.ts +0 -297
- package/src/provider/oidc.ts +0 -179
- package/src/provider/passkey.ts +0 -655
- package/src/provider/password.ts +0 -672
- package/src/provider/provider.ts +0 -33
- package/src/provider/slack.ts +0 -67
- package/src/provider/spotify.ts +0 -45
- package/src/provider/twitch.ts +0 -45
- package/src/provider/x.ts +0 -46
- package/src/provider/yahoo.ts +0 -45
- package/src/random.ts +0 -24
- package/src/storage/aws.ts +0 -59
- package/src/storage/cloudflare.ts +0 -77
- package/src/storage/dynamo.ts +0 -193
- package/src/storage/memory.ts +0 -135
- package/src/storage/storage.ts +0 -46
- package/src/subject.ts +0 -130
- package/src/ui/base.tsx +0 -118
- package/src/ui/code.tsx +0 -215
- package/src/ui/form.tsx +0 -40
- package/src/ui/icon.tsx +0 -95
- package/src/ui/passkey.tsx +0 -321
- package/src/ui/password.tsx +0 -405
- package/src/ui/select.tsx +0 -221
- package/src/ui/theme.ts +0 -319
- package/src/ui/ui.css +0 -252
- package/src/util.ts +0 -58
- /package/dist/esm/{css.d.js → adapters/d1/types.js} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ConfigStore` — tenant configuration lookup.
|
|
3
|
+
*
|
|
4
|
+
* Consistency contract: **eventual + bounded staleness (TTL ≤ 60 s).** This
|
|
5
|
+
* is a read-heavy, write-rare path; Cloudflare KV / read replicas are
|
|
6
|
+
* acceptable. Invalidation hook fires immediately on update so callers can
|
|
7
|
+
* drop stale entries earlier than TTL.
|
|
8
|
+
*
|
|
9
|
+
* See `ports/CONSISTENCY.md` for the full table.
|
|
10
|
+
*/
|
|
11
|
+
import type { Result } from "../types/result"
|
|
12
|
+
import type { TenantConfig, TenantId } from "../types/tenant"
|
|
13
|
+
|
|
14
|
+
export type ConfigStore = {
|
|
15
|
+
/**
|
|
16
|
+
* Look up a tenant's full config. Returns `tenant_not_found` if the id is
|
|
17
|
+
* unknown. Implementations should cache aggressively (TTL ≤ 60 s).
|
|
18
|
+
*/
|
|
19
|
+
getTenantConfig(id: TenantId): Promise<Result<TenantConfig>>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Persist (create or update) a tenant's config. Implementations must
|
|
23
|
+
* trigger invalidation of any cached value for `id` before resolving so
|
|
24
|
+
* a subsequent `getTenantConfig` returns the new value.
|
|
25
|
+
*/
|
|
26
|
+
putTenantConfig(config: TenantConfig): Promise<Result<void>>
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Optional: signal to in-process caches that a tenant's config has been
|
|
30
|
+
* invalidated externally (e.g. via the management console). Adapters that
|
|
31
|
+
* don't expose cross-process invalidation may omit this.
|
|
32
|
+
*/
|
|
33
|
+
onInvalidate?(handler: (id: TenantId) => void): void
|
|
34
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `KeyStore` — signing keys (JWT) and encryption keys (auth-code payload,
|
|
3
|
+
* other at-rest secrets).
|
|
4
|
+
*
|
|
5
|
+
* Per AD11, ES256 is the default signing algorithm; Ed25519 is supported.
|
|
6
|
+
*
|
|
7
|
+
* Consistency:
|
|
8
|
+
* - `currentSigningKey` — strong (active key must be unambiguous across
|
|
9
|
+
* the cluster).
|
|
10
|
+
* - `signingKeys` (JWKS) — eventual OK; verifiers tolerate brief lag
|
|
11
|
+
* during rotation.
|
|
12
|
+
* - Encryption keys — same as signing for consistency; rotated quarterly,
|
|
13
|
+
* old keys retained for `refreshTtl`.
|
|
14
|
+
*
|
|
15
|
+
* Note: `StateKeyRing` (HMAC keys for the `state` envelope) is **not** an
|
|
16
|
+
* abstraction over `KeyStore`. It is supplied directly via
|
|
17
|
+
* `IdPOptions.stateKeys` to avoid a bootstrap dependency on `KeyStore` for
|
|
18
|
+
* tenant resolution. A helper `loadStateKeyRingFromKeyStore` is offered
|
|
19
|
+
* for operators who choose to store the ring inside `KeyStore`.
|
|
20
|
+
*/
|
|
21
|
+
import type { Result } from "../types/result"
|
|
22
|
+
|
|
23
|
+
/** Asymmetric signing key. Public material is JWKS-exposed; private is server-only. */
|
|
24
|
+
export type SigningKey = {
|
|
25
|
+
kid: string
|
|
26
|
+
/** JOSE `alg` value, e.g. `"ES256"` or `"EdDSA"`. */
|
|
27
|
+
alg: string
|
|
28
|
+
/** JOSE `crv` for EC / OKP keys (`P-256`, `Ed25519`). Optional for other alg families. */
|
|
29
|
+
crv?: string
|
|
30
|
+
/** JWK form of the public key — published in JWKS. */
|
|
31
|
+
publicJwk: Record<string, unknown>
|
|
32
|
+
/**
|
|
33
|
+
* Opaque private-key handle. Concrete adapters interpret this:
|
|
34
|
+
* - In-memory / Postgres: a serialized JWK.
|
|
35
|
+
* - KMS-backed: a KMS key ARN / Cloudflare DO id.
|
|
36
|
+
*/
|
|
37
|
+
privateKeyRef: unknown
|
|
38
|
+
/** Status used by JWKS rotation logic. */
|
|
39
|
+
status: "active" | "next" | "retired"
|
|
40
|
+
createdAt: number
|
|
41
|
+
/** When this key may no longer be used to sign. Verification continues until removal. */
|
|
42
|
+
rotatedAt?: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Symmetric encryption key for the auth-code payload (and other at-rest data). */
|
|
46
|
+
export type EncryptionKey = {
|
|
47
|
+
kid: string
|
|
48
|
+
/** JOSE `alg`, e.g. `"A256GCM"`. */
|
|
49
|
+
alg: string
|
|
50
|
+
/** Opaque key handle (raw bytes for in-memory; KMS ref for cloud). */
|
|
51
|
+
keyRef: unknown
|
|
52
|
+
status: "active" | "next" | "retired"
|
|
53
|
+
createdAt: number
|
|
54
|
+
rotatedAt?: number
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Optional host-supplied envelope for wrapping private key material at rest.
|
|
59
|
+
*
|
|
60
|
+
* Adapters that persist signing-key private JWKs and encryption-key raw bytes
|
|
61
|
+
* to durable storage (Postgres, DynamoDB, …) accept a `KeyWrapper` so that
|
|
62
|
+
* material is encrypted with a key the database server cannot read. The
|
|
63
|
+
* canonical implementation backs `wrap` / `unwrap` with a cloud KMS
|
|
64
|
+
* (`AWS KMS Encrypt` / `Decrypt`, GCP KMS, Vault transit, etc.).
|
|
65
|
+
*
|
|
66
|
+
* Without a wrapper, `PostgresKeyStore` / `DynamoKeyStore` store private
|
|
67
|
+
* material in plaintext at rest — acceptable for dev / single-tenant
|
|
68
|
+
* operators with full-disk encryption who have accepted the trade-off, but
|
|
69
|
+
* **not** acceptable for production deployments with multi-tenant data. See
|
|
70
|
+
* `INTEGRATION.md` §4.
|
|
71
|
+
*/
|
|
72
|
+
export type KeyWrapper = {
|
|
73
|
+
/** Encrypt `plaintext` (≤ a few KB) under the host's master key. */
|
|
74
|
+
wrap(plaintext: Uint8Array): Promise<Uint8Array>
|
|
75
|
+
/** Decrypt a value previously returned by `wrap`. */
|
|
76
|
+
unwrap(ciphertext: Uint8Array): Promise<Uint8Array>
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type KeyStore = {
|
|
80
|
+
/** The unambiguous active signing key. Strong consistency. */
|
|
81
|
+
currentSigningKey(): Promise<Result<SigningKey>>
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* All keys to publish in JWKS — active + recently rotated, within the
|
|
85
|
+
* verification overlap window. Eventual consistency acceptable.
|
|
86
|
+
*/
|
|
87
|
+
signingKeys(): Promise<Result<SigningKey[]>>
|
|
88
|
+
|
|
89
|
+
/** Active encryption key for at-rest payload encryption. Strong consistency. */
|
|
90
|
+
currentEncryptionKey(): Promise<Result<EncryptionKey>>
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Look up a specific encryption key by `kid`. Used to decrypt payloads
|
|
94
|
+
* encrypted under a previous key during the overlap window.
|
|
95
|
+
*/
|
|
96
|
+
getEncryptionKey(kid: string): Promise<Result<EncryptionKey>>
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Rotate signing keys — promote `next` → `active`, retire current
|
|
100
|
+
* `active`, mint a new `next`. Phase 8 schedules this on a timer.
|
|
101
|
+
*/
|
|
102
|
+
rotateSigningKeys?(): Promise<Result<void>>
|
|
103
|
+
|
|
104
|
+
/** Same as `rotateSigningKeys` for encryption keys. Quarterly cadence. */
|
|
105
|
+
rotateEncryptionKeys?(): Promise<Result<void>>
|
|
106
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `MethodStore` — per-tenant `MethodConfig` lookup.
|
|
3
|
+
*
|
|
4
|
+
* This is a subset of `ConfigStore` exposed as a separate port for two
|
|
5
|
+
* reasons:
|
|
6
|
+
* 1. Adapters may want to back `MethodStore` with a more frequently
|
|
7
|
+
* invalidated cache than the full tenant config.
|
|
8
|
+
* 2. The management console can update auth-method config independently
|
|
9
|
+
* of other tenant-level fields.
|
|
10
|
+
*
|
|
11
|
+
* Consistency: same as `ConfigStore` — eventual + bounded staleness
|
|
12
|
+
* (TTL ≤ 60 s). Invalidation hook fires on update.
|
|
13
|
+
*/
|
|
14
|
+
import type { Result } from "../types/result"
|
|
15
|
+
import type { MethodConfig, TenantId } from "../types/tenant"
|
|
16
|
+
|
|
17
|
+
export type MethodStore = {
|
|
18
|
+
/** All method instances configured for a tenant (enabled and disabled). */
|
|
19
|
+
listMethods(tenantId: TenantId): Promise<Result<MethodConfig[]>>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Look up a single method instance by tenant-local id. Returns
|
|
23
|
+
* `method_not_found` if `methodId` does not exist in this tenant.
|
|
24
|
+
*/
|
|
25
|
+
getMethodConfig(
|
|
26
|
+
tenantId: TenantId,
|
|
27
|
+
methodId: string,
|
|
28
|
+
): Promise<Result<MethodConfig>>
|
|
29
|
+
|
|
30
|
+
/** Persist (create or update) a method instance. Triggers invalidation. */
|
|
31
|
+
putMethodConfig(
|
|
32
|
+
tenantId: TenantId,
|
|
33
|
+
method: MethodConfig,
|
|
34
|
+
): Promise<Result<void>>
|
|
35
|
+
|
|
36
|
+
/** Delete a method instance. Tokens issued by it remain valid until expiry. */
|
|
37
|
+
deleteMethodConfig(
|
|
38
|
+
tenantId: TenantId,
|
|
39
|
+
methodId: string,
|
|
40
|
+
): Promise<Result<void>>
|
|
41
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `SessionStore` — flow records (required) and optional long-lived sessions.
|
|
3
|
+
*
|
|
4
|
+
* Flow records are the single server-side source of truth for an in-flight
|
|
5
|
+
* authorization. They are written at `/authorize`, updated when a method
|
|
6
|
+
* returns a `challenge` with `saveMethodState`, and consumed exactly once
|
|
7
|
+
* on the upstream callback.
|
|
8
|
+
*
|
|
9
|
+
* The framework owns flow-record I/O — methods only observe
|
|
10
|
+
* (`MethodContext.flow`) and request updates via
|
|
11
|
+
* `MethodResult.challenge.saveMethodState`. Methods MUST NOT call
|
|
12
|
+
* `saveFlow` / `consumeFlow` directly.
|
|
13
|
+
*
|
|
14
|
+
* See `ports/CONSISTENCY.md`.
|
|
15
|
+
*/
|
|
16
|
+
import type { FlowRecord } from "../types/flow"
|
|
17
|
+
import type { Result } from "../types/result"
|
|
18
|
+
|
|
19
|
+
export type SessionStore = {
|
|
20
|
+
/**
|
|
21
|
+
* Persist a new flow record under `flowId`. Strong, atomic write — the
|
|
22
|
+
* record must be visible to `consumeFlow` on any node by the time this
|
|
23
|
+
* resolves. `ttl` is in milliseconds and must equal `expiresAt -
|
|
24
|
+
* createdAt` on the supplied record (default 10 minutes).
|
|
25
|
+
*/
|
|
26
|
+
saveFlow(
|
|
27
|
+
flowId: string,
|
|
28
|
+
payload: FlowRecord,
|
|
29
|
+
ttl: number,
|
|
30
|
+
): Promise<Result<void>>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Merge `methodState` into an existing flow record. The framework calls
|
|
34
|
+
* this when a method handler returns
|
|
35
|
+
* `{ kind: "challenge", saveMethodState }`, **before** sending the
|
|
36
|
+
* upstream redirect response — the user agent never sees the redirect
|
|
37
|
+
* until `methodState` is durably saved.
|
|
38
|
+
*
|
|
39
|
+
* Returns `unknown_state` if `flowId` is missing or already consumed.
|
|
40
|
+
*/
|
|
41
|
+
updateFlowMethodState(
|
|
42
|
+
flowId: string,
|
|
43
|
+
methodState: unknown,
|
|
44
|
+
): Promise<Result<void>>
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* **Peek** at a flow record without consuming it. Used by the method-route
|
|
48
|
+
* mount (Phase 4) where credential POSTs may need to dispatch the
|
|
49
|
+
* method multiple times before the flow is consumed on `success`.
|
|
50
|
+
*
|
|
51
|
+
* Consistency: strong (the record must be visible to a `consumeFlow`
|
|
52
|
+
* called immediately after). Returns `unknown_state` if missing /
|
|
53
|
+
* expired.
|
|
54
|
+
*
|
|
55
|
+
* The framework is the only legitimate caller; methods should never read
|
|
56
|
+
* the flow directly — they observe via `MethodContext.flow`.
|
|
57
|
+
*/
|
|
58
|
+
readFlow(flowId: string): Promise<Result<FlowRecord>>
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Atomic delete-on-read. Returns the full `FlowRecord` on success — the
|
|
62
|
+
* framework needs every field to snapshot into the auth-code payload
|
|
63
|
+
* before the record is gone. Concurrent calls with the same `flowId`
|
|
64
|
+
* resolve to exactly one winner; losers receive `unknown_state` which
|
|
65
|
+
* the HTTP layer maps to `invalid_request` (audit
|
|
66
|
+
* `flow_replay_attempt`).
|
|
67
|
+
*
|
|
68
|
+
* This is the **only** consume; the framework does not call it twice.
|
|
69
|
+
* Methods receive the in-memory record via `MethodContext.flow` for the
|
|
70
|
+
* rest of the callback request.
|
|
71
|
+
*/
|
|
72
|
+
consumeFlow(flowId: string): Promise<Result<FlowRecord>>
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Optional: long-lived session support (cross-request remember-me beyond
|
|
76
|
+
* the OAuth flow). Adapters that don't implement this can omit it; the
|
|
77
|
+
* framework only requires the flow-record methods above.
|
|
78
|
+
*/
|
|
79
|
+
createSession?(
|
|
80
|
+
sessionId: string,
|
|
81
|
+
payload: SessionRecord,
|
|
82
|
+
ttl: number,
|
|
83
|
+
): Promise<Result<void>>
|
|
84
|
+
readSession?(sessionId: string): Promise<Result<SessionRecord>>
|
|
85
|
+
revokeSession?(sessionId: string): Promise<Result<void>>
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Optional: Pushed Authorization Request (RFC 9126) storage. Persists the
|
|
89
|
+
* pre-parsed `/authorize` parameters under an opaque `request_uri` for
|
|
90
|
+
* one-shot retrieval at `/authorize` time. Strong consistency + atomic
|
|
91
|
+
* delete-on-read — same semantics as `saveFlow` / `consumeFlow`.
|
|
92
|
+
*
|
|
93
|
+
* Adapters without these methods cannot satisfy `/par`; the framework's
|
|
94
|
+
* `/par` handler returns `invalid_request` when called against such a
|
|
95
|
+
* store. Implement both methods together (the framework only exposes
|
|
96
|
+
* the endpoint when both are present).
|
|
97
|
+
*/
|
|
98
|
+
savePar?(
|
|
99
|
+
requestUri: string,
|
|
100
|
+
payload: ParRecord,
|
|
101
|
+
ttl: number,
|
|
102
|
+
): Promise<Result<void>>
|
|
103
|
+
consumePar?(requestUri: string): Promise<Result<ParRecord>>
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Stored PAR payload. The `params` blob is the raw form/query record from
|
|
108
|
+
* `POST /par`, kept verbatim so the `/authorize` rehydrate path can feed
|
|
109
|
+
* it through the same Zod parser the direct path uses.
|
|
110
|
+
*/
|
|
111
|
+
export type ParRecord = {
|
|
112
|
+
requestUri: string
|
|
113
|
+
/** Raw key/value record as posted to `/par` (excluding auth fields). */
|
|
114
|
+
params: Record<string, string>
|
|
115
|
+
clientId: string
|
|
116
|
+
/** Wall-clock issuance + absolute expiry (ms). */
|
|
117
|
+
issuedAt: number
|
|
118
|
+
expiresAt: number
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Optional long-lived session payload (used by `createSession` family). */
|
|
122
|
+
export type SessionRecord = {
|
|
123
|
+
sessionId: string
|
|
124
|
+
tenantId: string
|
|
125
|
+
subjectId: string
|
|
126
|
+
/** Wall-clock issued / expires timestamps (ms). */
|
|
127
|
+
issuedAt: number
|
|
128
|
+
expiresAt: number
|
|
129
|
+
/** Free-form metadata adapters may use (device, user agent fingerprint, etc.). */
|
|
130
|
+
metadata?: Record<string, unknown>
|
|
131
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `TokenStore` — authorization codes + refresh tokens.
|
|
3
|
+
*
|
|
4
|
+
* All methods on this port are **security-critical** and require strong,
|
|
5
|
+
* atomic semantics. Cloudflare KV is **not** an acceptable backing store
|
|
6
|
+
* for any method here; use D1 (Sessions API w/ bookmarks), Durable Objects,
|
|
7
|
+
* Postgres (`SELECT FOR UPDATE`), or DynamoDB with conditional writes.
|
|
8
|
+
*
|
|
9
|
+
* See `ports/CONSISTENCY.md` §"Per-method consistency contracts".
|
|
10
|
+
*/
|
|
11
|
+
import type { RefreshTokenPayload } from "../types/token"
|
|
12
|
+
import type { Result } from "../types/result"
|
|
13
|
+
import type { TenantId } from "../types/tenant"
|
|
14
|
+
|
|
15
|
+
export type TokenStore = {
|
|
16
|
+
/**
|
|
17
|
+
* Persist an auth-code ciphertext blob under `code`.
|
|
18
|
+
*
|
|
19
|
+
* The blob is **opaque** to the adapter — the framework encrypts the
|
|
20
|
+
* `CodePayload` at the domain boundary (`domain/authorize.ts` →
|
|
21
|
+
* `domain/crypto.encryptPayload`) before calling `saveCode`. Adapters
|
|
22
|
+
* must not parse, transform, or otherwise interpret the blob; just
|
|
23
|
+
* store it verbatim and return it on `consumeCode`.
|
|
24
|
+
*
|
|
25
|
+
* Required semantics:
|
|
26
|
+
* - Strong, atomic write (the row must be visible to the next
|
|
27
|
+
* `consumeCode` call on any node).
|
|
28
|
+
* - `ttl` must be ≤ the framework's auth-code TTL (60 s).
|
|
29
|
+
* Implementations that receive a larger value must reject.
|
|
30
|
+
*/
|
|
31
|
+
saveCode(code: string, ciphertext: string, ttl: number): Promise<Result<void>>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Single-use, atomic compare-and-swap: return and delete the
|
|
35
|
+
* ciphertext blob in one logical operation. Concurrent calls with the
|
|
36
|
+
* same `code` must resolve to exactly one winner; losers receive
|
|
37
|
+
* `invalid_grant`. The caller (`domain/token.exchangeCode`) decrypts
|
|
38
|
+
* the returned blob.
|
|
39
|
+
*/
|
|
40
|
+
consumeCode(code: string): Promise<Result<string>>
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Persist a refresh-token payload. Strong, atomic. New tokens issued
|
|
44
|
+
* during rotation must be immediately retrievable.
|
|
45
|
+
*/
|
|
46
|
+
saveRefresh(
|
|
47
|
+
refresh: string,
|
|
48
|
+
payload: RefreshTokenPayload,
|
|
49
|
+
): Promise<Result<void>>
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Rotate a refresh token. Strong CAS with reuse-detection window.
|
|
53
|
+
*
|
|
54
|
+
* Implementations must:
|
|
55
|
+
* - Atomically check the token is unconsumed, mark it consumed, and
|
|
56
|
+
* return its payload — concurrent presentations of the same token
|
|
57
|
+
* resolve to exactly one winner.
|
|
58
|
+
* - Within the reuse window (default 60 s), the consumed token must
|
|
59
|
+
* still be detectable so a second presentation can trigger
|
|
60
|
+
* revoke-the-whole-family. Outside the window the row may be GC'd.
|
|
61
|
+
* - On reuse-detection (second consume within the window), return an
|
|
62
|
+
* `invalid_grant` error **with a `reuseSignal` carrier** containing
|
|
63
|
+
* the compromised refresh chain's `family`, `tenantId`, and
|
|
64
|
+
* `subjectId`. The framework's refresh-grant handler reads
|
|
65
|
+
* `reuseSignal` directly to emit `refresh_reuse_detected` audit
|
|
66
|
+
* events. Adapters that omit the signal degrade audit fidelity (the
|
|
67
|
+
* framework falls back to the peeked-payload values) but remain
|
|
68
|
+
* behavior-compatible.
|
|
69
|
+
*/
|
|
70
|
+
consumeRefresh(
|
|
71
|
+
refresh: string,
|
|
72
|
+
options?: { reuseWindowMs?: number },
|
|
73
|
+
): Promise<Result<RefreshTokenPayload>>
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Non-destructive lookup. Returns the refresh-token payload without
|
|
77
|
+
* marking it consumed.
|
|
78
|
+
*
|
|
79
|
+
* Used by RFC 7009 `/revoke` to enforce token-to-client binding
|
|
80
|
+
* (§2.2) before destructively consuming. Returns `invalid_grant` for
|
|
81
|
+
* unknown or expired tokens; `peekRefresh` does **not** trigger
|
|
82
|
+
* reuse-detection — a token already past `consumeRefresh` is still
|
|
83
|
+
* reported here so the caller can decide whether to escalate.
|
|
84
|
+
*
|
|
85
|
+
* Eventual consistency is acceptable: callers race `peekRefresh` then
|
|
86
|
+
* `consumeRefresh`, and the atomicity guarantees of `consumeRefresh`
|
|
87
|
+
* remain authoritative.
|
|
88
|
+
*/
|
|
89
|
+
peekRefresh(refresh: string): Promise<Result<RefreshTokenPayload>>
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Revoke all refresh tokens whose `RefreshTokenPayload.family` equals
|
|
93
|
+
* `family`. Used by reuse-detection to invalidate every descendant of a
|
|
94
|
+
* compromised refresh chain.
|
|
95
|
+
*/
|
|
96
|
+
revokeFamily(family: string): Promise<Result<void>>
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Revoke every refresh token for the given (tenant, subject) pair. Strong
|
|
100
|
+
* preferred; documented eventual lag acceptable.
|
|
101
|
+
*/
|
|
102
|
+
revokeBySubject(tenantId: TenantId, subjectId: string): Promise<Result<void>>
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Optional: DPoP proof replay protection (RFC 9449 §11.1). Atomically
|
|
106
|
+
* record the proof's `jti` and reject if it's been seen within the TTL
|
|
107
|
+
* window. Returns `invalid_grant` (with `reuseSignal` omitted) when a
|
|
108
|
+
* `jti` is already present.
|
|
109
|
+
*
|
|
110
|
+
* Adapters without this method cannot satisfy DPoP at the token /
|
|
111
|
+
* userinfo endpoints; the framework's DPoP verifier returns
|
|
112
|
+
* `invalid_dpop_proof` when called against such a store. Memory adapter
|
|
113
|
+
* implements; production adapters follow in subsequent commits.
|
|
114
|
+
*/
|
|
115
|
+
recordDpopJti?(jti: string, ttlMs: number): Promise<Result<void>>
|
|
116
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authorization-request domain shapes. The HTTP layer parses the raw
|
|
3
|
+
* `/authorize` query into `AuthorizationRequest`; the domain operates on
|
|
4
|
+
* that.
|
|
5
|
+
*/
|
|
6
|
+
import type { TenantId } from "./tenant"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Parsed `/authorize` request. The HTTP layer is responsible for schema
|
|
10
|
+
* validation (Zod) and for rejecting `response_type=token` per OAuth 2.1.
|
|
11
|
+
*
|
|
12
|
+
* `audience` and OIDC-specific fields (`prompt`, `uiLocales`, `nonce`) are
|
|
13
|
+
* optional and threaded into the `FlowRecord`.
|
|
14
|
+
*/
|
|
15
|
+
export type AuthorizationRequest = {
|
|
16
|
+
tenantId: TenantId
|
|
17
|
+
clientId: string
|
|
18
|
+
redirectUri: string
|
|
19
|
+
/** OAuth 2.1: `code` only. */
|
|
20
|
+
responseType: "code"
|
|
21
|
+
scopes: string[]
|
|
22
|
+
/** Relying party's CSRF state. Echoed back at success; opaque to the IdP. */
|
|
23
|
+
state: string | null
|
|
24
|
+
audience?: string
|
|
25
|
+
/** Tenant-local method instance id (`MethodConfig.id`) the RP selected, if any. */
|
|
26
|
+
methodId?: string
|
|
27
|
+
/**
|
|
28
|
+
* Relying-party PKCE challenge. Required for public clients; the framework
|
|
29
|
+
* additionally requires it for any client where `ClientConfig.pkceRequired`
|
|
30
|
+
* is true (default true).
|
|
31
|
+
*/
|
|
32
|
+
codeChallenge?: string
|
|
33
|
+
codeChallengeMethod?: "S256"
|
|
34
|
+
/** Standard OIDC. */
|
|
35
|
+
prompt?: string[]
|
|
36
|
+
/** Standard OIDC. */
|
|
37
|
+
uiLocales?: string[]
|
|
38
|
+
/** Standard OIDC. */
|
|
39
|
+
nonce?: string
|
|
40
|
+
/**
|
|
41
|
+
* OIDC Core §5.5 — RP-requested claims, parsed from the `claims`
|
|
42
|
+
* parameter's JSON value. The library currently honors claim **names**
|
|
43
|
+
* (additive, bypasses scope gating) but does not enforce the
|
|
44
|
+
* `essential` / `value` / `values` qualifiers.
|
|
45
|
+
*/
|
|
46
|
+
claimsRequest?: ClaimsRequest
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* OIDC Core §5.5 `claims` parameter. Each section maps claim name to an
|
|
51
|
+
* optional qualifier object (`{essential, value, values}`) or `null`
|
|
52
|
+
* meaning "just request the claim without qualifiers".
|
|
53
|
+
*/
|
|
54
|
+
export type ClaimsRequest = {
|
|
55
|
+
/** Claims to include in the `/userinfo` response. */
|
|
56
|
+
userinfo?: Record<string, ClaimRequestEntry | null>
|
|
57
|
+
/** Claims to include in the `id_token`. */
|
|
58
|
+
id_token?: Record<string, ClaimRequestEntry | null>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type ClaimRequestEntry = {
|
|
62
|
+
essential?: boolean
|
|
63
|
+
value?: unknown
|
|
64
|
+
values?: unknown[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* In-memory authorization state produced by `domain/authorize.startAuthorize`
|
|
69
|
+
* when it has not yet emitted a `Response` (e.g. method selection UI was
|
|
70
|
+
* not needed because only one method is configured, so the domain returns
|
|
71
|
+
* the chosen state directly for the next stage to act on).
|
|
72
|
+
*/
|
|
73
|
+
export type AuthorizationState = {
|
|
74
|
+
tenantId: TenantId
|
|
75
|
+
flowId: string
|
|
76
|
+
methodId: string
|
|
77
|
+
methodKind: string
|
|
78
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthError — the closed taxonomy returned by every domain function on failure.
|
|
3
|
+
*
|
|
4
|
+
* Codes map 1:1 to OAuth 2.0 / RFC 6749 §5.2 error identifiers, plus a handful
|
|
5
|
+
* of framework-internal codes used before the HTTP layer is reached. The HTTP
|
|
6
|
+
* layer translates `AuthError` into a response (`server_error` is the public
|
|
7
|
+
* mapping for `internal_error` at OAuth endpoints).
|
|
8
|
+
*/
|
|
9
|
+
export type AuthError =
|
|
10
|
+
| { code: "invalid_request"; description: string; field?: string }
|
|
11
|
+
| { code: "invalid_client"; description: string }
|
|
12
|
+
/**
|
|
13
|
+
* `invalid_grant`. `reuseSignal`, when present, is the structured
|
|
14
|
+
* reuse-detection hint `TokenStore.consumeRefresh` adapters emit on a
|
|
15
|
+
* second-use-within-the-window — used by the refresh-grant handler to
|
|
16
|
+
* audit `refresh_reuse_detected` with branded `TenantId` / `subjectId`
|
|
17
|
+
* fields rather than parsing strings out of `description`.
|
|
18
|
+
*/
|
|
19
|
+
| {
|
|
20
|
+
code: "invalid_grant"
|
|
21
|
+
description: string
|
|
22
|
+
reuseSignal?: {
|
|
23
|
+
family: string
|
|
24
|
+
tenantId: string
|
|
25
|
+
subjectId: string
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
| { code: "unauthorized_client"; description: string }
|
|
29
|
+
| { code: "unsupported_grant_type"; description: string }
|
|
30
|
+
| { code: "invalid_scope"; description: string }
|
|
31
|
+
| { code: "access_denied"; description: string }
|
|
32
|
+
| { code: "unknown_state"; description: string }
|
|
33
|
+
// RFC 6749 §5.2 — token endpoint server-side failure (hook threw, downstream
|
|
34
|
+
// unavailable, etc.). Carries an optional `cause` for audit; not returned to
|
|
35
|
+
// the relying party.
|
|
36
|
+
| { code: "server_error"; description: string; cause?: unknown }
|
|
37
|
+
| { code: "tenant_not_found"; description: string; tenantId: string }
|
|
38
|
+
// RFC 8693 §2.2.2 — token-exchange "audience the subject can't reach"
|
|
39
|
+
// signal. Surfaced when the host's `exchangeAudience` hook rejects.
|
|
40
|
+
| { code: "invalid_target"; description: string }
|
|
41
|
+
// Populate whichever was requested (id from MethodConfig.id, or kind from
|
|
42
|
+
// MethodConfig.kind) so operators can find the offending config row.
|
|
43
|
+
| {
|
|
44
|
+
code: "method_not_found"
|
|
45
|
+
description: string
|
|
46
|
+
methodId?: string
|
|
47
|
+
methodKind?: string
|
|
48
|
+
}
|
|
49
|
+
// Framework-internal; the HTTP layer maps this to `server_error` at OAuth
|
|
50
|
+
// endpoints. Use for control-flow signalling that should never escape to a
|
|
51
|
+
// standards-compliant client.
|
|
52
|
+
| { code: "internal_error"; description: string; cause?: unknown }
|
|
53
|
+
// RFC 9449 §5.2 — DPoP proof verification failed (bad signature, htm/htu
|
|
54
|
+
// mismatch, iat outside window, replayed jti, missing/mismatched cnf.jkt).
|
|
55
|
+
// Returned as a 400 with `error="invalid_dpop_proof"` on form-body
|
|
56
|
+
// endpoints; on resource-server endpoints it becomes a 401 with
|
|
57
|
+
// `WWW-Authenticate: DPoP error="invalid_dpop_proof"`.
|
|
58
|
+
//
|
|
59
|
+
// `replaySignal`, when present, indicates `recordDpopJti` reported a
|
|
60
|
+
// jti already seen within the replay window. The HTTP layer uses this
|
|
61
|
+
// to emit a `dpop_replay_detected` audit event distinct from other
|
|
62
|
+
// proof failures.
|
|
63
|
+
| {
|
|
64
|
+
code: "invalid_dpop_proof"
|
|
65
|
+
description: string
|
|
66
|
+
replaySignal?: { jti: string }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type AuthErrorCode = AuthError["code"]
|
|
70
|
+
|
|
71
|
+
/** Narrow constructor helpers — keep call sites short and types tight. */
|
|
72
|
+
export const authError = {
|
|
73
|
+
invalidRequest: (description: string, field?: string): AuthError => ({
|
|
74
|
+
code: "invalid_request",
|
|
75
|
+
description,
|
|
76
|
+
...(field !== undefined ? { field } : {}),
|
|
77
|
+
}),
|
|
78
|
+
invalidClient: (description: string): AuthError => ({
|
|
79
|
+
code: "invalid_client",
|
|
80
|
+
description,
|
|
81
|
+
}),
|
|
82
|
+
invalidGrant: (
|
|
83
|
+
description: string,
|
|
84
|
+
reuseSignal?: { family: string; tenantId: string; subjectId: string },
|
|
85
|
+
): AuthError => ({
|
|
86
|
+
code: "invalid_grant",
|
|
87
|
+
description,
|
|
88
|
+
...(reuseSignal !== undefined ? { reuseSignal } : {}),
|
|
89
|
+
}),
|
|
90
|
+
unauthorizedClient: (description: string): AuthError => ({
|
|
91
|
+
code: "unauthorized_client",
|
|
92
|
+
description,
|
|
93
|
+
}),
|
|
94
|
+
unsupportedGrantType: (description: string): AuthError => ({
|
|
95
|
+
code: "unsupported_grant_type",
|
|
96
|
+
description,
|
|
97
|
+
}),
|
|
98
|
+
invalidScope: (description: string): AuthError => ({
|
|
99
|
+
code: "invalid_scope",
|
|
100
|
+
description,
|
|
101
|
+
}),
|
|
102
|
+
accessDenied: (description: string): AuthError => ({
|
|
103
|
+
code: "access_denied",
|
|
104
|
+
description,
|
|
105
|
+
}),
|
|
106
|
+
unknownState: (description: string): AuthError => ({
|
|
107
|
+
code: "unknown_state",
|
|
108
|
+
description,
|
|
109
|
+
}),
|
|
110
|
+
serverError: (description: string, cause?: unknown): AuthError => ({
|
|
111
|
+
code: "server_error",
|
|
112
|
+
description,
|
|
113
|
+
...(cause !== undefined ? { cause } : {}),
|
|
114
|
+
}),
|
|
115
|
+
tenantNotFound: (description: string, tenantId: string): AuthError => ({
|
|
116
|
+
code: "tenant_not_found",
|
|
117
|
+
description,
|
|
118
|
+
tenantId,
|
|
119
|
+
}),
|
|
120
|
+
methodNotFound: (
|
|
121
|
+
description: string,
|
|
122
|
+
refs: { methodId?: string; methodKind?: string },
|
|
123
|
+
): AuthError => ({
|
|
124
|
+
code: "method_not_found",
|
|
125
|
+
description,
|
|
126
|
+
...(refs.methodId !== undefined ? { methodId: refs.methodId } : {}),
|
|
127
|
+
...(refs.methodKind !== undefined ? { methodKind: refs.methodKind } : {}),
|
|
128
|
+
}),
|
|
129
|
+
invalidTarget: (description: string): AuthError => ({
|
|
130
|
+
code: "invalid_target",
|
|
131
|
+
description,
|
|
132
|
+
}),
|
|
133
|
+
internalError: (description: string, cause?: unknown): AuthError => ({
|
|
134
|
+
code: "internal_error",
|
|
135
|
+
description,
|
|
136
|
+
...(cause !== undefined ? { cause } : {}),
|
|
137
|
+
}),
|
|
138
|
+
invalidDpopProof: (
|
|
139
|
+
description: string,
|
|
140
|
+
replaySignal?: { jti: string },
|
|
141
|
+
): AuthError => ({
|
|
142
|
+
code: "invalid_dpop_proof",
|
|
143
|
+
description,
|
|
144
|
+
...(replaySignal !== undefined ? { replaySignal } : {}),
|
|
145
|
+
}),
|
|
146
|
+
}
|