diff --git a/package.json b/package.json index e34c109..8cc6810 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,9 @@ "type": "git", "url": "https://github.com/dgrubelic/vue-authenticate.git" }, - "files": ["dist"], + "files": ["dist", "types/index.d.ts"], + "types": "types/index.d.ts", + "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 new file mode 100644 index 0000000..600f84f --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,85 @@ +import Vue, { + 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 declare class 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" { + 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"