@anonympins/fingerprint 0.1.2 → 0.1.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/README.md CHANGED
@@ -97,15 +97,12 @@ const securityConfig = {
97
97
  ticketMaxAge: 3600000, // 1 hour. Duration for which a solved challenge ticket is valid.
98
98
  challengeTtl: 300000, // 5 minutes. Time during which a challenge nonce is valid.
99
99
  deviceIdCookieMaxAge: undefined, // By default, it's a session cookie. Set a value in ms for a persistent cookie.
100
- verbose: true, // set to true to log for fingerprint detection output
100
+ challengePagePath: './path/to/your/custom-challenge-page.html', // (Optional) Path to a custom HTML template for the challenge page.
101
+ verbose: process.env.NODE_ENV !== 'production', // Log detailed info in development, but not in production.
101
102
  patterns: { // (Optional) Initial values for request pattern detection, optimized by auto-tuner if enabled.
102
103
  velocityThreshold: 800, // ms between requests to be considered "fast"
103
104
  burstThreshold: 1500, // ms for identical requests to be a "burst"
104
105
  scrapeThreshold: 1000, // ms for sequential requests to be "scraping"
105
- scrapeBurstWeight: 40, // Additional weight for repeated scraping patterns
106
- sequenceLength: 3, // Length of a request sequence to detect (e.g., A->B->C)
107
- sequenceWeight: 60, // Penalty for repeating a sequence
108
- sequenceMinTimeSpan: 2000, // Sequence min time span
109
106
  historySize: 10, // Number of requests to keep for pattern analysis
110
107
  decayFactor: 0.9, // How quickly the pattern score decays over time
111
108
  inactivityReset: 30000, // ms of inactivity after which the pattern score is reset
@@ -199,7 +196,50 @@ app.use((req, res, next) => {
199
196
 
200
197
  app.listen(3000, () => console.log('Server started on port 3000'));
201
198
  ```
199
+ ### Customizing the Challenge Page
202
200
 
201
+ You can provide your own HTML template for the Proof-of-Work challenge page to maintain a consistent user experience with your brand.
202
+
203
+ 1. **Configuration**: In your `securityConfig`, specify the path to your template file using the `challengePagePath` option.
204
+
205
+ ```javascript
206
+ const securityConfig = {
207
+ // ... other options
208
+ challengePagePath: './path/to/your/custom-challenge-page.html',
209
+ };
210
+ ```
211
+
212
+ 2. **Template Placeholders**: Your HTML file **must** contain the following placeholders. The system will replace them with the dynamic JavaScript code required to run the challenge.
213
+
214
+ * `<!-- FINGERPRINT_SOLVER_SCRIPT -->`: This will be replaced by the script that contains the logic for solving the CPU and memory challenges.
215
+ * `<!-- FINGERPRINT_CHALLENGE_SCRIPT -->`: This will be replaced by the script that initiates the challenge with the specific parameters for the current request (nonce, difficulty, etc.).
216
+ * `<!-- FINGERPRINT_TRAPS -->`: This will be replaced by hidden "honeypot" links designed to trap simple bots. This placeholder is crucial for an effective defense.
217
+
218
+ #### Example Custom HTML Template
219
+
220
+ Here is a basic example of what your `custom-challenge-page.html` could look like:
221
+
222
+ ```html
223
+ <!DOCTYPE html>
224
+ <html lang="en">
225
+ <head>
226
+ <meta charset="UTF-8">
227
+ <title>Security Verification</title>
228
+ <style>
229
+ body { font-family: sans-serif; text-align: center; padding-top: 50px; }
230
+ h1 { color: #333; }
231
+ </style>
232
+ </head>
233
+ <body>
234
+ <h1>Please wait while we verify your connection...</h1>
235
+ <div id="loader" style="margin:20px;">⚙️ Initializing verification...</div>
236
+
237
+ <script><!-- FINGERPRINT_SOLVER_SCRIPT --></script>
238
+ <script><!-- FINGERPRINT_CHALLENGE_SCRIPT --></script>
239
+ <!-- FINGERPRINT_TRAPS -->
240
+ </body>
241
+ </html>
242
+ ```
203
243
  ## Public API
204
244
 
205
245
  In addition to the main middleware, several functions are exported to allow for more advanced integrations.