01 · Guide

Six-Line Passkey Verification

Install @bastionid/sdk and verify WebAuthn assertions on any Edge, Node 20+, Bun, or Deno runtime.

src/auth/passkey.ts
import { Bastion } from "@bastionid/sdk";

const auth = new Bastion({ tenant: process.env.BASTION_TENANT });

export async function beginLogin(userId: string) {
  return auth.passkeys.begin({ userId, userVerification: "required" });
}

export async function finishLogin(assertionJson: string) {
  return auth.passkeys.verify(assertionJson, { attestation: "mds-strict" });
}

02 · Guide

Declarative SAML 2.0 Tenant Routing

Resolve enterprise identity providers automatically from the user's verified corporate email domain.

src/auth/sso.ts
export async function redirectEnterpriseUser(email: string) {
  const { authorizationUrl, connectionId } = await auth.saml.resolve({
    email,
    callbackUrl: "https://app.acme.com/auth/callback",
    requireSignedAssertion: true,
  });

  return Response.redirect(authorizationUrl, 302);
}

03 · Guide

Global Edge Session Revocation

Invalidate a compromised hardware credential or offboarded SCIM seat globally in under 12 milliseconds.

src/auth/revoke.ts
await auth.sessions.revoke({
  subjectId: "usr_01J9K8M2V4N",
  reason: "scim_deprovisioned",
  purgeHardwareKeys: true,
});

Deterministic Error Ledger

Code HTTP Condition
ERR_ATTESTATION_UNTRUSTED 403 Authenticator AAGUID failed FIDO MDS3 root certificate or revocation policy.
ERR_CHALLENGE_EXPIRED 401 Single-use WebAuthn challenge exceeded its 120-second cryptographic TTL.
ERR_SAML_ASSERTION_REPLAY 409 SAML AssertionID was already consumed within the sliding replay window.
ERR_ORIGIN_MISMATCH 400 clientDataJSON origin did not match the configured Relying Party ID.