Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.28.0] - 2026-11-22

### Added

- Return observe-only scroll diagnostics from the embedded CAPTCHA widget and invisible endpoints.

### Fixed

- Select CAPTCHA detectors by the server's interaction mode and require verified proof of work for session tokens.
- Improve scoring for single taps, keyboard navigation, slow pointer movement, and precise trackpad clicks.
- Check measured font families against the reported platform and record the first textarea paste.
- Accept embedded CAPTCHA challenge IDs in the browser and use the configured invisible session origin for proof requests.

## [0.27.0] - 2026-11-22

### Added
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webdecoy/client",
"version": "0.27.0",
"version": "0.28.0",
"description": "Web Decoy browser widget - signal collection, proof-of-work, and captcha UI",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
8 changes: 6 additions & 2 deletions packages/client/src/invisible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class InvisibleSession {
this.environmental = new EnvironmentalCollector();
this.temporal = new TemporalCollector();
this.sensor = new SensorCollector();
this.powManager = new PoWManager();
this.powManager = new PoWManager(() => this.serverOrigin());
this.startTime = Date.now();

this._init();
Expand All @@ -72,6 +72,10 @@ export class InvisibleSession {
void this._fetchChallenge();
}

private serverOrigin(): string | null {
return this.options.serverUrl || getServerUrl();
}

private async _fetchChallenge(): Promise<void> {
try {
await this.powManager.fetchChallenge(this.options.siteKey);
Expand Down Expand Up @@ -216,7 +220,7 @@ export class InvisibleSession {
signalsHash: string | null,
powTiming: Record<string, unknown> | null,
): Promise<VerifyResponse> {
const url = this.options.serverUrl || getServerUrl();
const url = this.serverOrigin();
if (!url) return this._clientSideScore(signals);

try {
Expand Down
49 changes: 49 additions & 0 deletions packages/client/src/pow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { getServerUrl, setServerUrl } from './config';
import { InvisibleSession } from './invisible';
import { PoWManager } from './pow';

const globalFetch = globalThis.fetch;
const originalOrigin = getServerUrl();
const challengeData = {
prefix: 'fixture:123:2',
difficulty: 2,
expiresAt: 1_000_000,
nonce: 'fixture-nonce',
};

function serveChallenge(body: unknown): jest.Mock {
const fetch = jest.fn().mockResolvedValue({ ok: true, json: async () => body });
globalThis.fetch = fetch;
return fetch;
}

afterEach(() => {
setServerUrl(originalOrigin);
globalThis.fetch = globalFetch;
});

it.each(['id', 'challengeId'])('normalizes a challenge with the %s field', async field => {
setServerUrl('https://captcha.example.test');
const fetch = serveChallenge({ [field]: 'fixture', ...challengeData });

const manager = new PoWManager();
expect(await manager.fetchChallenge('test-site')).toEqual({ challengeId: 'fixture', ...challengeData });
expect(fetch).toHaveBeenCalledWith('https://captcha.example.test/__webdecoy/challenge?siteKey=test-site');
});

it('fetches the invisible session challenge from its configured origin', () => {
setServerUrl('https://global.example.test');
const fetch = serveChallenge({ id: 'fixture', ...challengeData });
const session = new InvisibleSession({
siteKey: 'test-site',
serverUrl: 'https://session.example.test',
autoScore: false,
});

try {
expect(fetch).toHaveBeenCalledTimes(1);
expect(fetch).toHaveBeenCalledWith('https://session.example.test/__webdecoy/challenge?siteKey=test-site');
} finally {
session.destroy();
}
});
13 changes: 11 additions & 2 deletions packages/client/src/pow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import { getServerUrl, getBasePath } from './config';
import type { Challenge, PoWSolution } from './types';

type ChallengeResponse = Omit<Challenge, 'challengeId'> & { challengeId?: string; id?: string };

export class PoWManager {
private workers: Worker[] = [];
challenge: Challenge | null = null;
Expand All @@ -17,6 +19,8 @@ export class PoWManager {
private solvePromise: Promise<PoWSolution> | null = null;
private startTime: number | null = null;

constructor(private readonly challengeOrigin: () => string | null = getServerUrl) {}

/**
* Inline Web Worker for PoW computation. Each worker scans a disjoint nonce
* slice via `(startNonce + k*stride)`, so N workers explore the space N-way.
Expand Down Expand Up @@ -88,7 +92,7 @@ export class PoWManager {
}

async fetchChallenge(siteKey?: string | null): Promise<Challenge> {
const serverUrl = getServerUrl();
const serverUrl = this.challengeOrigin();
if (!serverUrl) {
return this._generateLocalChallenge();
}
Expand All @@ -101,7 +105,12 @@ export class PoWManager {
console.warn(`PoW challenge fetch failed (status ${response.status}), using local challenge`);
return this._generateLocalChallenge();
}
this.challenge = (await response.json()) as Challenge;
const { id, challengeId: legacyId, ...data } = await response.json() as ChallengeResponse;
const challengeId = legacyId ?? id;
if (typeof challengeId !== 'string' || challengeId.length === 0) {
throw new Error('PoW challenge response is missing an ID');
}
this.challenge = { ...data, challengeId };
return this.challenge;
} catch (e) {
console.warn('PoW challenge fetch failed, using local challenge:', e);
Expand Down
4 changes: 2 additions & 2 deletions packages/express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webdecoy/express",
"version": "0.27.0",
"version": "0.28.0",
"description": "Web Decoy middleware for Express.js",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -40,7 +40,7 @@
"url": "https://github.com/WebDecoy/node/issues"
},
"dependencies": {
"@webdecoy/node": "^0.27.0"
"@webdecoy/node": "^0.28.0"
},
"peerDependencies": {
"express": "^4.18.0 || ^5.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/fastify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webdecoy/fastify",
"version": "0.27.0",
"version": "0.28.0",
"description": "Web Decoy plugin for Fastify",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -40,7 +40,7 @@
"url": "https://github.com/WebDecoy/node/issues"
},
"dependencies": {
"@webdecoy/node": "^0.27.0",
"@webdecoy/node": "^0.28.0",
"fastify-plugin": "^4.5.1"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/hono/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webdecoy/hono",
"version": "0.27.0",
"version": "0.28.0",
"description": "Web Decoy middleware for Hono \u2014 Cloudflare Workers, Bun, Deno, Node",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -44,7 +44,7 @@
"url": "https://github.com/WebDecoy/node/issues"
},
"dependencies": {
"@webdecoy/node": "^0.27.0"
"@webdecoy/node": "^0.28.0"
},
"peerDependencies": {
"hono": "^4.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webdecoy/nextjs",
"version": "0.27.0",
"version": "0.28.0",
"description": "Web Decoy middleware for Next.js",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -54,7 +54,7 @@
"url": "https://github.com/WebDecoy/node/issues"
},
"dependencies": {
"@webdecoy/node": "^0.27.0"
"@webdecoy/node": "^0.28.0"
},
"peerDependencies": {
"next": ">=13.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/webdecoy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webdecoy/node",
"version": "0.27.0",
"version": "0.28.0",
"description": "Bot detection and AI agent verification for Node.js and edge runtimes. Local honeypot tripwires, rate limiting and AI crawler policies, with optional WebDecoy dashboard reporting.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
Loading