@openbkn/bkn-sdk 0.1.1-alpha.5 → 0.1.1-alpha.6

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
@@ -36,7 +36,7 @@ import {
36
36
  use,
37
37
  whoami,
38
38
  writePlatformConfig
39
- } from "./chunk-67GKXAWG.js";
39
+ } from "./chunk-GAYXY7LP.js";
40
40
 
41
41
  // src/cli.ts
42
42
  import { Command as Command16 } from "commander";
@@ -44,7 +44,7 @@ import { Command as Command16 } from "commander";
44
44
  // package.json
45
45
  var package_default = {
46
46
  name: "@openbkn/bkn-sdk",
47
- version: "0.1.1-alpha.5",
47
+ version: "0.1.1-alpha.6",
48
48
  description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
49
49
  type: "module",
50
50
  license: "Apache-2.0",
@@ -502,9 +502,28 @@ User code: ${userCode}
502
502
  process.stdout.write(`${currentToken()}
503
503
  `);
504
504
  });
505
- cmd.command("whoami [url]").description("Show current user identity (from the token)").option("--no-lookup", "skip the backend identity fallback (eacp/user/get)").action(
506
- (_url, _opts, cmd2) => printJson(whoami(), outputOptions(cmd2))
507
- );
505
+ cmd.command("whoami [url]").description("Show current user identity (from the token)").option("--no-lookup", "skip the backend identity fallback (eacp/user/get)").action(async (_url, opts, cmd2) => {
506
+ const g = cmd2.optsWithGlobals();
507
+ if (g.insecure) process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
508
+ const me = whoami();
509
+ if (opts.lookup !== false && me.baseUrl && me.sub) {
510
+ try {
511
+ const u = await getUserSafe(
512
+ {
513
+ baseUrl: me.baseUrl,
514
+ token: currentToken(),
515
+ businessDomain: DEFAULT_BUSINESS_DOMAIN,
516
+ insecure: Boolean(g.insecure)
517
+ },
518
+ me.sub
519
+ );
520
+ if (u.account) me.username = u.account;
521
+ if (u.name) me.name = u.name;
522
+ } catch {
523
+ }
524
+ }
525
+ printJson(me, outputOptions(cmd2));
526
+ });
508
527
  cmd.command("list").alias("ls").description("List saved sessions (platform \u2192 users; * = active)").action((_opts, cmd2) => {
509
528
  const items = listPlatforms();
510
529
  const out = outputOptions(cmd2);