@mindfulauth/core 1.0.0 → 1.0.1
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/README.md +1 -47
- package/dist/auth-handler.js +1 -1
- package/dist/auth.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,53 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Core authentication library for Mindful Auth, designed for Astro applications.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @mindful-auth/core
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
### Set up middleware
|
|
14
|
-
|
|
15
|
-
In your `src/middleware.ts`:
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
export { onRequest } from '@mindful-auth/core/middleware';
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Handle auth routes
|
|
22
|
-
|
|
23
|
-
In your `src/pages/auth/[...slug].ts`:
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { handleAuthGet, handleAuthPost } from '@mindful-auth/core/auth-handler';
|
|
27
|
-
|
|
28
|
-
export async function GET(context: APIContext) {
|
|
29
|
-
const { params, request, url, locals } = context;
|
|
30
|
-
return handleAuthGet(params.slug || '', request, url, locals);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function POST(context: APIContext) {
|
|
34
|
-
const { params, request, url, locals } = context;
|
|
35
|
-
return handleAuthPost(params.slug || '', request, url, locals);
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Configure your application
|
|
40
|
-
|
|
41
|
-
You can customize the configuration by importing and modifying values:
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { CENTRAL_AUTH_ORIGIN, PUBLIC_ROUTES } from '@mindful-auth/core/config';
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Environment Variables
|
|
48
|
-
|
|
49
|
-
Set the following environment variable (required):
|
|
50
|
-
|
|
51
|
-
- `INTERNAL_API_KEY`: Your Mindful Auth API key
|
|
5
|
+
Install Mindful Auth Astro template here https://docs.mindfulauth.com/guides/frontend/astro/astro-setup/
|
|
52
6
|
|
|
53
7
|
## Features
|
|
54
8
|
|
package/dist/auth-handler.js
CHANGED
|
@@ -20,7 +20,7 @@ function buildProxyHeaders(request, tenantDomain, apiKey) {
|
|
|
20
20
|
request.headers.get('x-forwarded-for')?.split(',')[0]?.trim() ||
|
|
21
21
|
request.headers.get('x-real-ip');
|
|
22
22
|
if (clientIp)
|
|
23
|
-
headers['X-
|
|
23
|
+
headers['X-Original-Client-IP'] = clientIp;
|
|
24
24
|
const userAgent = request.headers.get('user-agent');
|
|
25
25
|
if (userAgent)
|
|
26
26
|
headers['User-Agent'] = userAgent;
|
package/dist/auth.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function validateSession(request, tenantDomain, pathname, internalA
|
|
|
17
17
|
'Content-Type': 'application/json',
|
|
18
18
|
'X-Tenant-Domain': tenantDomain,
|
|
19
19
|
'X-Internal-Api-Key': internalApiKey,
|
|
20
|
-
...(clientIp && { 'X-
|
|
20
|
+
...(clientIp && { 'X-Original-Client-IP': clientIp }),
|
|
21
21
|
...(request.headers.get('user-agent') && { 'User-Agent': request.headers.get('user-agent') })
|
|
22
22
|
},
|
|
23
23
|
body: JSON.stringify({ sessionId, requestedUrl: pathname }),
|