@vosjs/cli 0.48.0 → 0.48.1

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/README.md CHANGED
@@ -270,6 +270,7 @@ Everything that runs on your machine is open source; [vos.so](https://vos.so) is
270
270
 
271
271
  ```bash
272
272
  vos login [--key <k>] [--label <name>] [--no-browser] # browser sign-in: a code and a vos.so/cli/auth URL, a human approves, the key stores itself
273
+ vos login --handoff https://vos.so/h/<token> # the setup link a signed-in person's line carries: exchanged once for a key, no click
273
274
  vos fetch <vosId|url> [--out <slug>] [--media] # a program writes config.json + vos.json; a take writes doc.json (+ the recording with --media)
274
275
  vos check bright-loop/config.json # full local validation
275
276
  vos push bright-loop/config.json # untracked: create a PRIVATE vos. Tracked (vos.json): add a version to it
@@ -9059,6 +9059,41 @@ async function browserLogin(origin, r, opts) {
9059
9059
  "no approval within 15 minutes \u2014 run `vos login` again, or mint a key at https://vos.so/app/api and pass --key"
9060
9060
  );
9061
9061
  }
9062
+ var HANDOFF_URL = /^(https?:\/\/[^/]+)\/h\/(vos_ho_[A-Za-z0-9_-]+)$/;
9063
+ function parseHandoffUrl(url) {
9064
+ const m = HANDOFF_URL.exec(url.trim());
9065
+ return m ? { origin: m[1], token: m[2] } : null;
9066
+ }
9067
+ async function handoffLogin(url, r, opts = {}) {
9068
+ const parsed = parseHandoffUrl(url);
9069
+ if (!parsed)
9070
+ throw new Error(
9071
+ "--handoff wants the link a person copied from vos.so, https://vos.so/h/vos_ho_\u2026"
9072
+ );
9073
+ r.log(`exchanging the setup link at ${parsed.origin}\u2026`);
9074
+ const res = await apiJson(parsed.origin, "/api/cli/login/exchange", {
9075
+ method: "POST",
9076
+ body: { token: parsed.token, hostname: hostname().slice(0, 64) }
9077
+ });
9078
+ if (res.status === 200 && res.body.status === "ok") {
9079
+ const path = (opts.store ?? writeCredential)(res.body.key);
9080
+ const user = typeof res.body.user === "object" && res.body.user !== null ? res.body.user.name ?? "" : "";
9081
+ return {
9082
+ path,
9083
+ user,
9084
+ keyName: String(res.body.keyName ?? ""),
9085
+ origin: parsed.origin
9086
+ };
9087
+ }
9088
+ if (res.status === 404 && !res.body.status) {
9089
+ throw new Error(
9090
+ `${parsed.origin} does not support setup links yet \u2014 run \`vos login\` instead`
9091
+ );
9092
+ }
9093
+ const said = typeof res.body.error === "string" ? res.body.error : apiError("exchange", res);
9094
+ const hint = typeof res.body.hint === "string" ? ` ${res.body.hint}` : "";
9095
+ throw new Error(`${said}${hint}`);
9096
+ }
9062
9097
 
9063
9098
  // src/plugin/program.ts
9064
9099
  var BOOLEAN_FLAGS2 = /* @__PURE__ */ new Set([
@@ -9605,6 +9640,21 @@ async function cmdLogin(argv) {
9605
9640
  origin: strFlag(flags, "origin"),
9606
9641
  api: strFlag(flags, "api")
9607
9642
  });
9643
+ const handoffUrl = strFlag(flags, "handoff");
9644
+ if (handoffUrl) {
9645
+ const done = await handoffLogin(handoffUrl, r);
9646
+ r.done(
9647
+ {
9648
+ path: done.path,
9649
+ origin: done.origin,
9650
+ user: done.user,
9651
+ keyName: done.keyName,
9652
+ next_step: "the link is spent; vos push when you want the work hosted"
9653
+ },
9654
+ `Signed in${done.user ? ` as ${done.user}` : ""} \u2014 key "${done.keyName}" stored at ${done.path} (used by every vos platform verb). The link is spent.`
9655
+ );
9656
+ return EXIT_OK;
9657
+ }
9608
9658
  const explicit = strFlag(flags, "key") ?? process.env.VOS_API_KEY?.trim();
9609
9659
  if (explicit) return storeKey(explicit, origin, r);
9610
9660
  try {
@@ -11381,10 +11431,12 @@ This machine (no account)
11381
11431
  remove ~/.config/vos/credentials (VOS_API_KEY still resolves)
11382
11432
 
11383
11433
  Platform (vos.so) \u2014 fetch, edit, push, pull, repeat
11384
- vos login [--key <vos_sk_\u2026>] [--label <name>] [--no-browser]
11434
+ vos login [--key <vos_sk_\u2026>] [--handoff <url>] [--label <name>] [--no-browser]
11385
11435
  sign in via the browser (approve at vos.so/cli/auth; works
11386
11436
  headless \u2014 print the URL, a human approves, the key stores
11387
- itself). --key skips the browser (mint at vos.so/app/api)
11437
+ itself). --key skips the browser (mint at vos.so/app/api).
11438
+ --handoff https://vos.so/h/\u2026 exchanges the setup link a
11439
+ signed-in person's line carries for a key, once, no click
11388
11440
  vos fetch <vosId|watch-url> [--out dir] [--media] [--json]
11389
11441
  writes config.json + vos.json (no auth needed for public programs);
11390
11442
  a take vos also gets its doc.json, and --media its footage
@@ -13274,4 +13326,4 @@ export {
13274
13326
  verbHelp,
13275
13327
  run
13276
13328
  };
13277
- //# sourceMappingURL=chunk-ANKECV7F.js.map
13329
+ //# sourceMappingURL=chunk-RHPRZQRM.js.map