@_mustachio/openauth 0.9.1 → 0.10.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 +82 -0
- package/dist/esm/adapters/memory/token-store.js +91 -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 +26 -10
- package/dist/esm/domain/audit.js +13 -0
- package/dist/esm/domain/authorize.js +212 -0
- package/dist/esm/domain/callback.js +173 -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 +41 -0
- package/dist/esm/domain/introspect.js +51 -0
- package/dist/esm/domain/jwt.js +43 -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 +108 -0
- package/dist/esm/domain/pkce.js +16 -0
- package/dist/esm/domain/refresh.js +91 -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 +101 -0
- package/dist/esm/domain/token.js +205 -0
- package/dist/esm/domain/userinfo.js +27 -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 +163 -0
- package/dist/esm/http/handlers/callback.js +53 -0
- package/dist/esm/http/handlers/metadata.js +34 -0
- package/dist/esm/http/handlers/method-route.js +87 -0
- package/dist/esm/http/handlers/revocation.js +98 -0
- package/dist/esm/http/handlers/token.js +167 -0
- package/dist/esm/http/handlers/userinfo.js +54 -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 +35 -0
- package/dist/esm/http/schemas/authorize.js +24 -0
- package/dist/esm/http/schemas/revocation.js +18 -0
- package/dist/esm/http/schemas/token.js +57 -0
- package/dist/esm/index.js +121 -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 +65 -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 +19 -0
- package/dist/types/adapters/memory/session-store.d.ts.map +1 -0
- package/dist/types/adapters/memory/token-store.d.ts +28 -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 +1 -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 +52 -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 +44 -0
- package/dist/types/domain/discovery.d.ts.map +1 -0
- package/dist/types/domain/introspect.d.ts +71 -0
- package/dist/types/domain/introspect.d.ts.map +1 -0
- package/dist/types/domain/jwt.d.ts +48 -0
- package/dist/types/domain/jwt.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/pkce.d.ts +15 -0
- package/dist/types/domain/pkce.d.ts.map +1 -0
- package/dist/types/domain/refresh.d.ts +43 -0
- package/dist/types/domain/refresh.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 +67 -0
- package/dist/types/domain/token-exchange.d.ts.map +1 -0
- package/dist/types/domain/token.d.ts +100 -0
- package/dist/types/domain/token.d.ts.map +1 -0
- package/dist/types/domain/userinfo.d.ts +22 -0
- package/dist/types/domain/userinfo.d.ts.map +1 -0
- package/dist/types/http/context.d.ts +63 -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/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/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 +52 -0
- package/dist/types/http/schemas/authorize.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 +139 -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 +82 -0
- package/dist/types/ports/session-store.d.ts.map +1 -0
- package/dist/types/ports/token-store.d.ts +93 -0
- package/dist/types/ports/token-store.d.ts.map +1 -0
- package/dist/types/types/authorization.d.ts +52 -0
- package/dist/types/types/authorization.d.ts.map +1 -0
- package/dist/types/types/error.d.ts +92 -0
- package/dist/types/types/error.d.ts.map +1 -0
- package/dist/types/types/flow.d.ts +87 -0
- package/dist/types/types/flow.d.ts.map +1 -0
- package/dist/types/types/idp.d.ts +234 -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 +239 -0
- package/dist/types/types/tenant.d.ts.map +1 -0
- package/dist/types/types/token.d.ts +103 -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 +128 -0
- package/src/adapters/memory/token-store.ts +165 -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 +50 -16
- package/src/domain/audit.ts +28 -0
- package/src/domain/authorize.ts +405 -0
- package/src/domain/callback.ts +263 -0
- package/src/domain/client-auth.ts +116 -0
- package/src/domain/client-credentials.ts +178 -0
- package/src/domain/crypto.ts +168 -0
- package/src/domain/discovery.ts +83 -0
- package/src/domain/introspect.ts +145 -0
- package/src/domain/jwt.ts +106 -0
- package/src/domain/method-cache.ts +220 -0
- package/src/domain/method-dispatch.ts +95 -0
- package/src/domain/method-route.ts +208 -0
- package/src/domain/pkce.ts +37 -0
- package/src/domain/refresh.ts +169 -0
- package/src/domain/revoke.ts +161 -0
- package/src/domain/state-envelope.ts +142 -0
- package/src/domain/token-exchange.ts +232 -0
- package/src/domain/token.ts +357 -0
- package/src/domain/userinfo.ts +56 -0
- package/src/http/context.ts +86 -0
- package/src/http/cookies.ts +167 -0
- package/src/http/errors.ts +98 -0
- package/src/http/handlers/authorize.ts +221 -0
- package/src/http/handlers/callback.ts +77 -0
- package/src/http/handlers/metadata.ts +44 -0
- package/src/http/handlers/method-route.ts +115 -0
- package/src/http/handlers/revocation.ts +151 -0
- package/src/http/handlers/token.ts +244 -0
- package/src/http/handlers/userinfo.ts +66 -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 +66 -0
- package/src/http/schemas/authorize.ts +58 -0
- package/src/http/schemas/revocation.ts +23 -0
- package/src/http/schemas/token.ts +85 -0
- package/src/index.ts +266 -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 +88 -0
- package/src/ports/audit-log.ts +148 -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 +98 -0
- package/src/ports/token-store.ts +103 -0
- package/src/types/authorization.ts +53 -0
- package/src/types/error.ts +123 -0
- package/src/types/flow.ts +89 -0
- package/src/types/idp.ts +269 -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 +248 -0
- package/src/types/token.ts +101 -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,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Top-level Hono router for the IdP HTTP surface.
|
|
3
|
+
*
|
|
4
|
+
* Routes (Phase 3):
|
|
5
|
+
* GET /authorize — start OAuth flow
|
|
6
|
+
* POST /token — exchange code / refresh
|
|
7
|
+
* GET /userinfo, POST /userinfo — OIDC claims
|
|
8
|
+
* GET /cb/:methodId{.*} — upstream callback
|
|
9
|
+
* GET /.well-known/openid-configuration — discovery
|
|
10
|
+
* GET /.well-known/oauth-authorization-server — discovery (alias)
|
|
11
|
+
* GET /.well-known/jwks.json — JWKS
|
|
12
|
+
* POST /revoke — RFC 7009
|
|
13
|
+
* POST /introspect — RFC 7662
|
|
14
|
+
*
|
|
15
|
+
* Hono is imported **only** from this directory. `domain/`, `methods/`,
|
|
16
|
+
* `types/`, `ports/`, and `adapters/` remain framework-agnostic.
|
|
17
|
+
*/
|
|
18
|
+
import { Hono } from "hono"
|
|
19
|
+
|
|
20
|
+
import { makeAuthorizeHandler } from "./handlers/authorize"
|
|
21
|
+
import { makeCallbackHandler } from "./handlers/callback"
|
|
22
|
+
import { makeDiscoveryHandler, makeJwksHandler } from "./handlers/metadata"
|
|
23
|
+
import { makeMethodRouteHandler } from "./handlers/method-route"
|
|
24
|
+
import { makeIntrospectHandler, makeRevokeHandler } from "./handlers/revocation"
|
|
25
|
+
import { makeTokenHandler } from "./handlers/token"
|
|
26
|
+
import { makeUserinfoHandler } from "./handlers/userinfo"
|
|
27
|
+
import { errorMiddleware } from "./middleware/error"
|
|
28
|
+
import { bootstrapMiddleware, tenantMiddleware } from "./middleware/tenant"
|
|
29
|
+
import type { HttpDeps, HttpEnv } from "./context"
|
|
30
|
+
|
|
31
|
+
export function buildRouter(deps: HttpDeps): Hono<HttpEnv> {
|
|
32
|
+
const app = new Hono<HttpEnv>()
|
|
33
|
+
|
|
34
|
+
app.use("*", errorMiddleware(deps))
|
|
35
|
+
app.use("*", bootstrapMiddleware(deps))
|
|
36
|
+
|
|
37
|
+
// Public metadata — no tenant middleware required.
|
|
38
|
+
app.get("/.well-known/openid-configuration", makeDiscoveryHandler(deps))
|
|
39
|
+
app.get("/.well-known/oauth-authorization-server", makeDiscoveryHandler(deps))
|
|
40
|
+
app.get("/.well-known/jwks.json", makeJwksHandler(deps))
|
|
41
|
+
|
|
42
|
+
// Tenant-scoped endpoints.
|
|
43
|
+
app.use("/authorize", tenantMiddleware(deps))
|
|
44
|
+
app.get("/authorize", makeAuthorizeHandler(deps))
|
|
45
|
+
|
|
46
|
+
app.use("/cb/*", tenantMiddleware(deps))
|
|
47
|
+
app.get("/cb/*", makeCallbackHandler(deps))
|
|
48
|
+
// Apple `response_mode=form_post` and similar POST-binding callbacks.
|
|
49
|
+
app.post("/cb/*", makeCallbackHandler(deps))
|
|
50
|
+
|
|
51
|
+
// Credential-flow method routes — POST and GET allowed.
|
|
52
|
+
app.use("/m/*", tenantMiddleware(deps))
|
|
53
|
+
app.all("/m/*", makeMethodRouteHandler(deps))
|
|
54
|
+
|
|
55
|
+
// Token endpoint — tenant resolved from auth-code payload, not middleware.
|
|
56
|
+
app.post("/token", makeTokenHandler(deps))
|
|
57
|
+
|
|
58
|
+
// Userinfo — bearer token carries tenant claim (`tid`).
|
|
59
|
+
app.get("/userinfo", makeUserinfoHandler(deps))
|
|
60
|
+
app.post("/userinfo", makeUserinfoHandler(deps))
|
|
61
|
+
|
|
62
|
+
app.post("/revoke", makeRevokeHandler(deps))
|
|
63
|
+
app.post("/introspect", makeIntrospectHandler(deps))
|
|
64
|
+
|
|
65
|
+
return app
|
|
66
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for the `/authorize` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* Parse the raw query into an `AuthorizationRequest` shape. We surface OAuth
|
|
5
|
+
* `invalid_request` (or the more specific `unsupported_response_type` /
|
|
6
|
+
* `invalid_scope`) for any structural failure here; downstream domain code
|
|
7
|
+
* then handles semantic validation (client lookup, redirect-uri match, PKCE
|
|
8
|
+
* requirement, etc.).
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod"
|
|
11
|
+
|
|
12
|
+
/** RFC 6749 scope-token regex (visible ASCII minus delimiters). */
|
|
13
|
+
const SCOPE_TOKEN = /^[\x21\x23-\x5B\x5D-\x7E]+$/
|
|
14
|
+
|
|
15
|
+
const csv = z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.transform((s) =>
|
|
19
|
+
s
|
|
20
|
+
.split(/\s+/)
|
|
21
|
+
.map((part) => part.trim())
|
|
22
|
+
.filter((part) => part.length > 0),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const scopeParam = z
|
|
26
|
+
.string()
|
|
27
|
+
.transform((s) =>
|
|
28
|
+
s
|
|
29
|
+
.split(/\s+/)
|
|
30
|
+
.map((part) => part.trim())
|
|
31
|
+
.filter((part) => part.length > 0),
|
|
32
|
+
)
|
|
33
|
+
.pipe(z.array(z.string().regex(SCOPE_TOKEN, "invalid scope token")))
|
|
34
|
+
|
|
35
|
+
export const authorizeQuerySchema = z
|
|
36
|
+
.object({
|
|
37
|
+
response_type: z.string({
|
|
38
|
+
required_error: "missing response_type",
|
|
39
|
+
}),
|
|
40
|
+
client_id: z
|
|
41
|
+
.string({ required_error: "missing client_id" })
|
|
42
|
+
.min(1, "empty client_id"),
|
|
43
|
+
redirect_uri: z
|
|
44
|
+
.string({ required_error: "missing redirect_uri" })
|
|
45
|
+
.url("redirect_uri must be a valid URL"),
|
|
46
|
+
scope: scopeParam.optional(),
|
|
47
|
+
state: z.string().optional(),
|
|
48
|
+
audience: z.string().optional(),
|
|
49
|
+
method_id: z.string().optional(),
|
|
50
|
+
code_challenge: z.string().optional(),
|
|
51
|
+
code_challenge_method: z.literal("S256").optional(),
|
|
52
|
+
prompt: csv.optional(),
|
|
53
|
+
ui_locales: csv.optional(),
|
|
54
|
+
nonce: z.string().optional(),
|
|
55
|
+
})
|
|
56
|
+
.passthrough()
|
|
57
|
+
|
|
58
|
+
export type AuthorizeQuery = z.infer<typeof authorizeQuerySchema>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for RFC 7009 `/revoke` and RFC 7662 `/introspect`. Both are
|
|
3
|
+
* advertised in discovery from Phase 3 onward; their HTTP shims live here so
|
|
4
|
+
* the domain functions are reachable without waiting for Phase 8.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod"
|
|
7
|
+
|
|
8
|
+
export const revokeBodySchema = z.object({
|
|
9
|
+
token: z.string().min(1, "missing token"),
|
|
10
|
+
token_type_hint: z.enum(["access_token", "refresh_token"]).optional(),
|
|
11
|
+
client_id: z.string().optional(),
|
|
12
|
+
client_secret: z.string().optional(),
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const introspectBodySchema = z.object({
|
|
16
|
+
token: z.string().min(1, "missing token"),
|
|
17
|
+
token_type_hint: z.enum(["access_token", "refresh_token"]).optional(),
|
|
18
|
+
client_id: z.string().optional(),
|
|
19
|
+
client_secret: z.string().optional(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export type RevokeBody = z.infer<typeof revokeBodySchema>
|
|
23
|
+
export type IntrospectBody = z.infer<typeof introspectBodySchema>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for the `/token` endpoint.
|
|
3
|
+
*
|
|
4
|
+
* The endpoint accepts `application/x-www-form-urlencoded` per RFC 6749.
|
|
5
|
+
* `grant_type` discriminates between the supported grants:
|
|
6
|
+
* - `authorization_code`
|
|
7
|
+
* - `refresh_token`
|
|
8
|
+
* - `client_credentials`
|
|
9
|
+
* - `urn:ietf:params:oauth:grant-type:token-exchange` (RFC 8693)
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod"
|
|
12
|
+
|
|
13
|
+
/** RFC 8693 §3 token-type identifiers used at this endpoint. */
|
|
14
|
+
export const TOKEN_EXCHANGE_GRANT_TYPE =
|
|
15
|
+
"urn:ietf:params:oauth:grant-type:token-exchange" as const
|
|
16
|
+
export const ACCESS_TOKEN_TYPE =
|
|
17
|
+
"urn:ietf:params:oauth:token-type:access_token" as const
|
|
18
|
+
export const REFRESH_TOKEN_TYPE =
|
|
19
|
+
"urn:ietf:params:oauth:token-type:refresh_token" as const
|
|
20
|
+
|
|
21
|
+
export const authorizationCodeGrantSchema = z.object({
|
|
22
|
+
grant_type: z.literal("authorization_code"),
|
|
23
|
+
code: z.string().min(1, "missing code"),
|
|
24
|
+
redirect_uri: z.string().url("invalid redirect_uri"),
|
|
25
|
+
client_id: z.string().min(1, "missing client_id"),
|
|
26
|
+
client_secret: z.string().optional(),
|
|
27
|
+
code_verifier: z.string().optional(),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export const refreshTokenGrantSchema = z.object({
|
|
31
|
+
grant_type: z.literal("refresh_token"),
|
|
32
|
+
refresh_token: z.string().min(1, "missing refresh_token"),
|
|
33
|
+
scope: z.string().optional(),
|
|
34
|
+
client_id: z.string().optional(),
|
|
35
|
+
client_secret: z.string().optional(),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const clientCredentialsGrantSchema = z
|
|
39
|
+
.object({
|
|
40
|
+
grant_type: z.literal("client_credentials"),
|
|
41
|
+
client_id: z.string().min(1, "missing client_id"),
|
|
42
|
+
client_secret: z.string().min(1, "missing client_secret"),
|
|
43
|
+
scope: z.string().optional(),
|
|
44
|
+
audience: z.string().optional(),
|
|
45
|
+
resource: z.string().optional(),
|
|
46
|
+
})
|
|
47
|
+
.passthrough()
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* RFC 8693 §2.1 token-exchange request.
|
|
51
|
+
*
|
|
52
|
+
* `subject_token_type` MUST identify the type of `subject_token`. We only
|
|
53
|
+
* accept access tokens here — refresh-token-as-subject is out of scope.
|
|
54
|
+
*
|
|
55
|
+
* `audience` is opaque to the library; the host's `exchangeAudience`
|
|
56
|
+
* hook decides what counts as a legal target. In our two-level
|
|
57
|
+
* `App × App-Tenant` encoding pattern this is the new `TenantId`.
|
|
58
|
+
*
|
|
59
|
+
* `actor_token` (delegation) is intentionally rejected at the handler;
|
|
60
|
+
* only impersonation / audience-switching is supported in this phase.
|
|
61
|
+
*/
|
|
62
|
+
export const tokenExchangeGrantSchema = z
|
|
63
|
+
.object({
|
|
64
|
+
grant_type: z.literal(TOKEN_EXCHANGE_GRANT_TYPE),
|
|
65
|
+
subject_token: z.string().min(1, "missing subject_token"),
|
|
66
|
+
subject_token_type: z.literal(ACCESS_TOKEN_TYPE),
|
|
67
|
+
audience: z.string().min(1, "missing audience"),
|
|
68
|
+
requested_token_type: z.literal(ACCESS_TOKEN_TYPE).optional(),
|
|
69
|
+
scope: z.string().optional(),
|
|
70
|
+
client_id: z.string().optional(),
|
|
71
|
+
client_secret: z.string().optional(),
|
|
72
|
+
actor_token: z.string().optional(),
|
|
73
|
+
actor_token_type: z.string().optional(),
|
|
74
|
+
resource: z.string().optional(),
|
|
75
|
+
})
|
|
76
|
+
.passthrough()
|
|
77
|
+
|
|
78
|
+
export const tokenRequestSchema = z.discriminatedUnion("grant_type", [
|
|
79
|
+
authorizationCodeGrantSchema,
|
|
80
|
+
refreshTokenGrantSchema,
|
|
81
|
+
clientCredentialsGrantSchema,
|
|
82
|
+
tokenExchangeGrantSchema,
|
|
83
|
+
])
|
|
84
|
+
|
|
85
|
+
export type TokenRequest = z.infer<typeof tokenRequestSchema>
|
package/src/index.ts
CHANGED
|
@@ -1,26 +1,272 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `@_mustachio/openauth` — public entry point.
|
|
3
|
+
*
|
|
4
|
+
* Library-only IdP surface: domain logic + ports + adapters. Consumers
|
|
5
|
+
* embed this in a host application that owns UI, RBAC, admin, and tenant
|
|
6
|
+
* management. See `docs/integration-guide.md` for the embedding pattern.
|
|
7
|
+
*
|
|
8
|
+
* `createClient` continues to ship at the dedicated path
|
|
9
|
+
* `@_mustachio/openauth/client` (better tree-shaking than re-exporting
|
|
10
|
+
* it from the root).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// ─── New IdP public API ───
|
|
14
|
+
|
|
15
|
+
export type { Result } from "./types/result"
|
|
16
|
+
export { err, isErr, isOk, ok } from "./types/result"
|
|
17
|
+
|
|
18
|
+
export type { AuthError, AuthErrorCode } from "./types/error"
|
|
19
|
+
export { authError } from "./types/error"
|
|
20
|
+
|
|
21
|
+
export type {
|
|
22
|
+
ClientConfig,
|
|
23
|
+
ConfidentialClientConfig,
|
|
24
|
+
GrantType,
|
|
25
|
+
MethodConfig,
|
|
26
|
+
MethodType,
|
|
27
|
+
PublicClientConfig,
|
|
28
|
+
StateEnvelope,
|
|
29
|
+
StateKey,
|
|
30
|
+
StateKeyRing,
|
|
31
|
+
TenantConfig,
|
|
32
|
+
TenantContext,
|
|
33
|
+
TenantId,
|
|
34
|
+
TenantRecovery,
|
|
35
|
+
ThemeConfig,
|
|
36
|
+
} from "./types/tenant"
|
|
37
|
+
export { asTenantId } from "./types/tenant"
|
|
38
|
+
|
|
39
|
+
export type { FlowRecord } from "./types/flow"
|
|
40
|
+
|
|
41
|
+
export type {
|
|
42
|
+
AuthMethod,
|
|
43
|
+
AuthMethodFactory,
|
|
44
|
+
CachePolicy,
|
|
45
|
+
ClientFn,
|
|
46
|
+
MethodContext,
|
|
47
|
+
MethodDispatchData,
|
|
48
|
+
MethodHandler,
|
|
49
|
+
MethodResult,
|
|
50
|
+
SetCookie,
|
|
51
|
+
} from "./types/method"
|
|
52
|
+
|
|
53
|
+
export type {
|
|
54
|
+
AuthorizationRequest,
|
|
55
|
+
AuthorizationState,
|
|
56
|
+
} from "./types/authorization"
|
|
57
|
+
|
|
58
|
+
export type {
|
|
59
|
+
AccessTokenClaims,
|
|
60
|
+
CodePayload,
|
|
61
|
+
RefreshTokenPayload,
|
|
62
|
+
TokenResponse,
|
|
63
|
+
} from "./types/token"
|
|
64
|
+
|
|
65
|
+
export type {
|
|
66
|
+
SubjectClaim,
|
|
67
|
+
SubjectPayload,
|
|
68
|
+
SubjectSchema,
|
|
69
|
+
} from "./types/subject"
|
|
70
|
+
|
|
71
|
+
export type {
|
|
72
|
+
ExchangeAudience,
|
|
73
|
+
FailureEvent,
|
|
74
|
+
IdP,
|
|
75
|
+
IdPOptions,
|
|
76
|
+
PersistUpstreamTokens,
|
|
77
|
+
RenderPicker,
|
|
78
|
+
SuccessEvent,
|
|
79
|
+
SuccessMapInput,
|
|
80
|
+
} from "./types/idp"
|
|
81
|
+
|
|
82
|
+
export type { PickerContext, PickerMethod } from "./types/picker"
|
|
83
|
+
|
|
84
|
+
export type { AuditEvent, AuditLog } from "./ports/audit-log"
|
|
85
|
+
export type { ConfigStore } from "./ports/config-store"
|
|
86
|
+
export type {
|
|
87
|
+
EncryptionKey,
|
|
88
|
+
KeyStore,
|
|
89
|
+
KeyWrapper,
|
|
90
|
+
SigningKey,
|
|
91
|
+
} from "./ports/key-store"
|
|
92
|
+
export type { MethodStore } from "./ports/method-store"
|
|
93
|
+
export type { SessionRecord, SessionStore } from "./ports/session-store"
|
|
94
|
+
export type { TokenStore } from "./ports/token-store"
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Host-callable primitive for "log me out of all devices" UX. Wraps
|
|
98
|
+
* `TokenStore.revokeBySubject` with the framework's audit emission so
|
|
99
|
+
* hosts don't need to reimplement it. Reuse-detection escalation itself
|
|
100
|
+
* stays at family-scope per OAuth 2.0 Security BCP §4.13.2 (see
|
|
101
|
+
* ARCHITECTURE.md "Reuse detection scope").
|
|
102
|
+
*/
|
|
103
|
+
export { revokeAllForSubject } from "./domain/revoke"
|
|
104
|
+
|
|
105
|
+
// Phase 4 — credential + WebAuthn method factories.
|
|
106
|
+
export { passwordMethod } from "./methods/password"
|
|
107
|
+
export type {
|
|
108
|
+
PasswordMethodOptions,
|
|
109
|
+
PasswordProperties,
|
|
110
|
+
PasswordUser,
|
|
111
|
+
PasswordUserStore,
|
|
112
|
+
PasswordState,
|
|
113
|
+
} from "./methods/password"
|
|
114
|
+
export { codeMethod } from "./methods/code"
|
|
115
|
+
export type {
|
|
116
|
+
CodeMethodOptions,
|
|
117
|
+
CodeProperties,
|
|
118
|
+
CodeState,
|
|
119
|
+
} from "./methods/code"
|
|
120
|
+
export { m2mMethod } from "./methods/m2m"
|
|
121
|
+
export type { M2MMethodOptions, M2MProperties } from "./methods/m2m"
|
|
122
|
+
export { passkeyMethod } from "./methods/passkey"
|
|
123
|
+
export type {
|
|
124
|
+
PasskeyMethodOptions,
|
|
125
|
+
PasskeyProperties,
|
|
126
|
+
PasskeyState,
|
|
127
|
+
PasskeyCredentialStore,
|
|
128
|
+
StoredCredential,
|
|
129
|
+
} from "./methods/passkey"
|
|
8
130
|
|
|
9
131
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
132
|
+
argon2idHasher,
|
|
133
|
+
DEFAULT_ARGON2ID_PARAMS,
|
|
134
|
+
} from "./methods/password-hash"
|
|
135
|
+
export type { PasswordHasher, Argon2idParams } from "./methods/password-hash"
|
|
136
|
+
|
|
137
|
+
// Phase 5 — OAuth / OIDC provider factories.
|
|
138
|
+
export { buildOauth2Method } from "./methods/oauth2-generic"
|
|
139
|
+
export type {
|
|
140
|
+
Oauth2MethodInput,
|
|
141
|
+
Oauth2Properties,
|
|
142
|
+
Oauth2State,
|
|
143
|
+
} from "./methods/oauth2-generic"
|
|
144
|
+
export { buildOidcMethod } from "./methods/oidc-generic"
|
|
145
|
+
export type { OidcMethodInput } from "./methods/oidc-generic"
|
|
16
146
|
|
|
17
|
-
|
|
147
|
+
// Generic multi-tenant factories. Reach for these first when each
|
|
148
|
+
// tenant brings its own issuer / client credentials. The vendor
|
|
149
|
+
// factories above (googleFactory etc.) are convenience wrappers when
|
|
150
|
+
// the issuer is fixed.
|
|
151
|
+
export {
|
|
152
|
+
oauth2Factory,
|
|
153
|
+
oidcFactory,
|
|
154
|
+
type Oauth2FactoryConfig,
|
|
155
|
+
type OidcFactoryConfig,
|
|
156
|
+
} from "./methods/oauth2-factory"
|
|
18
157
|
|
|
19
158
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
159
|
+
appleFactory,
|
|
160
|
+
cognitoFactory,
|
|
161
|
+
discordFactory,
|
|
162
|
+
facebookFactory,
|
|
163
|
+
githubFactory,
|
|
164
|
+
googleFactory,
|
|
165
|
+
jumpcloudFactory,
|
|
166
|
+
keycloakFactory,
|
|
167
|
+
linkedinFactory,
|
|
168
|
+
microsoftFactory,
|
|
169
|
+
slackFactory,
|
|
170
|
+
spotifyFactory,
|
|
171
|
+
twitchFactory,
|
|
172
|
+
xFactory,
|
|
173
|
+
yahooFactory,
|
|
174
|
+
} from "./methods/providers"
|
|
175
|
+
|
|
176
|
+
import type { IdP, IdPOptions } from "./types/idp"
|
|
177
|
+
import { MethodCache } from "./domain/method-cache"
|
|
178
|
+
import { buildRouter } from "./http/router"
|
|
179
|
+
import type { HttpDeps } from "./http/context"
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Construct a new IdP from the supplied options.
|
|
183
|
+
*
|
|
184
|
+
* Phase 3 ships the full HTTP surface backed by the Phase 2 domain
|
|
185
|
+
* functions. Wire up:
|
|
186
|
+
*
|
|
187
|
+
* - A `MethodCache` over the configured factories. The factory map's
|
|
188
|
+
* keys MUST equal each factory's `kind`; we throw on construction if
|
|
189
|
+
* any disagree.
|
|
190
|
+
* - A `HttpDeps` record passed into the Hono router.
|
|
191
|
+
* - The returned `IdP.handle` is `app.fetch.bind(app)`; the per-endpoint
|
|
192
|
+
* primitives (`authorize`, `token`, etc.) re-enter the same app.
|
|
193
|
+
*/
|
|
194
|
+
export function createIdP(opts: IdPOptions): IdP {
|
|
195
|
+
// Validate factory-key invariant before any request can hit a bad map.
|
|
196
|
+
const mismatched = Object.entries(opts.methods)
|
|
197
|
+
.filter(([key, factory]) => key !== factory.kind)
|
|
198
|
+
.map(([key, factory]) => `${key}!=${factory.kind}`)
|
|
199
|
+
if (mismatched.length > 0) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
`createIdP: methods map keys must equal factory.kind. Offenders: ${mismatched.join(", ")}`,
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const clock = () => Date.now()
|
|
206
|
+
const auditLog = opts.auditLog
|
|
207
|
+
const methodCache = new MethodCache({
|
|
208
|
+
factories: opts.methods,
|
|
209
|
+
...(auditLog ? { auditLog } : {}),
|
|
210
|
+
now: clock,
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
// Tenant-config rotation must bust the cached `AuthMethod` instances,
|
|
214
|
+
// otherwise upstream client-secret changes (Google / Okta / etc.) are
|
|
215
|
+
// ignored because `buildOauth2Method` / `buildOidcMethod` capture the
|
|
216
|
+
// old secret in a closure. `ConfigStore.onInvalidate` is the canonical
|
|
217
|
+
// signal — adapters fire it from `putTenantConfig` and from any
|
|
218
|
+
// host-driven cross-process invalidation hook.
|
|
219
|
+
opts.configStore.onInvalidate?.((tenantId) => {
|
|
220
|
+
methodCache.invalidate(tenantId)
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
const resolveIssuer = (req: Request): string =>
|
|
224
|
+
typeof opts.issuerUrl === "string" ? opts.issuerUrl : opts.issuerUrl(req)
|
|
225
|
+
|
|
226
|
+
const deps: HttpDeps = {
|
|
227
|
+
configStore: opts.configStore,
|
|
228
|
+
tokenStore: opts.tokenStore,
|
|
229
|
+
sessionStore: opts.sessionStore,
|
|
230
|
+
keyStore: opts.keyStore,
|
|
231
|
+
...(opts.methodStore ? { methodStore: opts.methodStore } : {}),
|
|
232
|
+
...(auditLog ? { auditLog } : {}),
|
|
233
|
+
methodCache,
|
|
234
|
+
stateKeys: opts.stateKeys,
|
|
235
|
+
resolveIssuer,
|
|
236
|
+
...(opts.callbackHostFor ? { callbackHostFor: opts.callbackHostFor } : {}),
|
|
237
|
+
resolveTenant: opts.resolveTenant,
|
|
238
|
+
success: opts.success,
|
|
239
|
+
...(opts.persistUpstreamTokens
|
|
240
|
+
? { persistUpstreamTokens: opts.persistUpstreamTokens }
|
|
241
|
+
: {}),
|
|
242
|
+
...(opts.exchangeAudience
|
|
243
|
+
? { exchangeAudience: opts.exchangeAudience }
|
|
244
|
+
: {}),
|
|
245
|
+
...(opts.renderPicker ? { renderPicker: opts.renderPicker } : {}),
|
|
246
|
+
...(opts.buildCustomContext
|
|
247
|
+
? { buildCustomContext: opts.buildCustomContext }
|
|
248
|
+
: {}),
|
|
249
|
+
clock,
|
|
250
|
+
cookieDefaults: {
|
|
251
|
+
secure: opts.cookies?.secure ?? true,
|
|
252
|
+
...(opts.cookies?.domain !== undefined
|
|
253
|
+
? { domain: opts.cookies.domain }
|
|
254
|
+
: {}),
|
|
255
|
+
...(opts.cookies?.path !== undefined ? { path: opts.cookies.path } : {}),
|
|
256
|
+
},
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const app = buildRouter(deps)
|
|
260
|
+
const fetch = async (req: Request): Promise<Response> => await app.fetch(req)
|
|
261
|
+
|
|
262
|
+
return {
|
|
263
|
+
handle: fetch,
|
|
264
|
+
authorize: fetch,
|
|
265
|
+
token: fetch,
|
|
266
|
+
userinfo: fetch,
|
|
267
|
+
jwks: fetch,
|
|
268
|
+
discovery: fetch,
|
|
269
|
+
revoke: fetch,
|
|
270
|
+
introspect: fetch,
|
|
271
|
+
}
|
|
26
272
|
}
|