@tinycloud/mcp 0.8.0-beta.6 → 0.8.0-beta.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/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.cjs
CHANGED
|
@@ -195,9 +195,9 @@ var RemoteTenantStore = class {
|
|
|
195
195
|
}
|
|
196
196
|
async connectStatus(subject, ownerDids = []) {
|
|
197
197
|
const tenant = await this.#ensureTenant(subject);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
198
|
+
const state = await this.#sessionState(tenant, ownerDids, true);
|
|
199
|
+
if (state === "valid") return { connected: true, sessionDid: tenant.sessionDid };
|
|
200
|
+
if (state === "unknown") return { connected: false, sessionDid: tenant.sessionDid };
|
|
201
201
|
const pending = await this.#createPending(subject, ownerDids, "bootstrap", BOOTSTRAP_PERMISSIONS);
|
|
202
202
|
return {
|
|
203
203
|
connected: false,
|
|
@@ -537,7 +537,10 @@ var RemoteTenantStore = class {
|
|
|
537
537
|
return initializing;
|
|
538
538
|
}
|
|
539
539
|
async #hasValidSession(tenant, ownerDids, fresh = false) {
|
|
540
|
-
|
|
540
|
+
return await this.#sessionState(tenant, ownerDids, fresh) !== "invalid";
|
|
541
|
+
}
|
|
542
|
+
async #sessionState(tenant, ownerDids, fresh = false) {
|
|
543
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
541
544
|
const key = JSON.stringify([tenant.stateRoot, ownerDids.map(normalizeDid), fresh]);
|
|
542
545
|
const current = this.#sessionChecks.get(key);
|
|
543
546
|
if (current) return current;
|
|
@@ -554,9 +557,9 @@ var RemoteTenantStore = class {
|
|
|
554
557
|
} catch (error) {
|
|
555
558
|
if (!(error instanceof SyntaxError)) throw error;
|
|
556
559
|
await this.#clearAuthority(tenant);
|
|
557
|
-
return
|
|
560
|
+
return "invalid";
|
|
558
561
|
}
|
|
559
|
-
if (raw === null) return
|
|
562
|
+
if (raw === null) return "invalid";
|
|
560
563
|
const node = new import_node_sdk2.TinyCloudNode({ host: this.#config.nodeHost });
|
|
561
564
|
try {
|
|
562
565
|
await node.restoreSession(raw);
|
|
@@ -565,11 +568,11 @@ var RemoteTenantStore = class {
|
|
|
565
568
|
const signedExpiry = typeof header === "string" ? (0, import_node_sdk2.signedCompactUcanExpiry)(header) : void 0;
|
|
566
569
|
const siweExpiry = typeof raw.siwe === "string" ? /^Expiration Time: ([^\r\n]+)\r?$/m.exec(raw.siwe)?.[1] : void 0;
|
|
567
570
|
const expiry = signedExpiry ?? (siweExpiry === void 0 ? void 0 : new Date(siweExpiry));
|
|
568
|
-
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return
|
|
571
|
+
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return "invalid";
|
|
569
572
|
await this.#clearAuthority(tenant);
|
|
570
|
-
return
|
|
573
|
+
return "invalid";
|
|
571
574
|
}
|
|
572
|
-
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return
|
|
575
|
+
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return "invalid";
|
|
573
576
|
const additional = await readJson(this.#additionalPath(tenant.stateRoot));
|
|
574
577
|
const cids = [raw.delegationCid];
|
|
575
578
|
if (additional !== null) {
|
|
@@ -584,7 +587,7 @@ var RemoteTenantStore = class {
|
|
|
584
587
|
}
|
|
585
588
|
const fingerprint = cids.join("\n");
|
|
586
589
|
const cached = this.#activeSessions.get(tenant.stateRoot);
|
|
587
|
-
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return
|
|
590
|
+
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return "valid";
|
|
588
591
|
let timer;
|
|
589
592
|
const timeout = new Promise((resolve) => {
|
|
590
593
|
timer = setTimeout(() => resolve(void 0), 2e3);
|
|
@@ -597,13 +600,14 @@ var RemoteTenantStore = class {
|
|
|
597
600
|
const refusal = probe !== void 0 && !probe.ok ? (0, import_mcp_authority.nodeRevocationOf)(probe.error) : void 0;
|
|
598
601
|
if (refusal !== void 0 && (refusal.revokedCid === raw.delegationCid || refusal.reason === "delegation_ancestor_revoked" && refusal.ancestorCid === raw.delegationCid)) {
|
|
599
602
|
await this.#clearAuthority(tenant);
|
|
600
|
-
return
|
|
603
|
+
return "invalid";
|
|
601
604
|
}
|
|
602
|
-
if (this.#renewalRequired.has(tenant.stateRoot)) return
|
|
605
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
603
606
|
if (probe?.ok) {
|
|
604
607
|
this.#activeSessions.set(tenant.stateRoot, { cids: fingerprint, until: Date.now() + 3e4 });
|
|
608
|
+
return "valid";
|
|
605
609
|
}
|
|
606
|
-
return
|
|
610
|
+
return "unknown";
|
|
607
611
|
}
|
|
608
612
|
async #clearAuthority(tenant) {
|
|
609
613
|
const current = this.#clearing.get(tenant.stateRoot);
|
|
@@ -1378,7 +1382,7 @@ function outcomeCode(result) {
|
|
|
1378
1382
|
// package.json
|
|
1379
1383
|
var package_default = {
|
|
1380
1384
|
name: "@tinycloud/mcp",
|
|
1381
|
-
version: "0.8.0-beta.
|
|
1385
|
+
version: "0.8.0-beta.8",
|
|
1382
1386
|
description: "TinyCloud delegated operations MCP server",
|
|
1383
1387
|
keywords: [
|
|
1384
1388
|
"tinycloud",
|
|
@@ -1449,9 +1453,9 @@ var package_default = {
|
|
|
1449
1453
|
dependencies: {
|
|
1450
1454
|
"@modelcontextprotocol/node": "2.0.0-beta.5",
|
|
1451
1455
|
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
|
1452
|
-
"@tinycloud/node-sdk": "3.6.0-beta.
|
|
1456
|
+
"@tinycloud/node-sdk": "3.6.0-beta.7",
|
|
1453
1457
|
"@tinycloud/node-sdk-wasm": "1.7.8",
|
|
1454
|
-
"@tinycloud/operations": "0.7.4-beta.
|
|
1458
|
+
"@tinycloud/operations": "0.7.4-beta.7",
|
|
1455
1459
|
jose: "6.2.4"
|
|
1456
1460
|
},
|
|
1457
1461
|
devDependencies: {
|
|
@@ -1655,19 +1659,26 @@ function registerConnectTool(server, validator, store, identity, surface) {
|
|
|
1655
1659
|
async () => {
|
|
1656
1660
|
const startedAt = performance.now();
|
|
1657
1661
|
let code = "INTERNAL_ERROR";
|
|
1662
|
+
let text;
|
|
1658
1663
|
try {
|
|
1659
1664
|
const status = await store.connectStatus(identity.subject, identity.ownerDids);
|
|
1660
|
-
|
|
1665
|
+
if (status.connected) {
|
|
1666
|
+
code = "ok";
|
|
1667
|
+
text = "TinyCloud is connected.";
|
|
1668
|
+
} else if (status.approvalUrl === void 0) {
|
|
1669
|
+
code = "unavailable";
|
|
1670
|
+
text = "TinyCloud is unavailable. Call this tool again shortly.";
|
|
1671
|
+
} else {
|
|
1672
|
+
code = "authority_required";
|
|
1673
|
+
text = `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`;
|
|
1674
|
+
}
|
|
1661
1675
|
const visibleStatus = surface === "hosted" ? status : {
|
|
1662
1676
|
connected: status.connected,
|
|
1663
1677
|
...status.approvalUrl === void 0 ? {} : { approvalUrl: status.approvalUrl },
|
|
1664
1678
|
...status.expiresAt === void 0 ? {} : { expiresAt: status.expiresAt }
|
|
1665
1679
|
};
|
|
1666
1680
|
return {
|
|
1667
|
-
content: [{
|
|
1668
|
-
type: "text",
|
|
1669
|
-
text: status.connected ? "TinyCloud is connected." : `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`
|
|
1670
|
-
}],
|
|
1681
|
+
content: [{ type: "text", text }],
|
|
1671
1682
|
structuredContent: visibleStatus
|
|
1672
1683
|
};
|
|
1673
1684
|
} finally {
|