specbox 6.14.0 → 6.14.2

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/lib/internal.mjs CHANGED
@@ -124,7 +124,22 @@ export async function runInternal(command, ctx) {
124
124
  return 1;
125
125
  }
126
126
  if (res.status !== 200) {
127
- const reason = res.status === 401 ? "invalid_token" : res.status === 409 ? "conflict" : `http_${res.status}`;
127
+ let code = null;
128
+ try {
129
+ code = (await res.json())?.code ?? null;
130
+ } catch {
131
+ // sin cuerpo JSON
132
+ }
133
+ // UC-3902 AC-04 — `device_limit`: la cuenta ya tiene cinco dispositivos
134
+ // y este ordenador no cabe; la extensión enseña dónde desconectar uno.
135
+ const reason =
136
+ res.status === 401
137
+ ? "invalid_token"
138
+ : res.status === 409
139
+ ? code === "device_limit"
140
+ ? "device_limit"
141
+ : "conflict"
142
+ : `http_${res.status}`;
128
143
  out({ ok: false, reason });
129
144
  return 1;
130
145
  }
package/lib/login.mjs CHANGED
@@ -81,6 +81,7 @@ export async function deviceLogin({
81
81
  }
82
82
  if (error === "access_denied") throw new LoginError("denied");
83
83
  if (error === "expired_token" || error === "invalid_grant") throw new LoginError("expired");
84
+ if (error === "device_limit") throw new LoginError("device_limit"); // UC-3902 AC-04
84
85
  throw new LoginError("unexpected", `HTTP ${res.status} ${error ?? ""}`.trim());
85
86
  }
86
87
  throw new LoginError("expired");
package/lib/messages.mjs CHANGED
@@ -84,6 +84,9 @@ export function messages(lang) {
84
84
  expired: es ? "✗ El código caducó antes de confirmarse. Ejecuta specbox login otra vez." : "✗ The code expired before it was confirmed. Run specbox login again.",
85
85
  rate_limited: es ? "✗ Demasiados intentos seguidos. Espera unos minutos." : "✗ Too many attempts in a row. Wait a few minutes.",
86
86
  network: es ? "✗ No hay conexión con el panel de SpecBox." : "✗ Cannot reach the SpecBox panel.",
87
+ device_limit: es
88
+ ? "✗ Tu cuenta ya tiene 5 dispositivos conectados. Desconecta uno en https://cloud.specbox.build/profile y ejecuta specbox login otra vez."
89
+ : "✗ Your account already has 5 connected devices. Disconnect one at https://cloud.specbox.build/profile and run specbox login again.",
87
90
  })[code] ?? (es ? `✗ No se pudo conectar (${code}).` : `✗ Could not connect (${code}).`),
88
91
  notConnected: es ? "Este ordenador no está conectado. Ejecuta: specbox login" : "This computer is not connected. Run: specbox login",
89
92
  statusTitle: es ? "SpecBox · este ordenador" : "SpecBox · this computer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specbox",
3
- "version": "6.14.0",
3
+ "version": "6.14.2",
4
4
  "description": "Conecta este ordenador a SpecBox sin copiar tokens: specbox login, status y logout.",
5
5
  "type": "module",
6
6
  "bin": {