1 | export declare type AuthData = {
|
2 | hassUrl: string;
|
3 | clientId: string | null;
|
4 | expires: number;
|
5 | refresh_token: string;
|
6 | access_token: string;
|
7 | expires_in: number;
|
8 | };
|
9 | export declare type SaveTokensFunc = (data: AuthData | null) => void;
|
10 | export declare type LoadTokensFunc = () => Promise<AuthData | null | undefined>;
|
11 | export declare type getAuthOptions = {
|
12 | hassUrl?: string;
|
13 | clientId?: string | null;
|
14 | redirectUrl?: string;
|
15 | authCode?: string;
|
16 | saveTokens?: SaveTokensFunc;
|
17 | loadTokens?: LoadTokensFunc;
|
18 | };
|
19 | export declare const genClientId: () => string;
|
20 | export declare const genExpires: (expires_in: number) => number;
|
21 | export declare class Auth {
|
22 | private _saveTokens?;
|
23 | data: AuthData;
|
24 | constructor(data: AuthData, saveTokens?: SaveTokensFunc);
|
25 | get wsUrl(): string;
|
26 | get accessToken(): string;
|
27 | get expired(): boolean;
|
28 | /**
|
29 | * Refresh the access token.
|
30 | */
|
31 | refreshAccessToken(): Promise<void>;
|
32 | /**
|
33 | * Revoke the refresh & access tokens.
|
34 | */
|
35 | revoke(): Promise<void>;
|
36 | }
|
37 | export declare function createLongLivedTokenAuth(hassUrl: string, access_token: string): Auth;
|
38 | export declare function getAuth(options?: getAuthOptions): Promise<Auth>;
|