Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(license): device-bound Upgrade flow (no key paste)
enes988fad37246d
diff --git a/src/main/license.ts b/src/main/license.tsindex 49aa59ac2..9a8543b05 100644--- a/src/main/license.ts+++ b/src/main/license.ts@@ -5,7 +5,7 @@import { promises as fs, readFileSync } from 'fs'import path from 'path'import crypto from 'node:crypto'-import { app, ipcMain, type BrowserWindow } from 'electron'+import { app, ipcMain, shell, type BrowserWindow } from 'electron'import { IPC } from '../shared/ipc'import type { LicenseStatus } from '../shared/types'import { getDeviceId } from './device-id'@@ -13,6 +13,11 @@ import { ENTITLEMENT_PUBLIC_KEY } from './entitlement-key'const API_BASE = process.env.NODETERM_API_BASE || 'https://api.nodeterm.dev'+// Stripe Payment Link for the Pro subscription. The app appends ?client_reference_id=<deviceId>+// so the webhook binds the purchase to this device → keyless ("device-bound") activation.+// Replace with your real Payment Link (Stripe → Payment Links).+const CHECKOUT_URL = process.env.NODETERM_CHECKOUT_URL || 'https://buy.stripe.com/REPLACE_ME'+// Same gate as telemetry/check: never hit the prod API from a dev/unsigned build unless a// local server is targeted explicitly, and honor DO_NOT_TRACK / the kill switch.function allowed(): boolean {@@ -92,6 +97,21 @@ async function call(path: string, body: unknown): Promise<{ token?: string; erro}}+// GET helper for the device-bound status poll.+async function getJson(path: string): Promise<{ active?: boolean; token?: string; error?: string }> {+ if (!allowed()) return { error: 'disabled' }+ try {+ const ctrl = new AbortController()+ const t = setTimeout(() => ctrl.abort(), 8000)+ const res = await fetch(`${API_BASE}${path}`, { signal: ctrl.signal }).finally(() => clearTimeout(t))+ const json = (await res.json().catch(() => ({}))) as { active?: boolean; token?: string; error?: string }+ if (!res.ok) return { error: json.error ?? 'network' }+ return json+ } catch {+ return { error: 'offline' }+ }+}+export function initLicense(win: BrowserWindow): void {const deviceId = getDeviceId()const broadcast = (s: LicenseStatus) => {@@ -100,6 +120,34 @@ export function initLicense(win: BrowserWindow): void {ipcMain.handle(IPC.licenseStatus, () => statusFrom(load().token))+ // Device-bound upgrade: open Stripe checkout (carrying our deviceId), then poll the status+ // endpoint until the webhook has bound + minted the entitlement. Status arrives via broadcast.+ let polling = false+ ipcMain.handle(IPC.licenseUpgrade, async () => {+ const url = `${CHECKOUT_URL}${CHECKOUT_URL.includes('?') ? '&' : '?'}client_reference_id=${encodeURIComponent(deviceId)}`+ await shell.openExternal(url)+ if (!polling) {+ polling = true+ const deadline = Date.now() + 6 * 60 * 1000 // poll up to 6 min after opening checkout+ const poll = async (): Promise<void> => {+ if (Date.now() > deadline) {+ polling = false+ return+ }+ const r = await getJson(`/v1/license/status?deviceId=${encodeURIComponent(deviceId)}`)+ if (r.active && r.token) {+ await save({ key: load().key, token: r.token })+ broadcast(statusFrom(r.token))+ polling = false+ return+ }+ setTimeout(() => void poll(), 4000)+ }+ setTimeout(() => void poll(), 4000)+ }+ return statusFrom(load().token)+ })+ipcMain.handle(IPC.licenseActivate, async (_e, key: string) => {const r = await call('/v1/license/activate', { key: String(key).trim(), deviceId })if (r.token) await save({ key: String(key).trim(), token: r.token })diff --git a/src/preload/index.ts b/src/preload/index.tsindex c880cba9f..043521022 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -114,6 +114,7 @@ const api: NodeTerminalApi = {restart: () => ipcRenderer.send(IPC.appRestartToUpdate)},license: {+ upgrade: () => ipcRenderer.invoke(IPC.licenseUpgrade),activate: (key: string) => ipcRenderer.invoke(IPC.licenseActivate, key),deactivate: () => ipcRenderer.invoke(IPC.licenseDeactivate),getStatus: () => ipcRenderer.invoke(IPC.licenseStatus),diff --git a/src/renderer/components/SettingsPanel.tsx b/src/renderer/components/SettingsPanel.tsxindex 238999050..387841dc2 100644--- a/src/renderer/components/SettingsPanel.tsx+++ b/src/renderer/components/SettingsPanel.tsx@@ -26,6 +26,7 @@ export function SettingsPanel({ onClose }: SettingsPanelProps) {const ent = useEntitlement()const [licenseKey, setLicenseKey] = useState('')+ const [upgrading, setUpgrading] = useState(false)useEffect(() => {void ent.hydrate()}, [])@@ -392,30 +393,49 @@ export function SettingsPanel({ onClose }: SettingsPanelProps) {</>) : (<>- <label className="set-row">- <span>License key</span>- <input- type="text"- placeholder="paste your key"- value={licenseKey}- onChange={(e) => setLicenseKey(e.target.value)}- />- </label><buttonclassName="set-btn"onClick={() => {- if (licenseKey.trim()) void ent.activate(licenseKey.trim())+ setUpgrading(true)+ void ent.upgrade()}}>- Activate+ Upgrade to Pro — $29/mo</button>- {ent.status.error ? (- <p className="set-note" style={{ color: '#ff9f0a' }}>- Could not activate ({ent.status.error}).+ {upgrading ? (+ <p className="set-note">+ Complete your purchase in the browser — Pro unlocks here automatically.</p>) : (- <p className="set-note">Enter a key to unlock Pro features.</p>+ <p className="set-note">Unlock remote access and Pro features.</p>)}+ <details>+ <summary className="set-note" style={{ cursor: 'pointer' }}>+ Have a license key?+ </summary>+ <label className="set-row">+ <span>License key</span>+ <input+ type="text"+ placeholder="paste your key"+ value={licenseKey}+ onChange={(e) => setLicenseKey(e.target.value)}+ />+ </label>+ <button+ className="set-btn"+ onClick={() => {+ if (licenseKey.trim()) void ent.activate(licenseKey.trim())+ }}+ >+ Activate+ </button>+ {ent.status.error ? (+ <p className="set-note" style={{ color: '#ff9f0a' }}>+ Could not activate ({ent.status.error}).+ </p>+ ) : null}+ </details></>)}</section>diff --git a/src/renderer/state/entitlement.ts b/src/renderer/state/entitlement.tsindex 4e2aaa03b..dd79f530a 100644--- a/src/renderer/state/entitlement.ts+++ b/src/renderer/state/entitlement.ts@@ -6,6 +6,8 @@ interface EntitlementState {/** True when an active Pro entitlement is present — features gate on this. */isPremium: booleanhydrate(): Promise<void>+ /** Open Stripe checkout for this device; Pro arrives via onChange when the purchase lands. */+ upgrade(): Promise<void>activate(key: string): Promise<void>deactivate(): Promise<void>}@@ -22,6 +24,9 @@ export const useEntitlement = create<EntitlementState>((set) => {async hydrate() {apply(await window.nodeTerminal.license.getStatus())},+ async upgrade() {+ apply(await window.nodeTerminal.license.upgrade())+ },async activate(key) {apply(await window.nodeTerminal.license.activate(key))},diff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex cc732b173..ec819d36c 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -34,6 +34,7 @@ export const IPC = {licenseDeactivate: 'license:deactivate',licenseStatus: 'license:status',licenseChanged: 'license:changed',+ licenseUpgrade: 'license:upgrade',appRestartToUpdate: 'app:restart-to-update',announcementsFetch: 'announcements:fetch',usageFetch: 'usage:fetch',diff --git a/src/shared/types.ts b/src/shared/types.tsindex 18fcfb22c..9fadd91fd 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -494,6 +494,9 @@ export interface LicenseStatus {}export interface LicenseApi {+ /** Open Stripe checkout bound to this device and poll for the entitlement (no key paste).+ * Returns the current status immediately; the active status arrives via onChange. */+ upgrade(): Promise<LicenseStatus>/** Activate a license key on this device. Returns the resulting status. */activate(key: string): Promise<LicenseStatus>/** Release this device's seat and clear the local license. */