import { type H3Event } from "h3"; import { type WorkspaceConnectionProvider } from "../connections/catalog.js"; import { type OAuthStatePayload } from "./google-oauth.js"; export type GenericWorkspaceOAuthProvider = "figma" | "gmail" | "google_calendar" | "google_docs" | "google_drive" | "bigquery" | "google_sheets" | "google_slides" | "github" | "hubspot" | "salesforce" | "jira" | "sentry" | "notion" | "sigma"; export type WorkspaceProviderOAuthScope = "user" | "organization" | "app"; export declare function isWorkspaceProviderOAuthScope(value: unknown): value is WorkspaceProviderOAuthScope; export declare function isGoogleWorkspaceOAuthProvider(provider: string): boolean; export declare function shouldUseRootGoogleOAuthCallback(provider: GenericWorkspaceOAuthProvider): boolean; export declare function hasWorkspaceProviderOAuthCredentials(provider: GenericWorkspaceOAuthProvider): Promise; export interface WorkspaceProviderOAuthFlow { provider: GenericWorkspaceOAuthProvider; flowId: string; verifier: string; redirectUri: string; owner: string; orgId?: string; appId: string; scope: WorkspaceProviderOAuthScope; returnUrl?: string; salesforceLoginUrl?: string; sigmaApiBaseUrl?: string; sigmaAuthorizationUrl?: string; sigmaTokenUrl?: string; sigmaOAuthClientId?: string; sigmaOAuthClientSecret?: string; sigmaTokenEndpointAuthMethod?: "none" | "client_secret_basic" | "client_secret_post"; expiresAt: number; } export declare function workspaceProviderOAuthPath(provider: GenericWorkspaceOAuthProvider, phase: "start" | "callback"): string; export declare function createWorkspaceProviderOAuthHandler(provider: GenericWorkspaceOAuthProvider, phase: "start" | "callback"): import("h3").EventHandlerWithFetch | Response>>; export declare function oauthFlowFailure(event: H3Event, status: number, message: string): Response | { error: string; }; export declare function handleWorkspaceProviderOAuthStart(event: H3Event, providerId: GenericWorkspaceOAuthProvider): Promise>; export declare function handleWorkspaceProviderOAuthCallback(event: H3Event, providerId: GenericWorkspaceOAuthProvider): Promise>; export declare function buildWorkspaceProviderAuthorizationUrl(input: { provider: WorkspaceConnectionProvider; clientId: string; redirectUri: string; state: string; challenge: string; authorizationUrl?: string; loginHint?: string; includeGrantedScopes?: boolean; resource?: string; }): string; export declare function exchangeWorkspaceProviderOAuthCode(input: { providerId: GenericWorkspaceOAuthProvider; provider: WorkspaceConnectionProvider; clientId: string; clientSecret: string; code: string; verifier: string; redirectUri: string; tokenUrl?: string; sigma?: { apiBaseUrl: string; tokenUrl: string; tokenEndpointAuthMethod: "none" | "client_secret_basic" | "client_secret_post"; }; }): Promise>; export declare function resolveWorkspaceProviderIdentity(providerId: GenericWorkspaceOAuthProvider, tokens: Record): Promise; export declare function resolveWorkspaceProviderIdentities(providerId: GenericWorkspaceOAuthProvider, tokens: Record): Promise; type WorkspaceProviderIdentity = { accountId: string; label: string; scopes?: string[]; config?: Record; }; export declare function workspaceProviderOAuthFlowInvalidReason(input: { flow: WorkspaceProviderOAuthFlow; state: OAuthStatePayload; provider: GenericWorkspaceOAuthProvider; sessionEmail: string; sessionOrgId?: string; now?: number; }): string | undefined; export declare function isWorkspaceProviderOAuthFlowValid(input: { flow: WorkspaceProviderOAuthFlow; state: OAuthStatePayload; provider: GenericWorkspaceOAuthProvider; sessionEmail: string; sessionOrgId?: string; now?: number; }): boolean; export declare function canConnectWorkspaceProviderOAuth(orgId: string | null | undefined, role: string | null | undefined): boolean; export declare function scopedOAuthAccountId(provider: GenericWorkspaceOAuthProvider, owner: string, accountId: string): string; export declare function tokenScopes(tokens: Record, fallback: readonly string[]): string[]; export declare function mergeWorkspaceOAuthValues(existing: readonly string[], incoming: readonly string[]): string[]; export declare function resolveSalesforceOAuthLoginUrl(environment: string | undefined): string | null; export declare function salesforceOAuthEndpoint(loginUrl: string, phase: "authorize" | "token"): string; export {};