@networkpro/web 1.25.1 β†’ 1.25.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/CHANGELOG.md CHANGED
@@ -22,6 +22,30 @@ This project attempts to follow [Keep a Changelog](https://keepachangelog.com/en
22
22
 
23
23
  ---
24
24
 
25
+ ## [1.25.2]
26
+
27
+ ### Changed
28
+
29
+ - **Unified Environment Detection (`env.js`)**
30
+ - Added support for server-side hostname injection via optional `hostOverride` parameter.
31
+ - Enables accurate audit environment detection on both server (`hooks.server.js`) and client.
32
+ - Logs the resolved environment and host when executed on the server.
33
+ - Maintains safe fallback behavior for client-only usage.
34
+
35
+ - **CSP Handling (`hooks.server.js`)**
36
+ - Replaced reliance on `window.location` (unavailable on server) with `event.url.hostname` for host detection.
37
+ - Now correctly applies hardened audit-mode CSP in deployments matching `*.audit.netwk.pro`.
38
+ - Improved logging for audit/test/prod environment resolution during server request lifecycle.
39
+
40
+ - **Build Diagnostics (`vite.config.js`)**
41
+ - Added `stderr` output for `audit` mode builds to ensure visibility in CI logs.
42
+ - Displays a prominent `πŸ”’ Audit Mode Detected` tag during Vercel and local builds.
43
+ - Continues to log `ENV_MODE`, `PUBLIC_ENV_MODE`, and `NODE_ENV` for build-time inspection.
44
+
45
+ - Bumped project version to `v1.25.2`.
46
+
47
+ ---
48
+
25
49
  ## [1.25.1]
26
50
 
27
51
  ### Added
@@ -41,6 +65,7 @@ This project attempts to follow [Keep a Changelog](https://keepachangelog.com/en
41
65
  - Simplified and stabilized environment detection logic for better cross-environment consistency.
42
66
  - Removed redundant imports and corrected handling of static vs dynamic `BUILD_ENV_MODE`.
43
67
  - Improved comments and type annotations for maintainability and IDE autocompletion.
68
+ - Bumped project version to `v1.25.1`.
44
69
 
45
70
  ### Developer Experience
46
71
 
@@ -87,6 +112,7 @@ This project attempts to follow [Keep a Changelog](https://keepachangelog.com/en
87
112
  - Simplified step output and summary formatting for clearer reporting in the Actions log and job summary.
88
113
  - Maintains lightweight permissions (`contents: read`) and executes entirely without repository writes.
89
114
  - Improves reliability of branch protection monitoring without affecting CI or merge operations.
115
+ - Bumped project version to `v1.25.0`.
90
116
 
91
117
  ### Fixed
92
118
 
@@ -1610,7 +1636,8 @@ This enables analytics filtering and CSP hardening for the audit environment.
1610
1636
 
1611
1637
  <!-- Link references -->
1612
1638
 
1613
- [Unreleased]: https://github.com/netwk-pro/netwk-pro.github.io/compare/v1.25.1...HEAD
1639
+ [Unreleased]: https://github.com/netwk-pro/netwk-pro.github.io/compare/v1.25.2...HEAD
1640
+ [1.25.2]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.25.2
1614
1641
  [1.25.1]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.25.1
1615
1642
  [1.25.0]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.25.0
1616
1643
  [1.24.5]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.24.5
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@networkpro/web",
3
3
  "private": false,
4
- "version": "1.25.1",
4
+ "version": "1.25.2",
5
5
  "description": "Locking Down Networks, Unlocking Confidenceβ„’ | Security, Networking, Privacy β€” Network Pro Strategies",
6
6
  "keywords": [
7
7
  "advisory",
@@ -15,8 +15,17 @@ import { detectEnvironment } from '$lib/utils/env.js';
15
15
  export async function handle({ event, resolve }) {
16
16
  const response = await resolve(event);
17
17
 
18
- const { isAudit, isTest, isProd, effective, mode } = detectEnvironment();
19
- console.log('[CSP Debug ENV]', { mode, effective, isProd, isAudit, isTest });
18
+ const env = detectEnvironment(event.url.hostname);
19
+ const { isAudit, isTest, isProd, mode, effective } = env;
20
+
21
+ console.log('[CSP Debug ENV]', {
22
+ mode,
23
+ effective,
24
+ hostname: event.url.hostname,
25
+ isAudit,
26
+ isTest,
27
+ isProd,
28
+ });
20
29
 
21
30
  // Determine report URI
22
31
  const reportUri =
@@ -16,7 +16,7 @@ This file is part of Network Pro.
16
16
  *
17
17
  * @module src/lib/utils
18
18
  * @author Scott Lopez
19
- * @updated 2025-11-02
19
+ * @updated 2025-11-03
20
20
  *
21
21
  * @example
22
22
  * import { detectEnvironment } from '$lib/utils/env.js';
@@ -44,17 +44,19 @@ export const BUILD_ENV_MODE =
44
44
  import.meta.env.PUBLIC_ENV_MODE || import.meta.env.MODE || 'production';
45
45
 
46
46
  /**
47
- * Detects the current environment, combining build-time
48
- * and runtime (hostname-based) checks.
49
- * Works safely in both Node and browser contexts.
47
+ * Detects the current environment, combining build-time and host-based checks.
48
+ * Supports browser, server, and build-time contexts.
50
49
  *
50
+ * @param {string} [hostOverride] Optional hostname to use for environment resolution (e.g., from event.url.hostname)
51
51
  * @returns {EnvironmentInfo}
52
52
  */
53
- export function detectEnvironment() {
53
+ export function detectEnvironment(hostOverride) {
54
54
  const mode = BUILD_ENV_MODE;
55
55
 
56
- // Client-side fallback for audit/netwk environments
57
- const host = typeof window !== 'undefined' ? window.location.hostname : '';
56
+ // Determine host based on execution context
57
+ const host =
58
+ hostOverride ||
59
+ (typeof window !== 'undefined' ? window.location.hostname : '');
58
60
 
59
61
  const hostIsAudit = /(^|\.)audit\.netwk\.pro$/i.test(host);
60
62
 
@@ -64,16 +66,13 @@ export function detectEnvironment() {
64
66
  const isCI = mode === 'ci';
65
67
  const isTest = mode === 'test';
66
68
 
67
- // Prefer host-based detection if it disagrees with build-time
68
69
  const effective = hostIsAudit && !isAudit ? 'audit(host)' : mode;
69
70
 
70
71
  if (typeof window === 'undefined') {
71
- // Only log on server / build to avoid client noise
72
- console.log('[detectEnvironment] Build mode:', mode);
72
+ console.log('[detectEnvironment] Server-side build mode:', mode);
73
+ console.log('[detectEnvironment] Hostname:', host || '(none)');
73
74
  if (hostIsAudit && mode !== 'audit') {
74
- console.log(
75
- '[detectEnvironment] Host suggests audit, overriding build-time mode.',
76
- );
75
+ console.log('[detectEnvironment] Host suggests audit, overriding mode.');
77
76
  }
78
77
  }
79
78
 
@@ -12,11 +12,11 @@ This file is part of Network Pro.
12
12
  * Logs runtime environment variables for debugging purposes.
13
13
  * This function executes on the server during SSR and is used to verify
14
14
  * that environment variables (e.g., ENV_MODE and NODE_ENV) are properly
15
- * injected and available during runtime in Netlify's SSR context.
15
+ * injected and available during runtime in Vercel's SSR context.
16
16
  *
17
17
  * @module src/routes/status
18
18
  * @author Scott Lopez
19
- * @updated 2025-05-31
19
+ * @updated 2025-11-03
20
20
  */
21
21
 
22
22
  export const prerender = false;
package/vite.config.js CHANGED
@@ -31,6 +31,15 @@ export default defineConfig(({ mode }) => {
31
31
  console.log('ENV_MODE:', process.env.ENV_MODE);
32
32
  console.log('PUBLIC_ENV_MODE:', process.env.PUBLIC_ENV_MODE);
33
33
  console.log('NODE_ENV:', process.env.NODE_ENV);
34
+ if (
35
+ process.env.ENV_MODE === 'audit' ||
36
+ process.env.PUBLIC_ENV_MODE === 'audit' ||
37
+ mode === 'audit'
38
+ ) {
39
+ process.stderr.write(
40
+ 'πŸ”’ Audit Mode Detected β€” hardened CSP and no analytics will be applied.\n',
41
+ );
42
+ }
34
43
  console.log(
35
44
  '\x1b[36m%s\x1b[0m',
36
45
  '──────────────────────────────────────────────',
@@ -1,25 +0,0 @@
1
- /* ==========================================================================
2
- src/routes/api/env-check/+server.js
3
-
4
- Copyright Β© 2025 Network Pro Strategies (Network Proβ„’)
5
- SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
6
- This file is part of Network Pro.
7
- ========================================================================== */
8
-
9
- /**
10
- * @file Returns the current environment state (client + server vars)
11
- * @type {import('@sveltejs/kit').RequestHandler}
12
- */
13
- export async function GET() {
14
- const data = {
15
- NODE_ENV: process.env.NODE_ENV,
16
- ENV_MODE: process.env.ENV_MODE,
17
- PUBLIC_ENV_MODE: process.env.PUBLIC_ENV_MODE,
18
- IMPORT_META_MODE: import.meta.env.MODE,
19
- IMPORT_META_PUBLIC: import.meta.env.PUBLIC_ENV_MODE,
20
- };
21
-
22
- return new Response(JSON.stringify(data, null, 2), {
23
- headers: { 'Content-Type': 'application/json' },
24
- });
25
- }