@mastra/auth-workos 0.10.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.
@@ -0,0 +1,30 @@
1
+
2
+ > @mastra/auth-workos@0.10.0 build /home/runner/work/mastra/mastra/auth/workos
3
+ > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.4.0
8
+ TSC Build start
9
+ TSC ⚡️ Build success in 7538ms
10
+ DTS Build start
11
+ CLI Target: es2022
12
+ Analysis will use the bundled TypeScript version 5.8.3
13
+ Writing package typings: /home/runner/work/mastra/mastra/auth/workos/dist/_tsup-dts-rollup.d.ts
14
+ Analysis will use the bundled TypeScript version 5.8.3
15
+ Writing package typings: /home/runner/work/mastra/mastra/auth/workos/dist/_tsup-dts-rollup.d.cts
16
+ DTS ⚡️ Build success in 8130ms
17
+ CLI Cleaning output folder
18
+ ESM Build start
19
+ CJS Build start
20
+ ESM dist/index.js 11.63 KB
21
+ ESM dist/getMachineId-darwin-UJH25LDA.js 770.00 B
22
+ ESM dist/getMachineId-linux-YF3RLZNP.js 440.00 B
23
+ ESM dist/getMachineId-bsd-IPBZSYCM.js 564.00 B
24
+ ESM dist/getMachineId-win-PKATJI4A.js 738.00 B
25
+ ESM dist/chunk-N62AETLJ.js 334.00 B
26
+ ESM dist/getMachineId-unsupported-UOUTBEEW.js 382.00 B
27
+ ESM dist/chunk-JLXWUSDO.js 32.51 KB
28
+ ESM ⚡️ Build success in 2022ms
29
+ CJS dist/index.cjs 53.57 KB
30
+ CJS ⚡️ Build success in 2023ms
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # @mastra/auth-workos
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Mastra AI, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @mastra/auth-workos
2
+
3
+ A WorkOS authentication provider for Mastra, enabling seamless integration of WorkOS authentication and authorization in your applications.
4
+
5
+ ## Features
6
+
7
+ - 🔐 WorkOS authentication integration
8
+ - 👥 User management and organization membership support
9
+ - 🔑 JWT token verification using WorkOS JWKS
10
+ - 👮‍♂️ Role-based authorization with admin role support
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @mastra/auth-workos
16
+ # or
17
+ yarn add @mastra/auth-workos
18
+ # or
19
+ pnpm add @mastra/auth-workos
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```typescript
25
+ import { Mastra } from '@mastra/core';
26
+ import { MastraAuthWorkos } from '@mastra/auth-workos';
27
+
28
+ // Initialize with environment variables
29
+ const auth = new MastraAuthWorkos();
30
+
31
+ // Or initialize with explicit configuration
32
+ const auth = new MastraAuthWorkos({
33
+ apiKey: 'your_workos_api_key',
34
+ clientId: 'your_workos_client_id',
35
+ });
36
+
37
+ // Enable auth in Mastra
38
+ const mastra = new Mastra({
39
+ ...
40
+ server: {
41
+ experimental_auth: auth,
42
+ },
43
+ });
44
+ ```
45
+
46
+ ## Configuration
47
+
48
+ The package requires the following configuration:
49
+
50
+ ### Environment Variables
51
+
52
+ - `WORKOS_API_KEY`: Your WorkOS API key
53
+ - `WORKOS_CLIENT_ID`: Your WorkOS client ID
54
+
55
+ ### Options
56
+
57
+ You can also provide these values directly when initializing the provider:
58
+
59
+ ```typescript
60
+ interface MastraAuthWorkosOptions {
61
+ apiKey?: string;
62
+ clientId?: string;
63
+ }
64
+ ```
65
+
66
+ ## API
67
+
68
+ ### `authenticateToken(token: string): Promise<WorkosUser | null>`
69
+
70
+ Verifies a JWT token using WorkOS JWKS and returns the user information if valid.
71
+
72
+ ### `authorizeUser(user: WorkosUser): Promise<boolean>`
73
+
74
+ Checks if a user has admin privileges by verifying their organization memberships and roles.
75
+
76
+ ## License
77
+
78
+ MIT
@@ -0,0 +1,20 @@
1
+ import type { JwtPayload } from '@mastra/auth';
2
+ import { MastraAuthProvider } from '@mastra/core/server';
3
+ import type { MastraAuthProviderOptions } from '@mastra/core/server';
4
+ import { WorkOS } from '@workos-inc/node';
5
+
6
+ export declare class MastraAuthWorkos extends MastraAuthProvider<WorkosUser> {
7
+ protected workos: WorkOS;
8
+ constructor(options?: MastraAuthWorkosOptions);
9
+ authenticateToken(token: string): Promise<WorkosUser | null>;
10
+ authorizeUser(user: WorkosUser): Promise<boolean>;
11
+ }
12
+
13
+ declare interface MastraAuthWorkosOptions extends MastraAuthProviderOptions<WorkosUser> {
14
+ apiKey?: string;
15
+ clientId?: string;
16
+ }
17
+
18
+ declare type WorkosUser = JwtPayload;
19
+
20
+ export { }
@@ -0,0 +1,20 @@
1
+ import type { JwtPayload } from '@mastra/auth';
2
+ import { MastraAuthProvider } from '@mastra/core/server';
3
+ import type { MastraAuthProviderOptions } from '@mastra/core/server';
4
+ import { WorkOS } from '@workos-inc/node';
5
+
6
+ export declare class MastraAuthWorkos extends MastraAuthProvider<WorkosUser> {
7
+ protected workos: WorkOS;
8
+ constructor(options?: MastraAuthWorkosOptions);
9
+ authenticateToken(token: string): Promise<WorkosUser | null>;
10
+ authorizeUser(user: WorkosUser): Promise<boolean>;
11
+ }
12
+
13
+ declare interface MastraAuthWorkosOptions extends MastraAuthProviderOptions<WorkosUser> {
14
+ apiKey?: string;
15
+ clientId?: string;
16
+ }
17
+
18
+ declare type WorkosUser = JwtPayload;
19
+
20
+ export { }