@valiron/crawler-protection 0.2.0 → 0.4.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.
- package/README.md +107 -6
- package/dist/activation.d.ts +5 -1
- package/dist/activation.js +27 -7
- package/dist/admission.d.ts +1 -1
- package/dist/admission.js +16 -2
- package/dist/device-identity/collector-script.d.ts +6 -0
- package/dist/device-identity/collector-script.js +9 -0
- package/dist/device-identity/cookie.d.ts +28 -0
- package/dist/device-identity/cookie.js +76 -0
- package/dist/device-identity/identity.d.ts +98 -0
- package/dist/device-identity/identity.js +198 -0
- package/dist/device-identity/index.d.ts +25 -0
- package/dist/device-identity/index.js +41 -0
- package/dist/device-identity/middleware.d.ts +26 -0
- package/dist/device-identity/middleware.js +110 -0
- package/dist/device-identity/redis.d.ts +33 -0
- package/dist/device-identity/redis.js +70 -0
- package/dist/device-identity/signals.d.ts +50 -0
- package/dist/device-identity/signals.js +120 -0
- package/dist/device-identity/store.d.ts +40 -0
- package/dist/device-identity/store.js +66 -0
- package/dist/directory.js +6 -4
- package/dist/guard.d.ts +5 -0
- package/dist/guard.js +8 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +13 -1
- package/dist/operations.js +2 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/verification.d.ts +3 -1
- package/dist/webbotauth.d.ts +70 -0
- package/dist/webbotauth.js +323 -0
- package/gateway/README.md +4 -4
- package/package.json +4 -1
- package/public/collector.js +90 -0
package/gateway/README.md
CHANGED
|
@@ -12,7 +12,7 @@ The gateway verifies supported crawler sources, applies the site's route/rate po
|
|
|
12
12
|
|
|
13
13
|
The gateway bounds HTTP origin concurrency. Individual database queries and background jobs require the private operation protocol below. Origin timeouts, incomplete responses and uncertain acquisition/release leave inventoried, nonexpiring holds. A browser disconnect does not release still-running origin work. Normal origin HTTP completion releases the HTTP hold, while each database hold has its own settlement.
|
|
14
14
|
|
|
15
|
-
After lease expiry or an observed revoked
|
|
15
|
+
After lease expiry or an observed revoked key, new protected work fails closed. Existing work can settle and the private release API remains available. Activation does not initialize or resume Redis admission. Explicit static bypasses remain usable. Deploy the hosted activation endpoint before upgrading clients from 0.1.0.
|
|
16
16
|
|
|
17
17
|
## Compatibility and verified coverage
|
|
18
18
|
|
|
@@ -38,13 +38,13 @@ node packages/valiron-crawler-protection/gateway/service.cjs --check
|
|
|
38
38
|
node packages/valiron-crawler-protection/gateway/service.cjs
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
Provision authoritative `noeviction` Redis, configure a schema-v1 exported site policy and supply server-only environment settings. `--check` validates configuration and API-key syntax without listening, connecting to Redis, checking the subscription online, activating policy or printing secrets. Normal startup checks the current Pro/Enterprise account before listening. Build the supplied Dockerfile from the repository root to run the same service as a container. The Compose template keeps Redis and the work API off public host ports; attach the application to its separate private work network if it needs operation admission.
|
|
41
|
+
Provision authoritative `noeviction` Redis, configure a schema-v1 exported site policy and supply server-only environment settings. `--check` validates configuration and API-key syntax without listening, connecting to Redis, checking the subscription online, activating policy or printing secrets. Normal startup checks the current Free/Pro/Enterprise account before listening. Build the supplied Dockerfile from the repository root to run the same service as a container. The Compose template keeps Redis and the work API off public host ports; attach the application to its separate private work network if it needs operation admission.
|
|
42
42
|
|
|
43
|
-
Required settings (SDK 0.
|
|
43
|
+
Required settings (SDK 0.3.0+):
|
|
44
44
|
|
|
45
45
|
| Setting | Purpose |
|
|
46
46
|
| --- | --- |
|
|
47
|
-
| `VALIRON_API_KEY` | Server-side Pro/Enterprise operator API key. The exported tenant must belong to its account. Startup requires successful activation; refresh runs every minute, with a five-minute maximum lease. |
|
|
47
|
+
| `VALIRON_API_KEY` | Server-side Free/Pro/Enterprise operator API key. The exported tenant must belong to its account. Startup requires successful activation; refresh runs every minute, with a five-minute maximum lease. |
|
|
48
48
|
| `CRAWLER_CONFIGURATION_FILE` | Exported site configuration, with actual inventoried routes and measured limits. |
|
|
49
49
|
| `REDIS_URL` | Authoritative shared Redis, with TLS for untrusted networks. |
|
|
50
50
|
| `CRAWLER_ORIGIN` | One fixed `http://` or `https://` origin, without path, credentials or query. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valiron/crawler-protection",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Valiron Crawler Protection: HTTP gateway and shared workload admission for any website backend",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
15
|
"README.md",
|
|
16
|
+
"public/collector.js",
|
|
16
17
|
"gateway/service.cjs",
|
|
17
18
|
"gateway/admin.cjs",
|
|
18
19
|
"gateway/directory.cjs",
|
|
@@ -57,3 +58,5 @@
|
|
|
57
58
|
"registry": "https://registry.npmjs.org/"
|
|
58
59
|
}
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Valiron Device Identity collector (browser), shipped inside
|
|
3
|
+
* Valiron Crawler Protection and served by createNodeDeviceIdentityMiddleware().
|
|
4
|
+
*
|
|
5
|
+
* Collects coarsened device signals and POSTs them to the deployment's
|
|
6
|
+
* identify endpoint. The deterministic visitor id lives in a first-party,
|
|
7
|
+
* HttpOnly cookie set by the server; this script never reads or writes it,
|
|
8
|
+
* and it never touches localStorage. No third-party requests are made.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* <script src="/api/valiron/device-identity/collector.js"></script>
|
|
12
|
+
* <script>
|
|
13
|
+
* ValironDevice.identify({ endpoint: '/api/valiron/device-identity/identify' })
|
|
14
|
+
* .then(function (result) { console.log(result.state); });
|
|
15
|
+
* </script>
|
|
16
|
+
*
|
|
17
|
+
* Set respectPrivacySignals: true to skip collection entirely when the
|
|
18
|
+
* browser sends Do Not Track or Global Privacy Control.
|
|
19
|
+
*/
|
|
20
|
+
(function () {
|
|
21
|
+
'use strict';
|
|
22
|
+
|
|
23
|
+
function safe(fn, fallback) {
|
|
24
|
+
try {
|
|
25
|
+
var value = fn();
|
|
26
|
+
return value === undefined ? fallback : value;
|
|
27
|
+
} catch (_) {
|
|
28
|
+
return fallback;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function privacyRequested() {
|
|
33
|
+
return safe(function () { return navigator.globalPrivacyControl === true; }, false)
|
|
34
|
+
|| safe(function () { return navigator.doNotTrack === '1' || window.doNotTrack === '1'; }, false);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function collect() {
|
|
38
|
+
var screen_ = safe(function () {
|
|
39
|
+
return {
|
|
40
|
+
width: window.screen.width,
|
|
41
|
+
height: window.screen.height,
|
|
42
|
+
colorDepth: window.screen.colorDepth,
|
|
43
|
+
pixelRatio: window.devicePixelRatio,
|
|
44
|
+
};
|
|
45
|
+
}, undefined);
|
|
46
|
+
return {
|
|
47
|
+
userAgent: safe(function () { return navigator.userAgent; }, undefined),
|
|
48
|
+
languages: safe(function () {
|
|
49
|
+
return navigator.languages && navigator.languages.length ? Array.from(navigator.languages) : [navigator.language];
|
|
50
|
+
}, undefined),
|
|
51
|
+
timezone: safe(function () { return Intl.DateTimeFormat().resolvedOptions().timeZone; }, undefined),
|
|
52
|
+
platform: safe(function () { return navigator.platform; }, undefined),
|
|
53
|
+
hardwareConcurrency: safe(function () { return navigator.hardwareConcurrency; }, undefined),
|
|
54
|
+
deviceMemory: safe(function () { return navigator.deviceMemory; }, undefined),
|
|
55
|
+
maxTouchPoints: safe(function () { return navigator.maxTouchPoints; }, undefined),
|
|
56
|
+
screen: screen_,
|
|
57
|
+
cookiesEnabled: safe(function () { return navigator.cookieEnabled; }, undefined),
|
|
58
|
+
doNotTrack: privacyRequested(),
|
|
59
|
+
webdriver: safe(function () { return navigator.webdriver === true; }, undefined),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function identify(options) {
|
|
64
|
+
if (!options || typeof options.endpoint !== 'string' || options.endpoint.length > 2048) {
|
|
65
|
+
return Promise.reject(new Error('ValironDevice: endpoint is required'));
|
|
66
|
+
}
|
|
67
|
+
if (options.respectPrivacySignals === true && privacyRequested()) {
|
|
68
|
+
return Promise.resolve({ state: 'skipped', reason: 'privacy_signal' });
|
|
69
|
+
}
|
|
70
|
+
var timeoutMs = typeof options.timeoutMs === 'number' && options.timeoutMs >= 500 && options.timeoutMs <= 10000
|
|
71
|
+
? options.timeoutMs : 4000;
|
|
72
|
+
var controller = typeof AbortController !== 'undefined' ? new AbortController() : undefined;
|
|
73
|
+
var timer = controller ? setTimeout(function () { controller.abort(); }, timeoutMs) : undefined;
|
|
74
|
+
return fetch(options.endpoint, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers: { 'content-type': 'application/json' },
|
|
77
|
+
credentials: options.credentials || 'same-origin',
|
|
78
|
+
body: JSON.stringify({ signals: collect() }),
|
|
79
|
+
signal: controller ? controller.signal : undefined,
|
|
80
|
+
}).then(function (response) {
|
|
81
|
+
if (!response.ok) throw new Error('ValironDevice: identify failed with ' + response.status);
|
|
82
|
+
return response.json();
|
|
83
|
+
}).finally(function () {
|
|
84
|
+
if (timer) clearTimeout(timer);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
window.ValironDevice = Object.freeze({ identify: identify, collect: collect });
|
|
89
|
+
})();
|
|
90
|
+
|