Skip to main content
@daex-dev/sdk/connect adds Sign in with ChatGPT and Sign in with Cursor to your app. A user signs in once, from a web page, desktop app or phone. Your server keeps the sign-in sealed and renewed, and makes AI calls with it on the user’s own plan. This entry point does not start a DAEX runtime.

Server

handler is a Fetch API handler that returns null for paths outside /connect. On Node or Express, mount it with app.use(toNodeListener(handler)). In a Next.js route, return a 404 for null.

Page

OpenAI sends the browser back to http://127.0.0.1:… after a ChatGPT sign-in. A web page can’t receive that, so the tab shows a page that can’t load, and the user pastes its address. A desktop app catches the redirect itself with signInWithCodexOnThisDevice.

Requests

On the server, createConnectAI({ vault }).respond(userId, request) does the same without HTTP. From a browser, the handler takes the model, instructions, messages, effort, format and Cursor params. Raw codex fields and Cursor agent / send options act with your server’s authority (Cursor’s MCP servers are processes on your server), so a page can’t set them. Pass them on in prepareRequest when you want to.

Errors

Every failure is a ConnectError with a code:

Storage and security

  • Each sign-in is sealed with AES-256-GCM under a key derived from your secret. A row copied to another user’s key does not open, and keys hold a hash of the user ID.
  • ChatGPT refresh tokens rotate on every use. The vault runs refreshes, saves and sign-outs of a sign-in one at a time, so a refresh never undoes a sign-out. With several server instances, give the storage a lock.
  • POSTs must be application/json, so a cross-site form can’t act for a signed-in user.
  • Cursor runs on an in-memory file tree, and each run’s folder is deleted when it ends, so no conversation stays on your server’s disk.