@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.js CHANGED
@@ -557,6 +557,18 @@ var init_hashing = __esm({
557
557
  init_encoding();
558
558
  }
559
559
  });
560
+
561
+ // src/core/identity.ts
562
+ var identity_exports = {};
563
+ __export(identity_exports, {
564
+ createIdentity: () => createIdentity,
565
+ generateIdentityId: () => generateIdentityId,
566
+ generateKeypair: () => generateKeypair,
567
+ publicKeyToDid: () => publicKeyToDid,
568
+ rotateKeys: () => rotateKeys,
569
+ sign: () => sign,
570
+ verify: () => verify
571
+ });
560
572
  function generateKeypair() {
561
573
  const privateKey = randomBytes(32);
562
574
  const publicKey = ed25519.getPublicKey(privateKey);
@@ -1623,6 +1635,7 @@ tier1_always_approve:
1623
1635
  - reputation_import
1624
1636
  - reputation_export
1625
1637
  - bootstrap_provide_guarantee
1638
+ - reputation_publish
1626
1639
 
1627
1640
  # \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
1628
1641
  # Triggers approval when agent behavior deviates from its baseline.
@@ -1685,6 +1698,7 @@ tier3_always_allow:
1685
1698
  - bridge_commit
1686
1699
  - bridge_verify
1687
1700
  - bridge_attest
1701
+ - dashboard_open
1688
1702
 
1689
1703
  # \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
1690
1704
  # How Sanctuary reaches you when approval is needed.
@@ -1737,7 +1751,9 @@ var init_loader = __esm({
1737
1751
  "reputation_import",
1738
1752
  "reputation_export",
1739
1753
  "bootstrap_provide_guarantee",
1740
- "decommission_certificate"
1754
+ "decommission_certificate",
1755
+ "reputation_publish"
1756
+ // SEC-039: Explicit Tier 1 — sends data to external API
1741
1757
  ],
1742
1758
  tier2_anomaly: DEFAULT_TIER2,
1743
1759
  tier3_always_allow: [
@@ -1789,7 +1805,9 @@ var init_loader = __esm({
1789
1805
  "shr_gateway_export",
1790
1806
  "bridge_commit",
1791
1807
  "bridge_verify",
1792
- "bridge_attest"
1808
+ "bridge_attest",
1809
+ "dashboard_open"
1810
+ // SEC-039: Explicit Tier 3 — only generates a URL
1793
1811
  ],
1794
1812
  approval_channel: DEFAULT_CHANNEL
1795
1813
  };
@@ -3365,7 +3383,9 @@ function generateDashboardHTML(options) {
3365
3383
 
3366
3384
  <script>
3367
3385
  // Constants
3368
- const AUTH_TOKEN = '${options.authToken || ""}' || sessionStorage.getItem('authToken') || '';
3386
+ // SEC-038: Do NOT embed the long-lived auth token in page source.
3387
+ // Use only the session token stored in sessionStorage by the login flow.
3388
+ const AUTH_TOKEN = sessionStorage.getItem('authToken') || '';
3369
3389
  const TIMEOUT_SECONDS = ${options.timeoutSeconds};
3370
3390
  const API_BASE = '';
3371
3391
 
@@ -7176,6 +7196,24 @@ function createL4Tools(storage, masterKey, identityManager, auditLog, handshakeR
7176
7196
  }
7177
7197
  const publishType = args.type;
7178
7198
  const veracoreUrl = args.verascore_url || "https://verascore.ai";
7199
+ const ALLOWED_VERASCORE_HOSTS = ["verascore.ai", "www.verascore.ai", "api.verascore.ai"];
7200
+ try {
7201
+ const parsed = new URL(veracoreUrl);
7202
+ if (parsed.protocol !== "https:") {
7203
+ return toolResult({
7204
+ error: `verascore_url must use HTTPS. Got: ${parsed.protocol}`
7205
+ });
7206
+ }
7207
+ if (!ALLOWED_VERASCORE_HOSTS.includes(parsed.hostname)) {
7208
+ return toolResult({
7209
+ error: `verascore_url must point to a known Verascore domain (${ALLOWED_VERASCORE_HOSTS.join(", ")}). Got: ${parsed.hostname}`
7210
+ });
7211
+ }
7212
+ } catch {
7213
+ return toolResult({
7214
+ error: `verascore_url is not a valid URL: ${veracoreUrl}`
7215
+ });
7216
+ }
7179
7217
  const agentId = args.verascore_agent_id || identity.did.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
7180
7218
  let publishData;
7181
7219
  if (args.data) {
@@ -7205,24 +7243,21 @@ function createL4Tools(storage, masterKey, identityManager, auditLog, handshakeR
7205
7243
  return toolResult({ error: `Unknown publish type: ${publishType}` });
7206
7244
  }
7207
7245
  }
7208
- const { sign: sign2, createPrivateKey } = await import('crypto');
7209
- const payloadBytes = Buffer.from(JSON.stringify(publishData), "utf-8");
7246
+ const { sign: identitySign } = await Promise.resolve().then(() => (init_identity(), identity_exports));
7247
+ const payloadBytes = new TextEncoder().encode(JSON.stringify(publishData));
7210
7248
  let signatureB64;
7211
7249
  try {
7212
- const signingKey = derivePurposeKey(masterKey, "verascore-publish");
7213
- const privateKey = createPrivateKey({
7214
- key: Buffer.concat([
7215
- Buffer.from("302e020100300506032b657004220420", "hex"),
7216
- // Ed25519 DER PKCS8 prefix
7217
- Buffer.from(signingKey.slice(0, 32))
7218
- ]),
7219
- format: "der",
7220
- type: "pkcs8"
7221
- });
7222
- const sig = sign2(null, payloadBytes, privateKey);
7223
- signatureB64 = sig.toString("base64url");
7250
+ const signingBytes = identitySign(
7251
+ payloadBytes,
7252
+ identity.encrypted_private_key,
7253
+ identityEncryptionKey
7254
+ );
7255
+ signatureB64 = toBase64url(signingBytes);
7224
7256
  } catch (signError) {
7225
- signatureB64 = toBase64url(new Uint8Array(64));
7257
+ return toolResult({
7258
+ error: "Failed to sign publish payload. Identity key may be corrupted.",
7259
+ details: signError instanceof Error ? signError.message : String(signError)
7260
+ });
7226
7261
  }
7227
7262
  const requestBody = {
7228
7263
  agentId,