Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
update plugin injection interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kreejzak committed Apr 6, 2023
1 parent 8a16fd8 commit 6235d90
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export interface Auth {
}

export interface CSRFSpec {
headerKey: string,
cookieKey: string,
headerKey: string
cookieKey: string
}

export type ApiFetch = (endpoint: FetchRequest, options?: FetchOptions) => Promise<void>
export type ApiFetch = (
endpoint: FetchRequest,
options?: FetchOptions
) => Promise<void>

export type Csrf = Promise<void>

Expand All @@ -41,7 +44,7 @@ export type Callback = (response: any) => void
export interface SanctumAuthPlugin {
login: (data: any, callback?: Callback | undefined) => Promise<void>
logout: (callback?: Callback | undefined) => Promise<void>
getUser<T> (): Promise<T | undefined>
getUser<T>(): Promise<T | undefined>
}

// @ts-ignore
Expand All @@ -53,17 +56,15 @@ declare module 'vue/types/vue' {

// Nuxt Bridge & Nuxt 3
declare module '#app' {
interface NuxtApp extends PluginInjection {
}
interface NuxtApp extends PluginInjection {}
}

interface PluginInjection {
$sanctumAuth: SanctumAuthPlugin
apiFetch: ApiFetch,
csrf: Csrf,
$apiFetch: ApiFetch
$csrf: Csrf
}

declare module '@vue/runtime-core' {
interface ComponentCustomProperties extends PluginInjection {
}
interface ComponentCustomProperties extends PluginInjection {}
}

0 comments on commit 6235d90

Please sign in to comment.