@mastra/auth-workos 1.6.7-alpha.0 → 1.6.8-alpha.0

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.
@@ -1,6 +1,5 @@
1
- import { i as IMastraLogger, u as RegisteredLogger } from "../index-Biaf3BmX.js";
2
- //#region src/base/MastraBase.d.ts
3
- declare class MastraBase {
1
+ import { i as IMastraLogger, u as RegisteredLogger } from "../index-TNVgGNjs.js";
2
+ export declare class MastraBase {
4
3
  #private;
5
4
  component: RegisteredLogger;
6
5
  protected logger: IMastraLogger;
@@ -26,6 +25,4 @@ declare class MastraBase {
26
25
  */
27
26
  __setLogger(logger: IMastraLogger): void;
28
27
  }
29
- //#endregion
30
- export { MastraBase };
31
28
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { Transform } from "stream";
2
- //#region src/logger/adapter.d.ts
3
2
  /**
4
3
  * OpenTelemetry-compatible trace correlation fields, injected at the top
5
4
  * level of a logger's native record.
@@ -91,8 +90,6 @@ declare function exportTrackedException(ctx: LoggerAdapterContext | undefined, e
91
90
  * so the derived record preserves all context from the native call.
92
91
  */
93
92
  declare function buildLogRecordData(args: unknown[]): Record<string, unknown> | undefined;
94
- //#endregion
95
- //#region src/logger/index.d.ts
96
93
  declare const RegisteredLogger: {
97
94
  readonly AGENT: 'AGENT';
98
95
  readonly OBSERVABILITY: 'OBSERVABILITY';
@@ -314,6 +311,5 @@ declare class ConsoleLogger extends MastraLogger {
314
311
  hasMore: boolean;
315
312
  }>;
316
313
  }
317
- //#endregion
318
314
  export { buildLogRecordData as _, LogFilter as a, LoggerTransport as c, createCustomTransport as d, AdaptableLogger as f, TraceFields as g, LoggerAdapterOptions as h, IMastraLogger as i, MastraLogger as l, LoggerAdapterContext as m, ConsoleLogger as n, LogFilterContext as o, AdapterLogSink as p, ConsoleLoggerOptions as r, LogLevel as s, BaseLogMessage as t, RegisteredLogger as u, exportTrackedException as v, isAdaptableLogger as y };
319
- //# sourceMappingURL=index-Biaf3BmX.d.ts.map
315
+ //# sourceMappingURL=index-TNVgGNjs.d.ts.map
@@ -24,6 +24,15 @@ export interface ISessionProvider<TSession extends Session = Session> {
24
24
  getSessionIdFromRequest(request: Request): string | null;
25
25
  getSessionHeaders(session: TSession): Record<string, string>;
26
26
  getClearSessionHeaders(): Record<string, string>;
27
+ /**
28
+ * Optional: `Set-Cookie` values expiring legacy copies of the session cookie
29
+ * (for example one an earlier release scoped to a shared parent `Domain`).
30
+ * A browser only deletes a cookie whose exact `(name, Domain, Path)` match,
31
+ * so servers append these to every response that sets or clears the session
32
+ * cookie; otherwise a stale shared-domain copy keeps being sent to every
33
+ * sibling host until it expires.
34
+ */
35
+ getLegacySessionClearCookies?(): string[];
27
36
  }
28
37
  export { MemorySessionProvider, type MemorySessionProviderOptions } from './memory.js';
29
38
  export { CookieSessionProvider, type CookieSessionProviderOptions } from './cookie.js';
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@ let _mastra_auth = require("@mastra/auth");
3
3
  let _workos_authkit_session = require("@workos/authkit-session");
4
4
  let _workos_inc_node = require("@workos-inc/node");
5
5
  let lru_cache = require("lru-cache");
6
- //#region ../../packages/_internal-core/dist/logger/index.js
6
+ // ../../packages/_internal-core/dist/logger/index.js
7
7
  /**
8
8
  * Export a tracked exception through the adapter sink, mirroring the
9
9
  * DualLogger dual-write shape (`errorId`/`domain`/`category`/`details`/`cause`
@@ -236,8 +236,7 @@ var ConsoleLogger = class ConsoleLogger extends MastraLogger {
236
236
  };
237
237
  }
238
238
  };
239
- //#endregion
240
- //#region ../../packages/_internal-core/dist/base/index.js
239
+ // ../../packages/_internal-core/dist/base/index.js
241
240
  var MastraBase = class {
242
241
  component = RegisteredLogger.LLM;
243
242
  logger;
@@ -271,8 +270,7 @@ var MastraBase = class {
271
270
  this.logger = "child" in logger && typeof logger.child === "function" ? logger.child({ component: this.component }) : logger;
272
271
  }
273
272
  };
274
- //#endregion
275
- //#region ../../packages/_internals/auth/dist/provider/index.js
273
+ // ../../packages/_internals/auth/dist/provider/index.js
276
274
  var MastraAuthProvider = class extends MastraBase {
277
275
  protected;
278
276
  public;
@@ -284,7 +282,7 @@ var MastraAuthProvider = class extends MastraBase {
284
282
  if (options?.authorizeUser) this.authorizeUser = options.authorizeUser.bind(this);
285
283
  this.protected = options?.protected;
286
284
  this.public = options?.public;
287
- this.mapUserToResourceId = options?.mapUserToResourceId;
285
+ if (options?.mapUserToResourceId) this.mapUserToResourceId = options.mapUserToResourceId;
288
286
  }
289
287
  registerOptions(opts) {
290
288
  if (opts?.authorizeUser) this.authorizeUser = opts.authorizeUser.bind(this);
@@ -293,8 +291,7 @@ var MastraAuthProvider = class extends MastraBase {
293
291
  if (opts?.public) this.public = opts.public;
294
292
  }
295
293
  };
296
- //#endregion
297
- //#region src/session-storage.ts
294
+ // src/session-storage.ts
298
295
  /**
299
296
  * Hono/Web Request session storage adapter for WorkOS AuthKit.
300
297
  *
@@ -328,8 +325,7 @@ var WebSessionStorage = class extends _workos_authkit_session.CookieSessionStora
328
325
  }, {})[name] ?? null;
329
326
  }
330
327
  };
331
- //#endregion
332
- //#region src/types.ts
328
+ // src/types.ts
333
329
  /**
334
330
  * Maps a WorkOS User to EEUser format.
335
331
  */
@@ -346,8 +342,7 @@ function mapWorkOSUserToEEUser(user) {
346
342
  }
347
343
  };
348
344
  }
349
- //#endregion
350
- //#region src/auth-provider.ts
345
+ // src/auth-provider.ts
351
346
  function getWebRequest(request) {
352
347
  if (request instanceof Request) return request;
353
348
  return request.raw instanceof Request ? request.raw : void 0;
@@ -357,7 +352,7 @@ function getWebRequest(request) {
357
352
  * Generated once per process to ensure consistency during dev.
358
353
  */
359
354
  const DEV_COOKIE_PASSWORD = crypto.randomUUID() + crypto.randomUUID();
360
- const MEMBERSHIP_CACHE_TTL_MS = 60 * 1e3;
355
+ const MEMBERSHIP_CACHE_TTL_MS = 6e4;
361
356
  const MEMBERSHIP_CACHE_MAX_SIZE = 1e3;
362
357
  /** Pull a stable error code out of a WorkOS SDK error, if present. */
363
358
  function workosErrorCode(error) {
@@ -438,7 +433,7 @@ var MastraAuthWorkos = class extends MastraAuthProvider {
438
433
  redirectUri,
439
434
  cookiePassword,
440
435
  cookieName: options?.session?.cookieName ?? "wos_session",
441
- cookieMaxAge: options?.session?.maxAge ?? 3600 * 24 * 400,
436
+ cookieMaxAge: options?.session?.maxAge ?? 3456e4,
442
437
  cookieSameSite: options?.session?.sameSite?.toLowerCase(),
443
438
  cookieDomain: void 0,
444
439
  apiHttps: true
@@ -473,7 +468,8 @@ var MastraAuthWorkos = class extends MastraAuthProvider {
473
468
  };
474
469
  }
475
470
  if (token) {
476
- const payload = await (0, _mastra_auth.verifyJwks)(token, this.workos.userManagement.getJwksUrl(this.clientId));
471
+ const jwksUri = this.workos.userManagement.getJwksUrl(this.clientId);
472
+ const payload = await (0, _mastra_auth.verifyJwks)(token, jwksUri);
477
473
  const jwtUser = this.resolveJwtPayloadUser(payload);
478
474
  if (this.trustJwtClaims && jwtUser?.id && jwtUser?.workosId) return await this.attachMembershipsIfNeeded(jwtUser);
479
475
  if (payload?.sub) try {
@@ -939,8 +935,7 @@ var MastraAuthWorkos = class extends MastraAuthProvider {
939
935
  return this.redirectUri;
940
936
  }
941
937
  };
942
- //#endregion
943
- //#region ../../packages/_internals/auth/dist/ee-btY6vXIW.js
938
+ // ../../packages/_internals/auth/dist/ee-CnZdF0Vm.js
944
939
  /**
945
940
  * FGA enforcement utility for checking fine-grained authorization.
946
941
  *
@@ -1068,8 +1063,7 @@ function resolvePermissionsFromMapping(roles, mapping) {
1068
1063
  * @license Mastra Enterprise License - see ee/LICENSE
1069
1064
  * @packageDocumentation
1070
1065
  */
1071
- //#endregion
1072
- //#region src/rbac-provider.ts
1066
+ // src/rbac-provider.ts
1073
1067
  /**
1074
1068
  * WorkOS RBAC provider that maps organization roles to Mastra permissions.
1075
1069
  *
@@ -1106,7 +1100,7 @@ function resolvePermissionsFromMapping(roles, mapping) {
1106
1100
  * ```
1107
1101
  */
1108
1102
  /** Default cache TTL in milliseconds (60 seconds) */
1109
- const DEFAULT_CACHE_TTL_MS = 60 * 1e3;
1103
+ const DEFAULT_CACHE_TTL_MS = 6e4;
1110
1104
  /** Default max cache size (number of users) */
1111
1105
  const DEFAULT_CACHE_MAX_SIZE = 1e3;
1112
1106
  var MastraRBACWorkos = class {
@@ -1299,8 +1293,7 @@ var MastraRBACWorkos = class {
1299
1293
  return (this.options.organizationId ? user.memberships.filter((m) => m.organizationId === this.options.organizationId) : user.memberships).map((m) => m.role.slug);
1300
1294
  }
1301
1295
  };
1302
- //#endregion
1303
- //#region src/fga-provider.ts
1296
+ // src/fga-provider.ts
1304
1297
  /**
1305
1298
  * WorkOS FGA provider for Mastra.
1306
1299
  *
@@ -1736,8 +1729,7 @@ var MastraFGAWorkos = class {
1736
1729
  };
1737
1730
  }
1738
1731
  };
1739
- //#endregion
1740
- //#region src/directory-sync.ts
1732
+ // src/directory-sync.ts
1741
1733
  /**
1742
1734
  * WorkOSDirectorySync handles SCIM webhook events from WorkOS for automated
1743
1735
  * user provisioning and deprovisioning.
@@ -1946,8 +1938,7 @@ var WorkOSDirectorySync = class {
1946
1938
  return (await this.workos.directorySync.listGroups({ directory: directoryId })).data;
1947
1939
  }
1948
1940
  };
1949
- //#endregion
1950
- //#region src/admin-portal.ts
1941
+ // src/admin-portal.ts
1951
1942
  /**
1952
1943
  * WorkOS Admin Portal integration for customer self-service configuration.
1953
1944
  *
@@ -2040,7 +2031,6 @@ var WorkOSAdminPortal = class {
2040
2031
  })).link;
2041
2032
  }
2042
2033
  };
2043
- //#endregion
2044
2034
  exports.MastraAuthWorkos = MastraAuthWorkos;
2045
2035
  exports.MastraFGAWorkos = MastraFGAWorkos;
2046
2036
  exports.MastraRBACWorkos = MastraRBACWorkos;