@mastra/deployer 1.58.0-alpha.3 → 1.58.0-alpha.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAc5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoBnD,KAAK,QAAQ,GAAG,YAAY,CAAC;AAE7B,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,OAAO,EAAE,GAAG,CAAC;QAAE,UAAU,EAAE,+BAA+B,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC;AAwCF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,wCAmB/D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAER;cAegC,QAAQ;eAAa,SAAS;2CA4ZhE;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAmC,mDAwHlG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIhE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAc5B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoBnD,KAAK,QAAQ,GAAG,YAAY,CAAC;AAE7B,KAAK,SAAS,GAAG,aAAa,GAAG;IAC/B,OAAO,EAAE,GAAG,CAAC;QAAE,UAAU,EAAE,+BAA+B,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC;AAwCF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,wCAmB/D;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAER;cAegC,QAAQ;eAAa,SAAS;2CAkahE;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAmC,mDAwHlG"}
@@ -13,7 +13,7 @@ import process$1, { versions } from "process";
13
13
  import { getMimeType } from "hono/utils/mime";
14
14
  import { html } from "hono/html";
15
15
  import { Tool } from "@mastra/core/tools";
16
- import { MastraServer, checkRouteFGA, isZodError, normalizeQueryParams, redactStreamChunk, serializeStreamChunk } from "@mastra/server/server-adapter";
16
+ import { MASTRA_FRAMEWORK_PUBLIC_KEY, MastraServer, checkRouteFGA, isZodError, normalizeQueryParams, redactStreamChunk, serializeStreamChunk } from "@mastra/server/server-adapter";
17
17
  import util from "util";
18
18
  import { Buffer as Buffer$1 } from "buffer";
19
19
  import { bodyLimit } from "hono/body-limit";
@@ -3102,6 +3102,26 @@ function loadHasPermission() {
3102
3102
  });
3103
3103
  return _hasPermissionPromise;
3104
3104
  }
3105
+ /**
3106
+ * Wrap a Hono middleware handler so it becomes a no-op for framework-public
3107
+ * routes (routes registered with `requiresAuth: false`).
3108
+ *
3109
+ * Adapters that expose user-provided middleware — for example `serverMiddleware`
3110
+ * on the Mastra instance or `server.middleware` in Mastra config — MUST wrap
3111
+ * those handlers with this before registering them. This is the framework's
3112
+ * guarantee that user middleware cannot accidentally (or intentionally) 401
3113
+ * routes the framework needs to keep reachable (e.g. Studio sign-in endpoints).
3114
+ *
3115
+ * The framework-public flag is computed once per request by
3116
+ * {@link MastraServer.registerContextMiddleware} and stashed on the Hono
3117
+ * context under `MASTRA_FRAMEWORK_PUBLIC_KEY`.
3118
+ */
3119
+ const skipIfFrameworkPublic = (handler) => {
3120
+ return async (c, next) => {
3121
+ if (c.get(MASTRA_FRAMEWORK_PUBLIC_KEY)) return next();
3122
+ return handler(c, next);
3123
+ };
3124
+ };
3105
3125
  var MastraServer$1 = class extends MastraServer {
3106
3126
  createContextMiddleware() {
3107
3127
  return async (c, next) => {
@@ -3561,7 +3581,12 @@ var MastraServer$1 = class extends MastraServer {
3561
3581
  }
3562
3582
  }
3563
3583
  registerContextMiddleware() {
3584
+ const isFrameworkPublic = this.getFrameworkPublicMatcher();
3564
3585
  this.app.use("*", this.createContextMiddleware());
3586
+ this.app.use("*", async (c, next) => {
3587
+ c.set(MASTRA_FRAMEWORK_PUBLIC_KEY, isFrameworkPublic(c.req.path, c.req.method));
3588
+ return next();
3589
+ });
3565
3590
  this.app.use("*", async (c, next) => {
3566
3591
  await next();
3567
3592
  this.warnIfUnregisteredChannelWebhook(c.req.path, c.req.method, c.res.status);
@@ -4385,7 +4410,7 @@ async function createHonoServer(mastra, options = { tools: {} }) {
4385
4410
  });
4386
4411
  honoServerAdapter.registerContextMiddleware();
4387
4412
  const serverMiddleware = mastra.getServerMiddleware?.();
4388
- if (serverMiddleware && serverMiddleware.length > 0) for (const m of serverMiddleware) app.use(m.path, m.handler);
4413
+ if (serverMiddleware && serverMiddleware.length > 0) for (const m of serverMiddleware) app.use(m.path, skipIfFrameworkPublic(m.handler));
4389
4414
  const browserStreamSetup = options.browserStream === false ? null : await setupBrowserStream(app, {
4390
4415
  getToolset: async (agentId) => {
4391
4416
  try {
@@ -4435,7 +4460,7 @@ async function createHonoServer(mastra, options = { tools: {} }) {
4435
4460
  };
4436
4461
  return middleware;
4437
4462
  });
4438
- for (const middleware of middlewares) app.use(middleware.path, middleware.handler);
4463
+ for (const middleware of middlewares) app.use(middleware.path, skipIfFrameworkPublic(middleware.handler));
4439
4464
  }
4440
4465
  await honoServerAdapter.registerCustomApiRoutes();
4441
4466
  if (server?.build?.apiReqLogs) app.use(logger());