@webdecoy/fcaptcha 1.30.0 → 1.32.0

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.
Files changed (5) hide show
  1. package/clientip.js +14 -1
  2. package/engine.js +980 -0
  3. package/index.js +62 -309
  4. package/package.json +2 -2
  5. package/server.js +37 -883
package/clientip.js CHANGED
@@ -61,6 +61,18 @@ function normalizeIP(value) {
61
61
  }
62
62
  }
63
63
 
64
+ // Bind challenges to a coarse source network: tolerant of nearby mobile address
65
+ // rotation, but not transferable from an unrelated clean proxy.
66
+ function networkIdentity(value) {
67
+ const normalized = normalizeIP(value);
68
+ if (!normalized) return '';
69
+ let addr = ipaddr.parse(normalized);
70
+ if (addr.kind() === 'ipv6' && addr.isIPv4MappedAddress()) addr = addr.toIPv4Address();
71
+ const bytes = addr.toByteArray();
72
+ if (addr.kind() === 'ipv4') return `4:${bytes.slice(0, 3).join('.')}`;
73
+ return `6:${bytes.slice(0, 7).map((b) => b.toString(16).padStart(2, '0')).join('')}`;
74
+ }
75
+
64
76
  // Node merges repeated headers into one comma-joined string for everything
65
77
  // except set-cookie, but accept an array defensively.
66
78
  function headerValue(req, name) {
@@ -225,5 +237,6 @@ class ProxyTrust {
225
237
  module.exports = {
226
238
  ProxyTrust,
227
239
  DEFAULT_TRUSTED_PROXY_CIDRS,
228
- normalizeIP
240
+ normalizeIP,
241
+ networkIdentity
229
242
  };