@floomhq/skills 0.2.10 → 0.2.11

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/dist/index.js CHANGED
@@ -2395,7 +2395,7 @@ var AUTH_FILE = join3(CONFIG_DIR, "auth.json");
2395
2395
  var DEFAULT_APP_URL = "https://skills.floom.dev";
2396
2396
  var DEFAULT_API_URL = "https://skills.floom.dev/api/v1";
2397
2397
  var LEGACY_API_HOSTS = /* @__PURE__ */ new Set(["floom-v0.vercel.app", "skills.wasm.floom.dev"]);
2398
- var TRUSTED_API_HOSTS = /* @__PURE__ */ new Set(["skills.floom.dev", "skills.wasm.floom.dev", "localhost", "127.0.0.1", "::1"]);
2398
+ var TRUSTED_API_HOSTS = /* @__PURE__ */ new Set(["skills.floom.dev", "skills.wasm.floom.dev"]);
2399
2399
  async function ensureDir() {
2400
2400
  await mkdir2(CONFIG_DIR, { recursive: true, mode: 448 });
2401
2401
  }
@@ -2484,7 +2484,7 @@ function isLegacyApiUrl(apiUrl) {
2484
2484
  }
2485
2485
 
2486
2486
  // src/version.ts
2487
- var VERSION = "0.2.10";
2487
+ var VERSION = "0.2.11";
2488
2488
 
2489
2489
  // src/api-client.ts
2490
2490
  var DEFAULT_TIMEOUT_MS = 2e4;
@@ -2615,7 +2615,7 @@ async function loginCommand() {
2615
2615
  log.info(`Open this URL in your browser:`);
2616
2616
  log.info(` ${session.verification_uri}`);
2617
2617
  log.info("");
2618
- log.info(`Your code: ${session.user_code}`);
2618
+ log.info(`Confirm this code in the browser: ${session.user_code}`);
2619
2619
  log.info("");
2620
2620
  log.info("Waiting for approval in the browser. Press Ctrl+C to cancel.");
2621
2621
  openInBrowser(session.verification_uri).catch(() => {
@@ -2684,7 +2684,13 @@ async function whoamiCommand() {
2684
2684
  try {
2685
2685
  me = await api("/me", { authRequired: true });
2686
2686
  } catch (e) {
2687
- log.err(`Login is not accepted by the Floom API: ${e.message}`);
2687
+ if (e instanceof FloomError && e.code === "TOKEN_EXPIRED") {
2688
+ log.err("Login expired.");
2689
+ } else if (e instanceof FloomError && e.code === "TOKEN_INVALID") {
2690
+ log.err("Login revoked or unknown.");
2691
+ } else {
2692
+ log.err(`Login is not accepted by the Floom API: ${e.message}`);
2693
+ }
2688
2694
  log.info("Run: floom login");
2689
2695
  process.exitCode = 1;
2690
2696
  return;
@@ -3414,12 +3420,19 @@ async function infoCommand(refStr) {
3414
3420
  }
3415
3421
 
3416
3422
  // src/commands/share.ts
3423
+ function isValidEmail(email) {
3424
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
3425
+ }
3417
3426
  async function shareCommand(refStr, email, opts = {}) {
3418
3427
  const ref = parseSkillRef(refStr);
3419
3428
  if (!ref) {
3420
3429
  log.err(`Invalid skill ref: ${refStr}`);
3421
3430
  process.exit(1);
3422
3431
  }
3432
+ if (!isValidEmail(email)) {
3433
+ log.err(`Invalid email: ${email}`);
3434
+ process.exit(1);
3435
+ }
3423
3436
  const role = opts.role ?? "viewer";
3424
3437
  const r = await api(`/skills/${ref.owner}/${ref.slug}/grants`, {
3425
3438
  method: "POST",
@@ -3435,6 +3448,10 @@ async function unshareCommand(refStr, email) {
3435
3448
  log.err(`Invalid skill ref: ${refStr}`);
3436
3449
  process.exit(1);
3437
3450
  }
3451
+ if (!isValidEmail(email)) {
3452
+ log.err(`Invalid email: ${email}`);
3453
+ process.exit(1);
3454
+ }
3438
3455
  const list = await api(`/skills/${ref.owner}/${ref.slug}/grants`, { authRequired: true });
3439
3456
  const grant = list.grants.find((g) => (g.email ?? "").toLowerCase() === email.toLowerCase());
3440
3457
  if (!grant) {
@@ -3446,6 +3463,9 @@ async function unshareCommand(refStr, email) {
3446
3463
  }
3447
3464
 
3448
3465
  // src/commands/library.ts
3466
+ function isValidEmail2(email) {
3467
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
3468
+ }
3449
3469
  async function libraryListCommand() {
3450
3470
  const resp = await api("/libraries", { authRequired: true });
3451
3471
  if (!resp.libraries.length) {
@@ -3461,6 +3481,10 @@ async function libraryCreateCommand(slug, name) {
3461
3481
  log.ok(`Created workspace ${resp.slug}`);
3462
3482
  }
3463
3483
  async function libraryInviteCommand(librarySlug, email, role = "viewer") {
3484
+ if (!isValidEmail2(email)) {
3485
+ log.err(`Invalid email: ${email}`);
3486
+ process.exit(1);
3487
+ }
3464
3488
  await api(`/libraries/${librarySlug}/pending-invites`, {
3465
3489
  method: "POST",
3466
3490
  authRequired: true,