This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Node 16 is required. Always use Node 16 before running any command - some native dependencies (e.g. phantomjs-prebuilt) only compile on Node 16. The .nvmrc pins this.
nvm use # picks up .nvmrc → node 16If nvm is not available, verify with node --version before installing or running tests.
npm install # install deps (use npm, not yarn)
npm test # run all unit + integration tests (tape runner)
npm run lint # ESLint
# Run a single test file (tape has no built-in filter):
node test/unit/grant-manager-unit-test.js
node test/unit/keycloak-object-test.jsIntegration tests (test/grant-manager-spec.js, test/keycloak-connect-*-spec.js) require a live Keycloak server. Unit tests under test/unit/ run standalone.
This is the Smartling fork of the upstream Keycloak Node.js adapter (@smartling/keycloak-connect). It exposes an Express/Connect middleware that handles SSO via Keycloak.
| File | Role |
|---|---|
grant-manager.js |
Central orchestrator. Obtains, validates, refreshes, and stores grants. The most complex file - contains token refresh deduplication logic. |
grant.js |
Represents a set of tokens (access + refresh + id). |
token.js |
Wraps a single JWT: decoding, expiry checks, signature validation. |
config.js |
Parses keycloak.json config. |
rotation.js |
Fetches and caches Keycloak public keys for signature rotation. |
Each file is a discrete middleware function mounted by index.js:
protect.js- route guard (enforces authentication/role)grant-attacher.js- attaches an existing grant toreq.kauthpost-auth.js- handles the OAuth redirect callbacklogout.js- session logoutsetup.js/admin.js- Keycloak-initiated flows
Three interchangeable backends for persisting the grant between requests:
session-store.js(default, Express session)cookie-store.jsbearer-store.js(stateless, reads Authorization header)
index.js exports the Keycloak class, which wires all middleware together and exposes .middleware() for mounting on an Express app.
Publishes to Smartling's internal Artifactory npm registry (configured in publishConfig in package.json). Bump the version in package.json before publishing.