@mindfulauth/core 1.0.0 → 1.0.2

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 CHANGED
@@ -2,53 +2,7 @@
2
2
 
3
3
  Core authentication library for Mindful Auth, designed for Astro applications.
4
4
 
5
- ## Installation
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
 
@@ -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-Forwarded-For'] = clientIp;
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-Forwarded-For': clientIp }),
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 }),
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AACjE,eAAO,MAAM,UAAU,gCAAgC,CAAC;AACxD,eAAO,MAAM,oBAAoB,UAAkB,CAAC;AACpD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAMnD,eAAO,MAAM,WAAW,UAA+D,CAAC;AAKxF,eAAO,MAAM,aAAa,UAQzB,CAAC;AAKF,eAAO,MAAM,eAAe,UAM3B,CAAC;AAaF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAoBnD,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AACjE,eAAO,MAAM,UAAU,gCAAgC,CAAC;AACxD,eAAO,MAAM,oBAAoB,UAAkB,CAAC;AACpD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAMnD,eAAO,MAAM,WAAW,UAA+D,CAAC;AAKxF,eAAO,MAAM,aAAa,UAQzB,CAAC;AAKF,eAAO,MAAM,eAAe,UAO3B,CAAC;AAaF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAoBnD,CAAC"}
package/dist/config.js CHANGED
@@ -31,6 +31,7 @@ export const PUBLIC_PREFIXES = [
31
31
  '/reset-password/',
32
32
  '/verify-email/',
33
33
  '/verify-magic-link/',
34
+ '/api/public/', // Public API routes (e.g. for webhooks)
34
35
  ];
35
36
  // Security headers for all HTML responses
36
37
  // ⚠️ IMPORTANT: Do not remove the following domains from the CSP - they are critical for authentication:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindfulauth/core",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Mindful Auth core authentication library for Astro",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",