@openbkn/bkn-sdk 0.1.1-alpha.5 → 0.1.1-alpha.7
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-
|
|
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.
|
|
47
|
+
version: "0.1.1-alpha.7",
|
|
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,47 @@ 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
|
-
|
|
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
|
+
const out = outputOptions(cmd2);
|
|
526
|
+
if (out.json || out.compact || out.full) {
|
|
527
|
+
printJson(me, out);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const expMs = typeof me.exp === "number" ? me.exp * 1e3 : void 0;
|
|
531
|
+
const expired = expMs !== void 0 && expMs < Date.now();
|
|
532
|
+
const rows = [
|
|
533
|
+
["User", String(me.username ?? me.sub ?? "(unknown)")],
|
|
534
|
+
...me.name && me.name !== me.username ? [["Name", String(me.name)]] : [],
|
|
535
|
+
["ID", String(me.userId ?? me.sub ?? "-")],
|
|
536
|
+
["Platform", String(me.baseUrl ?? "-")],
|
|
537
|
+
...expMs !== void 0 ? [["Expires", `${new Date(expMs).toISOString()}${expired ? " (expired)" : ""}`]] : []
|
|
538
|
+
];
|
|
539
|
+
const pad2 = Math.max(...rows.map(([k]) => k.length));
|
|
540
|
+
process.stdout.write(
|
|
541
|
+
`${rows.map(([k, v]) => `${k.padEnd(pad2)} ${v}`).join("\n")}
|
|
542
|
+
\u2026 use --full or --json for all claims
|
|
543
|
+
`
|
|
544
|
+
);
|
|
545
|
+
});
|
|
508
546
|
cmd.command("list").alias("ls").description("List saved sessions (platform \u2192 users; * = active)").action((_opts, cmd2) => {
|
|
509
547
|
const items = listPlatforms();
|
|
510
548
|
const out = outputOptions(cmd2);
|