UNPKG

vuethenticate

Version:

A Vue 3 authentication state management library using oidc-client-ts

77 lines 2.56 kB
import { ComputedRef, Ref } from 'vue'; import { LogLevel, Logger } from '../utils/logger'; import { User } from 'oidc-client-ts'; export interface AuthConfig { authority: string; clientId: string; clientSecret?: string; clientAuthentication?: 'client_secret_basic' | 'client_secret_post'; redirectUri?: string; scope?: string; responseType?: string; storage?: 'localStorage' | 'sessionStorage' | 'memory'; automaticSilentRenew?: boolean; silentRedirectUri?: string; postLogoutRedirectUri?: string; logLevel?: LogLevel; logger?: Logger; onError?: (error: Error) => void; onUserLoaded?: (user: User) => void; onUserUnloaded?: () => void; onAccessTokenExpired?: () => void; onAccessTokenExpiring?: () => void; onSilentRenewError?: (error: Error) => void; } export interface AuthState { user: Ref<User | null>; isLoading: Ref<boolean>; isInitialized: Ref<boolean>; initError: Ref<Error | null>; authError: Ref<Error | null>; isAuthenticated: ComputedRef<boolean>; accessToken: ComputedRef<string | null>; isExpired: ComputedRef<boolean>; initializationPromise: Promise<void>; } export interface AuthMethods<TState = unknown> { signIn: (state?: TState) => Promise<void>; signOut: (state?: TState) => Promise<void>; silentRenew: () => Promise<void>; clearError: () => void; resetAuthState: () => Promise<void>; cleanup: () => void; } export interface AuthCallbackMethods<TState = unknown> { processCallback: (url?: string) => Promise<{ user: User; state?: TState; }>; processSilentCallback: (url?: string) => Promise<void>; } export interface UseAuthCallbacksReturn<TState = unknown> { processCallback: () => Promise<{ user: User; state?: TState; }>; processLogoutCallback: () => Promise<{ state?: TState; }>; processSilentCallback: () => Promise<void>; isInitialized: Ref<boolean>; isInitializing: Ref<boolean>; logger: Logger; } export type UseAuthReturn<TState = unknown> = AuthState & AuthMethods<TState>; export interface AuthCallbackProps<TState = unknown> { onSuccess?: (user: User, state?: TState) => void; onError?: (error: Error) => void; } export interface SilentCallbackProps { onError?: (error: Error) => void; } export interface LogoutCallbackProps<TState = unknown> { onSuccess?: (state?: TState) => void; onError?: (error: Error) => void; } export { User } from 'oidc-client-ts'; //# sourceMappingURL=auth.d.ts.map