diff --git a/index.d.ts b/index.d.ts index ab70cf4..c34a412 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,7 @@ -import { ActionContext, Module, Store } from 'vuex'; -import { OidcClientSettings, User, UserManager } from 'oidc-client'; -import { Route, RouteConfig } from 'vue-router'; +import Vue from 'vue' +import { Module, Store } from 'vuex'; +import { OidcClientSettings, User, UserManager, Profile, SignoutResponse } from 'oidc-client'; +import { Route, RouteConfig, NavigationGuard } from 'vue-router'; export interface VuexOidcClientSettings extends OidcClientSettings { authority: string; @@ -30,7 +31,7 @@ export interface VuexOidcSigninPopupOptions {} export interface VuexOidcStoreSettings { namespaced?: boolean; dispatchEventsOnWindow?: boolean; - isPublicRoute?: (route: Route) => boolean; + isPublicRoute?: (route: VuexOidcRoute) => boolean; publicRoutePaths?: string[]; routeBase?: string; defaultSigninRedirectOptions?: VuexOidcSigninRedirectOptions; @@ -75,7 +76,7 @@ export function vuexOidcCreateStoreModule( export function vuexOidcCreateNuxtRouterMiddleware(namespace?: string): any; -export function vuexOidcCreateRouterMiddleware(store: Store, namespace?: string): any; +export function vuexOidcCreateRouterMiddleware(store: Store, namespace?: string): NavigationGuard; export function vuexOidcProcessSilentSignInCallback(): Promise; @@ -99,12 +100,26 @@ export function vuexDispatchCustomBrowserEvent( params?: EventInit, ): any; +export interface VuexOidcRouteMeta { + isPublic?: boolean; + isOidcCallback?: boolean; + [propName: string]: unknown; +} + +export type VuexOidcRouteConfig = RouteConfig & { + meta?: VuexOidcRouteMeta; +} + +export interface VuexOidcRoute extends Route { + meta?: VuexOidcRouteMeta; +} + // The following types are not exposed directly, they are part of the store // and mostly for reference, or for use with vuex-class. export interface VuexOidcStoreGetters { readonly oidcIsAuthenticated: boolean; - readonly oidcUser: any | null; + readonly oidcUser?: Profile; readonly oidcAccessToken: string | null; readonly oidcAccessTokenExp: number | null; readonly oidcScopes: string[] | null; @@ -112,16 +127,16 @@ export interface VuexOidcStoreGetters { readonly oidcIdTokenExp: number | null; readonly oidcAuthenticationIsChecked: boolean | null; readonly oidcError: string | null; - readonly oidcIsRoutePublic: (route: RouteConfig) => boolean; + readonly oidcIsRoutePublic: (route: VuexOidcRouteConfig) => boolean; } export interface VuexOidcStoreActions { - oidcCheckAccess: (route: Route) => Promise; + oidcCheckAccess: (route: VuexOidcRoute) => Promise; authenticateOidc: (payload?: string | { [key: string]: any }) => Promise; - authenticateOidcSilent: (payload?: { options?: VuexOidcSigninSilentOptions }) => Promise; + authenticateOidcSilent: (payload?: { options?: VuexOidcSigninSilentOptions }) => Promise; authenticateOidcPopup: (payload?: { options?: VuexOidcSigninPopupOptions }) => Promise; - oidcSignInCallback: (url?: string) => Promise; - oidcSignInPopupCallback: (url?: string) => Promise; + oidcSignInCallback: (url?: string) => Promise; + oidcSignInPopupCallback: (url?: string) => Promise; oidcWasAuthenticated: (user: User) => void; getOidcUser: () => Promise; addOidcEventListener: (payload: { @@ -132,15 +147,15 @@ export interface VuexOidcStoreActions { eventName: string; eventListener: (...args: any[]) => void; }) => void; - signOutOidc: (payload?: object) => void; - signOutOidcCallback: () => void; - signOutPopupOidc: (payload?: object) => void; - signOutPopupOidcCallback: () => void; - signOutOidcSilent: (payload?: object) => Promise; - storeOidcUser: (user: User) => void; + signOutOidc: (payload?: object) => Promise; + signOutOidcCallback: () => Promise; + signOutPopupOidc: (payload?: object) => Promise; + signOutPopupOidcCallback: () => Promise; + signOutOidcSilent: (payload?: object) => Promise; + storeOidcUser: (user: User) => Promise; removeUser: () => void; - removeOidcUser: () => void; - clearStaleState: () => void; + removeOidcUser: () => Promise; + clearStaleState: () => Promise; } export interface VuexOidcStoreMutations {