@mastra/hono 1.4.12-alpha.1 → 1.4.12-alpha.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @mastra/hono
2
2
 
3
+ ## 1.4.12-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Added FGA enforcement to server adapter middleware, ensuring authorization checks are applied consistently across all built-in adapters. ([#15410](https://github.com/mastra-ai/mastra/pull/15410))
8
+
9
+ - Updated dependencies [[`86c0298`](https://github.com/mastra-ai/mastra/commit/86c0298e647306423c842f9d5ac827bd616bd13d), [`7fce309`](https://github.com/mastra-ai/mastra/commit/7fce30912b14170bfc41f0ac736cca0f39fe0cd4), [`cd96779`](https://github.com/mastra-ai/mastra/commit/cd9677937f113b2856dc8b9f3d4bdabcee58bb2e), [`7997c2e`](https://github.com/mastra-ai/mastra/commit/7997c2e55ddd121562a4098cd8d2b89c68433bf1), [`e97ccb9`](https://github.com/mastra-ai/mastra/commit/e97ccb900f8b7a390ce82c9f8eb8d6eb2c5e3777), [`f5afe62`](https://github.com/mastra-ai/mastra/commit/f5afe62beff3ae69148a35e55fe5375168897829), [`c5daf48`](https://github.com/mastra-ai/mastra/commit/c5daf48556e98c46ae06caf00f92c249912007e9), [`cd96779`](https://github.com/mastra-ai/mastra/commit/cd9677937f113b2856dc8b9f3d4bdabcee58bb2e), [`86c0298`](https://github.com/mastra-ai/mastra/commit/86c0298e647306423c842f9d5ac827bd616bd13d)]:
10
+ - @mastra/core@1.32.0-alpha.2
11
+ - @mastra/server@1.32.0-alpha.2
12
+
3
13
  ## 1.4.12-alpha.1
4
14
 
5
15
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -920,6 +920,14 @@ var MastraServer = class extends serverAdapter.MastraServer {
920
920
  }
921
921
  }
922
922
  }
923
+ const fgaError = await serverAdapter.checkRouteFGA(this.mastra, route, c.get("requestContext"), {
924
+ ...params.urlParams,
925
+ ...params.queryParams,
926
+ ...typeof params.body === "object" ? params.body : {}
927
+ });
928
+ if (fgaError) {
929
+ return c.json({ error: fgaError.error, message: fgaError.message }, fgaError.status);
930
+ }
923
931
  try {
924
932
  const result = await route.handler(handlerParams);
925
933
  return this.sendResponse(route, c, result, prefix);
@@ -968,7 +976,9 @@ var MastraServer = class extends serverAdapter.MastraServer {
968
976
  responseType: "json",
969
977
  handler: async () => {
970
978
  },
971
- requiresAuth: route.requiresAuth
979
+ requiresAuth: route.requiresAuth,
980
+ requiresPermission: route.requiresPermission,
981
+ fga: route.fga
972
982
  };
973
983
  const routeHandler = async (c) => {
974
984
  const authError = await this.checkRouteAuth(serverRoute, {
@@ -1004,6 +1014,32 @@ var MastraServer = class extends serverAdapter.MastraServer {
1004
1014
  }
1005
1015
  }
1006
1016
  }
1017
+ let bodyParams = {};
1018
+ const contentType = c.req.header("content-type");
1019
+ if (contentType?.includes("application/json")) {
1020
+ try {
1021
+ const body = await c.req.raw.clone().json();
1022
+ if (body && typeof body === "object" && !Array.isArray(body)) {
1023
+ bodyParams = body;
1024
+ }
1025
+ } catch {
1026
+ bodyParams = {};
1027
+ }
1028
+ } else if (contentType?.includes("application/x-www-form-urlencoded") || contentType?.includes("multipart/form-data")) {
1029
+ try {
1030
+ bodyParams = Object.fromEntries(await c.req.raw.clone().formData());
1031
+ } catch {
1032
+ bodyParams = {};
1033
+ }
1034
+ }
1035
+ const fgaError = await serverAdapter.checkRouteFGA(this.mastra, serverRoute, c.get("requestContext"), {
1036
+ ...c.req.param(),
1037
+ ...Object.fromEntries(new URL(c.req.url).searchParams.entries()),
1038
+ ...bodyParams
1039
+ });
1040
+ if (fgaError) {
1041
+ return c.json({ error: fgaError.error, message: fgaError.message }, fgaError.status);
1042
+ }
1007
1043
  const reqHeaders = {};
1008
1044
  c.req.raw.headers.forEach((v, k) => {
1009
1045
  reqHeaders[k] = v;