8000 Wrong type definition for `amr` claim in parsed token · Issue #254 · keycloak/keycloak-js · GitHub
[go: up one dir, main page]

Skip to content

Wrong type definition for amr claim in parsed token #254

Description

@fcucino

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?

  1. 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.
  2. 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();
  3. 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'
  4. 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

Activity

  1. added a commit that references this issue on Jan 30, 2026
    879d672
  2. added theissue type on Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    Fields

    No fields configured for bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0