@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/cli.cjs CHANGED
@@ -6715,6 +6715,11 @@ function generateDashboardHTML(options) {
6715
6715
  // SEC-038: Do NOT embed the long-lived auth token in page source.
6716
6716
  // Use only the session token stored in sessionStorage by the login flow.
6717
6717
  const AUTH_TOKEN = sessionStorage.getItem('authToken') || '';
6718
+ // v0.10.6: server-baked flag mirroring _autoAuthLocalhost. When true,
6719
+ // the init-time auth gate does NOT redirect to '/' on empty AUTH_TOKEN,
6720
+ // because the server already admitted this loopback caller without a
6721
+ // bearer token. See dashboard-html.ts generateDashboardHTML() doc.
6722
+ const LOOPBACK_AUTH = ${JSON.stringify(options.loopbackAutoAuth === true)};
6718
6723
  const TIMEOUT_SECONDS = ${options.timeoutSeconds};
6719
6724
  const API_BASE = '';
6720
6725
 
@@ -7119,11 +7124,20 @@ function generateDashboardHTML(options) {
7119
7124
 
7120
7125
  // SSE Setup
7121
7126
  function setupSSE() {
7122
- const eventSource = new EventSource(API_BASE + '/api/events', {
7123
- headers: {
7124
- 'Authorization': 'Bearer ' + AUTH_TOKEN,
7125
- },
7126
- });
7127
+ // v0.10.5: the standard browser EventSource API does not support a
7128
+ // headers option \u2014 it is silently dropped. Auth must travel as a
7129
+ // cookie (set by /auth/session and sent automatically by the
7130
+ // browser) or as a ?session= query parameter, both of which Stack
7131
+ // A's checkAuth honours. Loopback callers also bypass auth via the
7132
+ // v0.10.2 _autoAuthLocalhost path, which is the path moltbook
7133
+ // hits when the dashboard is auto-opened on 127.0.0.1.
7134
+ //
7135
+ // The endpoint itself is /events \u2014 Stack A's route table mounts it
7136
+ // there, and the previous /api/events URL was a 404 in every real
7137
+ // boot from v0.10.0 through v0.10.4. The retry loop that result
7138
+ // produced is exactly the "status bar flashing blue continuously"
7139
+ // moltbook reported on v0.10.4.
7140
+ const eventSource = new EventSource(API_BASE + '/events');
7127
7141
 
7128
7142
  eventSource.addEventListener('init', (e) => {
7129
7143
  console.log('Connected to SSE');
@@ -7813,7 +7827,13 @@ function generateDashboardHTML(options) {
7813
7827
 
7814
7828
  // Initialize
7815
7829
  async function initialize() {
7816
- if (!AUTH_TOKEN) {
7830
+ // v0.10.6: gate on BOTH sessionStorage and the server-baked loopback
7831
+ // auto-auth mirror. Pre-fix, a fresh loopback tab had empty
7832
+ // sessionStorage.authToken AND was admitted by the server via
7833
+ // _autoAuthLocalhost \u2014 this single-operand gate redirected to '/'
7834
+ // which reloaded the same page, which redirected again, infinitely.
7835
+ // See generateDashboardHTML() header comment for full threat model.
7836
+ if (!AUTH_TOKEN && !LOOPBACK_AUTH) {
7817
7837
  redirectToLogin();
7818
7838
  return;
7819
7839
  }
@@ -8858,7 +8878,11 @@ var init_dashboard = __esm({
8858
8878
  this.sessionTTLMs = isLocalhost ? SESSION_TTL_LOCAL_MS : SESSION_TTL_REMOTE_MS;
8859
8879
  this.dashboardHTML = generateDashboardHTML({
8860
8880
  timeoutSeconds: config.timeout_seconds,
8861
- serverVersion: SANCTUARY_VERSION
8881
+ serverVersion: SANCTUARY_VERSION,
8882
+ // Construction-time default; real value is set by setAutoAuthLocalhost()
8883
+ // below (which regenerates this HTML). Default false preserves the
8884
+ // pre-v0.10.6 remote-deployment behavior when auto-auth is not enabled.
8885
+ loopbackAutoAuth: this._autoAuthLocalhost
8862
8886
  });
8863
8887
  this.loginHTML = generateLoginHTML({ serverVersion: SANCTUARY_VERSION });
8864
8888
  this.sessionCleanupTimer = setInterval(() => this.cleanupSessions(), 6e4);
@@ -8894,6 +8918,11 @@ var init_dashboard = __esm({
8894
8918
  */
8895
8919
  setAutoAuthLocalhost(enabled) {
8896
8920
  this._autoAuthLocalhost = enabled;
8921
+ this.dashboardHTML = generateDashboardHTML({
8922
+ timeoutSeconds: this.config.timeout_seconds,
8923
+ serverVersion: SANCTUARY_VERSION,
8924
+ loopbackAutoAuth: this._autoAuthLocalhost
8925
+ });
8897
8926
  }
8898
8927
  /**
8899
8928
  * v0.10.2: is this request from a loopback interface? We treat the