TokenHandler

Utility class meant to manage the user's accessToken, decodedToken & permissions

Type

class TokenHandler {
constructor(getter: IAuthUserInfoGetter)
getAccessToken = async (): Promise<string>;
getDecodedToken = async (): Promise<DecodedAccessToken>;
getPermissions = async (): Promise<CustomerPermission[]>;
getStatus = async (): Promise<Status>;
invalidate = () => void;
}

Properties

none

Methods

getAccessToken: Promise<string>promise that should resolve to the accessToken (string)
getDecodedToken: Promise<DecodedAccessToken>promise that should resolve to the DecodedAccessToken
getPermissions: Promise<CustomerPermission[]>promise that should resolve to CustomerPermission[]
getStatus: Promise<Status>promise that should resolve to the Status
invalidate(): () => voidA function to invalidate the token & put it into status: 'unauthenticated' state. Call this function when a non-expired accessToken was rejected with a 401, usually done inside of the ApolloClient. This typically happens when the authenticated user's session has ended.