@networkpro/web 1.26.1 → 1.26.3
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/.env.codex +10 -0
- package/.github/ISSUE_TEMPLATE/config.yml +1 -1
- package/.github/workflows/lighthouse.yml +1 -2
- package/.node-version +1 -1
- package/.nvmrc +1 -1
- package/.vscode/settings.json +3 -2
- package/CHANGELOG.md +56 -1
- package/CLAUDE.md +330 -0
- package/LICENSE.md +2 -2
- package/package.json +11 -8
- package/src/app.html +1 -1
- package/src/lib/stores/posthog.js +9 -0
- package/static/robots.txt +0 -1
- package/tests/unit/client/lib/unregisterServiceWorker.test.js +9 -1
- package/tests/unit/client/lib/utils/utm.test.js +8 -0
- package/tests/unit/server/lib/utils/purify.test.js +2 -2
package/.env.codex
ADDED
|
@@ -10,7 +10,7 @@ contact_links:
|
|
|
10
10
|
|
|
11
11
|
- name: Commonly asked questions
|
|
12
12
|
url: https://stackoverflowteams.com/c/netwk-pro/questions
|
|
13
|
-
about: 'Ask and answer common questions on Stack
|
|
13
|
+
about: 'Ask and answer common questions on Stack Internal.'
|
|
14
14
|
|
|
15
15
|
- name: Contact Network Pro Strategies
|
|
16
16
|
url: https://netwk.pro/contact?utm_source=github
|
|
@@ -13,8 +13,6 @@ on:
|
|
|
13
13
|
branches: [master]
|
|
14
14
|
workflow_dispatch:
|
|
15
15
|
|
|
16
|
-
# cspell:ignore tostring
|
|
17
|
-
|
|
18
16
|
# Sets permissions of the GITHUB_TOKEN to allow read access to repo and write
|
|
19
17
|
# permission for PRs for comment summary
|
|
20
18
|
permissions:
|
|
@@ -160,3 +158,4 @@ jobs:
|
|
|
160
158
|
path: .lighthouseci/
|
|
161
159
|
include-hidden-files: true
|
|
162
160
|
if-no-files-found: error
|
|
161
|
+
# cspell:ignore tostring
|
package/.node-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
24.
|
|
1
|
+
24.13.0
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
24.
|
|
1
|
+
24.13.0
|
package/.vscode/settings.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"eslint.workingDirectories": ["D:\\Netwk-Pro\\git\\netwk-pro.github.io"],
|
|
21
21
|
"eslint.validate": ["svelte", "javascript", "javascriptreact"],
|
|
22
22
|
"eslint.lintTask.enable": true,
|
|
23
|
-
"eslint.lintTask.options": ". --ext .mjs,.js,.svelte --config eslint.config.mjs",
|
|
23
|
+
"eslint.lintTask.options": ". --ext .mjs,.js,.cjs,.svelte --config eslint.config.mjs",
|
|
24
24
|
"eslint.useESLintClass": true,
|
|
25
25
|
"eslint.useFlatConfig": true,
|
|
26
26
|
"eslint.codeActionsOnSave.mode": "problems",
|
|
@@ -41,5 +41,6 @@
|
|
|
41
41
|
"css.customData": [
|
|
42
42
|
".vscode/customData.json" // Path to your custom data file
|
|
43
43
|
],
|
|
44
|
-
"markdown.validate.enabled": false
|
|
44
|
+
"markdown.validate.enabled": false,
|
|
45
|
+
"chatgpt.openOnStartup": true
|
|
45
46
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,59 @@ version increments reflecting both user-visible and operational impact.
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
+
## [1.26.3] - 2026-01-21
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Codex-aware analytics guard** in `src/lib/stores/posthog.js` to explicitly skip PostHog initialization when the application is executed by automation or AI-assisted tooling.
|
|
32
|
+
This prevents analytics side effects during non-interactive builds, cloud executions, and AI-driven analysis while preserving normal production behavior.
|
|
33
|
+
- **`.env.codex` environment configuration** to support Codex and similar automation tools.
|
|
34
|
+
This file defines a controlled, non-interactive execution context that mirrors production build semantics without enabling analytics or requiring secrets, enabling safe use of cloud-based AI and CI-style tooling.
|
|
35
|
+
- **`CLAUDE.md` project guidance file** to provide persistent, repository-level instructions for Claude Code and other AI-assisted development tools.
|
|
36
|
+
The file establishes clear expectations and constraints for AI usage, including:
|
|
37
|
+
- **AI guardrails** that prohibit changes to security posture, environment detection logic, deployment assumptions, or analytics behavior without explicit human approval.
|
|
38
|
+
- An explicit **Allowed AI Uses** section defining safe, permitted activities such as code comprehension, incremental feature development, bug fixing, testing, and documentation updates.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- **Project version bumped** to `v1.26.3`.
|
|
43
|
+
- **Dependency updates** to incorporate upstream fixes, improvements, and compatibility updates:
|
|
44
|
+
- `prettier` `3.8.0` → `3.8.1`
|
|
45
|
+
- `eslint-plugin-jsdoc` `^62.0.1` → `^62.3.0`
|
|
46
|
+
- `lightningcss` `^1.30.2` → `^1.31.1`
|
|
47
|
+
- `posthog-js` `^1.327.0` → `^1.334.0`
|
|
48
|
+
- `svelte` `5.46.4` → `5.48.0`
|
|
49
|
+
|
|
50
|
+
### Security
|
|
51
|
+
|
|
52
|
+
- **Updated transitive dependency override** to remediate a reported vulnerability:
|
|
53
|
+
- `tar` `7.5.3` → `7.5.6`
|
|
54
|
+
_(addresses CVE-2026-23950)_
|
|
55
|
+
- **Added transitive dependency override** to mitigate a reported vulnerability:
|
|
56
|
+
- `lodash` pinned to `4.17.23`
|
|
57
|
+
_(addresses CVE-2025-13465)_
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## [1.26.2] - 2026-01-17
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- Updated generator metadata in `src/app.html` to reflect **SvelteKit 2.50.0**.
|
|
66
|
+
- Updated `.nvmrc` and `.node-version` to utilize **Node.js** `v24.13.0`.
|
|
67
|
+
- Bumped project version to `v1.26.2`.
|
|
68
|
+
- Updated dependencies:
|
|
69
|
+
- `@sveltejs/kit` `2.49.5` → `2.50.0`
|
|
70
|
+
- `posthog-js` `^1.323.0` → `^1.327.0`
|
|
71
|
+
- `eslint-plugin-jsdoc` `^62.0.0` → `^62.0.1`
|
|
72
|
+
|
|
73
|
+
### Security
|
|
74
|
+
|
|
75
|
+
- Updated transitive dependency override to address reported vulnerabilities:
|
|
76
|
+
- `tar@7.5.2` → `tar@7.5.3` (addresses CVE-2026-23745).
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
27
80
|
## [1.26.1] - 2026-01-15
|
|
28
81
|
|
|
29
82
|
### Changed
|
|
@@ -2224,7 +2277,9 @@ This enables analytics filtering and CSP hardening for the audit environment.
|
|
|
2224
2277
|
|
|
2225
2278
|
<!-- Link references -->
|
|
2226
2279
|
|
|
2227
|
-
[Unreleased]: https://github.com/netwk-pro/netwk-pro.github.io/compare/v1.26.
|
|
2280
|
+
[Unreleased]: https://github.com/netwk-pro/netwk-pro.github.io/compare/v1.26.3...HEAD
|
|
2281
|
+
[1.26.3]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.26.3
|
|
2282
|
+
[1.26.2]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.26.2
|
|
2228
2283
|
[1.26.1]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.26.1
|
|
2229
2284
|
[1.26.0]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.26.0
|
|
2230
2285
|
[1.25.24]: https://github.com/netwk-pro/netwk-pro.github.io/releases/tag/v1.25.24
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
<!-- markdownlint-disable -->
|
|
6
|
+
|
|
7
|
+
## Project Overview
|
|
8
|
+
|
|
9
|
+
This is a **SvelteKit-based web presence** for Network Pro Strategies, deployed via Vercel. The codebase emphasizes security, privacy, and maintainability, and is distributed as both a production website and an npm package (`@networkpro/web`). It includes Progressive Web App (PWA) functionality with a custom service worker, strict Content Security Policy (CSP) configuration, and comprehensive testing.
|
|
10
|
+
|
|
11
|
+
## AI Guardrails
|
|
12
|
+
|
|
13
|
+
This repository may be worked on using AI-assisted tools (e.g., Claude Code). When doing so, the following guardrails apply:
|
|
14
|
+
|
|
15
|
+
- **Do not introduce new environment modes** or alter environment-detection logic (`src/lib/utils/env.js`) without explicit human approval.
|
|
16
|
+
- **Do not weaken security posture**: CSP rules, analytics gating, service worker exclusions, and audit-mode behavior must not be relaxed for convenience.
|
|
17
|
+
- **Do not invent or assume CI/CD workflows**: Deployment behavior must match existing infrastructure (Vercel for production, Netlify for audit via branch-scoped workflow).
|
|
18
|
+
- **Do not add or modify analytics, telemetry, or external network calls** without confirming consent and environment gating logic.
|
|
19
|
+
- **Do not refactor for style or abstraction alone** if it obscures intent, security checks, or explicit control flow.
|
|
20
|
+
- **Do not commit secrets or sensitive data**; environment files are strictly separated by purpose.
|
|
21
|
+
- **Prefer explicit, readable code over "clever" optimizations**, especially in security- or environment-related paths.
|
|
22
|
+
|
|
23
|
+
If a change would materially affect security, deployment behavior, environment resolution, or privacy guarantees, **pause and ask for confirmation** before proceeding.
|
|
24
|
+
|
|
25
|
+
AI tools should treat this file (`CLAUDE.md`) as authoritative guidance and defer to existing documentation and code comments where conflicts arise.
|
|
26
|
+
|
|
27
|
+
## Allowed AI Uses
|
|
28
|
+
|
|
29
|
+
AI-assisted tools may be used in this repository for the following purposes:
|
|
30
|
+
|
|
31
|
+
- **Code comprehension and explanation**: Explaining existing logic, security controls, environment detection, or architectural decisions.
|
|
32
|
+
- **Incremental feature development**: Implementing new features or routes that follow established patterns and respect existing constraints.
|
|
33
|
+
- **Bug fixing and debugging**: Identifying defects, edge cases, or test failures and proposing targeted fixes.
|
|
34
|
+
- **Test creation and improvement**: Writing or extending unit tests, integration tests, and E2E tests consistent with existing testing architecture.
|
|
35
|
+
- **Refactoring for clarity**: Improving readability, structure, or maintainability _without altering behavior, security posture, or environment semantics_.
|
|
36
|
+
- **Documentation updates**: Improving README files, comments, JSDoc, and other documentation to better reflect current behavior.
|
|
37
|
+
- **Dependency and configuration review**: Highlighting outdated dependencies, misconfigurations, or potential risks (without making changes unilaterally).
|
|
38
|
+
- **Accessibility and standards compliance**: Suggesting improvements related to a11y, web standards, or best practices, subject to review.
|
|
39
|
+
- **Clarifying questions**: Asking for confirmation when intent, risk, or trade-offs are unclear.
|
|
40
|
+
|
|
41
|
+
AI output should be treated as **assistance, not authority**. All changes are subject to human review and approval.
|
|
42
|
+
|
|
43
|
+
## Essential Commands
|
|
44
|
+
|
|
45
|
+
### Development
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run dev # Start dev server
|
|
49
|
+
npm run dev:audit # Dev server in audit mode (hardened CSP, no analytics)
|
|
50
|
+
npm run build # Production build
|
|
51
|
+
npm run build:audit # Audit build (for testing hardened CSP)
|
|
52
|
+
npm run preview # Preview production build locally
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Testing
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run test:all # Run all unit tests (client + server)
|
|
59
|
+
npm run test:client # Run client-side unit tests (jsdom)
|
|
60
|
+
npm run test:server # Run server-side unit tests (node)
|
|
61
|
+
npm run test:watch # Watch mode for client tests
|
|
62
|
+
npm run test:coverage # Generate coverage reports
|
|
63
|
+
npm run test:e2e # Run Playwright E2E tests (with 1 retry)
|
|
64
|
+
npm run lhci:run # Run Lighthouse CI audits
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Linting & Formatting
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npm run lint:all # Run all linters (JS, CSS, Markdown, Prettier)
|
|
71
|
+
npm run lint:fix # Auto-fix ESLint issues
|
|
72
|
+
npm run format:fix # Auto-fix Prettier formatting
|
|
73
|
+
npm run lint:css # Lint CSS and Svelte styles
|
|
74
|
+
npm run lint:md # Lint Markdown files
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Pre-commit Verification
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run checkout # Full verification (type-check, tests, linting)
|
|
81
|
+
npm run verify # Alias for checkout
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Single Test Execution
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Run a specific client test
|
|
88
|
+
npx vitest run tests/unit/client/path/to/test.test.js
|
|
89
|
+
|
|
90
|
+
# Run a specific server test
|
|
91
|
+
npx vitest run tests/unit/server/path/to/test.test.js
|
|
92
|
+
|
|
93
|
+
# Run a specific E2E test
|
|
94
|
+
npx playwright test tests/e2e/app.spec.js
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Architecture & Key Patterns
|
|
98
|
+
|
|
99
|
+
### Environment Management
|
|
100
|
+
|
|
101
|
+
The project uses a sophisticated multi-environment setup with behavior controlled by `ENV_MODE` and `PUBLIC_ENV_MODE`:
|
|
102
|
+
|
|
103
|
+
- **`development` / `dev`**: Local development with relaxed CSP, no analytics
|
|
104
|
+
- **`production` / `prod`**: Full CSP enforcement, PostHog analytics enabled, CSP reporting to production endpoint
|
|
105
|
+
- **`audit`**: Hardened environment for security testing—no analytics, no external connections, strict CSP
|
|
106
|
+
- **`test`**: CI/test mode with relaxed CSP for automation
|
|
107
|
+
- **`codex`**: Special mode for Claude Code development
|
|
108
|
+
|
|
109
|
+
**Critical**: Environment detection happens in two places:
|
|
110
|
+
|
|
111
|
+
1. **Build-time**: Via `import.meta.env.MODE` or `PUBLIC_ENV_MODE` (baked into bundle)
|
|
112
|
+
2. **Runtime**: Via hostname detection in `src/lib/utils/env.js` (e.g., `audit.netwk.pro` triggers audit mode)
|
|
113
|
+
|
|
114
|
+
The `detectEnvironment()` function in `src/lib/utils/env.js` unifies this logic and is used throughout the app.
|
|
115
|
+
|
|
116
|
+
### Content Security Policy (CSP)
|
|
117
|
+
|
|
118
|
+
CSP headers are dynamically generated in `src/hooks.server.js` based on environment:
|
|
119
|
+
|
|
120
|
+
- **Production**: Strict CSP with `Content-Security-Policy` header, real CSP reporting endpoint
|
|
121
|
+
- **Audit**: Hardened CSP with no analytics domains, no CSP reporting
|
|
122
|
+
- **Dev/Test**: Report-only mode (`Content-Security-Policy-Report-Only`) for debugging
|
|
123
|
+
|
|
124
|
+
**Current Trade-off**: The CSP allows `unsafe-inline` for scripts and styles due to PostHog and SvelteKit limitations. Moving to nonce-based CSP is a documented future goal (see README.md).
|
|
125
|
+
|
|
126
|
+
**Probely Scanner Allowlisting**: The `hooks.server.js` includes logic to detect and bypass security checks for Probely DAST scanners using `isProbelyScanner()` from `src/lib/security/probely.js`.
|
|
127
|
+
|
|
128
|
+
### Service Worker & PWA
|
|
129
|
+
|
|
130
|
+
The service worker is defined in `src/service-worker.js` and handles:
|
|
131
|
+
|
|
132
|
+
- Precaching of build artifacts and static files
|
|
133
|
+
- Runtime caching strategies (cache-first, network-first)
|
|
134
|
+
- Analytics domain blocking (PostHog never cached)
|
|
135
|
+
- Cache versioning and cleanup
|
|
136
|
+
|
|
137
|
+
**Registration**: `src/lib/registerServiceWorker.js` handles:
|
|
138
|
+
|
|
139
|
+
- SW registration and update lifecycle
|
|
140
|
+
- Cache cleanup (removes non-prefixed caches)
|
|
141
|
+
- Install prompt support (`beforeinstallprompt` event)
|
|
142
|
+
- Firefox localhost compatibility skip
|
|
143
|
+
- `?nosw` query parameter bypass via `static/disableSw.js`
|
|
144
|
+
|
|
145
|
+
### Route Structure
|
|
146
|
+
|
|
147
|
+
- **`+page.svelte`**: Page component
|
|
148
|
+
- **`+page.server.js`**: Server-side page load (metadata, redirects)
|
|
149
|
+
- **`+layout.svelte`**: Root layout with analytics init, MetaTags, header/footer
|
|
150
|
+
- **`+layout.js`**: Client-side layout load (pathname detection)
|
|
151
|
+
- **`+server.js`**: API endpoints (e.g., `/api/mock-csp`, `/pgp/[key]`)
|
|
152
|
+
|
|
153
|
+
**Special Routes**:
|
|
154
|
+
|
|
155
|
+
- `/pgp/[key]/+server.js`: Dynamic PGP key serving with proper Content-Type headers
|
|
156
|
+
- `/api/mock-csp/+server.js`: Mock CSP violation reporting endpoint for dev/test
|
|
157
|
+
- `/relay-[slug]/[...catchall]/+server.js`: Dynamic redirect handler
|
|
158
|
+
|
|
159
|
+
### Component Organization
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
src/lib/
|
|
163
|
+
├── components/ # Reusable Svelte components
|
|
164
|
+
│ ├── layout/ # Header, Footer
|
|
165
|
+
│ └── foss/ # FOSS-specific components
|
|
166
|
+
├── pages/ # Page-specific content components (e.g., AboutContent.svelte)
|
|
167
|
+
├── data/ # Static data (fossData.js, pgpKeys.js)
|
|
168
|
+
├── stores/ # Svelte stores (posthog.js, trackingPreferences.js)
|
|
169
|
+
├── utils/ # Helper utilities (env.js, utm.js, purify.js)
|
|
170
|
+
├── types/ # Type definitions and constants
|
|
171
|
+
├── styles/ # Global CSS
|
|
172
|
+
└── security/ # Security utilities (probely.js)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Import Pattern**: Use `$lib` alias for all internal imports (configured in `jsconfig.json` via `vite-tsconfig-paths`).
|
|
176
|
+
|
|
177
|
+
### Analytics & Tracking
|
|
178
|
+
|
|
179
|
+
PostHog is initialized in `src/lib/stores/posthog.js` and conditionally loaded based on:
|
|
180
|
+
|
|
181
|
+
- Environment (disabled in audit, test, dev)
|
|
182
|
+
- User consent (tracked in `trackingPreferences.js` store)
|
|
183
|
+
- Browser support
|
|
184
|
+
|
|
185
|
+
**Key Functions**:
|
|
186
|
+
|
|
187
|
+
- `initPostHog()`: Initializes PostHog with consent checking
|
|
188
|
+
- `capture(event)`: Wrapper for PostHog event capture
|
|
189
|
+
- `showReminder`: Svelte store for tracking consent banner state
|
|
190
|
+
|
|
191
|
+
Analytics initialization happens in `src/lib/utils/initAnalytics.js`, called from `+layout.svelte`.
|
|
192
|
+
|
|
193
|
+
### Testing Architecture
|
|
194
|
+
|
|
195
|
+
**Unit Tests**: Split into client (jsdom) and server (node) contexts with separate Vitest configs:
|
|
196
|
+
|
|
197
|
+
- `tests/unit/client/`: Browser-environment tests (components, client utils)
|
|
198
|
+
- `tests/unit/server/`: Node-environment tests (server utils, API endpoints)
|
|
199
|
+
- `tests/unit/server/internal/auditCoverage.test.js`: Warns about untested source files
|
|
200
|
+
|
|
201
|
+
**E2E Tests**: Playwright tests in `tests/e2e/`:
|
|
202
|
+
|
|
203
|
+
- `app.spec.js`: Desktop and mobile route tests
|
|
204
|
+
- `mobile.spec.js`: Mobile-specific assertions
|
|
205
|
+
- `shared/helpers.js`: Shared test utilities (viewport helpers, element getters)
|
|
206
|
+
|
|
207
|
+
**Coverage Audit**: The project includes a coverage audit that warns (but doesn't fail) when source files lack corresponding unit tests.
|
|
208
|
+
|
|
209
|
+
## Configuration Files
|
|
210
|
+
|
|
211
|
+
- **`svelte.config.js`**: SvelteKit config with Vercel adapter, prerender error handling
|
|
212
|
+
- **`vite.config.js`**: Vite config with SvelteKit, LightningCSS, devtools-json plugins
|
|
213
|
+
- **`vitest.config.client.js`**: Client-side unit test config (jsdom environment)
|
|
214
|
+
- **`vitest.config.server.js`**: Server-side unit test config (node environment)
|
|
215
|
+
- **`playwright.config.js`**: E2E test config (Chromium, Firefox, WebKit)
|
|
216
|
+
- **`.lighthouserc.cjs`**: Lighthouse CI audit configuration
|
|
217
|
+
- **`postcss.config.cjs`**: PostCSS with autoprefixer
|
|
218
|
+
- **`vercel.json`**: Vercel deployment config
|
|
219
|
+
|
|
220
|
+
## Development Workflows
|
|
221
|
+
|
|
222
|
+
### Adding a New Route
|
|
223
|
+
|
|
224
|
+
1. Create `src/routes/your-route/+page.svelte`
|
|
225
|
+
2. Create `src/routes/your-route/+page.server.js` for metadata:
|
|
226
|
+
```javascript
|
|
227
|
+
export function load() {
|
|
228
|
+
return {
|
|
229
|
+
meta: {
|
|
230
|
+
title: 'Your Page Title',
|
|
231
|
+
description: 'Your page description',
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
3. Add corresponding E2E test in `tests/e2e/app.spec.js`
|
|
237
|
+
4. Update sitemap at `static/sitemap.xml` if needed
|
|
238
|
+
|
|
239
|
+
### Adding a New Component
|
|
240
|
+
|
|
241
|
+
1. Create component in `src/lib/components/YourComponent.svelte`
|
|
242
|
+
2. Export from `src/lib/components/index.js` if it's shared
|
|
243
|
+
3. Add unit test in `tests/unit/client/components/YourComponent.test.js`
|
|
244
|
+
4. Use `$lib/components` alias for imports
|
|
245
|
+
|
|
246
|
+
### Modifying CSP
|
|
247
|
+
|
|
248
|
+
1. Edit `src/hooks.server.js` and update `cspDirectives` array
|
|
249
|
+
2. Test in audit mode: `npm run dev:audit`
|
|
250
|
+
3. Check CSP violations in browser console or `/api/mock-csp` logs
|
|
251
|
+
4. Update tests if needed
|
|
252
|
+
|
|
253
|
+
### Adding Analytics Events
|
|
254
|
+
|
|
255
|
+
1. Import `capture` from `$lib/stores/posthog`
|
|
256
|
+
2. Call `capture('event_name', { properties })` in client-side code
|
|
257
|
+
3. Events are automatically gated by consent and environment checks
|
|
258
|
+
|
|
259
|
+
## Important Constraints
|
|
260
|
+
|
|
261
|
+
### Security Considerations
|
|
262
|
+
|
|
263
|
+
- **Never commit sensitive data**: Use `.env` for local secrets, never `.env.template`
|
|
264
|
+
- **CSP compliance**: All inline scripts/styles must work with `unsafe-inline` or be refactored for nonces
|
|
265
|
+
- **Service worker**: Analytics domains (PostHog) are explicitly excluded from SW caching
|
|
266
|
+
- **PGP keys**: `.asc` files in `static/pgp/` are served directly, not precached
|
|
267
|
+
|
|
268
|
+
### Code Quality Standards
|
|
269
|
+
|
|
270
|
+
- **No emojis** in commit messages or code comments unless explicitly requested
|
|
271
|
+
- **Copyright headers** required on all source files
|
|
272
|
+
- **ESLint + Prettier** enforced via pre-commit hooks
|
|
273
|
+
- **Stylelint** for CSS/Svelte style validation
|
|
274
|
+
- **JSDoc** required for exported functions
|
|
275
|
+
|
|
276
|
+
### Build Requirements
|
|
277
|
+
|
|
278
|
+
- **Node.js**: >= 22.0.0, < 25
|
|
279
|
+
- **npm**: >= 10.0.0, < 12
|
|
280
|
+
- Enforced via `engines` in `package.json` and `scripts/checkNode.js`
|
|
281
|
+
|
|
282
|
+
### Testing Requirements
|
|
283
|
+
|
|
284
|
+
- Unit tests should use appropriate environment (client vs. server)
|
|
285
|
+
- E2E tests automatically retry once to reduce flakiness
|
|
286
|
+
- Coverage audit warns about untested files but doesn't fail CI
|
|
287
|
+
|
|
288
|
+
## Common Gotchas
|
|
289
|
+
|
|
290
|
+
1. **Service Worker Caching**: Use `?nosw` query param to bypass SW for testing
|
|
291
|
+
2. **Environment Detection**: Remember that `audit.netwk.pro` hostname overrides build mode
|
|
292
|
+
3. **CSP Violations**: Check browser console in dev mode; violations are logged to `/api/mock-csp`
|
|
293
|
+
4. **PostHog Initialization**: Happens asynchronously; use `$isInitialized` store to check status
|
|
294
|
+
5. **Static Asset Imports**: Use Vite's `import` syntax (e.g., `import logo from '$lib/img/logo.png'`)
|
|
295
|
+
6. **Prerendering**: Some routes are prerendered at build time; check `svelte.config.js` error handlers
|
|
296
|
+
|
|
297
|
+
## Debugging Tips
|
|
298
|
+
|
|
299
|
+
- **Enable debug mode**: Add `?debug=true` to URL for verbose console logs
|
|
300
|
+
- **Disable service worker**: Add `?nosw` to URL to bypass SW caching
|
|
301
|
+
- **Check environment**: Use `detectEnvironment()` in any file to see current env flags
|
|
302
|
+
- **View CSP violations**: Check `/api/mock-csp` endpoint logs in dev mode
|
|
303
|
+
- **Playwright UI mode**: Run `npx playwright test --ui` for interactive debugging
|
|
304
|
+
|
|
305
|
+
## Deployment Environments
|
|
306
|
+
|
|
307
|
+
- **Production**
|
|
308
|
+
- URL: `https://netwk.pro`
|
|
309
|
+
- Hosting: **Vercel**
|
|
310
|
+
- Deployment model: Automatic builds and deployments triggered by merges to `master`
|
|
311
|
+
- CI: Managed by Vercel (not GitHub Actions)
|
|
312
|
+
|
|
313
|
+
- **Audit**
|
|
314
|
+
- URL: `https://audit.netwk.pro`
|
|
315
|
+
- Hosting: **Netlify**
|
|
316
|
+
- Purpose: Hardened security environment (strict CSP, no analytics, no external reporting)
|
|
317
|
+
- Deployment model:
|
|
318
|
+
- Built and deployed via a GitHub Actions workflow
|
|
319
|
+
- Workflow file: `.github/workflows/deploy-audit-netlify.yml`
|
|
320
|
+
- Workflow exists **only on the `audit-netlify` branch**
|
|
321
|
+
- Deployments are intentionally decoupled from production
|
|
322
|
+
|
|
323
|
+
- **Preview**
|
|
324
|
+
- Hosting: Vercel
|
|
325
|
+
- Trigger: Pull requests and non-`master` branches
|
|
326
|
+
- Purpose: Ephemeral previews for review and testing
|
|
327
|
+
|
|
328
|
+
**Note**: There is no single CI/CD pipeline shared by all environments. Production relies on Vercel’s native build system, while the audit environment uses a dedicated, branch-scoped GitHub Actions workflow.
|
|
329
|
+
|
|
330
|
+
<!-- cspell:ignore prerender precached Prerendering prerendered -->
|
package/LICENSE.md
CHANGED
|
@@ -6,11 +6,11 @@ SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
|
|
|
6
6
|
This file is part of Network Pro.
|
|
7
7
|
====================================================================== -->
|
|
8
8
|
|
|
9
|
+
<a name="top"></a>
|
|
10
|
+
|
|
9
11
|
<sup>[SPDX-License-Identifier](https://spdx.dev/learn/handling-license-info/):
|
|
10
12
|
`CC-BY-4.0 OR GPL-3.0-or-later`</sup>
|
|
11
13
|
|
|
12
|
-
<a name="top"></a>
|
|
13
|
-
|
|
14
14
|
# Legal, Copyright, and Licensing
|
|
15
15
|
|
|
16
16
|
**Network Pro Strategies**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@networkpro/web",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.26.
|
|
4
|
+
"version": "1.26.3",
|
|
5
5
|
"description": "Locking Down Networks, Unlocking Confidence™ | Security, Networking, Privacy — Network Pro Strategies",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"advocacy",
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
"build": "vite build --mode production",
|
|
44
44
|
"build:audit": "vite build --mode audit",
|
|
45
45
|
"build:vercel": "vercel build",
|
|
46
|
+
"build:codex": "vite build --mode codex",
|
|
47
|
+
"dev:codex": "vite dev --mode codex",
|
|
46
48
|
"preview": "vite preview",
|
|
47
49
|
"css:bundle": "node scripts/bundleCss.js",
|
|
48
50
|
"prepare": "svelte-kit sync && npx simple-git-hooks || echo ''",
|
|
@@ -88,9 +90,9 @@
|
|
|
88
90
|
},
|
|
89
91
|
"dependencies": {
|
|
90
92
|
"dompurify": "^3.3.1",
|
|
91
|
-
"posthog-js": "^1.
|
|
93
|
+
"posthog-js": "^1.334.0",
|
|
92
94
|
"semver": "^7.7.3",
|
|
93
|
-
"svelte": "5.
|
|
95
|
+
"svelte": "5.48.0"
|
|
94
96
|
},
|
|
95
97
|
"devDependencies": {
|
|
96
98
|
"@eslint/compat": "^2.0.1",
|
|
@@ -99,7 +101,7 @@
|
|
|
99
101
|
"@playwright/test": "^1.57.0",
|
|
100
102
|
"@sveltejs/adapter-netlify": "^5.2.4",
|
|
101
103
|
"@sveltejs/adapter-vercel": "^6.3.0",
|
|
102
|
-
"@sveltejs/kit": "2.
|
|
104
|
+
"@sveltejs/kit": "2.50.0",
|
|
103
105
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
104
106
|
"@testing-library/jest-dom": "^6.9.1",
|
|
105
107
|
"@testing-library/svelte": "^5.3.1",
|
|
@@ -108,18 +110,18 @@
|
|
|
108
110
|
"browserslist": "^4.28.1",
|
|
109
111
|
"eslint": "^9.39.2",
|
|
110
112
|
"eslint-config-prettier": "^10.1.8",
|
|
111
|
-
"eslint-plugin-jsdoc": "^62.
|
|
113
|
+
"eslint-plugin-jsdoc": "^62.3.0",
|
|
112
114
|
"eslint-plugin-svelte": "^3.14.0",
|
|
113
115
|
"globals": "^17.0.0",
|
|
114
116
|
"globby": "^16.1.0",
|
|
115
117
|
"jsdom": "27.4.0",
|
|
116
|
-
"lightningcss": "^1.
|
|
118
|
+
"lightningcss": "^1.31.1",
|
|
117
119
|
"markdownlint": "^0.40.0",
|
|
118
120
|
"markdownlint-cli2": "0.20.0",
|
|
119
121
|
"npm-run-all": "^4.1.5",
|
|
120
122
|
"playwright": "^1.57.0",
|
|
121
123
|
"postcss": "^8.5.6",
|
|
122
|
-
"prettier": "3.8.
|
|
124
|
+
"prettier": "3.8.1",
|
|
123
125
|
"prettier-plugin-svelte": "^3.4.1",
|
|
124
126
|
"simple-git-hooks": "^2.13.1",
|
|
125
127
|
"stylelint": "^17.0.0",
|
|
@@ -140,8 +142,9 @@
|
|
|
140
142
|
"cookie": "^1.0.0",
|
|
141
143
|
"glob": "^11.1.0",
|
|
142
144
|
"js-yaml": "^4.1.1",
|
|
145
|
+
"lodash": "^4.17.23",
|
|
143
146
|
"qs": "^6.14.1",
|
|
144
|
-
"tar": "^7.5.
|
|
147
|
+
"tar": "^7.5.6",
|
|
145
148
|
"tmp": "^0.2.4"
|
|
146
149
|
}
|
|
147
150
|
}
|
package/src/app.html
CHANGED
|
@@ -49,6 +49,15 @@ export async function initPostHog() {
|
|
|
49
49
|
const { isAudit, isDebug, isDev, isTest, mode, effective } =
|
|
50
50
|
detectEnvironment();
|
|
51
51
|
|
|
52
|
+
const isCodex =
|
|
53
|
+
import.meta.env.PUBLIC_CODEX === 'true' || import.meta.env.CODEX === 'true';
|
|
54
|
+
|
|
55
|
+
// 🤖 Skip analytics entirely in Codex environments
|
|
56
|
+
if (isCodex) {
|
|
57
|
+
console.info('[PostHog] Skipping analytics (Codex environment).');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
// 🌐 Hybrid hostname + environment guard
|
|
53
62
|
const host = window.location.hostname;
|
|
54
63
|
const isAuditHost = /(^|\.)audit\.netwk\.pro$/i.test(host);
|
package/static/robots.txt
CHANGED
|
@@ -6,8 +6,16 @@ SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
|
|
|
6
6
|
This file is part of Network Pro.
|
|
7
7
|
========================================================================== */
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @file unregisterServiceWorker.test.js
|
|
11
|
+
* @description Unit test for unregisterServiceWorker.js
|
|
12
|
+
* @module tests/unit/client/lib
|
|
13
|
+
* @author Scott Lopez
|
|
14
|
+
* @updated 2026-01-15
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { unregisterServiceWorker } from '$lib/unregisterServiceWorker.js';
|
|
9
18
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
10
|
-
import { unregisterServiceWorker } from '../../../../src/lib/unregisterServiceWorker.js';
|
|
11
19
|
|
|
12
20
|
describe('unregisterServiceWorker()', () => {
|
|
13
21
|
beforeEach(() => {
|
|
@@ -6,6 +6,14 @@ SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
|
|
|
6
6
|
This file is part of Network Pro.
|
|
7
7
|
========================================================================== */
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @file utm.test.js
|
|
11
|
+
* @description Unit test for UTM parameters
|
|
12
|
+
* @module tests/unit/client/lib/utils
|
|
13
|
+
* @author Scott Lopez
|
|
14
|
+
* @updated 2026-01-15
|
|
15
|
+
*/
|
|
16
|
+
|
|
9
17
|
// Mock SvelteKit environment and store
|
|
10
18
|
vi.mock('$app/environment', () => ({ browser: true }));
|
|
11
19
|
|
|
@@ -11,11 +11,11 @@ This file is part of Network Pro.
|
|
|
11
11
|
* @description Unit test for src/lib/utils/purify.js
|
|
12
12
|
* @module tests/unit/lib/util
|
|
13
13
|
* @author Scott Lopez
|
|
14
|
-
* @updated
|
|
14
|
+
* @updated 2026-01-15
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { sanitizeHtml } from '$lib/utils/purify.js';
|
|
17
18
|
import { describe, expect, it } from 'vitest';
|
|
18
|
-
import { sanitizeHtml } from '../../../../../src/lib/utils/purify.js';
|
|
19
19
|
|
|
20
20
|
describe('sanitizeHtml', () => {
|
|
21
21
|
it('removes dangerous tags like <script>', async () => {
|