/// import { ApolloLink, FetchResult, NextLink, Observable, Operation } from '@apollo/client/core'; import { IAuthTokenSet, ISlicknodeLinkOptions, IStorage } from './types'; export declare const REFRESH_TOKEN_MUTATION: import("graphql/language").DocumentNode; export declare const LOGOUT_MUTATION: import("graphql/language").DocumentNode; /** * SlicknodeLink instance to be used to load data with apollo-client * from slicknode GraphQL servers */ export default class SlicknodeLink extends ApolloLink { options: ISlicknodeLinkOptions; storage: IStorage; namespace: string; private loadHeadersPromise; /** * Constructor * @param options */ constructor(options?: ISlicknodeLinkOptions); /** * * @param {Operation} operation * @param {NextLink} forward * @returns {Observable | null} */ request(operation: Operation, forward?: NextLink): Observable | null; /** * Returns true if the client has a valid access token * * @returns {boolean} */ hasAccessToken(): boolean; /** * Returns true if the client has a valid refresh token * * @returns {boolean} */ hasRefreshToken(): boolean; /** * Updates the auth token set * @param token */ setAuthTokenSet(token: IAuthTokenSet): void; /** * Stores the refreshToken in the storage of the client * @param token */ setRefreshToken(token: string): void; /** * Returns the refresh token, NULL if none was stored yet * @returns {string|null} */ getRefreshToken(): string | null; /** * Sets the time when the auth token expires */ setAccessTokenExpires(timestamp: number | null): void; /** * Returns the UNIX Timestamp when the refresh token expires * @returns {number|null} */ getRefreshTokenExpires(): number | null; /** * Sets the time when the auth token expires */ setRefreshTokenExpires(timestamp: number | null): void; /** * Returns the UNIX Timestamp when the access token expires * @returns {number|null} */ getAccessTokenExpires(): number | null; /** * Writes the access token to storage * @param token */ setAccessToken(token: string): void; /** * Returns the access token, NULL if no valid token was found * @returns {null} */ getAccessToken(): string | null; /** * Clears all tokens in the storage */ logout(): Promise; /** * Returns the headers that are required to authenticate at the GraphQL endpoint. * If no access tokens are available, an attempt is made to retrieve it from the backend * with the refreshToken */ getAuthHeaders(forward: NextLink): Promise; protected validateAndSetAuthTokenSet(tokenSet: any): boolean; protected debug(message: string): void; }