@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.
- package/dist/_types/@internal_auth/dist/_types/@internal_core/dist/base/index.d.ts +2 -5
- package/dist/_types/@internal_auth/dist/_types/@internal_core/dist/{index-Biaf3BmX.d.ts → index-TNVgGNjs.d.ts} +1 -5
- package/dist/_types/@internal_auth/dist/session/index.d.ts +9 -0
- package/dist/index.cjs +17 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -27
- package/dist/index.js.map +1 -1
- package/dist/session-storage.d.ts.map +1 -1
- package/package.json +13 -14
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { verifyJwks } from "@mastra/auth";
|
|
|
2
2
|
import { AuthService, CookieSessionStorage, sessionEncryption } from "@workos/authkit-session";
|
|
3
3
|
import { GeneratePortalLinkIntent, WorkOS } from "@workos-inc/node";
|
|
4
4
|
import { LRUCache } from "lru-cache";
|
|
5
|
-
|
|
5
|
+
// ../../packages/_internal-core/dist/logger/index.js
|
|
6
6
|
/**
|
|
7
7
|
* Export a tracked exception through the adapter sink, mirroring the
|
|
8
8
|
* DualLogger dual-write shape (`errorId`/`domain`/`category`/`details`/`cause`
|
|
@@ -235,8 +235,7 @@ var ConsoleLogger = class ConsoleLogger extends MastraLogger {
|
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
|
-
|
|
239
|
-
//#region ../../packages/_internal-core/dist/base/index.js
|
|
238
|
+
// ../../packages/_internal-core/dist/base/index.js
|
|
240
239
|
var MastraBase = class {
|
|
241
240
|
component = RegisteredLogger.LLM;
|
|
242
241
|
logger;
|
|
@@ -270,8 +269,7 @@ var MastraBase = class {
|
|
|
270
269
|
this.logger = "child" in logger && typeof logger.child === "function" ? logger.child({ component: this.component }) : logger;
|
|
271
270
|
}
|
|
272
271
|
};
|
|
273
|
-
|
|
274
|
-
//#region ../../packages/_internals/auth/dist/provider/index.js
|
|
272
|
+
// ../../packages/_internals/auth/dist/provider/index.js
|
|
275
273
|
var MastraAuthProvider = class extends MastraBase {
|
|
276
274
|
protected;
|
|
277
275
|
public;
|
|
@@ -283,7 +281,7 @@ var MastraAuthProvider = class extends MastraBase {
|
|
|
283
281
|
if (options?.authorizeUser) this.authorizeUser = options.authorizeUser.bind(this);
|
|
284
282
|
this.protected = options?.protected;
|
|
285
283
|
this.public = options?.public;
|
|
286
|
-
this.mapUserToResourceId = options
|
|
284
|
+
if (options?.mapUserToResourceId) this.mapUserToResourceId = options.mapUserToResourceId;
|
|
287
285
|
}
|
|
288
286
|
registerOptions(opts) {
|
|
289
287
|
if (opts?.authorizeUser) this.authorizeUser = opts.authorizeUser.bind(this);
|
|
@@ -292,8 +290,7 @@ var MastraAuthProvider = class extends MastraBase {
|
|
|
292
290
|
if (opts?.public) this.public = opts.public;
|
|
293
291
|
}
|
|
294
292
|
};
|
|
295
|
-
|
|
296
|
-
//#region src/session-storage.ts
|
|
293
|
+
// src/session-storage.ts
|
|
297
294
|
/**
|
|
298
295
|
* Hono/Web Request session storage adapter for WorkOS AuthKit.
|
|
299
296
|
*
|
|
@@ -327,8 +324,7 @@ var WebSessionStorage = class extends CookieSessionStorage {
|
|
|
327
324
|
}, {})[name] ?? null;
|
|
328
325
|
}
|
|
329
326
|
};
|
|
330
|
-
|
|
331
|
-
//#region src/types.ts
|
|
327
|
+
// src/types.ts
|
|
332
328
|
/**
|
|
333
329
|
* Maps a WorkOS User to EEUser format.
|
|
334
330
|
*/
|
|
@@ -345,8 +341,7 @@ function mapWorkOSUserToEEUser(user) {
|
|
|
345
341
|
}
|
|
346
342
|
};
|
|
347
343
|
}
|
|
348
|
-
|
|
349
|
-
//#region src/auth-provider.ts
|
|
344
|
+
// src/auth-provider.ts
|
|
350
345
|
function getWebRequest(request) {
|
|
351
346
|
if (request instanceof Request) return request;
|
|
352
347
|
return request.raw instanceof Request ? request.raw : void 0;
|
|
@@ -356,7 +351,7 @@ function getWebRequest(request) {
|
|
|
356
351
|
* Generated once per process to ensure consistency during dev.
|
|
357
352
|
*/
|
|
358
353
|
const DEV_COOKIE_PASSWORD = crypto.randomUUID() + crypto.randomUUID();
|
|
359
|
-
const MEMBERSHIP_CACHE_TTL_MS =
|
|
354
|
+
const MEMBERSHIP_CACHE_TTL_MS = 6e4;
|
|
360
355
|
const MEMBERSHIP_CACHE_MAX_SIZE = 1e3;
|
|
361
356
|
/** Pull a stable error code out of a WorkOS SDK error, if present. */
|
|
362
357
|
function workosErrorCode(error) {
|
|
@@ -437,7 +432,7 @@ var MastraAuthWorkos = class extends MastraAuthProvider {
|
|
|
437
432
|
redirectUri,
|
|
438
433
|
cookiePassword,
|
|
439
434
|
cookieName: options?.session?.cookieName ?? "wos_session",
|
|
440
|
-
cookieMaxAge: options?.session?.maxAge ??
|
|
435
|
+
cookieMaxAge: options?.session?.maxAge ?? 3456e4,
|
|
441
436
|
cookieSameSite: options?.session?.sameSite?.toLowerCase(),
|
|
442
437
|
cookieDomain: void 0,
|
|
443
438
|
apiHttps: true
|
|
@@ -472,7 +467,8 @@ var MastraAuthWorkos = class extends MastraAuthProvider {
|
|
|
472
467
|
};
|
|
473
468
|
}
|
|
474
469
|
if (token) {
|
|
475
|
-
const
|
|
470
|
+
const jwksUri = this.workos.userManagement.getJwksUrl(this.clientId);
|
|
471
|
+
const payload = await verifyJwks(token, jwksUri);
|
|
476
472
|
const jwtUser = this.resolveJwtPayloadUser(payload);
|
|
477
473
|
if (this.trustJwtClaims && jwtUser?.id && jwtUser?.workosId) return await this.attachMembershipsIfNeeded(jwtUser);
|
|
478
474
|
if (payload?.sub) try {
|
|
@@ -938,8 +934,7 @@ var MastraAuthWorkos = class extends MastraAuthProvider {
|
|
|
938
934
|
return this.redirectUri;
|
|
939
935
|
}
|
|
940
936
|
};
|
|
941
|
-
|
|
942
|
-
//#region ../../packages/_internals/auth/dist/ee-btY6vXIW.js
|
|
937
|
+
// ../../packages/_internals/auth/dist/ee-CnZdF0Vm.js
|
|
943
938
|
/**
|
|
944
939
|
* FGA enforcement utility for checking fine-grained authorization.
|
|
945
940
|
*
|
|
@@ -1067,8 +1062,7 @@ function resolvePermissionsFromMapping(roles, mapping) {
|
|
|
1067
1062
|
* @license Mastra Enterprise License - see ee/LICENSE
|
|
1068
1063
|
* @packageDocumentation
|
|
1069
1064
|
*/
|
|
1070
|
-
|
|
1071
|
-
//#region src/rbac-provider.ts
|
|
1065
|
+
// src/rbac-provider.ts
|
|
1072
1066
|
/**
|
|
1073
1067
|
* WorkOS RBAC provider that maps organization roles to Mastra permissions.
|
|
1074
1068
|
*
|
|
@@ -1105,7 +1099,7 @@ function resolvePermissionsFromMapping(roles, mapping) {
|
|
|
1105
1099
|
* ```
|
|
1106
1100
|
*/
|
|
1107
1101
|
/** Default cache TTL in milliseconds (60 seconds) */
|
|
1108
|
-
const DEFAULT_CACHE_TTL_MS =
|
|
1102
|
+
const DEFAULT_CACHE_TTL_MS = 6e4;
|
|
1109
1103
|
/** Default max cache size (number of users) */
|
|
1110
1104
|
const DEFAULT_CACHE_MAX_SIZE = 1e3;
|
|
1111
1105
|
var MastraRBACWorkos = class {
|
|
@@ -1298,8 +1292,7 @@ var MastraRBACWorkos = class {
|
|
|
1298
1292
|
return (this.options.organizationId ? user.memberships.filter((m) => m.organizationId === this.options.organizationId) : user.memberships).map((m) => m.role.slug);
|
|
1299
1293
|
}
|
|
1300
1294
|
};
|
|
1301
|
-
|
|
1302
|
-
//#region src/fga-provider.ts
|
|
1295
|
+
// src/fga-provider.ts
|
|
1303
1296
|
/**
|
|
1304
1297
|
* WorkOS FGA provider for Mastra.
|
|
1305
1298
|
*
|
|
@@ -1735,8 +1728,7 @@ var MastraFGAWorkos = class {
|
|
|
1735
1728
|
};
|
|
1736
1729
|
}
|
|
1737
1730
|
};
|
|
1738
|
-
|
|
1739
|
-
//#region src/directory-sync.ts
|
|
1731
|
+
// src/directory-sync.ts
|
|
1740
1732
|
/**
|
|
1741
1733
|
* WorkOSDirectorySync handles SCIM webhook events from WorkOS for automated
|
|
1742
1734
|
* user provisioning and deprovisioning.
|
|
@@ -1945,8 +1937,7 @@ var WorkOSDirectorySync = class {
|
|
|
1945
1937
|
return (await this.workos.directorySync.listGroups({ directory: directoryId })).data;
|
|
1946
1938
|
}
|
|
1947
1939
|
};
|
|
1948
|
-
|
|
1949
|
-
//#region src/admin-portal.ts
|
|
1940
|
+
// src/admin-portal.ts
|
|
1950
1941
|
/**
|
|
1951
1942
|
* WorkOS Admin Portal integration for customer self-service configuration.
|
|
1952
1943
|
*
|
|
@@ -2039,7 +2030,6 @@ var WorkOSAdminPortal = class {
|
|
|
2039
2030
|
})).link;
|
|
2040
2031
|
}
|
|
2041
2032
|
};
|
|
2042
|
-
//#endregion
|
|
2043
2033
|
export { MastraAuthWorkos, MastraFGAWorkos, MastraRBACWorkos, WebSessionStorage, WorkOSAdminPortal, WorkOSDirectorySync, WorkOSFGAMembershipResolutionError, WorkOSFGAResourceNotFoundError, mapWorkOSUserToEEUser };
|
|
2044
2034
|
|
|
2045
2035
|
//# sourceMappingURL=index.js.map
|