@tinycloud/mcp 0.8.0-beta.5 → 0.8.0-beta.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/README.md +4 -1
- package/dist/cli.cjs +3 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/http-cli.cjs +32 -21
- package/dist/http-cli.cjs.map +1 -1
- package/dist/http-cli.js +32 -21
- package/dist/http-cli.js.map +1 -1
- package/dist/http.cjs +32 -21
- package/dist/http.cjs.map +1 -1
- package/dist/http.js +32 -21
- package/dist/http.js.map +1 -1
- package/dist/index.cjs +32 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -21
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +3 -3
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/http.js
CHANGED
|
@@ -191,9 +191,9 @@ var RemoteTenantStore = class {
|
|
|
191
191
|
}
|
|
192
192
|
async connectStatus(subject, ownerDids = []) {
|
|
193
193
|
const tenant = await this.#ensureTenant(subject);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
194
|
+
const state = await this.#sessionState(tenant, ownerDids, true);
|
|
195
|
+
if (state === "valid") return { connected: true, sessionDid: tenant.sessionDid };
|
|
196
|
+
if (state === "unknown") return { connected: false, sessionDid: tenant.sessionDid };
|
|
197
197
|
const pending = await this.#createPending(subject, ownerDids, "bootstrap", BOOTSTRAP_PERMISSIONS);
|
|
198
198
|
return {
|
|
199
199
|
connected: false,
|
|
@@ -533,7 +533,10 @@ var RemoteTenantStore = class {
|
|
|
533
533
|
return initializing;
|
|
534
534
|
}
|
|
535
535
|
async #hasValidSession(tenant, ownerDids, fresh = false) {
|
|
536
|
-
|
|
536
|
+
return await this.#sessionState(tenant, ownerDids, fresh) !== "invalid";
|
|
537
|
+
}
|
|
538
|
+
async #sessionState(tenant, ownerDids, fresh = false) {
|
|
539
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
537
540
|
const key = JSON.stringify([tenant.stateRoot, ownerDids.map(normalizeDid), fresh]);
|
|
538
541
|
const current = this.#sessionChecks.get(key);
|
|
539
542
|
if (current) return current;
|
|
@@ -550,9 +553,9 @@ var RemoteTenantStore = class {
|
|
|
550
553
|
} catch (error) {
|
|
551
554
|
if (!(error instanceof SyntaxError)) throw error;
|
|
552
555
|
await this.#clearAuthority(tenant);
|
|
553
|
-
return
|
|
556
|
+
return "invalid";
|
|
554
557
|
}
|
|
555
|
-
if (raw === null) return
|
|
558
|
+
if (raw === null) return "invalid";
|
|
556
559
|
const node = new TinyCloudNode({ host: this.#config.nodeHost });
|
|
557
560
|
try {
|
|
558
561
|
await node.restoreSession(raw);
|
|
@@ -561,11 +564,11 @@ var RemoteTenantStore = class {
|
|
|
561
564
|
const signedExpiry = typeof header === "string" ? signedCompactUcanExpiry(header) : void 0;
|
|
562
565
|
const siweExpiry = typeof raw.siwe === "string" ? /^Expiration Time: ([^\r\n]+)\r?$/m.exec(raw.siwe)?.[1] : void 0;
|
|
563
566
|
const expiry = signedExpiry ?? (siweExpiry === void 0 ? void 0 : new Date(siweExpiry));
|
|
564
|
-
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return
|
|
567
|
+
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return "invalid";
|
|
565
568
|
await this.#clearAuthority(tenant);
|
|
566
|
-
return
|
|
569
|
+
return "invalid";
|
|
567
570
|
}
|
|
568
|
-
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return
|
|
571
|
+
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return "invalid";
|
|
569
572
|
const additional = await readJson(this.#additionalPath(tenant.stateRoot));
|
|
570
573
|
const cids = [raw.delegationCid];
|
|
571
574
|
if (additional !== null) {
|
|
@@ -580,7 +583,7 @@ var RemoteTenantStore = class {
|
|
|
580
583
|
}
|
|
581
584
|
const fingerprint = cids.join("\n");
|
|
582
585
|
const cached = this.#activeSessions.get(tenant.stateRoot);
|
|
583
|
-
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return
|
|
586
|
+
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return "valid";
|
|
584
587
|
let timer;
|
|
585
588
|
const timeout = new Promise((resolve) => {
|
|
586
589
|
timer = setTimeout(() => resolve(void 0), 2e3);
|
|
@@ -593,13 +596,14 @@ var RemoteTenantStore = class {
|
|
|
593
596
|
const refusal = probe !== void 0 && !probe.ok ? nodeRevocationOf(probe.error) : void 0;
|
|
594
597
|
if (refusal !== void 0 && (refusal.revokedCid === raw.delegationCid || refusal.reason === "delegation_ancestor_revoked" && refusal.ancestorCid === raw.delegationCid)) {
|
|
595
598
|
await this.#clearAuthority(tenant);
|
|
596
|
-
return
|
|
599
|
+
return "invalid";
|
|
597
600
|
}
|
|
598
|
-
if (this.#renewalRequired.has(tenant.stateRoot)) return
|
|
601
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
599
602
|
if (probe?.ok) {
|
|
600
603
|
this.#activeSessions.set(tenant.stateRoot, { cids: fingerprint, until: Date.now() + 3e4 });
|
|
604
|
+
return "valid";
|
|
601
605
|
}
|
|
602
|
-
return
|
|
606
|
+
return "unknown";
|
|
603
607
|
}
|
|
604
608
|
async #clearAuthority(tenant) {
|
|
605
609
|
const current = this.#clearing.get(tenant.stateRoot);
|
|
@@ -1373,7 +1377,7 @@ function outcomeCode(result) {
|
|
|
1373
1377
|
// package.json
|
|
1374
1378
|
var package_default = {
|
|
1375
1379
|
name: "@tinycloud/mcp",
|
|
1376
|
-
version: "0.8.0-beta.
|
|
1380
|
+
version: "0.8.0-beta.7",
|
|
1377
1381
|
description: "TinyCloud delegated operations MCP server",
|
|
1378
1382
|
keywords: [
|
|
1379
1383
|
"tinycloud",
|
|
@@ -1444,9 +1448,9 @@ var package_default = {
|
|
|
1444
1448
|
dependencies: {
|
|
1445
1449
|
"@modelcontextprotocol/node": "2.0.0-beta.5",
|
|
1446
1450
|
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
|
1447
|
-
"@tinycloud/node-sdk": "3.6.0-beta.
|
|
1451
|
+
"@tinycloud/node-sdk": "3.6.0-beta.6",
|
|
1448
1452
|
"@tinycloud/node-sdk-wasm": "1.7.8",
|
|
1449
|
-
"@tinycloud/operations": "0.7.4-beta.
|
|
1453
|
+
"@tinycloud/operations": "0.7.4-beta.6",
|
|
1450
1454
|
jose: "6.2.4"
|
|
1451
1455
|
},
|
|
1452
1456
|
devDependencies: {
|
|
@@ -1650,19 +1654,26 @@ function registerConnectTool(server, validator, store, identity, surface) {
|
|
|
1650
1654
|
async () => {
|
|
1651
1655
|
const startedAt = performance.now();
|
|
1652
1656
|
let code = "INTERNAL_ERROR";
|
|
1657
|
+
let text;
|
|
1653
1658
|
try {
|
|
1654
1659
|
const status = await store.connectStatus(identity.subject, identity.ownerDids);
|
|
1655
|
-
|
|
1660
|
+
if (status.connected) {
|
|
1661
|
+
code = "ok";
|
|
1662
|
+
text = "TinyCloud is connected.";
|
|
1663
|
+
} else if (status.approvalUrl === void 0) {
|
|
1664
|
+
code = "unavailable";
|
|
1665
|
+
text = "TinyCloud is unavailable. Call this tool again shortly.";
|
|
1666
|
+
} else {
|
|
1667
|
+
code = "authority_required";
|
|
1668
|
+
text = `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`;
|
|
1669
|
+
}
|
|
1656
1670
|
const visibleStatus = surface === "hosted" ? status : {
|
|
1657
1671
|
connected: status.connected,
|
|
1658
1672
|
...status.approvalUrl === void 0 ? {} : { approvalUrl: status.approvalUrl },
|
|
1659
1673
|
...status.expiresAt === void 0 ? {} : { expiresAt: status.expiresAt }
|
|
1660
1674
|
};
|
|
1661
1675
|
return {
|
|
1662
|
-
content: [{
|
|
1663
|
-
type: "text",
|
|
1664
|
-
text: status.connected ? "TinyCloud is connected." : `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`
|
|
1665
|
-
}],
|
|
1676
|
+
content: [{ type: "text", text }],
|
|
1666
1677
|
structuredContent: visibleStatus
|
|
1667
1678
|
};
|
|
1668
1679
|
} finally {
|