/** * Base error class for OAuth related errors */ declare class OAuthError extends Error { code: string; details?: any | undefined; constructor(message: string, code: string, details?: any | undefined); } /** * Error thrown when there's a problem with configuration */ declare class ConfigurationError extends OAuthError { constructor(message: string, details?: any); } /** * Error thrown during token exchange or refresh */ declare class TokenError extends OAuthError { constructor(message: string, details?: any); } /** * Base configuration options for OAuth authentication */ interface OAuthConfig { redirectUri: string; scopes?: string[]; nonce?: string; onSuccess?: (selectedFields?: any) => void; onError?: (error: OAuthError) => void; } /** * Response from OAuth token exchange */ interface OAuthResponse { access_token: string; refresh_token: string; expires_in: number; token_type: string; } /** * Generic file interface that can be extended by specific connectors */ interface GenericFile { id: string; name: string; mimeType: string; } /** * Generic selection result that can be extended by specific connectors */ interface GenericSelection { files: GenericFile[]; } /** * Configuration for Vectorize API */ interface VectorizeAPIConfig { authorization: string; organizationId: string; } /** * Generic connector configuration for Vectorize API */ interface ConnectorConfig { name: string; type: string; config?: Record; } /** * Actions that can be performed when managing users */ type UserAction = "add" | "edit" | "remove"; /** * Create a connector source via the Vectorize API. * * @param config - An object containing your organization ID and authorization token * @param connector - Connector configuration including name, type, and optional config * @param platformUrl - URL of the Vectorize API (primarily used for testing) * * @returns A Promise that resolves with the connector ID that is created */ declare function createSourceConnector(config: VectorizeAPIConfig, connector: ConnectorConfig, platformUrl?: string): Promise; /** * Manages a user for a connector, allowing you to add, edit, or remove users. * * @param config VectorizeAPIConfig containing authorization and organizationId * @param connectorId ID of the connector * @param userId User ID to manage * @param action Action to perform ("add", "edit", or "remove") * @param payload Additional payload for the request (varies by connector type) * @param platformUrl Optional URL of the Vectorize API (primarily used for testing) * @returns Promise that resolves with the API response */ declare function manageUser(config: VectorizeAPIConfig, connectorId: string, userId: string, action: UserAction, payload?: Record, platformUrl?: string): Promise; /** * Gets a one-time authentication token for connector operations * * @param config VectorizeAPIConfig containing authorization and organizationId * @param userId User ID to include in the token * @param connectorId Connector ID to include in the token * @param platformUrl Optional URL of the Vectorize API (primarily used for testing) * @returns Promise that resolves with the token response */ declare function getOneTimeConnectorToken(config: VectorizeAPIConfig, userId: string, connectorId: string, platformUrl?: string): Promise<{ token: string; expires_at: number; ttl: number; }>; /** * Base OAuth class that provides common functionality for all OAuth connectors */ declare abstract class BaseOAuth { /** * Validates the OAuth configuration * @param config The OAuth configuration to validate * @throws OAuthError if configuration is invalid */ protected static validateConfig(config: OAuthConfig): void; /** * To be implemented by subclasses for connector-specific configuration validation * @param config The OAuth configuration to validate * @throws OAuthError if configuration is invalid */ protected static validateConnectorConfig(config: OAuthConfig): void; /** * Creates an OAuth popup window for authentication * @param authUrl The authorization URL to open in the popup * @param popupTitle The title for the popup window * @returns The popup window instance or null if creation failed */ protected static createOAuthPopup(authUrl: string, popupTitle?: string): Window | null; /** * Cleans up OAuth handler from window object */ protected static cleanupOAuthHandler(): void; /** * Sets up OAuth handler in window object for callback * @param config The OAuth configuration */ protected static setupOAuthHandler(config: OAuthConfig): void; /** * Monitor popup and cleanup when closed * @param popup The popup window to monitor */ protected static monitorPopup(popup: Window): void; /** * Abstract method to start the OAuth flow * To be implemented by subclasses * @param config The OAuth configuration * @returns The popup window instance or null if creation failed */ static startOAuth(config: OAuthConfig): Window | null; /** * Create an error response for the OAuth callback * @param error The error to include in the response * @param nonce Optional nonce for Content Security Policy * @returns A Response object with the error */ protected static createErrorResponse(error: OAuthError, nonce?: string): Response; /** * Abstract method to create a callback response * To be implemented by subclasses * @param code Authorization code from the OAuth redirect * @param config The OAuth configuration * @param error Optional error from the OAuth process * @returns A Response object with the callback page */ static createCallbackResponse(code: string, config: OAuthConfig, error?: string | OAuthError): Promise; /** * Creates an iframe for connecting to a platform * @param url The URL to load in the iframe * @param options Configuration options for the iframe * @returns A promise that resolves when the iframe is closed or errors */ protected static createConnectIframe(url: string, options?: { width?: string; height?: string; timeoutMs?: number; originPattern?: RegExp; successMessage?: string; }): Promise; /** * Abstract method to redirect to Vectorize platform connect * To be implemented by subclasses * @param oneTimeToken The token for authentication * @param organizationId The organization ID * @param platformUrl The platform URL */ static redirectToVectorizeConnect(oneTimeToken: string, organizationId: string, platformUrl: string): Promise; /** * Abstract method to redirect to Vectorize platform for editing files * To be implemented by subclasses * @param oneTimeToken The token for authentication * @param organizationId The organization ID * @param platformUrl The platform URL */ static redirectToVectorizeEdit(oneTimeToken: string, organizationId: string, platformUrl: string): Promise; } /** * Validates the basic OAuth configuration * @param config The OAuth configuration to validate * @throws OAuthError if configuration is invalid */ declare function validateConfig(config: OAuthConfig): void; /** * Creates an error response for OAuth callbacks * @param error The error to include in the response * @param nonce Optional nonce for Content Security Policy * @returns A Response object with the error */ declare function createErrorResponse(error: OAuthError, nonce?: string): Response; /** * Google Drive specific configuration options */ interface GoogleDriveOAuthConfig extends OAuthConfig { clientId: string; clientSecret: string; apiKey: string; } /** * Error thrown from the Google Drive picker */ declare class PickerError$2 extends OAuthError { constructor(message: string, details?: any); } /** * Google Drive connector types */ declare enum GoogleDriveConnectorType { VECTORIZE = "GOOGLE_DRIVE_OAUTH_MULTI", WHITE_LABEL = "GOOGLE_DRIVE_OAUTH_MULTI_CUSTOM" } /** * Create a Vectorize Google Drive OAuth Connector Source. * * @param config - An object containing your organization ID and authorization token * @param connectorName - Name for the connector * @param platformUrl - URL of the Vectorize API (primarily used for testing) * * @returns A Promise that resolves with the connector ID */ declare function createVectorizeGDriveConnector(config: VectorizeAPIConfig, connectorName: string, platformUrl?: string): Promise; /** * Create a White Label Google Drive OAuth Connector Source. * * @param config - An object containing your organization ID and authorization token * @param connectorName - Name for the connector * @param clientId - OAuth2 client ID for the white label connector * @param clientSecret - OAuth2 client secret for the white label connector * @param platformUrl - URL of the Vectorize API (primarily used for testing) * * @returns A Promise that resolves with the connector ID */ declare function createWhiteLabelGDriveConnector(config: VectorizeAPIConfig, connectorName: string, clientId: string, clientSecret: string, platformUrl?: string): Promise; /** * Manages a Google Drive user for a connector, allowing you to add, edit, or remove users. * * @param config VectorizeAPIConfig containing authorization and organizationId * @param connectorId ID of the connector * @param selectedFiles Record of selected files with their metadata * @param refreshToken Google OAuth refresh token * @param userId User ID to manage * @param action Action to perform ("add", "edit", or "remove") * @param platformUrl Optional URL of the Vectorize API (primarily used for testing) * @returns Promise that resolves with the API response */ declare function manageGDriveUser(config: VectorizeAPIConfig, connectorId: string, selectedFiles: Record | null, refreshToken: string, userId: string, action: UserAction, platformUrl?: string): Promise; /** * Google Drive specific OAuth implementation */ declare class GoogleDriveOAuth extends BaseOAuth { /** * Validates Google Drive specific configuration * @param config The OAuth configuration to validate * @throws OAuthError if configuration is invalid */ protected static validateConnectorConfig(config: OAuthConfig): void; /** * Creates an OAuth popup window for Google authentication * @param config The OAuth configuration * @returns The popup window instance or null if creation failed */ static startOAuth(config: GoogleDriveOAuthConfig): Window | null; /** * Creates a response for the OAuth callback page * @param code Authorization code from the OAuth redirect * @param config The OAuth configuration * @param error Optional error from the OAuth process * @returns A Response object with the callback page */ static createCallbackResponse(code: string, config: GoogleDriveOAuthConfig, error?: string | OAuthError, nonce?: string): Promise; /** * Redirects the user to the Vectorize Google Drive connector authentication flow * with a one-time token for security * * @param oneTimeToken The security token for authentication * @param organizationId Organization ID for the connection * @param platformUrl Optional URL of the Vectorize platform (primarily used for testing) * @returns Promise that resolves when the redirect is ready */ static redirectToVectorizeConnect(oneTimeToken: string, organizationId: string, platformUrl?: string): Promise; /** * Redirects the user to the Vectorize Google Drive connector edit flow * with a one-time token for security * * @param oneTimeToken The security token for authentication * @param organizationId Organization ID for the connection * @param platformUrl Optional URL of the Vectorize platform (primarily used for testing) * @returns Promise that resolves when the redirect is ready */ static redirectToVectorizeEdit(oneTimeToken: string, organizationId: string, platformUrl?: string): Promise; } /** * Refreshes an access token using a refresh token * @param refreshToken The refresh token * @param clientId The OAuth client ID * @param clientSecret The OAuth client secret * @returns An object containing the new access token */ declare function refreshGDriveToken(refreshToken: string, clientId: string, clientSecret: string): Promise<{ access_token: string; expires_in: number; token_type: string; }>; /** * Abstract base class for file selection functionality * Can be extended by connector-specific implementations */ declare abstract class BaseSelection { /** * Creates a popup window for file selection * * @param width Width of the popup window * @param height Height of the popup window * @param title Title of the popup window * @returns The created popup window or null if creation failed */ protected static createPopupWindow(width?: number, height?: number, title?: string): Window | null; /** * Sets up the OAuth handler in the window object * * @param config OAuth configuration with success and error callbacks */ protected static setupOAuthHandler(config: OAuthConfig): void; /** * Monitors a popup window and cleans up when it's closed * * @param popup The popup window to monitor */ protected static monitorPopup(popup: Window | null): void; /** * Writes content to a popup window * * @param popup The popup window to write to * @param content The HTML content to write */ protected static writeToPopup(popup: Window | null, content: string): void; /** * Abstract method to be implemented by connector-specific classes * This is the main entry point for file selection */ abstract startFileSelection(config: OAuthConfig, refreshToken: string, selectedFiles?: Record, targetWindow?: Window): Promise; } /** * Google Drive implementation of file selection functionality */ declare class GoogleDriveSelection extends BaseSelection { /** * Static method to start Google Drive file selection * This static method is what will be called from the React components */ static startFileSelection(config: GoogleDriveOAuthConfig, refreshToken: string, selectedFiles?: Record, targetWindow?: Window): Promise; /** * Instance method implementation (fulfills abstract class requirement) * Delegates to the static method for actual implementation */ startFileSelection(config: GoogleDriveOAuthConfig, refreshToken: string, selectedFiles?: Record, targetWindow?: Window): Promise; } /** * Dropbox specific configuration options */ interface DropboxOAuthConfig extends OAuthConfig { appKey: string; appSecret: string; } /** * Error thrown from the Dropbox picker */ declare class PickerError$1 extends OAuthError { constructor(message: string, details?: any); } /** * Dropbox connector types */ declare enum DropboxConnectorType { VECTORIZE = "DROPBOX_OAUTH_MULTI", WHITE_LABEL = "DROPBOX_OAUTH_MULTI_CUSTOM" } /** * Create a Vectorize Dropbox OAuth Connector Source * * @param config - An object containing your organization ID and authorization token * @param connectorName - Name for the connector * @param platformUrl - URL of the Vectorize API (primarily used for testing) * * @returns A Promise that resolves with the connector ID */ declare function createVectorizeDropboxConnector(config: VectorizeAPIConfig, connectorName: string, platformUrl?: string): Promise; /** * Create a White Label Dropbox OAuth Connector Source * * @param config - An object containing your organization ID and authorization token * @param connectorName - Name for the connector * @param appKey - Dropbox API app key for the white label connector * @param appSecret - Dropbox API app secret for the white label connector * @param platformUrl - URL of the Vectorize API (primarily used for testing) * * @returns A Promise that resolves with the connector ID */ declare function createWhiteLabelDropboxConnector(config: VectorizeAPIConfig, connectorName: string, appKey: string, appSecret: string, platformUrl?: string): Promise; /** * Manages a Dropbox user for a connector, allowing you to add, edit, or remove users. * * @param config VectorizeAPIConfig containing authorization and organizationId * @param connectorId ID of the connector * @param selectedFiles Record of selected files with their metadata * @param refreshToken Dropbox OAuth refresh token * @param userId User ID to manage * @param action Action to perform ("add", "edit", or "remove") * @param platformUrl Optional URL of the Vectorize API (primarily used for testing) * @returns Promise that resolves with the API response */ declare function manageDropboxUser(config: VectorizeAPIConfig, connectorId: string, selectedFiles: Record | null, refreshToken: string, userId: string, action: UserAction, platformUrl?: string): Promise; /** * Dropbox specific OAuth implementation */ declare class DropboxOAuth extends BaseOAuth { /** * Validates Dropbox specific configuration * @param config The OAuth configuration to validate * @throws OAuthError if configuration is invalid */ protected static validateConnectorConfig(config: OAuthConfig): void; /** * Creates an OAuth popup window for Dropbox authentication * @param config The OAuth configuration * @returns The popup window instance or null if creation failed */ static startOAuth(config: DropboxOAuthConfig): Window | null; /** * Creates a response for the OAuth callback page * @param code Authorization code from the OAuth redirect * @param config The OAuth configuration * @param error Optional error from the OAuth process * @returns A Response object with the callback page */ static createCallbackResponse(code: string, config: DropboxOAuthConfig, error?: string | OAuthError, nonce?: string): Promise; /** * Redirects the user to the Vectorize Dropbox connector authentication flow * with a one-time token for security * * @param oneTimeToken The security token for authentication * @param organizationId Organization ID for the connection * @param platformUrl Optional URL of the Vectorize platform (primarily used for testing) * @returns Promise that resolves when the redirect is ready */ static redirectToVectorizeConnect(oneTimeToken: string, organizationId: string, platformUrl?: string): Promise; /** * Redirects the user to the Vectorize Dropbox connector edit flow * with a one-time token for security * * @param oneTimeToken The security token for authentication * @param organizationId Organization ID for the connection * @param platformUrl Optional URL of the Vectorize platform (primarily used for testing) * @returns Promise that resolves when the redirect is ready */ static redirectToVectorizeEdit(oneTimeToken: string, organizationId: string, platformUrl?: string): Promise; } /** * Dropbox implementation of file selection functionality */ declare class DropboxSelection extends BaseSelection { /** * Static method to start Dropbox file selection * This static method is what will be called from the React components */ static startFileSelection(config: DropboxOAuthConfig, refreshToken: string, selectedFiles?: Record, targetWindow?: Window): Promise; /** * Instance method implementation (fulfills abstract class requirement) * Delegates to the static method for actual implementation */ startFileSelection(config: DropboxOAuthConfig, refreshToken: string, selectedFiles?: Record, targetWindow?: Window): Promise; } /** * Refreshes an access token using a refresh token * @param refreshToken The refresh token * @param appKey The Dropbox app key * @param appSecret The Dropbox app secret * @returns An object containing the new access token */ declare function refreshDropboxToken(refreshToken: string, appKey: string, appSecret: string): Promise<{ access_token: string; expires_in: number; token_type: string; }>; /** * Notion specific configuration options */ interface NotionOAuthConfig extends OAuthConfig { clientId: string; clientSecret: string; redirectUri: string; scopes?: string[]; } /** * Error thrown from the Notion picker */ declare class PickerError extends OAuthError { constructor(message: string, details?: any); } /** * Represents a page in Notion */ interface NotionPage { id: string; title: string; pageId: string; parentType?: string; url?: string; } /** * Selection result from the Notion picker */ interface NotionPageSelection extends GenericSelection { pages: NotionPage[]; workspaceId?: string; workspaceName?: string; } /** * Notion connector types */ declare enum NotionConnectorType { VECTORIZE = "NOTION_OAUTH_MULTI", WHITE_LABEL = "NOTION_OAUTH_MULTI_CUSTOM" } /** * Create a Vectorize Notion OAuth Connector Source * * @param config - An object containing your organization ID and authorization token * @param connectorName - Name for the connector * @param platformUrl - URL of the Vectorize API (primarily used for testing) * * @returns A Promise that resolves with the connector ID */ declare function createVectorizeNotionConnector(config: VectorizeAPIConfig, connectorName: string, platformUrl?: string): Promise; /** * Create a White Label Notion OAuth Connector Source * * @param config - An object containing your organization ID and authorization token * @param connectorName - Name for the connector * @param clientId - Notion API client ID for the white label connector * @param clientSecret - Notion API client secret for the white label connector * @param platformUrl - URL of the Vectorize API (primarily used for testing) * * @returns A Promise that resolves with the connector ID */ declare function createWhiteLabelNotionConnector(config: VectorizeAPIConfig, connectorName: string, clientId: string, clientSecret: string, platformUrl?: string): Promise; /** * Manages a Notion user for a connector, allowing you to add, edit, or remove users. * * @param config VectorizeAPIConfig containing authorization and organizationId * @param connectorId ID of the connector * @param selectedPages Record of selected pages with their metadata * @param accessToken Notion OAuth access token * @param userId User ID to manage * @param action Action to perform ("add", "edit", or "remove") * @param platformUrl Optional URL of the Vectorize API (primarily used for testing) * @returns Promise that resolves with the API response */ declare function manageNotionUser(config: VectorizeAPIConfig, connectorId: string, selectedPages: Record | null, accessToken: string, userId: string, action: UserAction, platformUrl?: string): Promise; /** * Notion specific OAuth implementation */ declare class NotionOAuth extends BaseOAuth { /** * Validates Notion specific configuration * @param config The OAuth configuration to validate * @throws OAuthError if configuration is invalid */ protected static validateConnectorConfig(config: OAuthConfig): void; /** * Creates an OAuth popup window for Notion authentication * @param config The OAuth configuration * @returns The popup window instance or null if creation failed */ static startOAuth(config: NotionOAuthConfig): Window | null; /** * Creates a response for the OAuth callback page * @param code Authorization code from the OAuth redirect * @param config The OAuth configuration * @param error Optional error from the OAuth process * @param nonce Optional nonce for Content Security Policy * @returns A Response object with the callback page */ static createCallbackResponse(code: string, config: NotionOAuthConfig, error?: string | OAuthError, nonce?: string): Promise; /** * Redirects the user to the Vectorize Notion connector authentication flow * with a one-time token for security * * @param oneTimeToken The security token for authentication * @param organizationId Organization ID for the connection * @param platformUrl Optional URL of the Vectorize platform (primarily used for testing) * @returns Promise that resolves when the redirect is ready */ static redirectToVectorizeConnect(oneTimeToken: string, organizationId: string, platformUrl?: string): Promise; /** * Redirects the user to the Vectorize Notion connector edit flow * with a one-time token for security * * @param oneTimeToken The security token for authentication * @param organizationId Organization ID for the connection * @param platformUrl Optional URL of the Vectorize platform (primarily used for testing) * @returns Promise that resolves when the redirect is ready */ static redirectToVectorizeEdit(oneTimeToken: string, organizationId: string, platformUrl?: string): Promise; } /** * Refresh or validate a Notion access token * * Note: Notion tokens are long-lived and don't typically need refreshing like Dropbox, * but we'll verify the token is valid by making a small API request. * If token is invalid, we'll throw an error that can be caught by the caller. * * @param accessToken Current Notion access token * @param clientId The OAuth client ID (for potential future token refresh) * @param clientSecret The OAuth client secret (for potential future token refresh) * @returns Promise resolving to the validated token information */ declare function refreshNotionToken(accessToken: string, clientId: string, clientSecret: string): Promise<{ access_token: string; workspace_id: string; workspace_name: string; workspace_icon?: string; bot_id: string; }>; export { BaseOAuth, ConfigurationError, type ConnectorConfig, DropboxConnectorType, DropboxOAuth, type DropboxOAuthConfig, PickerError$1 as DropboxPickerError, DropboxSelection, type GenericFile, type GenericSelection, GoogleDriveConnectorType, GoogleDriveOAuth, type GoogleDriveOAuthConfig, PickerError$2 as GoogleDrivePickerError, GoogleDriveSelection, NotionConnectorType, NotionOAuth, type NotionOAuthConfig, type NotionPage, type NotionPageSelection, PickerError as NotionPickerError, type OAuthConfig, OAuthError, type OAuthResponse, TokenError, type UserAction, type VectorizeAPIConfig, createErrorResponse, createSourceConnector, createVectorizeDropboxConnector, createVectorizeGDriveConnector, createVectorizeNotionConnector, createWhiteLabelDropboxConnector, createWhiteLabelGDriveConnector, createWhiteLabelNotionConnector, getOneTimeConnectorToken, manageDropboxUser, manageGDriveUser, manageNotionUser, manageUser, refreshDropboxToken, refreshGDriveToken, refreshNotionToken, validateConfig };