upfynai-code 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "upfynai-code",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Upfyn-Code — Visual AI coding interface with Upfyn-Canvas whiteboard for AI coding assistants by Thinqmesh Technologies",
5
5
  "type": "module",
6
6
  "main": "server/index.js",
package/server/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * Upfyn-Code CLI
4
4
  * by Thinqmesh Technologies
@@ -184,7 +184,7 @@ Options:
184
184
  Examples:
185
185
  $ uc # Start with defaults
186
186
  $ uc --port 8080 # Start on port 8080
187
- $ uc connect --key rt_xxx # Bridge to hosted server
187
+ $ uc connect --key upfyn_xxx # Bridge to hosted server
188
188
  $ uc start --port 4000 # Explicit start command
189
189
  $ uc status # Show configuration
190
190
 
@@ -220,7 +220,7 @@ const runMigrations = async () => {
220
220
  // Relay token
221
221
  const tokens = await db.execute({ sql: 'SELECT id FROM relay_tokens WHERE user_id = ? LIMIT 1', args: [user.id] });
222
222
  if (tokens.rows.length === 0) {
223
- const token = 'rt_' + crypto.randomBytes(32).toString('hex');
223
+ const token = 'upfyn_' + crypto.randomBytes(32).toString('hex');
224
224
  await db.execute({ sql: 'INSERT INTO relay_tokens (user_id, token, name) VALUES (?, ?, ?)', args: [user.id, token, 'default'] });
225
225
  backfilled++;
226
226
  }
@@ -567,7 +567,7 @@ const paymentDb = {
567
567
  // ─── Relay Tokens DB ────────────────────────────────────────────────────────────
568
568
 
569
569
  const relayTokensDb = {
570
- generateToken: () => 'rt_' + crypto.randomBytes(32).toString('hex'),
570
+ generateToken: () => 'upfyn_' + crypto.randomBytes(32).toString('hex'),
571
571
 
572
572
  createToken: async (userId, name = 'default') => {
573
573
  const token = relayTokensDb.generateToken();
package/server/index.js CHANGED
@@ -1228,7 +1228,7 @@ function handleChatConnection(ws) {
1228
1228
  // Handle relay WebSocket connections (local machine ↔ server bridge)
1229
1229
  async function handleRelayConnection(ws, token) {
1230
1230
  if (!token) {
1231
- ws.send(JSON.stringify({ type: 'error', error: 'Relay token required. Use ?token=rt_xxx' }));
1231
+ ws.send(JSON.stringify({ type: 'error', error: 'Relay token required. Use ?token=upfyn_xxx' }));
1232
1232
  ws.close();
1233
1233
  return;
1234
1234
  }
@@ -474,12 +474,12 @@ export async function mountMcpServer(app, mcpServer, mcpServerFactory) {
474
474
  } catch (e) { /* fall through */ }
475
475
  }
476
476
 
477
- // 2. Try Bearer token — supports JWT, relay token (rt_), or API key (up-cli-)
477
+ // 2. Try Bearer token — supports JWT, relay token (upfyn_/rt_), or API key (up-cli-)
478
478
  const authHeader = req.headers['authorization'];
479
479
  const token = authHeader && authHeader.split(' ')[1];
480
480
  if (token) {
481
- // 2a. Relay token (rt_xxx) — same token used for CLI connect
482
- if (token.startsWith('rt_')) {
481
+ // 2a. Relay token (upfyn_xxx or legacy rt_xxx) — same token used for CLI connect
482
+ if (token.startsWith('upfyn_') || token.startsWith('rt_')) {
483
483
  try {
484
484
  const tokenData = await relayTokensDb.validateToken(token);
485
485
  if (tokenData) {
@@ -1,5 +1,5 @@
1
1
  import jwt from 'jsonwebtoken';
2
- import { userDb } from '../database/db.js';
2
+ import { userDb, relayTokensDb } from '../database/db.js';
3
3
  import { IS_PLATFORM } from '../constants/config.js';
4
4
 
5
5
  const JWT_SECRET = process.env.JWT_SECRET?.trim();
@@ -127,6 +127,17 @@ const authenticateWebSocket = async (request) => {
127
127
 
128
128
  if (!token) return null;
129
129
 
130
+ // Relay token (upfyn_ prefix) — validate against DB, not JWT
131
+ if (token.startsWith('upfyn_') || token.startsWith('rt_')) {
132
+ try {
133
+ const tokenData = await relayTokensDb.validateToken(token);
134
+ if (tokenData) {
135
+ return { userId: Number(tokenData.user_id), username: tokenData.username };
136
+ }
137
+ } catch {}
138
+ return null;
139
+ }
140
+
130
141
  try {
131
142
  const decoded = jwt.verify(token, JWT_SECRET);
132
143
  // Validate against Turso — DB is source of truth
@@ -6,7 +6,7 @@
6
6
  * Bridges Claude CLI, terminal, filesystem, and git to the web UI.
7
7
  *
8
8
  * Usage:
9
- * upfynai-code connect --server https://upfynai.thinqmesh.com --key rt_xxx
9
+ * upfynai-code connect --server https://upfynai.thinqmesh.com --key upfyn_xxx
10
10
  * upfynai-code connect (uses saved config from ~/.upfynai/config.json)
11
11
  */
12
12
 
@@ -217,7 +217,7 @@ export async function connectToServer(options = {}) {
217
217
  if (!relayKey) {
218
218
  console.error(c.red('No relay key provided.'));
219
219
  console.log('Generate a relay token from Settings > Relay Tokens in the web UI.');
220
- console.log(`Then run: ${c.cyan('upfynai-code connect --key rt_your_token_here')}`);
220
+ console.log(`Then run: ${c.cyan('upfynai-code connect --key upfyn_your_token_here')}`);
221
221
  process.exit(1);
222
222
  }
223
223