import { JwtPayload } from 'jsonwebtoken'; import { JwtKeyMapping } from './jwt'; /** * Representation of the user i.e. authenticated persona. The authentication is done by the XSUAA. */ export interface UserData { id: string; userName: string; givenName?: string; familyName?: string; email?: string; scopes: Scope[]; customAttributes: Map; } /** * Representation of the user i.e. authenticated persona. The authentication is done by the XSUAA. */ export interface User extends UserData { hasScope: (scope: Scope) => boolean; } /** * Extracts the custom attributes from the JWT. * @param jwtPayload - Token payload to read the custom attributes from. * @returns Custom attributes added by the XSUAA service to the issued JWT. */ export declare function customAttributes(jwtPayload: JwtPayload): Map; /** * Mapping between key name in the User and key name in decoded JWT and the */ export declare const mappingUserFields: JwtKeyMapping; /** * Get the user's given name from the JWT payload. * @param jwtPayload - Token payload to read the user's given name from. * @returns The user's given name if available. */ export declare function userGivenName(jwtPayload: JwtPayload): string | undefined; /** * Get the user's family name from the JWT payload. * @param jwtPayload - Token payload to read the user's family from. * @returns The user's family name if available. */ export declare function userFamilyName(jwtPayload: JwtPayload): string | undefined; /** * Get the user name from the JWT payload. * @param jwtPayload - Token payload to read the user name from. * @returns The user name if available. */ export declare function userName(jwtPayload: JwtPayload): string | undefined; /** * Get the user's e-mail address from the JWT payload. * @param jwtPayload - Token payload to read the user e-mail address from. * @returns The user's e-mail address if available. */ export declare function userEmail(jwtPayload: JwtPayload): string | undefined; /** * Get the user's scopes from the JWT payload. * @param jwtPayload - Token payload to read the user's scopes from. * @returns The user's scopes if available. */ export declare function userScopes(jwtPayload: JwtPayload): Scope[]; /** * Get the user id from the JWT payload. * @param jwtPayload - Token payload to read the user id from. * @returns The user id if available. */ export declare function userId(jwtPayload: JwtPayload): string | undefined; /** * @deprecated Since v1.46.0. This interface will not be replaced. Use the higher level JWT types directly. * Keys in the JWT related to the user. */ export interface RegisteredJWTClaimsUser { user_id?: string; user_name?: string; given_name?: string; family_name?: string; email?: string; scope?: string[]; 'xs.user.attributes'?: Map; } /** * Representation of the scope. A scope is assigned to a user via role-collection in cloud foundry. */ export interface Scope { name: string; } /** * Creates a user object from the decoded JWT. * Throws an error if no `id` or `userName` property is present on the JWT payload. * @param jwtPayload - Token payload to get the user from. * @returns Representation of the user. */ export declare function userFromJwt(jwtPayload: JwtPayload): User; //# sourceMappingURL=user.d.ts.map