splitToken()function
splitToken(token: string, caller: AnyCaller = splitToken): TokenData
| Param | Type | |
|---|---|---|
token | string | The JWT string to split and decode. required |
caller | AnyCaller | Identity of the calling function for error attribution. Defaults to splitToken |
| Throws | |
|---|---|
unknown | UnauthorizedError If the token is malformed, or its segments are not valid Base64URL-encoded JSON. |
Split a JSON Web Token into its header, payload, and signature, and decode and parse the JSON.
- Does not verify the signature — use
verifyToken()for that.
Examples
splitToken("aaa.bbb.ccc") // { header, payload, signature, headerData, payloadData, signatureBytes }