@_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,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `AuthMethod` — the core pluggable authentication abstraction.
|
|
3
|
+
*
|
|
4
|
+
* AD2: methods are **data + handler functions**, not framework modules. They
|
|
5
|
+
* depend on Web Fetch `Request`/`Response` (Web standards available on every
|
|
6
|
+
* runtime) and on a small `MethodContext` of plain data. The full allowed
|
|
7
|
+
* import set for files under `src/methods/` is `src/types/`,
|
|
8
|
+
* `src/domain/crypto`, `src/ui/forms`, sibling `src/methods/*`, and
|
|
9
|
+
* method-specific third-party libraries (e.g. `zod`,
|
|
10
|
+
* `@simplewebauthn/server`); methods MUST NOT import from `src/http/`,
|
|
11
|
+
* `src/adapters/`, or `src/ports/`, and never from Hono or any other HTTP
|
|
12
|
+
* framework. This `types/method.ts` file in particular is enforced
|
|
13
|
+
* framework-import-free by CI lint. See ARCHITECTURE.md §"Methods plug
|
|
14
|
+
* in alongside this stack" for the full contract.
|
|
15
|
+
*
|
|
16
|
+
* Cookies and other policy-sensitive response headers are returned as data
|
|
17
|
+
* (`SetCookie[]`, `CachePolicy`) and applied to the final `Response` by the
|
|
18
|
+
* HTTP layer. The HTTP layer also strips a fixed allowlist-violating set of
|
|
19
|
+
* headers from method-returned `Response` instances (`Set-Cookie`, security
|
|
20
|
+
* headers, `Cache-Control`) so methods cannot bypass framework policy. See
|
|
21
|
+
* `ARCHITECTURE.md` §"Response sanitization".
|
|
22
|
+
*/
|
|
23
|
+
import type { v1 } from "@standard-schema/spec"
|
|
24
|
+
|
|
25
|
+
import type { AuthError } from "./error"
|
|
26
|
+
import type { FlowRecord } from "./flow"
|
|
27
|
+
import type { Result } from "./result"
|
|
28
|
+
import type { MethodType, TenantContext, TenantId } from "./tenant"
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A built, ready-to-dispatch auth method instance for a particular tenant.
|
|
32
|
+
*
|
|
33
|
+
* Generics:
|
|
34
|
+
* - `P`: properties type emitted to the user's `success` callback on a
|
|
35
|
+
* successful authentication. Typed per method.
|
|
36
|
+
* - `S`: method-private state stashed in `FlowRecord.methodState`. Opaque
|
|
37
|
+
* to the framework; the method reads and writes it through
|
|
38
|
+
* `MethodContext.methodState` and `MethodResult.challenge.saveMethodState`.
|
|
39
|
+
*/
|
|
40
|
+
export type AuthMethod<P = unknown, S = unknown> = {
|
|
41
|
+
/**
|
|
42
|
+
* Tenant-local instance id. Populated by the factory from
|
|
43
|
+
* `MethodConfig.id`. The framework dispatches URL routes by this value.
|
|
44
|
+
*/
|
|
45
|
+
id: string
|
|
46
|
+
/**
|
|
47
|
+
* Factory kind. Populated by the factory from `MethodConfig.kind`. Used to
|
|
48
|
+
* tell the user's `success` callback which provider produced the result.
|
|
49
|
+
*/
|
|
50
|
+
kind: string
|
|
51
|
+
type: MethodType
|
|
52
|
+
/**
|
|
53
|
+
* Routes the method declares. Key format: `"GET /authorize"`,
|
|
54
|
+
* `"POST /callback"`, etc. The HTTP layer mounts these under
|
|
55
|
+
* `/<AuthMethod.id>/*` (tenant-local instance id, so two instances of the
|
|
56
|
+
* same factory get distinct URL spaces).
|
|
57
|
+
*/
|
|
58
|
+
routes: Record<string, MethodHandler<P, S>>
|
|
59
|
+
/**
|
|
60
|
+
* Token-exchange function for the `/token` endpoint when the method
|
|
61
|
+
* participates in client-credentials-style flows (e.g. `m2m`). Most
|
|
62
|
+
* redirect-based methods do not set this.
|
|
63
|
+
*/
|
|
64
|
+
client?: ClientFn<P>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type MethodHandler<P, S> = (
|
|
68
|
+
ctx: MethodContext<S>,
|
|
69
|
+
) => Promise<MethodResult<P, S>>
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Per-request context handed to a method handler.
|
|
73
|
+
*
|
|
74
|
+
* Methods **do not** receive raw `MethodConfig.config`. The factory captured
|
|
75
|
+
* the validated config via closure in `build`, so the handler only sees
|
|
76
|
+
* request-scoped data here.
|
|
77
|
+
*
|
|
78
|
+
* `cookies` is `ReadonlyMap` because methods don't get to mutate the
|
|
79
|
+
* incoming cookie jar — they return `SetCookie[]` instructions and the
|
|
80
|
+
* framework applies them.
|
|
81
|
+
*/
|
|
82
|
+
export type MethodContext<S = unknown> = {
|
|
83
|
+
/** The raw Web Fetch `Request`. Web standard, not Hono `Context`. */
|
|
84
|
+
request: Request
|
|
85
|
+
/** Path within the method's mount, e.g. `"/callback"` (without the `/<id>` prefix). */
|
|
86
|
+
subPath: string
|
|
87
|
+
tenant: TenantContext
|
|
88
|
+
/** `null` while `/authorize` is being initiated; populated on callback. */
|
|
89
|
+
flow: FlowRecord | null
|
|
90
|
+
/**
|
|
91
|
+
* Shortcut to `flow?.methodState`, narrowed to this method's `S` generic.
|
|
92
|
+
* `null` when there is no flow yet or no state has been written.
|
|
93
|
+
*/
|
|
94
|
+
methodState: S | null
|
|
95
|
+
/** Parsed cookies from the incoming `Request`. Read-only. */
|
|
96
|
+
cookies: ReadonlyMap<string, string>
|
|
97
|
+
/**
|
|
98
|
+
* Framework-supplied dispatch data. Populated for the `GET /authorize`
|
|
99
|
+
* initiation so the method can build an upstream redirect carrying the
|
|
100
|
+
* framework-minted state envelope; `null` for callback handlers (the
|
|
101
|
+
* framework has already verified `state` and the flow record by then,
|
|
102
|
+
* and the relevant data is on `flow`).
|
|
103
|
+
*/
|
|
104
|
+
dispatch: MethodDispatchData | null
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Framework-supplied data available to the method at `/authorize` time. */
|
|
108
|
+
export type MethodDispatchData = {
|
|
109
|
+
/**
|
|
110
|
+
* The MAC-signed state envelope the method must include in any upstream
|
|
111
|
+
* redirect. Opaque to the method.
|
|
112
|
+
*/
|
|
113
|
+
state: string
|
|
114
|
+
/**
|
|
115
|
+
* Fully qualified callback URL the upstream provider should redirect to.
|
|
116
|
+
* Methods include this as `redirect_uri` (OAuth) or its equivalent.
|
|
117
|
+
*/
|
|
118
|
+
callbackUrl: string
|
|
119
|
+
/** The issuer URL of this IdP. Methods may include in upstream OIDC requests. */
|
|
120
|
+
issuerUrl: string
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Discriminated union returned by a `MethodHandler`. The HTTP layer applies
|
|
125
|
+
* the result: rendering the challenge response, kicking off token issuance
|
|
126
|
+
* on success, or surfacing the error.
|
|
127
|
+
*/
|
|
128
|
+
export type MethodResult<P = unknown, S = unknown> =
|
|
129
|
+
/**
|
|
130
|
+
* Render UI / redirect to upstream / otherwise pause the flow waiting for
|
|
131
|
+
* the user agent. `setCookies` is applied via the framework's serializer
|
|
132
|
+
* (which enforces `Secure`, `SameSite`, `HttpOnly` defaults).
|
|
133
|
+
* `saveMethodState` is merged into `FlowRecord.methodState` and persisted
|
|
134
|
+
* **before** the response is sent — the user agent never sees the
|
|
135
|
+
* upstream redirect until the upstream verifier / nonce / state is
|
|
136
|
+
* durably saved.
|
|
137
|
+
*/
|
|
138
|
+
| {
|
|
139
|
+
kind: "challenge"
|
|
140
|
+
/** Body + non-policy headers. Policy-sensitive headers are stripped. */
|
|
141
|
+
response: Response
|
|
142
|
+
setCookies?: SetCookie[]
|
|
143
|
+
saveMethodState?: S
|
|
144
|
+
/** Serialized into a `Cache-Control` header by the framework. */
|
|
145
|
+
cache?: CachePolicy
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Authentication succeeded. The HTTP layer hands `providerSubject` +
|
|
149
|
+
* `properties` to the user's `IdPOptions.success` callback to mint the
|
|
150
|
+
* final `SubjectClaim`. Methods never construct the final subject.
|
|
151
|
+
*/
|
|
152
|
+
| {
|
|
153
|
+
kind: "success"
|
|
154
|
+
/** Upstream system's stable identifier for the authenticated principal. */
|
|
155
|
+
providerSubject: string
|
|
156
|
+
properties: P
|
|
157
|
+
setCookies?: SetCookie[]
|
|
158
|
+
}
|
|
159
|
+
/** User refused / failed auth in a non-error way (e.g. consent declined). */
|
|
160
|
+
| { kind: "denied"; reason: string; setCookies?: SetCookie[] }
|
|
161
|
+
/** Method hit an error. The HTTP layer maps to a standards-compliant response. */
|
|
162
|
+
| { kind: "error"; error: AuthError }
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Cache policy for `MethodResult.challenge`. Methods do **not** set
|
|
166
|
+
* `Cache-Control` directly — the framework strips that header from any
|
|
167
|
+
* method-returned `Response`. Opt in to caching via this typed field; the
|
|
168
|
+
* framework serializes it.
|
|
169
|
+
*/
|
|
170
|
+
export type CachePolicy = {
|
|
171
|
+
/** Seconds. `0` ≡ `no-store`. Default for auth UI. */
|
|
172
|
+
maxAge?: number
|
|
173
|
+
/** Shared (CDN) cache TTL. */
|
|
174
|
+
sMaxAge?: number
|
|
175
|
+
/** Adds `Cache-Control: private`. */
|
|
176
|
+
isPrivate?: boolean
|
|
177
|
+
/** For static assets only. */
|
|
178
|
+
immutable?: boolean
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Cookie instruction returned from a method, applied by the framework's
|
|
183
|
+
* cookie serializer. Defaults enforced: `Secure` in production, `SameSite`
|
|
184
|
+
* defaults to `Lax`, `HttpOnly` defaults to true for any cookie name in the
|
|
185
|
+
* framework's reserved namespace (`auth.*` / `idp.*`).
|
|
186
|
+
*/
|
|
187
|
+
export type SetCookie = {
|
|
188
|
+
name: string
|
|
189
|
+
/** `null` clears the cookie (`Max-Age=0`). */
|
|
190
|
+
value: string | null
|
|
191
|
+
maxAge?: number
|
|
192
|
+
path?: string
|
|
193
|
+
domain?: string
|
|
194
|
+
httpOnly?: boolean
|
|
195
|
+
secure?: boolean
|
|
196
|
+
sameSite?: "lax" | "strict" | "none"
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Token-exchange function for methods that participate in `/token`
|
|
201
|
+
* (currently just `m2m`). Returns the same `P` properties shape as a
|
|
202
|
+
* `MethodResult.success`.
|
|
203
|
+
*/
|
|
204
|
+
export type ClientFn<P> = (input: {
|
|
205
|
+
clientID: string
|
|
206
|
+
clientSecret: string
|
|
207
|
+
params: Record<string, string>
|
|
208
|
+
}) => Promise<Result<P, AuthError>>
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Factory that turns a tenant's per-method config into an `AuthMethod`.
|
|
212
|
+
*
|
|
213
|
+
* The factory owns config validation. The framework validates
|
|
214
|
+
* `MethodConfig.config` against `configSchema` before calling `build`;
|
|
215
|
+
* methods never observe `Record<string, unknown>` at runtime.
|
|
216
|
+
*
|
|
217
|
+
* `build` may be async (e.g. to fetch an OIDC discovery doc / JWKS). The
|
|
218
|
+
* result is cached per `(tenantId, MethodConfig.id)` — TTL matches the
|
|
219
|
+
* `ConfigStore` cache TTL; invalidation fires when tenant config changes.
|
|
220
|
+
*
|
|
221
|
+
* The framework verifies the returned `AuthMethod.id` and `AuthMethod.kind`
|
|
222
|
+
* match the `input.id` / `input.kind` passed into `build`. Mismatch fails
|
|
223
|
+
* the load with audit `factory_id_mismatch`.
|
|
224
|
+
*/
|
|
225
|
+
// `AnyAuthMethodFactory` is the variance-permissive form used by
|
|
226
|
+
// `IdPOptions.methods` and `MethodCache.factories`. Each entry in such a
|
|
227
|
+
// map may be a `AuthMethodFactory<P, S, Cfg>` with concrete generics —
|
|
228
|
+
// the `any` defaults keep the map type assignable without losing strict
|
|
229
|
+
// typing inside individual factories.
|
|
230
|
+
export type AnyAuthMethodFactory = AuthMethodFactory<
|
|
231
|
+
any, // P — properties emitted to success callback
|
|
232
|
+
any, // S — method-private state
|
|
233
|
+
any // Cfg — tenant-supplied config (validated by configSchema)
|
|
234
|
+
>
|
|
235
|
+
|
|
236
|
+
export type AuthMethodFactory<P = unknown, S = unknown, Cfg = unknown> = {
|
|
237
|
+
/** Matches `MethodConfig.kind`. Multiple `MethodConfig` rows may share the same `kind`. */
|
|
238
|
+
kind: string
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Standard Schema for the tenant-supplied config blob. The framework
|
|
242
|
+
* runs this after `ConfigStore` returns a tenant's `MethodConfig.config`
|
|
243
|
+
* and rejects loads that don't validate (audit + log). The validated
|
|
244
|
+
* value is threaded into `build`.
|
|
245
|
+
*
|
|
246
|
+
* Any validation library implementing [Standard Schema v1] satisfies
|
|
247
|
+
* this contract — Zod 3.24+, Valibot 1.0+, Arktype 2.0+, Effect Schema,
|
|
248
|
+
* etc. This decouples the library from any one validator's version
|
|
249
|
+
* choices.
|
|
250
|
+
*
|
|
251
|
+
* [Standard Schema v1]: https://github.com/standard-schema/standard-schema
|
|
252
|
+
*/
|
|
253
|
+
configSchema: v1.StandardSchema<unknown, Cfg>
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Build a concrete `AuthMethod` from validated config plus the binding
|
|
257
|
+
* context. The factory **must** set `AuthMethod.id` to `input.id` and
|
|
258
|
+
* `AuthMethod.kind` to `input.kind` — the framework verifies and audits
|
|
259
|
+
* on mismatch (`factory_id_mismatch`).
|
|
260
|
+
*/
|
|
261
|
+
build: (input: {
|
|
262
|
+
/** `MethodConfig.id` — tenant-local instance id, becomes `AuthMethod.id`. */
|
|
263
|
+
id: string
|
|
264
|
+
/** `MethodConfig.kind` — factory id, becomes `AuthMethod.kind`. */
|
|
265
|
+
kind: string
|
|
266
|
+
tenantId: TenantId
|
|
267
|
+
/** Validated against `configSchema`. */
|
|
268
|
+
config: Cfg
|
|
269
|
+
}) => Promise<AuthMethod<P, S>>
|
|
270
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public-surface types for the default provider picker and any
|
|
3
|
+
* host-supplied override (`IdPOptions.renderPicker`). Kept under `types/`
|
|
4
|
+
* — separate from `ui/picker.ts` which holds the default renderer — so
|
|
5
|
+
* the public-API layer doesn't depend on the UI implementation file.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Minimal shape of a method as seen by the picker. */
|
|
9
|
+
export type PickerMethod = {
|
|
10
|
+
/** Tenant-local id (e.g. "google-workspace"). Goes into method_id. */
|
|
11
|
+
id: string
|
|
12
|
+
/** Factory kind (e.g. "google"). Identifies the provider family. */
|
|
13
|
+
kind: string
|
|
14
|
+
/** "redirect" for upstream OAuth/OIDC, "credential" for password/code/passkey. */
|
|
15
|
+
type: string
|
|
16
|
+
/** Optional human-readable label provided by tenant config. */
|
|
17
|
+
displayName?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Query params propagated into each picker option's link. */
|
|
21
|
+
export type PickerContext = {
|
|
22
|
+
clientId: string
|
|
23
|
+
redirectUri: string
|
|
24
|
+
state?: string | null
|
|
25
|
+
scope?: string | null
|
|
26
|
+
nonce?: string | null
|
|
27
|
+
codeChallenge?: string | null
|
|
28
|
+
codeChallengeMethod?: string | null
|
|
29
|
+
audience?: string | null
|
|
30
|
+
prompt?: string | null
|
|
31
|
+
uiLocales?: string | null
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result<T, E> — explicit success / failure encoding used throughout the domain.
|
|
3
|
+
*
|
|
4
|
+
* Domain functions return `Result` instead of throwing. The HTTP layer is the
|
|
5
|
+
* one place that converts `AuthError` into an HTTP response. Keeping the domain
|
|
6
|
+
* throw-free makes composition (chaining validators, branching on error code)
|
|
7
|
+
* straightforward and avoids hidden control flow.
|
|
8
|
+
*
|
|
9
|
+
* AD5 in `docs/plans/claude/idp-rebuild-plan.md`.
|
|
10
|
+
*/
|
|
11
|
+
import type { AuthError } from "./error"
|
|
12
|
+
|
|
13
|
+
export type Result<T, E = AuthError> =
|
|
14
|
+
| { ok: true; value: T }
|
|
15
|
+
| { ok: false; error: E }
|
|
16
|
+
|
|
17
|
+
export const ok = <T>(value: T): Result<T, never> => ({ ok: true, value })
|
|
18
|
+
export const err = <E>(error: E): Result<never, E> => ({ ok: false, error })
|
|
19
|
+
|
|
20
|
+
export const isOk = <T, E>(r: Result<T, E>): r is { ok: true; value: T } =>
|
|
21
|
+
r.ok === true
|
|
22
|
+
export const isErr = <T, E>(r: Result<T, E>): r is { ok: false; error: E } =>
|
|
23
|
+
r.ok === false
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subject — the typed principal the IdP issues at the end of an auth flow.
|
|
3
|
+
*
|
|
4
|
+
* Per AD4 / plan §"Subject", Zod is the canonical schema library. The
|
|
5
|
+
* subject schema type is library-agnostic at the boundary (any schema that
|
|
6
|
+
* implements the [Standard Schema v1] spec — including Zod 3.24+, Valibot,
|
|
7
|
+
* and Arktype) so existing consumers can migrate from Valibot/Arktype
|
|
8
|
+
* without rewriting subject definitions.
|
|
9
|
+
*
|
|
10
|
+
* [Standard Schema v1]: https://github.com/standard-schema/standard-schema
|
|
11
|
+
*/
|
|
12
|
+
import type { v1 } from "@standard-schema/spec"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Map of subject-type id → schema for that subject's `properties`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { z } from "zod"
|
|
20
|
+
*
|
|
21
|
+
* const subjects: SubjectSchema = {
|
|
22
|
+
* user: z.object({ userId: z.string(), email: z.string().email() }),
|
|
23
|
+
* admin: z.object({ adminId: z.string(), roles: z.array(z.string()) }),
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export type SubjectSchema = Record<string, v1.StandardSchema>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Helper that infers the discriminated-union `{ type, properties }` shape
|
|
31
|
+
* from a `SubjectSchema`. Used to type the IdP's `success` callback return
|
|
32
|
+
* and the access-token `claim` payload.
|
|
33
|
+
*/
|
|
34
|
+
export type SubjectPayload<T extends SubjectSchema> = {
|
|
35
|
+
[type in keyof T & string]: {
|
|
36
|
+
type: type
|
|
37
|
+
properties: v1.InferOutput<T[type]>
|
|
38
|
+
}
|
|
39
|
+
}[keyof T & string]
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generic typed-subject claim — what the user's `IdPOptions.success`
|
|
43
|
+
* callback returns and what is inlined as `claim` on the access token.
|
|
44
|
+
*
|
|
45
|
+
* Domain / port signatures keep the generic open (`SubjectClaim`) so the
|
|
46
|
+
* framework doesn't need to know each consumer's subject schema. Concrete
|
|
47
|
+
* call sites narrow `T extends SubjectSchema` for type safety.
|
|
48
|
+
*/
|
|
49
|
+
export type SubjectClaim<T extends SubjectSchema = SubjectSchema> =
|
|
50
|
+
SubjectPayload<T>
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant model + tenant-resolution / callback-recovery types.
|
|
3
|
+
*
|
|
4
|
+
* Per AD1, tenancy is **not** a URL concept. A tenant is whatever the
|
|
5
|
+
* user-supplied `resolveTenant(req)` says it is for an incoming request, plus
|
|
6
|
+
* a deterministic callback-recovery chain (MAC-bound state, partitioned host,
|
|
7
|
+
* or `flowId`-in-URI) for the post-redirect leg where the original tenant
|
|
8
|
+
* signal may no longer be available.
|
|
9
|
+
*
|
|
10
|
+
* The minimal state envelope MACed and round-tripped through upstream
|
|
11
|
+
* providers carries only `{ tenantId, flowId, nonce, kid }`. Everything else
|
|
12
|
+
* lives in the server-side `FlowRecord` (see `./flow.ts`).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Branded tenant id — **opaque to the framework**.
|
|
17
|
+
*
|
|
18
|
+
* The framework treats `TenantId` as a comparable string and nothing more.
|
|
19
|
+
* It never parses it, never assumes a hierarchy or naming convention, never
|
|
20
|
+
* imposes uniqueness rules, never knows the lifecycle of a tenant. The
|
|
21
|
+
* embedding application decides what a tenant *is* (an organization, a
|
|
22
|
+
* workspace, an App-Tenant tuple, a customer, …) and supplies a
|
|
23
|
+
* `resolveTenant(req)` that maps incoming requests to the right key.
|
|
24
|
+
*
|
|
25
|
+
* Common embedding pattern when the host application has two levels of
|
|
26
|
+
* scoping (e.g. `App` ⇒ `App-Tenant`): encode the tuple into the key.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Inside the host application's resolveTenant:
|
|
30
|
+
* return ok(`${app.id}:${appTenant?.id ?? "__default__"}` as TenantId)
|
|
31
|
+
*
|
|
32
|
+
* // Inside the host application's ConfigStore.getTenantConfig:
|
|
33
|
+
* const [appId, subId] = (id as string).split(":")
|
|
34
|
+
* // merge App defaults + App-Tenant overrides from your own DB ...
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* The brand exists to keep arbitrary `string` values from being passed
|
|
38
|
+
* where a `TenantId` is expected; the *meaning* of the string is the host
|
|
39
|
+
* application's concern.
|
|
40
|
+
*/
|
|
41
|
+
export type TenantId = string & { readonly __brand: "TenantId" }
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Cast helper for code that mints `TenantId` from a validated string. The
|
|
45
|
+
* framework imposes no validation on the value — callers ensure their key
|
|
46
|
+
* is non-empty and stable per partition.
|
|
47
|
+
*/
|
|
48
|
+
export const asTenantId = (value: string): TenantId => value as TenantId
|
|
49
|
+
|
|
50
|
+
/** OAuth 2.1 grant types in scope for this IdP. Implicit is intentionally absent. */
|
|
51
|
+
export type GrantType =
|
|
52
|
+
| "authorization_code"
|
|
53
|
+
| "refresh_token"
|
|
54
|
+
| "client_credentials"
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* `MethodType` is the canonical discriminator for an `AuthMethod`. It mirrors
|
|
58
|
+
* the existing provider taxonomy. The UI uses it to decide which selection /
|
|
59
|
+
* form to render; the framework uses it as a routing / dispatch hint.
|
|
60
|
+
*/
|
|
61
|
+
export type MethodType =
|
|
62
|
+
| "oauth2"
|
|
63
|
+
| "oidc"
|
|
64
|
+
| "password"
|
|
65
|
+
| "code"
|
|
66
|
+
| "m2m"
|
|
67
|
+
| "passkey"
|
|
68
|
+
| "custom"
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Per-tenant configuration for a single auth method **instance**.
|
|
72
|
+
*
|
|
73
|
+
* `id` is the **tenant-local instance id** — the value that ends up in URLs
|
|
74
|
+
* (`/<id>/*`) and that the framework dispatches by.
|
|
75
|
+
*
|
|
76
|
+
* `kind` is the **factory id** — the value that selects which
|
|
77
|
+
* `AuthMethodFactory` builds this instance. A tenant may register multiple
|
|
78
|
+
* instances of the same factory (e.g. one Google Workspace SSO and one
|
|
79
|
+
* consumer Google Sign-In) by giving each instance a unique `id` while
|
|
80
|
+
* sharing a `kind`.
|
|
81
|
+
*
|
|
82
|
+
* `type` is the `MethodType` discriminator the UI uses. The framework
|
|
83
|
+
* verifies it agrees with the factory's declared type at load time.
|
|
84
|
+
*
|
|
85
|
+
* `config` is the tenant-supplied configuration blob. The framework validates
|
|
86
|
+
* it against the factory's Zod `configSchema` before any handler runs.
|
|
87
|
+
*/
|
|
88
|
+
export type MethodConfig = {
|
|
89
|
+
id: string
|
|
90
|
+
kind: string
|
|
91
|
+
type: MethodType
|
|
92
|
+
enabled: boolean
|
|
93
|
+
config: Record<string, unknown>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Optional theme metadata. Schema expanded in later phases. */
|
|
97
|
+
export type ThemeConfig = {
|
|
98
|
+
primary?: string
|
|
99
|
+
logo?: string
|
|
100
|
+
favicon?: string
|
|
101
|
+
background?: string
|
|
102
|
+
font?: string
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Registered OAuth client of this IdP (an app, SPA, mobile, M2M).
|
|
107
|
+
*
|
|
108
|
+
* Phase 8: split into a discriminated union so misconfiguration is a type
|
|
109
|
+
* error, not a runtime check. The runtime in `domain/authorize.ts` still
|
|
110
|
+
* enforces PKCE for public clients defensively, but hosts will see the
|
|
111
|
+
* problem at compile time.
|
|
112
|
+
*
|
|
113
|
+
* - **Public clients** (SPAs, mobile apps, native apps): no client secret;
|
|
114
|
+
* `pkceRequired` is the literal `true`. PKCE is non-negotiable per
|
|
115
|
+
* OAuth 2.1 BCP §2.1.1.
|
|
116
|
+
* - **Confidential clients** (server-side apps, M2M): `secretHash` is
|
|
117
|
+
* required (this used to be optional, in practice always set). PKCE
|
|
118
|
+
* recommended but may be disabled by the host.
|
|
119
|
+
*/
|
|
120
|
+
export type ClientConfig = PublicClientConfig | ConfidentialClientConfig
|
|
121
|
+
|
|
122
|
+
export type PublicClientConfig = {
|
|
123
|
+
id: string
|
|
124
|
+
name: string
|
|
125
|
+
type: "public"
|
|
126
|
+
redirectUris: string[]
|
|
127
|
+
grantTypes: GrantType[]
|
|
128
|
+
scopes: string[]
|
|
129
|
+
/** Must be `true` for public clients per OAuth 2.1 §2.1.1. */
|
|
130
|
+
pkceRequired: true
|
|
131
|
+
/**
|
|
132
|
+
* Registered URIs to which `/end_session` may redirect after RP-initiated
|
|
133
|
+
* logout (OIDC RP-Initiated Logout 1.0 §2). Exact-match. If absent, the
|
|
134
|
+
* `/end_session` endpoint refuses any `post_logout_redirect_uri`.
|
|
135
|
+
*/
|
|
136
|
+
postLogoutRedirectUris?: string[]
|
|
137
|
+
/**
|
|
138
|
+
* RFC 9126 §2: when `true`, the client MUST use Pushed Authorization
|
|
139
|
+
* Requests; a direct `GET /authorize` call without `request_uri` is
|
|
140
|
+
* rejected with `invalid_request`.
|
|
141
|
+
*/
|
|
142
|
+
requirePushedAuthorizationRequests?: boolean
|
|
143
|
+
/**
|
|
144
|
+
* OIDC Core §8.1 — when set, the subject identifier (`sub`) is derived
|
|
145
|
+
* as a pairwise pseudonym keyed by this string. Two clients sharing
|
|
146
|
+
* the same `sectorIdentifier` will see the same `sub`; different
|
|
147
|
+
* values yield different `sub`s for the same end user. Absent =
|
|
148
|
+
* public subject (sub is identical across all RPs).
|
|
149
|
+
*/
|
|
150
|
+
sectorIdentifier?: string
|
|
151
|
+
/** Phase 8. */
|
|
152
|
+
dpopRequired?: boolean
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type ConfidentialClientConfig = {
|
|
156
|
+
id: string
|
|
157
|
+
name: string
|
|
158
|
+
type: "confidential"
|
|
159
|
+
/** Hash of the client secret. Required for confidential clients. */
|
|
160
|
+
secretHash: string
|
|
161
|
+
redirectUris: string[]
|
|
162
|
+
grantTypes: GrantType[]
|
|
163
|
+
scopes: string[]
|
|
164
|
+
/**
|
|
165
|
+
* Default true. Disabling it is permitted for confidential clients but
|
|
166
|
+
* strongly discouraged; OAuth 2.1 §2.1.1 recommends PKCE for every client.
|
|
167
|
+
*/
|
|
168
|
+
pkceRequired: boolean
|
|
169
|
+
/**
|
|
170
|
+
* Registered URIs to which `/end_session` may redirect after RP-initiated
|
|
171
|
+
* logout (OIDC RP-Initiated Logout 1.0 §2). Exact-match.
|
|
172
|
+
*/
|
|
173
|
+
postLogoutRedirectUris?: string[]
|
|
174
|
+
/**
|
|
175
|
+
* RFC 9126 §2: when `true`, the client MUST use Pushed Authorization
|
|
176
|
+
* Requests; a direct `GET /authorize` call without `request_uri` is
|
|
177
|
+
* rejected with `invalid_request`.
|
|
178
|
+
*/
|
|
179
|
+
requirePushedAuthorizationRequests?: boolean
|
|
180
|
+
/**
|
|
181
|
+
* OIDC Core §8.1 — see `PublicClientConfig.sectorIdentifier` for
|
|
182
|
+
* semantics. Same field; duplicated on each branch because the
|
|
183
|
+
* `ClientConfig` discriminated union doesn't share optional fields.
|
|
184
|
+
*/
|
|
185
|
+
sectorIdentifier?: string
|
|
186
|
+
/** Phase 8. */
|
|
187
|
+
dpopRequired?: boolean
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export type TenantConfig = {
|
|
191
|
+
id: TenantId
|
|
192
|
+
displayName: string
|
|
193
|
+
clients: ClientConfig[]
|
|
194
|
+
methods: MethodConfig[]
|
|
195
|
+
theme?: ThemeConfig
|
|
196
|
+
/** Set when the tenant needs cross-subdomain SSO. */
|
|
197
|
+
cookieDomain?: string
|
|
198
|
+
/** Override default refresh-token TTL (seconds). */
|
|
199
|
+
refreshTtl?: number
|
|
200
|
+
/** Override default access-token TTL (seconds). */
|
|
201
|
+
accessTtl?: number
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Per-request tenant context handed to methods and the user-supplied
|
|
206
|
+
* `success` callback. `request.raw` is the Web Fetch `Request` the framework
|
|
207
|
+
* received; `request.custom` is whatever the host returned from the
|
|
208
|
+
* `IdPOptions.buildCustomContext` hook (request id, decoded JWT claims, mTLS
|
|
209
|
+
* cert info, geo hints — anything per-request that methods or `success`
|
|
210
|
+
* should see). Without the hook the blob is `{}`. The same blob is also
|
|
211
|
+
* persisted on the `FlowRecord` at `/authorize` time so it survives the
|
|
212
|
+
* upstream redirect and re-presents on the callback side.
|
|
213
|
+
*/
|
|
214
|
+
export type TenantContext = {
|
|
215
|
+
id: TenantId
|
|
216
|
+
config: TenantConfig
|
|
217
|
+
request: {
|
|
218
|
+
raw: Request
|
|
219
|
+
custom: Record<string, unknown>
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Outcome of the framework's tenant-recovery chain, evaluated **before**
|
|
225
|
+
* `resolveTenant` runs on the incoming request. Each non-`fresh-request`
|
|
226
|
+
* variant carries a `flowId`; the framework consumes the matching
|
|
227
|
+
* `FlowRecord` and dispatches without consulting `resolveTenant`.
|
|
228
|
+
*
|
|
229
|
+
* Order of evaluation (see plan §"Tenant Recovery Across Redirects"):
|
|
230
|
+
* 1. If `callbackHostFor` configured AND host matches a known tenant:
|
|
231
|
+
* a. `state` MAC-verifies → host-plus-mac
|
|
232
|
+
* b. `flowId` in URI → host-plus-uri
|
|
233
|
+
* c. otherwise → invalid_request, audit unrecoverable_flow
|
|
234
|
+
* 2. Else if `state` MAC-verifies → mac-state
|
|
235
|
+
* 3. Else if `flowId` in registered URI path/query → flow-id-in-uri
|
|
236
|
+
* 4. Else → fresh-request → call user's `resolveTenant(req)`
|
|
237
|
+
*/
|
|
238
|
+
export type TenantRecovery =
|
|
239
|
+
| { kind: "mac-state"; tenantId: TenantId; flowId: string }
|
|
240
|
+
| { kind: "host-plus-uri"; tenantId: TenantId; flowId: string }
|
|
241
|
+
| { kind: "host-plus-mac"; tenantId: TenantId; flowId: string }
|
|
242
|
+
| { kind: "flow-id-in-uri"; tenantId: TenantId; flowId: string }
|
|
243
|
+
| { kind: "fresh-request" }
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Minimal envelope MACed into the `state` query parameter. Intentionally
|
|
247
|
+
* tiny — under 256 base64url bytes — so it stays clear of provider URL
|
|
248
|
+
* limits. **No sensitive data must ever be added here.** Everything else
|
|
249
|
+
* lives in the server-side `FlowRecord`.
|
|
250
|
+
*/
|
|
251
|
+
export type StateEnvelope = {
|
|
252
|
+
tenantId: TenantId
|
|
253
|
+
flowId: string
|
|
254
|
+
/** Per-flow nonce. Distinct from the relying party's `state` param. */
|
|
255
|
+
nonce: string
|
|
256
|
+
/** Key id of the HMAC key used to mint this envelope (`StateKeyRing` lookup). */
|
|
257
|
+
kid: string
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* HMAC-SHA-256 key entry used to mint / verify the `state` envelope MAC.
|
|
262
|
+
* The 32-byte key is global (shared across IdP instances) — recovery has to
|
|
263
|
+
* work before tenant config is loaded, so per-tenant keys would create a
|
|
264
|
+
* bootstrap problem.
|
|
265
|
+
*/
|
|
266
|
+
export type StateKey = {
|
|
267
|
+
kid: string
|
|
268
|
+
/** 32 raw bytes. */
|
|
269
|
+
key: Uint8Array
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* State-MAC key ring with overlap-based rotation. `active` mints new state;
|
|
274
|
+
* any key in `verify` accepts existing state during its overlap window.
|
|
275
|
+
*
|
|
276
|
+
* Rotation cadence: monthly. The overlap window must be at least as long as
|
|
277
|
+
* the flow-record TTL (default 10 minutes); a 1-hour overlap is the
|
|
278
|
+
* recommended default. New keys are added to `verify` first, promoted to
|
|
279
|
+
* `active` on the next rotation, then dropped from `verify` after overlap.
|
|
280
|
+
*/
|
|
281
|
+
export type StateKeyRing = {
|
|
282
|
+
active: StateKey
|
|
283
|
+
/** Includes `active` plus any previous keys still inside their overlap window. */
|
|
284
|
+
verify: ReadonlyArray<StateKey>
|
|
285
|
+
}
|