azure-b2c-auth-nextjs
Version:
Comprehensive Azure AD B2C Authentication Library for Next.js - Plug and Play Solution
67 lines (60 loc) • 1.56 kB
text/typescript
export interface B2CConfig {
tenantId: string;
clientId: string;
domain: string;
userFlow: string;
redirectUri: string;
postLogoutRedirectUri: string;
scope: string[];
authority?: string;
knownAuthorities?: string[];
cacheLocation?: 'localStorage' | 'sessionStorage';
storeAuthStateInCookie?: boolean;
}
export interface User {
name?: string;
email?: string;
givenName?: string;
surname?: string;
oid?: string;
sub?: string;
aud?: string;
iss?: string;
iat?: number;
exp?: number;
auth_time?: number;
[key: string]: any;
}
export interface AuthState {
isAuthenticated: boolean;
user: User | null;
accessToken: string | null;
idToken: string | null;
error: string | null;
loading: boolean;
}
export interface AuthContextType extends AuthState {
login: (options?: LoginOptions) => Promise<void>;
logout: () => Promise<void>;
getAccessToken: (scopes?: string[]) => Promise<string | null>;
refreshToken: () => Promise<void>;
}
export interface LoginOptions {
scopes?: string[];
extraQueryParameters?: Record<string, string>;
extraScopesToConsent?: string[];
prompt?: 'login' | 'none' | 'consent' | 'select_account';
loginHint?: string;
sid?: string;
domainHint?: string;
}
export interface ProtectedRouteProps {
children: React.ReactNode;
fallback?: React.ReactNode;
redirectTo?: string;
requiredScopes?: string[];
}
export interface AuthProviderProps {
config: B2CConfig;
children: React.ReactNode;
}