@mastra/deployer 0.10.2-alpha.3 → 0.10.2-alpha.5
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/_tsup-dts-rollup.d.cts +2 -0
- package/dist/_tsup-dts-rollup.d.ts +2 -0
- package/dist/server/index.cjs +29 -14
- package/dist/server/index.js +29 -14
- package/package.json +3 -3
|
@@ -589,6 +589,8 @@ export declare const html = "\n<!doctype html>\n<html lang=\"en\">\n <head>\n
|
|
|
589
589
|
|
|
590
590
|
export declare function isNodeBuiltin(dep: string): boolean;
|
|
591
591
|
|
|
592
|
+
export declare const isProtectedPath: (path: string, method: string, authConfig: MastraAuthConfig) => boolean;
|
|
593
|
+
|
|
592
594
|
/**
|
|
593
595
|
* Convert speech to text using the agent's voice provider
|
|
594
596
|
*/
|
|
@@ -589,6 +589,8 @@ export declare const html = "\n<!doctype html>\n<html lang=\"en\">\n <head>\n
|
|
|
589
589
|
|
|
590
590
|
export declare function isNodeBuiltin(dep: string): boolean;
|
|
591
591
|
|
|
592
|
+
export declare const isProtectedPath: (path: string, method: string, authConfig: MastraAuthConfig) => boolean;
|
|
593
|
+
|
|
592
594
|
/**
|
|
593
595
|
* Convert speech to text using the agent's voice provider
|
|
594
596
|
*/
|
package/dist/server/index.cjs
CHANGED
|
@@ -1046,17 +1046,7 @@ async function setAgentInstructionsHandler(c2) {
|
|
|
1046
1046
|
|
|
1047
1047
|
// src/server/handlers/auth/defaults.ts
|
|
1048
1048
|
var defaultAuthConfig = {
|
|
1049
|
-
|
|
1050
|
-
"/",
|
|
1051
|
-
"/refresh-events",
|
|
1052
|
-
"/__refresh",
|
|
1053
|
-
"/assets/*",
|
|
1054
|
-
"/auth/*",
|
|
1055
|
-
"/openapi.json",
|
|
1056
|
-
"/swagger-ui",
|
|
1057
|
-
["/api/agents", "GET"],
|
|
1058
|
-
["/a2a/*", ["GET"]]
|
|
1059
|
-
],
|
|
1049
|
+
protected: ["/api/*"],
|
|
1060
1050
|
// Simple rule system
|
|
1061
1051
|
rules: [
|
|
1062
1052
|
// Admin users can do anything
|
|
@@ -1078,9 +1068,19 @@ var defaultAuthConfig = {
|
|
|
1078
1068
|
};
|
|
1079
1069
|
|
|
1080
1070
|
// src/server/handlers/auth/helpers.ts
|
|
1071
|
+
var isProtectedPath = (path, method, authConfig) => {
|
|
1072
|
+
const protectedAccess = [...defaultAuthConfig.protected || [], ...authConfig.protected || []];
|
|
1073
|
+
return isAnyMatch(path, method, protectedAccess);
|
|
1074
|
+
};
|
|
1081
1075
|
var canAccessPublicly = (path, method, authConfig) => {
|
|
1082
1076
|
const publicAccess = [...defaultAuthConfig.public || [], ...authConfig.public || []];
|
|
1083
|
-
|
|
1077
|
+
return isAnyMatch(path, method, publicAccess);
|
|
1078
|
+
};
|
|
1079
|
+
var isAnyMatch = (path, method, patterns) => {
|
|
1080
|
+
if (!patterns) {
|
|
1081
|
+
return false;
|
|
1082
|
+
}
|
|
1083
|
+
for (const patternPathOrMethod of patterns) {
|
|
1084
1084
|
if (patternPathOrMethod instanceof RegExp) {
|
|
1085
1085
|
if (patternPathOrMethod.test(path)) {
|
|
1086
1086
|
return true;
|
|
@@ -1157,6 +1157,9 @@ var authenticationMiddleware = async (c2, next) => {
|
|
|
1157
1157
|
if (!authConfig) {
|
|
1158
1158
|
return next();
|
|
1159
1159
|
}
|
|
1160
|
+
if (!isProtectedPath(c2.req.path, c2.req.method, authConfig)) {
|
|
1161
|
+
return next();
|
|
1162
|
+
}
|
|
1160
1163
|
if (canAccessPublicly(c2.req.path, c2.req.method, authConfig)) {
|
|
1161
1164
|
return next();
|
|
1162
1165
|
}
|
|
@@ -1197,7 +1200,19 @@ var authorizationMiddleware = async (c2, next) => {
|
|
|
1197
1200
|
return next();
|
|
1198
1201
|
}
|
|
1199
1202
|
const user = c2.get("runtimeContext").get("user");
|
|
1200
|
-
if (typeof authConfig.
|
|
1203
|
+
if ("authorizeUser" in authConfig && typeof authConfig.authorizeUser === "function") {
|
|
1204
|
+
try {
|
|
1205
|
+
const isAuthorized = await authConfig.authorizeUser(user, c2.req);
|
|
1206
|
+
if (isAuthorized) {
|
|
1207
|
+
return next();
|
|
1208
|
+
}
|
|
1209
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1210
|
+
} catch (err) {
|
|
1211
|
+
console.error(err);
|
|
1212
|
+
return c2.json({ error: "Authorization error" }, 500);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
if ("authorize" in authConfig && typeof authConfig.authorize === "function") {
|
|
1201
1216
|
try {
|
|
1202
1217
|
const isAuthorized = await authConfig.authorize(path, method, user, c2);
|
|
1203
1218
|
if (isAuthorized) {
|
|
@@ -1209,7 +1224,7 @@ var authorizationMiddleware = async (c2, next) => {
|
|
|
1209
1224
|
return c2.json({ error: "Authorization error" }, 500);
|
|
1210
1225
|
}
|
|
1211
1226
|
}
|
|
1212
|
-
if (authConfig.rules && authConfig.rules.length > 0) {
|
|
1227
|
+
if ("rules" in authConfig && authConfig.rules && authConfig.rules.length > 0) {
|
|
1213
1228
|
const isAuthorized = await checkRules(authConfig.rules, path, method, user);
|
|
1214
1229
|
if (isAuthorized) {
|
|
1215
1230
|
return next();
|
package/dist/server/index.js
CHANGED
|
@@ -1040,17 +1040,7 @@ async function setAgentInstructionsHandler(c2) {
|
|
|
1040
1040
|
|
|
1041
1041
|
// src/server/handlers/auth/defaults.ts
|
|
1042
1042
|
var defaultAuthConfig = {
|
|
1043
|
-
|
|
1044
|
-
"/",
|
|
1045
|
-
"/refresh-events",
|
|
1046
|
-
"/__refresh",
|
|
1047
|
-
"/assets/*",
|
|
1048
|
-
"/auth/*",
|
|
1049
|
-
"/openapi.json",
|
|
1050
|
-
"/swagger-ui",
|
|
1051
|
-
["/api/agents", "GET"],
|
|
1052
|
-
["/a2a/*", ["GET"]]
|
|
1053
|
-
],
|
|
1043
|
+
protected: ["/api/*"],
|
|
1054
1044
|
// Simple rule system
|
|
1055
1045
|
rules: [
|
|
1056
1046
|
// Admin users can do anything
|
|
@@ -1072,9 +1062,19 @@ var defaultAuthConfig = {
|
|
|
1072
1062
|
};
|
|
1073
1063
|
|
|
1074
1064
|
// src/server/handlers/auth/helpers.ts
|
|
1065
|
+
var isProtectedPath = (path, method, authConfig) => {
|
|
1066
|
+
const protectedAccess = [...defaultAuthConfig.protected || [], ...authConfig.protected || []];
|
|
1067
|
+
return isAnyMatch(path, method, protectedAccess);
|
|
1068
|
+
};
|
|
1075
1069
|
var canAccessPublicly = (path, method, authConfig) => {
|
|
1076
1070
|
const publicAccess = [...defaultAuthConfig.public || [], ...authConfig.public || []];
|
|
1077
|
-
|
|
1071
|
+
return isAnyMatch(path, method, publicAccess);
|
|
1072
|
+
};
|
|
1073
|
+
var isAnyMatch = (path, method, patterns) => {
|
|
1074
|
+
if (!patterns) {
|
|
1075
|
+
return false;
|
|
1076
|
+
}
|
|
1077
|
+
for (const patternPathOrMethod of patterns) {
|
|
1078
1078
|
if (patternPathOrMethod instanceof RegExp) {
|
|
1079
1079
|
if (patternPathOrMethod.test(path)) {
|
|
1080
1080
|
return true;
|
|
@@ -1151,6 +1151,9 @@ var authenticationMiddleware = async (c2, next) => {
|
|
|
1151
1151
|
if (!authConfig) {
|
|
1152
1152
|
return next();
|
|
1153
1153
|
}
|
|
1154
|
+
if (!isProtectedPath(c2.req.path, c2.req.method, authConfig)) {
|
|
1155
|
+
return next();
|
|
1156
|
+
}
|
|
1154
1157
|
if (canAccessPublicly(c2.req.path, c2.req.method, authConfig)) {
|
|
1155
1158
|
return next();
|
|
1156
1159
|
}
|
|
@@ -1191,7 +1194,19 @@ var authorizationMiddleware = async (c2, next) => {
|
|
|
1191
1194
|
return next();
|
|
1192
1195
|
}
|
|
1193
1196
|
const user = c2.get("runtimeContext").get("user");
|
|
1194
|
-
if (typeof authConfig.
|
|
1197
|
+
if ("authorizeUser" in authConfig && typeof authConfig.authorizeUser === "function") {
|
|
1198
|
+
try {
|
|
1199
|
+
const isAuthorized = await authConfig.authorizeUser(user, c2.req);
|
|
1200
|
+
if (isAuthorized) {
|
|
1201
|
+
return next();
|
|
1202
|
+
}
|
|
1203
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1204
|
+
} catch (err) {
|
|
1205
|
+
console.error(err);
|
|
1206
|
+
return c2.json({ error: "Authorization error" }, 500);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
if ("authorize" in authConfig && typeof authConfig.authorize === "function") {
|
|
1195
1210
|
try {
|
|
1196
1211
|
const isAuthorized = await authConfig.authorize(path, method, user, c2);
|
|
1197
1212
|
if (isAuthorized) {
|
|
@@ -1203,7 +1218,7 @@ var authorizationMiddleware = async (c2, next) => {
|
|
|
1203
1218
|
return c2.json({ error: "Authorization error" }, 500);
|
|
1204
1219
|
}
|
|
1205
1220
|
}
|
|
1206
|
-
if (authConfig.rules && authConfig.rules.length > 0) {
|
|
1221
|
+
if ("rules" in authConfig && authConfig.rules && authConfig.rules.length > 0) {
|
|
1207
1222
|
const isAuthorized = await checkRules(authConfig.rules, path, method, user);
|
|
1208
1223
|
if (isAuthorized) {
|
|
1209
1224
|
return next();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer",
|
|
3
|
-
"version": "0.10.2-alpha.
|
|
3
|
+
"version": "0.10.2-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"rollup-plugin-node-externals": "^8.0.0",
|
|
109
109
|
"typescript-paths": "^1.5.1",
|
|
110
110
|
"zod": "^3.24.3",
|
|
111
|
-
"@mastra/server": "^0.10.2-alpha.
|
|
111
|
+
"@mastra/server": "^0.10.2-alpha.5"
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@hono/node-server": "^1.13.8",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"typescript": "^5.8.2",
|
|
129
129
|
"vitest": "^2.1.9",
|
|
130
130
|
"@internal/lint": "0.0.7",
|
|
131
|
-
"@mastra/core": "0.10.2-alpha.
|
|
131
|
+
"@mastra/core": "0.10.2-alpha.5",
|
|
132
132
|
"@mastra/mcp": "^0.10.2-alpha.1"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|