@networkpro/web 1.11.0 → 1.12.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.
@@ -0,0 +1,152 @@
1
+ # 📧 Encrypting Email with PGP
2
+
3
+ > This guide walks you through using PGP (Pretty Good Privacy) to encrypt email using both graphical and client-based tools.
4
+
5
+ PGP encryption ensures that only the intended recipient can read your email content — even if it's intercepted.
6
+
7
+ ---
8
+
9
+ ## 🔹 Option A: Outlook (Windows) with GpgOL
10
+
11
+ GpgOL is a plugin included with **Gpg4win** that integrates directly into Microsoft Outlook (desktop only).
12
+
13
+ ### ✅ Requirements
14
+
15
+ - Gpg4win (with GpgOL selected during installation)
16
+ - Outlook 2010 or newer (desktop version)
17
+ - Recipient’s **public key**
18
+
19
+ > ⚠️ GpgOL does not work with Outlook for Microsoft 365 Web or Outlook Mobile. It is only compatible with the **desktop edition of Outlook** on Windows.
20
+
21
+ ### 📥 Encrypting an Email in Outlook
22
+
23
+ 1. Open Outlook and compose a new message
24
+ 2. Enter the recipient’s email address (must match imported key)
25
+ 3. Click the `Encrypt` button on the **GpgOL ribbon** tab
26
+ 4. Send your email
27
+
28
+ > ✉️ Outlook will encrypt the email contents using the recipient's public key.
29
+
30
+ ### 📥 Decrypting an Email in Outlook
31
+
32
+ When receiving an encrypted message:
33
+
34
+ - GpgOL will automatically prompt to decrypt it using your private key
35
+ - You may need to enter your key passphrase
36
+
37
+ > 💡 Tip: Manage keys with **Kleopatra** — launch from Start Menu
38
+
39
+ ---
40
+
41
+ ## 🔹 Option B: Thunderbird (Windows/macOS/Linux)
42
+
43
+ Thunderbird includes **built-in OpenPGP** support and is often preferred for privacy-focused users.
44
+
45
+ ### ✅ Setup
46
+
47
+ 1. [Download Thunderbird](https://www.thunderbird.net)
48
+ 2. Add your email account
49
+ 3. Go to: `Account Settings → End-to-End Encryption`
50
+ 4. Generate a new key, or import your existing one
51
+ 5. Import your recipient’s **public key**
52
+
53
+ ### 🔐 Sending Encrypted Email
54
+
55
+ When composing a message:
56
+
57
+ - Click the **padlock** icon to enable encryption
58
+ - Click **sign** if you also want to verify authenticity
59
+ - Send as usual
60
+
61
+ ---
62
+
63
+ ## 🔹 Option C: Webmail with Mailvelope
64
+
65
+ **Mailvelope** adds OpenPGP support to Gmail, Outlook.com, Yahoo, and others.
66
+
67
+ ### 🔧 Setup
68
+
69
+ 1. Install [Mailvelope](https://www.mailvelope.com/) for Chrome or Firefox
70
+ 2. Import your keys or generate a new pair
71
+ 3. Use the Mailvelope overlay when composing encrypted emails
72
+
73
+ ---
74
+
75
+ ## Alternative PGP-Compatible Email Clients
76
+
77
+ In addition to widely used options like Outlook (via GpgOL) and Thunderbird, several other desktop email clients offer OpenPGP support—either natively or through plugins.
78
+
79
+ Notable alternatives include:
80
+
81
+ - **[Betterbird](https://www.betterbird.eu/):**
82
+ A privacy-focused Thunderbird fork with full PGP support.
83
+ ▸ Available on Windows, Linux, and macOS.
84
+
85
+ - **[eM Client](https://www.emclient.com/):**
86
+ A feature-rich client with native OpenPGP integration and calendar/task support.
87
+ ▸ Available on Windows, macOS, Android, and iOS.
88
+ ▸ _Free tier supports 2 email accounts after a 30-day trial._
89
+
90
+ > 💡 **Note:** Be sure to verify the client’s compatibility with your GPG keyring (e.g., Gpg4win or Kleopatra on Windows).
91
+
92
+ ---
93
+
94
+ ## 📱 Mobile Email Clients with OpenPGP Support
95
+
96
+ For secure email on Android, the following apps support OpenPGP encryption via [**OpenKeychain**](https://www.openkeychain.org/):
97
+
98
+ - **[FairEmail](https://email.faircode.eu/)**
99
+ A lightweight, privacy-first email client for Android, offering built-in OpenPGP support, rich customization, and a modern, privacy-respecting interface.
100
+
101
+ - **[K-9 Mail](https://k9mail.app/)**
102
+ A veteran open-source Android mail client known for its simplicity and transparency. K-9 is now maintained by the Thunderbird team as part of their mobile strategy.
103
+
104
+ - **[Thunderbird Mobile](https://www.thunderbird.net/en-US/mobile/)**
105
+ A mobile adaptation of Thunderbird, currently built on K-9 Mail and maintained by the same team. Provides end-to-end encryption and an open-source, user-friendly experience.
106
+
107
+ > ⚠️ OpenPGP support on iOS is limited due to platform restrictions.
108
+ > Most options are proprietary or require external tools, and may not provide full compatibility with standard PGP workflows.
109
+
110
+ ---
111
+
112
+ ## 📤 Exporting and Sharing Public Keys
113
+
114
+ You can export your public key from **Kleopatra**, Thunderbird, or the command line, and share it via:
115
+
116
+ - Your website
117
+ - A keyserver (e.g., [keys.openpgp.org](https://keys.openpgp.org))
118
+ - Your GitHub profile (e.g., in `SECURITY.md` or a `PGP-KEY.asc` file)
119
+
120
+ ### 🔧 Export via Command Line
121
+
122
+ If you’re using GnuPG directly:
123
+
124
+ ```sh
125
+ gpg --armor --export your@email.com > publickey.asc
126
+ ```
127
+
128
+ This creates a text-formatted (`.asc`) version of your public key that’s easy to upload or embed.
129
+
130
+ > 💡 Replace `your@email.com` with the email associated with your PGP key.
131
+
132
+ ---
133
+
134
+ ## 🛠 Troubleshooting Tips
135
+
136
+ - Ensure email address in key matches recipient’s address
137
+ - Key must be **trusted/imported** before encryption works
138
+ - For Outlook, restart if GpgOL ribbon does not appear
139
+ - Thunderbird may require re-indexing of OpenPGP keyring
140
+
141
+ ---
142
+
143
+ ## 📚 Learn More
144
+
145
+ - [Gpg4win Documentation](https://gpg4win.org/documentation.html)
146
+ - [How to Encrypt Emails with OpenPGP in Thunderbird (2022)](https://www.linuxbabe.com/security/encrypt-emails-gpg-thunderbird)
147
+ - [Mozilla OpenPGP Docs](https://support.mozilla.org/en-US/kb/openpgp-thunderbird-how-does-it-work)
148
+ - [Mailvelope Overview](https://www.mailvelope.com/help)
149
+
150
+ ---
151
+
152
+ > 🔐 PGP protects your communication, but both parties must be using it correctly. Always test before sending sensitive content.
@@ -0,0 +1,67 @@
1
+ # 💻 Using PGP on Windows (Gpg4win & Kleopatra)
2
+
3
+ ## This section walks through encrypting a message or file using **Gpg4win** and its GUI tool **Kleopatra**
4
+
5
+ ### 📦 1. Install Gpg4win
6
+
7
+ - Download from: [https://gpg4win.org](https://gpg4win.org)
8
+ - During setup, make sure **Kleopatra** is selected.
9
+
10
+ ---
11
+
12
+ ### 🔑 2. Import the Recipient’s Public Key
13
+
14
+ 1. Open **Kleopatra**
15
+ 2. Click `File` → `Import Certificates…`
16
+ 3. Select the `.asc` or `.gpg` file you downloaded
17
+ 4. Confirm the fingerprint matches the published value
18
+
19
+ ---
20
+
21
+ ### ✍️ 3. Encrypt a Message (Text)
22
+
23
+ 1. In Kleopatra, go to `Tools` → `Clipboard` → `Encrypt`
24
+ 2. Paste your message
25
+ 3. Select the recipient’s public key
26
+ 4. Click **Encrypt**
27
+ 5. Copy or save the armored output (begins with `-----BEGIN PGP MESSAGE-----`)
28
+
29
+ You can now send that encrypted message via email or any communication platform.
30
+
31
+ ---
32
+
33
+ ### 📁 4. Encrypt a File
34
+
35
+ 1. Right-click on any file (e.g., PDF or TXT)
36
+ 2. Choose **More GpgEX options** → **Encrypt**
37
+ 3. Select the recipient key
38
+ 4. The encrypted file will be saved with a `.gpg` extension
39
+
40
+ ---
41
+
42
+ ### 🔓 5. Decrypt a Message or File
43
+
44
+ To decrypt a file:
45
+
46
+ - Right-click `.gpg` file → **Decrypt and verify**
47
+
48
+ To decrypt a clipboard message:
49
+
50
+ - In Kleopatra, go to `Tools` → `Clipboard` → `Decrypt/Verify`
51
+ - Paste the encrypted message
52
+ - Kleopatra will prompt for your private key if needed
53
+
54
+ ---
55
+
56
+ ### 🧠 Tips for Windows Users
57
+
58
+ - Your private key is protected by a passphrase — never share it.
59
+ - You can export your public key for others to encrypt messages to you.
60
+ - Kleopatra also supports **signing** files and messages to verify your identity.
61
+
62
+ ---
63
+
64
+ 📘 For full walkthroughs, see:
65
+
66
+ - [Gpg4win Documentation](https://gpg4win.org/documentation.html)
67
+ - [Kleopatra User Guide (PDF)](https://files.gpg4win.org/doc/gpg4win-compendium-en.pdf)
@@ -0,0 +1,71 @@
1
+ # 🔐 How to Encrypt Messages Using PGP
2
+
3
+ This guide explains how to encrypt a message or file using PGP (Pretty Good Privacy) for secure communication with **Network Pro Strategies** or any contact with a published PGP key.
4
+
5
+ ---
6
+
7
+ ## 📥 1. Obtain the Recipient's Public Key
8
+
9
+ You can find the official public key at:
10
+
11
+ - [https://netwk.pro/pgp](https://netwk.pro/pgp)
12
+ - Or via GitHub, Keybase, or direct contact
13
+
14
+ Make sure the key fingerprint matches what the recipient advertises.
15
+
16
+ ---
17
+
18
+ ## 🔧 2. Import the Public Key
19
+
20
+ Save the public key as a `.asc` or `.gpg` file, then run:
21
+
22
+ ```bash
23
+ gpg --import path/to/public-key.asc
24
+ ```
25
+
26
+ You can confirm the key is imported:
27
+
28
+ ```bash
29
+ gpg --list-keys
30
+ ```
31
+
32
+ ## 🔏 3. Encrypt a Message
33
+
34
+ To encrypt a plain text file (e.g. message.txt) for the recipient:
35
+
36
+ ```bash
37
+ gpg --encrypt --armor --recipient recipient@example.com message.txt
38
+ ```
39
+
40
+ - --armor creates ASCII-formatted output
41
+ - Output is saved as message.txt.asc
42
+
43
+ ## 🔏 4. Encrypt a File (Binary or Attachment)
44
+
45
+ ```bash
46
+ gpg --encrypt --recipient recipient@example.com file.pdf
47
+ ```
48
+
49
+ This will create file.pdf.gpg, which you can send securely.
50
+
51
+ ## 🔓 Optional: Decrypting (For Testing)
52
+
53
+ If you're the recipient and want to decrypt a file:
54
+
55
+ ```bash
56
+ gpg --decrypt file.txt.asc
57
+ ```
58
+
59
+ ## 🔐 Tips
60
+
61
+ - Always verify the recipient’s key fingerprint.
62
+ - Never share your private key.
63
+ - Use a strong passphrase to protect your keypair.
64
+
65
+ ---
66
+
67
+ 📘 For more help, see:
68
+
69
+ - [GnuPG Documentation](https://gnupg.org/documentation/)
70
+ - [A Practical Guide to GPG](https://www.linuxbabe.com/security/a-practical-guide-to-gpg-part-1-generate-your-keypair)
71
+ - [OpenPGP Best Practices](https://help.riseup.net/en/security/message-security/openpgp/best-practices)
@@ -0,0 +1,63 @@
1
+ # Tracking Preferences & Privacy Signals
2
+
3
+ <!-- markdownlint-disable MD018 -->
4
+
5
+ ## Overview
6
+
7
+ This document explains how Network Pro handles analytics tracking in a privacy-aware, user-consented, and standards-compliant manner. It covers:
8
+
9
+ - Tracking preference storage (cookies)
10
+ - Browser signals (DNT and GPC)
11
+ - Reconsent logic
12
+ - Reactive store architecture
13
+
14
+ ### 🔐 Principles
15
+
16
+ - **Privacy by default**: Tracking is disabled when browser signals indicate user preference (DNT/GPC).
17
+ - **Explicit consent**: Users may opt-in or opt-out manually, overriding signals.
18
+ - **Persistent choice**: Consent state is remembered via first-party cookies.
19
+ - **Transparency**: The tracking status is shown to users in the UI.
20
+
21
+ ### 🧠 Architecture Summary
22
+
23
+ - **Store**: `src/lib/stores/trackingPreferences.js`
24
+ - Consolidates logic for cookie preferences, browser signals, and consent state.
25
+ - SSR-safe, reactive, and fully declarative.
26
+ - **Deprecated**:
27
+ - `utils/privacy.js` → replaced by derived store logic.
28
+ - `utils/trackingCookies.js` → merged into the store with SSR-safe cookie APIs.
29
+
30
+ ### Reactive State
31
+
32
+ | Store | Type | Description |
33
+ | ----------------------- | ------------------------- | ----------------------------------------------------------------------- |
34
+ | `trackingPreferences` | `Readable<TrackingState>` | Contains current tracking metadata (opt-in/out, DNT, GPC, status, etc). |
35
+ | `trackingEnabled` | `Writable<boolean>` | Exposed to toggle or query PostHog tracking state reactively. |
36
+ | `remindUserToReconsent` | `Readable<boolean>` | Indicates whether a consent renewal prompt should be shown. |
37
+ | `showReminder` | `Writable<boolean>` | Used by PostHog to conditionally display a reminder or banner. |
38
+
39
+ ### ⏳ Reconsent Logic
40
+
41
+ The derived store `remindUserToReconsent` evaluates whether a user should be reminded to re-consent to tracking.
42
+
43
+ It checks for:
44
+
45
+ - Manual opt-in or opt-out
46
+ - A valid `tracking_consent_timestamp` cookie
47
+ - Whether 6+ months have elapsed since that timestamp
48
+
49
+ ### ⚙️ Developer Notes
50
+
51
+ - Changes to tracking preferences update cookies and reactive state
52
+ - Reconsent timestamp is written/cleared via store utility functions
53
+ - Use `$trackingPreferences` and `remindUserToReconsent` wherever reactive values are needed
54
+
55
+ ### 💡 Related Components
56
+
57
+ | File | Purpose |
58
+ | ------------------------------- | -------------------------------------------------------------------------------- |
59
+ | `+layout.svelte` | Initializes PostHog client and service worker; references `trackingPreferences`. |
60
+ | `PrivacyDashboard.svelte` | UI control panel for opt-in/out toggles and consent status display. |
61
+ | `PrivacyContent.svelte` | Informational content rendered in modals, footers, and standalone pages. |
62
+ | `stores/trackingPreferences.js` | Primary source of truth; tracks and derives tracking state. |
63
+ | `stores/posthog.js` | Encapsulates privacy-safe analytics setup and event capture logic. |
Binary file
package/svelte.config.js CHANGED
@@ -23,7 +23,7 @@ const config = {
23
23
  kit: {
24
24
  // Netlify adapter configuration
25
25
  adapter: adapter({
26
- edge: false, // Disable edge functions for site
26
+ edge: false, // Disable edge functions (optional, enable if needed)
27
27
  split: false, // Disable splitting function files (optional, enable if needed)
28
28
  }),
29
29
 
@@ -1,173 +0,0 @@
1
- <!-- =========================================================================
2
- CODE_OF_CONDUCT.md
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
- <a name="top"></a>
10
-
11
- <sup>[SPDX-License-Identifier](https://spdx.dev/learn/handling-license-info):
12
- `CC-BY-4.0 OR GPL-3.0-or-later`</sup>
13
-
14
- # Contributor Covenant Code of Conduct
15
-
16
- **Network Pro Strategies**
17
- **Effective Date:** 3/21/2025
18
-
19
- &nbsp;
20
-
21
- ## Contents
22
-
23
- - [Our Pledge](#pledge)
24
- - [Our Standards](#standards)
25
- - [Responsibilities](#response)
26
- - [Scope](#scope)
27
- - [Enforcement](#enforce)
28
- - [Attribution](#attribute)
29
-
30
- ---
31
-
32
- <section id="pledge">
33
-
34
- ## Our Pledge
35
-
36
- We as members, contributors, and leaders pledge to make participation in our
37
- community a harassment-free experience for everyone, regardless of age, body
38
- size, visible or invisible disability, ethnicity, sex characteristics, gender
39
- identity and expression, level of experience, education, socio-economic status,
40
- nationality, personal appearance, race, caste, color, religion, or sexual
41
- identity and orientation.
42
-
43
- We pledge to act and interact in ways that contribute to an open, welcoming,
44
- diverse, inclusive, and healthy community.
45
-
46
- </section>
47
-
48
- <section id="standards">
49
-
50
- ## Our Standards
51
-
52
- Examples of behavior that contributes to a positive environment for our
53
- community include:
54
-
55
- - Demonstrating empathy and kindness toward other people
56
- - Being respectful of differing opinions, viewpoints, and experiences
57
- - Giving and gracefully accepting constructive feedback
58
- - Accepting responsibility and apologizing to those affected by our mistakes,
59
- and learning from the experience
60
- - Focusing on what is best not just for us as individuals, but for the overall
61
- community
62
-
63
- Examples of unacceptable behavior include:
64
-
65
- - The use of sexualized language or imagery, and sexual attention or advances of
66
- any kind
67
- - Trolling, insulting or derogatory comments, and personal or political attacks
68
- - Public or private harassment
69
- - Publishing others' private information, such as a physical or email address,
70
- without their explicit permission
71
- - Other conduct which could reasonably be considered inappropriate in a
72
- professional setting
73
-
74
- <sub>[Back to top](#top)</sub>
75
-
76
- </section>
77
-
78
- <section id="response">
79
-
80
- ## Responsibilities
81
-
82
- Company and community leaders are responsible for clarifying and enforcing our standards of
83
- acceptable behavior and will take appropriate and fair corrective action in
84
- response to any behavior that they deem inappropriate, threatening, offensive,
85
- or harmful.
86
-
87
- Company and community leaders have the right and responsibility to remove, edit, or reject
88
- comments, commits, code, wiki edits, issues, and other contributions that are
89
- not aligned to this Code of Conduct, and will communicate reasons for moderation
90
- decisions when appropriate.
91
-
92
- Network Pro Strategies reserves the right, at its sole discretion, to remove, edit, or reject any contributions that are contrary to or detrimental to its business interests.
93
-
94
- <sub>[Back to top](#top)</sub>
95
-
96
- </section>
97
-
98
- <section id="scope">
99
-
100
- ## Scope
101
-
102
- This Code of Conduct applies within all community spaces, and also applies when
103
- an individual is officially representing the company or community in public spaces.
104
- Examples of representing our company or community include using an official email address,
105
- posting via an official social media account, or acting as an appointed
106
- representative at an online or offline event.
107
-
108
- <sub>[Back to top](#top)</sub>
109
-
110
- </section>
111
-
112
- <section id="enforce">
113
-
114
- ## Enforcement
115
-
116
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the abuse team at [abuse@neteng.pro](mailto:abuse@neteng.pro). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances.
117
-
118
- The abuse team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
119
-
120
- Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project’s leadership.
121
-
122
- <sub>[Back to top](#top)</sub>
123
-
124
- </section>
125
-
126
- <section id="attribute">
127
-
128
- ## Attribution
129
-
130
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
131
- version 2.1, available at
132
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
133
-
134
- The **Enforcement** section is adapted from the
135
- [Contributor Covenant][homepage],
136
- version 1.4, available at
137
- [https://www.contributor-covenant.org/version/1/4/code-of-conduct/][v1.4].
138
-
139
- For answers to common questions about this code of conduct, see the FAQ at
140
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
141
- [https://www.contributor-covenant.org/translations][translations].
142
-
143
- [homepage]: https://www.contributor-covenant.org
144
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
145
- [v1.4]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/
146
- [FAQ]: https://www.contributor-covenant.org/faq
147
- [translations]: https://www.contributor-covenant.org/translations
148
-
149
- <sub>[Back to top](#top)</sub>
150
-
151
- </section>
152
-
153
- ---
154
-
155
- <span style="font-size: 12px; font-weight: bold; text-align: center;">
156
-
157
- [Home](https://netwk.pro) &nbsp; | &nbsp; [Terms of Use](https://netwk.pro/terms-of-use)
158
- [Privacy Policy](https://netwk.pro/privacy) &nbsp; | &nbsp; [Legal](https://netwk.pro/license)
159
-
160
- </span>
161
-
162
- &nbsp;
163
-
164
- <span style="font-size: 12px; text-align: center;">
165
-
166
- Copyright &copy; 2025
167
- **[Network Pro Strategies](https://netwk.pro/)** (Network Pro&trade;)
168
-
169
- Network Pro&trade;, the shield logo, and the "Locking Down Networks&trade;" slogan are [trademarks](https://netwk.pro/license#trademark) of Network Pro Strategies.
170
-
171
- Licensed under **[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)** and the **[GNU GPL](https://spdx.org/licenses/GPL-3.0-or-later.html)**, as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
172
-
173
- </span>
@@ -1,30 +0,0 @@
1
- /* ==========================================================================
2
- src/lib/stores/trackingStatus.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
- ========================================================================== */
7
-
8
- /**
9
- * @file trackingStatus.js
10
- * @description Tracks state of PostHog tracking status for instant updates
11
- * in Privacy Policy and Privacy Dashboard.
12
- * @module src/lib/stores
13
- */
14
-
15
- import { writable } from "svelte/store";
16
-
17
- /**
18
- * Writable tracking status store.
19
- * Initialized with fallback value and updated in browser context.
20
- * @type {import("svelte/store").Writable<string>}
21
- */
22
- export const trackingStatus = writable("⏳ Checking tracking preferences...");
23
-
24
- // Dynamically import browser-only logic after mount
25
- if (typeof window !== "undefined") {
26
- import("$lib/utils/trackingStatus.js").then(({ getTrackingPreferences }) => {
27
- const prefs = getTrackingPreferences();
28
- trackingStatus.set(prefs.status);
29
- });
30
- }
@@ -1,81 +0,0 @@
1
- /* ==========================================================================
2
- src/lib/utils/privacy.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 privacy.js
11
- * @description Determines whether the user allows tracking based on DNT, GPC, or manual opt-out.
12
- * @module src/lib/utils/
13
- * @author SunDevil311
14
- * @updated 2025-06-03
15
- */
16
-
17
- /**
18
- * Check if user has manually set tracking preference.
19
- * @returns {boolean}
20
- */
21
- export function hasUserManuallySetTrackingPreference() {
22
- if (typeof document === "undefined") return false;
23
-
24
- const cookies = document.cookie;
25
- return (
26
- cookies.includes("enable_tracking=true") ||
27
- cookies.includes("disable_tracking=true")
28
- );
29
- }
30
-
31
- /**
32
- * Determine if the user allows tracking based on cookies, DNT, and GPC.
33
- * @returns {boolean}
34
- */
35
- export function shouldTrackUser() {
36
- if (
37
- typeof window === "undefined" ||
38
- typeof navigator === "undefined" ||
39
- typeof document === "undefined"
40
- ) {
41
- return false;
42
- }
43
-
44
- const cookies = document.cookie;
45
- const windowDNT = /** @type {any} */ (window).doNotTrack;
46
- const navigatorGPC = /** @type {any} */ (navigator).globalPrivacyControl;
47
-
48
- const dnt = navigator.doNotTrack === "1" || windowDNT === "1";
49
- const gpc = navigatorGPC === true;
50
-
51
- const manualOptOut = cookies.includes("disable_tracking=true");
52
- const manualOptIn = cookies.includes("enable_tracking=true");
53
-
54
- console.log("[Privacy] Opt-in cookie present:", manualOptIn);
55
- console.log("[Privacy] Opt-out cookie present:", manualOptOut);
56
-
57
- if (manualOptIn) return true;
58
- if (manualOptOut) return false;
59
-
60
- return !dnt && !gpc;
61
- }
62
-
63
- /**
64
- * Determines if user should be reminded to reconsent (after 6 months).
65
- * @returns {boolean}
66
- */
67
- export function shouldRemindUserToReconsent() {
68
- if (typeof document === "undefined") return false;
69
-
70
- if (!hasUserManuallySetTrackingPreference()) return false;
71
-
72
- const match = document.cookie.match(/tracking_consent_timestamp=(\d+)/);
73
- if (!match) return true;
74
-
75
- const timestamp = Number(match[1]);
76
- if (isNaN(timestamp)) return true;
77
-
78
- const age = Date.now() - timestamp;
79
-
80
- return age > 1000 * 60 * 60 * 24 * 180; // 6 months
81
- }