API reference

yatta/oidc

OpenID Connect: ID tokens, discovery, JWKS, userinfo.

4 exported symbols and 11 members, read from src/func/oidc.ts.

Construct

createOIDC

function

Build the OpenID Connect endpoints over an existing OAuth server.

Mount `handleDiscovery` on `/.well-known/openid-configuration`, `handleJWKS` on `/oauth/jwks` and `handleUserinfo` on `/oauth/userinfo`, then hand `issueIdToken` to the OAuth server with `setIdTokenIssuer`, so a token reply carries an ID token.

createOIDC(options: OidcOptions)

Returns `issueIdToken`, plus the three HTTP handlers.

Types

OidcOptions

interface

What the OIDC layer needs from the app.

It adds three endpoints on top of the OAuth server — discovery, JWKS and userinfo — and one method, `issueIdToken`, that the OAuth server calls when a code is exchanged. Both objects share the same reading of who the user is; neither keeps its own copy.

interface OidcOptions

7 members

  • issuerproperty
    issuer: string
  • oauthproperty
    oauth: { getAccessToken(token: string): AccessTokenInfo | null | Promise<AccessTokenInfo | null>; }
  • findUserproperty
    findUser: (id: string) => Promise<OidcUser | null>
  • privateKeyPemproperty
    privateKeyPem?: string
  • idTokenTtlSecondsproperty
    idTokenTtlSeconds?: number
  • grantTypesproperty
    grantTypes?: string[]
  • codeChallengeMethodsproperty
    codeChallengeMethods?: string[]

OidcUser

interface

The parts of a user an ID token can carry.

interface OidcUser

4 members

  • idproperty
    id: string
  • emailproperty
    email?: string
  • emailVerifiedproperty
    emailVerified?: boolean
  • nameproperty
    name?: string

OIDC

type

The object `createOIDC` returns.

type OIDC = ReturnType<typeof createOIDC>
Tip
Most of the types above are inferred. You rarely import AuthConfig or JobPayload — declaring your schema once is enough for the rest to follow. See Typed keys.