@openbkn/bkn-sdk 0.1.1-alpha.3 → 0.1.1-alpha.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.
package/dist/cli.js CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  fetchAuthStatus,
19
19
  formatError,
20
20
  getUserSafe,
21
+ isHeadless,
21
22
  listPlatforms,
22
23
  logout,
23
24
  openBrowser,
@@ -35,7 +36,7 @@ import {
35
36
  use,
36
37
  whoami,
37
38
  writePlatformConfig
38
- } from "./chunk-APJNRHLS.js";
39
+ } from "./chunk-67GKXAWG.js";
39
40
 
40
41
  // src/cli.ts
41
42
  import { Command as Command16 } from "commander";
@@ -43,7 +44,7 @@ import { Command as Command16 } from "commander";
43
44
  // package.json
44
45
  var package_default = {
45
46
  name: "@openbkn/bkn-sdk",
46
- version: "0.1.1-alpha.3",
47
+ version: "0.1.1-alpha.5",
47
48
  description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
48
49
  type: "module",
49
50
  license: "Apache-2.0",
@@ -83,6 +84,7 @@ var package_default = {
83
84
  },
84
85
  dependencies: {
85
86
  "@clack/prompts": "^0.9.1",
87
+ "@openbkn/bkn-sdk": "^0.1.1-alpha.3",
86
88
  chalk: "^5.4.1",
87
89
  commander: "^13.1.0",
88
90
  "csv-parse": "^6.2.1",
@@ -448,7 +450,8 @@ function registerAuthLeaves(cmd) {
448
450
  timeoutMs: opts.timeout * 1e3
449
451
  });
450
452
  } else {
451
- const openInBrowser = !opts.device && opts.browser !== false;
453
+ const headless = isHeadless();
454
+ const openInBrowser = !opts.device && opts.browser !== false && !headless;
452
455
  tokens = await deviceLogin(url, {
453
456
  clientId: opts.clientId,
454
457
  audience: opts.audience,
@@ -463,6 +466,8 @@ User code: ${userCode}
463
466
  `
464
467
  );
465
468
  if (openInBrowser) openBrowser(target);
469
+ else if (headless && !opts.device && opts.browser !== false)
470
+ process.stderr.write("(headless \u2014 approve on any machine with a browser)\n");
466
471
  process.stderr.write("Waiting for authorization\u2026\n");
467
472
  }
468
473
  });
@@ -575,6 +580,7 @@ function authCommand() {
575
580
 
576
581
  // src/commands/admin.ts
577
582
  var int = (v) => Number.parseInt(v, 10);
583
+ var DEFAULT_RESET_PASSWORD = "openbkn";
578
584
  function adminCommand() {
579
585
  const admin = new Command2("admin").description(
580
586
  "Operator CLI (kweaver-admin): org, user, role, models, audit"
@@ -707,12 +713,21 @@ function adminCommand() {
707
713
  user.command("delete <id>").description("Delete a user").action(async (id, _opts, cmd) => {
708
714
  printJson(await clientFrom(cmd).admin.userDelete(id), outputOptions(cmd));
709
715
  });
710
- user.command("reset-password [id]").description("Reset a user's password (RSA-encrypted in transit)").option("--id <userId>", "explicit user UUID (alt to the positional id)").option("--user <account>", "resolve the user by account / login name").option("--password <s>", "the new password").option("--new-password <s>", "the new password (alias of --password)").option("--prompt-password", "prompt for the new password interactively").option("-y, --yes", "skip confirmation").action(async (id, opts, cmd) => {
716
+ user.command("reset-password [id]").description("Reset a user's password (defaults to the platform initial password)").option("--id <userId>", "explicit user UUID (alt to the positional id)").option("--user <account>", "resolve the user by account / login name").option("--password <s>", "the new password (default: platform initial 'openbkn')").option("--new-password <s>", "the new password (alias of --password)").option("-y, --yes", "skip confirmation").action(async (id, opts, cmd) => {
711
717
  const userId = id ?? opts.id ?? opts.user;
712
- const pwd = opts.password ?? opts.newPassword;
713
718
  if (!userId) throw new Error("Provide a user id (positional or --id).");
714
- if (!pwd) throw new Error("Provide --password / --new-password.");
715
- printJson(await clientFrom(cmd).admin.userResetPassword(userId, pwd), outputOptions(cmd));
719
+ const pwd = opts.password ?? opts.newPassword ?? DEFAULT_RESET_PASSWORD;
720
+ const r = await clientFrom(cmd).admin.userResetPassword(userId, pwd);
721
+ const out = outputOptions(cmd);
722
+ if (out.json || out.compact) printJson(r, out);
723
+ else if (opts.password || opts.newPassword)
724
+ process.stdout.write(`Password reset for ${userId}.
725
+ `);
726
+ else
727
+ process.stdout.write(
728
+ `Password reset for ${userId} to the initial password '${DEFAULT_RESET_PASSWORD}' (must change on next login).
729
+ `
730
+ );
716
731
  });
717
732
  const role = admin.command("role").description("Role management");
718
733
  role.command("list").description("List roles").option("--keyword <s>", "filter by keyword").option("--limit <n>", "page size", int, 100).option("--offset <n>", "page offset", int, 0).option("--source <s>", "role source filter (business | user)").action(async (opts, cmd) => {