import { BrowserConfig } from '../types.js'; import { CreateProfileInput, ProfileSetup, Profile, ProfileWithMethods, ProfileSessionInput, ProfileSession, RepoSummary, ProfileStateResponse, SaveProfileSessionInput } from './types.js'; import '../../utils/resilience.js'; /** * ProfilesClient - Manage browser profiles for storing login state. * * @example * ```typescript * const morph = new MorphClient({ apiKey: '...' }); * * // Create a profile + live setup session * const setup = await morph.browser.profiles.createProfile({ * name: 'LinkedIn', * repoId: 'owner/repo' * }); * * console.log('Sign in at:', setup.session.debugUrl); * // User logs in, then explicitly save * await setup.save(); * * // Use profile in browser tasks * await morph.browser.execute({ * task: 'Check notifications', * url: 'https://linkedin.com', * profileId: profile.id * }); * ``` */ /** * ProfilesClient class for managing browser profiles. * * Access via `morph.browser.profiles` on a MorphClient instance. */ declare class ProfilesClient { private config; constructor(config: BrowserConfig); /** * Create a new browser profile and immediately start a live session. * * @param input - Profile creation parameters * @returns Profile setup handle with live URL + save() * @throws {MorphValidationError} If input validation fails * @throws {MorphProfileLimitError} If profile limit is exceeded * @throws {MorphAuthenticationError} If API key is missing or invalid * * @example * ```typescript * const setup = await morph.browser.profiles.createProfile({ * name: 'LinkedIn Production', * repoId: 'owner/repo' * }); * console.log(setup.session.debugUrl); * await setup.save(); * ``` */ createProfile(input: CreateProfileInput): Promise; /** * List all profiles for the authenticated user. * * @param repoId - Optional repository ID to filter by * @returns Array of profiles * * @example * ```typescript * // List all profiles * const allProfiles = await morph.browser.profiles.listProfiles(); * * // List profiles for a specific repo * const repoProfiles = await morph.browser.profiles.listProfiles('owner/repo'); * ``` */ listProfiles(repoId?: string): Promise; /** * Get a profile by ID with convenience methods. * * @param id - Profile ID * @returns Profile with attached methods * @throws {MorphNotFoundError} If profile is not found * * @example * ```typescript * const profile = await morph.browser.profiles.getProfile('profile-id'); * const state = await profile.getState(); * await profile.delete(); * ``` */ getProfile(id: string): Promise; /** * Update a profile by opening a live session (no rename). * * @param id - Profile ID * @returns Profile setup handle with live URL + save() */ updateProfile(id: string): Promise; /** * Delete a profile. * * @param id - Profile ID * @throws {MorphNotFoundError} If profile is not found */ deleteProfile(id: string): Promise; /** * Start a browser session for profile setup. * * Returns a live URL where the user can sign into accounts. * After signing in, call `saveSession` to persist the state. * * @param input - Optional session parameters * @returns Session with debug URL * * @example * ```typescript * const session = await morph.browser.profiles.startSession(); * console.log('Sign in at:', session.debugUrl); * // Open debugUrl in browser, user signs in... * await morph.browser.profiles.saveSession(session.sessionId, profile.id); * ``` */ startSession(input?: ProfileSessionInput): Promise; /** * Save browser state from a session to a profile. * * Call this after the user is done signing into accounts. * Extracts cookies, localStorage, and sessionStorage. * * @param sessionId - Browser session ID from startSession * @param profileId - Profile ID to save state to * @returns Updated profile with cookie domains */ saveSession(sessionId: string, profileId: string): Promise; /** * List available repo IDs (discovery). * * @returns Repo summaries with profile counts */ listRepos(): Promise; /** * Get the presigned URL for a profile's state. * * Use this to download the raw state JSON for debugging * or to restore state manually. * * @param profileId - Profile ID * @returns State URL with expiry information */ getProfileState(profileId: string): Promise; } /** * Create a new browser profile. */ declare function createProfile(input: CreateProfileInput, config?: BrowserConfig): Promise; /** * List all profiles for the authenticated user. */ declare function listProfiles(config?: BrowserConfig, repoId?: string): Promise; /** * Get a profile by ID with convenience methods. */ declare function getProfile(id: string, config?: BrowserConfig): Promise; /** * Update a profile. */ declare function updateProfile(id: string, config?: BrowserConfig): Promise; /** * Delete a profile. */ declare function deleteProfile(id: string, config?: BrowserConfig): Promise; /** * Start a browser session for profile setup. */ declare function startProfileSession(config?: BrowserConfig, input?: ProfileSessionInput): Promise; /** * Save browser state from a session to a profile. */ declare function saveProfileSession(input: SaveProfileSessionInput, config?: BrowserConfig): Promise; /** * List repo IDs available to the authenticated user/org. */ declare function listRepos(config?: BrowserConfig): Promise; /** * Get the presigned URL for a profile's state. */ declare function getProfileState(profileId: string, config?: BrowserConfig): Promise; export { ProfilesClient, createProfile, deleteProfile, getProfile, getProfileState, listProfiles, listRepos, saveProfileSession, startProfileSession, updateProfile };