import { ErrorType } from './consts'; import { AuthClient, SimpleStorage } from './interface'; import { Credentials, ResponseError, RequestOptions, RequestFunction, OAuth2ClientOptions, AuthClientRequestOptions } from './models'; export interface ToResponseErrorOptions { error?: ErrorType; error_description?: string | null; error_uri?: string | null; details?: any | null; } export declare const defaultRequest: RequestFunction; export declare const toResponseError: (error: ResponseError | Error, options?: ToResponseErrorOptions) => ResponseError; export declare function generateRequestId(): string; declare class DefaultStorage implements SimpleStorage { private readonly _env; constructor(opts?: { env: string; }); getItem(key: string): Promise; removeItem(key: string): Promise; setItem(key: string, value: string): Promise; getItemSync(key: string): string | null; removeItemSync(key: string): void; setItemSync(key: string, value: string): void; } export declare const defaultStorage: DefaultStorage; interface LocalCredentialsOptions { tokenSectionName: string; storage: SimpleStorage; clientId: string; credentials?: Credentials; } declare class LocalCredentials { private tokenSectionName; private storage; private clientId; private credentials; private accessKeyCredentials; private singlePromise; constructor(options: LocalCredentialsOptions); getStorageCredentialsSync(): Credentials | null; setCredentials(credentials?: Credentials): Promise; setAccessKeyCredentials(credentials?: Credentials): void; getCredentials(): Promise; private getStorageCredentials; } export declare class OAuth2Client implements AuthClient { private static defaultRetry; private static minRetry; private static maxRetry; private static retryInterval; localCredentials: LocalCredentials; initializePromise: Promise<{ error: Error | null; }> | null; protected lockAcquired: boolean; protected pendingInLock: Promise[]; protected logDebugMessages: boolean; protected getInitialSession?: () => Promise<{ data: { session: Credentials; user?: any; } | null; error: Error | null; }>; private apiOrigin; private apiPath; private clientId; private i18n; private retry; private clientSecret?; private baseRequest; private storage; private deviceID?; private tokenInURL?; private refreshTokenFunc; private headers?; private singlePromise; private anonymousSignInFunc; private wxCloud; private useWxCloud; private eventBus; private basicAuth; private onCredentialsError; private onInitialSessionObtained?; constructor(options: OAuth2ClientOptions); setGetInitialSession(callback: () => Promise<{ data: { session: Credentials; user?: any; } | null; error: Error | null; }>): void; setOnInitialSessionObtained(callback: (data: { session: Credentials; user?: any; }) => void | Promise): void; initialize(func?: Promise<{ error: Error | null; }>): Promise<{ error: Error | null; }>; setCredentials(credentials?: Credentials): Promise; setAccessKeyCredentials(credentials?: Credentials): void; getAccessToken(): Promise; request(url: string, options?: AuthClientRequestOptions): Promise; wxCloudCallFunction(url: string, options?: RequestOptions): Promise; getCredentials(): Promise; getCredentialsSync(): Credentials | null; getCredentialsAsync(): Promise; getScope(): Promise; getGroups(): Promise; refreshToken(credentials: Credentials, options?: { throwError?: boolean; }): Promise; private _refreshToken; private anonymousLogin; private checkRetry; private formatRetry; private sleep; private anonymousSignIn; private defaultRefreshTokenFunc; private getDeviceId; private unAuthenticatedError; private _debug; private _initialize; private _acquireLock; private _getCredentials; } export {};