npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@haneinfo/iam-keycloak

v0.3.5

Published

Keycloak backend IAM profile implementing @haneinfo/plugin-api IamProfilePort.

Readme

@haneinfo/iam-keycloak

Keycloak 26.8.2 backend IamProfilePort implementation for @haneinfo/plugin-api.

Usage

import { createKeycloakIamProfile } from '@haneinfo/iam-keycloak';
import { validateTokenTimestamps } from '@haneinfo/plugin-api';

const profile = createKeycloakIamProfile({
  deployment,
  // Optional: custom fetch or discovery timeout (default: globalThis.fetch, 5000ms)
});

const metadata = await profile.getTrustedMetadata();
const claims = profile.normalizeClaims('web', rawPayload, rawHeader);

// Time window checks (iat / exp bounds and clock tolerance) are NOT performed by
// normalizeClaims; consumers must run validateTokenTimestamps from @haneinfo/plugin-api.
const timeResult = validateTokenTimestamps({
  iat: claims.issuedAt,
  exp: claims.expiresAt,
  nowSeconds: Math.floor(Date.now() / 1000),
});

Error Handling

normalizeClaims throws when a token header or payload violates the Keycloak IAM contract. Consumers must not depend on KeycloakClaimsRejectedError or inspect its reason field for control flow; treat any thrown error from normalizeClaims as invalid_token.

Runtime Constraints

  • Pure Node.js (>=22.0.0), CommonJS.
  • Runtime dependencies are restricted to @haneinfo/plugin-api and Node built-ins (globalThis.fetch, AbortSignal.timeout).
  • Never reads or forwards IAM role/group claims (realm_access, resource_access, groups).

Token Exchange (KeycloakTokenExchangeProvider)

@haneinfo/iam-keycloak also exports KeycloakTokenExchangeProvider and KeycloakTokenExchangeProviderConfig from the root entry point, implementing @haneinfo/plugin-api's TokenExchangeProvider (IAM_TOKEN_EXCHANGE).

  • No plugin registration yet: @haneinfo/iam-keycloak/plugin intentionally does not provide haneinfo.iam-token-exchange. Cross-app delegation (O3) is disabled by default and will only be integrated in a pilot app after O3 conformance is accepted.

Web Profile (@haneinfo/iam-keycloak/web)

@haneinfo/iam-keycloak/web is a server-only entry point exporting createKeycloakWebProfile(options?), which implements @haneinfo/plugin-api's IamWebProfile for @haneinfo/frontend-auth:

import { createFrontendAuth } from '@haneinfo/frontend-auth/server';
import { createKeycloakWebProfile } from '@haneinfo/iam-keycloak/web';

export const auth = createFrontendAuth({
  webProfile: createKeycloakWebProfile(),
  iam: {
    issuer: process.env.IAM_ISSUER!,
    clientId: process.env.IAM_WEB_CLIENT_ID!,
    clientSecret: process.env.IAM_WEB_CLIENT_SECRET!,
  },
});
  • Uses profileId: 'keycloak' and fixed callbackId: 'iam' (/api/auth/callback/iam).
  • Defaults scopes to 'openid profile email' and enables ['pkce', 'state'] checks.
  • Resolves token_endpoint and end_session_endpoint from ${issuer}/.well-known/openid-configuration with verbatim issuer verification and without caching failed discovery responses.
  • Does not import NestJS or zod at runtime.

Provisioner (@haneinfo/iam-keycloak/provisioner)

createKeycloakIamProvisioner(options?) implements @haneinfo/plugin-api's IamProvisioner (plan, apply with dryRun, drift) for an existing Keycloak 26.8.2 realm, using a service-account client with the realm-management roles manage-clients, manage-realm, view-clients and view-realm plus the kc-admin-api client scope. The full rules are in the haneinfo-packages specs, iam-contract section 8.1.

It manages:

  • Per app: one client scope per manifest scope (with a single-resource audience mapper, plus auth_time, amr and acr mappers on admin scopes), realm default optional client scopes, and the confidential Web client (never its secret).

  • MCP connector objects (tagged haneinfo.managed-by=haneinfo-mcp):

    • the haneinfo-mcp-employee and haneinfo-mcp-admin browser flows (the admin flow requires OTP)
    • the haneinfo-cimd client profile and policy: CIMD metadata executor with the resource allow list, plus PKCE S256
    • the employee and admin flow-selection policies
    • the trusted CIMD clients derived from the HTTPS entries in the manifests' allowedClientIds

    Each trusted CIMD client is pre-registered with a real authorization request, using the first redirect_uris entry of its metadata document. The provisioner then sets minimum.acr.value=1, reduces the default scopes to basic and acr, attaches the resource scopes plus offline_access, and creates cimd-resource-indicator-* mappers with token claims disabled.

Rules:

  • Shared lists change only for the apps in the input. An app is removed only when listed in removedAppIds.
  • Same-name objects without the managed marker are conflicts: plan() reports them, and apply() fails before any write.
  • plan() and apply({ dryRun: true }) send only Admin REST GET requests. They never send the registration request.
  • The machine running the provisioner must reach the trusted clients' metadata hosts (for Claude, claude.ai).
  • It never changes the realm browserFlow, existing Web client flow overrides, the built-in offline_access scope, accounts or realm session settings.
  • Run apply() serially per realm: Keycloak replaces /client-policies/profiles and /client-policies/policies as whole documents. Although apply() re-reads and re-merges against the latest realm document up to 3 attempts before each whole-document PUT, callers/CI jobs targeting the same realm must serialize apply() runs.

pnpm test:keycloak runs the disposable-Keycloak acceptance (Docker, outbound HTTPS to claude.ai; set HANEINFO_DEV_REALM_JSON when the dev-infra realm JSON is not at ../dev-infra/keycloak/haneinfo-dev-realm.json).