Skip to content

@nogoo9/no-crd / index / extractUserIdentity

Function: extractUserIdentity() ​

extractUserIdentity(jwtPayload, jsonPathExpr?): string

Defined in: src/auth/jwt-parser.ts:15

Extracts the user sub/identity identifier from a decrypted JWT payload object. Evaluates the specified JsonPath expression (e.g. "$.sub" or "$.identity") against the payload.

Parameters ​

jwtPayload ​

unknown

Decrypted JWT payload dictionary.

jsonPathExpr? ​

string = "$.sub"

JSONPath expression specifying where the identity claim resides. Defaults to "$.sub".

Returns ​

string

The resolved identity string.

Throws ​

An Error if the identity claim is missing or invalid.