diff --git a/packages/cli/src/digitalocean/digitalocean.ts b/packages/cli/src/digitalocean/digitalocean.ts index 890afc53..54d94e85 100644 --- a/packages/cli/src/digitalocean/digitalocean.ts +++ b/packages/cli/src/digitalocean/digitalocean.ts @@ -6,7 +6,7 @@ import type { CloudInitTier } from "../shared/agents"; import { mkdirSync, readFileSync } from "node:fs"; import { handleBillingError, isBillingError, showNonBillingError } from "../shared/billing-guidance"; import { getPackagesForTier, NODE_INSTALL_CMD, needsBun, needsNode } from "../shared/cloud-init"; -import { OAUTH_CSS } from "../shared/oauth"; +import { generateCsrfState, OAUTH_CSS } from "../shared/oauth"; import { parseJsonObj } from "../shared/parse"; import { getSpawnCloudConfigPath } from "../shared/paths"; import { @@ -313,12 +313,6 @@ const OAUTH_SUCCESS_HTML = `

Authorization Failed

Invalid or missing state parameter (CSRF protection). Please try again.

`; -function generateCsrfState(): string { - const bytes = new Uint8Array(16); - crypto.getRandomValues(bytes); - return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join(""); -} - async function tryRefreshDoToken(): Promise { const refreshToken = loadRefreshToken(); if (!refreshToken) { diff --git a/packages/cli/src/shared/oauth.ts b/packages/cli/src/shared/oauth.ts index 1c5fdcd4..2b95c5af 100644 --- a/packages/cli/src/shared/oauth.ts +++ b/packages/cli/src/shared/oauth.ts @@ -48,7 +48,7 @@ async function verifyOpenrouterKey(apiKey: string): Promise { // ─── OAuth Flow via Bun.serve ──────────────────────────────────────────────── -function generateCsrfState(): string { +export function generateCsrfState(): string { const bytes = new Uint8Array(16); crypto.getRandomValues(bytes); return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");