@sanctuary-framework/mcp-server 0.5.12 → 0.5.13

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/cli.cjs CHANGED
@@ -560,6 +560,18 @@ var init_hashing = __esm({
560
560
  init_encoding();
561
561
  }
562
562
  });
563
+
564
+ // src/core/identity.ts
565
+ var identity_exports = {};
566
+ __export(identity_exports, {
567
+ createIdentity: () => createIdentity,
568
+ generateIdentityId: () => generateIdentityId,
569
+ generateKeypair: () => generateKeypair,
570
+ publicKeyToDid: () => publicKeyToDid,
571
+ rotateKeys: () => rotateKeys,
572
+ sign: () => sign,
573
+ verify: () => verify
574
+ });
563
575
  function generateKeypair() {
564
576
  const privateKey = randomBytes(32);
565
577
  const publicKey = ed25519.ed25519.getPublicKey(privateKey);
@@ -1626,6 +1638,7 @@ tier1_always_approve:
1626
1638
  - reputation_import
1627
1639
  - reputation_export
1628
1640
  - bootstrap_provide_guarantee
1641
+ - reputation_publish
1629
1642
 
1630
1643
  # \u2500\u2500\u2500 Tier 2: Behavioral Anomaly Detection \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
1631
1644
  # Triggers approval when agent behavior deviates from its baseline.
@@ -1688,6 +1701,7 @@ tier3_always_allow:
1688
1701
  - bridge_commit
1689
1702
  - bridge_verify
1690
1703
  - bridge_attest
1704
+ - dashboard_open
1691
1705
 
1692
1706
  # \u2500\u2500\u2500 Approval Channel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
1693
1707
  # How Sanctuary reaches you when approval is needed.
@@ -1740,7 +1754,9 @@ var init_loader = __esm({
1740
1754
  "reputation_import",
1741
1755
  "reputation_export",
1742
1756
  "bootstrap_provide_guarantee",
1743
- "decommission_certificate"
1757
+ "decommission_certificate",
1758
+ "reputation_publish"
1759
+ // SEC-039: Explicit Tier 1 — sends data to external API
1744
1760
  ],
1745
1761
  tier2_anomaly: DEFAULT_TIER2,
1746
1762
  tier3_always_allow: [
@@ -1792,7 +1808,9 @@ var init_loader = __esm({
1792
1808
  "shr_gateway_export",
1793
1809
  "bridge_commit",
1794
1810
  "bridge_verify",
1795
- "bridge_attest"
1811
+ "bridge_attest",
1812
+ "dashboard_open"
1813
+ // SEC-039: Explicit Tier 3 — only generates a URL
1796
1814
  ],
1797
1815
  approval_channel: DEFAULT_CHANNEL
1798
1816
  };
@@ -3368,7 +3386,9 @@ function generateDashboardHTML(options) {
3368
3386
 
3369
3387
  <script>
3370
3388
  // Constants
3371
- const AUTH_TOKEN = '${options.authToken || ""}' || sessionStorage.getItem('authToken') || '';
3389
+ // SEC-038: Do NOT embed the long-lived auth token in page source.
3390
+ // Use only the session token stored in sessionStorage by the login flow.
3391
+ const AUTH_TOKEN = sessionStorage.getItem('authToken') || '';
3372
3392
  const TIMEOUT_SECONDS = ${options.timeoutSeconds};
3373
3393
  const API_BASE = '';
3374
3394
 
@@ -7179,6 +7199,24 @@ function createL4Tools(storage, masterKey, identityManager, auditLog, handshakeR
7179
7199
  }
7180
7200
  const publishType = args.type;
7181
7201
  const veracoreUrl = args.verascore_url || "https://verascore.ai";
7202
+ const ALLOWED_VERASCORE_HOSTS = ["verascore.ai", "www.verascore.ai", "api.verascore.ai"];
7203
+ try {
7204
+ const parsed = new URL(veracoreUrl);
7205
+ if (parsed.protocol !== "https:") {
7206
+ return toolResult({
7207
+ error: `verascore_url must use HTTPS. Got: ${parsed.protocol}`
7208
+ });
7209
+ }
7210
+ if (!ALLOWED_VERASCORE_HOSTS.includes(parsed.hostname)) {
7211
+ return toolResult({
7212
+ error: `verascore_url must point to a known Verascore domain (${ALLOWED_VERASCORE_HOSTS.join(", ")}). Got: ${parsed.hostname}`
7213
+ });
7214
+ }
7215
+ } catch {
7216
+ return toolResult({
7217
+ error: `verascore_url is not a valid URL: ${veracoreUrl}`
7218
+ });
7219
+ }
7182
7220
  const agentId = args.verascore_agent_id || identity.did.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
7183
7221
  let publishData;
7184
7222
  if (args.data) {
@@ -7208,24 +7246,21 @@ function createL4Tools(storage, masterKey, identityManager, auditLog, handshakeR
7208
7246
  return toolResult({ error: `Unknown publish type: ${publishType}` });
7209
7247
  }
7210
7248
  }
7211
- const { sign: sign2, createPrivateKey } = await import('crypto');
7212
- const payloadBytes = Buffer.from(JSON.stringify(publishData), "utf-8");
7249
+ const { sign: identitySign } = await Promise.resolve().then(() => (init_identity(), identity_exports));
7250
+ const payloadBytes = new TextEncoder().encode(JSON.stringify(publishData));
7213
7251
  let signatureB64;
7214
7252
  try {
7215
- const signingKey = derivePurposeKey(masterKey, "verascore-publish");
7216
- const privateKey = createPrivateKey({
7217
- key: Buffer.concat([
7218
- Buffer.from("302e020100300506032b657004220420", "hex"),
7219
- // Ed25519 DER PKCS8 prefix
7220
- Buffer.from(signingKey.slice(0, 32))
7221
- ]),
7222
- format: "der",
7223
- type: "pkcs8"
7224
- });
7225
- const sig = sign2(null, payloadBytes, privateKey);
7226
- signatureB64 = sig.toString("base64url");
7253
+ const signingBytes = identitySign(
7254
+ payloadBytes,
7255
+ identity.encrypted_private_key,
7256
+ identityEncryptionKey
7257
+ );
7258
+ signatureB64 = toBase64url(signingBytes);
7227
7259
  } catch (signError) {
7228
- signatureB64 = toBase64url(new Uint8Array(64));
7260
+ return toolResult({
7261
+ error: "Failed to sign publish payload. Identity key may be corrupted.",
7262
+ details: signError instanceof Error ? signError.message : String(signError)
7263
+ });
7229
7264
  }
7230
7265
  const requestBody = {
7231
7266
  agentId,