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