@mastra/auth-cloud 1.2.3 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @mastra/auth-cloud
2
2
 
3
+ ## 1.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed reading request headers from Express-style plain header objects so cookie-based auth providers no longer throw and fail with a misleading 401. ([#21261](https://github.com/mastra-ai/mastra/pull/21261))
8
+
9
+ Related to https://github.com/mastra-ai/mastra/issues/21253
10
+
11
+ ## 1.2.4-alpha.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Fixed reading request headers from Express-style plain header objects so cookie-based auth providers no longer throw and fail with a misleading 401. ([#21261](https://github.com/mastra-ai/mastra/pull/21261))
16
+
17
+ Related to https://github.com/mastra-ai/mastra/issues/21253
18
+
3
19
  ## 1.2.3
4
20
 
5
21
  ### Patch Changes
@@ -35,6 +35,17 @@ export type ActorSignal = true | {
35
35
  permissions?: MastraFGAPermissionInput[];
36
36
  /** Additional provider-specific scope for the actor (e.g. tenant, environment). */
37
37
  scope?: Record<string, string>;
38
+ /**
39
+ * Opt in to propagating this actor into the agent/tool calls the framework
40
+ * makes for declarative workflow steps (`.then(agent)` / `.then(tool)`)
41
+ * within this run's own execution tree.
42
+ *
43
+ * Never implicit, and ignored by authorization itself. Custom step
44
+ * `execute` closures are not covered — they already receive `actor` on the
45
+ * step context and must pass it explicitly. The `true` shorthand cannot
46
+ * opt in; use this object form.
47
+ */
48
+ propagate?: boolean;
38
49
  };
39
50
  /**
40
51
  * Optional context for an authorization check.
@@ -10,7 +10,7 @@
10
10
  * All known API resources.
11
11
  * Derived from SERVER_ROUTES paths in @mastra/server.
12
12
  */
13
- export declare const RESOURCES: readonly ["a2a", "agent-builder", "agent-controller", "agents", "auth", "background-tasks", "channels", "datasets", "embedders", "experiments", "infrastructure", "logs", "mcp", "memory", "observability", "processor-providers", "processors", "schedules", "scores", "stored-agents", "stored-mcp-clients", "stored-prompt-blocks", "stored-scorers", "stored-skills", "stored-workspaces", "system", "tool-providers", "tools", "vector", "vectors", "workflows", "workspaces"];
13
+ export declare const RESOURCES: readonly ["a2a", "agent-builder", "agent-controller", "agents", "auth", "background-tasks", "channels", "datasets", "embedders", "experiments", "infrastructure", "logs", "mcp", "memory", "observability", "processor-providers", "processors", "schedules", "scores", "stored-agents", "stored-mcp-clients", "stored-prompt-blocks", "stored-scorers", "stored-skills", "stored-workflows", "stored-workspaces", "system", "tool-providers", "tools", "vector", "vectors", "workflows", "workspaces"];
14
14
  /**
15
15
  * Resource type union.
16
16
  */
@@ -98,6 +98,8 @@ export declare const PERMISSION_PATTERNS: {
98
98
  readonly 'stored-scorers:*': "stored-scorers:*";
99
99
  /** Full access to stored skills */
100
100
  readonly 'stored-skills:*': "stored-skills:*";
101
+ /** Full access to stored workflows */
102
+ readonly 'stored-workflows:*': "stored-workflows:*";
101
103
  /** Full access to stored workspaces */
102
104
  readonly 'stored-workspaces:*': "stored-workspaces:*";
103
105
  /** Full access to system info */
@@ -238,6 +240,10 @@ export declare const PERMISSION_PATTERNS: {
238
240
  readonly 'stored-skills:read': "stored-skills:read";
239
241
  /** Create and modify stored skills */
240
242
  readonly 'stored-skills:write': "stored-skills:write";
243
+ /** View stored workflows */
244
+ readonly 'stored-workflows:read': "stored-workflows:read";
245
+ /** Create and modify stored workflows */
246
+ readonly 'stored-workflows:write': "stored-workflows:write";
241
247
  /** Delete stored workspaces */
242
248
  readonly 'stored-workspaces:delete': "stored-workspaces:delete";
243
249
  /** View stored workspaces */
@@ -305,7 +311,7 @@ export type PermissionPattern = keyof typeof PERMISSION_PATTERNS;
305
311
  /**
306
312
  * All valid resource:action permission combinations (excludes wildcards).
307
313
  */
308
- export declare const PERMISSIONS: readonly ["a2a:read", "a2a:write", "agent-builder:execute", "agent-builder:read", "agent-builder:write", "agent-controller:execute", "agent-controller:read", "agents:create", "agents:delete", "agents:execute", "agents:read", "agents:write", "auth:read", "background-tasks:read", "channels:read", "channels:write", "datasets:delete", "datasets:execute", "datasets:read", "datasets:write", "embedders:read", "experiments:read", "infrastructure:read", "logs:read", "mcp:execute", "mcp:read", "mcp:write", "memory:delete", "memory:execute", "memory:read", "memory:write", "observability:read", "observability:write", "processor-providers:read", "processors:execute", "processors:read", "schedules:delete", "schedules:execute", "schedules:read", "schedules:write", "scores:read", "scores:write", "stored-agents:delete", "stored-agents:publish", "stored-agents:read", "stored-agents:write", "stored-mcp-clients:delete", "stored-mcp-clients:publish", "stored-mcp-clients:read", "stored-mcp-clients:write", "stored-prompt-blocks:delete", "stored-prompt-blocks:publish", "stored-prompt-blocks:read", "stored-prompt-blocks:write", "stored-scorers:delete", "stored-scorers:publish", "stored-scorers:read", "stored-scorers:write", "stored-skills:delete", "stored-skills:publish", "stored-skills:read", "stored-skills:write", "stored-workspaces:delete", "stored-workspaces:read", "stored-workspaces:write", "system:read", "tool-providers:delete", "tool-providers:read", "tool-providers:write", "tools:execute", "tools:read", "vector:delete", "vector:execute", "vector:read", "vector:write", "vectors:read", "workflows:delete", "workflows:execute", "workflows:read", "workflows:write", "workspaces:delete", "workspaces:read", "workspaces:write"];
314
+ export declare const PERMISSIONS: readonly ["a2a:read", "a2a:write", "agent-builder:execute", "agent-builder:read", "agent-builder:write", "agent-controller:execute", "agent-controller:read", "agents:create", "agents:delete", "agents:execute", "agents:read", "agents:write", "auth:read", "background-tasks:read", "channels:read", "channels:write", "datasets:delete", "datasets:execute", "datasets:read", "datasets:write", "embedders:read", "experiments:read", "infrastructure:read", "logs:read", "mcp:execute", "mcp:read", "mcp:write", "memory:delete", "memory:execute", "memory:read", "memory:write", "observability:read", "observability:write", "processor-providers:read", "processors:execute", "processors:read", "schedules:delete", "schedules:execute", "schedules:read", "schedules:write", "scores:read", "scores:write", "stored-agents:delete", "stored-agents:publish", "stored-agents:read", "stored-agents:write", "stored-mcp-clients:delete", "stored-mcp-clients:publish", "stored-mcp-clients:read", "stored-mcp-clients:write", "stored-prompt-blocks:delete", "stored-prompt-blocks:publish", "stored-prompt-blocks:read", "stored-prompt-blocks:write", "stored-scorers:delete", "stored-scorers:publish", "stored-scorers:read", "stored-scorers:write", "stored-skills:delete", "stored-skills:publish", "stored-skills:read", "stored-skills:write", "stored-workflows:read", "stored-workflows:write", "stored-workspaces:delete", "stored-workspaces:read", "stored-workspaces:write", "system:read", "tool-providers:delete", "tool-providers:read", "tool-providers:write", "tools:execute", "tools:read", "vector:delete", "vector:execute", "vector:read", "vector:write", "vectors:read", "workflows:delete", "workflows:execute", "workflows:read", "workflows:write", "workspaces:delete", "workspaces:read", "workspaces:write"];
309
315
  /**
310
316
  * Specific permission type (e.g., 'agents:read', 'workflows:execute').
311
317
  */
@@ -441,6 +447,10 @@ export declare const MastraFGAPermissions: {
441
447
  readonly STORED_SKILLS_READ: "stored-skills:read";
442
448
  /** Create and modify stored skills */
443
449
  readonly STORED_SKILLS_WRITE: "stored-skills:write";
450
+ /** View stored workflows */
451
+ readonly STORED_WORKFLOWS_READ: "stored-workflows:read";
452
+ /** Create and modify stored workflows */
453
+ readonly STORED_WORKFLOWS_WRITE: "stored-workflows:write";
444
454
  /** Delete stored workspaces */
445
455
  readonly STORED_WORKSPACES_DELETE: "stored-workspaces:delete";
446
456
  /** View stored workspaces */
@@ -1,7 +1,7 @@
1
1
  export interface HonoRequestLike {
2
2
  raw?: Request;
3
- headers?: Headers;
4
- header(name: string): string | undefined;
3
+ headers?: Headers | Record<string, string | string[] | undefined>;
4
+ header?(name: string): string | undefined;
5
5
  }
6
6
  export type MastraAuthRequest = Request | HonoRequestLike;
7
7
  export type AuthenticateTokenFn<TUser, TResult = Promise<TUser | null>> = {
@@ -10,6 +10,10 @@ export type AuthenticateTokenFn<TUser, TResult = Promise<TUser | null>> = {
10
10
  export type AuthorizeUserFn<TUser, TResult = Promise<boolean> | boolean> = {
11
11
  bivarianceHack(user: TUser, request: MastraAuthRequest): TResult;
12
12
  }['bivarianceHack'];
13
+ /**
14
+ * Read a request header across fetch, Hono, and Express-style request shapes.
15
+ * Must not throw when `headers` is a plain object (Express `IncomingHttpHeaders`).
16
+ */
13
17
  export declare function getRequestHeader(request: MastraAuthRequest, name: string): string | null;
14
18
  export declare function getWebRequest(request: MastraAuthRequest): Request | undefined;
15
19
  export type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'ALL';
@@ -6,17 +6,11 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- import type { IUserProvider, ISSOProvider, ISessionProvider, Session, SSOCallbackResult, SSOLoginConfig } from './_types/@internal_auth/dist/index.d.ts';
9
+ import type { IUserProvider, ISSOProvider, ISessionProvider, MastraAuthRequest, Session, SSOCallbackResult, SSOLoginConfig } from './_types/@internal_auth/dist/index.d.ts';
10
10
  import type { EEUser } from './_types/@internal_auth/dist/ee/index.d.ts';
11
11
  import type { MastraAuthProviderOptions } from './_types/@internal_auth/dist/provider/index.d.ts';
12
12
  import { MastraAuthProvider } from './_types/@internal_auth/dist/provider/index.d.ts';
13
13
  import type { CloudUser } from './types.js';
14
- type HonoRequestLike = {
15
- raw?: Request;
16
- headers?: Headers;
17
- header(name: string): string | undefined;
18
- };
19
- type MastraAuthRequest = Request | HonoRequestLike;
20
14
  /**
21
15
  * Configuration options for MastraCloudAuthProvider.
22
16
  */
@@ -203,5 +197,4 @@ export declare class MastraCloudAuthProvider extends MastraAuthProvider<CloudUse
203
197
  */
204
198
  getUser(_userId: string): Promise<CloudUser | null>;
205
199
  }
206
- export {};
207
200
  //# sourceMappingURL=auth-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,cAAc,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE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AAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAIhE;;;;;OAKG;IACH,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAIxD;;;;;OAKG;IACH,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI3D;;;;OAIG;IACH,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQhD;;;;;OAKG;IACG,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAYjE;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;CAG1D"}
package/dist/index.cjs CHANGED
@@ -672,6 +672,27 @@ var MastraCloudAuth = class {
672
672
  }
673
673
  };
674
674
  //#endregion
675
+ //#region ../../packages/_internals/auth/dist/types/index.js
676
+ function headerFromPlainObject(headers, name) {
677
+ const normalizedName = name.toLowerCase();
678
+ const matchingKey = Object.keys(headers).find((key) => key.toLowerCase() === normalizedName);
679
+ const value = matchingKey === void 0 ? void 0 : headers[matchingKey];
680
+ return Array.isArray(value) ? value[0] ?? null : value ?? null;
681
+ }
682
+ /**
683
+ * Read a request header across fetch, Hono, and Express-style request shapes.
684
+ * Must not throw when `headers` is a plain object (Express `IncomingHttpHeaders`).
685
+ */
686
+ function getRequestHeader(request, name) {
687
+ if (request instanceof Request) return request.headers.get(name);
688
+ if (request.raw instanceof Request) return request.raw.headers.get(name);
689
+ const headers = request.headers;
690
+ if (headers instanceof Headers) return headers.get(name);
691
+ if (typeof request.header === "function") return request.header(name) ?? null;
692
+ if (headers && typeof headers === "object") return headerFromPlainObject(headers, name);
693
+ return null;
694
+ }
695
+ //#endregion
675
696
  //#region ../../packages/_internal-core/dist/logger/index.js
676
697
  const RegisteredLogger = {
677
698
  AGENT: "AGENT",
@@ -879,12 +900,117 @@ var MastraAuthProvider = class extends MastraBase {
879
900
  }
880
901
  };
881
902
  //#endregion
882
- //#region src/auth-provider.ts
883
- function getRequestHeader(request, name) {
884
- if (request instanceof Request) return request.headers.get(name);
885
- return request.raw?.headers.get(name) ?? request.headers?.get(name) ?? request.header(name) ?? null;
903
+ //#region ../../packages/_internals/auth/dist/ee-DXvSoTl7.js
904
+ /**
905
+ * FGA enforcement utility for checking fine-grained authorization.
906
+ *
907
+ * @license Mastra Enterprise License - see ee/LICENSE
908
+ */
909
+ /**
910
+ * Compound resource keys that expand to a set of per-family resources.
911
+ * A granted `stored:<action>` is treated as matching any `stored-<family>:<action>`
912
+ * (and `stored:*` matches any `stored-<family>:*`).
913
+ */
914
+ const RESOURCE_EXPANSIONS = { stored: [
915
+ "stored-agents",
916
+ "stored-mcp-clients",
917
+ "stored-prompt-blocks",
918
+ "stored-scorers",
919
+ "stored-skills",
920
+ "stored-workspaces"
921
+ ] };
922
+ /**
923
+ * Check if a permission matches (including wildcard support).
924
+ *
925
+ * Permission format: `{resource}:{action}[:{resource-id}]`
926
+ *
927
+ * Examples:
928
+ * - `*` matches everything
929
+ * - `agents:*` matches `agents:read`, `agents:read:my-agent`
930
+ * - `*:read` matches `agents:read`, `workflows:read` (action across all resources)
931
+ * - `agents:read` matches `agents:read`, `agents:read:my-agent`
932
+ * - `agents:read:my-agent` matches only `agents:read:my-agent`
933
+ * - `agents:*:my-agent` matches `agents:read:my-agent`, `agents:write:my-agent`
934
+ *
935
+ * @param userPermission - Permission the user has
936
+ * @param requiredPermission - Permission being checked
937
+ * @returns True if permission matches
938
+ */
939
+ function matchesPermission(userPermission, requiredPermission) {
940
+ if (userPermission === "*") return true;
941
+ const grantedParts = userPermission.split(":");
942
+ const requiredParts = requiredPermission.split(":");
943
+ const expandedFamilies = RESOURCE_EXPANSIONS[grantedParts[0] ?? ""];
944
+ if (expandedFamilies && expandedFamilies.includes(requiredParts[0] ?? "")) return matchesPermission([requiredParts[0], ...grantedParts.slice(1)].join(":"), requiredPermission);
945
+ if (grantedParts.length < 2 || requiredParts.length < 2) return userPermission === requiredPermission;
946
+ const [grantedResource, grantedAction, grantedId] = grantedParts;
947
+ const [requiredResource, requiredAction, requiredId] = requiredParts;
948
+ if (grantedResource === "*") {
949
+ if (grantedAction === "*") {
950
+ if (grantedId === void 0) return true;
951
+ return grantedId === requiredId;
952
+ }
953
+ if (grantedAction !== requiredAction) return false;
954
+ if (grantedId === void 0) return true;
955
+ return grantedId === requiredId;
956
+ }
957
+ if (grantedResource !== requiredResource) return false;
958
+ if (grantedAction === "*") {
959
+ if (grantedId === void 0) return true;
960
+ return grantedId === requiredId;
961
+ }
962
+ if (grantedAction !== requiredAction) return false;
963
+ if (grantedId === void 0) return true;
964
+ return grantedId === requiredId;
965
+ }
966
+ /**
967
+ * Resolve permissions from user roles using a role mapping.
968
+ *
969
+ * This function translates provider-defined roles (from WorkOS, Okta, etc.)
970
+ * to Mastra permissions using a configurable mapping.
971
+ *
972
+ * @example
973
+ * ```typescript
974
+ * const roleMapping = {
975
+ * "Engineering": ["agents:*", "workflows:*"],
976
+ * "Product": ["agents:read"],
977
+ * "_default": [],
978
+ * };
979
+ *
980
+ * // User has "Engineering" and "QA" roles
981
+ * const permissions = resolvePermissionsFromMapping(
982
+ * ["Engineering", "QA"],
983
+ * roleMapping
984
+ * );
985
+ * // Result: ["agents:*", "workflows:*"] (QA is unmapped, gets _default)
986
+ * ```
987
+ *
988
+ * @param roles - User's roles from the identity provider
989
+ * @param mapping - Role to permission mapping
990
+ * @returns Array of resolved permissions
991
+ */
992
+ function resolvePermissionsFromMapping(roles, mapping) {
993
+ const permissions = /* @__PURE__ */ new Set();
994
+ const defaultPerms = mapping["_default"] ?? [];
995
+ for (const role of roles) {
996
+ const rolePerms = mapping[role];
997
+ if (rolePerms) for (const perm of rolePerms) permissions.add(perm);
998
+ else for (const perm of defaultPerms) permissions.add(perm);
999
+ }
1000
+ return Array.from(permissions);
886
1001
  }
887
1002
  /**
1003
+ * @mastra/core/auth/ee
1004
+ *
1005
+ * Enterprise authentication capabilities for Mastra.
1006
+ * This code is licensed under the Mastra Enterprise License - see ee/LICENSE.
1007
+ *
1008
+ * @license Mastra Enterprise License - see ee/LICENSE
1009
+ * @packageDocumentation
1010
+ */
1011
+ //#endregion
1012
+ //#region src/auth-provider.ts
1013
+ /**
888
1014
  * Mastra Cloud authentication provider for server integration.
889
1015
  *
890
1016
  * Wraps the MastraCloudAuth client and implements the required interfaces
@@ -1185,115 +1311,6 @@ var MastraCloudAuthProvider = class extends MastraAuthProvider {
1185
1311
  }
1186
1312
  };
1187
1313
  //#endregion
1188
- //#region ../../packages/_internals/auth/dist/ee-C8o0LZ3r.js
1189
- /**
1190
- * FGA enforcement utility for checking fine-grained authorization.
1191
- *
1192
- * @license Mastra Enterprise License - see ee/LICENSE
1193
- */
1194
- /**
1195
- * Compound resource keys that expand to a set of per-family resources.
1196
- * A granted `stored:<action>` is treated as matching any `stored-<family>:<action>`
1197
- * (and `stored:*` matches any `stored-<family>:*`).
1198
- */
1199
- const RESOURCE_EXPANSIONS = { stored: [
1200
- "stored-agents",
1201
- "stored-mcp-clients",
1202
- "stored-prompt-blocks",
1203
- "stored-scorers",
1204
- "stored-skills",
1205
- "stored-workspaces"
1206
- ] };
1207
- /**
1208
- * Check if a permission matches (including wildcard support).
1209
- *
1210
- * Permission format: `{resource}:{action}[:{resource-id}]`
1211
- *
1212
- * Examples:
1213
- * - `*` matches everything
1214
- * - `agents:*` matches `agents:read`, `agents:read:my-agent`
1215
- * - `*:read` matches `agents:read`, `workflows:read` (action across all resources)
1216
- * - `agents:read` matches `agents:read`, `agents:read:my-agent`
1217
- * - `agents:read:my-agent` matches only `agents:read:my-agent`
1218
- * - `agents:*:my-agent` matches `agents:read:my-agent`, `agents:write:my-agent`
1219
- *
1220
- * @param userPermission - Permission the user has
1221
- * @param requiredPermission - Permission being checked
1222
- * @returns True if permission matches
1223
- */
1224
- function matchesPermission(userPermission, requiredPermission) {
1225
- if (userPermission === "*") return true;
1226
- const grantedParts = userPermission.split(":");
1227
- const requiredParts = requiredPermission.split(":");
1228
- const expandedFamilies = RESOURCE_EXPANSIONS[grantedParts[0] ?? ""];
1229
- if (expandedFamilies && expandedFamilies.includes(requiredParts[0] ?? "")) return matchesPermission([requiredParts[0], ...grantedParts.slice(1)].join(":"), requiredPermission);
1230
- if (grantedParts.length < 2 || requiredParts.length < 2) return userPermission === requiredPermission;
1231
- const [grantedResource, grantedAction, grantedId] = grantedParts;
1232
- const [requiredResource, requiredAction, requiredId] = requiredParts;
1233
- if (grantedResource === "*") {
1234
- if (grantedAction === "*") {
1235
- if (grantedId === void 0) return true;
1236
- return grantedId === requiredId;
1237
- }
1238
- if (grantedAction !== requiredAction) return false;
1239
- if (grantedId === void 0) return true;
1240
- return grantedId === requiredId;
1241
- }
1242
- if (grantedResource !== requiredResource) return false;
1243
- if (grantedAction === "*") {
1244
- if (grantedId === void 0) return true;
1245
- return grantedId === requiredId;
1246
- }
1247
- if (grantedAction !== requiredAction) return false;
1248
- if (grantedId === void 0) return true;
1249
- return grantedId === requiredId;
1250
- }
1251
- /**
1252
- * Resolve permissions from user roles using a role mapping.
1253
- *
1254
- * This function translates provider-defined roles (from WorkOS, Okta, etc.)
1255
- * to Mastra permissions using a configurable mapping.
1256
- *
1257
- * @example
1258
- * ```typescript
1259
- * const roleMapping = {
1260
- * "Engineering": ["agents:*", "workflows:*"],
1261
- * "Product": ["agents:read"],
1262
- * "_default": [],
1263
- * };
1264
- *
1265
- * // User has "Engineering" and "QA" roles
1266
- * const permissions = resolvePermissionsFromMapping(
1267
- * ["Engineering", "QA"],
1268
- * roleMapping
1269
- * );
1270
- * // Result: ["agents:*", "workflows:*"] (QA is unmapped, gets _default)
1271
- * ```
1272
- *
1273
- * @param roles - User's roles from the identity provider
1274
- * @param mapping - Role to permission mapping
1275
- * @returns Array of resolved permissions
1276
- */
1277
- function resolvePermissionsFromMapping(roles, mapping) {
1278
- const permissions = /* @__PURE__ */ new Set();
1279
- const defaultPerms = mapping["_default"] ?? [];
1280
- for (const role of roles) {
1281
- const rolePerms = mapping[role];
1282
- if (rolePerms) for (const perm of rolePerms) permissions.add(perm);
1283
- else for (const perm of defaultPerms) permissions.add(perm);
1284
- }
1285
- return Array.from(permissions);
1286
- }
1287
- /**
1288
- * @mastra/core/auth/ee
1289
- *
1290
- * Enterprise authentication capabilities for Mastra.
1291
- * This code is licensed under the Mastra Enterprise License - see ee/LICENSE.
1292
- *
1293
- * @license Mastra Enterprise License - see ee/LICENSE
1294
- * @packageDocumentation
1295
- */
1296
- //#endregion
1297
1314
  //#region src/rbac/rbac-provider.ts
1298
1315
  /**
1299
1316
  * RBAC provider for Mastra Cloud authentication.