@localskills/cli 0.12.1 → 0.12.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.
Files changed (2) hide show
  1. package/dist/index.js +7 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -164,7 +164,6 @@ import { Command as Command10 } from "commander";
164
164
 
165
165
  // src/commands/auth.ts
166
166
  import { Command } from "commander";
167
- import { randomBytes, createHash } from "crypto";
168
167
  import { spawn } from "child_process";
169
168
 
170
169
  // ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
@@ -1487,11 +1486,6 @@ var ApiClient = class {
1487
1486
  };
1488
1487
 
1489
1488
  // src/commands/auth.ts
1490
- var USER_CODE_CHARS = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
1491
- function generateUserCode(length = 8) {
1492
- const bytes = randomBytes(length);
1493
- return Array.from(bytes).map((b) => USER_CODE_CHARS[b % USER_CODE_CHARS.length]).join("");
1494
- }
1495
1489
  function openBrowser(url) {
1496
1490
  try {
1497
1491
  const platform = process.platform;
@@ -1557,18 +1551,15 @@ var loginCommand = new Command("login").description("Log in to localskills.sh").
1557
1551
  We("localskills login");
1558
1552
  const spinner = bt2();
1559
1553
  spinner.start("Initializing...");
1560
- const deviceCode = randomBytes(32);
1561
- const codeHash = createHash("sha256").update(deviceCode).digest("hex");
1562
- const userCode = generateUserCode();
1563
1554
  const client = new ApiClient();
1564
- const initRes = await client.post("/api/cli/auth/device", { codeHash, userCode });
1555
+ const initRes = await client.post("/api/cli/auth/device");
1565
1556
  if (!initRes.success || !initRes.data) {
1566
1557
  spinner.stop(`Failed: ${initRes.error || "Could not start login"}`);
1567
1558
  process.exit(1);
1568
1559
  return;
1569
1560
  }
1570
1561
  spinner.stop("Ready!");
1571
- const { verificationUrl } = initRes.data;
1562
+ const { deviceCode, verificationUrl, userCode } = initRes.data;
1572
1563
  R2.info(`Your verification code: ${userCode}`);
1573
1564
  R2.message(`Opening browser to ${verificationUrl}`);
1574
1565
  R2.message("If the browser doesn't open, visit the URL above manually.");
@@ -1576,12 +1567,13 @@ var loginCommand = new Command("login").description("Log in to localskills.sh").
1576
1567
  const pollSpinner = bt2();
1577
1568
  pollSpinner.start("Waiting for authorization...");
1578
1569
  const expiresAt = new Date(initRes.data.expiresAt).getTime();
1579
- const POLL_INTERVAL = 2e3;
1570
+ const pollInterval = Math.max(1, initRes.data.interval || 2) * 1e3;
1580
1571
  while (Date.now() < expiresAt) {
1581
- await sleep(POLL_INTERVAL);
1572
+ await sleep(pollInterval);
1582
1573
  try {
1583
- const pollRes = await client.get(
1584
- `/api/cli/auth/poll?code_hash=${codeHash}`
1574
+ const pollRes = await client.post(
1575
+ "/api/cli/auth/poll",
1576
+ { deviceCode }
1585
1577
  );
1586
1578
  if (!pollRes.success || !pollRes.data) continue;
1587
1579
  if (pollRes.data.status === "approved" && pollRes.data.token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localskills/cli",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "CLI for localskills.sh — install agent skills locally",
5
5
  "type": "module",
6
6
  "bin": {