{"version":3,"file":"index.cjs","sources":["../src/auth-with-google.ts","../src/cloud-runner-launch-options.ts","../src/index.ts"],"sourcesContent":["import type { BrowserContext } from \"@playwright/test\";\n\nimport {\n  createClient,\n  postInternalV1TestAccountGoogleAuthState,\n} from \"@stablyai-internal/api-client\";\nimport { requireApiKey } from \"@stablyai/playwright-base\";\n\ndeclare const __PACKAGE_VERSION__: string;\n\ntype PlaywrightCookie = Parameters<BrowserContext[\"addCookies\"]>[0][number];\n\ntype LocalStorageEntry = {\n  name: string;\n  value: string;\n};\n\ntype StorageOrigin = {\n  localStorage: LocalStorageEntry[];\n  origin: string;\n};\n\n/**\n * Playwright-compatible storage state.\n */\nexport type GoogleStorageState = {\n  cookies: PlaywrightCookie[];\n  origins: StorageOrigin[];\n};\n\n/**\n * Input for {@link authWithGoogle}.\n */\nexport type AuthWithGoogleOptions = {\n  /**\n   * Browser context where auth state should be applied.\n   */\n  context: BrowserContext;\n  /**\n   * Google account email.\n   */\n  email: string;\n  /**\n   * Google account password.\n   */\n  password: string;\n  /**\n   * TOTP seed/secret used to generate the Google 2FA code.\n   */\n  otpSecret: string;\n  /**\n   * Force a cache refresh server-side. Defaults to `false`.\n   */\n  forceRefresh?: boolean;\n  /**\n   * Optional API key override. Defaults to the configured Stably API key.\n   */\n  apiKey?: string;\n};\n\nconst getApiUrl = (): string =>\n  process.env.STABLY_API_URL ?? \"https://api.stably.ai\";\n\nconst sdkVersion =\n  typeof __PACKAGE_VERSION__ !== \"undefined\"\n    ? __PACKAGE_VERSION__\n    : (process.env.npm_package_version ?? \"local\");\n\nconst assertNonEmptyString = (value: string, fieldName: string): void => {\n  if (!value.trim()) {\n    throw new Error(`Missing required field: ${fieldName}`);\n  }\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n  typeof value === \"object\" && value !== null;\n\nconst parseCookie = (value: unknown): PlaywrightCookie => {\n  if (!isRecord(value)) {\n    throw new Error(\"Invalid Google storage state: cookie must be an object\");\n  }\n\n  const { domain } = value;\n  const { name } = value;\n  const { path } = value;\n  const { sameSite } = value;\n  const valueText = value.value;\n\n  if (\n    typeof domain !== \"string\" ||\n    typeof name !== \"string\" ||\n    typeof path !== \"string\" ||\n    typeof valueText !== \"string\"\n  ) {\n    throw new Error(\n      \"Invalid Google storage state: cookie is missing required fields\",\n    );\n  }\n\n  return {\n    ...(typeof value.expires === \"number\" ? { expires: value.expires } : {}),\n    ...(typeof value.httpOnly === \"boolean\"\n      ? { httpOnly: value.httpOnly }\n      : {}),\n    ...(typeof value.partitionKey === \"string\"\n      ? { partitionKey: value.partitionKey }\n      : {}),\n    ...(typeof value.secure === \"boolean\" ? { secure: value.secure } : {}),\n    ...(sameSite === \"Lax\" || sameSite === \"None\" || sameSite === \"Strict\"\n      ? { sameSite }\n      : {}),\n    domain,\n    name,\n    path,\n    value: valueText,\n  };\n};\n\nconst parseLocalStorageEntry = (value: unknown): LocalStorageEntry => {\n  if (!isRecord(value)) {\n    throw new Error(\n      \"Invalid Google storage state: localStorage entry must be an object\",\n    );\n  }\n\n  const { name } = value;\n  const storedValue = value.value;\n\n  if (typeof name !== \"string\" || typeof storedValue !== \"string\") {\n    throw new Error(\n      \"Invalid Google storage state: localStorage entry must contain string name and value\",\n    );\n  }\n\n  return { name, value: storedValue };\n};\n\nconst parseOrigin = (value: unknown): StorageOrigin => {\n  if (!isRecord(value)) {\n    throw new Error(\"Invalid Google storage state: origin must be an object\");\n  }\n\n  const { origin } = value;\n  const rawLocalStorage = value.localStorage;\n\n  if (typeof origin !== \"string\") {\n    throw new Error(\"Invalid Google storage state: origin must be a string\");\n  }\n\n  if (!Array.isArray(rawLocalStorage)) {\n    return { localStorage: [], origin };\n  }\n\n  return {\n    localStorage: rawLocalStorage.map(parseLocalStorageEntry),\n    origin,\n  };\n};\n\nconst parseStorageState = (value: {\n  cookies?: unknown[];\n  origins?: unknown[];\n}): GoogleStorageState => ({\n  cookies: Array.isArray(value.cookies) ? value.cookies.map(parseCookie) : [],\n  origins: Array.isArray(value.origins) ? value.origins.map(parseOrigin) : [],\n});\n\nconst applyStorageStateToContext = async (\n  context: BrowserContext,\n  storageState: GoogleStorageState,\n): Promise<void> => {\n  if (storageState.cookies.length > 0) {\n    await context.addCookies(storageState.cookies);\n  }\n\n  for (const originState of storageState.origins) {\n    if (originState.localStorage.length === 0) {\n      continue;\n    }\n\n    const page = await context.newPage();\n    try {\n      await page.goto(originState.origin, { waitUntil: \"domcontentloaded\" });\n      await page.evaluate((entries: LocalStorageEntry[]) => {\n        for (const entry of entries) {\n          window.localStorage.setItem(entry.name, entry.value);\n        }\n      }, originState.localStorage);\n    } finally {\n      await page.close();\n    }\n  }\n};\n\n/**\n * Signs in a Google test account and applies the authenticated session to a Playwright context.\n *\n * Use this when your test needs to start in an already-authenticated state without\n * manually driving the login UI. After this resolves, cookies and localStorage are\n * applied to the provided context and subsequent pages in that context can continue\n * as an authenticated user.\n *\n * @param options - Google credentials and target Playwright context.\n * @param options.context - Browser context to receive the authenticated session.\n * @param options.email - Google account email.\n * @param options.password - Google account password.\n * @param options.otpSecret - TOTP secret for 2FA. See https://docs.stably.ai/stably2/auth/google-otp-secret-helper.\n * @param options.forceRefresh - Optional flag to force regeneration of session state.\n * @param options.apiKey - Optional Stably API key override.\n *\n * @returns Resolves when auth state has been successfully applied to the context.\n *\n * @example\n * ```ts\n * import { test } from \"@stablyai/playwright-test\";\n *\n * test(\"opens Google settings as authenticated user\", async ({ context, page }) => {\n *   await context.authWithGoogle({\n *     email: \"qa@example.com\",\n *     password: process.env.GOOGLE_TEST_PASSWORD!,\n *     otpSecret: process.env.GOOGLE_TEST_OTP_SECRET!,\n *   });\n *\n *   await page.goto(\"https://myaccount.google.com\");\n * });\n * ```\n */\nexport async function authWithGoogle(\n  options: AuthWithGoogleOptions,\n): Promise<void> {\n  const apiKey = options.apiKey ?? requireApiKey();\n\n  assertNonEmptyString(options.email, \"email\");\n  assertNonEmptyString(options.password, \"password\");\n  assertNonEmptyString(options.otpSecret, \"otpSecret\");\n\n  const client = createClient({\n    baseUrl: getApiUrl(),\n    headers: {\n      Authorization: `Bearer ${apiKey}`,\n      \"X-Client-Name\": \"stably-playwright-test\",\n      \"X-Client-Version\": sdkVersion,\n      \"X-Stably-SDK-Version\": sdkVersion,\n    },\n  });\n\n  const response = await postInternalV1TestAccountGoogleAuthState({\n    body: {\n      email: options.email,\n      forceRefresh: options.forceRefresh,\n      otpSecret: options.otpSecret,\n      password: options.password,\n    },\n    client,\n  });\n\n  if (response.error) {\n    const errorMessage =\n      \"error\" in response.error ? response.error.error : \"Unknown error\";\n    throw new Error(`Failed to authenticate with Google: ${errorMessage}`);\n  }\n\n  const storageState = parseStorageState(response.data.storageState);\n  await applyStorageStateToContext(options.context, storageState);\n}\n","import type { LaunchOptions } from \"@playwright/test\";\n\nconst REQUIRED_CLOUD_CHROMIUM_ARGS = [\n  \"--no-sandbox\",\n  \"--disable-dev-shm-usage\",\n] as const;\n\nfunction isChromiumBrowserName(browserName: string): boolean {\n  return browserName.toLowerCase().includes(\"chromium\");\n}\n\nfunction mergeChromiumArgs(args: LaunchOptions[\"args\"]): string[] {\n  const existingArgs = args ?? [];\n  const existingArgNames = new Set(\n    existingArgs.map((arg) => arg.split(\"=\")[0]),\n  );\n  const missingRequiredArgs = REQUIRED_CLOUD_CHROMIUM_ARGS.filter(\n    (arg) => !existingArgNames.has(arg),\n  );\n\n  return [...missingRequiredArgs, ...existingArgs];\n}\n\n/**\n * Stably's hosted runner uses an Alpine image with system Chromium instead of\n * Playwright's downloaded browser bundle. Playwright only shallow-merges\n * `use.launchOptions`, so file-level `test.use({ launchOptions })` can erase\n * the wrapper config's executablePath. Apply the runner executable after\n * Playwright has resolved all user launch options.\n */\nexport function applyStablyCloudRunnerLaunchOptions({\n  browserName,\n  chromeBin = process.env.CHROME_BIN,\n  launchOptions,\n}: {\n  browserName: string;\n  chromeBin?: string;\n  launchOptions: LaunchOptions;\n}): LaunchOptions {\n  const executablePath = chromeBin?.trim();\n  if (!executablePath || !isChromiumBrowserName(browserName)) {\n    return launchOptions;\n  }\n\n  return {\n    ...launchOptions,\n    args: mergeChromiumArgs(launchOptions.args),\n    executablePath,\n  };\n}\n","import { dirname } from \"path\";\nimport { fileURLToPath } from \"url\";\n\nimport type { BrowserContext } from \"@playwright/test\";\nimport {\n  defineConfig as playwrightDefineConfig,\n  expect as playwrightExpect,\n  type LaunchOptions,\n  test as playwrightTest,\n} from \"@playwright/test\";\nimport \"@stablyai/playwright-base\";\n\nimport type { Agent } from \"@stablyai/playwright-base\";\nimport {\n  augmentBrowser,\n  augmentBrowserContext,\n  augmentPage,\n  stablyPlaywrightMatchers,\n} from \"@stablyai/playwright-base\";\n\nimport type { StablyNotificationConfig } from \"@stablyai/playwright-reporter\";\nimport {\n  authWithGoogle,\n  type AuthWithGoogleOptions,\n  type GoogleStorageState,\n} from \"./auth-with-google\";\nimport { applyStablyCloudRunnerLaunchOptions } from \"./cloud-runner-launch-options\";\n\nexport { stablyReporter } from \"@stablyai/playwright-reporter\";\nexport type {\n  StablyReporterOptions,\n  ProjectNotificationConfig,\n  NotificationResultPolicy,\n  StablyEmailNotificationConfig,\n  StablySlackNotificationConfig,\n  StablyNotificationConfig,\n} from \"@stablyai/playwright-reporter\";\nexport { Agent, setApiKey } from \"@stablyai/playwright-base\";\nexport { authWithGoogle, type AuthWithGoogleOptions, type GoogleStorageState };\nexport type {\n  AIModel,\n  GetLocatorsByAIOptions,\n  GetLocatorsByAIResult,\n  ScreenshotPromptOptions,\n} from \"@stablyai/playwright-base\";\n\n/**\n * Get the directory name from an import.meta.url.\n * This is the ESM equivalent of __dirname.\n *\n * @example\n * ```ts\n * import { getDirname } from '@stablyai/playwright-test';\n * const __dirname = getDirname(import.meta.url);\n *\n * // Use in tests for file paths\n * await page.setInputFiles('input', path.join(__dirname, 'fixtures', 'file.pdf'));\n * ```\n */\nexport function getDirname(importMetaUrl: string): string {\n  return dirname(fileURLToPath(importMetaUrl));\n}\n\n/**\n * Get the filename from an import.meta.url.\n * This is the ESM equivalent of __filename.\n *\n * @example\n * ```ts\n * import { getFilename } from '@stablyai/playwright-test';\n * const __filename = getFilename(import.meta.url);\n * ```\n */\nexport function getFilename(importMetaUrl: string): string {\n  return fileURLToPath(importMetaUrl);\n}\n\ntype PlaywrightWithDefaultLaunchOptions = {\n  _defaultLaunchOptions?: LaunchOptions;\n};\n\ntype InternalBrowserOptionsFixtureArgs = {\n  _browserOptions: LaunchOptions;\n  browserName: string;\n  playwright: PlaywrightWithDefaultLaunchOptions;\n};\n\ntype UseBrowserOptions = (options: LaunchOptions) => Promise<void>;\n\nconst stablyFixtures = {\n  _browserOptions: async (\n    {\n      _browserOptions,\n      browserName,\n      playwright,\n    }: InternalBrowserOptionsFixtureArgs,\n    use: UseBrowserOptions,\n  ) => {\n    const browserOptions = applyStablyCloudRunnerLaunchOptions({\n      browserName,\n      launchOptions: _browserOptions,\n    });\n    const previousDefaultLaunchOptions = playwright._defaultLaunchOptions;\n    playwright._defaultLaunchOptions = browserOptions;\n    try {\n      await use(browserOptions);\n    } finally {\n      playwright._defaultLaunchOptions = previousDefaultLaunchOptions;\n    }\n  },\n  agent: async (\n    { context }: { context: BrowserContext },\n    use: (agent: Agent) => Promise<void>,\n  ) => {\n    // Create a default agent from the default context\n    const agent = context.newAgent();\n    await use(agent);\n  },\n  browser: async ({ browser }, use) => {\n    await use(augmentBrowser(browser));\n  },\n  context: async ({ context }, use) => {\n    const augmentedContext = augmentBrowserContext(context);\n    if (!(\"authWithGoogle\" in augmentedContext)) {\n      augmentedContext.authWithGoogle = (\n        options: Omit<AuthWithGoogleOptions, \"context\">,\n      ) => authWithGoogle({ context: augmentedContext, ...options });\n    }\n\n    await use(augmentedContext);\n  },\n  page: async ({ page }, use) => {\n    await use(augmentPage(page));\n  },\n} as Parameters<typeof playwrightTest.extend<{ agent: Agent }>>[0];\n\nexport const test: typeof playwrightTest = playwrightTest.extend<{\n  agent: Agent;\n}>(stablyFixtures);\n\nexport const expect = playwrightExpect.extend(stablyPlaywrightMatchers);\n\nexport * from \"@playwright/test\";\n\nexport type StablyProjectConfig = {\n  notifications?: StablyNotificationConfig;\n};\n\n/**\n * Stably-enhanced defineConfig with typed support for stably notification configuration in projects.\n * The `stably` property on projects is available via module augmentation of `@playwright/test`.\n *\n * @example\n * ```ts\n * import { defineConfig, stablyReporter } from \"@stablyai/playwright-test\";\n *\n * export default defineConfig({\n *   reporter: [stablyReporter({ apiKey: \"...\" })],\n *   projects: [\n *     {\n *       name: \"smoke\",\n *       stably: {\n *         notifications: {\n *           slack: { channelName: \"#alerts\", notifyOnResult: \"failures-only\" },\n *         },\n *       },\n *     },\n *   ],\n * });\n * ```\n */\nexport const defineConfig = playwrightDefineConfig;\n\ndeclare module \"@playwright/test\" {\n  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n  interface LocatorAssertions {\n    /**\n     * Asserts that the locator satisfies a natural language condition using AI vision.\n     *\n     * Takes a screenshot of the locator and uses AI to verify whether the specified condition is met.\n     *\n     * @param condition - A natural language description of what should be true about the locator\n     * @param options - Optional screenshot options (e.g., timeout)\n     *\n     * @example\n     * ```typescript\n     * await expect(page.locator('.button')).aiAssert('The button is disabled and grayed out');\n     * ```\n     */\n    aiAssert(\n      condition: string,\n      // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n      options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n    ): Promise<void>;\n\n    /**\n     * @deprecated Use `aiAssert` instead. This method will be removed in a future version.\n     */\n    toMatchScreenshotPrompt(\n      condition: string,\n      // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n      options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n    ): Promise<void>;\n  }\n\n  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n  interface PageAssertions {\n    /**\n     * Asserts that the page satisfies a natural language condition using AI vision.\n     *\n     * Takes a screenshot of the page and uses AI to verify whether the specified condition is met.\n     *\n     * @param condition - A natural language description of what should be true about the page\n     * @param options - Optional screenshot options (e.g., fullPage, timeout)\n     *\n     * @example\n     * ```typescript\n     * await expect(page).aiAssert('The page shows a success message after form submission');\n     * ```\n     */\n    aiAssert(\n      condition: string,\n      // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n      options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n    ): Promise<void>;\n\n    /**\n     * @deprecated Use `aiAssert` instead. This method will be removed in a future version.\n     */\n    toMatchScreenshotPrompt(\n      condition: string,\n      // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n      options?: import(\"@stablyai/playwright-base\").ScreenshotPromptOptions,\n    ): Promise<void>;\n  }\n\n  // Add agent fixture to test args\n  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n  interface PlaywrightTestArgs {\n    agent: Agent;\n  }\n\n  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n  interface BrowserContext {\n    /**\n     * Generates and applies Google auth state to this context.\n     *\n     * Calls Stably's Google auth-state endpoint and proactively sets cookies and\n     * localStorage values on this context.\n     */\n    authWithGoogle(\n      options: Omit<AuthWithGoogleOptions, \"context\">,\n    ): Promise<void>;\n  }\n\n  // Add stably config to project configuration\n  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n  interface Project {\n    stably?: StablyProjectConfig;\n  }\n}\n"],"names":["requireApiKey","createClient","postInternalV1TestAccountGoogleAuthState","dirname","fileURLToPath","augmentBrowser","augmentBrowserContext","augmentPage","playwrightTest","playwrightExpect","stablyPlaywrightMatchers","playwrightDefineConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,SAAA,GAAY,MAChB,OAAA,CAAQ,GAAA,CAAI,cAAA,IAAkB,uBAAA;AAEhC,MAAM,UAAA,GAEA,QAAA,CACoC;AAE1C,MAAM,oBAAA,GAAuB,CAAC,KAAA,EAAe,SAAA,KAA4B;AACvE,EAAA,IAAI,CAAC,KAAA,CAAM,IAAA,EAAK,EAAG;AACjB,IAAA,MAAM,IAAI,KAAA,CAAM,CAA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