mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-01-30 16:15:55 +00:00
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
export interface Credentials {
|
|
privateKey: string;
|
|
clientEmail?: string;
|
|
}
|
|
export interface TokenData {
|
|
refresh_token?: string;
|
|
expires_in?: number;
|
|
access_token?: string;
|
|
token_type?: string;
|
|
id_token?: string;
|
|
}
|
|
export interface TokenOptions {
|
|
keyFile?: string;
|
|
key?: string;
|
|
email?: string;
|
|
iss?: string;
|
|
sub?: string;
|
|
scope?: string | string[];
|
|
additionalClaims?: {};
|
|
}
|
|
export declare class GoogleToken {
|
|
token?: string | null;
|
|
expiresAt?: number | null;
|
|
key?: string;
|
|
keyFile?: string;
|
|
iss?: string;
|
|
sub?: string;
|
|
scope?: string;
|
|
rawToken: TokenData | null;
|
|
tokenExpires: number | null;
|
|
email?: string;
|
|
additionalClaims?: {};
|
|
/**
|
|
* Create a GoogleToken.
|
|
*
|
|
* @param options Configuration object.
|
|
*/
|
|
constructor(options?: TokenOptions);
|
|
/**
|
|
* Returns whether the token has expired.
|
|
*
|
|
* @return true if the token has expired, false otherwise.
|
|
*/
|
|
hasExpired(): boolean;
|
|
/**
|
|
* Returns a cached token or retrieves a new one from Google.
|
|
*
|
|
* @param callback The callback function.
|
|
*/
|
|
getToken(): Promise<string | null | undefined>;
|
|
getToken(callback: (err: Error | null, token?: string | null | undefined) => void): void;
|
|
/**
|
|
* Given a keyFile, extract the key and client email if available
|
|
* @param keyFile Path to a json, pem, or p12 file that contains the key.
|
|
* @returns an object with privateKey and clientEmail properties
|
|
*/
|
|
getCredentials(keyFile: string): Promise<Credentials>;
|
|
private getTokenAsync();
|
|
private ensureEmail();
|
|
/**
|
|
* Revoke the token if one is set.
|
|
*
|
|
* @param callback The callback function.
|
|
*/
|
|
revokeToken(): Promise<void>;
|
|
revokeToken(callback: (err?: Error) => void): void;
|
|
private revokeTokenAsync();
|
|
/**
|
|
* Configure the GoogleToken for re-use.
|
|
* @param {object} options Configuration object.
|
|
*/
|
|
private configure(options?);
|
|
/**
|
|
* Request the token from Google.
|
|
*/
|
|
private requestToken();
|
|
}
|