@vibesdotdev/auth 0.0.0-stage → 1.0.0-rc.3
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/LICENSE +18 -0
- package/README.md +224 -2
- package/dist/api/auth.api-client.descriptor.d.ts +33 -0
- package/dist/api/auth.api-client.descriptor.d.ts.map +1 -0
- package/dist/api/auth.api-client.descriptor.js +34 -0
- package/dist/api/auth.api-client.descriptor.js.map +1 -0
- package/dist/api/auth.api-client.impl.d.ts +165 -0
- package/dist/api/auth.api-client.impl.d.ts.map +1 -0
- package/dist/api/auth.api-client.impl.js +595 -0
- package/dist/api/auth.api-client.impl.js.map +1 -0
- package/dist/api/auth.api-client.schemas.d.ts +199 -0
- package/dist/api/auth.api-client.schemas.d.ts.map +1 -0
- package/dist/api/auth.api-client.schemas.js +130 -0
- package/dist/api/auth.api-client.schemas.js.map +1 -0
- package/dist/api/auth.api-client.types.d.ts +142 -0
- package/dist/api/auth.api-client.types.d.ts.map +1 -0
- package/dist/api/auth.api-client.types.js +45 -0
- package/dist/api/auth.api-client.types.js.map +1 -0
- package/dist/api/auth.api-client.urls.d.ts +6 -0
- package/dist/api/auth.api-client.urls.d.ts.map +1 -0
- package/dist/api/auth.api-client.urls.js +29 -0
- package/dist/api/auth.api-client.urls.js.map +1 -0
- package/dist/api/failure-message.d.ts +11 -0
- package/dist/api/failure-message.d.ts.map +1 -0
- package/dist/api/failure-message.js +25 -0
- package/dist/api/failure-message.js.map +1 -0
- package/dist/api/index.d.ts +19 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +19 -0
- package/dist/api/index.js.map +1 -0
- package/dist/augmentations/users.descriptor.d.ts +35 -0
- package/dist/augmentations/users.descriptor.d.ts.map +1 -0
- package/dist/augmentations/users.descriptor.js +18 -0
- package/dist/augmentations/users.descriptor.js.map +1 -0
- package/dist/bearer/caller-bearer.context.descriptor.d.ts +35 -0
- package/dist/bearer/caller-bearer.context.descriptor.d.ts.map +1 -0
- package/dist/bearer/caller-bearer.context.descriptor.js +18 -0
- package/dist/bearer/caller-bearer.context.descriptor.js.map +1 -0
- package/dist/bearer/caller-bearer.context.impl.d.ts +8 -0
- package/dist/bearer/caller-bearer.context.impl.d.ts.map +1 -0
- package/dist/bearer/caller-bearer.context.impl.js +8 -0
- package/dist/bearer/caller-bearer.context.impl.js.map +1 -0
- package/dist/bearer/caller-bearer.d.ts +36 -0
- package/dist/bearer/caller-bearer.d.ts.map +1 -0
- package/dist/bearer/caller-bearer.js +71 -0
- package/dist/bearer/caller-bearer.js.map +1 -0
- package/dist/bearer/oauth-account.d.ts +37 -0
- package/dist/bearer/oauth-account.d.ts.map +1 -0
- package/dist/bearer/oauth-account.js +51 -0
- package/dist/bearer/oauth-account.js.map +1 -0
- package/dist/bearer/oauth-account.store.d.ts +8 -0
- package/dist/bearer/oauth-account.store.d.ts.map +1 -0
- package/dist/bearer/oauth-account.store.descriptor.d.ts +14 -0
- package/dist/bearer/oauth-account.store.descriptor.d.ts.map +1 -0
- package/dist/bearer/oauth-account.store.descriptor.js +13 -0
- package/dist/bearer/oauth-account.store.descriptor.js.map +1 -0
- package/dist/bearer/oauth-account.store.js +120 -0
- package/dist/bearer/oauth-account.store.js.map +1 -0
- package/dist/bearer/request-session.store.d.ts +8 -0
- package/dist/bearer/request-session.store.d.ts.map +1 -0
- package/dist/bearer/request-session.store.descriptor.d.ts +15 -0
- package/dist/bearer/request-session.store.descriptor.d.ts.map +1 -0
- package/dist/bearer/request-session.store.descriptor.js +15 -0
- package/dist/bearer/request-session.store.descriptor.js.map +1 -0
- package/dist/bearer/request-session.store.js +21 -0
- package/dist/bearer/request-session.store.js.map +1 -0
- package/dist/cli/api-key/auth.api-key.cli-group.descriptor.d.ts +9 -0
- package/dist/cli/api-key/auth.api-key.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/api-key/auth.api-key.cli-group.descriptor.js +18 -0
- package/dist/cli/api-key/auth.api-key.cli-group.descriptor.js.map +1 -0
- package/dist/cli/api-key/create/auth.api-key-create.descriptor.d.ts +9 -0
- package/dist/cli/api-key/create/auth.api-key-create.descriptor.d.ts.map +1 -0
- package/dist/cli/api-key/create/auth.api-key-create.descriptor.js +39 -0
- package/dist/cli/api-key/create/auth.api-key-create.descriptor.js.map +1 -0
- package/dist/cli/api-key/create/auth.api-key-create.impl.d.ts +8 -0
- package/dist/cli/api-key/create/auth.api-key-create.impl.d.ts.map +1 -0
- package/dist/cli/api-key/create/auth.api-key-create.impl.js +56 -0
- package/dist/cli/api-key/create/auth.api-key-create.impl.js.map +1 -0
- package/dist/cli/api-key/list/auth.api-key-list.descriptor.d.ts +9 -0
- package/dist/cli/api-key/list/auth.api-key-list.descriptor.d.ts.map +1 -0
- package/dist/cli/api-key/list/auth.api-key-list.descriptor.js +24 -0
- package/dist/cli/api-key/list/auth.api-key-list.descriptor.js.map +1 -0
- package/dist/cli/api-key/list/auth.api-key-list.impl.d.ts +8 -0
- package/dist/cli/api-key/list/auth.api-key-list.impl.d.ts.map +1 -0
- package/dist/cli/api-key/list/auth.api-key-list.impl.js +39 -0
- package/dist/cli/api-key/list/auth.api-key-list.impl.js.map +1 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.descriptor.d.ts +9 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.descriptor.d.ts.map +1 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.descriptor.js +31 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.descriptor.js.map +1 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.impl.d.ts +8 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.impl.d.ts.map +1 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.impl.js +42 -0
- package/dist/cli/api-key/revoke/auth.api-key-revoke.impl.js.map +1 -0
- package/dist/cli/client/api.d.ts +10 -0
- package/dist/cli/client/api.d.ts.map +1 -0
- package/dist/cli/client/api.js +81 -0
- package/dist/cli/client/api.js.map +1 -0
- package/dist/cli/command-io.d.ts +31 -0
- package/dist/cli/command-io.d.ts.map +1 -0
- package/dist/cli/command-io.js +38 -0
- package/dist/cli/command-io.js.map +1 -0
- package/dist/cli/commands/login/auth.login.descriptor.d.ts +9 -0
- package/dist/cli/commands/login/auth.login.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/login/auth.login.descriptor.js +27 -0
- package/dist/cli/commands/login/auth.login.descriptor.js.map +1 -0
- package/dist/cli/commands/login/auth.login.impl.d.ts +8 -0
- package/dist/cli/commands/login/auth.login.impl.d.ts.map +1 -0
- package/dist/cli/commands/login/auth.login.impl.js +45 -0
- package/dist/cli/commands/login/auth.login.impl.js.map +1 -0
- package/dist/cli/commands/logout/auth.logout.descriptor.d.ts +9 -0
- package/dist/cli/commands/logout/auth.logout.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/logout/auth.logout.descriptor.js +17 -0
- package/dist/cli/commands/logout/auth.logout.descriptor.js.map +1 -0
- package/dist/cli/commands/logout/auth.logout.impl.d.ts +8 -0
- package/dist/cli/commands/logout/auth.logout.impl.d.ts.map +1 -0
- package/dist/cli/commands/logout/auth.logout.impl.js +27 -0
- package/dist/cli/commands/logout/auth.logout.impl.js.map +1 -0
- package/dist/cli/commands/profile/auth.profile.descriptor.d.ts +9 -0
- package/dist/cli/commands/profile/auth.profile.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/profile/auth.profile.descriptor.js +17 -0
- package/dist/cli/commands/profile/auth.profile.descriptor.js.map +1 -0
- package/dist/cli/commands/profile/auth.profile.impl.d.ts +8 -0
- package/dist/cli/commands/profile/auth.profile.impl.d.ts.map +1 -0
- package/dist/cli/commands/profile/auth.profile.impl.js +38 -0
- package/dist/cli/commands/profile/auth.profile.impl.js.map +1 -0
- package/dist/cli/commands/seed/auth.seed.descriptor.d.ts +4 -0
- package/dist/cli/commands/seed/auth.seed.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/seed/auth.seed.descriptor.js +24 -0
- package/dist/cli/commands/seed/auth.seed.descriptor.js.map +1 -0
- package/dist/cli/commands/seed/auth.seed.impl.d.ts +3 -0
- package/dist/cli/commands/seed/auth.seed.impl.d.ts.map +1 -0
- package/dist/cli/commands/seed/auth.seed.impl.js +146 -0
- package/dist/cli/commands/seed/auth.seed.impl.js.map +1 -0
- package/dist/cli/commands/seed/seed-users.d.ts +145 -0
- package/dist/cli/commands/seed/seed-users.d.ts.map +1 -0
- package/dist/cli/commands/seed/seed-users.js +64 -0
- package/dist/cli/commands/seed/seed-users.js.map +1 -0
- package/dist/cli/commands/setup/auth.setup.descriptor.d.ts +9 -0
- package/dist/cli/commands/setup/auth.setup.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/setup/auth.setup.descriptor.js +37 -0
- package/dist/cli/commands/setup/auth.setup.descriptor.js.map +1 -0
- package/dist/cli/commands/setup/auth.setup.impl.d.ts +11 -0
- package/dist/cli/commands/setup/auth.setup.impl.d.ts.map +1 -0
- package/dist/cli/commands/setup/auth.setup.impl.js +129 -0
- package/dist/cli/commands/setup/auth.setup.impl.js.map +1 -0
- package/dist/cli/commands/status/auth.status.descriptor.d.ts +9 -0
- package/dist/cli/commands/status/auth.status.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/status/auth.status.descriptor.js +23 -0
- package/dist/cli/commands/status/auth.status.descriptor.js.map +1 -0
- package/dist/cli/commands/status/auth.status.impl.d.ts +19 -0
- package/dist/cli/commands/status/auth.status.impl.d.ts.map +1 -0
- package/dist/cli/commands/status/auth.status.impl.js +128 -0
- package/dist/cli/commands/status/auth.status.impl.js.map +1 -0
- package/dist/cli/commands/token/auth.token.descriptor.d.ts +9 -0
- package/dist/cli/commands/token/auth.token.descriptor.d.ts.map +1 -0
- package/dist/cli/commands/token/auth.token.descriptor.js +24 -0
- package/dist/cli/commands/token/auth.token.descriptor.js.map +1 -0
- package/dist/cli/commands/token/auth.token.impl.d.ts +18 -0
- package/dist/cli/commands/token/auth.token.impl.d.ts.map +1 -0
- package/dist/cli/commands/token/auth.token.impl.js +51 -0
- package/dist/cli/commands/token/auth.token.impl.js.map +1 -0
- package/dist/cli/context-bridge.d.ts +15 -0
- package/dist/cli/context-bridge.d.ts.map +1 -0
- package/dist/cli/context-bridge.js +17 -0
- package/dist/cli/context-bridge.js.map +1 -0
- package/dist/cli/groups/auth.cli-group.descriptor.d.ts +10 -0
- package/dist/cli/groups/auth.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/groups/auth.cli-group.descriptor.js +17 -0
- package/dist/cli/groups/auth.cli-group.descriptor.js.map +1 -0
- package/dist/cli/runtime/plugin/cli.d.ts +3 -0
- package/dist/cli/runtime/plugin/cli.d.ts.map +1 -0
- package/dist/cli/runtime/plugin/cli.js +95 -0
- package/dist/cli/runtime/plugin/cli.js.map +1 -0
- package/dist/cli/schemas/commands.d.ts +165 -0
- package/dist/cli/schemas/commands.d.ts.map +1 -0
- package/dist/cli/schemas/commands.js +134 -0
- package/dist/cli/schemas/commands.js.map +1 -0
- package/dist/cli/schemas/types.d.ts +108 -0
- package/dist/cli/schemas/types.d.ts.map +1 -0
- package/dist/cli/schemas/types.js +2 -0
- package/dist/cli/schemas/types.js.map +1 -0
- package/dist/cli/services/api-key.d.ts +4 -0
- package/dist/cli/services/api-key.d.ts.map +1 -0
- package/dist/cli/services/api-key.js +124 -0
- package/dist/cli/services/api-key.js.map +1 -0
- package/dist/cli/services/app-jwt.d.ts +23 -0
- package/dist/cli/services/app-jwt.d.ts.map +1 -0
- package/dist/cli/services/app-jwt.js +189 -0
- package/dist/cli/services/app-jwt.js.map +1 -0
- package/dist/cli/services/auth-probe-failure.d.ts +17 -0
- package/dist/cli/services/auth-probe-failure.d.ts.map +1 -0
- package/dist/cli/services/auth-probe-failure.js +109 -0
- package/dist/cli/services/auth-probe-failure.js.map +1 -0
- package/dist/cli/services/auth.d.ts +7 -0
- package/dist/cli/services/auth.d.ts.map +1 -0
- package/dist/cli/services/auth.js +7 -0
- package/dist/cli/services/auth.js.map +1 -0
- package/dist/cli/services/bootstrap-session.d.ts +68 -0
- package/dist/cli/services/bootstrap-session.d.ts.map +1 -0
- package/dist/cli/services/bootstrap-session.js +102 -0
- package/dist/cli/services/bootstrap-session.js.map +1 -0
- package/dist/cli/services/login-device.cli.d.ts +32 -0
- package/dist/cli/services/login-device.cli.d.ts.map +1 -0
- package/dist/cli/services/login-device.cli.js +296 -0
- package/dist/cli/services/login-device.cli.js.map +1 -0
- package/dist/cli/services/login-shared.d.ts +10 -0
- package/dist/cli/services/login-shared.d.ts.map +1 -0
- package/dist/cli/services/login-shared.js +18 -0
- package/dist/cli/services/login-shared.js.map +1 -0
- package/dist/cli/services/login.d.ts +11 -0
- package/dist/cli/services/login.d.ts.map +1 -0
- package/dist/cli/services/login.js +143 -0
- package/dist/cli/services/login.js.map +1 -0
- package/dist/cli/services/logout.d.ts +4 -0
- package/dist/cli/services/logout.d.ts.map +1 -0
- package/dist/cli/services/logout.js +101 -0
- package/dist/cli/services/logout.js.map +1 -0
- package/dist/cli/services/profile.d.ts +7 -0
- package/dist/cli/services/profile.d.ts.map +1 -0
- package/dist/cli/services/profile.js +45 -0
- package/dist/cli/services/profile.js.map +1 -0
- package/dist/cli/services/status.d.ts +7 -0
- package/dist/cli/services/status.d.ts.map +1 -0
- package/dist/cli/services/status.js +42 -0
- package/dist/cli/services/status.js.map +1 -0
- package/dist/cli/services/token.d.ts +7 -0
- package/dist/cli/services/token.d.ts.map +1 -0
- package/dist/cli/services/token.js +139 -0
- package/dist/cli/services/token.js.map +1 -0
- package/dist/client/admin.d.ts +12 -0
- package/dist/client/admin.d.ts.map +1 -0
- package/dist/client/admin.js +179 -0
- package/dist/client/admin.js.map +1 -0
- package/dist/client/app-authority.d.ts +175 -0
- package/dist/client/app-authority.d.ts.map +1 -0
- package/dist/client/app-authority.js +561 -0
- package/dist/client/app-authority.js.map +1 -0
- package/dist/client/auth-client.d.ts +21 -0
- package/dist/client/auth-client.d.ts.map +1 -0
- package/dist/client/auth-client.js +58 -0
- package/dist/client/auth-client.js.map +1 -0
- package/dist/client/auth.api-client.impl.d.ts +29 -0
- package/dist/client/auth.api-client.impl.d.ts.map +1 -0
- package/dist/client/auth.api-client.impl.js +64 -0
- package/dist/client/auth.api-client.impl.js.map +1 -0
- package/dist/client/auth.legacy-api-client.descriptor.d.ts +4 -0
- package/dist/client/auth.legacy-api-client.descriptor.d.ts.map +1 -0
- package/dist/client/auth.legacy-api-client.descriptor.js +8 -0
- package/dist/client/auth.legacy-api-client.descriptor.js.map +1 -0
- package/dist/client/browser-session-code.d.ts +32 -0
- package/dist/client/browser-session-code.d.ts.map +1 -0
- package/dist/client/browser-session-code.js +78 -0
- package/dist/client/browser-session-code.js.map +1 -0
- package/dist/client/browser-session.d.ts +9 -0
- package/dist/client/browser-session.d.ts.map +1 -0
- package/dist/client/browser-session.js +43 -0
- package/dist/client/browser-session.js.map +1 -0
- package/dist/client/consumer-context.d.ts +25 -0
- package/dist/client/consumer-context.d.ts.map +1 -0
- package/dist/client/consumer-context.js +52 -0
- package/dist/client/consumer-context.js.map +1 -0
- package/dist/client/consumer-context.types.d.ts +52 -0
- package/dist/client/consumer-context.types.d.ts.map +1 -0
- package/dist/client/consumer-context.types.js +2 -0
- package/dist/client/consumer-context.types.js.map +1 -0
- package/dist/client/device-authorization.d.ts +120 -0
- package/dist/client/device-authorization.d.ts.map +1 -0
- package/dist/client/device-authorization.js +352 -0
- package/dist/client/device-authorization.js.map +1 -0
- package/dist/client/device-login.d.ts +9 -0
- package/dist/client/device-login.d.ts.map +1 -0
- package/dist/client/device-login.js +196 -0
- package/dist/client/device-login.js.map +1 -0
- package/dist/client/factory.d.ts +18 -0
- package/dist/client/factory.d.ts.map +1 -0
- package/dist/client/factory.js +79 -0
- package/dist/client/factory.js.map +1 -0
- package/dist/client/gateway.d.ts +26 -0
- package/dist/client/gateway.d.ts.map +1 -0
- package/dist/client/gateway.js +129 -0
- package/dist/client/gateway.js.map +1 -0
- package/dist/client/index.d.ts +18 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +11 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/mobile-auth.d.ts +47 -0
- package/dist/client/mobile-auth.d.ts.map +1 -0
- package/dist/client/mobile-auth.js +137 -0
- package/dist/client/mobile-auth.js.map +1 -0
- package/dist/client/provider-compat.d.ts +24 -0
- package/dist/client/provider-compat.d.ts.map +1 -0
- package/dist/client/provider-compat.js +23 -0
- package/dist/client/provider-compat.js.map +1 -0
- package/dist/client/read-json-or-null.d.ts +23 -0
- package/dist/client/read-json-or-null.d.ts.map +1 -0
- package/dist/client/read-json-or-null.js +39 -0
- package/dist/client/read-json-or-null.js.map +1 -0
- package/dist/client/request-failure.d.ts +28 -0
- package/dist/client/request-failure.d.ts.map +1 -0
- package/dist/client/request-failure.js +80 -0
- package/dist/client/request-failure.js.map +1 -0
- package/dist/client/routes.d.ts +29 -0
- package/dist/client/routes.d.ts.map +1 -0
- package/dist/client/routes.js +29 -0
- package/dist/client/routes.js.map +1 -0
- package/dist/client/schemas.d.ts +3 -0
- package/dist/client/schemas.d.ts.map +1 -0
- package/dist/client/schemas.js +2 -0
- package/dist/client/schemas.js.map +1 -0
- package/dist/client/session-authorization.d.ts +17 -0
- package/dist/client/session-authorization.d.ts.map +1 -0
- package/dist/client/session-authorization.js +17 -0
- package/dist/client/session-authorization.js.map +1 -0
- package/dist/client/session-identity.d.ts +25 -0
- package/dist/client/session-identity.d.ts.map +1 -0
- package/dist/client/session-identity.js +29 -0
- package/dist/client/session-identity.js.map +1 -0
- package/dist/config/auth.app-credentials.config.descriptor.d.ts +10 -0
- package/dist/config/auth.app-credentials.config.descriptor.d.ts.map +1 -0
- package/dist/config/auth.app-credentials.config.descriptor.js +25 -0
- package/dist/config/auth.app-credentials.config.descriptor.js.map +1 -0
- package/dist/config/auth.providers.config.descriptor.d.ts +26 -0
- package/dist/config/auth.providers.config.descriptor.d.ts.map +1 -0
- package/dist/config/auth.providers.config.descriptor.js +51 -0
- package/dist/config/auth.providers.config.descriptor.js.map +1 -0
- package/dist/config/auth.providers.storage.descriptor.d.ts +17 -0
- package/dist/config/auth.providers.storage.descriptor.d.ts.map +1 -0
- package/dist/config/auth.providers.storage.descriptor.js +54 -0
- package/dist/config/auth.providers.storage.descriptor.js.map +1 -0
- package/dist/config/env.d.ts +6 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +6 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/local-auth-origin.d.ts +6 -0
- package/dist/config/local-auth-origin.d.ts.map +1 -0
- package/dist/config/local-auth-origin.js +33 -0
- package/dist/config/local-auth-origin.js.map +1 -0
- package/dist/device-session/auth-device-session.capability.d.ts +202 -0
- package/dist/device-session/auth-device-session.capability.d.ts.map +1 -0
- package/dist/device-session/auth-device-session.capability.js +185 -0
- package/dist/device-session/auth-device-session.capability.js.map +1 -0
- package/dist/device-session/auth-device-session.impl.consumer.worker.d.ts +58 -0
- package/dist/device-session/auth-device-session.impl.consumer.worker.d.ts.map +1 -0
- package/dist/device-session/auth-device-session.impl.consumer.worker.js +494 -0
- package/dist/device-session/auth-device-session.impl.consumer.worker.js.map +1 -0
- package/dist/device-session/device-session.state.d.ts +8 -0
- package/dist/device-session/device-session.state.d.ts.map +1 -0
- package/dist/device-session/device-session.state.js +32 -0
- package/dist/device-session/device-session.state.js.map +1 -0
- package/dist/device-session/device-session.store.d.ts +81 -0
- package/dist/device-session/device-session.store.d.ts.map +1 -0
- package/dist/device-session/device-session.store.descriptor.d.ts +27 -0
- package/dist/device-session/device-session.store.descriptor.d.ts.map +1 -0
- package/dist/device-session/device-session.store.descriptor.js +30 -0
- package/dist/device-session/device-session.store.descriptor.js.map +1 -0
- package/dist/device-session/device-session.store.js +225 -0
- package/dist/device-session/device-session.store.js.map +1 -0
- package/dist/docs/auth.docs.descriptor.d.ts +4 -0
- package/dist/docs/auth.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/auth.docs.descriptor.js +50 -0
- package/dist/docs/auth.docs.descriptor.js.map +1 -0
- package/dist/docs/auth.providers.docs.descriptor.d.ts +4 -0
- package/dist/docs/auth.providers.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/auth.providers.docs.descriptor.js +177 -0
- package/dist/docs/auth.providers.docs.descriptor.js.map +1 -0
- package/dist/docs/flows.docs.descriptor.d.ts +4 -0
- package/dist/docs/flows.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/flows.docs.descriptor.js +192 -0
- package/dist/docs/flows.docs.descriptor.js.map +1 -0
- package/dist/docs/keys.docs.descriptor.d.ts +4 -0
- package/dist/docs/keys.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/keys.docs.descriptor.js +247 -0
- package/dist/docs/keys.docs.descriptor.js.map +1 -0
- package/dist/docs/oauth.docs.descriptor.d.ts +4 -0
- package/dist/docs/oauth.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/oauth.docs.descriptor.js +177 -0
- package/dist/docs/oauth.docs.descriptor.js.map +1 -0
- package/dist/docs/sessions.docs.descriptor.d.ts +4 -0
- package/dist/docs/sessions.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/sessions.docs.descriptor.js +295 -0
- package/dist/docs/sessions.docs.descriptor.js.map +1 -0
- package/dist/events/on-client-auth-rejected.impl.d.ts +18 -0
- package/dist/events/on-client-auth-rejected.impl.d.ts.map +1 -0
- package/dist/events/on-client-auth-rejected.impl.js +23 -0
- package/dist/events/on-client-auth-rejected.impl.js.map +1 -0
- package/dist/events/on-client-auth-rejected.subscription.descriptor.d.ts +18 -0
- package/dist/events/on-client-auth-rejected.subscription.descriptor.d.ts.map +1 -0
- package/dist/events/on-client-auth-rejected.subscription.descriptor.js +18 -0
- package/dist/events/on-client-auth-rejected.subscription.descriptor.js.map +1 -0
- package/dist/events/session-established.event.descriptor.d.ts +32 -0
- package/dist/events/session-established.event.descriptor.d.ts.map +1 -0
- package/dist/events/session-established.event.descriptor.js +35 -0
- package/dist/events/session-established.event.descriptor.js.map +1 -0
- package/dist/features/authorization/organization-policy.d.ts +270 -0
- package/dist/features/authorization/organization-policy.d.ts.map +1 -0
- package/dist/features/authorization/organization-policy.js +187 -0
- package/dist/features/authorization/organization-policy.js.map +1 -0
- package/dist/features/config/auth-api.d.ts +4 -0
- package/dist/features/config/auth-api.d.ts.map +1 -0
- package/dist/features/config/auth-api.js +20 -0
- package/dist/features/config/auth-api.js.map +1 -0
- package/dist/features/config/e2e.d.ts +9 -0
- package/dist/features/config/e2e.d.ts.map +1 -0
- package/dist/features/config/e2e.js +21 -0
- package/dist/features/config/e2e.js.map +1 -0
- package/dist/features/core/shared/auth-errors.d.ts +2 -0
- package/dist/features/core/shared/auth-errors.d.ts.map +1 -0
- package/dist/features/core/shared/auth-errors.js +68 -0
- package/dist/features/core/shared/auth-errors.js.map +1 -0
- package/dist/features/email/email.config.descriptor.d.ts +4 -0
- package/dist/features/email/email.config.descriptor.d.ts.map +1 -0
- package/dist/features/email/email.config.descriptor.js +14 -0
- package/dist/features/email/email.config.descriptor.js.map +1 -0
- package/dist/features/email/env.d.ts +6 -0
- package/dist/features/email/env.d.ts.map +1 -0
- package/dist/features/email/env.js +14 -0
- package/dist/features/email/env.js.map +1 -0
- package/dist/features/email/env.schema.d.ts +50 -0
- package/dist/features/email/env.schema.d.ts.map +1 -0
- package/dist/features/email/env.schema.js +25 -0
- package/dist/features/email/env.schema.js.map +1 -0
- package/dist/features/email/provider.d.ts +8 -0
- package/dist/features/email/provider.d.ts.map +1 -0
- package/dist/features/email/provider.js +25 -0
- package/dist/features/email/provider.js.map +1 -0
- package/dist/features/email/resolver.d.ts +48 -0
- package/dist/features/email/resolver.d.ts.map +1 -0
- package/dist/features/email/resolver.js +54 -0
- package/dist/features/email/resolver.js.map +1 -0
- package/dist/features/email/schemas/common.d.ts +146 -0
- package/dist/features/email/schemas/common.d.ts.map +1 -0
- package/dist/features/email/schemas/common.js +109 -0
- package/dist/features/email/schemas/common.js.map +1 -0
- package/dist/features/email/schemas/forms.d.ts +72 -0
- package/dist/features/email/schemas/forms.d.ts.map +1 -0
- package/dist/features/email/schemas/forms.js +62 -0
- package/dist/features/email/schemas/forms.js.map +1 -0
- package/dist/features/email/schemas/index.d.ts +10 -0
- package/dist/features/email/schemas/index.d.ts.map +1 -0
- package/dist/features/email/schemas/index.js +5 -0
- package/dist/features/email/schemas/index.js.map +1 -0
- package/dist/features/email/schemas/templates.d.ts +40 -0
- package/dist/features/email/schemas/templates.d.ts.map +1 -0
- package/dist/features/email/schemas/templates.js +2 -0
- package/dist/features/email/schemas/templates.js.map +1 -0
- package/dist/features/email/schemas/transport.d.ts +83 -0
- package/dist/features/email/schemas/transport.d.ts.map +1 -0
- package/dist/features/email/schemas/transport.js +38 -0
- package/dist/features/email/schemas/transport.js.map +1 -0
- package/dist/features/email/schemas/types.d.ts +2 -0
- package/dist/features/email/schemas/types.d.ts.map +1 -0
- package/dist/features/email/schemas/types.js +2 -0
- package/dist/features/email/schemas/types.js.map +1 -0
- package/dist/features/email/send.d.ts +50 -0
- package/dist/features/email/send.d.ts.map +1 -0
- package/dist/features/email/send.js +73 -0
- package/dist/features/email/send.js.map +1 -0
- package/dist/features/oauth/schemas/common.d.ts +75 -0
- package/dist/features/oauth/schemas/common.d.ts.map +1 -0
- package/dist/features/oauth/schemas/common.js +51 -0
- package/dist/features/oauth/schemas/common.js.map +1 -0
- package/dist/features/oauth/schemas/forms.d.ts +29 -0
- package/dist/features/oauth/schemas/forms.d.ts.map +1 -0
- package/dist/features/oauth/schemas/forms.js +17 -0
- package/dist/features/oauth/schemas/forms.js.map +1 -0
- package/dist/features/oauth/schemas/index.d.ts +7 -0
- package/dist/features/oauth/schemas/index.d.ts.map +1 -0
- package/dist/features/oauth/schemas/index.js +4 -0
- package/dist/features/oauth/schemas/index.js.map +1 -0
- package/dist/features/oauth/schemas/types.d.ts +2 -0
- package/dist/features/oauth/schemas/types.d.ts.map +1 -0
- package/dist/features/oauth/schemas/types.js +2 -0
- package/dist/features/oauth/schemas/types.js.map +1 -0
- package/dist/features/oauth/schemas/ui.d.ts +28 -0
- package/dist/features/oauth/schemas/ui.d.ts.map +1 -0
- package/dist/features/oauth/schemas/ui.js +10 -0
- package/dist/features/oauth/schemas/ui.js.map +1 -0
- package/dist/features/permissions/definitions/ai.d.ts +4 -0
- package/dist/features/permissions/definitions/ai.d.ts.map +1 -0
- package/dist/features/permissions/definitions/ai.js +195 -0
- package/dist/features/permissions/definitions/ai.js.map +1 -0
- package/dist/features/permissions/definitions/billing.d.ts +2 -0
- package/dist/features/permissions/definitions/billing.d.ts.map +1 -0
- package/dist/features/permissions/definitions/billing.js +2 -0
- package/dist/features/permissions/definitions/billing.js.map +1 -0
- package/dist/features/permissions/definitions/catalog.d.ts +11 -0
- package/dist/features/permissions/definitions/catalog.d.ts.map +1 -0
- package/dist/features/permissions/definitions/catalog.js +13 -0
- package/dist/features/permissions/definitions/catalog.js.map +1 -0
- package/dist/features/permissions/definitions/collaboration.d.ts +3 -0
- package/dist/features/permissions/definitions/collaboration.d.ts.map +1 -0
- package/dist/features/permissions/definitions/collaboration.js +66 -0
- package/dist/features/permissions/definitions/collaboration.js.map +1 -0
- package/dist/features/permissions/definitions/helpers.d.ts +14 -0
- package/dist/features/permissions/definitions/helpers.d.ts.map +1 -0
- package/dist/features/permissions/definitions/helpers.js +42 -0
- package/dist/features/permissions/definitions/helpers.js.map +1 -0
- package/dist/features/permissions/definitions/index.d.ts +9 -0
- package/dist/features/permissions/definitions/index.d.ts.map +1 -0
- package/dist/features/permissions/definitions/index.js +8 -0
- package/dist/features/permissions/definitions/index.js.map +1 -0
- package/dist/features/permissions/definitions/repository.d.ts +23 -0
- package/dist/features/permissions/definitions/repository.d.ts.map +1 -0
- package/dist/features/permissions/definitions/repository.js +34 -0
- package/dist/features/permissions/definitions/repository.js.map +1 -0
- package/dist/features/permissions/definitions/roles.d.ts +13 -0
- package/dist/features/permissions/definitions/roles.d.ts.map +1 -0
- package/dist/features/permissions/definitions/roles.js +176 -0
- package/dist/features/permissions/definitions/roles.js.map +1 -0
- package/dist/features/permissions/definitions/system.d.ts +3 -0
- package/dist/features/permissions/definitions/system.d.ts.map +1 -0
- package/dist/features/permissions/definitions/system.js +157 -0
- package/dist/features/permissions/definitions/system.js.map +1 -0
- package/dist/features/permissions/schemas/common.d.ts +110 -0
- package/dist/features/permissions/schemas/common.d.ts.map +1 -0
- package/dist/features/permissions/schemas/common.js +89 -0
- package/dist/features/permissions/schemas/common.js.map +1 -0
- package/dist/features/permissions/schemas/forms.d.ts +46 -0
- package/dist/features/permissions/schemas/forms.d.ts.map +1 -0
- package/dist/features/permissions/schemas/forms.js +42 -0
- package/dist/features/permissions/schemas/forms.js.map +1 -0
- package/dist/features/permissions/schemas/guards.d.ts +56 -0
- package/dist/features/permissions/schemas/guards.d.ts.map +1 -0
- package/dist/features/permissions/schemas/guards.js +2 -0
- package/dist/features/permissions/schemas/guards.js.map +1 -0
- package/dist/features/permissions/schemas/index.d.ts +10 -0
- package/dist/features/permissions/schemas/index.d.ts.map +1 -0
- package/dist/features/permissions/schemas/index.js +5 -0
- package/dist/features/permissions/schemas/index.js.map +1 -0
- package/dist/features/permissions/schemas/server.d.ts +128 -0
- package/dist/features/permissions/schemas/server.d.ts.map +1 -0
- package/dist/features/permissions/schemas/server.js +91 -0
- package/dist/features/permissions/schemas/server.js.map +1 -0
- package/dist/features/permissions/schemas/types.d.ts +3 -0
- package/dist/features/permissions/schemas/types.d.ts.map +1 -0
- package/dist/features/permissions/schemas/types.js +5 -0
- package/dist/features/permissions/schemas/types.js.map +1 -0
- package/dist/features/permissions/schemas/ui.d.ts +50 -0
- package/dist/features/permissions/schemas/ui.d.ts.map +1 -0
- package/dist/features/permissions/schemas/ui.js +27 -0
- package/dist/features/permissions/schemas/ui.js.map +1 -0
- package/dist/features/services/credential-custody.d.ts +12 -0
- package/dist/features/services/credential-custody.d.ts.map +1 -0
- package/dist/features/services/credential-custody.js +76 -0
- package/dist/features/services/credential-custody.js.map +1 -0
- package/dist/features/services/credential-store.d.ts +116 -0
- package/dist/features/services/credential-store.d.ts.map +1 -0
- package/dist/features/services/credential-store.js +476 -0
- package/dist/features/services/credential-store.js.map +1 -0
- package/dist/features/utils/attempt.d.ts +29 -0
- package/dist/features/utils/attempt.d.ts.map +1 -0
- package/dist/features/utils/attempt.js +43 -0
- package/dist/features/utils/attempt.js.map +1 -0
- package/dist/features/utils/qr-code.d.ts +17 -0
- package/dist/features/utils/qr-code.d.ts.map +1 -0
- package/dist/features/utils/qr-code.js +68 -0
- package/dist/features/utils/qr-code.js.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +11 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +19 -0
- package/dist/json.js.map +1 -0
- package/dist/jwt/index.d.ts +51 -0
- package/dist/jwt/index.d.ts.map +1 -0
- package/dist/jwt/index.js +47 -0
- package/dist/jwt/index.js.map +1 -0
- package/dist/jwt/local-jwks-origin.d.ts +3 -0
- package/dist/jwt/local-jwks-origin.d.ts.map +1 -0
- package/dist/jwt/local-jwks-origin.js +6 -0
- package/dist/jwt/local-jwks-origin.js.map +1 -0
- package/dist/keys/attempt.d.ts +19 -0
- package/dist/keys/attempt.d.ts.map +1 -0
- package/dist/keys/attempt.js +26 -0
- package/dist/keys/attempt.js.map +1 -0
- package/dist/keys/device-keys.d.ts +24 -0
- package/dist/keys/device-keys.d.ts.map +1 -0
- package/dist/keys/device-keys.js +40 -0
- package/dist/keys/device-keys.js.map +1 -0
- package/dist/keys/did-key.d.ts +45 -0
- package/dist/keys/did-key.d.ts.map +1 -0
- package/dist/keys/did-key.js +198 -0
- package/dist/keys/did-key.js.map +1 -0
- package/dist/keys/ed25519-strict.d.ts +27 -0
- package/dist/keys/ed25519-strict.d.ts.map +1 -0
- package/dist/keys/ed25519-strict.js +147 -0
- package/dist/keys/ed25519-strict.js.map +1 -0
- package/dist/keys/envelope-versions.d.ts +8 -0
- package/dist/keys/envelope-versions.d.ts.map +1 -0
- package/dist/keys/envelope-versions.js +8 -0
- package/dist/keys/envelope-versions.js.map +1 -0
- package/dist/keys/errors.d.ts +56 -0
- package/dist/keys/errors.d.ts.map +1 -0
- package/dist/keys/errors.js +88 -0
- package/dist/keys/errors.js.map +1 -0
- package/dist/keys/index.d.ts +13 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +13 -0
- package/dist/keys/index.js.map +1 -0
- package/dist/keys/jws.d.ts +25 -0
- package/dist/keys/jws.d.ts.map +1 -0
- package/dist/keys/jws.js +102 -0
- package/dist/keys/jws.js.map +1 -0
- package/dist/keys/key-envelope.d.ts +85 -0
- package/dist/keys/key-envelope.d.ts.map +1 -0
- package/dist/keys/key-envelope.js +189 -0
- package/dist/keys/key-envelope.js.map +1 -0
- package/dist/keys/recipient-key-bundle.d.ts +70 -0
- package/dist/keys/recipient-key-bundle.d.ts.map +1 -0
- package/dist/keys/recipient-key-bundle.js +143 -0
- package/dist/keys/recipient-key-bundle.js.map +1 -0
- package/dist/keys/replay-guard.d.ts +39 -0
- package/dist/keys/replay-guard.d.ts.map +1 -0
- package/dist/keys/replay-guard.js +15 -0
- package/dist/keys/replay-guard.js.map +1 -0
- package/dist/providers/builtin/index.d.ts +7 -0
- package/dist/providers/builtin/index.d.ts.map +1 -0
- package/dist/providers/builtin/index.js +7 -0
- package/dist/providers/builtin/index.js.map +1 -0
- package/dist/providers/builtin/known-providers.d.ts +239 -0
- package/dist/providers/builtin/known-providers.d.ts.map +1 -0
- package/dist/providers/builtin/known-providers.js +243 -0
- package/dist/providers/builtin/known-providers.js.map +1 -0
- package/dist/qrcode-wrapper.d.ts +3 -0
- package/dist/qrcode-wrapper.d.ts.map +1 -0
- package/dist/qrcode-wrapper.js +3 -0
- package/dist/qrcode-wrapper.js.map +1 -0
- package/dist/resolvers/auth-provider.resolver.descriptor.d.ts +40 -0
- package/dist/resolvers/auth-provider.resolver.descriptor.d.ts.map +1 -0
- package/dist/resolvers/auth-provider.resolver.descriptor.js +26 -0
- package/dist/resolvers/auth-provider.resolver.descriptor.js.map +1 -0
- package/dist/resolvers/auth-provider.resolver.impl.d.ts +108 -0
- package/dist/resolvers/auth-provider.resolver.impl.d.ts.map +1 -0
- package/dist/resolvers/auth-provider.resolver.impl.js +123 -0
- package/dist/resolvers/auth-provider.resolver.impl.js.map +1 -0
- package/dist/runtime/auth.browser.plugin.d.ts +3 -0
- package/dist/runtime/auth.browser.plugin.d.ts.map +1 -0
- package/dist/runtime/auth.browser.plugin.js +19 -0
- package/dist/runtime/auth.browser.plugin.js.map +1 -0
- package/dist/runtime/auth.config.descriptor.d.ts +22 -0
- package/dist/runtime/auth.config.descriptor.d.ts.map +1 -0
- package/dist/runtime/auth.config.descriptor.js +83 -0
- package/dist/runtime/auth.config.descriptor.js.map +1 -0
- package/dist/runtime/auth.consumer.plugin.d.ts +3 -0
- package/dist/runtime/auth.consumer.plugin.d.ts.map +1 -0
- package/dist/runtime/auth.consumer.plugin.js +42 -0
- package/dist/runtime/auth.consumer.plugin.js.map +1 -0
- package/dist/runtime/auth.context.descriptor.d.ts +38 -0
- package/dist/runtime/auth.context.descriptor.d.ts.map +1 -0
- package/dist/runtime/auth.context.descriptor.js +12 -0
- package/dist/runtime/auth.context.descriptor.js.map +1 -0
- package/dist/runtime/auth.context.impl.d.ts +10 -0
- package/dist/runtime/auth.context.impl.d.ts.map +1 -0
- package/dist/runtime/auth.context.impl.js +11 -0
- package/dist/runtime/auth.context.impl.js.map +1 -0
- package/dist/runtime/auth.identity.descriptor.d.ts +30 -0
- package/dist/runtime/auth.identity.descriptor.d.ts.map +1 -0
- package/dist/runtime/auth.identity.descriptor.js +20 -0
- package/dist/runtime/auth.identity.descriptor.js.map +1 -0
- package/dist/runtime/auth.identity.impl.d.ts +16 -0
- package/dist/runtime/auth.identity.impl.d.ts.map +1 -0
- package/dist/runtime/auth.identity.impl.js +111 -0
- package/dist/runtime/auth.identity.impl.js.map +1 -0
- package/dist/runtime/auth.plugin.d.ts +3 -0
- package/dist/runtime/auth.plugin.d.ts.map +1 -0
- package/dist/runtime/auth.plugin.js +58 -0
- package/dist/runtime/auth.plugin.js.map +1 -0
- package/dist/runtime/auto-verify.config.descriptor.d.ts +18 -0
- package/dist/runtime/auto-verify.config.descriptor.d.ts.map +1 -0
- package/dist/runtime/auto-verify.config.descriptor.js +79 -0
- package/dist/runtime/auto-verify.config.descriptor.js.map +1 -0
- package/dist/runtime/consumer-auth.context.descriptor.d.ts +30 -0
- package/dist/runtime/consumer-auth.context.descriptor.d.ts.map +1 -0
- package/dist/runtime/consumer-auth.context.descriptor.js +6 -0
- package/dist/runtime/consumer-auth.context.descriptor.js.map +1 -0
- package/dist/runtime/consumer-auth.impl.consumer.d.ts +7 -0
- package/dist/runtime/consumer-auth.impl.consumer.d.ts.map +1 -0
- package/dist/runtime/consumer-auth.impl.consumer.js +51 -0
- package/dist/runtime/consumer-auth.impl.consumer.js.map +1 -0
- package/dist/runtime/kinds/account-linking.kind.d.ts +28 -0
- package/dist/runtime/kinds/account-linking.kind.d.ts.map +1 -0
- package/dist/runtime/kinds/account-linking.kind.js +12 -0
- package/dist/runtime/kinds/account-linking.kind.js.map +1 -0
- package/dist/runtime/kinds/index.d.ts +9 -0
- package/dist/runtime/kinds/index.d.ts.map +1 -0
- package/dist/runtime/kinds/index.js +8 -0
- package/dist/runtime/kinds/index.js.map +1 -0
- package/dist/runtime/kinds/provider.api.impl.consumer.d.ts +7 -0
- package/dist/runtime/kinds/provider.api.impl.consumer.d.ts.map +1 -0
- package/dist/runtime/kinds/provider.api.impl.consumer.js +37 -0
- package/dist/runtime/kinds/provider.api.impl.consumer.js.map +1 -0
- package/dist/runtime/kinds/provider.default.api.d.ts +4 -0
- package/dist/runtime/kinds/provider.default.api.d.ts.map +1 -0
- package/dist/runtime/kinds/provider.default.api.js +56 -0
- package/dist/runtime/kinds/provider.default.api.js.map +1 -0
- package/dist/runtime/kinds/provider.default.config.d.ts +17 -0
- package/dist/runtime/kinds/provider.default.config.d.ts.map +1 -0
- package/dist/runtime/kinds/provider.default.config.js +103 -0
- package/dist/runtime/kinds/provider.default.config.js.map +1 -0
- package/dist/runtime/kinds/provider.default.d.ts +30 -0
- package/dist/runtime/kinds/provider.default.d.ts.map +1 -0
- package/dist/runtime/kinds/provider.default.js +76 -0
- package/dist/runtime/kinds/provider.default.js.map +1 -0
- package/dist/runtime/kinds/provider.kind.d.ts +20 -0
- package/dist/runtime/kinds/provider.kind.d.ts.map +1 -0
- package/dist/runtime/kinds/provider.kind.js +96 -0
- package/dist/runtime/kinds/provider.kind.js.map +1 -0
- package/dist/runtime/logging/auth.logger.descriptor.d.ts +9 -0
- package/dist/runtime/logging/auth.logger.descriptor.d.ts.map +1 -0
- package/dist/runtime/logging/auth.logger.descriptor.js +18 -0
- package/dist/runtime/logging/auth.logger.descriptor.js.map +1 -0
- package/dist/runtime/logging/auth.output.descriptor.d.ts +7 -0
- package/dist/runtime/logging/auth.output.descriptor.d.ts.map +1 -0
- package/dist/runtime/logging/auth.output.descriptor.js +17 -0
- package/dist/runtime/logging/auth.output.descriptor.js.map +1 -0
- package/dist/runtime/plugin/account-linking.d.ts +3 -0
- package/dist/runtime/plugin/account-linking.d.ts.map +1 -0
- package/dist/runtime/plugin/account-linking.js +30 -0
- package/dist/runtime/plugin/account-linking.js.map +1 -0
- package/dist/runtime/plugin/api-client.d.ts +19 -0
- package/dist/runtime/plugin/api-client.d.ts.map +1 -0
- package/dist/runtime/plugin/api-client.js +59 -0
- package/dist/runtime/plugin/api-client.js.map +1 -0
- package/dist/runtime/plugin/core.provider.d.ts +3 -0
- package/dist/runtime/plugin/core.provider.d.ts.map +1 -0
- package/dist/runtime/plugin/core.provider.js +38 -0
- package/dist/runtime/plugin/core.provider.js.map +1 -0
- package/dist/runtime/plugin/identity.d.ts +3 -0
- package/dist/runtime/plugin/identity.d.ts.map +1 -0
- package/dist/runtime/plugin/identity.js +14 -0
- package/dist/runtime/plugin/identity.js.map +1 -0
- package/dist/runtime/plugin/index.d.ts +5 -0
- package/dist/runtime/plugin/index.d.ts.map +1 -0
- package/dist/runtime/plugin/index.js +5 -0
- package/dist/runtime/plugin/index.js.map +1 -0
- package/dist/runtime/plugin/support.d.ts +3 -0
- package/dist/runtime/plugin/support.d.ts.map +1 -0
- package/dist/runtime/plugin/support.js +10 -0
- package/dist/runtime/plugin/support.js.map +1 -0
- package/dist/runtime/providers/auth-provider.api.descriptor.d.ts +10 -0
- package/dist/runtime/providers/auth-provider.api.descriptor.d.ts.map +1 -0
- package/dist/runtime/providers/auth-provider.api.descriptor.js +24 -0
- package/dist/runtime/providers/auth-provider.api.descriptor.js.map +1 -0
- package/dist/runtime/providers/db.descriptor.d.ts +11 -0
- package/dist/runtime/providers/db.descriptor.d.ts.map +1 -0
- package/dist/runtime/providers/db.descriptor.js +26 -0
- package/dist/runtime/providers/db.descriptor.js.map +1 -0
- package/dist/schemas/account-linking.d.ts +82 -0
- package/dist/schemas/account-linking.d.ts.map +1 -0
- package/dist/schemas/account-linking.js +49 -0
- package/dist/schemas/account-linking.js.map +1 -0
- package/dist/schemas/admin/index.d.ts +253 -0
- package/dist/schemas/admin/index.d.ts.map +1 -0
- package/dist/schemas/admin/index.js +2 -0
- package/dist/schemas/admin/index.js.map +1 -0
- package/dist/schemas/admin/responses.d.ts +298 -0
- package/dist/schemas/admin/responses.d.ts.map +1 -0
- package/dist/schemas/admin/responses.js +189 -0
- package/dist/schemas/admin/responses.js.map +1 -0
- package/dist/schemas/agents.d.ts +337 -0
- package/dist/schemas/agents.d.ts.map +1 -0
- package/dist/schemas/agents.js +164 -0
- package/dist/schemas/agents.js.map +1 -0
- package/dist/schemas/api/api-keys.d.ts +74 -0
- package/dist/schemas/api/api-keys.d.ts.map +1 -0
- package/dist/schemas/api/api-keys.js +70 -0
- package/dist/schemas/api/api-keys.js.map +1 -0
- package/dist/schemas/api/client.d.ts +220 -0
- package/dist/schemas/api/client.d.ts.map +1 -0
- package/dist/schemas/api/client.js +95 -0
- package/dist/schemas/api/client.js.map +1 -0
- package/dist/schemas/api/provider.d.ts +85 -0
- package/dist/schemas/api/provider.d.ts.map +1 -0
- package/dist/schemas/api/provider.js +42 -0
- package/dist/schemas/api/provider.js.map +1 -0
- package/dist/schemas/app-credentials.d.ts +44 -0
- package/dist/schemas/app-credentials.d.ts.map +1 -0
- package/dist/schemas/app-credentials.js +36 -0
- package/dist/schemas/app-credentials.js.map +1 -0
- package/dist/schemas/app-jwt.d.ts +112 -0
- package/dist/schemas/app-jwt.d.ts.map +1 -0
- package/dist/schemas/app-jwt.js +14 -0
- package/dist/schemas/app-jwt.js.map +1 -0
- package/dist/schemas/auth/better-auth.d.ts +11 -0
- package/dist/schemas/auth/better-auth.d.ts.map +1 -0
- package/dist/schemas/auth/better-auth.js +2 -0
- package/dist/schemas/auth/better-auth.js.map +1 -0
- package/dist/schemas/auth/capabilities.d.ts +42 -0
- package/dist/schemas/auth/capabilities.d.ts.map +1 -0
- package/dist/schemas/auth/capabilities.js +16 -0
- package/dist/schemas/auth/capabilities.js.map +1 -0
- package/dist/schemas/auth/common.d.ts +158 -0
- package/dist/schemas/auth/common.d.ts.map +1 -0
- package/dist/schemas/auth/common.js +118 -0
- package/dist/schemas/auth/common.js.map +1 -0
- package/dist/schemas/auth/services.d.ts +23 -0
- package/dist/schemas/auth/services.d.ts.map +1 -0
- package/dist/schemas/auth/services.js +2 -0
- package/dist/schemas/auth/services.js.map +1 -0
- package/dist/schemas/auth/stores.d.ts +128 -0
- package/dist/schemas/auth/stores.d.ts.map +1 -0
- package/dist/schemas/auth/stores.js +73 -0
- package/dist/schemas/auth/stores.js.map +1 -0
- package/dist/schemas/auth/types.d.ts +3 -0
- package/dist/schemas/auth/types.d.ts.map +1 -0
- package/dist/schemas/auth/types.js +5 -0
- package/dist/schemas/auth/types.js.map +1 -0
- package/dist/schemas/auth/ui.d.ts +168 -0
- package/dist/schemas/auth/ui.d.ts.map +1 -0
- package/dist/schemas/auth/ui.js +112 -0
- package/dist/schemas/auth/ui.js.map +1 -0
- package/dist/schemas/auth-provider.d.ts +170 -0
- package/dist/schemas/auth-provider.d.ts.map +1 -0
- package/dist/schemas/auth-provider.js +137 -0
- package/dist/schemas/auth-provider.js.map +1 -0
- package/dist/schemas/authority-state.d.ts +42 -0
- package/dist/schemas/authority-state.d.ts.map +1 -0
- package/dist/schemas/authority-state.js +15 -0
- package/dist/schemas/authority-state.js.map +1 -0
- package/dist/schemas/browser-session-code.d.ts +49 -0
- package/dist/schemas/browser-session-code.d.ts.map +1 -0
- package/dist/schemas/browser-session-code.js +49 -0
- package/dist/schemas/browser-session-code.js.map +1 -0
- package/dist/schemas/consumer-auth.d.ts +95 -0
- package/dist/schemas/consumer-auth.d.ts.map +1 -0
- package/dist/schemas/consumer-auth.js +46 -0
- package/dist/schemas/consumer-auth.js.map +1 -0
- package/dist/schemas/credentials.d.ts +172 -0
- package/dist/schemas/credentials.d.ts.map +1 -0
- package/dist/schemas/credentials.js +105 -0
- package/dist/schemas/credentials.js.map +1 -0
- package/dist/schemas/flows/forms.d.ts +91 -0
- package/dist/schemas/flows/forms.d.ts.map +1 -0
- package/dist/schemas/flows/forms.js +133 -0
- package/dist/schemas/flows/forms.js.map +1 -0
- package/dist/schemas/flows/phone.d.ts +84 -0
- package/dist/schemas/flows/phone.d.ts.map +1 -0
- package/dist/schemas/flows/phone.js +90 -0
- package/dist/schemas/flows/phone.js.map +1 -0
- package/dist/schemas/identity.d.ts +14 -0
- package/dist/schemas/identity.d.ts.map +1 -0
- package/dist/schemas/identity.js +13 -0
- package/dist/schemas/identity.js.map +1 -0
- package/dist/schemas/index.d.ts +27 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +14 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/mobile-auth.d.ts +58 -0
- package/dist/schemas/mobile-auth.d.ts.map +1 -0
- package/dist/schemas/mobile-auth.js +25 -0
- package/dist/schemas/mobile-auth.js.map +1 -0
- package/dist/schemas/mobile.config.descriptor.d.ts +10 -0
- package/dist/schemas/mobile.config.descriptor.d.ts.map +1 -0
- package/dist/schemas/mobile.config.descriptor.js +61 -0
- package/dist/schemas/mobile.config.descriptor.js.map +1 -0
- package/dist/schemas/provider.d.ts +3 -0
- package/dist/schemas/provider.d.ts.map +1 -0
- package/dist/schemas/provider.js +2 -0
- package/dist/schemas/provider.js.map +1 -0
- package/dist/schemas/registered-app.d.ts +86 -0
- package/dist/schemas/registered-app.d.ts.map +1 -0
- package/dist/schemas/registered-app.js +68 -0
- package/dist/schemas/registered-app.js.map +1 -0
- package/dist/schemas/session-verification.d.ts +87 -0
- package/dist/schemas/session-verification.d.ts.map +1 -0
- package/dist/schemas/session-verification.js +49 -0
- package/dist/schemas/session-verification.js.map +1 -0
- package/dist/schemas/tui-actions.d.ts +17 -0
- package/dist/schemas/tui-actions.d.ts.map +1 -0
- package/dist/schemas/tui-actions.js +7 -0
- package/dist/schemas/tui-actions.js.map +1 -0
- package/dist/schemas/types.d.ts +3 -0
- package/dist/schemas/types.d.ts.map +1 -0
- package/dist/schemas/types.js +2 -0
- package/dist/schemas/types.js.map +1 -0
- package/dist/schemas/ui.d.ts +5 -0
- package/dist/schemas/ui.d.ts.map +1 -0
- package/dist/schemas/ui.js +3 -0
- package/dist/schemas/ui.js.map +1 -0
- package/dist/server/auth-service-binding.d.ts +11 -0
- package/dist/server/auth-service-binding.d.ts.map +1 -0
- package/dist/server/auth-service-binding.js +8 -0
- package/dist/server/auth-service-binding.js.map +1 -0
- package/dist/server/bound-session-verifier.descriptor.d.ts +7 -0
- package/dist/server/bound-session-verifier.descriptor.d.ts.map +1 -0
- package/dist/server/bound-session-verifier.descriptor.js +5 -0
- package/dist/server/bound-session-verifier.descriptor.js.map +1 -0
- package/dist/server/bound-session-verifier.impl.d.ts +7 -0
- package/dist/server/bound-session-verifier.impl.d.ts.map +1 -0
- package/dist/server/bound-session-verifier.impl.js +11 -0
- package/dist/server/bound-session-verifier.impl.js.map +1 -0
- package/dist/server/browser-session-code-handoff.d.ts +33 -0
- package/dist/server/browser-session-code-handoff.d.ts.map +1 -0
- package/dist/server/browser-session-code-handoff.js +87 -0
- package/dist/server/browser-session-code-handoff.js.map +1 -0
- package/dist/server/consumer-session-user.d.ts +11 -0
- package/dist/server/consumer-session-user.d.ts.map +1 -0
- package/dist/server/consumer-session-user.js +23 -0
- package/dist/server/consumer-session-user.js.map +1 -0
- package/dist/server/cookie-domain.d.ts +8 -0
- package/dist/server/cookie-domain.d.ts.map +1 -0
- package/dist/server/cookie-domain.js +25 -0
- package/dist/server/cookie-domain.js.map +1 -0
- package/dist/server/issuer-session-verifier.impl.d.ts +23 -0
- package/dist/server/issuer-session-verifier.impl.d.ts.map +1 -0
- package/dist/server/issuer-session-verifier.impl.js +38 -0
- package/dist/server/issuer-session-verifier.impl.js.map +1 -0
- package/dist/server/issuer-session-verifier.plugin.d.ts +3 -0
- package/dist/server/issuer-session-verifier.plugin.d.ts.map +1 -0
- package/dist/server/issuer-session-verifier.plugin.js +8 -0
- package/dist/server/issuer-session-verifier.plugin.js.map +1 -0
- package/dist/server/jwks-response-cache.d.ts +50 -0
- package/dist/server/jwks-response-cache.d.ts.map +1 -0
- package/dist/server/jwks-response-cache.js +207 -0
- package/dist/server/jwks-response-cache.js.map +1 -0
- package/dist/server/jwt-session-handle.d.ts +113 -0
- package/dist/server/jwt-session-handle.d.ts.map +1 -0
- package/dist/server/jwt-session-handle.js +1184 -0
- package/dist/server/jwt-session-handle.js.map +1 -0
- package/dist/server/registered-origin-resolver.d.ts +25 -0
- package/dist/server/registered-origin-resolver.d.ts.map +1 -0
- package/dist/server/registered-origin-resolver.js +30 -0
- package/dist/server/registered-origin-resolver.js.map +1 -0
- package/dist/server/schemas/admin-directory.d.ts +62 -0
- package/dist/server/schemas/admin-directory.d.ts.map +1 -0
- package/dist/server/schemas/admin-directory.js +2 -0
- package/dist/server/schemas/admin-directory.js.map +1 -0
- package/dist/server/schemas/index.d.ts +151 -0
- package/dist/server/schemas/index.d.ts.map +1 -0
- package/dist/server/schemas/index.js +71 -0
- package/dist/server/schemas/index.js.map +1 -0
- package/dist/server/schemas/session.d.ts +22 -0
- package/dist/server/schemas/session.d.ts.map +1 -0
- package/dist/server/schemas/session.js +2 -0
- package/dist/server/schemas/session.js.map +1 -0
- package/dist/server/services/account-linking.service.d.ts +43 -0
- package/dist/server/services/account-linking.service.d.ts.map +1 -0
- package/dist/server/services/account-linking.service.descriptor.d.ts +8 -0
- package/dist/server/services/account-linking.service.descriptor.d.ts.map +1 -0
- package/dist/server/services/account-linking.service.descriptor.js +9 -0
- package/dist/server/services/account-linking.service.descriptor.js.map +1 -0
- package/dist/server/services/account-linking.service.js +178 -0
- package/dist/server/services/account-linking.service.js.map +1 -0
- package/dist/server/session-revocation.d.ts +70 -0
- package/dist/server/session-revocation.d.ts.map +1 -0
- package/dist/server/session-revocation.js +112 -0
- package/dist/server/session-revocation.js.map +1 -0
- package/dist/server/session-verifier.d.ts +69 -0
- package/dist/server/session-verifier.d.ts.map +1 -0
- package/dist/server/session-verifier.js +15 -0
- package/dist/server/session-verifier.js.map +1 -0
- package/dist/storage/auth-accounts.storage.descriptor.d.ts +74 -0
- package/dist/storage/auth-accounts.storage.descriptor.d.ts.map +1 -0
- package/dist/storage/auth-accounts.storage.descriptor.js +46 -0
- package/dist/storage/auth-accounts.storage.descriptor.js.map +1 -0
- package/dist/storage/auth-accounts.storage.manifest.impl.d.ts +18 -0
- package/dist/storage/auth-accounts.storage.manifest.impl.d.ts.map +1 -0
- package/dist/storage/auth-accounts.storage.manifest.impl.js +69 -0
- package/dist/storage/auth-accounts.storage.manifest.impl.js.map +1 -0
- package/dist/svelte/augmentations/users.impl.browser.d.ts +10 -0
- package/dist/svelte/augmentations/users.impl.browser.d.ts.map +1 -0
- package/dist/svelte/augmentations/users.impl.browser.js +74 -0
- package/dist/svelte/auth-method.d.ts +22 -0
- package/dist/svelte/auth-method.d.ts.map +1 -0
- package/dist/svelte/auth-method.js +24 -0
- package/dist/svelte/auth-svelte.plugin.d.ts +3 -0
- package/dist/svelte/auth-svelte.plugin.d.ts.map +1 -0
- package/dist/svelte/auth-svelte.plugin.js +11 -0
- package/dist/svelte/auth-variants.d.ts +56 -0
- package/dist/svelte/auth-variants.d.ts.map +1 -0
- package/dist/svelte/auth-variants.js +35 -0
- package/dist/svelte/browser-window.d.ts +7 -0
- package/dist/svelte/browser-window.d.ts.map +1 -0
- package/dist/svelte/browser-window.js +8 -0
- package/dist/svelte/component-logging.d.ts +6 -0
- package/dist/svelte/component-logging.d.ts.map +1 -0
- package/dist/svelte/component-logging.js +16 -0
- package/dist/svelte/components/AuthConnectedAccountsPanel.svelte +326 -0
- package/dist/svelte/components/AuthConnectedAccountsPanel.svelte.d.ts +19 -0
- package/dist/svelte/components/AuthConnectedAccountsPanel.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AuthSessionsPanel.svelte +302 -0
- package/dist/svelte/components/AuthSessionsPanel.svelte.d.ts +31 -0
- package/dist/svelte/components/AuthSessionsPanel.svelte.d.ts.map +1 -0
- package/dist/svelte/components/BrowserSessionBridge.svelte +24 -0
- package/dist/svelte/components/BrowserSessionBridge.svelte.d.ts +15 -0
- package/dist/svelte/components/BrowserSessionBridge.svelte.d.ts.map +1 -0
- package/dist/svelte/components/DeviceAuthorizationPanel.svelte +374 -0
- package/dist/svelte/components/DeviceAuthorizationPanel.svelte.d.ts +20 -0
- package/dist/svelte/components/DeviceAuthorizationPanel.svelte.d.ts.map +1 -0
- package/dist/svelte/components/OAuthMethodPicker.svelte +132 -0
- package/dist/svelte/components/OAuthMethodPicker.svelte.d.ts +24 -0
- package/dist/svelte/components/OAuthMethodPicker.svelte.d.ts.map +1 -0
- package/dist/svelte/components/PasswordStrengthMeter.svelte +38 -0
- package/dist/svelte/components/PasswordStrengthMeter.svelte.d.ts +15 -0
- package/dist/svelte/components/PasswordStrengthMeter.svelte.d.ts.map +1 -0
- package/dist/svelte/components/RequireAuth.svelte +59 -0
- package/dist/svelte/components/RequireAuth.svelte.d.ts +24 -0
- package/dist/svelte/components/RequireAuth.svelte.d.ts.map +1 -0
- package/dist/svelte/components/SessionTimer.svelte +116 -0
- package/dist/svelte/components/SessionTimer.svelte.d.ts +36 -0
- package/dist/svelte/components/SessionTimer.svelte.d.ts.map +1 -0
- package/dist/svelte/components/SessionWatcher.svelte +70 -0
- package/dist/svelte/components/SessionWatcher.svelte.d.ts +19 -0
- package/dist/svelte/components/SessionWatcher.svelte.d.ts.map +1 -0
- package/dist/svelte/components/SignInForm.svelte +357 -0
- package/dist/svelte/components/SignInForm.svelte.d.ts +55 -0
- package/dist/svelte/components/SignInForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/SignInHub.svelte +103 -0
- package/dist/svelte/components/SignInHub.svelte.d.ts +38 -0
- package/dist/svelte/components/SignInHub.svelte.d.ts.map +1 -0
- package/dist/svelte/components/SignOutButton.svelte +83 -0
- package/dist/svelte/components/SignOutButton.svelte.d.ts +23 -0
- package/dist/svelte/components/SignOutButton.svelte.d.ts.map +1 -0
- package/dist/svelte/components/SignUpForm.svelte +437 -0
- package/dist/svelte/components/SignUpForm.svelte.d.ts +39 -0
- package/dist/svelte/components/SignUpForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/mfa-setup/CompleteStep.svelte +23 -0
- package/dist/svelte/components/mfa-setup/CompleteStep.svelte.d.ts +5 -0
- package/dist/svelte/components/mfa-setup/CompleteStep.svelte.d.ts.map +1 -0
- package/dist/svelte/components/mfa-setup/PasswordStep.svelte +60 -0
- package/dist/svelte/components/mfa-setup/PasswordStep.svelte.d.ts +5 -0
- package/dist/svelte/components/mfa-setup/PasswordStep.svelte.d.ts.map +1 -0
- package/dist/svelte/components/mfa-setup/QrCodeStep.svelte +56 -0
- package/dist/svelte/components/mfa-setup/QrCodeStep.svelte.d.ts +5 -0
- package/dist/svelte/components/mfa-setup/QrCodeStep.svelte.d.ts.map +1 -0
- package/dist/svelte/components/mfa-setup/RecoveryCodesStep.svelte +42 -0
- package/dist/svelte/components/mfa-setup/RecoveryCodesStep.svelte.d.ts +5 -0
- package/dist/svelte/components/mfa-setup/RecoveryCodesStep.svelte.d.ts.map +1 -0
- package/dist/svelte/components/mfa-setup/VerifyStep.svelte +68 -0
- package/dist/svelte/components/mfa-setup/VerifyStep.svelte.d.ts +5 -0
- package/dist/svelte/components/mfa-setup/VerifyStep.svelte.d.ts.map +1 -0
- package/dist/svelte/components/mfa-setup/schemas/index.d.ts +35 -0
- package/dist/svelte/components/mfa-setup/schemas/index.d.ts.map +1 -0
- package/dist/svelte/components/mfa-setup/schemas/index.js +1 -0
- package/dist/svelte/components/phone-auth/OtpCodeFields.svelte +119 -0
- package/dist/svelte/components/phone-auth/OtpCodeFields.svelte.d.ts +5 -0
- package/dist/svelte/components/phone-auth/OtpCodeFields.svelte.d.ts.map +1 -0
- package/dist/svelte/components/phone-auth/OtpInput.svelte +192 -0
- package/dist/svelte/components/phone-auth/OtpInput.svelte.d.ts +5 -0
- package/dist/svelte/components/phone-auth/OtpInput.svelte.d.ts.map +1 -0
- package/dist/svelte/components/phone-auth/PhoneAuthFlow.svelte +151 -0
- package/dist/svelte/components/phone-auth/PhoneAuthFlow.svelte.d.ts +5 -0
- package/dist/svelte/components/phone-auth/PhoneAuthFlow.svelte.d.ts.map +1 -0
- package/dist/svelte/components/phone-auth/PhoneInput.svelte +141 -0
- package/dist/svelte/components/phone-auth/PhoneInput.svelte.d.ts +5 -0
- package/dist/svelte/components/phone-auth/PhoneInput.svelte.d.ts.map +1 -0
- package/dist/svelte/components/phone-auth/PhoneMagicLinkFlow.svelte +171 -0
- package/dist/svelte/components/phone-auth/PhoneMagicLinkFlow.svelte.d.ts +5 -0
- package/dist/svelte/components/phone-auth/PhoneMagicLinkFlow.svelte.d.ts.map +1 -0
- package/dist/svelte/components/phone-auth/schemas/index.d.ts +60 -0
- package/dist/svelte/components/phone-auth/schemas/index.d.ts.map +1 -0
- package/dist/svelte/components/phone-auth/schemas/index.js +1 -0
- package/dist/svelte/index.d.ts +79 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +71 -0
- package/dist/svelte/loaders.d.ts +63 -0
- package/dist/svelte/loaders.d.ts.map +1 -0
- package/dist/svelte/loaders.js +59 -0
- package/dist/svelte/navigation-effect.d.ts +7 -0
- package/dist/svelte/navigation-effect.d.ts.map +1 -0
- package/dist/svelte/navigation-effect.js +16 -0
- package/dist/svelte/outcome.d.ts +24 -0
- package/dist/svelte/outcome.d.ts.map +1 -0
- package/dist/svelte/outcome.js +38 -0
- package/dist/svelte/password.d.ts +40 -0
- package/dist/svelte/password.d.ts.map +1 -0
- package/dist/svelte/password.js +66 -0
- package/dist/svelte/session-warmup.d.ts +6 -0
- package/dist/svelte/session-warmup.d.ts.map +1 -0
- package/dist/svelte/session-warmup.js +12 -0
- package/dist/svelte/sessions.d.ts +18 -0
- package/dist/svelte/sessions.d.ts.map +1 -0
- package/dist/svelte/sessions.js +56 -0
- package/dist/svelte/state.svelte.d.ts +20 -0
- package/dist/svelte/state.svelte.d.ts.map +1 -0
- package/dist/svelte/state.svelte.js +45 -0
- package/dist/svelte/styles.css +10 -0
- package/dist/svelte/types.d.ts +37 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +9 -0
- package/dist/system/index.d.ts +2 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/index.js +4 -0
- package/dist/system/index.js.map +1 -0
- package/dist/system/internal-api/client.d.ts +34 -0
- package/dist/system/internal-api/client.d.ts.map +1 -0
- package/dist/system/internal-api/client.js +117 -0
- package/dist/system/internal-api/client.js.map +1 -0
- package/dist/system/internal-api/endpoints.d.ts +15 -0
- package/dist/system/internal-api/endpoints.d.ts.map +1 -0
- package/dist/system/internal-api/endpoints.js +15 -0
- package/dist/system/internal-api/endpoints.js.map +1 -0
- package/dist/system/internal-api/index.d.ts +5 -0
- package/dist/system/internal-api/index.d.ts.map +1 -0
- package/dist/system/internal-api/index.js +4 -0
- package/dist/system/internal-api/index.js.map +1 -0
- package/dist/system/internal-api/schemas.d.ts +188 -0
- package/dist/system/internal-api/schemas.d.ts.map +1 -0
- package/dist/system/internal-api/schemas.js +123 -0
- package/dist/system/internal-api/schemas.js.map +1 -0
- package/dist/system/require-admin.d.ts +25 -0
- package/dist/system/require-admin.d.ts.map +1 -0
- package/dist/system/require-admin.js +184 -0
- package/dist/system/require-admin.js.map +1 -0
- package/dist/system/session-handle.d.ts +15 -0
- package/dist/system/session-handle.d.ts.map +1 -0
- package/dist/system/session-handle.js +104 -0
- package/dist/system/session-handle.js.map +1 -0
- package/dist/system/sign-out-handoff.d.ts +88 -0
- package/dist/system/sign-out-handoff.d.ts.map +1 -0
- package/dist/system/sign-out-handoff.js +136 -0
- package/dist/system/sign-out-handoff.js.map +1 -0
- package/dist/tui/auth-actions.client.consumer.d.ts +11 -0
- package/dist/tui/auth-actions.client.consumer.d.ts.map +1 -0
- package/dist/tui/auth-actions.client.consumer.js +19 -0
- package/dist/tui/auth-actions.client.consumer.js.map +1 -0
- package/dist/tui/auth-tui.plugin.d.ts +3 -0
- package/dist/tui/auth-tui.plugin.d.ts.map +1 -0
- package/dist/tui/auth-tui.plugin.js +25 -0
- package/dist/tui/auth-tui.plugin.js.map +1 -0
- package/dist/tui/auth.tui-app.descriptor.d.ts +4 -0
- package/dist/tui/auth.tui-app.descriptor.d.ts.map +1 -0
- package/dist/tui/auth.tui-app.descriptor.js +19 -0
- package/dist/tui/auth.tui-app.descriptor.js.map +1 -0
- package/dist/tui/auth.tui-app.impl.consumer.d.ts +4 -0
- package/dist/tui/auth.tui-app.impl.consumer.d.ts.map +1 -0
- package/dist/tui/auth.tui-app.impl.consumer.js +46 -0
- package/dist/tui/auth.tui-app.impl.consumer.js.map +1 -0
- package/dist/tui/auth.tui-state.descriptor.d.ts +7 -0
- package/dist/tui/auth.tui-state.descriptor.d.ts.map +1 -0
- package/dist/tui/auth.tui-state.descriptor.js +21 -0
- package/dist/tui/auth.tui-state.descriptor.js.map +1 -0
- package/dist/tui/auth.tui-state.impl.consumer.d.ts +5 -0
- package/dist/tui/auth.tui-state.impl.consumer.d.ts.map +1 -0
- package/dist/tui/auth.tui-state.impl.consumer.js +122 -0
- package/dist/tui/auth.tui-state.impl.consumer.js.map +1 -0
- package/dist/tui/auth.tui-state.key.d.ts +27 -0
- package/dist/tui/auth.tui-state.key.d.ts.map +1 -0
- package/dist/tui/auth.tui-state.key.js +18 -0
- package/dist/tui/auth.tui-state.key.js.map +1 -0
- package/dist/tui/index.d.ts +2 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +2 -0
- package/dist/tui/index.js.map +1 -0
- package/package.json +916 -4
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import { getVibesClient, tryGetVibesClient } from '@vibesdotdev/kernel/client';
|
|
2
|
+
import { delegatedActorVerificationOptionsSchema, orgClaimSchema, delegatedActorVerificationSchema } from "../schemas/session-verification.js";
|
|
3
|
+
export { delegatedActorClaimsSchema, delegatedActorVerificationSchema, delegatedActorVerificationSchema as DelegatedActorVerificationSchema } from "../schemas/session-verification.js";
|
|
4
|
+
export { SessionJwtVerificationSchema } from "./session-verifier.js";
|
|
5
|
+
import * as z from 'zod/v4';
|
|
6
|
+
import { errors, createLocalJWKSet, jwtVerify } from 'jose';
|
|
7
|
+
import { getLogger } from '@vibesdotdev/logging';
|
|
8
|
+
import { CapabilityError, readPluginConfig, valueFreeFailure } from '@vibesdotdev/kernel';
|
|
9
|
+
import { attempt, attemptSync, failureLabel, rethrowFailure } from "../features/utils/attempt.js";
|
|
10
|
+
import { VIBES_LOCAL_AUTH_ORIGIN } from "../config/local-auth-origin.js";
|
|
11
|
+
import { ApiKeyValidationResponseSchema } from "../schemas/api/api-keys.js";
|
|
12
|
+
import { authenticatedAgentPrincipalSchema } from "../schemas/agents.js";
|
|
13
|
+
import { readJsonOrNull } from "../client/read-json-or-null.js";
|
|
14
|
+
import { SessionBlacklistReaderSchema, sessionIdRevocationKey, sessionRevocationKeys } from "./session-revocation.js";
|
|
15
|
+
import { AuthServiceBindingSchema } from "./auth-service-binding.js";
|
|
16
|
+
import { decodeJWTUnsafe } from "../jwt/index.js";
|
|
17
|
+
import { SESSION_VERIFIER_KIND, SESSION_VERIFIER_ID, SessionJwtVerificationSchema } from "./session-verifier.js";
|
|
18
|
+
import { isLocalAuthOrigin, resolveJwksOrigin, resolveLocalAuthOrigin } from "../jwt/local-jwks-origin.js";
|
|
19
|
+
/**
|
|
20
|
+
* A single organization membership as carried by the shared .vibes.dev JWT
|
|
21
|
+
* `orgs` claim. Sourced from auth-web's `definePayload` (the ONE seam) and
|
|
22
|
+
* surfaced on `event.locals.user.orgs` by {@link applyJwtPayload}. Kept to
|
|
23
|
+
* `id` + `role` to keep the token small; `getRepositoryPermission` and other
|
|
24
|
+
* authorization checks read this off locals rather than re-querying account-web.
|
|
25
|
+
*/
|
|
26
|
+
const orgEntrySchema = orgClaimSchema;
|
|
27
|
+
const orgListSchema = z.array(z.unknown());
|
|
28
|
+
/**
|
|
29
|
+
* Coerce the JWT `orgs` claim into a validated `OrgClaim[]`. Tolerates a
|
|
30
|
+
* missing / malformed claim (old tokens predating the claim) by defaulting to
|
|
31
|
+
* `[]`. Only well-formed `{ id: string, role: string }` entries survive.
|
|
32
|
+
*/
|
|
33
|
+
function normalizeOrgClaims(raw) {
|
|
34
|
+
const list = orgListSchema.safeParse(raw);
|
|
35
|
+
if (!list.success)
|
|
36
|
+
return [];
|
|
37
|
+
const orgs = [];
|
|
38
|
+
for (const entry of list.data) {
|
|
39
|
+
const org = orgEntrySchema.safeParse(entry);
|
|
40
|
+
if (!org.success)
|
|
41
|
+
continue;
|
|
42
|
+
const claim = { id: org.data.id, role: org.data.role };
|
|
43
|
+
if (org.data.slug !== undefined && org.data.slug.length > 0)
|
|
44
|
+
claim.slug = org.data.slug;
|
|
45
|
+
orgs.push(claim);
|
|
46
|
+
}
|
|
47
|
+
return orgs;
|
|
48
|
+
}
|
|
49
|
+
/** What the session handle puts on `event.locals`, and what `authRequestPrincipal` reads back. */
|
|
50
|
+
const sessionLocalsSchema = z.looseObject({
|
|
51
|
+
user: z
|
|
52
|
+
.looseObject({
|
|
53
|
+
id: z.string().optional().catch(undefined),
|
|
54
|
+
orgId: z.string().optional().catch(undefined),
|
|
55
|
+
roles: z.array(z.unknown()).optional().catch(undefined),
|
|
56
|
+
orgs: z.unknown().optional(),
|
|
57
|
+
staff: z.unknown().optional(),
|
|
58
|
+
isSuperuser: z.unknown().optional(),
|
|
59
|
+
agentPrincipal: z.unknown().optional()
|
|
60
|
+
})
|
|
61
|
+
.nullish()
|
|
62
|
+
.catch(undefined),
|
|
63
|
+
session: z.looseObject({ id: z.string().optional().catch(undefined) }).nullish().catch(undefined),
|
|
64
|
+
sessionToken: z.string().optional().catch(undefined)
|
|
65
|
+
});
|
|
66
|
+
const REFRESH_SESSION_COOKIE_NAMES = new Set([
|
|
67
|
+
'vibes.session',
|
|
68
|
+
'better-auth.session_token',
|
|
69
|
+
'__Secure-better-auth.session_token',
|
|
70
|
+
'__Host-better-auth.session_token'
|
|
71
|
+
]);
|
|
72
|
+
const JWT_COOKIE_NAME = 'vibes.jwt';
|
|
73
|
+
const JWT_MAX_AGE_SECONDS = 15 * 60;
|
|
74
|
+
// 30s default. Local SvelteKit dev under bun is slow on cold/warm requests
|
|
75
|
+
// (Vite module runner re-evaluation, plugin chain); 5s consistently aborted
|
|
76
|
+
// the JWT refresh fetch in dev even though the request itself succeeded.
|
|
77
|
+
// Override with VIBES_AUTH_SESSION_REFRESH_TIMEOUT_MS when you need a
|
|
78
|
+
// stricter budget (e.g. prod where the auth-web call is sub-100ms).
|
|
79
|
+
const DEFAULT_SESSION_REFRESH_TIMEOUT_MS = 30_000;
|
|
80
|
+
// Bound the server-to-server API-key validation fetch. auth-web's
|
|
81
|
+
// `/api/api-keys/validate` has intermittently hung to Cloudflare's 30s
|
|
82
|
+
// wall-clock limit (a public-URL loopback pathology); with NO timeout that hang
|
|
83
|
+
// propagates up through EVERY consumer's sessionHandle on any request carrying
|
|
84
|
+
// an opaque/API-key Bearer — e.g. it stalled the private-repo billing quota
|
|
85
|
+
// check (an internal-service call) for minutes. 10s is far above the healthy
|
|
86
|
+
// sub-100ms validate yet well under the 30s wall-clock kill, so a degraded
|
|
87
|
+
// auth-web fails the request FAST (caller catches → user-less, non-fatal)
|
|
88
|
+
// instead of hanging. Override with VIBES_AUTH_API_KEY_VALIDATE_TIMEOUT_MS.
|
|
89
|
+
const DEFAULT_API_KEY_VALIDATE_TIMEOUT_MS = 10_000;
|
|
90
|
+
// Bound the JWKS refill fetch, for exactly the reason the api-key validate call
|
|
91
|
+
// is bounded. Consumers that DON'T declare the `AUTH_SERVICE` binding (git-web,
|
|
92
|
+
// registry-web call `createJwtSessionHandle` with the default binding name and
|
|
93
|
+
// declare no such binding in their wrangler.jsonc) fall through to global fetch
|
|
94
|
+
// against the PUBLIC issuer origin — the loopback documented below as hanging to
|
|
95
|
+
// Cloudflare's 30s wall clock. Unbounded, that hang owns the whole request, and
|
|
96
|
+
// the forwarded `Authorization: Bearer <jwt>` path has no refresh-cookie fallback
|
|
97
|
+
// to rescue it. 10s (not jose's old 5s ceiling, which a cold public auth-web blew
|
|
98
|
+
// routinely) is far above a healthy sub-100ms JWKS read yet well under the wall
|
|
99
|
+
// clock, so a degraded issuer fails the verify FAST (caller degrades to user-less)
|
|
100
|
+
// instead of hanging. Override with VIBES_AUTH_JWKS_FETCH_TIMEOUT_MS.
|
|
101
|
+
const DEFAULT_JWKS_FETCH_TIMEOUT_MS = 10_000;
|
|
102
|
+
/** The request's runtime, set by `createSvelteKitRuntime`'s `prepareHandle`. */
|
|
103
|
+
function requireRequestRuntime(locals) {
|
|
104
|
+
const runtime = locals.runtime;
|
|
105
|
+
if (!runtime) {
|
|
106
|
+
throw new CapabilityError('The session handle ran before the runtime prepared this request.', 'INTERNAL', {
|
|
107
|
+
reason: 'environment-not-prepared',
|
|
108
|
+
recoveryHint: 'Sequence createSvelteKitRuntime(...).prepareHandle before the session handle.'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return runtime;
|
|
112
|
+
}
|
|
113
|
+
/** A blacklist that is not bound is a deployment fault, not a failed login: it is never swallowed into "no session". */
|
|
114
|
+
function rethrowIfBlacklistUnavailable(failure) {
|
|
115
|
+
const reason = valueFreeFailure(failure).reason;
|
|
116
|
+
if (reason === 'session-blacklist-unavailable' || reason === 'session-verifier-unavailable')
|
|
117
|
+
rethrowFailure(failure);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The auth origin this handle verifies against and calls: an http(s) URL with
|
|
121
|
+
* no user, password or fragment. Anything else is a configuration fault, so it
|
|
122
|
+
* is refused before a request is made to it.
|
|
123
|
+
*/
|
|
124
|
+
function assertAuthOrigin(authOrigin) {
|
|
125
|
+
const url = URL.parse(authOrigin);
|
|
126
|
+
if (url === null || (url.protocol !== 'https:' && url.protocol !== 'http:') || url.username !== '' || url.password !== '' || url.hash !== '') {
|
|
127
|
+
throw new CapabilityError('The auth origin is not an http(s) URL.', 'INVALID_INPUT', {
|
|
128
|
+
reason: 'auth-origin-invalid',
|
|
129
|
+
retryable: false
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return authOrigin;
|
|
133
|
+
}
|
|
134
|
+
const SessionHandleKnobsSchema = z.object({
|
|
135
|
+
sessionRefreshTimeoutMs: z.number().positive().default(DEFAULT_SESSION_REFRESH_TIMEOUT_MS),
|
|
136
|
+
apiKeyValidateTimeoutMs: z.number().positive().default(DEFAULT_API_KEY_VALIDATE_TIMEOUT_MS),
|
|
137
|
+
jwksFetchTimeoutMs: z.number().positive().default(DEFAULT_JWKS_FETCH_TIMEOUT_MS)
|
|
138
|
+
}).strict();
|
|
139
|
+
const AuthHostSettingsSchema = z.object({ sessionHandle: SessionHandleKnobsSchema.prefault({}) }).passthrough();
|
|
140
|
+
/** Declared auth plugin settings; host environment aliases are not configuration. */
|
|
141
|
+
async function readSessionHandleKnobs(runtime) {
|
|
142
|
+
const config = await readPluginConfig(runtime, 'auth', AuthHostSettingsSchema);
|
|
143
|
+
return config?.sessionHandle ?? SessionHandleKnobsSchema.parse({});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Bound a promise even when the underlying I/O ignores AbortSignal.
|
|
147
|
+
* Cloudflare service-binding / public-edge fetches have been observed to
|
|
148
|
+
* swallow abort; without this race the incoming request holds the socket
|
|
149
|
+
* until the isolate wall clock (~30s).
|
|
150
|
+
*/
|
|
151
|
+
function withTimeout(runtime, promise, ms, message) {
|
|
152
|
+
let disarm;
|
|
153
|
+
const timeout = new Promise((_, reject) => {
|
|
154
|
+
disarm = runtime.lifecycle.timeout(() => reject(new Error(message)), ms);
|
|
155
|
+
});
|
|
156
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
157
|
+
if (disarm !== undefined)
|
|
158
|
+
disarm();
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
// ─── JWKS resolution (Cloudflare-native) ─────────────────────────────────────
|
|
162
|
+
// Verification keys come from the auth issuer's JWKS. We deliberately do NOT use
|
|
163
|
+
// jose's `createRemoteJWKSet`: it fetches over the network with a hard 5s ceiling
|
|
164
|
+
// whose timeout error is literally "request timed out", and against a cold
|
|
165
|
+
// auth-web reached over the PUBLIC url that ceiling was blown routinely — every
|
|
166
|
+
// consumer app then failed verification and 401'd ("Authentication required").
|
|
167
|
+
//
|
|
168
|
+
// Instead the keys are managed as a three-tier cache, each tier decoupling
|
|
169
|
+
// verification further from auth-web being warm:
|
|
170
|
+
// 1. per-isolate memo (a local JWKS resolver — zero per-request network),
|
|
171
|
+
// 2. the Cloudflare Cache API (survives isolate churn within a colo),
|
|
172
|
+
// 3. a refill fetched through the AUTH_SERVICE service binding (Worker→Worker
|
|
173
|
+
// RPC — no public-edge loopback), never the consumer's arbitrary auth-RPC
|
|
174
|
+
// fetcher; single-flighted per origin and bounded by a generous timeout
|
|
175
|
+
// (`jwksFetchTimeoutMs`, from the caller) so an unanswering issuer fails fast instead of
|
|
176
|
+
// hanging the request — consumers that declare no AUTH_SERVICE binding run
|
|
177
|
+
// this leg over the public origin, exactly the loopback described above.
|
|
178
|
+
// Freshness is charged against when the keys were pulled FROM THE ISSUER, not
|
|
179
|
+
// when a tier happened to read them, so a partly-aged Cache entry cannot be
|
|
180
|
+
// re-extended to a full fresh TTL (that would double the window in which a
|
|
181
|
+
// revoked key still verifies).
|
|
182
|
+
// A brand-new signing `kid` (key rotation the cached set predates) is handled
|
|
183
|
+
// eagerly by a cooldown-guarded forced refresh, not by waiting out the TTL.
|
|
184
|
+
function getRuntimeSessionState(runtime, expected) {
|
|
185
|
+
const state = tryGetVibesClient('auth', runtime)?.sessionVerificationState;
|
|
186
|
+
if (!state?.active || runtime.disposed || (expected && state !== expected)) {
|
|
187
|
+
throw new CapabilityError('Session verification owner is unavailable.', 'UNAVAILABLE', {
|
|
188
|
+
reason: 'session-verification-unavailable'
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return state;
|
|
192
|
+
}
|
|
193
|
+
// JWKS rotate rarely; an hour sits well within better-auth's key-overlap window
|
|
194
|
+
// and bounds how long a rotated-out key can linger in a warm cache.
|
|
195
|
+
const JWKS_TTL_MS = 60 * 60 * 1000;
|
|
196
|
+
// Floor between forced refreshes so a flood of unknown-`kid` (e.g. forged or
|
|
197
|
+
// stale) tokens cannot hammer the issuer — mirrors jose's `cooldownDuration`.
|
|
198
|
+
const JWKS_FORCE_REFRESH_COOLDOWN_MS = 30 * 1000;
|
|
199
|
+
// How long a Cache entry of UNKNOWN age may be memoized. Such an entry is a
|
|
200
|
+
// legacy body written before this module started stamping its pull time (they
|
|
201
|
+
// wash out within one max-age window). We can't date it, so we don't pretend to:
|
|
202
|
+
// it is trusted only briefly and then re-checked. The Cache API's own max-age
|
|
203
|
+
// eviction already bounds the entry itself at JWKS_TTL_MS, so worst-case key
|
|
204
|
+
// acceptance stays TTL + this floor — NOT the 2x TTL that memoizing an aged hit
|
|
205
|
+
// for a full fresh TTL would produce.
|
|
206
|
+
const JWKS_UNKNOWN_AGE_MEMO_MS = 60 * 1000;
|
|
207
|
+
/**
|
|
208
|
+
* Clear the JWKS cache. Test-only: tests that generate fresh key pairs need
|
|
209
|
+
* to bust the per-origin cache between cases, otherwise the first test's
|
|
210
|
+
* JWKS persists and subsequent verifies fail with "signature verification
|
|
211
|
+
* failed". Production code never needs this.
|
|
212
|
+
*/
|
|
213
|
+
export function _resetJwksCache(runtime) {
|
|
214
|
+
const state = tryGetVibesClient('auth', runtime)?.sessionVerificationState;
|
|
215
|
+
state?.jwksByOrigin.clear();
|
|
216
|
+
state?.jwksForceRefreshAtMs.clear();
|
|
217
|
+
state?.jwksRefillInFlight.clear();
|
|
218
|
+
}
|
|
219
|
+
/** The declared service binding's fetcher on the request's runtime, if the host binds one. */
|
|
220
|
+
function serviceBindingFetcherFrom(runtime, bindingName) {
|
|
221
|
+
if (!bindingName)
|
|
222
|
+
return undefined;
|
|
223
|
+
const binding = runtime.getBinding(bindingName, AuthServiceBindingSchema);
|
|
224
|
+
return binding ? binding.fetch.bind(binding) : undefined;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Service-binding fetch MUST NOT be pointed at the public issuer origin.
|
|
228
|
+
* `AUTH_SERVICE.fetch('https://auth.vibes.dev/api/auth/jwks')` has been
|
|
229
|
+
* observed to take the public-edge loopback (Worker → auth.vibes.dev →
|
|
230
|
+
* same colo) and hold the isolate without yielding, so AbortSignal and
|
|
231
|
+
* Promise.race timeouts never fire and the incoming socket dies at ~30s.
|
|
232
|
+
* The binding already selects the issuer worker; the host is only a
|
|
233
|
+
* pathname carrier.
|
|
234
|
+
*/
|
|
235
|
+
const ISSUER_BINDING_ORIGIN = 'https://issuer-binding.internal';
|
|
236
|
+
function issuerBindingUrl(pathname) {
|
|
237
|
+
return new URL(pathname, ISSUER_BINDING_ORIGIN).toString();
|
|
238
|
+
}
|
|
239
|
+
function resolveFetcher(option, serviceBindingFetcher) {
|
|
240
|
+
if (option === null) {
|
|
241
|
+
return globalThis.fetch.bind(globalThis);
|
|
242
|
+
}
|
|
243
|
+
if (option !== undefined) {
|
|
244
|
+
if (option instanceof Function && option.length === 0) {
|
|
245
|
+
// Looks like a getter `() => fetcher | undefined`. The `fetch`
|
|
246
|
+
// shape has `length === 2` so this disambiguates safely.
|
|
247
|
+
// SAFETY: a zero-arity function is the getter form of the option; the fetch shape takes (input, init).
|
|
248
|
+
const got = option();
|
|
249
|
+
if (got)
|
|
250
|
+
return got;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// SAFETY: any other function is the fetcher itself (the getter form was handled above).
|
|
254
|
+
return option;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return serviceBindingFetcher ?? globalThis.fetch.bind(globalThis);
|
|
258
|
+
}
|
|
259
|
+
export function createJwtSessionHandle(options) {
|
|
260
|
+
const serviceBindingName = options.serviceBindingName === undefined ? 'AUTH_SERVICE' : options.serviceBindingName;
|
|
261
|
+
const sessionHandle = async ({ event, resolve }) => {
|
|
262
|
+
const authOrigin = assertAuthOrigin(options.authOrigin instanceof Function ? await options.authOrigin(event) : options.authOrigin);
|
|
263
|
+
// SAFETY: `App.Locals` is an interface the host app augments; this handle owns the session fields on it (`SessionLocals`).
|
|
264
|
+
const locals = event.locals;
|
|
265
|
+
// Knobs and bindings come from the runtime prepareHandle bound to this
|
|
266
|
+
// request, never the ambient default (rc01 R2).
|
|
267
|
+
const runtime = requireRequestRuntime(locals);
|
|
268
|
+
const logger = getLogger(`${options.clientName || 'app'}.session`, runtime);
|
|
269
|
+
const knobs = await readSessionHandleKnobs(runtime);
|
|
270
|
+
const bindingNameForOrigin = isLocalAuthOrigin(authOrigin) ? null : serviceBindingName;
|
|
271
|
+
const serviceBindingFetcher = serviceBindingFetcherFrom(runtime, bindingNameForOrigin);
|
|
272
|
+
const fetcher = resolveFetcher(options.fetcher, serviceBindingFetcher);
|
|
273
|
+
// JWKS refill comes from the issuer worker via the AUTH_SERVICE binding
|
|
274
|
+
// (Worker→Worker RPC — no public-edge loopback). Crucially NOT the caller's
|
|
275
|
+
// `options.fetcher`: that override targets session/API-key endpoints and may
|
|
276
|
+
// point elsewhere, whereas verification keys must come from the issuer. The
|
|
277
|
+
// binding is guaranteed to be the issuer (wrangler `AUTH_SERVICE → vibes-auth`)
|
|
278
|
+
// and `iss` is checked independently, so this is correct as well as fast.
|
|
279
|
+
// Unbound (local dev / tests) it falls back to the public origin via `fetch`.
|
|
280
|
+
const jwksBindingFetcher = serviceBindingFetcher;
|
|
281
|
+
const jwksFetcher = jwksBindingFetcher ?? globalThis.fetch.bind(globalThis);
|
|
282
|
+
const jwksViaServiceBinding = Boolean(jwksBindingFetcher);
|
|
283
|
+
const jwtCookie = event.cookies.get(JWT_COOKIE_NAME);
|
|
284
|
+
if (jwtCookie) {
|
|
285
|
+
const verified = await attempt(() => verifyAuthJwt(jwtCookie, authOrigin, jwksFetcher, {
|
|
286
|
+
viaServiceBinding: jwksViaServiceBinding,
|
|
287
|
+
jwksFetchTimeoutMs: knobs.jwksFetchTimeoutMs,
|
|
288
|
+
runtime
|
|
289
|
+
}));
|
|
290
|
+
if (verified.ok) {
|
|
291
|
+
applyJwtPayload(locals, verified.value);
|
|
292
|
+
locals.sessionToken = jwtCookie;
|
|
293
|
+
return resolve(event);
|
|
294
|
+
}
|
|
295
|
+
rethrowIfBlacklistUnavailable(verified.failure);
|
|
296
|
+
logger.warn('[sessionHandle] Better Auth JWT verification failed', {
|
|
297
|
+
failure: failureLabel(verified.failure)
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
// Cross-app service calls (e.g. ai-web → platform-web/api/storage/upload)
|
|
301
|
+
// can't rely on browser-set cookies — Worker fetch doesn't carry the
|
|
302
|
+
// user's cookie jar. They forward the user's verified JWT as
|
|
303
|
+
// `Authorization: Bearer <jwt>` instead. Same JWKS verify path; the
|
|
304
|
+
// principal is still the requesting user, no service token involved.
|
|
305
|
+
const bearer = extractBearerToken(event.request.headers.get('authorization'));
|
|
306
|
+
if (bearer) {
|
|
307
|
+
if (bearer.split('.').length === 3) {
|
|
308
|
+
const verified = await attempt(() => verifyAuthJwt(bearer, authOrigin, jwksFetcher, {
|
|
309
|
+
viaServiceBinding: jwksViaServiceBinding,
|
|
310
|
+
jwksFetchTimeoutMs: knobs.jwksFetchTimeoutMs,
|
|
311
|
+
runtime
|
|
312
|
+
}));
|
|
313
|
+
if (verified.ok) {
|
|
314
|
+
applyJwtPayload(locals, verified.value);
|
|
315
|
+
locals.sessionToken = bearer;
|
|
316
|
+
return resolve(event);
|
|
317
|
+
}
|
|
318
|
+
rethrowIfBlacklistUnavailable(verified.failure);
|
|
319
|
+
logger.warn('[sessionHandle] Bearer JWT verification failed', {
|
|
320
|
+
failure: failureLabel(verified.failure)
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
// CLI / programmatic callers present a durable vibes API key, not a
|
|
325
|
+
// JWT. Validate against auth-web's existing server-to-server route
|
|
326
|
+
// (the MCP pattern) and populate the principal from the owner.
|
|
327
|
+
// Human-key results and misses are cached briefly by key hash.
|
|
328
|
+
// Agent principals are revalidated on every request so revocation,
|
|
329
|
+
// expiry, and quota changes take effect at Auth immediately.
|
|
330
|
+
const validated = await attempt(() => verifyApiKeyBearer(runtime, bearer, authOrigin, fetcher, {
|
|
331
|
+
viaServiceBinding: Boolean(serviceBindingFetcher),
|
|
332
|
+
timeoutMs: knobs.apiKeyValidateTimeoutMs
|
|
333
|
+
}));
|
|
334
|
+
if (!validated.ok) {
|
|
335
|
+
logger.warn('[sessionHandle] API-key validation failed', {
|
|
336
|
+
failure: failureLabel(validated.failure)
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
const payload = validated.ok ? validated.value : null;
|
|
340
|
+
if (payload) {
|
|
341
|
+
applyJwtPayload(locals, payload);
|
|
342
|
+
// An opaque vibes API key, not a JWT — but every consumer's
|
|
343
|
+
// sessionHandle validates it through the same bearer path, so it
|
|
344
|
+
// re-presents correctly on a server-to-server hop.
|
|
345
|
+
locals.sessionToken = bearer;
|
|
346
|
+
return resolve(event);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (hasRefreshSessionCookie(event.request.headers)) {
|
|
351
|
+
const refreshAttempt = await attempt(() => refreshJwtFromAuthSession({
|
|
352
|
+
authOrigin,
|
|
353
|
+
clientName: options.clientName,
|
|
354
|
+
requestHeaders: event.request.headers,
|
|
355
|
+
requestUrl: event.url,
|
|
356
|
+
setCookie: event.cookies.set,
|
|
357
|
+
fetcher,
|
|
358
|
+
jwksFetcher,
|
|
359
|
+
viaServiceBinding: jwksViaServiceBinding,
|
|
360
|
+
timeoutMs: knobs.sessionRefreshTimeoutMs,
|
|
361
|
+
jwksFetchTimeoutMs: knobs.jwksFetchTimeoutMs,
|
|
362
|
+
runtime
|
|
363
|
+
}));
|
|
364
|
+
if (!refreshAttempt.ok) {
|
|
365
|
+
rethrowIfBlacklistUnavailable(refreshAttempt.failure);
|
|
366
|
+
logger.warn('[sessionHandle] Better Auth JWT refresh failed', {
|
|
367
|
+
failure: failureLabel(refreshAttempt.failure)
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
const refreshed = refreshAttempt.ok ? refreshAttempt.value : null;
|
|
371
|
+
if (refreshed) {
|
|
372
|
+
// Best-effort — a no-op wherever request headers are immutable (workerd).
|
|
373
|
+
// `locals.sessionToken` is the reliable channel; see its docs.
|
|
374
|
+
upsertRequestCookie(runtime, event.request.headers, JWT_COOKIE_NAME, refreshed.token);
|
|
375
|
+
applyJwtPayload(locals, refreshed.payload);
|
|
376
|
+
locals.sessionToken = refreshed.token;
|
|
377
|
+
return resolve(event);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
locals.user = null;
|
|
381
|
+
locals.session = null;
|
|
382
|
+
locals.sessionToken = null;
|
|
383
|
+
return resolve(event);
|
|
384
|
+
};
|
|
385
|
+
return sessionHandle;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* The request principal extractor for `createSvelteKitRuntime({ principal })`.
|
|
389
|
+
*
|
|
390
|
+
* Runs in `invocationHandle`, after {@link createJwtSessionHandle}, and reads
|
|
391
|
+
* only what that handle verified: the user from `locals.user` and the JWT from
|
|
392
|
+
* `locals.sessionToken`, which is the credential in force after a refresh. It
|
|
393
|
+
* never reads the `vibes.jwt` cookie, which can be the expired token the
|
|
394
|
+
* request arrived with (d48 revision). No verified user, or no token, is
|
|
395
|
+
* `{ kind: 'anonymous' }`.
|
|
396
|
+
*/
|
|
397
|
+
export function authRequestPrincipal(event) {
|
|
398
|
+
const parsed = sessionLocalsSchema.safeParse(event.locals);
|
|
399
|
+
if (!parsed.success)
|
|
400
|
+
return { kind: 'anonymous' };
|
|
401
|
+
const { user, session, sessionToken: jwt } = parsed.data;
|
|
402
|
+
const userId = user?.id !== undefined && user.id.length > 0 ? user.id : null;
|
|
403
|
+
if (!user || !userId || jwt === undefined || jwt.length === 0)
|
|
404
|
+
return { kind: 'anonymous' };
|
|
405
|
+
const principal = { kind: 'user', userId, jwt };
|
|
406
|
+
// Verified facts (A18): projected only from what `applyJwtPayload` verified onto
|
|
407
|
+
// `locals.user`. An absent fact is omitted, never `false` / `[]`.
|
|
408
|
+
if (user.orgId !== undefined && user.orgId.length > 0)
|
|
409
|
+
principal.orgId = user.orgId;
|
|
410
|
+
const roles = (user.roles ?? []).flatMap((role) => {
|
|
411
|
+
const name = z.string().safeParse(role);
|
|
412
|
+
return name.success ? [name.data] : [];
|
|
413
|
+
});
|
|
414
|
+
if (roles.length > 0)
|
|
415
|
+
principal.roles = roles;
|
|
416
|
+
const orgs = normalizeOrgClaims(user.orgs);
|
|
417
|
+
if (orgs.length > 0)
|
|
418
|
+
principal.orgs = orgs;
|
|
419
|
+
if (user.staff === true)
|
|
420
|
+
principal.staff = true;
|
|
421
|
+
if (user.isSuperuser === true)
|
|
422
|
+
principal.isSuperuser = true;
|
|
423
|
+
const agentPrincipal = authenticatedAgentPrincipalSchema.safeParse(user.agentPrincipal);
|
|
424
|
+
if (agentPrincipal.success)
|
|
425
|
+
principal.agentPrincipal = agentPrincipal.data;
|
|
426
|
+
if (session?.id !== undefined && session.id.length > 0)
|
|
427
|
+
principal.sessionId = session.id;
|
|
428
|
+
return principal;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Create a same-origin route that binds an already verified bearer JWT as the
|
|
432
|
+
* host-only session cookie used by {@link createJwtSessionHandle}.
|
|
433
|
+
*
|
|
434
|
+
* The session handle must run before this route. It verifies the bearer against
|
|
435
|
+
* Auth's JWKS and populates `locals.user`; this handler refuses to write a
|
|
436
|
+
* cookie unless that verification succeeded. When the old cookie authenticated
|
|
437
|
+
* a renewal request, an explicit authOrigin lets it verify the new bearer too.
|
|
438
|
+
*/
|
|
439
|
+
export function createJwtSessionBindingHandler(options) {
|
|
440
|
+
return async (event) => {
|
|
441
|
+
const { request, cookies, locals, url } = event;
|
|
442
|
+
const origin = request.headers.get('origin');
|
|
443
|
+
if (origin !== null && origin !== url.origin)
|
|
444
|
+
return Response.json({ bound: false }, { status: 403 });
|
|
445
|
+
const bearer = extractBearerToken(request.headers.get('authorization'));
|
|
446
|
+
const verified = sessionLocalsSchema.safeParse(locals).data;
|
|
447
|
+
if (!bearer || bearer.split('.').length !== 3) {
|
|
448
|
+
return Response.json({ bound: false }, { status: 401 });
|
|
449
|
+
}
|
|
450
|
+
if (verified?.sessionToken === bearer && verified.user) {
|
|
451
|
+
const principal = authRequestPrincipal({ locals: verified });
|
|
452
|
+
if (principal.kind !== 'user')
|
|
453
|
+
return Response.json({ bound: false }, { status: 401 });
|
|
454
|
+
await options?.admit?.(event, principal);
|
|
455
|
+
setSessionJwtCookie(cookies, url, bearer);
|
|
456
|
+
return Response.json({ bound: true });
|
|
457
|
+
}
|
|
458
|
+
if (!options)
|
|
459
|
+
return Response.json({ bound: false }, { status: 401 });
|
|
460
|
+
const bound = await bindVerifiedSessionJwt(event, bearer, options);
|
|
461
|
+
return Response.json({ bound }, { status: bound ? 200 : 401 });
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function setSessionJwtCookie(cookies, url, bearer) {
|
|
465
|
+
cookies.set(JWT_COOKIE_NAME, bearer, {
|
|
466
|
+
httpOnly: true,
|
|
467
|
+
sameSite: 'lax',
|
|
468
|
+
secure: url.protocol === 'https:',
|
|
469
|
+
path: '/',
|
|
470
|
+
maxAge: JWT_MAX_AGE_SECONDS
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Verify a bearer against Auth, apply host admission, and write it as the
|
|
475
|
+
* host-only HttpOnly session cookie. Returns false when the bearer does not
|
|
476
|
+
* verify as a user session; admission refusals propagate from `admit`.
|
|
477
|
+
*/
|
|
478
|
+
export async function bindVerifiedSessionJwt(event, bearer, options) {
|
|
479
|
+
if (bearer.split('.').length !== 3)
|
|
480
|
+
return false;
|
|
481
|
+
const authOrigin = options.authOrigin instanceof Function ? await options.authOrigin(event) : options.authOrigin;
|
|
482
|
+
const verdict = await verifySessionJwtResult({ token: bearer, authOrigin, runtime: requireRequestRuntime(event.locals) });
|
|
483
|
+
if (verdict.status !== 'verified')
|
|
484
|
+
return false;
|
|
485
|
+
const bindingLocals = { sessionToken: bearer };
|
|
486
|
+
applyJwtPayload(bindingLocals, verdict.payload);
|
|
487
|
+
const principal = authRequestPrincipal({ locals: bindingLocals });
|
|
488
|
+
if (principal.kind !== 'user')
|
|
489
|
+
return false;
|
|
490
|
+
await options.admit?.(event, principal);
|
|
491
|
+
setSessionJwtCookie(event.cookies, event.url, bearer);
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
/** The Cache API store is usable when it answers the two calls this module makes. */
|
|
495
|
+
const cacheStoreSchema = z.custom((value) => value instanceof Object &&
|
|
496
|
+
'match' in value &&
|
|
497
|
+
value.match instanceof Function &&
|
|
498
|
+
'put' in value &&
|
|
499
|
+
value.put instanceof Function);
|
|
500
|
+
const cacheHostSchema = z.object({
|
|
501
|
+
caches: z.object({ default: cacheStoreSchema }).optional()
|
|
502
|
+
});
|
|
503
|
+
/** The Cloudflare Cache API (`caches.default`), or null off-Workers (local dev, tests). */
|
|
504
|
+
function getCacheStore() {
|
|
505
|
+
const host = cacheHostSchema.safeParse(globalThis);
|
|
506
|
+
return host.success ? host.data.caches?.default ?? null : null;
|
|
507
|
+
}
|
|
508
|
+
/** Stable Cache-API key for an issuer's JWKS. Host is only a namespace; the entry
|
|
509
|
+
* is keyed by this URL string. */
|
|
510
|
+
function jwksCacheRequest(jwksOrigin) {
|
|
511
|
+
// Never key the Cache API on the public issuer URL. A put at
|
|
512
|
+
// `https://auth.vibes.dev/api/auth/jwks` pollutes that origin's HTTP cache
|
|
513
|
+
// with this module's envelope (`{cachedAtMs,jwks}`), so a public GET no
|
|
514
|
+
// longer returns a standard JWKS `{keys:[...]}`.
|
|
515
|
+
const key = new URL('https://jwks-cache.internal/api/auth/jwks');
|
|
516
|
+
key.searchParams.set('origin', jwksOrigin);
|
|
517
|
+
return new Request(key.toString(), { method: 'GET' });
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* When was this cache hit actually written? The Cache API does not rewrite an
|
|
521
|
+
* entry on a hit, so `Age` (seconds the entry has been cached) / `Date` are the
|
|
522
|
+
* only header-borne signals. Entries this module writes carry the timestamp in
|
|
523
|
+
* the body instead; these headers cover entries written by an older deploy.
|
|
524
|
+
*/
|
|
525
|
+
function readCacheEntryFetchedAtMs(hit) {
|
|
526
|
+
const ageHeader = hit.headers.get('age');
|
|
527
|
+
if (ageHeader !== null && ageHeader.trim().length > 0) {
|
|
528
|
+
const ageSeconds = Number(ageHeader);
|
|
529
|
+
if (Number.isFinite(ageSeconds) && ageSeconds >= 0)
|
|
530
|
+
return Date.now() - ageSeconds * 1000;
|
|
531
|
+
}
|
|
532
|
+
const dateHeader = hit.headers.get('date');
|
|
533
|
+
if (dateHeader) {
|
|
534
|
+
const parsed = Date.parse(dateHeader);
|
|
535
|
+
if (Number.isFinite(parsed))
|
|
536
|
+
return parsed;
|
|
537
|
+
}
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
/** A JWKS body: a `keys` list. The keys themselves are parsed by `jose` when the set is built. */
|
|
541
|
+
const jsonWebKeySetSchema = z.looseObject({
|
|
542
|
+
keys: z.array(z.looseObject({ kty: z.string().optional(), kid: z.string().optional() }))
|
|
543
|
+
});
|
|
544
|
+
/** What the Cache API holds: the envelope this module writes, or a bare key set an older deploy wrote. */
|
|
545
|
+
const cachedJwksBodySchema = z.union([
|
|
546
|
+
z.looseObject({
|
|
547
|
+
jwks: jsonWebKeySetSchema,
|
|
548
|
+
cachedAtMs: z.number().optional().catch(undefined)
|
|
549
|
+
}),
|
|
550
|
+
jsonWebKeySetSchema.transform((jwks) => ({ jwks, cachedAtMs: undefined }))
|
|
551
|
+
]);
|
|
552
|
+
async function readJwksFromCache(runtime, jwksOrigin) {
|
|
553
|
+
const store = getCacheStore();
|
|
554
|
+
if (!store)
|
|
555
|
+
return null;
|
|
556
|
+
// Declared-optional cache read: a miss (or an unreadable entry) refetches from the issuer.
|
|
557
|
+
const read = await attempt(async () => {
|
|
558
|
+
const hit = await store.match(jwksCacheRequest(jwksOrigin));
|
|
559
|
+
if (!hit)
|
|
560
|
+
return null;
|
|
561
|
+
const headerFetchedAtMs = readCacheEntryFetchedAtMs(hit);
|
|
562
|
+
// Envelope written by this module — the write time travels WITH the keys, so
|
|
563
|
+
// freshness never depends on an edge header we don't control. A bare key set
|
|
564
|
+
// (an older deploy) is only as fresh as its headers say, possibly not at all.
|
|
565
|
+
const body = cachedJwksBodySchema.safeParse(await hit.json());
|
|
566
|
+
if (!body.success)
|
|
567
|
+
return null;
|
|
568
|
+
return { jwks: body.data.jwks, fetchedAtMs: body.data.cachedAtMs ?? headerFetchedAtMs };
|
|
569
|
+
});
|
|
570
|
+
if (read.ok)
|
|
571
|
+
return read.value;
|
|
572
|
+
getLogger('auth.jwt-session', runtime).debug('JWKS cache read failed; treating as a miss', { failure: failureLabel(read.failure) });
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
575
|
+
async function writeJwksToCache(runtime, jwksOrigin, jwks, fetchedAtMs) {
|
|
576
|
+
const store = getCacheStore();
|
|
577
|
+
if (!store)
|
|
578
|
+
return;
|
|
579
|
+
// Declared-optional cache write: a failure just means the next isolate refetches.
|
|
580
|
+
const written = await attempt(() => store.put(jwksCacheRequest(jwksOrigin),
|
|
581
|
+
// The envelope carries the issuer-pull time so a later reader can charge
|
|
582
|
+
// the entry's own age against the TTL. An older deploy reading this body
|
|
583
|
+
// finds no `keys` and simply refills — it never mistakes it for keys.
|
|
584
|
+
new Response(JSON.stringify({ cachedAtMs: fetchedAtMs, jwks }), {
|
|
585
|
+
headers: {
|
|
586
|
+
'content-type': 'application/json',
|
|
587
|
+
// Cache API evicts past max-age → bounds staleness without a manual sweep.
|
|
588
|
+
'cache-control': `max-age=${Math.floor(JWKS_TTL_MS / 1000)}`
|
|
589
|
+
}
|
|
590
|
+
})));
|
|
591
|
+
if (!written.ok)
|
|
592
|
+
getLogger('auth.jwt-session', runtime).debug('JWKS cache write failed', { failure: failureLabel(written.failure) });
|
|
593
|
+
}
|
|
594
|
+
/** A fetched JWKS body: `{ keys }` or `{ jwks: { keys } }`, with at least one key. */
|
|
595
|
+
const issuerJwksBodySchema = z.union([
|
|
596
|
+
jsonWebKeySetSchema,
|
|
597
|
+
z.looseObject({ jwks: jsonWebKeySetSchema }).transform((body) => body.jwks)
|
|
598
|
+
]);
|
|
599
|
+
function asJsonWebKeySet(body) {
|
|
600
|
+
const parsed = issuerJwksBodySchema.safeParse(body);
|
|
601
|
+
return parsed.success && parsed.data.keys.length > 0 ? parsed.data : null;
|
|
602
|
+
}
|
|
603
|
+
async function fetchJwksFromIssuer(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs) {
|
|
604
|
+
// Bounded two ways: AbortSignal (cooperative fetchers) AND Promise.race
|
|
605
|
+
// (CF Fetcher / public-edge loopback, which ignore abort and otherwise
|
|
606
|
+
// own the incoming socket until the ~30s isolate wall clock).
|
|
607
|
+
const jwksUrl = viaServiceBinding
|
|
608
|
+
? issuerBindingUrl('/api/auth/jwks')
|
|
609
|
+
: new URL('/api/auth/jwks', jwksOrigin).toString();
|
|
610
|
+
try {
|
|
611
|
+
return await withTimeout(runtime, (async () => {
|
|
612
|
+
const controller = new AbortController();
|
|
613
|
+
const disarm = runtime.lifecycle.timeout(() => controller.abort(), timeoutMs);
|
|
614
|
+
try {
|
|
615
|
+
const res = await fetcher(jwksUrl, {
|
|
616
|
+
// Refills establish verification trust and are already amortized by the
|
|
617
|
+
// package-owned memo. Revalidate the issuer instead of accepting a
|
|
618
|
+
// long-lived shared-edge entry written by another Worker cache.
|
|
619
|
+
headers: { accept: 'application/json', 'cache-control': 'no-cache' },
|
|
620
|
+
signal: controller.signal
|
|
621
|
+
});
|
|
622
|
+
if (!res.ok)
|
|
623
|
+
throw new Error(`JWKS fetch failed: ${res.status}`);
|
|
624
|
+
const jwks = asJsonWebKeySet(await res.json());
|
|
625
|
+
if (!jwks)
|
|
626
|
+
throw new Error('JWKS fetch returned no keys');
|
|
627
|
+
return jwks;
|
|
628
|
+
}
|
|
629
|
+
finally {
|
|
630
|
+
disarm();
|
|
631
|
+
}
|
|
632
|
+
})(), timeoutMs, `JWKS fetch timed out after ${timeoutMs}ms`);
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
if (error instanceof CapabilityError)
|
|
636
|
+
throw error;
|
|
637
|
+
throw new CapabilityError('JWKS verification dependency is unavailable.', 'UNAVAILABLE', {
|
|
638
|
+
reason: 'jwks-unavailable'
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Memoize a key set in this isolate. `fetchedAtMs` is when the set was pulled
|
|
644
|
+
* FROM THE ISSUER — not when we happened to read it — so the TTL measures key
|
|
645
|
+
* age, not memo age. Passing `Date.now()` for a Cache hit would re-extend an
|
|
646
|
+
* already-old entry to a full fresh TTL, doubling how long a revoked key keeps
|
|
647
|
+
* verifying (a 59-minute-old hit memoized for another 60).
|
|
648
|
+
*/
|
|
649
|
+
function memoizeJwks(runtime, jwksOrigin, jwks, fetchedAtMs, expected) {
|
|
650
|
+
return memoizeJwksUntil(runtime, jwksOrigin, jwks, fetchedAtMs + JWKS_TTL_MS, expected);
|
|
651
|
+
}
|
|
652
|
+
function memoizeJwksUntil(runtime, jwksOrigin, jwks, expiresAtMs, expected) {
|
|
653
|
+
const state = getRuntimeSessionState(runtime, expected);
|
|
654
|
+
const entry = { resolver: createLocalJWKSet(jwks), expiresAtMs };
|
|
655
|
+
state.jwksByOrigin.set(jwksOrigin, entry);
|
|
656
|
+
return entry;
|
|
657
|
+
}
|
|
658
|
+
/** Pull fresh keys from the issuer, cache them, memoize them. Concurrent callers
|
|
659
|
+
* in one isolate share ONE in-flight pull rather than stampeding the issuer. */
|
|
660
|
+
function refillJwksEntry(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs) {
|
|
661
|
+
const state = getRuntimeSessionState(runtime);
|
|
662
|
+
const existing = state.jwksRefillInFlight.get(jwksOrigin);
|
|
663
|
+
if (existing)
|
|
664
|
+
return existing;
|
|
665
|
+
const inFlight = (async () => {
|
|
666
|
+
// Stamped BEFORE the fetch: if the pull is slow the keys are treated as
|
|
667
|
+
// slightly older than they are, never younger.
|
|
668
|
+
const fetchedAtMs = Date.now();
|
|
669
|
+
const fetched = await fetchJwksFromIssuer(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs);
|
|
670
|
+
getRuntimeSessionState(runtime, state);
|
|
671
|
+
await writeJwksToCache(runtime, jwksOrigin, fetched, fetchedAtMs);
|
|
672
|
+
return memoizeJwks(runtime, jwksOrigin, fetched, fetchedAtMs, state);
|
|
673
|
+
})();
|
|
674
|
+
state.jwksRefillInFlight.set(jwksOrigin, inFlight);
|
|
675
|
+
const clear = () => {
|
|
676
|
+
if (state.jwksRefillInFlight.get(jwksOrigin) === inFlight)
|
|
677
|
+
state.jwksRefillInFlight.delete(jwksOrigin);
|
|
678
|
+
};
|
|
679
|
+
// `attempt` settles instead of rejecting: the derived promise must not re-throw a
|
|
680
|
+
// rejected refill as an unhandled rejection. Real callers still see the
|
|
681
|
+
// rejection on `inFlight` itself.
|
|
682
|
+
void attempt(() => inFlight).then(clear);
|
|
683
|
+
return inFlight;
|
|
684
|
+
}
|
|
685
|
+
/** Resolve a verification key set: isolate memo → Cache API → issuer binding fetch. */
|
|
686
|
+
async function getJwksEntry(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs) {
|
|
687
|
+
const state = getRuntimeSessionState(runtime);
|
|
688
|
+
const memo = state.jwksByOrigin.get(jwksOrigin);
|
|
689
|
+
if (memo && memo.expiresAtMs > Date.now())
|
|
690
|
+
return memo;
|
|
691
|
+
const cached = await readJwksFromCache(runtime, jwksOrigin);
|
|
692
|
+
if (cached) {
|
|
693
|
+
// A hit is only as fresh as the entry itself — the Cache API does not
|
|
694
|
+
// rewrite an entry when it is read.
|
|
695
|
+
if (cached.fetchedAtMs !== null) {
|
|
696
|
+
if (cached.fetchedAtMs + JWKS_TTL_MS > Date.now()) {
|
|
697
|
+
return memoizeJwks(runtime, jwksOrigin, cached.jwks, cached.fetchedAtMs, state);
|
|
698
|
+
}
|
|
699
|
+
// Known-age and already past the TTL: refill rather than serve it.
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
// Age unknown (a legacy pre-envelope entry). Still serve it — a warm
|
|
703
|
+
// cache entry is what decouples every consumer from a cold auth-web —
|
|
704
|
+
// but hold it only briefly instead of inventing a fresh full TTL.
|
|
705
|
+
return memoizeJwksUntil(runtime, jwksOrigin, cached.jwks, Date.now() + JWKS_UNKNOWN_AGE_MEMO_MS, state);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return refillJwksEntry(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs);
|
|
709
|
+
}
|
|
710
|
+
/** Force a fresh issuer pull (bypassing memo + Cache), cooldown-guarded so a burst
|
|
711
|
+
* of unknown-`kid` tokens can't hammer the issuer. Returns null when on cooldown. */
|
|
712
|
+
async function refreshJwksEntry(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs) {
|
|
713
|
+
const state = getRuntimeSessionState(runtime);
|
|
714
|
+
const last = state.jwksForceRefreshAtMs.get(jwksOrigin) ?? 0;
|
|
715
|
+
if (Date.now() - last < JWKS_FORCE_REFRESH_COOLDOWN_MS)
|
|
716
|
+
return null;
|
|
717
|
+
state.jwksForceRefreshAtMs.set(jwksOrigin, Date.now());
|
|
718
|
+
return refillJwksEntry(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs);
|
|
719
|
+
}
|
|
720
|
+
/** jose signals a `kid` absent from the current key set — the tell for a rotation
|
|
721
|
+
* the cached JWKS predates (as opposed to a bad signature, which must NOT refetch). */
|
|
722
|
+
function isNoMatchingKeyError(failure) {
|
|
723
|
+
return (valueFreeFailure(failure).code === 'ERR_JWKS_NO_MATCHING_KEY' ||
|
|
724
|
+
(failure instanceof Error && failure.name === 'JWKSNoMatchingKey'));
|
|
725
|
+
}
|
|
726
|
+
/** Normalize both token and session-ID storage failures at the verification owner. */
|
|
727
|
+
async function readRevocation(blacklist, key) {
|
|
728
|
+
try {
|
|
729
|
+
return await blacklist.get(key);
|
|
730
|
+
}
|
|
731
|
+
catch (cause) {
|
|
732
|
+
throw new CapabilityError('Session revocation storage is unavailable.', 'UNAVAILABLE', {
|
|
733
|
+
cause,
|
|
734
|
+
reason: 'session-blacklist-unavailable'
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
/** Reject a verified JWT whose `sessionId` claim was revoked by admin session termination. */
|
|
739
|
+
async function assertSessionIdNotRevoked(blacklist, payload) {
|
|
740
|
+
const sessionId = z.string().min(1).safeParse(payload.sessionId);
|
|
741
|
+
if (!sessionId.success)
|
|
742
|
+
return;
|
|
743
|
+
if (await readRevocation(blacklist, sessionIdRevocationKey(sessionId.data))) {
|
|
744
|
+
throw new CapabilityError('Session has been revoked.', 'AUTH_REQUIRED', {
|
|
745
|
+
reason: 'session-revoked'
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
async function verifyAuthJwt(token, authOrigin, fetcher, options) {
|
|
750
|
+
const verifier = await options.runtime.query(SESSION_VERIFIER_KIND).withId(SESSION_VERIFIER_ID).resolve();
|
|
751
|
+
return verifier.verify({ token, authOrigin, fetcher, jwksFetchTimeoutMs: options.jwksFetchTimeoutMs, viaServiceBinding: options.viaServiceBinding });
|
|
752
|
+
}
|
|
753
|
+
export async function verifyBoundAuthJwt(token, authOrigin, fetcher, options) {
|
|
754
|
+
const runtime = options.runtime;
|
|
755
|
+
await getVibesClient('auth', runtime);
|
|
756
|
+
getRuntimeSessionState(runtime);
|
|
757
|
+
const blacklist = runtime.getBinding('SESSION_BLACKLIST', SessionBlacklistReaderSchema);
|
|
758
|
+
if (!blacklist) {
|
|
759
|
+
throw new CapabilityError('Session blacklist KV namespace (SESSION_BLACKLIST) is not bound.', 'UNAVAILABLE', { reason: 'session-blacklist-unavailable' });
|
|
760
|
+
}
|
|
761
|
+
for (const key of await sessionRevocationKeys(token)) {
|
|
762
|
+
if (await readRevocation(blacklist, key)) {
|
|
763
|
+
throw new CapabilityError('Session token has been revoked.', 'AUTH_REQUIRED', { reason: 'session-revoked' });
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
const jwksOrigin = resolveJwksOrigin(authOrigin);
|
|
767
|
+
const viaServiceBinding = options.viaServiceBinding === true;
|
|
768
|
+
const timeoutMs = options.jwksFetchTimeoutMs;
|
|
769
|
+
const issuer = isLocalAuthOrigin(authOrigin)
|
|
770
|
+
? [
|
|
771
|
+
...new Set([
|
|
772
|
+
authOrigin,
|
|
773
|
+
resolveLocalAuthOrigin(authOrigin),
|
|
774
|
+
VIBES_LOCAL_AUTH_ORIGIN
|
|
775
|
+
])
|
|
776
|
+
]
|
|
777
|
+
: authOrigin;
|
|
778
|
+
// Local auth has two equivalent ingress names: the canonical auth.vibes.local
|
|
779
|
+
// origin and the direct PM port. Depending on which path minted the JWT, either
|
|
780
|
+
// may appear in `iss`; the signing key and audience are still verified normally.
|
|
781
|
+
// Production remains a single exact issuer.
|
|
782
|
+
const verifyOpts = { issuer, audience: 'vibes-apps' };
|
|
783
|
+
const verifyWith = async (resolver) => {
|
|
784
|
+
const { payload } = await jwtVerify(token, resolver, verifyOpts);
|
|
785
|
+
await assertSessionIdNotRevoked(blacklist, payload);
|
|
786
|
+
getRuntimeSessionState(runtime);
|
|
787
|
+
return payload;
|
|
788
|
+
};
|
|
789
|
+
const entry = await getJwksEntry(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs);
|
|
790
|
+
const first = await attempt(() => verifyWith(entry.resolver));
|
|
791
|
+
if (first.ok)
|
|
792
|
+
return first.value;
|
|
793
|
+
if (!isNoMatchingKeyError(first.failure))
|
|
794
|
+
return rethrowFailure(first.failure);
|
|
795
|
+
// Unknown `kid`: the issuer likely rotated keys since we cached. Pull fresh
|
|
796
|
+
// once (cooldown-guarded) and retry; on cooldown, surface the original miss.
|
|
797
|
+
const refreshed = await refreshJwksEntry(runtime, jwksOrigin, fetcher, viaServiceBinding, timeoutMs);
|
|
798
|
+
if (!refreshed)
|
|
799
|
+
return rethrowFailure(first.failure);
|
|
800
|
+
return verifyWith(refreshed.resolver);
|
|
801
|
+
}
|
|
802
|
+
/** The actor fields an org/tenant gate needs. Deliberately a SUBSET of the session user —
|
|
803
|
+
* a delegated call proves who the end user is, not that they hold a live session here. */
|
|
804
|
+
// The public projection and result types are inferred from Auth's owning schemas.
|
|
805
|
+
/**
|
|
806
|
+
* Verify a JWT that a TRUSTED internal service forwarded on an end user's behalf, and return
|
|
807
|
+
* only the claims a tenant gate reads.
|
|
808
|
+
*
|
|
809
|
+
* Why this exists. A service-to-service call (chat-web → ai-web's agent run/stream, the
|
|
810
|
+
* agent-execution tool) carries no session cookie, so `locals.user` is null and every
|
|
811
|
+
* org-scope check downstream sees a null actor. Two bad options follow from that: deny every
|
|
812
|
+
* org-scoped agent over the delegated path, or skip the tenant check for delegated callers —
|
|
813
|
+
* which reopens the IDOR the per-agent org gate exists to close, because the delegating
|
|
814
|
+
* surface applies no org gate of its own and the agent id is caller-controlled.
|
|
815
|
+
*
|
|
816
|
+
* The third option is this one: the delegating service already forwards the ACTOR'S OWN JWT
|
|
817
|
+
* (strip-protected, so staged or model-authored metadata cannot forge it), and that JWT
|
|
818
|
+
* carries the same `orgs` / `staff` claims `locals.user` is built from. Verifying it here
|
|
819
|
+
* gives the delegated path the SAME evidence the session path has, from the same issuer,
|
|
820
|
+
* through the same JWKS — rather than a second, weaker notion of "who is acting".
|
|
821
|
+
*
|
|
822
|
+
* Verification is the full session-handle path (issuer + `vibes-apps` audience + JWKS with
|
|
823
|
+
* kid-rotation retry); this is not a decode. Credential refusals return a typed invalid
|
|
824
|
+
* result. Revocation/JWKS dependency failures reject, preserving CapabilityError.
|
|
825
|
+
* The compatible nullable entrypoint below projects every unsuccessful result to null.
|
|
826
|
+
*/
|
|
827
|
+
export async function verifyDelegatedActorClaimsResult(input) {
|
|
828
|
+
const options = delegatedActorVerificationOptionsSchema.parse(input);
|
|
829
|
+
const token = options.token?.trim();
|
|
830
|
+
if (!token)
|
|
831
|
+
return { status: 'invalid', reason: 'missing' };
|
|
832
|
+
const runtime = options.runtime;
|
|
833
|
+
const authOrigin = assertAuthOrigin(options.authOrigin);
|
|
834
|
+
const serviceBindingFetcher = options.serviceBindingFetcher ??
|
|
835
|
+
serviceBindingFetcherFrom(runtime, isLocalAuthOrigin(authOrigin) ? null : 'AUTH_SERVICE');
|
|
836
|
+
const viaServiceBinding = Boolean(options.fetcher === undefined && serviceBindingFetcher);
|
|
837
|
+
const verified = await attempt(async () => {
|
|
838
|
+
const knobs = await readSessionHandleKnobs(runtime);
|
|
839
|
+
return verifyAuthJwt(token, authOrigin, resolveFetcher(options.fetcher, serviceBindingFetcher), {
|
|
840
|
+
viaServiceBinding,
|
|
841
|
+
jwksFetchTimeoutMs: options.jwksFetchTimeoutMs ?? knobs.jwksFetchTimeoutMs,
|
|
842
|
+
runtime
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
if (!verified.ok) {
|
|
846
|
+
const failure = verified.failure;
|
|
847
|
+
if (failure instanceof CapabilityError && failure.code === 'AUTH_REQUIRED' && failure.reason === 'session-revoked') {
|
|
848
|
+
return { status: 'invalid', reason: 'revoked' };
|
|
849
|
+
}
|
|
850
|
+
if (failure instanceof errors.JWTExpired ||
|
|
851
|
+
failure instanceof errors.JWTClaimValidationFailed ||
|
|
852
|
+
failure instanceof errors.JWTInvalid ||
|
|
853
|
+
failure instanceof errors.JWSInvalid ||
|
|
854
|
+
failure instanceof errors.JWSSignatureVerificationFailed ||
|
|
855
|
+
failure instanceof errors.JWKSNoMatchingKey ||
|
|
856
|
+
failure instanceof errors.JOSEAlgNotAllowed) {
|
|
857
|
+
const reason = failure instanceof errors.JWTExpired ? 'expired'
|
|
858
|
+
: failure instanceof errors.JWTClaimValidationFailed ? 'scope' : 'invalid';
|
|
859
|
+
return { status: 'invalid', reason };
|
|
860
|
+
}
|
|
861
|
+
return rethrowFailure(failure);
|
|
862
|
+
}
|
|
863
|
+
const payload = verified.value;
|
|
864
|
+
const userId = z.string().min(1).safeParse(payload.sub);
|
|
865
|
+
if (!userId.success)
|
|
866
|
+
return { status: 'invalid', reason: 'invalid' };
|
|
867
|
+
return delegatedActorVerificationSchema.parse({
|
|
868
|
+
status: 'verified',
|
|
869
|
+
claims: {
|
|
870
|
+
userId: userId.data,
|
|
871
|
+
orgs: normalizeOrgClaims(payload.orgs),
|
|
872
|
+
staff: payload.staff === true,
|
|
873
|
+
isSuperuser: payload.isSuperuser === true
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
/** Issuer endpoint projection. Decode only the exact token the full verifier just accepted. */
|
|
878
|
+
export async function verifySessionJwtResult(input) {
|
|
879
|
+
const options = delegatedActorVerificationOptionsSchema.parse(input);
|
|
880
|
+
const token = options.token?.trim();
|
|
881
|
+
if (!token)
|
|
882
|
+
return { status: 'invalid', reason: 'missing' };
|
|
883
|
+
const verdict = await verifyDelegatedActorClaimsResult({ ...options, token });
|
|
884
|
+
if (verdict.status === 'invalid')
|
|
885
|
+
return verdict;
|
|
886
|
+
return SessionJwtVerificationSchema.parse({ status: 'verified', payload: decodeJWTUnsafe(token) });
|
|
887
|
+
}
|
|
888
|
+
/** Compatibility projection: every unsuccessful verification remains nullable. */
|
|
889
|
+
export async function verifyDelegatedActorClaims(options) {
|
|
890
|
+
const verified = await attempt(() => verifyDelegatedActorClaimsResult(options));
|
|
891
|
+
if (!verified.ok) {
|
|
892
|
+
// Invalid issuer configuration has always been a caller error, not a nullable credential refusal.
|
|
893
|
+
if (verified.failure instanceof CapabilityError &&
|
|
894
|
+
verified.failure.code === 'INVALID_INPUT' &&
|
|
895
|
+
verified.failure.reason === 'auth-origin-invalid')
|
|
896
|
+
return rethrowFailure(verified.failure);
|
|
897
|
+
return null;
|
|
898
|
+
}
|
|
899
|
+
return verified.value.status === 'verified' ? verified.value.claims : null;
|
|
900
|
+
}
|
|
901
|
+
const API_KEY_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
902
|
+
const API_KEY_CACHE_MAX = 1000;
|
|
903
|
+
/** Test-only cache reset for falsifiers that exercise repeated opaque bearers. */
|
|
904
|
+
export function _resetApiKeyCache(runtime) {
|
|
905
|
+
tryGetVibesClient('auth', runtime)?.sessionVerificationState.apiKeyCache.clear();
|
|
906
|
+
}
|
|
907
|
+
async function sha256Hex(value) {
|
|
908
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));
|
|
909
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Validate a vibes API key against auth-web's server-to-server
|
|
913
|
+
* `/api/api-keys/validate` route and shape the owner as a minimal JWT-like
|
|
914
|
+
* payload (`sub` + scopes; no org claims — those require a real JWT).
|
|
915
|
+
* Human-key and negative results are cached. Agent principals are deliberately
|
|
916
|
+
* never cached: Auth remains authoritative for every use of a revocable,
|
|
917
|
+
* expiring machine credential.
|
|
918
|
+
*/
|
|
919
|
+
async function verifyApiKeyBearer(runtime, key, authOrigin, fetcher, options) {
|
|
920
|
+
await getVibesClient('auth', runtime);
|
|
921
|
+
const cacheKey = await sha256Hex(key);
|
|
922
|
+
const state = getRuntimeSessionState(runtime);
|
|
923
|
+
const hit = state.apiKeyCache.get(cacheKey);
|
|
924
|
+
if (hit && hit.expiresAtMs > Date.now())
|
|
925
|
+
return hit.payload;
|
|
926
|
+
const doFetch = fetcher ?? globalThis.fetch;
|
|
927
|
+
// Bounded two ways (AbortSignal + Promise.race): a hung auth-web, or a
|
|
928
|
+
// CF Fetcher that ignores abort, must not stall the caller's request.
|
|
929
|
+
// On timeout the fetch rejects and the caller's rejection handler
|
|
930
|
+
// degrades to user-less — non-fatal; routes that require a principal
|
|
931
|
+
// still enforce via their own guards.
|
|
932
|
+
const validateTimeoutMs = options.timeoutMs;
|
|
933
|
+
const controller = new AbortController();
|
|
934
|
+
const disarm = runtime.lifecycle.timeout(() => controller.abort(), validateTimeoutMs);
|
|
935
|
+
let res;
|
|
936
|
+
try {
|
|
937
|
+
const validateUrl = options.viaServiceBinding
|
|
938
|
+
? issuerBindingUrl('/api/api-keys/validate')
|
|
939
|
+
: `${authOrigin.replace(/\/$/, '')}/api/api-keys/validate`;
|
|
940
|
+
res = await withTimeout(runtime, doFetch(validateUrl, {
|
|
941
|
+
method: 'POST',
|
|
942
|
+
headers: { 'content-type': 'application/json' },
|
|
943
|
+
body: JSON.stringify({ key }),
|
|
944
|
+
signal: controller.signal
|
|
945
|
+
}), validateTimeoutMs, `API-key validate timed out after ${validateTimeoutMs}ms`);
|
|
946
|
+
}
|
|
947
|
+
finally {
|
|
948
|
+
disarm();
|
|
949
|
+
}
|
|
950
|
+
let payload = null;
|
|
951
|
+
if (res.ok) {
|
|
952
|
+
const body = ApiKeyValidationResponseSchema.safeParse(await readJsonOrNull(res));
|
|
953
|
+
if (body.success && body.data.valid) {
|
|
954
|
+
payload = {
|
|
955
|
+
sub: body.data.userId,
|
|
956
|
+
scopes: body.data.scopes,
|
|
957
|
+
authMethod: 'api-key'
|
|
958
|
+
};
|
|
959
|
+
if (body.data.principal?.kind === 'agent') {
|
|
960
|
+
payload.agentPrincipal = authenticatedAgentPrincipalSchema.parse(body.data.principal);
|
|
961
|
+
payload.roles = ['agent'];
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
getRuntimeSessionState(runtime, state);
|
|
966
|
+
if (payload?.agentPrincipal === undefined) {
|
|
967
|
+
if (state.apiKeyCache.size >= API_KEY_CACHE_MAX) {
|
|
968
|
+
// Evict the OLDEST entry (Map preserves insertion order) rather than wiping
|
|
969
|
+
// the whole cache. A full .clear() at the cap invalidated every still-valid
|
|
970
|
+
// cached key at once, causing a thundering herd of re-validations against
|
|
971
|
+
// auth-web the instant the cache filled.
|
|
972
|
+
const oldest = state.apiKeyCache.keys().next().value;
|
|
973
|
+
if (oldest !== undefined)
|
|
974
|
+
state.apiKeyCache.delete(oldest);
|
|
975
|
+
}
|
|
976
|
+
state.apiKeyCache.set(cacheKey, { expiresAtMs: Date.now() + API_KEY_CACHE_TTL_MS, payload });
|
|
977
|
+
}
|
|
978
|
+
return payload;
|
|
979
|
+
}
|
|
980
|
+
/** The claims `applyJwtPayload` reads; a claim of another type is absent (old tokens predate several of them). */
|
|
981
|
+
const sessionClaimsSchema = z.looseObject({
|
|
982
|
+
email: z.string().optional().catch(undefined),
|
|
983
|
+
name: z.string().optional().catch(undefined),
|
|
984
|
+
slug: z.string().optional().catch(undefined),
|
|
985
|
+
org: z.string().optional().catch(undefined),
|
|
986
|
+
sessionId: z.string().optional().catch(undefined)
|
|
987
|
+
});
|
|
988
|
+
function applyJwtPayload(locals, payload) {
|
|
989
|
+
const agentPrincipal = authenticatedAgentPrincipalSchema.safeParse(payload.agentPrincipal);
|
|
990
|
+
const claims = sessionClaimsSchema.parse(payload);
|
|
991
|
+
const user = {
|
|
992
|
+
id: payload.sub,
|
|
993
|
+
email: claims.email ?? '',
|
|
994
|
+
// Display name from auth-web's `definePayload`. Old JWTs predating the
|
|
995
|
+
// claim fall through to undefined until the next sign-in / 15m refresh.
|
|
996
|
+
name: claims.name,
|
|
997
|
+
// User handle (slug) from `definePayload`. Consumers (forge user-repo
|
|
998
|
+
// namespace → `git.vibes.dev/~<slug>/<repo>`) read it off locals. Absent
|
|
999
|
+
// on tokens predating the claim → undefined (provider falls back to id).
|
|
1000
|
+
slug: claims.slug !== undefined && claims.slug.length > 0 ? claims.slug : undefined,
|
|
1001
|
+
orgId: claims.org,
|
|
1002
|
+
// Org-membership claim — set exclusively by auth-web's `definePayload`
|
|
1003
|
+
// (the single seam). Consumer apps (e.g. git-web's
|
|
1004
|
+
// `getRepositoryPermission`) read this off `event.locals.user.orgs`
|
|
1005
|
+
// instead of querying account-web per request. Defaults to `[]` for
|
|
1006
|
+
// tokens issued before the claim existed.
|
|
1007
|
+
orgs: normalizeOrgClaims(payload.orgs),
|
|
1008
|
+
roles: Array.isArray(payload.roles) ? payload.roles : undefined,
|
|
1009
|
+
// Admin-gate booleans — auth-web's JWT `definePayload` sets these from
|
|
1010
|
+
// the `staff` / `is_superuser` columns. `requireAdminScope` reads them
|
|
1011
|
+
// directly off `event.locals.user`. Old JWTs that predate the claim
|
|
1012
|
+
// fall through to `false`, so users issued tokens before the auth-web
|
|
1013
|
+
// deploy lose admin access until their next sign-in or 15m refresh.
|
|
1014
|
+
staff: payload.staff === true,
|
|
1015
|
+
isSuperuser: payload.isSuperuser === true
|
|
1016
|
+
};
|
|
1017
|
+
locals.user = agentPrincipal.success ? { ...user, agentPrincipal: agentPrincipal.data } : user;
|
|
1018
|
+
locals.session = {
|
|
1019
|
+
id: claims.sessionId,
|
|
1020
|
+
validUntil: payload.exp
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
function extractBearerToken(header) {
|
|
1024
|
+
if (!header)
|
|
1025
|
+
return null;
|
|
1026
|
+
// RFC 6750 Bearer auth: `Authorization: Bearer <token>`. Allow any
|
|
1027
|
+
// whitespace between scheme and token; tolerate leading/trailing space
|
|
1028
|
+
// on the token itself. Match scheme case-insensitively per the RFC.
|
|
1029
|
+
const match = header.match(/^\s*Bearer\s+(.+?)\s*$/i);
|
|
1030
|
+
if (!match)
|
|
1031
|
+
return null;
|
|
1032
|
+
const token = match[1].trim();
|
|
1033
|
+
return token.length > 0 ? token : null;
|
|
1034
|
+
}
|
|
1035
|
+
function hasRefreshSessionCookie(headers) {
|
|
1036
|
+
const cookieHeader = headers.get('cookie');
|
|
1037
|
+
if (!cookieHeader)
|
|
1038
|
+
return false;
|
|
1039
|
+
for (const part of cookieHeader.split(';')) {
|
|
1040
|
+
const name = part.trim().split('=', 1)[0];
|
|
1041
|
+
if (REFRESH_SESSION_COOKIE_NAMES.has(name))
|
|
1042
|
+
return true;
|
|
1043
|
+
}
|
|
1044
|
+
return false;
|
|
1045
|
+
}
|
|
1046
|
+
function upsertRequestCookie(runtime, headers, name, value) {
|
|
1047
|
+
const cookieHeader = headers.get('cookie') ?? '';
|
|
1048
|
+
const parts = cookieHeader
|
|
1049
|
+
.split(';')
|
|
1050
|
+
.map((part) => part.trim())
|
|
1051
|
+
.filter((part) => part.length > 0 && part.split('=', 1)[0] !== name);
|
|
1052
|
+
parts.push(`${name}=${value}`);
|
|
1053
|
+
// Best-effort: some runtimes expose immutable request headers. The response cookie
|
|
1054
|
+
// still refreshes the browser; this mutation only helps same-request
|
|
1055
|
+
// server-to-server calls forward the fresh JWT.
|
|
1056
|
+
const written = attemptSync(() => headers.set('cookie', parts.join('; ')));
|
|
1057
|
+
if (!written.ok)
|
|
1058
|
+
getLogger('auth.jwt-session', runtime).debug('Request headers are immutable here; the refreshed cookie was not set on them', { failure: failureLabel(written.failure) });
|
|
1059
|
+
}
|
|
1060
|
+
// A cross-subdomain FIRST request carries no host-scoped `vibes.jwt` yet, so it
|
|
1061
|
+
// ALWAYS lands in this refresh path — and the JWT mint depends on a session read
|
|
1062
|
+
// against a possibly-cold D1. That read races: observed in prod as GET
|
|
1063
|
+
// auth.vibes.dev/api/auth/token → 401 → 401 → 200 within ~120ms (the session row
|
|
1064
|
+
// resolves on a warm retry). A single-attempt refresh turned that transient into
|
|
1065
|
+
// `locals.user = null` → the user's FIRST action ("send a message") 401'd
|
|
1066
|
+
// "Authentication required", then a manual re-send worked. Retry the session read a
|
|
1067
|
+
// few times on a transient (non-ok / network) failure so the first request
|
|
1068
|
+
// resolves cleanly. A clean `{ authenticated: false }` (genuine no-session) is NOT
|
|
1069
|
+
// retried. See docs/audits + reference_auth_cold_start_hang_waituntil.
|
|
1070
|
+
const SESSION_REFRESH_MAX_ATTEMPTS = 3;
|
|
1071
|
+
const SESSION_REFRESH_RETRY_BACKOFF_MS = 120;
|
|
1072
|
+
/** HTTP statuses from /api/session that plausibly reflect a cold-start/session race, not a real deny. */
|
|
1073
|
+
const RETRYABLE_SESSION_REFRESH_STATUSES = new Set([401, 408, 425, 429, 500, 502, 503, 504]);
|
|
1074
|
+
/** What `/api/session` answers: whether there is a session, and its JWT when the mint succeeded. */
|
|
1075
|
+
const sessionRefreshBodySchema = z.looseObject({
|
|
1076
|
+
authenticated: z.boolean().optional().catch(undefined),
|
|
1077
|
+
jwt: z.string().optional().catch(undefined)
|
|
1078
|
+
});
|
|
1079
|
+
/** One `/api/session` attempt: a refreshed token, no session, or a transient answer worth retrying. */
|
|
1080
|
+
async function refreshOnce(input, url, attemptNumber, logger) {
|
|
1081
|
+
const controller = new AbortController();
|
|
1082
|
+
const disarm = input.runtime.lifecycle.timeout(() => controller.abort(), input.timeoutMs);
|
|
1083
|
+
try {
|
|
1084
|
+
const response = await input.fetcher(url, {
|
|
1085
|
+
headers: {
|
|
1086
|
+
accept: 'application/json',
|
|
1087
|
+
cookie: input.requestHeaders.get('cookie') ?? ''
|
|
1088
|
+
},
|
|
1089
|
+
signal: controller.signal
|
|
1090
|
+
});
|
|
1091
|
+
if (!response.ok) {
|
|
1092
|
+
// Only a transient status warrants a retry; anything else is a real refusal.
|
|
1093
|
+
if (attemptNumber < SESSION_REFRESH_MAX_ATTEMPTS &&
|
|
1094
|
+
RETRYABLE_SESSION_REFRESH_STATUSES.has(response.status)) {
|
|
1095
|
+
logger.warn('[sessionHandle] session refresh transient non-ok; retrying', {
|
|
1096
|
+
status: response.status,
|
|
1097
|
+
attempt: attemptNumber
|
|
1098
|
+
});
|
|
1099
|
+
return { kind: 'retry' };
|
|
1100
|
+
}
|
|
1101
|
+
return { kind: 'none' };
|
|
1102
|
+
}
|
|
1103
|
+
const body = sessionRefreshBodySchema.safeParse(await response.json());
|
|
1104
|
+
// A clean authenticated:false is a genuine no-session — never retry it.
|
|
1105
|
+
// (auth-web returns 200 {authenticated:false} for both a real logout AND a
|
|
1106
|
+
// swallowed transient session read, so we can't distinguish here — the source
|
|
1107
|
+
// fix in getAuthSessionState retries the null-with-cookie read instead.)
|
|
1108
|
+
if (!body.success || body.data.authenticated !== true)
|
|
1109
|
+
return { kind: 'none' };
|
|
1110
|
+
// authenticated:true but NO jwt = the token MINT transiently failed
|
|
1111
|
+
// (auth-web getToken swallows its own mint error into null), NOT a real no-session. The user
|
|
1112
|
+
// IS logged in; retry to obtain their token rather than nulling them → 401.
|
|
1113
|
+
const jwt = body.data.jwt;
|
|
1114
|
+
if (jwt === undefined || jwt.length === 0) {
|
|
1115
|
+
if (attemptNumber < SESSION_REFRESH_MAX_ATTEMPTS) {
|
|
1116
|
+
logger.warn('[sessionHandle] session authenticated but token mint empty; retrying', {
|
|
1117
|
+
attempt: attemptNumber
|
|
1118
|
+
});
|
|
1119
|
+
return { kind: 'retry' };
|
|
1120
|
+
}
|
|
1121
|
+
return { kind: 'none' };
|
|
1122
|
+
}
|
|
1123
|
+
const payload = await verifyAuthJwt(jwt, input.authOrigin, input.jwksFetcher, {
|
|
1124
|
+
viaServiceBinding: input.viaServiceBinding === true,
|
|
1125
|
+
jwksFetchTimeoutMs: input.jwksFetchTimeoutMs,
|
|
1126
|
+
runtime: input.runtime
|
|
1127
|
+
});
|
|
1128
|
+
const cookieDomain = resolveCookieDomain(input.authOrigin);
|
|
1129
|
+
const cookie = {
|
|
1130
|
+
httpOnly: true,
|
|
1131
|
+
sameSite: input.requestUrl.protocol === 'https:' ? 'none' : 'lax',
|
|
1132
|
+
secure: input.requestUrl.protocol === 'https:',
|
|
1133
|
+
path: '/',
|
|
1134
|
+
maxAge: JWT_MAX_AGE_SECONDS
|
|
1135
|
+
};
|
|
1136
|
+
if (cookieDomain)
|
|
1137
|
+
cookie.domain = cookieDomain;
|
|
1138
|
+
input.setCookie(JWT_COOKIE_NAME, jwt, cookie);
|
|
1139
|
+
return { kind: 'refreshed', value: { token: jwt, payload } };
|
|
1140
|
+
}
|
|
1141
|
+
finally {
|
|
1142
|
+
disarm();
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
async function refreshJwtFromAuthSession(input) {
|
|
1146
|
+
const url = new URL('/api/session', resolveLocalAuthOrigin(input.authOrigin));
|
|
1147
|
+
if (input.clientName)
|
|
1148
|
+
url.searchParams.set('client', input.clientName);
|
|
1149
|
+
const logger = getLogger(`${input.clientName || 'app'}.session`, input.runtime);
|
|
1150
|
+
for (let attemptNumber = 1; attemptNumber <= SESSION_REFRESH_MAX_ATTEMPTS; attemptNumber += 1) {
|
|
1151
|
+
const step = await attempt(() => refreshOnce(input, url, attemptNumber, logger));
|
|
1152
|
+
if (step.ok) {
|
|
1153
|
+
if (step.value.kind === 'refreshed')
|
|
1154
|
+
return step.value.value;
|
|
1155
|
+
if (step.value.kind === 'none')
|
|
1156
|
+
return null;
|
|
1157
|
+
}
|
|
1158
|
+
else {
|
|
1159
|
+
rethrowIfBlacklistUnavailable(step.failure);
|
|
1160
|
+
// Network / abort (cold-start timeout) — retry unless this was the last attempt.
|
|
1161
|
+
if (attemptNumber >= SESSION_REFRESH_MAX_ATTEMPTS)
|
|
1162
|
+
return rethrowFailure(step.failure);
|
|
1163
|
+
logger.warn('[sessionHandle] session refresh threw; retrying', {
|
|
1164
|
+
failure: failureLabel(step.failure),
|
|
1165
|
+
attempt: attemptNumber
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
await input.runtime.lifecycle.delay(SESSION_REFRESH_RETRY_BACKOFF_MS * attemptNumber);
|
|
1169
|
+
}
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
function resolveCookieDomain(authOrigin) {
|
|
1173
|
+
const hostname = new URL(authOrigin).hostname;
|
|
1174
|
+
if (hostname === 'localhost' ||
|
|
1175
|
+
/^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname) ||
|
|
1176
|
+
hostname.includes(':')) {
|
|
1177
|
+
return undefined;
|
|
1178
|
+
}
|
|
1179
|
+
const parts = hostname.split('.').filter(Boolean);
|
|
1180
|
+
if (parts.length < 2)
|
|
1181
|
+
return undefined;
|
|
1182
|
+
return `.${parts.slice(-2).join('.')}`;
|
|
1183
|
+
}
|
|
1184
|
+
//# sourceMappingURL=jwt-session-handle.js.map
|