@openbkn/bkn-sdk 0.1.1-alpha.4 → 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/{chunk-APJNRHLS.js → chunk-GAYXY7LP.js} +17 -4
- package/dist/chunk-GAYXY7LP.js.map +1 -0
- package/dist/cli.js +29 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-APJNRHLS.js.map +0 -1
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-
|
|
39
|
+
} from "./chunk-GAYXY7LP.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.
|
|
47
|
+
version: "0.1.1-alpha.6",
|
|
47
48
|
description: "Unified TypeScript SDK + CLI for the BKN (Business Knowledge Network) platform.",
|
|
48
49
|
type: "module",
|
|
49
50
|
license: "Apache-2.0",
|
|
@@ -449,7 +450,8 @@ function registerAuthLeaves(cmd) {
|
|
|
449
450
|
timeoutMs: opts.timeout * 1e3
|
|
450
451
|
});
|
|
451
452
|
} else {
|
|
452
|
-
const
|
|
453
|
+
const headless = isHeadless();
|
|
454
|
+
const openInBrowser = !opts.device && opts.browser !== false && !headless;
|
|
453
455
|
tokens = await deviceLogin(url, {
|
|
454
456
|
clientId: opts.clientId,
|
|
455
457
|
audience: opts.audience,
|
|
@@ -464,6 +466,8 @@ User code: ${userCode}
|
|
|
464
466
|
`
|
|
465
467
|
);
|
|
466
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");
|
|
467
471
|
process.stderr.write("Waiting for authorization\u2026\n");
|
|
468
472
|
}
|
|
469
473
|
});
|
|
@@ -498,9 +502,28 @@ User code: ${userCode}
|
|
|
498
502
|
process.stdout.write(`${currentToken()}
|
|
499
503
|
`);
|
|
500
504
|
});
|
|
501
|
-
cmd.command("whoami [url]").description("Show current user identity (from the token)").option("--no-lookup", "skip the backend identity fallback (eacp/user/get)").action(
|
|
502
|
-
|
|
503
|
-
|
|
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
|
+
});
|
|
504
527
|
cmd.command("list").alias("ls").description("List saved sessions (platform \u2192 users; * = active)").action((_opts, cmd2) => {
|
|
505
528
|
const items = listPlatforms();
|
|
506
529
|
const out = outputOptions(cmd2);
|