import type { CodeResponse, CodeClientConfig } from '../interfaces/oauth2'; import { type Ref } from "vue"; import type { MaybeRef } from '../utils/types'; /** * On success with implicit flow */ export type ImplicitFlowSuccessResponse = Omit; /** * On error with implicit flow */ export type ImplicitFlowErrorResponse = Pick; /** * Options for Implicit flow * * @export * @interface ImplicitFlowOptions * @extends {(Omit)} */ export interface ImplicitFlowOptions extends Omit { /** * On success callback * * @memberof ImplicitFlowOptions */ onSuccess?: (response: ImplicitFlowSuccessResponse) => void; /** * On error callback * * @memberof ImplicitFlowOptions */ onError?: (errorResponse: ImplicitFlowErrorResponse) => void; /** * Authorization scopes * * @type {(MaybeRef | MaybeRef)} * @see https://developers.google.com/identity/protocols/oauth2/scopes * @memberof ImplicitFlowOptions */ scope?: MaybeRef | MaybeRef; } /** * Result of composable * * @export * @interface UseCodeClientReturn */ export interface UseCodeClientReturn { /** * Is script is ready to be used? * * @type {Readonly>} * @memberof UseCodeClientReturn */ isReady: Readonly>; /** * Execute login with code client * * @memberof UseCodeClientReturn */ login: () => void | undefined; /** * Get a URL to perform code request without actually redirecting user. * This is useful for platforms like _Electron/Tauri_ for redirecting user with system browser * * @type {Readonly>} * @memberof UseCodeClientReturn */ codeRequestRedirectUrl: Readonly>; } /** * Initiate login with implicit flow using code client. Return values of the composable can be used * to trigger the login flow and determine the readiness of the client. * It also provides callbacks such as `onSuccess` and `onError` that can be used to obtain the results from the login client. * * @export * @param {ImplicitFlowOptions} [options={}] * @see https://developers.google.com/identity/oauth2/web/guides/use-code-model * @return {*} {UseCodeClientReturn} */ export default function useCodeClient(options?: ImplicitFlowOptions): UseCodeClientReturn;