Describe the bug
The TypeScript type definitions in keycloak-js (specifically in keycloak.d.ts) declare the amr (Authentication Methods References) claim as string | undefined, but Keycloak server actually returns it as a JSON array (string[]) per RFC 8176.
This causes TypeScript type mismatches / incorrect IntelliSense when accessing keycloak.tokenParsed.amr, even though the runtime value is correctly an array.
Version
keycloak-js 26.2.2
Expected behavior
Type definition is typed as an array of strings
Actual behavior
Type definition is typed as a string
How to Reproduce?
- Use Keycloak server (any recent version, e.g. 26.x) with an authentication flow that includes at least one authenticator reference, for example
pwd in Username Password Form.
- Initialize keycloak-js adapter in a TypeScript project:
import Keycloak from 'keycloak-js';
const keycloak = new Keycloak(/* config */);
await keycloak.init({ onLoad: true });
await keycloak.login();
- Observe TypeScript error / warning when trying to use array methods:
keycloak.tokenParsed?.amr.map((value) => console.log("AMR VALUE: ", value)); // TS error: Property 'map' does not exist on type 'string'
- After successful login, access the parsed token:
console.log(keycloak.tokenParsed?.amr); // runtime: ["pwd"]
console.log(Array.isArray(keycloak.tokenParsed?.amr)); // true
Anything else?
No response
Describe the bug
The TypeScript type definitions in
keycloak-js(specifically inkeycloak.d.ts) declare theamr(Authentication Methods References) claim asstring | undefined, but Keycloak server actually returns it as a JSON array (string[]) per RFC 8176.This causes TypeScript type mismatches / incorrect IntelliSense when accessing
keycloak.tokenParsed.amr, even though the runtime value is correctly an array.Version
keycloak-js 26.2.2
Expected behavior
Type definition is typed as an array of strings
Actual behavior
Type definition is typed as a string
How to Reproduce?
pwdin Username Password Form.Anything else?
No response