@mindfulauth/core 2.0.0-beta.2 → 2.0.0-beta.4

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/dist/config.d.ts CHANGED
@@ -1,32 +1,22 @@
1
- export declare const CENTRAL_AUTH_ORIGIN = "https://dev-api.mindfulauth.com";
2
- export declare const CDN_ORIGIN = "https://dev-cdn.mindfulauth.com";
1
+ export declare const CENTRAL_AUTH_ORIGIN = "https://api.mindfulauth.com";
2
+ export declare const CDN_ORIGIN = "https://cdn.mindfulauth.com";
3
3
  export declare const ALLOWED_AUTH_METHODS: string[];
4
4
  export declare const MAX_BODY_SIZE_BYTES = 1048576;
5
5
  export declare const AUTH_PROXY_TIMEOUT_MS = 15000;
6
6
  export declare const SESSION_VALIDATION_TIMEOUT_MS = 10000;
7
7
  /**
8
8
  * Returns the combined list of assets to skip session validation for.
9
- * Merges defaults with any custom assets configured via mauthSecurityConfig().
9
+ * Merges defaults with any custom assets configured via mauthSecurityConfig() in astro.config.mjs.
10
10
  */
11
11
  export declare function GET_SKIP_ASSETS(): string[];
12
- export declare const PUBLIC_ROUTES: string[];
13
- export declare const PUBLIC_PREFIXES: string[];
14
12
  /**
15
- * Configure Mindful Auth security settings including CSP sources and static
16
- * assets to skip. Returns the options to be passed to getMauthViteDefines().
17
- *
18
- * Call in astro.config.mjs and pass the result to vite.define:
13
+ * Configure Mindful Auth security settings including custom skip assets.
14
+ * Call in astro.config.mjs and pass the result to getMauthViteDefines().
19
15
  *
20
16
  * @example
21
17
  * // astro.config.mjs
22
18
  * const mauthCfg = mauthSecurityConfig({
23
- * skipAssets: ['/sitemap.xml', '/manifest.webmanifest'],
24
- * csp: {
25
- * scriptSources: ['https://analytics.example.com'],
26
- * connectSources: ['https://api.example.com'],
27
- * frameSources: ['https://stripe.com'],
28
- * fontSources: ['https://fonts.googleapis.com']
29
- * }
19
+ * skipAssets: ['/sitemap.xml', '/manifest.webmanifest']
30
20
  * });
31
21
  *
32
22
  * export default defineConfig({
@@ -35,12 +25,6 @@ export declare const PUBLIC_PREFIXES: string[];
35
25
  */
36
26
  export declare function mauthSecurityConfig(options?: {
37
27
  skipAssets?: string[];
38
- csp?: {
39
- scriptSources?: string[];
40
- connectSources?: string[];
41
- frameSources?: string[];
42
- fontSources?: string[];
43
- };
44
28
  }): typeof options;
45
29
  /**
46
30
  * Converts the result of mauthSecurityConfig() into Vite define entries.
@@ -49,16 +33,17 @@ export declare function mauthSecurityConfig(options?: {
49
33
  */
50
34
  export declare function getMauthViteDefines(options?: {
51
35
  skipAssets?: string[];
52
- csp?: {
53
- scriptSources?: string[];
54
- connectSources?: string[];
55
- frameSources?: string[];
56
- fontSources?: string[];
57
- };
58
36
  }): Record<string, string>;
37
+ export declare const PUBLIC_ROUTES: string[];
38
+ export declare const PUBLIC_PREFIXES: string[];
59
39
  /**
60
- * Get security headers with CSP sources merged from defaults and build-time
61
- * custom values injected via vite.define (from getMauthViteDefines()).
40
+ * Returns security headers to be added to every SSR response.
41
+ * CSP (Content-Security-Policy) for script-src and style-src is handled by
42
+ * Astro 6's native security.csp in astro.config.mjs using hashes.
43
+ * The remaining headers here cover transport security, framing, and permissions.
44
+ *
45
+ * Note: X-Frame-Options: SAMEORIGIN covers clickjacking protection
46
+ * (equivalent to CSP frame-ancestors 'self', which cannot be set via meta tag).
62
47
  */
63
- export declare function GET_SECURITY_HEADERS(nonce?: string): Record<string, string>;
48
+ export declare function GET_SECURITY_HEADERS(): Record<string, string>;
64
49
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,oCAAoC,CAAC;AACrE,eAAO,MAAM,UAAU,oCAAoC,CAAC;AAG5D,eAAO,MAAM,oBAAoB,UAAkB,CAAC;AACpD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAenD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAID,eAAO,MAAM,aAAa,UAQzB,CAAC;AAIF,eAAO,MAAM,eAAe,UAO3B,CAAC;AA0CF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC1C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE;QACF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;CACL,GAAG,OAAO,OAAO,CAEjB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC1C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE;QACF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;CACL,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQzB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiD3E"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AACjE,eAAO,MAAM,UAAU,gCAAgC,CAAC;AAGxD,eAAO,MAAM,oBAAoB,UAAkB,CAAC;AACpD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAenD;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC1C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,GAAG,OAAO,OAAO,CAEjB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC1C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIzB;AAID,eAAO,MAAM,aAAa,UAQzB,CAAC;AAIF,eAAO,MAAM,eAAe,UAO3B,CAAC;AAMF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ7D"}
package/dist/config.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // Configuration for the Astro Portal
3
3
  // ============================================================================
4
4
  // API Endpoints
5
- export const CENTRAL_AUTH_ORIGIN = 'https://dev-api.mindfulauth.com';
6
- export const CDN_ORIGIN = 'https://dev-cdn.mindfulauth.com';
5
+ export const CENTRAL_AUTH_ORIGIN = 'https://api.mindfulauth.com';
6
+ export const CDN_ORIGIN = 'https://cdn.mindfulauth.com';
7
7
  // Request & Timeout Configuration
8
8
  export const ALLOWED_AUTH_METHODS = ['GET', 'POST'];
9
9
  export const MAX_BODY_SIZE_BYTES = 1048576; // 1MB limit
@@ -15,81 +15,23 @@ export const SESSION_VALIDATION_TIMEOUT_MS = 10000;
15
15
  // Static assets to skip session validation (favicon, robots.txt, etc.)
16
16
  // SECURITY CRITICAL: Only add actual static file requests here.
17
17
  // Examples of safe entries: /favicon.ico, /robots.txt, /sitemap.xml
18
- // NEVER add application routes like /dashboard, /profile, /secure/* - this COMPLETELY bypasses authentication. If you add a route here, unauthenticated users can access it without logging in.
18
+ // NEVER add application routes like [memberid]/dashboard, [memberid]/profile, [memberid]/secure/* - this COMPLETELY bypasses authentication. If you add a route here, unauthenticated users can access it without logging in.
19
19
  const DEFAULT_SKIP_ASSETS = ['/favicon.ico', '/robots.txt', '/.well-known/security.txt'];
20
20
  /**
21
21
  * Returns the combined list of assets to skip session validation for.
22
- * Merges defaults with any custom assets configured via mauthSecurityConfig().
22
+ * Merges defaults with any custom assets configured via mauthSecurityConfig() in astro.config.mjs.
23
23
  */
24
24
  export function GET_SKIP_ASSETS() {
25
25
  return [...DEFAULT_SKIP_ASSETS, ...__MAUTH_SKIP_ASSETS__];
26
26
  }
27
- // Public routes that do not require authentication
28
- // ⚠️ DO NOT EDIT - These are critical for the authentication system to work correctly
29
- export const PUBLIC_ROUTES = [
30
- '/',
31
- '/login',
32
- '/register',
33
- '/magic-login',
34
- '/magic-register',
35
- '/forgot-password',
36
- '/resend-verification',
37
- ];
38
- // Dynamic public routes (prefix matching)
39
- // ⚠️ DO NOT EDIT - These are critical for the authentication system to work correctly
40
- export const PUBLIC_PREFIXES = [
41
- '/auth/',
42
- '/email-verified/',
43
- '/reset-password/',
44
- '/verify-email/',
45
- '/verify-magic-link/',
46
- '/api/public/',
47
- ];
48
- // ============================================================================
49
- // Security Headers & CSP Configuration
50
- // ============================================================================
51
- // Default allowed script sources for CSP
52
- // ⚠️ IMPORTANT: Do not remove these domains - they are critical for authentication:
53
- // Removing these will break authentication and user will be unable to log in.
54
- const DEFAULT_SCRIPT_SOURCES = [
55
- "'self'",
56
- 'https://*.cloudflare.com',
57
- 'https://*.cloudflareinsights.com',
58
- 'https://dev-cdn.mindfulauth.com',
59
- 'https://dev-api.mindfulauth.com'
60
- ];
61
- // Default allowed connection sources for CSP
62
- const DEFAULT_CONNECT_SOURCES = [
63
- "'self'",
64
- 'https://*.cloudflare.com',
65
- 'https://dev-api.mindfulauth.com'
66
- ];
67
- // Default allowed frame sources for CSP
68
- const DEFAULT_FRAME_SOURCES = [
69
- "'self'",
70
- 'https://*.cloudflare.com'
71
- ];
72
- // Default allowed font sources for CSP
73
- const DEFAULT_FONT_SOURCES = [
74
- "'self'",
75
- 'data:'
76
- ];
77
27
  /**
78
- * Configure Mindful Auth security settings including CSP sources and static
79
- * assets to skip. Returns the options to be passed to getMauthViteDefines().
80
- *
81
- * Call in astro.config.mjs and pass the result to vite.define:
28
+ * Configure Mindful Auth security settings including custom skip assets.
29
+ * Call in astro.config.mjs and pass the result to getMauthViteDefines().
82
30
  *
83
31
  * @example
84
32
  * // astro.config.mjs
85
33
  * const mauthCfg = mauthSecurityConfig({
86
- * skipAssets: ['/sitemap.xml', '/manifest.webmanifest'],
87
- * csp: {
88
- * scriptSources: ['https://analytics.example.com'],
89
- * connectSources: ['https://api.example.com'],
90
- * frameSources: ['https://stripe.com'],
91
- * fontSources: ['https://fonts.googleapis.com']
92
- * }
34
+ * skipAssets: ['/sitemap.xml', '/manifest.webmanifest']
93
35
  * });
94
36
  *
95
37
  * export default defineConfig({
@@ -107,54 +49,47 @@ export function mauthSecurityConfig(options) {
107
49
  export function getMauthViteDefines(options) {
108
50
  return {
109
51
  __MAUTH_SKIP_ASSETS__: JSON.stringify(options?.skipAssets ?? []),
110
- __MAUTH_SCRIPT_SOURCES__: JSON.stringify(options?.csp?.scriptSources ?? []),
111
- __MAUTH_CONNECT_SOURCES__: JSON.stringify(options?.csp?.connectSources ?? []),
112
- __MAUTH_FRAME_SOURCES__: JSON.stringify(options?.csp?.frameSources ?? []),
113
- __MAUTH_FONT_SOURCES__: JSON.stringify(options?.csp?.fontSources ?? []),
114
52
  };
115
53
  }
54
+ // Public routes that do not require authentication
55
+ // ⚠️ DO NOT EDIT - These are critical for the authentication system to work correctly
56
+ export const PUBLIC_ROUTES = [
57
+ '/',
58
+ '/login',
59
+ '/register',
60
+ '/magic-login',
61
+ '/magic-register',
62
+ '/forgot-password',
63
+ '/resend-verification',
64
+ ];
65
+ // Dynamic public routes (prefix matching)
66
+ // ⚠️ DO NOT EDIT - These are critical for the authentication system to work correctly
67
+ export const PUBLIC_PREFIXES = [
68
+ '/auth/',
69
+ '/email-verified/',
70
+ '/reset-password/',
71
+ '/verify-email/',
72
+ '/verify-magic-link/',
73
+ '/api/public/',
74
+ ];
75
+ // ============================================================================
76
+ // Security Headers
77
+ // ============================================================================
116
78
  /**
117
- * Get security headers with CSP sources merged from defaults and build-time
118
- * custom values injected via vite.define (from getMauthViteDefines()).
79
+ * Returns security headers to be added to every SSR response.
80
+ * CSP (Content-Security-Policy) for script-src and style-src is handled by
81
+ * Astro 6's native security.csp in astro.config.mjs using hashes.
82
+ * The remaining headers here cover transport security, framing, and permissions.
83
+ *
84
+ * Note: X-Frame-Options: SAMEORIGIN covers clickjacking protection
85
+ * (equivalent to CSP frame-ancestors 'self', which cannot be set via meta tag).
119
86
  */
120
- export function GET_SECURITY_HEADERS(nonce) {
121
- // Custom sources are baked in at build time via vite.define
122
- const SCRIPT_SOURCES = [
123
- ...DEFAULT_SCRIPT_SOURCES,
124
- ...__MAUTH_SCRIPT_SOURCES__,
125
- ...(nonce ? [`'nonce-${nonce}'`] : []),
126
- ];
127
- const CONNECT_SOURCES = [...DEFAULT_CONNECT_SOURCES, ...__MAUTH_CONNECT_SOURCES__];
128
- const FRAME_SOURCES = [...DEFAULT_FRAME_SOURCES, ...__MAUTH_FRAME_SOURCES__];
129
- const FONT_SOURCES = [...DEFAULT_FONT_SOURCES, ...__MAUTH_FONT_SOURCES__];
87
+ export function GET_SECURITY_HEADERS() {
130
88
  return {
131
89
  'X-Content-Type-Options': 'nosniff',
132
90
  'X-Frame-Options': 'SAMEORIGIN',
133
91
  'Referrer-Policy': 'strict-origin-when-cross-origin',
134
92
  'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
135
93
  'Permissions-Policy': 'geolocation=(), microphone=(), camera=()',
136
- 'Content-Security-Policy': [
137
- // Default policy
138
- "default-src 'self'",
139
- // Scripts
140
- `script-src ${SCRIPT_SOURCES.join(' ')}`,
141
- // Styles
142
- "style-src 'self' 'unsafe-inline'",
143
- // Images
144
- "img-src 'self' data: https:",
145
- // Connections
146
- `connect-src ${CONNECT_SOURCES.join(' ')}`,
147
- // Frames
148
- `frame-src ${FRAME_SOURCES.join(' ')}`,
149
- // Fonts
150
- `font-src ${FONT_SOURCES.join(' ')}`,
151
- // Disallow object/embed tags (Flash, Java, etc.)
152
- "object-src 'none'",
153
- // Security directives
154
- "base-uri 'self'",
155
- "form-action 'self'",
156
- "upgrade-insecure-requests",
157
- "block-all-mixed-content"
158
- ].join('; ')
159
94
  };
160
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,SAAS,mCAuEpB,CAAC"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,SAAS,mCAqFpB,CAAC"}
@@ -8,19 +8,20 @@
8
8
  import { defineMiddleware } from 'astro:middleware';
9
9
  import { env } from 'cloudflare:workers';
10
10
  import { PUBLIC_ROUTES, PUBLIC_PREFIXES, GET_SECURITY_HEADERS, GET_SKIP_ASSETS } from './config';
11
- import { sanitizePath, generateNonce } from './security';
11
+ import { sanitizePath } from './security';
12
12
  import { validateSession, validateMemberIdInUrl } from './auth';
13
13
  /** Check if a path is a public route (no auth required) */
14
14
  function isPublicRoute(pathname) {
15
15
  return PUBLIC_ROUTES.includes(pathname) ||
16
- PUBLIC_PREFIXES.some(prefix => pathname.startsWith(prefix));
16
+ PUBLIC_PREFIXES.some((prefix) => pathname.startsWith(prefix));
17
17
  }
18
18
  /** Add security headers to a response */
19
19
  // NOTE: In Cloudflare Workers, Response.headers is immutable.
20
20
  // We must create a new Response with a fresh Headers object instead of mutating.
21
- function addSecurityHeaders(response, nonce) {
21
+ // CSP for script-src/style-src is handled by Astro 6's native security.csp (via <meta> tag).
22
+ function addSecurityHeaders(response) {
22
23
  const newHeaders = new Headers(response.headers);
23
- Object.entries(GET_SECURITY_HEADERS(nonce)).forEach(([key, value]) => {
24
+ Object.entries(GET_SECURITY_HEADERS()).forEach(([key, value]) => {
24
25
  newHeaders.set(key, value);
25
26
  });
26
27
  return new Response(response.body, {
@@ -33,10 +34,11 @@ function addSecurityHeaders(response, nonce) {
33
34
  export const onRequest = defineMiddleware(async (context, next) => {
34
35
  const { request, url, redirect, locals } = context;
35
36
  const pathname = url.pathname;
36
- // Generate a per-request nonce for CSP. Exposed as locals.cspNonce so
37
- // layouts can add nonce={Astro.locals.cspNonce} to inline <script> tags.
38
- const nonce = generateNonce();
39
- locals.cspNonce = nonce;
37
+ // Redirect HTTP to HTTPS (skip in dev mode and localhost)
38
+ if (!import.meta.env.DEV && url.protocol === 'http:' && url.hostname !== 'localhost' && url.hostname !== '127.0.0.1') {
39
+ const httpsUrl = url.toString().replace('http://', 'https://');
40
+ return redirect(httpsUrl, 307);
41
+ }
40
42
  // Skip middleware for static assets FIRST (before dev mode)
41
43
  if (GET_SKIP_ASSETS().includes(pathname)) {
42
44
  return next();
@@ -58,6 +60,18 @@ export const onRequest = defineMiddleware(async (context, next) => {
58
60
  locals.recordId = match ? match[1] : 'dev-user-123';
59
61
  return next();
60
62
  }
63
+ // PREVIEW MODE: Skip auth (for testing without Mindful Auth on localhost)
64
+ // npm run preview builds the project first, so import.meta.env.DEV is false.
65
+ // We need a runtime check for localhost to simulate auth in preview.
66
+ if (url.hostname === 'localhost' || url.hostname === '127.0.0.1') {
67
+ if (isPublicRoute(pathname)) {
68
+ locals.recordId = null;
69
+ return addSecurityHeaders(await next());
70
+ }
71
+ const match = pathname.match(/^\/([a-zA-Z0-9-]+)(?:\/|$)/);
72
+ locals.recordId = match ? match[1] : 'preview-user-123';
73
+ return addSecurityHeaders(await next());
74
+ }
61
75
  // Sanitize path
62
76
  const safePath = sanitizePath(pathname);
63
77
  if (!safePath) {
@@ -66,7 +80,7 @@ export const onRequest = defineMiddleware(async (context, next) => {
66
80
  // Public routes - no auth needed
67
81
  if (isPublicRoute(safePath)) {
68
82
  locals.recordId = null;
69
- return addSecurityHeaders(await next(), nonce);
83
+ return addSecurityHeaders(await next());
70
84
  }
71
85
  // Protected route - validate session
72
86
  // ASTRO 6 CHANGE: Environment variables are accessed directly from 'cloudflare:workers' env,
@@ -90,5 +104,5 @@ export const onRequest = defineMiddleware(async (context, next) => {
90
104
  return new Response('Forbidden: Invalid user ID in URL', { status: 403 });
91
105
  }
92
106
  locals.recordId = session.recordId;
93
- return addSecurityHeaders(await next(), nonce);
107
+ return addSecurityHeaders(await next());
94
108
  });
@@ -1,9 +1,3 @@
1
- /**
2
- * Generate a cryptographically secure random nonce for use in CSP headers.
3
- * The same nonce must be added as a `nonce` attribute on every inline <script>
4
- * tag so the browser allows it to execute.
5
- */
6
- export declare function generateNonce(): string;
7
1
  /** Sanitize endpoint path (prevents ../ traversal and encoded variants) */
8
2
  export declare function sanitizeEndpoint(endpoint: string): string | null;
9
3
  /** Sanitize URL path (prevents ../ traversal and encoded variants) */
@@ -1 +1 @@
1
- {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAgBD,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIhE;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI5D"}
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAkBA,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIhE;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI5D"}
package/dist/security.js CHANGED
@@ -1,15 +1,5 @@
1
- // Security utilities - path traversal prevention, nonce generation
1
+ // Security utilities - path traversal prevention
2
2
  const MAX_PATH_LENGTH = 2048;
3
- /**
4
- * Generate a cryptographically secure random nonce for use in CSP headers.
5
- * The same nonce must be added as a `nonce` attribute on every inline <script>
6
- * tag so the browser allows it to execute.
7
- */
8
- export function generateNonce() {
9
- const bytes = new Uint8Array(16);
10
- crypto.getRandomValues(bytes);
11
- return btoa(String.fromCharCode(...bytes));
12
- }
13
3
  /** Decode and check for traversal attacks */
14
4
  function decodeAndValidate(str) {
15
5
  if (!str || typeof str !== 'string' || str.length > MAX_PATH_LENGTH)
package/dist/types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { MiddlewareHandler } from 'astro';
2
2
  export interface MindfulAuthLocals {
3
3
  recordId: string | null;
4
- cspNonce: string;
5
4
  runtime?: {
6
5
  env?: {
7
6
  INTERNAL_API_KEY?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE;YACJ,gBAAgB,CAAC,EAAE,MAAM,CAAC;SAC3B,CAAC;KACH,CAAC;CACH;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,MAAO,SAAQ,iBAAiB;SAAG;KAC9C;CACF;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE;YACJ,gBAAgB,CAAC,EAAE,MAAM,CAAC;SAC3B,CAAC;KACH,CAAC;CACH;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,MAAO,SAAQ,iBAAiB;SAAG;KAC9C;CACF;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC"}
package/dist/types.js CHANGED
@@ -1,3 +1,2 @@
1
1
  // Type definitions for Mindful Auth
2
- /// <reference types="@cloudflare/workers-types" />
3
2
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindfulauth/core",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.4",
4
4
  "description": "Mindful Auth core authentication library for Astro 6",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,8 +45,8 @@
45
45
  "astro": "^6.0.0-beta.14"
46
46
  },
47
47
  "devDependencies": {
48
- "@cloudflare/workers-types": "^4.20260303.0",
49
- "astro": "^6.0.0-beta.14",
48
+ "@cloudflare/workers-types": "^4.20260304.0",
49
+ "astro": "^6.0.0-beta.15",
50
50
  "typescript": "^5.9.3"
51
51
  }
52
52
  }