Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/cli/src/digitalocean/digitalocean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -313,12 +313,6 @@ const OAUTH_SUCCESS_HTML = `<html><head><meta name="viewport" content="width=dev

const OAUTH_ERROR_HTML = `<html><head><meta name="viewport" content="width=device-width,initial-scale=1"><style>${OAUTH_CSS}h1{color:#dc2626}@media(prefers-color-scheme:dark){h1{color:#ef4444}}</style></head><body><div class="card"><div class="icon">&#10007;</div><h1>Authorization Failed</h1><p>Invalid or missing state parameter (CSRF protection). Please try again.</p></div></body></html>`;

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<string | null> {
const refreshToken = loadRefreshToken();
if (!refreshToken) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/shared/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function verifyOpenrouterKey(apiKey: string): Promise<boolean> {

// ─── 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("");
Expand Down
Loading