@clavis.nexus/setup 1.0.1 → 1.0.2
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/README.md +6 -0
- package/dist/cli.js +228 -149
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +201 -142
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +215 -145
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/mcp.js
CHANGED
|
@@ -7,10 +7,11 @@ import { pathToFileURL } from 'url';
|
|
|
7
7
|
import { execFile } from 'child_process';
|
|
8
8
|
import { promisify } from 'util';
|
|
9
9
|
import { readFile, mkdir, writeFile, chmod, unlink } from 'fs/promises';
|
|
10
|
-
import { dirname, join } from 'path';
|
|
10
|
+
import path, { dirname, join } from 'path';
|
|
11
11
|
import { homedir } from 'os';
|
|
12
12
|
import { generateKeyPair, exportJWK, createRemoteJWKSet, jwtVerify } from 'jose';
|
|
13
|
-
import {
|
|
13
|
+
import { createInterface } from 'readline/promises';
|
|
14
|
+
import { stdin, stdout } from 'process';
|
|
14
15
|
import { randomBytes } from 'crypto';
|
|
15
16
|
|
|
16
17
|
var execFileAsync = promisify(execFile);
|
|
@@ -101,12 +102,12 @@ function stableStringify(v) {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
// src/digests.ts
|
|
104
|
-
async function computeOrgPolicyBootstrapDigest(
|
|
105
|
+
async function computeOrgPolicyBootstrapDigest(input2) {
|
|
105
106
|
return sha256Base64Url(
|
|
106
107
|
canonicalStringify({
|
|
107
|
-
org_id:
|
|
108
|
-
primary_domain:
|
|
109
|
-
owner_sub:
|
|
108
|
+
org_id: input2.org_id.trim(),
|
|
109
|
+
primary_domain: input2.primary_domain.trim().toLowerCase(),
|
|
110
|
+
owner_sub: input2.owner_sub.trim()
|
|
110
111
|
})
|
|
111
112
|
);
|
|
112
113
|
}
|
|
@@ -117,21 +118,21 @@ async function computePayloadCommitmentHex(payload) {
|
|
|
117
118
|
}
|
|
118
119
|
return sha256HexUtf8(canonicalStringify(o));
|
|
119
120
|
}
|
|
120
|
-
async function computeOrgAppRegisterDigest(
|
|
121
|
+
async function computeOrgAppRegisterDigest(input2) {
|
|
121
122
|
return sha256Base64Url(
|
|
122
123
|
canonicalStringify({
|
|
123
|
-
payload_hash:
|
|
124
|
-
proposer_sub:
|
|
124
|
+
payload_hash: input2.payload_hash.trim().toLowerCase(),
|
|
125
|
+
proposer_sub: input2.proposer_sub.trim()
|
|
125
126
|
})
|
|
126
127
|
);
|
|
127
128
|
}
|
|
128
|
-
async function computeOrgAppVerifyHostDigest(
|
|
129
|
+
async function computeOrgAppVerifyHostDigest(input2) {
|
|
129
130
|
return sha256Base64Url(
|
|
130
131
|
canonicalStringify({
|
|
131
|
-
app_id:
|
|
132
|
-
host:
|
|
133
|
-
nonce:
|
|
134
|
-
org_id:
|
|
132
|
+
app_id: input2.app_id.trim(),
|
|
133
|
+
host: input2.host.trim().toLowerCase(),
|
|
134
|
+
nonce: input2.nonce.trim(),
|
|
135
|
+
org_id: input2.org_id.trim()
|
|
135
136
|
})
|
|
136
137
|
);
|
|
137
138
|
}
|
|
@@ -144,13 +145,13 @@ async function computeOrgAppDeclarationHash(declaration) {
|
|
|
144
145
|
})
|
|
145
146
|
);
|
|
146
147
|
}
|
|
147
|
-
async function computeOrgAppDeclarationDigest(
|
|
148
|
+
async function computeOrgAppDeclarationDigest(input2) {
|
|
148
149
|
return sha256Base64Url(
|
|
149
150
|
canonicalStringify({
|
|
150
|
-
org_id:
|
|
151
|
-
app_id:
|
|
152
|
-
declaration_hash:
|
|
153
|
-
actor_sub:
|
|
151
|
+
org_id: input2.org_id.trim(),
|
|
152
|
+
app_id: input2.app_id.trim(),
|
|
153
|
+
declaration_hash: input2.declaration_hash.trim(),
|
|
154
|
+
actor_sub: input2.actor_sub.trim()
|
|
154
155
|
})
|
|
155
156
|
);
|
|
156
157
|
}
|
|
@@ -247,8 +248,8 @@ var SetupApiError = class extends Error {
|
|
|
247
248
|
this.code = code;
|
|
248
249
|
}
|
|
249
250
|
};
|
|
250
|
-
async function apiJson(apiOrigin,
|
|
251
|
-
const res = await fetch(`${apiOrigin.replace(/\/+$/, "")}${
|
|
251
|
+
async function apiJson(apiOrigin, path2, opts) {
|
|
252
|
+
const res = await fetch(`${apiOrigin.replace(/\/+$/, "")}${path2}`, {
|
|
252
253
|
method: opts.method ?? "GET",
|
|
253
254
|
headers: {
|
|
254
255
|
Accept: "application/json",
|
|
@@ -387,25 +388,25 @@ function appEnvFilePath(appId) {
|
|
|
387
388
|
const base = process.env.CLAVIS_OPERATE_KEYS_DIR?.trim() || join(homedir(), ".config", "clavis", "apps");
|
|
388
389
|
return join(base, app, "app.env");
|
|
389
390
|
}
|
|
390
|
-
async function restrictFileMode(
|
|
391
|
+
async function restrictFileMode(path2) {
|
|
391
392
|
try {
|
|
392
|
-
await chmod(
|
|
393
|
+
await chmod(path2, 384);
|
|
393
394
|
} catch (e) {
|
|
394
395
|
console.warn(
|
|
395
|
-
`clavis: could not set mode 0600 on ${
|
|
396
|
+
`clavis: could not set mode 0600 on ${path2}: ${e instanceof Error ? e.message : e}`
|
|
396
397
|
);
|
|
397
398
|
}
|
|
398
399
|
}
|
|
399
400
|
async function saveOperatePrivateJwk(appId, jwkJson) {
|
|
400
|
-
const
|
|
401
|
-
await mkdir(dirname(
|
|
402
|
-
await writeFile(
|
|
403
|
-
await restrictFileMode(
|
|
401
|
+
const path2 = operatePrivateJwkPath(appId);
|
|
402
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
403
|
+
await writeFile(path2, jwkJson.trim(), "utf8");
|
|
404
|
+
await restrictFileMode(path2);
|
|
404
405
|
try {
|
|
405
|
-
await chmod(dirname(
|
|
406
|
+
await chmod(dirname(path2), 448);
|
|
406
407
|
} catch {
|
|
407
408
|
}
|
|
408
|
-
return
|
|
409
|
+
return path2;
|
|
409
410
|
}
|
|
410
411
|
async function readOperatePrivateJwk(appId) {
|
|
411
412
|
try {
|
|
@@ -416,12 +417,12 @@ async function readOperatePrivateJwk(appId) {
|
|
|
416
417
|
}
|
|
417
418
|
}
|
|
418
419
|
async function writeAppEnvFile(appId, contents) {
|
|
419
|
-
const
|
|
420
|
-
await mkdir(dirname(
|
|
421
|
-
await writeFile(
|
|
420
|
+
const path2 = appEnvFilePath(appId);
|
|
421
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
422
|
+
await writeFile(path2, contents.endsWith("\n") ? contents : `${contents}
|
|
422
423
|
`, "utf8");
|
|
423
|
-
await restrictFileMode(
|
|
424
|
-
return
|
|
424
|
+
await restrictFileMode(path2);
|
|
425
|
+
return path2;
|
|
425
426
|
}
|
|
426
427
|
|
|
427
428
|
// src/emit-env.ts
|
|
@@ -500,9 +501,9 @@ function originsFromEnv(overrides) {
|
|
|
500
501
|
developersOrigin: overrides?.developersOrigin ?? process.env.CLAVIS_DEVELOPERS_ORIGIN?.trim() ?? DEFAULT_ORIGINS.developersOrigin
|
|
501
502
|
};
|
|
502
503
|
}
|
|
503
|
-
async function loadSession(
|
|
504
|
+
async function loadSession(path2 = defaultSessionPath()) {
|
|
504
505
|
try {
|
|
505
|
-
const raw = await readFile(
|
|
506
|
+
const raw = await readFile(path2, "utf8");
|
|
506
507
|
const parsed = JSON.parse(raw);
|
|
507
508
|
if (parsed?.v !== 1 || typeof parsed.session?.accessToken !== "string") return null;
|
|
508
509
|
if (parsed.session.expiresAt && parsed.session.expiresAt * 1e3 < Date.now()) return null;
|
|
@@ -511,50 +512,30 @@ async function loadSession(path = defaultSessionPath()) {
|
|
|
511
512
|
return null;
|
|
512
513
|
}
|
|
513
514
|
}
|
|
514
|
-
async function saveSession(session, origins,
|
|
515
|
-
await mkdir(dirname(
|
|
515
|
+
async function saveSession(session, origins, path2 = defaultSessionPath()) {
|
|
516
|
+
await mkdir(dirname(path2), { recursive: true });
|
|
516
517
|
const body = { v: 1, origins, session, savedAt: Date.now() };
|
|
517
|
-
await writeFile(
|
|
518
|
+
await writeFile(path2, JSON.stringify(body, null, 2), "utf8");
|
|
518
519
|
try {
|
|
519
|
-
await chmod(
|
|
520
|
+
await chmod(path2, 384);
|
|
520
521
|
} catch (e) {
|
|
521
522
|
console.warn(
|
|
522
|
-
`clavis: could not set session file mode 0600 (${
|
|
523
|
+
`clavis: could not set session file mode 0600 (${path2}): ${e instanceof Error ? e.message : e}`
|
|
523
524
|
);
|
|
524
525
|
}
|
|
525
526
|
}
|
|
526
|
-
async function clearSession(
|
|
527
|
+
async function clearSession(path2 = defaultSessionPath()) {
|
|
527
528
|
try {
|
|
528
|
-
await unlink(
|
|
529
|
+
await unlink(path2);
|
|
529
530
|
} catch {
|
|
530
531
|
}
|
|
531
532
|
}
|
|
532
533
|
|
|
533
534
|
// src/login.ts
|
|
534
|
-
var
|
|
535
|
-
function
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
let total = 0;
|
|
539
|
-
req.on("data", (c) => {
|
|
540
|
-
const buf = Buffer.isBuffer(c) ? c : Buffer.from(c);
|
|
541
|
-
total += buf.length;
|
|
542
|
-
if (total > MAX_CALLBACK_BODY_BYTES) {
|
|
543
|
-
reject(new Error("callback body too large"));
|
|
544
|
-
req.destroy();
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
chunks.push(buf);
|
|
548
|
-
});
|
|
549
|
-
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
550
|
-
req.on("error", reject);
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
function cors(res, developersOrigin) {
|
|
554
|
-
res.setHeader("Access-Control-Allow-Origin", developersOrigin);
|
|
555
|
-
res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS");
|
|
556
|
-
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
557
|
-
res.setHeader("Vary", "Origin");
|
|
535
|
+
var MAX_BRIDGE_JSON_CHARS = 16384;
|
|
536
|
+
function pendingLoginPath(sessionPath) {
|
|
537
|
+
const base = sessionPath ? path.dirname(sessionPath) : path.dirname(defaultSessionPath());
|
|
538
|
+
return path.join(base, "login-pending.json");
|
|
558
539
|
}
|
|
559
540
|
function subFromJwt(accessToken) {
|
|
560
541
|
try {
|
|
@@ -567,85 +548,148 @@ function subFromJwt(accessToken) {
|
|
|
567
548
|
return void 0;
|
|
568
549
|
}
|
|
569
550
|
}
|
|
551
|
+
function loginBridgeUrl(developersOrigin, state) {
|
|
552
|
+
const bridge = new URL("/developers/setup/login", developersOrigin);
|
|
553
|
+
bridge.searchParams.set("state", state);
|
|
554
|
+
return bridge.toString();
|
|
555
|
+
}
|
|
556
|
+
async function writePending(pendingPath, pending) {
|
|
557
|
+
await mkdir(path.dirname(pendingPath), { recursive: true, mode: 448 });
|
|
558
|
+
await writeFile(pendingPath, `${JSON.stringify(pending, null, 2)}
|
|
559
|
+
`, { mode: 384 });
|
|
560
|
+
}
|
|
561
|
+
async function readPending(pendingPath) {
|
|
562
|
+
try {
|
|
563
|
+
const raw = await readFile(pendingPath, "utf8");
|
|
564
|
+
const parsed = JSON.parse(raw);
|
|
565
|
+
if (parsed?.v !== 1 || typeof parsed.state !== "string" || !parsed.state) return null;
|
|
566
|
+
return parsed;
|
|
567
|
+
} catch {
|
|
568
|
+
return null;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
async function clearPending(pendingPath) {
|
|
572
|
+
try {
|
|
573
|
+
await unlink(pendingPath);
|
|
574
|
+
} catch {
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
function parseBridgePayload(raw) {
|
|
578
|
+
const trimmed = raw.trim();
|
|
579
|
+
if (!trimmed) throw new Error("empty_bridge_json");
|
|
580
|
+
if (trimmed.length > MAX_BRIDGE_JSON_CHARS) throw new Error("bridge_json_too_large");
|
|
581
|
+
const body = JSON.parse(trimmed);
|
|
582
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) {
|
|
583
|
+
throw new Error("bridge_json_not_object");
|
|
584
|
+
}
|
|
585
|
+
return body;
|
|
586
|
+
}
|
|
587
|
+
async function sessionFromBridge(args) {
|
|
588
|
+
const body = parseBridgePayload(args.raw);
|
|
589
|
+
if (body.state !== args.expectedState || typeof body.accessToken !== "string" || !body.accessToken) {
|
|
590
|
+
throw new Error("invalid_bridge_json");
|
|
591
|
+
}
|
|
592
|
+
await verifyDevelopersAccessToken(body.accessToken, args.apiOrigin);
|
|
593
|
+
const sub = typeof body.sub === "string" ? body.sub : subFromJwt(body.accessToken);
|
|
594
|
+
return {
|
|
595
|
+
accessToken: body.accessToken,
|
|
596
|
+
...sub ? { sub } : {},
|
|
597
|
+
...typeof body.expiresAt === "number" ? { expiresAt: body.expiresAt } : {}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
async function readBridgeJsonFromStdin() {
|
|
601
|
+
if (!stdin.isTTY) {
|
|
602
|
+
const chunks = [];
|
|
603
|
+
for await (const chunk of stdin) {
|
|
604
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
605
|
+
}
|
|
606
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
607
|
+
}
|
|
608
|
+
const rl = createInterface({ input: stdin, output: stdout });
|
|
609
|
+
try {
|
|
610
|
+
stdout.write(
|
|
611
|
+
"Paste the JSON shown on developers /setup/login, then press Enter.\n(End with a blank line if the paste spans multiple lines.)\n"
|
|
612
|
+
);
|
|
613
|
+
const lines = [];
|
|
614
|
+
for (; ; ) {
|
|
615
|
+
const line = await rl.question("");
|
|
616
|
+
if (line.trim() === "" && lines.length > 0) break;
|
|
617
|
+
lines.push(line);
|
|
618
|
+
const joined = lines.join("\n").trim();
|
|
619
|
+
if (joined.startsWith("{") && joined.endsWith("}")) break;
|
|
620
|
+
}
|
|
621
|
+
return lines.join("\n");
|
|
622
|
+
} finally {
|
|
623
|
+
rl.close();
|
|
624
|
+
}
|
|
625
|
+
}
|
|
570
626
|
async function loginWithBrowser(args) {
|
|
571
|
-
const
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
try {
|
|
587
|
-
const raw = await readBody(req);
|
|
588
|
-
const body = JSON.parse(raw);
|
|
589
|
-
if (body.state !== state || typeof body.accessToken !== "string" || !body.accessToken) {
|
|
590
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
591
|
-
res.end(JSON.stringify({ ok: false, error: "invalid_callback" }));
|
|
592
|
-
return;
|
|
593
|
-
}
|
|
594
|
-
try {
|
|
595
|
-
await verifyDevelopersAccessToken(body.accessToken, args.origins.apiOrigin);
|
|
596
|
-
} catch {
|
|
597
|
-
res.writeHead(400, { "Content-Type": "application/json" });
|
|
598
|
-
res.end(JSON.stringify({ ok: false, error: "invalid_token" }));
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
const sub = typeof body.sub === "string" ? body.sub : subFromJwt(body.accessToken);
|
|
602
|
-
const next = {
|
|
603
|
-
accessToken: body.accessToken,
|
|
604
|
-
...sub ? { sub } : {},
|
|
605
|
-
...typeof body.expiresAt === "number" ? { expiresAt: body.expiresAt } : {}
|
|
606
|
-
};
|
|
607
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
608
|
-
res.end(JSON.stringify({ ok: true }));
|
|
609
|
-
server.close();
|
|
610
|
-
resolve(next);
|
|
611
|
-
} catch (e) {
|
|
612
|
-
res.writeHead(500, { "Content-Type": "application/json" });
|
|
613
|
-
res.end(JSON.stringify({ ok: false }));
|
|
614
|
-
server.close();
|
|
615
|
-
reject(e);
|
|
616
|
-
}
|
|
627
|
+
const pendingPath = pendingLoginPath(args.sessionPath);
|
|
628
|
+
const openFlag = args.open !== false;
|
|
629
|
+
if (args.bridgeJson?.trim()) {
|
|
630
|
+
const pending = await readPending(pendingPath);
|
|
631
|
+
if (!pending) {
|
|
632
|
+
throw new Error("no_pending_login \u2014 run login again to open the browser first");
|
|
633
|
+
}
|
|
634
|
+
if (pending.apiOrigin !== args.origins.apiOrigin || pending.developersOrigin !== args.origins.developersOrigin) {
|
|
635
|
+
await clearPending(pendingPath);
|
|
636
|
+
throw new Error("pending_login_origin_mismatch \u2014 run login again");
|
|
637
|
+
}
|
|
638
|
+
const session2 = await sessionFromBridge({
|
|
639
|
+
raw: args.bridgeJson,
|
|
640
|
+
expectedState: pending.state,
|
|
641
|
+
apiOrigin: args.origins.apiOrigin
|
|
617
642
|
});
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
643
|
+
await saveSession(session2, args.origins, args.sessionPath);
|
|
644
|
+
await clearPending(pendingPath);
|
|
645
|
+
return {
|
|
646
|
+
session: session2,
|
|
647
|
+
human: {
|
|
648
|
+
needs_human: "login",
|
|
649
|
+
message: "Session stored.",
|
|
650
|
+
open_url: loginBridgeUrl(args.origins.developersOrigin, pending.state)
|
|
623
651
|
}
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
})();
|
|
635
|
-
});
|
|
636
|
-
const timer = setTimeout(() => {
|
|
637
|
-
server.close();
|
|
638
|
-
reject(new Error("login timeout \u2014 complete Passkey in the browser"));
|
|
639
|
-
}, timeoutMs);
|
|
640
|
-
server.on("close", () => clearTimeout(timer));
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
const state = randomBytes(16).toString("hex");
|
|
655
|
+
const openUrl = loginBridgeUrl(args.origins.developersOrigin, state);
|
|
656
|
+
await writePending(pendingPath, {
|
|
657
|
+
v: 1,
|
|
658
|
+
state,
|
|
659
|
+
createdAt: Date.now(),
|
|
660
|
+
developersOrigin: args.origins.developersOrigin,
|
|
661
|
+
apiOrigin: args.origins.apiOrigin
|
|
641
662
|
});
|
|
642
|
-
|
|
663
|
+
if (openFlag) {
|
|
664
|
+
try {
|
|
665
|
+
await openBrowser(assertOriginBrowserUrl(openUrl, args.origins.developersOrigin));
|
|
666
|
+
} catch {
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (args.deferPaste) {
|
|
670
|
+
return {
|
|
671
|
+
pending: true,
|
|
672
|
+
human: {
|
|
673
|
+
needs_human: "login",
|
|
674
|
+
message: "Complete Passkey in the browser, copy the JSON on the page, then call login again with bridge_json.",
|
|
675
|
+
open_url: openUrl
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
const raw = await readBridgeJsonFromStdin();
|
|
680
|
+
const session = await sessionFromBridge({
|
|
681
|
+
raw,
|
|
682
|
+
expectedState: state,
|
|
683
|
+
apiOrigin: args.origins.apiOrigin
|
|
684
|
+
});
|
|
685
|
+
await saveSession(session, args.origins, args.sessionPath);
|
|
686
|
+
await clearPending(pendingPath);
|
|
643
687
|
return {
|
|
644
688
|
session,
|
|
645
689
|
human: {
|
|
646
690
|
needs_human: "login",
|
|
647
|
-
message: "
|
|
648
|
-
open_url:
|
|
691
|
+
message: "Session stored. You can close the browser tab.",
|
|
692
|
+
open_url: openUrl
|
|
649
693
|
}
|
|
650
694
|
};
|
|
651
695
|
}
|
|
@@ -787,9 +831,24 @@ function createSetupClient(options = {}) {
|
|
|
787
831
|
const s = await loadSession(sessionPath);
|
|
788
832
|
return s?.session ?? null;
|
|
789
833
|
},
|
|
790
|
-
async login() {
|
|
791
|
-
const
|
|
792
|
-
|
|
834
|
+
async login(opts) {
|
|
835
|
+
const bridgeJson = opts?.bridgeJson?.trim();
|
|
836
|
+
const deferPaste = !bridgeJson && !process.stdin.isTTY;
|
|
837
|
+
const out = await loginWithBrowser({
|
|
838
|
+
origins,
|
|
839
|
+
open: openBrowserFlag,
|
|
840
|
+
...bridgeJson ? { bridgeJson } : {},
|
|
841
|
+
...deferPaste ? { deferPaste: true } : {},
|
|
842
|
+
sessionPath
|
|
843
|
+
});
|
|
844
|
+
if (out.pending || !out.session) {
|
|
845
|
+
return {
|
|
846
|
+
ok: false,
|
|
847
|
+
error: "login_pending_paste",
|
|
848
|
+
human: out.human
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
return { ok: true, data: { sub: out.session.sub } };
|
|
793
852
|
},
|
|
794
853
|
async logout() {
|
|
795
854
|
await clearSession(sessionPath);
|
|
@@ -1148,8 +1207,17 @@ var TOOLS = [
|
|
|
1148
1207
|
},
|
|
1149
1208
|
{
|
|
1150
1209
|
name: "clavis_login",
|
|
1151
|
-
description: "
|
|
1152
|
-
inputSchema: {
|
|
1210
|
+
description: "Start or finish developers Passkey login. First call opens the browser; after the human pastes the page JSON, call again with bridge_json.",
|
|
1211
|
+
inputSchema: {
|
|
1212
|
+
type: "object",
|
|
1213
|
+
properties: {
|
|
1214
|
+
bridge_json: {
|
|
1215
|
+
type: "string",
|
|
1216
|
+
description: "JSON shown on developers /setup/login after Passkey (state + accessToken)."
|
|
1217
|
+
}
|
|
1218
|
+
},
|
|
1219
|
+
additionalProperties: false
|
|
1220
|
+
}
|
|
1153
1221
|
},
|
|
1154
1222
|
{
|
|
1155
1223
|
name: "clavis_org_anchor_plan",
|
|
@@ -1297,7 +1365,9 @@ async function dispatch(client, name, args) {
|
|
|
1297
1365
|
case "clavis_setup_status":
|
|
1298
1366
|
return client.status();
|
|
1299
1367
|
case "clavis_login":
|
|
1300
|
-
return client.login(
|
|
1368
|
+
return client.login(
|
|
1369
|
+
args.bridge_json ? { bridgeJson: String(args.bridge_json) } : void 0
|
|
1370
|
+
);
|
|
1301
1371
|
case "clavis_org_anchor_plan":
|
|
1302
1372
|
return client.orgAnchorPlan(String(args.domain), args.name ? String(args.name) : void 0);
|
|
1303
1373
|
case "clavis_org_anchor_finish":
|