import { SimpleStorage } from './interface'; import { ErrorType } from './consts'; import { AuthOptions } from '../auth/apis'; import { ICloudbaseConfig } from '@cloudbase/types'; export interface Credentials { token_type?: string | null; access_token?: string | null; refresh_token?: string | null; scope?: string | null; expires_in?: number | null; expires_at?: Date | null; sub?: string | null; groups?: string[] | null; version?: string; } export interface ResponseError { error: ErrorType; error_description?: string | null; error_uri?: string | null; details?: any | null; } export interface RequestOptions { body?: any | null; headers?: any | null; method?: string; [key: string]: any; } export type RequestFunction = (url: string, options?: RequestOptions) => Promise; export interface AuthClientRequestOptions extends RequestOptions { headers?: { 'x-request-id'?: string; [key: string]: any; } | null; withCredentials?: boolean; withBasicAuth?: boolean; retry?: number; useWxCloud?: boolean; getCredentials?: () => Credentials | Promise | null; [key: string]: any; } export interface OAuth2ClientOptions { devMode?: boolean; apiOrigin: string; apiPath?: string; clientId: string; env: string; retry?: number; baseRequest?: (url: string, options?: RequestOptions) => Promise; storage?: SimpleStorage; clientSecret?: string; refreshTokenFunc?: (refreshToken?: string) => Promise; tokenInURL?: boolean; headers?: { [key: string]: string; }; anonymousSignInFunc?: (Credentials: any) => Promise; wxCloud?: any; onCredentialsError?: AuthOptions['onCredentialsError']; i18n?: ICloudbaseConfig['i18n']; useWxCloud?: boolean; eventBus?: any; debug?: boolean; getInitialSession?: () => Promise<{ data: { session: Credentials; user?: any; } | null; error: Error | null; }>; onInitialSessionObtained?: (data: { session: Credentials; user?: any; }) => void | Promise; }