UNPKG

wgc

Version:

The official CLI tool to manage the GraphQL Federation Platform Cosmo

67 lines (66 loc) 1.9 kB
interface DeviceAuthResponse { deviceCode: string; userCode: string; verificationURI: string; interval: number; } export interface KeycloakToken { accessToken: string; refreshToken: string; expiresAt: Date; refreshExpiresAt: Date; } export interface KeycloakTokenResponse { access_token: string; refresh_token: string; expires_in: number; refresh_expires_in: number; } export type GraphTokenFeature = 'split-config-loading'; export interface GraphToken { iss?: string; iat?: number; federated_graph_id: string; organization_id: string; features?: GraphTokenFeature[]; } export interface DecodedAccessToken { iss?: string; sub?: string; aud?: string[] | string; exp?: number; nbf?: number; iat?: number; jti?: string; groups: string[]; email: string; } export declare const performDeviceAuth: () => Promise<{ success: boolean; response: DeviceAuthResponse; errorMessage?: string; }>; export declare const startPollingForAccessToken: ({ deviceCode, interval, }: { deviceCode: string; interval: number; }) => Promise<{ success: boolean; response?: KeycloakToken; errorMessage?: string; }>; /** * Checks if either of access token or api key are present. * If not, it will try to refresh the access token * * @param [showErrorMessage] - when `false`, any and all error message will be skipped */ export declare function checkAuth(showErrorMessage?: boolean): Promise<void>; /** * Perform access token refresh and updates the value for `config.apiKey` accordingly (if needed); * however, if the value for `config.apiKey` remains empty, that means the user is not authenticated or the * token refresh failed * * @returns {boolean} A value indicating whether the client is authenticated */ export declare function isAuthenticated(): Promise<boolean>; export {};