@sanctuary-framework/mcp-server 0.10.4 → 0.10.6

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/index.js CHANGED
@@ -6602,6 +6602,11 @@ function generateDashboardHTML(options) {
6602
6602
  // SEC-038: Do NOT embed the long-lived auth token in page source.
6603
6603
  // Use only the session token stored in sessionStorage by the login flow.
6604
6604
  const AUTH_TOKEN = sessionStorage.getItem('authToken') || '';
6605
+ // v0.10.6: server-baked flag mirroring _autoAuthLocalhost. When true,
6606
+ // the init-time auth gate does NOT redirect to '/' on empty AUTH_TOKEN,
6607
+ // because the server already admitted this loopback caller without a
6608
+ // bearer token. See dashboard-html.ts generateDashboardHTML() doc.
6609
+ const LOOPBACK_AUTH = ${JSON.stringify(options.loopbackAutoAuth === true)};
6605
6610
  const TIMEOUT_SECONDS = ${options.timeoutSeconds};
6606
6611
  const API_BASE = '';
6607
6612
 
@@ -7006,11 +7011,20 @@ function generateDashboardHTML(options) {
7006
7011
 
7007
7012
  // SSE Setup
7008
7013
  function setupSSE() {
7009
- const eventSource = new EventSource(API_BASE + '/api/events', {
7010
- headers: {
7011
- 'Authorization': 'Bearer ' + AUTH_TOKEN,
7012
- },
7013
- });
7014
+ // v0.10.5: the standard browser EventSource API does not support a
7015
+ // headers option \u2014 it is silently dropped. Auth must travel as a
7016
+ // cookie (set by /auth/session and sent automatically by the
7017
+ // browser) or as a ?session= query parameter, both of which Stack
7018
+ // A's checkAuth honours. Loopback callers also bypass auth via the
7019
+ // v0.10.2 _autoAuthLocalhost path, which is the path moltbook
7020
+ // hits when the dashboard is auto-opened on 127.0.0.1.
7021
+ //
7022
+ // The endpoint itself is /events \u2014 Stack A's route table mounts it
7023
+ // there, and the previous /api/events URL was a 404 in every real
7024
+ // boot from v0.10.0 through v0.10.4. The retry loop that result
7025
+ // produced is exactly the "status bar flashing blue continuously"
7026
+ // moltbook reported on v0.10.4.
7027
+ const eventSource = new EventSource(API_BASE + '/events');
7014
7028
 
7015
7029
  eventSource.addEventListener('init', (e) => {
7016
7030
  console.log('Connected to SSE');
@@ -7700,7 +7714,13 @@ function generateDashboardHTML(options) {
7700
7714
 
7701
7715
  // Initialize
7702
7716
  async function initialize() {
7703
- if (!AUTH_TOKEN) {
7717
+ // v0.10.6: gate on BOTH sessionStorage and the server-baked loopback
7718
+ // auto-auth mirror. Pre-fix, a fresh loopback tab had empty
7719
+ // sessionStorage.authToken AND was admitted by the server via
7720
+ // _autoAuthLocalhost \u2014 this single-operand gate redirected to '/'
7721
+ // which reloaded the same page, which redirected again, infinitely.
7722
+ // See generateDashboardHTML() header comment for full threat model.
7723
+ if (!AUTH_TOKEN && !LOOPBACK_AUTH) {
7704
7724
  redirectToLogin();
7705
7725
  return;
7706
7726
  }
@@ -8726,7 +8746,11 @@ var DashboardApprovalChannel = class {
8726
8746
  this.sessionTTLMs = isLocalhost ? SESSION_TTL_LOCAL_MS : SESSION_TTL_REMOTE_MS;
8727
8747
  this.dashboardHTML = generateDashboardHTML({
8728
8748
  timeoutSeconds: config.timeout_seconds,
8729
- serverVersion: SANCTUARY_VERSION
8749
+ serverVersion: SANCTUARY_VERSION,
8750
+ // Construction-time default; real value is set by setAutoAuthLocalhost()
8751
+ // below (which regenerates this HTML). Default false preserves the
8752
+ // pre-v0.10.6 remote-deployment behavior when auto-auth is not enabled.
8753
+ loopbackAutoAuth: this._autoAuthLocalhost
8730
8754
  });
8731
8755
  this.loginHTML = generateLoginHTML({ serverVersion: SANCTUARY_VERSION });
8732
8756
  this.sessionCleanupTimer = setInterval(() => this.cleanupSessions(), 6e4);
@@ -8762,6 +8786,11 @@ var DashboardApprovalChannel = class {
8762
8786
  */
8763
8787
  setAutoAuthLocalhost(enabled) {
8764
8788
  this._autoAuthLocalhost = enabled;
8789
+ this.dashboardHTML = generateDashboardHTML({
8790
+ timeoutSeconds: this.config.timeout_seconds,
8791
+ serverVersion: SANCTUARY_VERSION,
8792
+ loopbackAutoAuth: this._autoAuthLocalhost
8793
+ });
8765
8794
  }
8766
8795
  /**
8767
8796
  * v0.10.2: is this request from a loopback interface? We treat the