Setup
1
Generate a signing key
2
Create the module
lib/kavach.ts
GetUserClaimsFn callback. KavachOS calls it to build ID tokens and userinfo responses. You control what data is returned per scope.3
Register a client
clientSecret is only returned on registration. It is stored hashed. If you lose it, delete and re-register the client.Configuration options
Authorization code flow
- Client redirects user to
{issuer}/authorizewithresponse_type=code,client_id,redirect_uri,scope, and optionallycode_challenge+code_challenge_method=S256. - Your app authenticates the user, then calls
oidc.authorize({ ...params, userId })to issue a code. - Client exchanges the code at
{issuer}/tokenforaccess_token,id_token, andrefresh_token. - Client can refresh tokens using
grant_type=refresh_token. Refresh tokens rotate on each use.
PKCE with
S256 is supported. If the authorization request includes a code_challenge, the token request must include the matching code_verifier. Authorization codes are single-use and expire after 10 minutes by default.