import { Credentials, AuthClientRequestOptions } from './models' /** * the interface for the Oauth2Client */ export abstract class AuthClient { /** * Provides an alternative fetch api request implementation with auth credentials * if options.withCredentials:true, the request will auto add Authorization: Bearer in the request * error: * - unreachable, the network error or response is not json * - unauthenticated: has no validate access token */ abstract request: RequestFunction; /** * Sets the auth credentials. */ abstract setCredentials(credentials?: Credentials): Promise; /** * get the current accessToken from AuthClient, you can use this to detect login status * error: * - unauthenticated: has no validate access token */ abstract getAccessToken(): Promise; } export type RequestFunction = (url: string, options?: AuthClientRequestOptions) => Promise; /** An interface of the Simple Web Storage API */ export interface SimpleStorage { /** * value = storage[key] */ getItem: (key: string) => Promise; /** * delete storage[key] */ removeItem: (key: string) => Promise; /** * storage[key] = value */ setItem: (key: string, value: string) => Promise; /** * value = storage[key] */ getItemSync: (key: string) => string | null; /** * delete storage[key] */ removeItemSync: (key: string) => void; /** * storage[key] = value */ setItemSync: (key: string, value: string) => void; }