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

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
@@ -11,6 +11,7 @@ import {
11
11
  createClient,
12
12
  credentialDeviceLogin,
13
13
  currentToken,
14
+ currentTokenFresh,
14
15
  decodeJwt,
15
16
  deletePlatform,
16
17
  deviceLogin,
@@ -36,7 +37,7 @@ import {
36
37
  use,
37
38
  whoami,
38
39
  writePlatformConfig
39
- } from "./chunk-GAYXY7LP.js";
40
+ } from "./chunk-DTU5DGJW.js";
40
41
 
41
42
  // src/cli.ts
42
43
  import { Command as Command16 } from "commander";
@@ -44,7 +45,7 @@ import { Command as Command16 } from "commander";
44
45
  // package.json
45
46
  var package_default = {
46
47
  name: "@openbkn/bkn-sdk",
47
- version: "0.1.1-alpha.6",
48
+ version: "0.1.1-alpha.8",
48
49
  description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
49
50
  type: "module",
50
51
  license: "Apache-2.0",
@@ -498,8 +499,11 @@ User code: ${userCode}
498
499
  );
499
500
  });
500
501
  cmd.command("status").description("Show base URL and whether a token is configured").action((_opts, cmd2) => printJson(status(), outputOptions(cmd2)));
501
- cmd.command("token").description("Print the current access token (keep secret)").action(() => {
502
- process.stdout.write(`${currentToken()}
502
+ cmd.command("token").description("Print the current access token, refreshing it if expired (keep secret)").option("--no-refresh", "print the stored token as-is, without refreshing").action(async (opts, cmd2) => {
503
+ const g = cmd2.optsWithGlobals();
504
+ if (g.insecure) process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
505
+ const token = opts.refresh === false ? currentToken() : await currentTokenFresh();
506
+ process.stdout.write(`${token}
503
507
  `);
504
508
  });
505
509
  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) => {
@@ -522,7 +526,26 @@ User code: ${userCode}
522
526
  } catch {
523
527
  }
524
528
  }
525
- printJson(me, outputOptions(cmd2));
529
+ const out = outputOptions(cmd2);
530
+ if (out.json || out.compact || out.full) {
531
+ printJson(me, out);
532
+ return;
533
+ }
534
+ const expMs = typeof me.exp === "number" ? me.exp * 1e3 : void 0;
535
+ const expired = expMs !== void 0 && expMs < Date.now();
536
+ const rows = [
537
+ ["User", String(me.username ?? me.sub ?? "(unknown)")],
538
+ ...me.name && me.name !== me.username ? [["Name", String(me.name)]] : [],
539
+ ["ID", String(me.userId ?? me.sub ?? "-")],
540
+ ["Platform", String(me.baseUrl ?? "-")],
541
+ ...expMs !== void 0 ? [["Expires", `${new Date(expMs).toISOString()}${expired ? " (expired)" : ""}`]] : []
542
+ ];
543
+ const pad2 = Math.max(...rows.map(([k]) => k.length));
544
+ process.stdout.write(
545
+ `${rows.map(([k, v]) => `${k.padEnd(pad2)} ${v}`).join("\n")}
546
+ \u2026 use --full or --json for all claims
547
+ `
548
+ );
526
549
  });
527
550
  cmd.command("list").alias("ls").description("List saved sessions (platform \u2192 users; * = active)").action((_opts, cmd2) => {
528
551
  const items = listPlatforms();