Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update type definitions #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Vue imported here?

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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +76,7 @@ export function vuexOidcCreateStoreModule(

export function vuexOidcCreateNuxtRouterMiddleware(namespace?: string): any;

export function vuexOidcCreateRouterMiddleware(store: Store<any>, namespace?: string): any;
export function vuexOidcCreateRouterMiddleware(store: Store<any>, namespace?: string): NavigationGuard<Vue>;

export function vuexOidcProcessSilentSignInCallback(): Promise<void>;

Expand All @@ -99,29 +100,43 @@ export function vuexDispatchCustomBrowserEvent<T>(
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;
readonly oidcIdToken: string | null;
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<boolean>;
oidcCheckAccess: (route: VuexOidcRoute) => Promise<boolean>;
authenticateOidc: (payload?: string | { [key: string]: any }) => Promise<void>;
authenticateOidcSilent: (payload?: { options?: VuexOidcSigninSilentOptions }) => Promise<void>;
authenticateOidcSilent: (payload?: { options?: VuexOidcSigninSilentOptions }) => Promise<User | any>;
authenticateOidcPopup: (payload?: { options?: VuexOidcSigninPopupOptions }) => Promise<void>;
oidcSignInCallback: (url?: string) => Promise<string>;
oidcSignInPopupCallback: (url?: string) => Promise<User | undefined>;
oidcSignInCallback: (url?: string) => Promise<string | any>;
oidcSignInPopupCallback: (url?: string) => Promise<User | any>;
oidcWasAuthenticated: (user: User) => void;
getOidcUser: () => Promise<User>;
addOidcEventListener: (payload: {
Expand All @@ -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<void>;
storeOidcUser: (user: User) => void;
signOutOidc: (payload?: object) => Promise<void>;
signOutOidcCallback: () => Promise<SignoutResponse>;
signOutPopupOidc: (payload?: object) => Promise<void>;
signOutPopupOidcCallback: () => Promise<void>;
signOutOidcSilent: (payload?: object) => Promise<any>;
storeOidcUser: (user: User) => Promise<void>;
removeUser: () => void;
removeOidcUser: () => void;
clearStaleState: () => void;
removeOidcUser: () => Promise<void>;
clearStaleState: () => Promise<void>;
}

export interface VuexOidcStoreMutations {
Expand Down