@altostra/core
Version:
Core library for shared types and logic
43 lines (42 loc) • 1.64 kB
TypeScript
import type { DefaultSeverity, Logger } from "../../common/Logging";
import type { Maybe } from "../../common/Maybe";
import type { Void } from "../../common/Types";
import type { AxiosInstance } from 'axios';
import type { Credentials, TokensFile, User } from "./Types";
export interface AuthManagerOptions {
clientId: string;
ignoreTokenExpiration?: boolean;
skipSignatureVerification?: boolean;
debug?: Logger<DefaultSeverity>;
axios?: AxiosInstance;
tokensFilePath?: string;
publicKey?: string;
auth0Tenant?: string;
oauthUrl?: string;
cacheSuppression?: boolean;
}
export declare class AuthManager {
#private;
readonly oauthProvider: string;
readonly tokenLocation: string;
readonly ignoreTokenExpiration: boolean;
readonly skipSignatureVerification: boolean;
constructor({ tokensFilePath, clientId, ignoreTokenExpiration, skipSignatureVerification, publicKey: specifiedPubKey, auth0Tenant, oauthUrl, debug, axios, cacheSuppression, }: AuthManagerOptions);
readonly tryGetCredentials: () => Promise<Maybe<Credentials>>;
validateLogin(errMessage?: string): Promise<Credentials>;
storeToken(refreshToken: string, token: string): Promise<Void>;
storeUnrefreshableToken(token: string): Promise<Void>;
clearAllCredentials(): Promise<Void>;
tryDeleteTokensFile(): Promise<Void>;
verifyToken(token: string): TokenData | undefined;
loadCredentials(): Promise<Maybe<TokensFile>>;
}
interface TokenData {
user: User;
expires: Date;
team: string;
memberOf: string[];
token: string;
onboardingComplete: boolean;
}
export {};