Skip to content

Commit 346f898

Browse files
authored
Fixes #3 Initial type.d.ts based on abeven's changes (#5)
1 parent 0063004 commit 346f898

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"module": "dist/vue-authenticate.esm.min.js",
66
"browser": "dist/vue-authenticate.umd.min.js",
77
"main": "dist/vue-authenticate.esm.min.js",
8+
"types": "types/index.d.ts",
9+
"typings": "types/index.d.ts",
810
"scripts": {
911
"build": "rollup -c",
1012
"lint": "eslint src",
@@ -33,7 +35,7 @@
3335
"url": "https://github.com/ajmas/vue-authenticate.git"
3436
},
3537
"files": [
36-
"dist"
38+
"dist", "types/index.d.ts"
3739
],
3840
"license": "MIT",
3941
"devDependencies": {

types/index.d.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios';
2+
3+
export interface CookieStorageOptions {
4+
domain?: string;
5+
path?: string;
6+
secure?: boolean;
7+
}
8+
9+
export interface ProviderOptions {
10+
name?: string;
11+
url?: string;
12+
clientId?: string;
13+
authorizationEndpoint?: string;
14+
redirectUri?: string;
15+
requiredUrlParams?: string[];
16+
defaultUrlParams?: string[];
17+
optionalUrlParams?: string[];
18+
scope?: string[];
19+
scopePrefix?: string;
20+
scopeDelimiter?: string;
21+
state?: string;
22+
display?: string;
23+
oauthType?: string;
24+
responseType?: string;
25+
responseParams?: {
26+
code?: string;
27+
clientId?: string;
28+
redirectUri?: string;
29+
};
30+
popupOptions?: {
31+
width: number;
32+
height: number;
33+
};
34+
}
35+
36+
export declare class VueAuthenticate {
37+
login(user: Object): Promise<AxiosResponse>;
38+
login(
39+
user: Object,
40+
requestOptions: AxiosRequestConfig
41+
): Promise<AxiosResponse>;
42+
isAuthenticated(): boolean;
43+
getToken(): string;
44+
setToken(token: string | object): void;
45+
register(
46+
user: any,
47+
requestOptions?: AxiosRequestConfig
48+
): Promise<AxiosResponse>;
49+
logout(requestOptions?: AxiosRequestConfig): Promise<AxiosResponse>;
50+
authenticate(
51+
provider: string,
52+
userData: any,
53+
requestOptions?: AxiosRequestConfig
54+
): Promise<{}>;
55+
}
56+
57+
export interface AuthenticateOptions {
58+
baseUrl?: string;
59+
axios?: AxiosInstance;
60+
tokenName?: string;
61+
tokenPrefix?: string;
62+
tokenHeader?: string;
63+
tokenType?: string;
64+
loginUrl?: string;
65+
registerUrl?: string;
66+
logoutUrl?: string;
67+
storageType?: string;
68+
storageNamespace?: string;
69+
cookieStorage?: CookieStorageOptions;
70+
requestDataKey?: string;
71+
responseDataKey?: string;
72+
withCredentials?: boolean;
73+
providers: { [key: string]: ProviderOptions };
74+
}
75+
76+
declare module "vue/types/vue" {
77+
interface Vue {
78+
$auth: VueAuthenticate;
79+
}
80+
}

0 commit comments

Comments
 (0)