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