AuthContextData

context data housing the auth information

Type

{
status: Status;
getAccessToken: () => Promise<string>;
getDecodedToken: () => Promise<DecodedAccessToken>;
getPermissions: () => Promise<CustomerPermission[]>;
decodedToken?: DecodedAccessToken;
permissions?: CustomerPermission[];
invalidate: () => void;
}

Properties

statusValue determining what state the AuthContext is in. not_initialized: means the TokenHandler has not yet started the authentication flow and should shortly. unauthenticated: means the IAuthUserInfoGetter tried to retrieve a token but the server returned a non 200 status code or TokenHandler.invalidate function was called, this should happen when the session has ended and the token is technically no longer valid. authenticated: TokenHandler was able to retrieve an accessToken & the exp claim is in the future.
decodedToken?: DecodedAccessTokenThe access token decoded to utilize it's properites*
permissions?: CustomerPermission[]The permissions for the authenticated user. The permissions are retreived using the sso instrospection endpoint, scope for you application must be set correctly*

*NOTE: decodedToken & permissions are the last cached values, for performance & security these are cached and not constantly re-validated and refreshed. Utilize their respective getter methods or utilize the AuthHandler's observables' if accurate values are required.

Methods

getAccessToken(): Promise<string>Retreive a non-expired accessToken. *
getDecodedToken(): Promise<DecodedAccessToken>Retreive a non-expired decodedToken. *
getPermissions(): Promise<CustomerPermission[]>Retrieve the authenticated users permissions. *
invalidate(): () => voidA function to call TokenHandler.invalidate, see TokenHandler docs for additional information

*NOTE: when these methods are called the cached expiration date will be validated and if needed a new token, decodedToken & permissions will be fetched.