From c5d8ad577f8a526c02c1c7f9c01d60c3b045e90c Mon Sep 17 00:00:00 2001 From: Ishaan Gupta Date: Thu, 11 Jun 2026 19:17:20 +0530 Subject: [PATCH 1/2] Route Cursor OAuth through web app --- src/auth.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/auth.ts b/src/auth.ts index e854081..6dc1030 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,11 +1,11 @@ import path from "node:path"; import os from "node:os"; import fs from "node:fs"; +import { randomBytes } from "node:crypto"; const CREDENTIALS_DIR = path.join(os.homedir(), ".supermemory-cursor"); const CREDENTIALS_FILE = path.join(CREDENTIALS_DIR, "credentials.json"); -const AUTH_PORT = 19878; -const AUTH_URL = "https://console.supermemory.ai/auth/connect"; +const AUTH_URL = process.env.SUPERMEMORY_AUTH_URL || "https://app.supermemory.ai/auth/connect"; const SUCCESS_HTML = `

Connected to Cursor!

`; + + + Connected - Supermemory + + + + +
+
Connected
+
+
+ + +
+ +
+
+

Cursor is connected

+

Supermemory is ready to provide persistent context inside Cursor.

+
You can close this tab and return to Cursor.
+
+ +`; export function loadCredentials(): { apiKey: string; createdAt: string } | null { try { @@ -54,6 +174,16 @@ export async function startAuthFlow( hostname: "127.0.0.1", fetch(req) { const url = new URL(req.url); + + if (url.pathname === "/cursor.png") { + return new Response(Bun.file(CURSOR_LOGO_FILE), { + headers: { + "Content-Type": "image/png", + "Cache-Control": "no-store", + }, + }); + } + if (url.pathname !== "/callback") { return new Response("Not found", { status: 404 }); } @@ -98,7 +228,7 @@ export async function startAuthFlow( async function openUrl(url: string): Promise { if (process.platform === "win32") { - const result = await Bun.spawn(["cmd.exe", "/c", "start", "", url]).exited; + const result = await Bun.spawn(["rundll32.exe", "url.dll,FileProtocolHandler", url]).exited; if (result !== 0) throw new Error(`browser opener exited with code ${result}`); return; } diff --git a/src/hooks/session-start.ts b/src/hooks/session-start.ts index 6ac5dbf..af501c9 100644 --- a/src/hooks/session-start.ts +++ b/src/hooks/session-start.ts @@ -48,7 +48,7 @@ async function main() { process.stdout.write(JSON.stringify({ continue: true, hookSpecificOutput: { - hookEventName: "sessionStart", + hookEventName: "SessionStart", additionalContext: context, }, }));