From 01e4d764405609593e41c16f5a6fb473e6686edf Mon Sep 17 00:00:00 2001 From: Abe Rodriguez Date: Thu, 20 Feb 2020 14:41:31 -0500 Subject: [PATCH 1/5] Added typescript definitions --- package.json | 1 + yarn.lock | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/package.json b/package.json index e34c109..5b42e1b 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "url": "https://github.com/dgrubelic/vue-authenticate.git" }, "files": ["dist"], + "types": "types/index.d.ts", "license": "MIT", "devDependencies": { "@babel/core": "^7.4.3", diff --git a/yarn.lock b/yarn.lock index 7bb49c4..dd5f71d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5438,11 +5438,6 @@ parallel-transform@^1.1.0: inherits "^2.0.3" readable-stream "^2.1.5" -parallelshell@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/parallelshell/-/parallelshell-3.0.1.tgz#0587ce1535350543916d8f3d329fbfa4a0355f22" - integrity sha512-xsSQGhJTFjbSW3WGsnSFTg1G17dcDU+gMH7bWxjAiy/3H579KPFbSp3fhkZ+jx2wcZuoav46nq+QVX0I0xPcyA== - parse-asn1@^5.0.0: version "5.1.4" resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.4.tgz#37f6628f823fbdeb2273b4d540434a22f3ef1fcc" From c69bd8840669706947c176dcf522ab835fcbcd3b Mon Sep 17 00:00:00 2001 From: Abe Rodriguez Date: Thu, 20 Feb 2020 14:44:55 -0500 Subject: [PATCH 2/5] Added typescript definitions --- types/index.d.ts | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 types/index.d.ts diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..b157109 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,86 @@ +import Vue from "vue"; +import { + ComponentOptions, + PluginFunction, + AsyncComponent, + VueConstructor +} from "vue"; +import { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios"; + +export default function plugin(Vue: VueConstructor, options?: any): void; + +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 interface VueAuthenticate { + login(user: Object): Promise; + login( + user: Object, + requestOptions: AxiosRequestConfig + ): Promise; + isAuthenticated(): boolean; + getToken(): string; + setToken(token: string | object): void; + register( + user: any, + requestOptions?: AxiosRequestConfig + ): Promise; + logout(requestOptions?: AxiosRequestConfig): Promise; + authenticate( + provider: string, + userData: any, + requestOptions?: AxiosRequestConfig + ): Promise<{}>; +} +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; + providers: { [key: string]: ProviderOptions }; +} + +declare module "vue/types/vue" { + export interface Vue { + $auth: VueAuthenticate; + } +} From ec5517d340ce9601c146756a032693466e91c92b Mon Sep 17 00:00:00 2001 From: Abe Rodriguez Date: Thu, 20 Feb 2020 14:46:11 -0500 Subject: [PATCH 3/5] Add typescript definitions --- package.json | 1 + types/index.d.ts | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ yarn.lock | 5 --- 3 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 types/index.d.ts diff --git a/package.json b/package.json index e34c109..5b42e1b 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "url": "https://github.com/dgrubelic/vue-authenticate.git" }, "files": ["dist"], + "types": "types/index.d.ts", "license": "MIT", "devDependencies": { "@babel/core": "^7.4.3", diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..b157109 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,86 @@ +import Vue from "vue"; +import { + ComponentOptions, + PluginFunction, + AsyncComponent, + VueConstructor +} from "vue"; +import { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios"; + +export default function plugin(Vue: VueConstructor, options?: any): void; + +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 interface VueAuthenticate { + login(user: Object): Promise; + login( + user: Object, + requestOptions: AxiosRequestConfig + ): Promise; + isAuthenticated(): boolean; + getToken(): string; + setToken(token: string | object): void; + register( + user: any, + requestOptions?: AxiosRequestConfig + ): Promise; + logout(requestOptions?: AxiosRequestConfig): Promise; + authenticate( + provider: string, + userData: any, + requestOptions?: AxiosRequestConfig + ): Promise<{}>; +} +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; + providers: { [key: string]: ProviderOptions }; +} + +declare module "vue/types/vue" { + export interface Vue { + $auth: VueAuthenticate; + } +} diff --git a/yarn.lock b/yarn.lock index 7bb49c4..dd5f71d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5438,11 +5438,6 @@ parallel-transform@^1.1.0: inherits "^2.0.3" readable-stream "^2.1.5" -parallelshell@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/parallelshell/-/parallelshell-3.0.1.tgz#0587ce1535350543916d8f3d329fbfa4a0355f22" - integrity sha512-xsSQGhJTFjbSW3WGsnSFTg1G17dcDU+gMH7bWxjAiy/3H579KPFbSp3fhkZ+jx2wcZuoav46nq+QVX0I0xPcyA== - parse-asn1@^5.0.0: version "5.1.4" resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.4.tgz#37f6628f823fbdeb2273b4d540434a22f3ef1fcc" From d9fdbcc7f0d21e9569c7db583eaae80baed94d6d Mon Sep 17 00:00:00 2001 From: Abe Rodriguez Date: Thu, 20 Feb 2020 14:57:34 -0500 Subject: [PATCH 4/5] Fix for typings --- package.json | 4 ++-- types/index.d.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5b42e1b..00d1242 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "type": "git", "url": "https://github.com/dgrubelic/vue-authenticate.git" }, - "files": ["dist"], - "types": "types/index.d.ts", + "files": ["dist", "types"], + "typings": "types/index.d.ts", "license": "MIT", "devDependencies": { "@babel/core": "^7.4.3", diff --git a/types/index.d.ts b/types/index.d.ts index b157109..600f84f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,5 +1,4 @@ -import Vue from "vue"; -import { +import Vue, { ComponentOptions, PluginFunction, AsyncComponent, @@ -41,7 +40,7 @@ export interface ProviderOptions { height: number; }; } -export interface VueAuthenticate { +export declare class VueAuthenticate { login(user: Object): Promise; login( user: Object, @@ -80,7 +79,7 @@ export interface AuthenticateOptions { } declare module "vue/types/vue" { - export interface Vue { + interface Vue { $auth: VueAuthenticate; } } From c10c82c7238a03e84de8452329c550fafe5d1946 Mon Sep 17 00:00:00 2001 From: Abe Rodriguez Date: Thu, 20 Feb 2020 15:10:00 -0500 Subject: [PATCH 5/5] Fixes for package.json around typings --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 00d1242..8cc6810 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "type": "git", "url": "https://github.com/dgrubelic/vue-authenticate.git" }, - "files": ["dist", "types"], + "files": ["dist", "types/index.d.ts"], + "types": "types/index.d.ts", "typings": "types/index.d.ts", "license": "MIT", "devDependencies": {