@mastra/hono 1.4.8-alpha.4 → 1.4.8-alpha.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.js CHANGED
@@ -723,6 +723,13 @@ var MastraServer = class extends MastraServer$1 {
723
723
  }
724
724
  async sendResponse(route, response, result, prefix) {
725
725
  const resolvedPrefix = prefix ?? this.prefix ?? "";
726
+ if (result && typeof result === "object" && "__refreshHeaders" in result) {
727
+ const refreshHeaders = result.__refreshHeaders;
728
+ for (const [key, value] of Object.entries(refreshHeaders)) {
729
+ response.header(key, value);
730
+ }
731
+ delete result.__refreshHeaders;
732
+ }
726
733
  if (route.responseType === "json") {
727
734
  return response.json(result, 200);
728
735
  } else if (route.responseType === "stream") {
@@ -792,7 +799,7 @@ var MastraServer = class extends MastraServer$1 {
792
799
  `${prefix}${route.path}`,
793
800
  ...middlewares,
794
801
  async (c) => {
795
- const authError = await this.checkRouteAuth(route, {
802
+ const authResult = await this.checkRouteAuth(route, {
796
803
  path: c.req.path,
797
804
  method: c.req.method,
798
805
  getHeader: (name) => c.req.header(name),
@@ -801,8 +808,15 @@ var MastraServer = class extends MastraServer$1 {
801
808
  request: c.req.raw,
802
809
  buildAuthorizeContext: () => c
803
810
  });
804
- if (authError) {
805
- return c.json({ error: authError.error }, authError.status);
811
+ if (authResult) {
812
+ if (authResult.headers) {
813
+ for (const [key, value] of Object.entries(authResult.headers)) {
814
+ c.header(key, value);
815
+ }
816
+ }
817
+ if (authResult.error) {
818
+ return c.json({ error: authResult.error }, authResult.status);
819
+ }
806
820
  }
807
821
  const params = await this.getParams(route, c.req);
808
822
  if (params.bodyParseError) {
@@ -965,7 +979,14 @@ var MastraServer = class extends MastraServer$1 {
965
979
  buildAuthorizeContext: () => c
966
980
  });
967
981
  if (authError) {
968
- return c.json({ error: authError.error }, authError.status);
982
+ if (authError.headers) {
983
+ for (const [key, value] of Object.entries(authError.headers)) {
984
+ c.header(key, value);
985
+ }
986
+ }
987
+ if (authError.error) {
988
+ return c.json({ error: authError.error }, authError.status);
989
+ }
969
990
  }
970
991
  const authConfig = this.mastra.getServer()?.auth;
971
992
  if (authConfig) {