Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"dev": "parallelshell \"node-dev ./example/server.js\" \"gulp dev\"",
"build": "node build/build.js && cp ./dist/vue-authenticate.js ./example/"
},
"typings": "types/index.d.ts",
"files": [
"types/*.d.ts"
],
"keywords": [
"vue",
"vuejs",
Expand Down
69 changes: 69 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import './vue';
import Vue, { ComponentOptions, PluginFunction, AsyncComponent, VueConstructor } from 'vue';
import { AxiosResponse, AxiosRequestConfig } from 'axios';

export default function plugin(Vue: VueConstructor, options?: any): void;

export interface AuthenticateOptions {
baseUrl?: string;
tokenName?: string;
tokenPrefix?: string;
tokenHeader?: string;
tokenType?: string;
loginUrl?: string;
registerUrl?: string;
logoutUrl?: string;
storageType?: string;
storageNamespace?: string;
cookieStorage?: CookieStorageOptions,
requestDataKey?: string;
responseDataKey?: string;
withCredentials?: boolean;
bindRequestInterceptor?: ($auth: VueAuthenticate) => void;
providers: { [key: string]: ProviderOptions };
}

export interface CookieStorageOptions {
domain?: string;
path?: string;
secure?: boolean;
}

export interface ProviderOptions {
name?: string;
url?: string;
clientId?: string;
authorizationEndpoint?: string;
redirectUri?: string;
requiredUrlParams?: string[];
defaultUrlParams?: string[];
optionalUrlParams?: string[];
scope?: string[];
scopePrefix?: string;
scopeDelimiter?: string;
state?: string;
display?: string;
oauthType?: string;
responseType?: string;
responseParams?: {
code?: string;
clientId?: string;
redirectUri?: string;
};
popupOptions?: {
width: number;
height: number;
};
}

export declare class VueAuthenticate {
public constructor($http: AxiosInstance, overrideOptions?: AuthenticateOptions);
Copy link

Choose a reason for hiding this comment

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

May it be that line 3 has to be: import { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios';

public login(user: Object): Promise<AxiosResponse>;
public login(user: Object, requestOptions: AxiosRequestConfig): Promise<AxiosResponse>;
public isAuthenticated(): boolean;
public getToken(): string;
public setToken(token: string|object): void;
public register(user: any, requestOptions?: AxiosRequestConfig): Promise<AxiosResponse>;
public logout(requestOptions?: AxiosRequestConfig): Promise<AxiosResponse>;
public authenticate(provider: string, userData: any, requestOptions?: AxiosRequestConfig): Promise<{}>
}
7 changes: 7 additions & 0 deletions types/vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { VueAuthenticate } from 'vue-authenticate';
Copy link

Choose a reason for hiding this comment

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

Looks like import Vue from "vue"; is missing here.


declare module 'vue/types/vue' {
interface Vue {
$auth: VueAuthenticate;
}
}