import type { OAuthConfig } from '#auth-utils'; /** * Cloudflare OAuth provider — Authorization Code flow (the only flow Cloudflare supports). * * References: * - Endpoints: https://developers.cloudflare.com/fundamentals/oauth/integrate-with-cloudflare/ * - Flow/PKCE: https://developers.cloudflare.com/fundamentals/oauth/create-an-oauth-client/#supported-oauth-flows * - Scopes: https://developers.cloudflare.com/fundamentals/oauth/create-an-oauth-client/#select-scopes * * Scopes are dot-notation API-permission names (e.g. `workers-platform.read`) fetched from * `GET /client/v4/oauth/scopes` — `openid` is NOT a Cloudflare scope. PKCE (S256) is required * for public clients (auth method `none`) and optional for confidential clients (client secret). */ export interface OAuthCloudflareConfig { /** * Cloudflare OAuth Client ID * @default process.env.NUXT_OAUTH_CLOUDFLARE_CLIENT_ID */ clientId?: string; /** * Cloudflare OAuth Client Secret. Required for confidential clients * (`client_secret_post`/`client_secret_basic`); omit for public PKCE-only * clients (`token_endpoint_auth_method=none`). * @default process.env.NUXT_OAUTH_CLOUDFLARE_CLIENT_SECRET */ clientSecret?: string; /** * Cloudflare OAuth scopes — dot-notation API token permission IDs from * `GET /client/v4/oauth/scopes`, matching the scopes the client was registered with. * Cloudflare requires at least one; there is no default (`openid` is not a Cloudflare scope). * @see https://developers.cloudflare.com/fundamentals/oauth/create-an-oauth-client/#select-scopes * @example ['workers-platform.read'] */ scope?: string[]; /** * Cloudflare OAuth Authorization URL * @default 'https://dash.cloudflare.com/oauth2/auth' */ authorizationURL?: string; /** * Cloudflare OAuth Token URL * @default 'https://dash.cloudflare.com/oauth2/token' */ tokenURL?: string; /** * Cloudflare OIDC userinfo URL. Returns standard claims (`sub`, `iss`, `aud`, …); * use `GET /client/v4/user` for email/name. * @default 'https://dash.cloudflare.com/oauth2/userinfo' */ userURL?: string; /** * Extra authorization parameters to provide to the authorization URL */ authorizationParams?: Record; /** * Redirect URL to allow overriding for situations like prod failing to determine public hostname * @default process.env.NUXT_OAUTH_CLOUDFLARE_REDIRECT_URL or current URL */ redirectURL?: string; } /** * Claims returned by Cloudflare's `/oauth2/userinfo` endpoint. `sub` is the stable * Cloudflare user ID; the rest are standard OIDC token claims. There is no email/name * here — for richer profile data call `GET /client/v4/user` with the access token. */ export interface CloudflareUser { /** Stable Cloudflare user ID. */ sub: string; aud?: string[]; iss?: string; iat?: number; auth_time?: number; rat?: number; } export interface CloudflareTokens { access_token: string; token_type: string; expires_in: number; /** Present when scope includes `offline_access` */ refresh_token?: string; scope: string; } export declare function defineOAuthCloudflareEventHandler({ config, onSuccess, onError }: OAuthConfig): import("nuxt/server").EventHandler>;