@alfresco/adf-core
Version:
109 lines (108 loc) • 3.28 kB
TypeScript
import * as i0 from "@angular/core";
export declare class JwtHelperService {
static USER_NAME: string;
static FAMILY_NAME: string;
static GIVEN_NAME: string;
static USER_EMAIL: string;
static USER_ACCESS_TOKEN: string;
static USER_ID_TOKEN: string;
static REALM_ACCESS: string;
static RESOURCE_ACCESS: string;
static USER_PREFERRED_USERNAME: string;
static HXP_AUTHORIZATION: string;
private storageService;
/**
* Decodes a JSON web token into a JS object.
*
* @param token Token in encoded form
* @returns Decoded token data object
*/
decodeToken(token: any): any;
private urlBase64Decode;
/**
* Gets a named value from the user access or id token.
*
* @param key Key name of the field to retrieve
* @returns Value from the token
*/
getValueFromLocalToken<T>(key: string): T;
/**
* Gets a named value from the user access token.
*
* @param key Key name of the field to retrieve
* @returns Value from the token
*/
getValueFromLocalAccessToken<T>(key: string): T;
/**
* Gets access token
*
* @returns access token
*/
getAccessToken(): string;
/**
* Gets a named value from the user id token.
*
* @param key Key name of the field to retrieve
* @returns Value from the token
*/
getValueFromLocalIdToken<T>(key: string): T;
/**
* Gets id token
*
* @returns id token
*/
getIdToken(): string;
/**
* Gets a named value from the user access token.
*
* @param token your SSO access token where the value is encode
* @param key Key name of the field to retrieve
* @returns Value from the token
*/
getValueFromToken<T>(token: string, key: string): T;
/**
* Gets realm roles.
*
* @returns Array of realm roles
*/
getRealmRoles(): string[];
/**
* Gets Client roles.
*
* @param clientName client name
* @returns Array of client roles
*/
getClientRoles(clientName: string): string[];
/**
* Checks for single realm role.
*
* @param role Role name to check
* @returns True if it contains given role, false otherwise
*/
hasRealmRole(role: string): boolean;
/**
* Checks for realm roles.
*
* @param rolesToCheck List of role names to check
* @returns True if it contains at least one of the given roles, false otherwise
*/
hasRealmRoles(rolesToCheck: string[]): boolean;
/**
* Checks for client roles.
*
* @param clientName Targeted client name
* @param rolesToCheck List of role names to check
* @returns True if it contains at least one of the given roles, false otherwise
*/
hasRealmRolesForClientRole(clientName: string, rolesToCheck: string[]): boolean;
/**
* Checks for client role.
*
* @param clientName Targeted client name
* @param role Role name to check
* @returns True if it contains given role, false otherwise
*/
hasClientRole(clientName: string, role: string): boolean;
static ɵfac: i0.ɵɵFactoryDeclaration<JwtHelperService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<JwtHelperService>;
}