UNPKG

@guardian/pan-domain-node

Version:

NodeJs implementation of Guardian pan-domain auth verification

45 lines (44 loc) 1.3 kB
export { PanDomainAuthentication } from './panda'; export declare const gracePeriodInMillis: number; interface Result { success: boolean; } interface Success extends Result { success: true; shouldRefreshCredentials: boolean; user: User; } interface Failure extends Result { success: false; reason: string; } export interface FreshSuccess extends Success { shouldRefreshCredentials: false; } export interface StaleSuccess extends Success { shouldRefreshCredentials: true; mustRefreshByEpochTimeMillis: number; } export interface UserValidationFailure extends Failure { reason: 'invalid-user'; user: User; } export interface CookieFailure extends Failure { reason: 'no-cookie' | 'invalid-cookie' | 'expired-cookie'; } export interface UnknownFailure extends Failure { reason: 'unknown'; } export type AuthenticationResult = FreshSuccess | StaleSuccess | CookieFailure | UserValidationFailure | UnknownFailure; export interface User { firstName: string; lastName: string; email: string; avatarUrl?: string; authenticatingSystem: string; authenticatedIn: string[]; expires: number; multifactor: boolean; } export type ValidateUserFn = (user: User) => boolean; export declare function guardianValidation(user: User): boolean;