@mastra/auth-okta 0.1.1 → 0.1.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,17 @@
1
1
  # @mastra/auth-okta
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Hardened several string-parsing code paths against regular-expression denial of service (ReDoS). Path normalization, URL trimming, LLM token stripping, and observation parsing now use linear-time string scanning instead of regexes that could back-track polynomially on adversarial input. No behavior changes. ([#18801](https://github.com/mastra-ai/mastra/pull/18801))
8
+
9
+ ## 0.1.2-alpha.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Hardened several string-parsing code paths against regular-expression denial of service (ReDoS). Path normalization, URL trimming, LLM token stripping, and observation parsing now use linear-time string scanning instead of regexes that could back-track polynomially on adversarial input. No behavior changes. ([#18801](https://github.com/mastra-ai/mastra/pull/18801))
14
+
3
15
  ## 0.1.1
4
16
 
5
17
  ### Patch Changes
@@ -186,6 +186,8 @@ export declare const PERMISSION_PATTERNS: {
186
186
  readonly 'processors:execute': "processors:execute";
187
187
  /** View processors */
188
188
  readonly 'processors:read': "processors:read";
189
+ /** Delete schedules */
190
+ readonly 'schedules:delete': "schedules:delete";
189
191
  /** Execute schedules */
190
192
  readonly 'schedules:execute': "schedules:execute";
191
193
  /** View schedules */
@@ -303,7 +305,7 @@ export type PermissionPattern = keyof typeof PERMISSION_PATTERNS;
303
305
  /**
304
306
  * All valid resource:action permission combinations (excludes wildcards).
305
307
  */
306
- 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: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"];
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"];
307
309
  /**
308
310
  * Specific permission type (e.g., 'agents:read', 'workflows:execute').
309
311
  */
@@ -387,6 +389,8 @@ export declare const MastraFGAPermissions: {
387
389
  readonly PROCESSORS_EXECUTE: "processors:execute";
388
390
  /** View processors */
389
391
  readonly PROCESSORS_READ: "processors:read";
392
+ /** Delete schedules */
393
+ readonly SCHEDULES_DELETE: "schedules:delete";
390
394
  /** Execute schedules */
391
395
  readonly SCHEDULES_EXECUTE: "schedules:execute";
392
396
  /** View schedules */
@@ -14,7 +14,44 @@ export interface MastraAuthProviderOptions<TUser = unknown> {
14
14
  */
15
15
  public?: MastraAuthConfig['public'];
16
16
  }
17
- export declare abstract class MastraAuthProvider<TUser = unknown> extends MastraBase {
17
+ /**
18
+ * Structural description of the public surface of a `MastraAuthProvider`.
19
+ *
20
+ * Auth provider packages bundle their own copy of the `MastraAuthProvider`
21
+ * declaration, so provider class types cannot be compared nominally across
22
+ * package boundaries — `#private`/`protected` members would make otherwise
23
+ * identical copies mutually unassignable. Positions that accept user-supplied
24
+ * providers (e.g. `server.auth`, `CompositeAuth`) accept this interface
25
+ * instead of the class.
26
+ *
27
+ * Note: methods intentionally use method syntax (not property syntax) so they
28
+ * are checked bivariantly — providers with a narrower `TUser` must remain
29
+ * assignable to `IMastraAuthProvider<unknown>`.
30
+ */
31
+ export interface IMastraAuthProvider<TUser = unknown> {
32
+ name?: string;
33
+ /**
34
+ * Protected paths for the auth provider
35
+ */
36
+ protected?: MastraAuthConfig['protected'];
37
+ /**
38
+ * Public paths for the auth provider
39
+ */
40
+ public?: MastraAuthConfig['public'];
41
+ /**
42
+ * Authenticate a token and return the payload
43
+ */
44
+ authenticateToken(token: string, request: MastraAuthRequest): Promise<TUser | null>;
45
+ /**
46
+ * Authorize a user for a path and method
47
+ */
48
+ authorizeUser(user: TUser, request: MastraAuthRequest): Promise<boolean> | boolean;
49
+ /**
50
+ * Map an authenticated user to a memory resource id
51
+ */
52
+ mapUserToResourceId?(user: TUser): string | undefined | null;
53
+ }
54
+ export declare abstract class MastraAuthProvider<TUser = unknown> extends MastraBase implements IMastraAuthProvider<TUser> {
18
55
  protected?: MastraAuthConfig['protected'];
19
56
  public?: MastraAuthConfig['public'];
20
57
  mapUserToResourceId?(user: TUser): string | undefined | null;
@@ -39,7 +76,7 @@ export declare class CompositeAuth extends MastraAuthProvider implements ISSOPro
39
76
  private providers;
40
77
  private authenticatedProviderByObject;
41
78
  private authenticatedProviderByPrimitive;
42
- constructor(providers: MastraAuthProvider[]);
79
+ constructor(providers: IMastraAuthProvider[]);
43
80
  private findProvider;
44
81
  private rememberAuthenticatedProvider;
45
82
  private takeAuthenticatedProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../src/auth-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEF,KAAK,iBAAiB,GAAG,OAAO,GAAG,eAAe,CAAC;AAUnD,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA0ElE;;;;;;;;;;;;;;;;G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AIjD,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAIjE,uBAAuB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAIzD,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAI5D,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMhD;;OAEG;IACH,OAAO,CAAC,WAAW;IASnB;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
package/dist/index.cjs CHANGED
@@ -8,7 +8,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
8
 
9
9
  var pkg__default = /*#__PURE__*/_interopDefault(pkg);
10
10
 
11
- // ../../packages/_internals/auth/dist/chunk-7SVOHBXQ.js
11
+ // ../../packages/_internals/auth/dist/chunk-H3EJ4GVJ.js
12
12
  var RESOURCE_EXPANSIONS = {
13
13
  stored: [
14
14
  "stored-agents",
@@ -393,7 +393,7 @@ var MastraBase = class {
393
393
  }
394
394
  };
395
395
 
396
- // ../../packages/_internals/auth/dist/chunk-XG6GH2VJ.js
396
+ // ../../packages/_internals/auth/dist/chunk-7GLKLOU3.js
397
397
  var MastraAuthProvider = class extends MastraBase {
398
398
  protected;
399
399
  public;
@@ -440,6 +440,11 @@ function mapOktaClaimsToUser(payload) {
440
440
  }
441
441
 
442
442
  // src/auth-provider.ts
443
+ function trimTrailingSlashes(value) {
444
+ let end = value.length;
445
+ while (end > 0 && value[end - 1] === "/") end--;
446
+ return value.slice(0, end);
447
+ }
443
448
  function getRequestHeader2(request, name) {
444
449
  if (request instanceof Request) {
445
450
  return request.headers.get(name);
@@ -533,7 +538,7 @@ var MastraAuthOkta = class extends MastraAuthProvider {
533
538
  this.domain = domain;
534
539
  this.clientId = clientId;
535
540
  this.clientSecret = clientSecret;
536
- this.issuer = (issuer ?? `https://${domain}/oauth2/default`).replace(/\/+$/, "");
541
+ this.issuer = trimTrailingSlashes(issuer ?? `https://${domain}/oauth2/default`);
537
542
  this.endpointBase = this.issuer.includes("/oauth2/") || this.issuer.endsWith("/oauth2") ? this.issuer : `${this.issuer}/oauth2`;
538
543
  this.redirectUri = redirectUri;
539
544
  this.scopes = options?.scopes ?? DEFAULT_SCOPES;