@emesoft/tokenhub 0.8.4 → 0.8.5

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/lib/pair.js +10 -4
  2. package/package.json +1 -1
package/lib/pair.js CHANGED
@@ -260,7 +260,10 @@ export async function runConnect({
260
260
  log(`Error: the pool rejected the pairing request (HTTP ${start.status}).`);
261
261
  return 1;
262
262
  }
263
- const { deviceCode, userCode, verifyUrl, interval, expiresIn } = start.body;
263
+ const { deviceCode, userCode, verifyUrl: rawVerifyUrl, interval, expiresIn } = start.body;
264
+ const verifyUrl = pool.startsWith("https://") && String(rawVerifyUrl || "").startsWith("http://")
265
+ ? rawVerifyUrl.replace(/^http:\/\//, "https://")
266
+ : rawVerifyUrl;
264
267
  log("");
265
268
  log(` Your code: ${userCode}`);
266
269
  log("");
@@ -279,18 +282,21 @@ export async function runConnect({
279
282
  const poll = await postJson(`${pool}/pair/poll`, { deviceCode }, signal);
280
283
  if (poll.status === 429) continue;
281
284
  const status = poll.body?.status;
285
+ const baseUrl = pool.startsWith("https://") && String(poll.body?.baseUrl || "").startsWith("http://")
286
+ ? poll.body.baseUrl.replace(/^http:\/\//, "https://")
287
+ : poll.body?.baseUrl || pool;
282
288
  if (status === "approved" && admin) {
283
289
  if (poll.body.kind !== "admin") {
284
290
  log("Error: the pool did not issue an admin device token. Update the pool, then run the command again.");
285
291
  return 1;
286
292
  }
287
- writeAdminConfig(adminFile, poll.body.baseUrl, poll.body.key);
293
+ writeAdminConfig(adminFile, baseUrl, poll.body.key);
288
294
  log(`Admin device paired. Token saved to ${adminFile}`);
289
- log(`Revoke it any time on the pool's admin Devices page (${poll.body.baseUrl}/admin/pair).`);
295
+ log(`Revoke it any time on the pool's admin Devices page (${baseUrl}/admin/pair).`);
290
296
  return 0;
291
297
  }
292
298
  if (status === "approved") {
293
- const statusResult = connectSettings(settingsFile, poll.body.baseUrl, poll.body.key, { statusLine });
299
+ const statusResult = connectSettings(settingsFile, baseUrl, poll.body.key, { statusLine });
294
300
  log(`Connected. Claude Code settings updated: ${settingsFile}`);
295
301
  if (statusResult === "installed") log("Status line added: today's spend and credit show under the Claude Code prompt.");
296
302
  if (statusResult === "updated") log("Status line refreshed with your new key.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emesoft/tokenhub",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Connect Claude Code to a TokenHub pool in one command, and track your spend from the terminal",
5
5
  "keywords": [
6
6
  "claude",