tthr 0.3.24 → 0.3.26

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -18
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -2207,24 +2207,28 @@ async function requestDeviceCode() {
2207
2207
  const userCode = generateUserCode();
2208
2208
  const deviceCode = crypto.randomUUID();
2209
2209
  const deviceName = os.hostname();
2210
- const response = await fetch(`${API_URL}/auth/device`, {
2211
- method: "POST",
2212
- headers: { "Content-Type": "application/json" },
2213
- body: JSON.stringify({ userCode, deviceCode, deviceName })
2214
- }).catch(() => null);
2215
- if (response?.ok) {
2216
- return await response.json();
2217
- }
2218
- const baseUrl = API_URL.replace(/\/api\/v1$/, "");
2219
- return {
2220
- deviceCode,
2221
- userCode,
2222
- expiresIn: 60,
2223
- // 1 minute
2224
- interval: 5,
2225
- // Poll every 5 seconds
2226
- authUrl: `${baseUrl}/cli`
2227
- };
2210
+ let response;
2211
+ try {
2212
+ response = await fetch(`${API_URL}/auth/device`, {
2213
+ method: "POST",
2214
+ headers: { "Content-Type": "application/json" },
2215
+ body: JSON.stringify({ userCode, deviceCode, deviceName })
2216
+ });
2217
+ } catch (err) {
2218
+ throw new Error(
2219
+ `Could not reach the Tether API at ${API_URL}: ${err instanceof Error ? err.message : String(err)}
2220
+ Set TETHER_API_URL in your shell or .env.local if your server is elsewhere.`
2221
+ );
2222
+ }
2223
+ if (!response.ok) {
2224
+ const body = await response.text().catch(() => "");
2225
+ throw new Error(
2226
+ `Tether API at ${API_URL} returned ${response.status} ${response.statusText} when requesting a device code.
2227
+ ` + (body ? `Response: ${body.slice(0, 300)}
2228
+ ` : "") + `Check that TETHER_API_URL points at a Tether server (not a dashboard / proxy).`
2229
+ );
2230
+ }
2231
+ return await response.json();
2228
2232
  }
2229
2233
  async function pollForApproval(deviceCode, interval, expiresIn) {
2230
2234
  const startTime = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tthr",
3
- "version": "0.3.24",
3
+ "version": "0.3.26",
4
4
  "description": "Tether CLI - project scaffolding and deployment",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,12 +17,6 @@
17
17
  "files": [
18
18
  "dist"
19
19
  ],
20
- "scripts": {
21
- "build": "tsup src/index.ts --format esm --dts --clean",
22
- "dev": "tsup src/index.ts --format esm --watch --clean",
23
- "typecheck": "tsc --noEmit",
24
- "start": "TETHER_DEV=true node dist/index.js"
25
- },
26
20
  "dependencies": {
27
21
  "chalk": "^5.4.1",
28
22
  "chokidar": "^5.0.0",
@@ -38,5 +32,11 @@
38
32
  "@types/prompts": "^2.4.9",
39
33
  "tsup": "^8.3.6",
40
34
  "typescript": "^5.7.2"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup src/index.ts --format esm --dts --clean",
38
+ "dev": "tsup src/index.ts --format esm --watch --clean",
39
+ "typecheck": "tsc --noEmit",
40
+ "start": "TETHER_DEV=true node dist/index.js"
41
41
  }
42
- }
42
+ }