Bindings overview
Workflows
The kinde.idToken
binding lets you modify ID tokens for the current user. When you add custom claims, these are included in the ID token returned to the client.
setCustomClaim(name: string, value: any): void
Adds a custom claim to the ID token. The claim will be available when the token is returned to the client.
export const workflowSettings = { // ...other settings bindings: {"kinde.idToken": {}}};
The Kinde infrastructure library provides type-safe ID token modification:
import { idTokenCustomClaims } from "@kinde/infrastructure";
export default async function (event: onUserTokenGeneratedEvent) { const idToken = idTokenCustomClaims<{ userRole: string; lastLogin: string; }>();
idToken.userRole = "admin"; idToken.lastLogin = new Date().toISOString();};
If you’re not using the infrastructure library, you can modify the ID token directly:
kinde.idToken.setCustomClaim("userRole", "admin");kinde.idToken.setCustomClaim("lastLogin", new Date().toISOString());