@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-cli.cjs
CHANGED
|
@@ -212,9 +212,9 @@ var RemoteTenantStore = class {
|
|
|
212
212
|
}
|
|
213
213
|
async connectStatus(subject, ownerDids = []) {
|
|
214
214
|
const tenant = await this.#ensureTenant(subject);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
215
|
+
const state = await this.#sessionState(tenant, ownerDids, true);
|
|
216
|
+
if (state === "valid") return { connected: true, sessionDid: tenant.sessionDid };
|
|
217
|
+
if (state === "unknown") return { connected: false, sessionDid: tenant.sessionDid };
|
|
218
218
|
const pending = await this.#createPending(subject, ownerDids, "bootstrap", BOOTSTRAP_PERMISSIONS);
|
|
219
219
|
return {
|
|
220
220
|
connected: false,
|
|
@@ -554,7 +554,10 @@ var RemoteTenantStore = class {
|
|
|
554
554
|
return initializing;
|
|
555
555
|
}
|
|
556
556
|
async #hasValidSession(tenant, ownerDids, fresh = false) {
|
|
557
|
-
|
|
557
|
+
return await this.#sessionState(tenant, ownerDids, fresh) !== "invalid";
|
|
558
|
+
}
|
|
559
|
+
async #sessionState(tenant, ownerDids, fresh = false) {
|
|
560
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
558
561
|
const key = JSON.stringify([tenant.stateRoot, ownerDids.map(normalizeDid), fresh]);
|
|
559
562
|
const current = this.#sessionChecks.get(key);
|
|
560
563
|
if (current) return current;
|
|
@@ -571,9 +574,9 @@ var RemoteTenantStore = class {
|
|
|
571
574
|
} catch (error) {
|
|
572
575
|
if (!(error instanceof SyntaxError)) throw error;
|
|
573
576
|
await this.#clearAuthority(tenant);
|
|
574
|
-
return
|
|
577
|
+
return "invalid";
|
|
575
578
|
}
|
|
576
|
-
if (raw === null) return
|
|
579
|
+
if (raw === null) return "invalid";
|
|
577
580
|
const node = new import_node_sdk2.TinyCloudNode({ host: this.#config.nodeHost });
|
|
578
581
|
try {
|
|
579
582
|
await node.restoreSession(raw);
|
|
@@ -582,11 +585,11 @@ var RemoteTenantStore = class {
|
|
|
582
585
|
const signedExpiry = typeof header === "string" ? (0, import_node_sdk2.signedCompactUcanExpiry)(header) : void 0;
|
|
583
586
|
const siweExpiry = typeof raw.siwe === "string" ? /^Expiration Time: ([^\r\n]+)\r?$/m.exec(raw.siwe)?.[1] : void 0;
|
|
584
587
|
const expiry = signedExpiry ?? (siweExpiry === void 0 ? void 0 : new Date(siweExpiry));
|
|
585
|
-
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return
|
|
588
|
+
if (expiry !== void 0 && expiry.getTime() <= Date.now()) return "invalid";
|
|
586
589
|
await this.#clearAuthority(tenant);
|
|
587
|
-
return
|
|
590
|
+
return "invalid";
|
|
588
591
|
}
|
|
589
|
-
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return
|
|
592
|
+
if (!samePrincipal(node.sessionDid, tenant.sessionDid) || !ownerDids.some((did) => samePrincipal(node.did, did))) return "invalid";
|
|
590
593
|
const additional = await readJson(this.#additionalPath(tenant.stateRoot));
|
|
591
594
|
const cids = [raw.delegationCid];
|
|
592
595
|
if (additional !== null) {
|
|
@@ -601,7 +604,7 @@ var RemoteTenantStore = class {
|
|
|
601
604
|
}
|
|
602
605
|
const fingerprint = cids.join("\n");
|
|
603
606
|
const cached = this.#activeSessions.get(tenant.stateRoot);
|
|
604
|
-
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return
|
|
607
|
+
if (!fresh && cached?.cids === fingerprint && cached.until > Date.now()) return "valid";
|
|
605
608
|
let timer;
|
|
606
609
|
const timeout = new Promise((resolve2) => {
|
|
607
610
|
timer = setTimeout(() => resolve2(void 0), 2e3);
|
|
@@ -614,13 +617,14 @@ var RemoteTenantStore = class {
|
|
|
614
617
|
const refusal = probe !== void 0 && !probe.ok ? (0, import_mcp_authority.nodeRevocationOf)(probe.error) : void 0;
|
|
615
618
|
if (refusal !== void 0 && (refusal.revokedCid === raw.delegationCid || refusal.reason === "delegation_ancestor_revoked" && refusal.ancestorCid === raw.delegationCid)) {
|
|
616
619
|
await this.#clearAuthority(tenant);
|
|
617
|
-
return
|
|
620
|
+
return "invalid";
|
|
618
621
|
}
|
|
619
|
-
if (this.#renewalRequired.has(tenant.stateRoot)) return
|
|
622
|
+
if (this.#renewalRequired.has(tenant.stateRoot)) return "invalid";
|
|
620
623
|
if (probe?.ok) {
|
|
621
624
|
this.#activeSessions.set(tenant.stateRoot, { cids: fingerprint, until: Date.now() + 3e4 });
|
|
625
|
+
return "valid";
|
|
622
626
|
}
|
|
623
|
-
return
|
|
627
|
+
return "unknown";
|
|
624
628
|
}
|
|
625
629
|
async #clearAuthority(tenant) {
|
|
626
630
|
const current = this.#clearing.get(tenant.stateRoot);
|
|
@@ -1395,7 +1399,7 @@ function outcomeCode(result) {
|
|
|
1395
1399
|
// package.json
|
|
1396
1400
|
var package_default = {
|
|
1397
1401
|
name: "@tinycloud/mcp",
|
|
1398
|
-
version: "0.8.0-beta.
|
|
1402
|
+
version: "0.8.0-beta.8",
|
|
1399
1403
|
description: "TinyCloud delegated operations MCP server",
|
|
1400
1404
|
keywords: [
|
|
1401
1405
|
"tinycloud",
|
|
@@ -1466,9 +1470,9 @@ var package_default = {
|
|
|
1466
1470
|
dependencies: {
|
|
1467
1471
|
"@modelcontextprotocol/node": "2.0.0-beta.5",
|
|
1468
1472
|
"@modelcontextprotocol/server": "2.0.0-beta.5",
|
|
1469
|
-
"@tinycloud/node-sdk": "3.6.0-beta.
|
|
1473
|
+
"@tinycloud/node-sdk": "3.6.0-beta.7",
|
|
1470
1474
|
"@tinycloud/node-sdk-wasm": "1.7.8",
|
|
1471
|
-
"@tinycloud/operations": "0.7.4-beta.
|
|
1475
|
+
"@tinycloud/operations": "0.7.4-beta.7",
|
|
1472
1476
|
jose: "6.2.4"
|
|
1473
1477
|
},
|
|
1474
1478
|
devDependencies: {
|
|
@@ -1672,19 +1676,26 @@ function registerConnectTool(server, validator, store, identity, surface) {
|
|
|
1672
1676
|
async () => {
|
|
1673
1677
|
const startedAt = performance.now();
|
|
1674
1678
|
let code = "INTERNAL_ERROR";
|
|
1679
|
+
let text;
|
|
1675
1680
|
try {
|
|
1676
1681
|
const status = await store.connectStatus(identity.subject, identity.ownerDids);
|
|
1677
|
-
|
|
1682
|
+
if (status.connected) {
|
|
1683
|
+
code = "ok";
|
|
1684
|
+
text = "TinyCloud is connected.";
|
|
1685
|
+
} else if (status.approvalUrl === void 0) {
|
|
1686
|
+
code = "unavailable";
|
|
1687
|
+
text = "TinyCloud is unavailable. Call this tool again shortly.";
|
|
1688
|
+
} else {
|
|
1689
|
+
code = "authority_required";
|
|
1690
|
+
text = `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`;
|
|
1691
|
+
}
|
|
1678
1692
|
const visibleStatus = surface === "hosted" ? status : {
|
|
1679
1693
|
connected: status.connected,
|
|
1680
1694
|
...status.approvalUrl === void 0 ? {} : { approvalUrl: status.approvalUrl },
|
|
1681
1695
|
...status.expiresAt === void 0 ? {} : { expiresAt: status.expiresAt }
|
|
1682
1696
|
};
|
|
1683
1697
|
return {
|
|
1684
|
-
content: [{
|
|
1685
|
-
type: "text",
|
|
1686
|
-
text: status.connected ? "TinyCloud is connected." : `TinyCloud approval is required. Open ${status.approvalUrl}, then call this tool again. This link expires at ${status.expiresAt}.`
|
|
1687
|
-
}],
|
|
1698
|
+
content: [{ type: "text", text }],
|
|
1688
1699
|
structuredContent: visibleStatus
|
|
1689
1700
|
};
|
|
1690
1701
|
} finally {
|