yatta/oidc
OpenID Connect: ID tokens, discovery, JWKS, userinfo.
4 exported symbols and 11 members, read from src/func/oidc.ts.
Construct
createOIDC
functionBuild 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
interfaceWhat 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 OidcOptions7 members
issuerpropertyissuer: stringoauthpropertyoauth: { getAccessToken(token: string): AccessTokenInfo | null | Promise<AccessTokenInfo | null>; }findUserpropertyfindUser: (id: string) => Promise<OidcUser | null>privateKeyPempropertyprivateKeyPem?: stringidTokenTtlSecondspropertyidTokenTtlSeconds?: numbergrantTypespropertygrantTypes?: string[]codeChallengeMethodspropertycodeChallengeMethods?: string[]
OidcUser
interfaceThe parts of a user an ID token can carry.
interface OidcUser4 members
idpropertyid: stringemailpropertyemail?: stringemailVerifiedpropertyemailVerified?: booleannamepropertyname?: string
OIDC
typeThe object `createOIDC` returns.
type OIDC = ReturnType<typeof createOIDC>AuthConfig or JobPayload — declaring your schema once is enough for the rest to follow. See Typed keys.