@mastra/auth-clerk 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-clerk@0.10.0 build /home/runner/work/mastra/mastra/auth/clerk
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 8150ms
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/clerk/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/clerk/dist/_tsup-dts-rollup.d.cts
16
+ DTS ⚡️ Build success in 11926ms
17
+ CLI Cleaning output folder
18
+ ESM Build start
19
+ CJS Build start
20
+ CJS dist/index.cjs 53.61 KB
21
+ CJS ⚡️ Build success in 2221ms
22
+ ESM dist/index.js 11.68 KB
23
+ ESM dist/getMachineId-darwin-UJH25LDA.js 770.00 B
24
+ ESM dist/getMachineId-linux-YF3RLZNP.js 440.00 B
25
+ ESM dist/getMachineId-bsd-IPBZSYCM.js 564.00 B
26
+ ESM dist/getMachineId-win-PKATJI4A.js 738.00 B
27
+ ESM dist/chunk-N62AETLJ.js 334.00 B
28
+ ESM dist/getMachineId-unsupported-UOUTBEEW.js 382.00 B
29
+ ESM dist/chunk-JLXWUSDO.js 32.51 KB
30
+ ESM ⚡️ Build success in 2223ms
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # @mastra/auth-clerk
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,79 @@
1
+ # @mastra/auth-clerk
2
+
3
+ A Mastra authentication provider for Clerk, enabling seamless integration of Clerk authentication with Mastra applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/auth-clerk
9
+ # or
10
+ yarn add @mastra/auth-clerk
11
+ # or
12
+ pnpm add @mastra/auth-clerk
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { Mastra } from '@mastra/core';
19
+ import { MastraAuthClerk } from '@mastra/auth-clerk';
20
+
21
+ // Initialize the Clerk auth provider
22
+ const clerkAuth = new MastraAuthClerk({
23
+ jwksUri: 'your-jwks-uri',
24
+ secretKey: 'your-secret-key',
25
+ publishableKey: 'your-publishable-key',
26
+ });
27
+
28
+ // Or use environment variables
29
+ const clerkAuth = new MastraAuthClerk();
30
+
31
+ // Enable auth in Mastra
32
+ const mastra = new Mastra({
33
+ ...
34
+ server: {
35
+ experimental_auth: clerkAuth,
36
+ },
37
+ });
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ The package can be configured either through constructor options or environment variables:
43
+
44
+ ### Environment Variables
45
+
46
+ - `CLERK_JWKS_URI`: The JWKS URI for your Clerk instance
47
+ - `CLERK_SECRET_KEY`: Your Clerk secret key
48
+ - `CLERK_PUBLISHABLE_KEY`: Your Clerk publishable key
49
+
50
+ ### Constructor Options
51
+
52
+ ```typescript
53
+ interface MastraAuthClerkOptions {
54
+ jwksUri?: string;
55
+ secretKey?: string;
56
+ publishableKey?: string;
57
+ }
58
+ ```
59
+
60
+ ## Features
61
+
62
+ - JWT token verification using Clerk's JWKS
63
+ - User authentication and authorization
64
+ - Organization membership verification
65
+ - Seamless integration with Mastra's authentication system
66
+
67
+ ## API
68
+
69
+ ### `authenticateToken(token: string): Promise<ClerkUser | null>`
70
+
71
+ Verifies a JWT token and returns the associated user if valid.
72
+
73
+ ### `authorizeUser(user: ClerkUser): Promise<boolean>`
74
+
75
+ Checks if a user is authorized by verifying their organization membership.
76
+
77
+ ## License
78
+
79
+ MIT
@@ -0,0 +1,22 @@
1
+ import type { ClerkClient } from '@clerk/backend';
2
+ import type { JwtPayload } from '@mastra/auth';
3
+ import { MastraAuthProvider } from '@mastra/core/server';
4
+ import type { MastraAuthProviderOptions } from '@mastra/core/server';
5
+
6
+ declare type ClerkUser = JwtPayload;
7
+
8
+ export declare class MastraAuthClerk extends MastraAuthProvider<ClerkUser> {
9
+ protected clerk: ClerkClient;
10
+ protected jwksUri: string;
11
+ constructor(options?: MastraAuthClerkOptions);
12
+ authenticateToken(token: string): Promise<ClerkUser | null>;
13
+ authorizeUser(user: ClerkUser): Promise<boolean>;
14
+ }
15
+
16
+ declare interface MastraAuthClerkOptions extends MastraAuthProviderOptions<ClerkUser> {
17
+ jwksUri?: string;
18
+ secretKey?: string;
19
+ publishableKey?: string;
20
+ }
21
+
22
+ export { }
@@ -0,0 +1,22 @@
1
+ import type { ClerkClient } from '@clerk/backend';
2
+ import type { JwtPayload } from '@mastra/auth';
3
+ import { MastraAuthProvider } from '@mastra/core/server';
4
+ import type { MastraAuthProviderOptions } from '@mastra/core/server';
5
+
6
+ declare type ClerkUser = JwtPayload;
7
+
8
+ export declare class MastraAuthClerk extends MastraAuthProvider<ClerkUser> {
9
+ protected clerk: ClerkClient;
10
+ protected jwksUri: string;
11
+ constructor(options?: MastraAuthClerkOptions);
12
+ authenticateToken(token: string): Promise<ClerkUser | null>;
13
+ authorizeUser(user: ClerkUser): Promise<boolean>;
14
+ }
15
+
16
+ declare interface MastraAuthClerkOptions extends MastraAuthProviderOptions<ClerkUser> {
17
+ jwksUri?: string;
18
+ secretKey?: string;
19
+ publishableKey?: string;
20
+ }
21
+
22
+ export { }