5 min quickstart
Drop-in install.
Add the SDK in your client, the middleware on your server. That's it.
npm install @graypass/sdk
import { GrayPassV2 } from "@graypass/sdk";
// init returns a client instance - keep it around for the session lifetime
const gp = GrayPassV2.init({ apiKey: "pk_test_…" });
// startSession returns V2SessionStartResponse - snake_case fields, mirrors the JSON API.
const { session_id, enrolled, trust, state } = await gp.startSession({ userId: "user_42" });
gp.on("trust_change", ({ confidence, state, reasons }) => {
console.log("trust ->", confidence, state, reasons);
});
// when the user clicks "Open dashboard":
const verdict = await gp.authorize("dashboard.example.com", { minTrust: 0.7 });
if (verdict.authorized) {
document.cookie = `gp_token=${verdict.token}; Secure; SameSite=Lax`;
} else {
// verdict.fallback ∈ {step_up_required, re_authenticate, wait_for_trust, session_killed}
}