@mastra/auth-auth0 0.0.0-ai-v5-20250729181825
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 +15 -0
- package/LICENSE.md +15 -0
- package/README.md +89 -0
- package/dist/_tsup-dts-rollup.d.cts +20 -0
- package/dist/_tsup-dts-rollup.d.ts +20 -0
- package/dist/chunk-JLXWUSDO.js +972 -0
- package/dist/chunk-N62AETLJ.js +7 -0
- package/dist/getMachineId-bsd-IPBZSYCM.js +21 -0
- package/dist/getMachineId-darwin-UJH25LDA.js +22 -0
- package/dist/getMachineId-linux-YF3RLZNP.js +17 -0
- package/dist/getMachineId-unsupported-UOUTBEEW.js +9 -0
- package/dist/getMachineId-win-PKATJI4A.js +23 -0
- package/dist/index.cjs +1565 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +392 -0
- package/eslint.config.js +6 -0
- package/package.json +40 -0
- package/src/index.test.ts +112 -0
- package/src/index.ts +49 -0
- package/tsconfig.json +5 -0
- package/vitest.config.ts +8 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @mastra/auth-auth0
|
|
2
|
+
|
|
3
|
+
## 0.0.0-ai-v5-20250729181825
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ee857ae: dependencies updates:
|
|
8
|
+
- Updated dependency [`jose@^6.0.12` ↗︎](https://www.npmjs.com/package/jose/v/6.0.12) (from `^6.0.11`, in `dependencies`)
|
|
9
|
+
|
|
10
|
+
## 0.10.1-alpha.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- ee857ae: dependencies updates:
|
|
15
|
+
- Updated dependency [`jose@^6.0.12` ↗︎](https://www.npmjs.com/package/jose/v/6.0.12) (from `^6.0.11`, in `dependencies`)
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @mastra/auth-auth0
|
|
2
|
+
|
|
3
|
+
A Mastra authentication provider for Auth0 integration. This package provides seamless authentication and authorization using Auth0's JWT tokens.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/auth-auth0
|
|
9
|
+
# or
|
|
10
|
+
yarn add @mastra/auth-auth0
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @mastra/auth-auth0
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Mastra } from '@mastra/core';
|
|
19
|
+
import { MastraAuthAuth0 } from '@mastra/auth-auth0';
|
|
20
|
+
|
|
21
|
+
// Initialize with options
|
|
22
|
+
const auth0Provider = new MastraAuthAuth0({
|
|
23
|
+
domain: 'your-tenant.auth0.com',
|
|
24
|
+
audience: 'your-api-identifier',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Or use environment variables
|
|
28
|
+
const auth0Provider = new MastraAuthAuth0();
|
|
29
|
+
|
|
30
|
+
// Enable auth in Mastra
|
|
31
|
+
const mastra = new Mastra({
|
|
32
|
+
...
|
|
33
|
+
server: {
|
|
34
|
+
experimental_auth: auth0Provider,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
The package can be configured either through constructor options or environment variables:
|
|
42
|
+
|
|
43
|
+
### Constructor Options
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface MastraAuthAuth0Options {
|
|
47
|
+
domain?: string; // Your Auth0 domain
|
|
48
|
+
audience?: string; // Your Auth0 API identifier
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Environment Variables
|
|
53
|
+
|
|
54
|
+
- `AUTH0_DOMAIN`: Your Auth0 domain (e.g., 'your-tenant.auth0.com')
|
|
55
|
+
- `AUTH0_AUDIENCE`: Your Auth0 API identifier
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
- JWT token verification using Auth0's JWKS
|
|
60
|
+
- Automatic token validation against Auth0's issuer
|
|
61
|
+
- Audience validation
|
|
62
|
+
- Type-safe user payload
|
|
63
|
+
|
|
64
|
+
## Example
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { MastraAuthAuth0 } from '@mastra/auth-auth0';
|
|
68
|
+
|
|
69
|
+
const auth0Provider = new MastraAuthAuth0({
|
|
70
|
+
domain: 'your-tenant.auth0.com',
|
|
71
|
+
audience: 'your-api-identifier',
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Authenticate a token
|
|
75
|
+
const user = await auth0Provider.authenticateToken('your-jwt-token');
|
|
76
|
+
|
|
77
|
+
// Authorize a user
|
|
78
|
+
const isAuthorized = await auth0Provider.authorizeUser(user);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Requirements
|
|
82
|
+
|
|
83
|
+
- Node.js 16 or higher
|
|
84
|
+
- Auth0 account and configured application
|
|
85
|
+
- Valid Auth0 domain and API identifier
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JWTPayload } from 'jose';
|
|
2
|
+
import { MastraAuthProvider } from '@mastra/core/server';
|
|
3
|
+
import type { MastraAuthProviderOptions } from '@mastra/core/server';
|
|
4
|
+
|
|
5
|
+
declare type Auth0User = JWTPayload;
|
|
6
|
+
|
|
7
|
+
export declare class MastraAuthAuth0 extends MastraAuthProvider<Auth0User> {
|
|
8
|
+
protected domain: string;
|
|
9
|
+
protected audience: string;
|
|
10
|
+
constructor(options?: MastraAuthAuth0Options);
|
|
11
|
+
authenticateToken(token: string): Promise<Auth0User | null>;
|
|
12
|
+
authorizeUser(user: Auth0User): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare interface MastraAuthAuth0Options extends MastraAuthProviderOptions<Auth0User> {
|
|
16
|
+
domain?: string;
|
|
17
|
+
audience?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JWTPayload } from 'jose';
|
|
2
|
+
import { MastraAuthProvider } from '@mastra/core/server';
|
|
3
|
+
import type { MastraAuthProviderOptions } from '@mastra/core/server';
|
|
4
|
+
|
|
5
|
+
declare type Auth0User = JWTPayload;
|
|
6
|
+
|
|
7
|
+
export declare class MastraAuthAuth0 extends MastraAuthProvider<Auth0User> {
|
|
8
|
+
protected domain: string;
|
|
9
|
+
protected audience: string;
|
|
10
|
+
constructor(options?: MastraAuthAuth0Options);
|
|
11
|
+
authenticateToken(token: string): Promise<Auth0User | null>;
|
|
12
|
+
authorizeUser(user: Auth0User): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare interface MastraAuthAuth0Options extends MastraAuthProviderOptions<Auth0User> {
|
|
16
|
+
domain?: string;
|
|
17
|
+
audience?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { }
|