You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document cookieMaxAgeSeconds, forceCloudflareWorkers in README
Catches the README up with three feature commits that landed since the
last doc touch (286775e):
- forceCloudflareWorkers (0496c2f) — bypass navigator-based runtime
inference. Added to Init Options block and given its own section
covering the debug log signal (fe71fe9) and per-init reset (8c00364).
- cookieMaxAgeSeconds (695fc31) — opt-in cookie persistence via
Max-Age, motivated by waiting-room resilience across browser
restarts. Added to Init Options block and given its own section.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
// and treat the runtime as Cloudflare Workers. Only `true`
347
+
// is accepted; omit for auto-detection.
343
348
waitingRoom:false, // Set to true if SDK is running in a waiting room context
344
349
liteValidator:false, // Enable lite validator mode (default: false)
345
350
roomsConfig: [{ // Array of room configurations for lite validator
@@ -400,6 +405,40 @@ This is useful when:
400
405
- Avoiding conflicts with existing cookies
401
406
- Meeting specific naming conventions
402
407
408
+
## Cookie Persistence
409
+
410
+
By default the CrowdHandler cookie is a **session cookie** — the browser drops it when the user fully quits (note: many browsers restore session cookies if "continue where you left off" is enabled). For waiting-room use cases where you want a queued user's position to survive a browser restart, opt in to persistence with `cookieMaxAgeSeconds`:
411
+
412
+
```javascript
413
+
const { gatekeeper } =crowdhandler.init({
414
+
publicKey:'YOUR_PUBLIC_KEY',
415
+
options: {
416
+
cookieMaxAgeSeconds:86400// Persist for 24 hours via Max-Age
417
+
}
418
+
});
419
+
```
420
+
421
+
Notes:
422
+
- The value is written as the cookie's `Max-Age` attribute (preferred over `Expires` because it isn't affected by client clock skew).
423
+
- The option applies to every Set-Cookie the SDK emits — both while the user is queued and after promotion.
424
+
- Omit the option (or leave it `undefined`) to keep the original session-cookie behaviour.
425
+
426
+
## Forcing the Cloudflare Workers Runtime
427
+
428
+
The SDK infers a Cloudflare Workers runtime from `navigator.userAgent`. If that signal is unreliable in your environment (custom workerd builds, bundlers that strip globals, test harnesses) you can make the decision explicit:
429
+
430
+
```javascript
431
+
const { gatekeeper } =crowdhandler.init({
432
+
publicKey:env.CROWDHANDLER_PUBLIC_KEY,
433
+
cloudflareWorkersRequest: request,
434
+
options: {
435
+
forceCloudflareWorkers:true
436
+
}
437
+
});
438
+
```
439
+
440
+
Only `true` is accepted — omit the option to fall back to auto-detection. With `debug:true`, the SDK logs which signal drove the decision, e.g. `[CH] Cloudflare Workers runtime:true (via override)` vs `(via navigator inference)`. The override is reset on every `init()` call so it never leaks across re-initialisations.
441
+
403
442
## API Client
404
443
405
444
The SDK provides a unified client for both public and private APIs:
0 commit comments