Installation
Installation
Prerequisites
| Dependency | Minimum version |
|---|---|
| Node.js | 20 |
ioserver | 2.0.0 |
| TypeScript | 5.0 |
ioserver must be installed in your project first — ioserver-oidc declares it as a peer dependency. See the IOServer installation guide if you have not set up an IOServer project yet.
Install the package
# pnpm (recommended)
pnpm add ioserver-oidc
# npm
npm install ioserver-oidc
# yarn
yarn add ioserver-oidc
jose is bundled as a direct dependency — no extra installation is required.
TypeScript configuration
ioserver-oidc is an ESM-only package. Your tsconfig.json must target ES2020 or later and use "module": "NodeNext" or "module": "ESNext":
{
"compilerOptions": {
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true
}
}
If your IOServer project uses "module": "commonjs" (default in many templates), you have two options:
- Migrate to ESM — Change
"type": "module"inpackage.jsonand updatetsconfig.json. See the Node.js ESM guide. - Use dynamic import — Import
ioserver-oidcvia a dynamicimport()call at startup, which works in CommonJS projects.
Environment variables
OidcConfigManager reads the following variables at startup. Set them in your .env file or deployment environment:
# Required
AUTH_SERVICE_URL=https://auth.example.com
AUTH_SERVICE_APP_SLUG=my-app
# Optional — override auto-discovered endpoints
AUTH_SERVICE_JWKS_URI=https://auth.example.com/api/auth/jwks
AUTH_SERVICE_ISSUER=https://auth.example.com
| Variable | Required | Description |
|---|---|---|
AUTH_SERVICE_URL | Yes | Public base URL of your auth-service instance |
AUTH_SERVICE_APP_SLUG | Yes | OAuth2 client_id / application slug registered in auth-service |
AUTH_SERVICE_JWKS_URI | No | Override the JWKS endpoint (default: <AUTH_SERVICE_URL>/api/auth/jwks) |
AUTH_SERVICE_ISSUER | No | Override the expected iss claim (default: AUTH_SERVICE_URL) |
Variables are read once at server startup by OidcConfigManager.start(). If OidcConfigManager is not registered, the middlewares read them lazily on the first request without caching between restarts — registering the manager is strongly recommended.