capjs-core 0.1.4 → 0.1.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +12 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capjs-core",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Stateless server-side challenge generator and verifier for Cap, a lightweight, modern open-source CAPTCHA alternative. No storage, no filesystem - bring your own.",
5
5
  "keywords": [
6
6
  "anti-abuse",
package/src/index.js CHANGED
@@ -241,9 +241,12 @@ export async function validateChallenge(secret, body, opts = {}) {
241
241
  }
242
242
 
243
243
  if (body.instr_blocked === true) {
244
- if (instrMeta.blockAutomatedBrowsers) {
245
- return fail("instr_automated_browser", { instr_error: true });
246
- }
244
+ return fail(
245
+ instrMeta.blockAutomatedBrowsers
246
+ ? "instr_automated_browser"
247
+ : "instr_failed",
248
+ { instr_error: true },
249
+ );
247
250
  } else if (body.instr_timeout === true) {
248
251
  return fail("instr_timeout", { instr_error: true });
249
252
  } else if (body.instr) {
@@ -435,9 +438,12 @@ async function validateChallengeV2(secret, body, payload, opts = {}) {
435
438
  return fail("instr_expired", { instr_error: true });
436
439
  }
437
440
  if (s.blocked === true) {
438
- if (meta.blockAutomatedBrowsers) {
439
- return fail("instr_automated_browser", { instr_error: true });
440
- }
441
+ return fail(
442
+ meta.blockAutomatedBrowsers
443
+ ? "instr_automated_browser"
444
+ : "instr_failed",
445
+ { instr_error: true },
446
+ );
441
447
  } else if (s.timeout === true) {
442
448
  return fail("instr_timeout", { instr_error: true });
443
449
  } else if (s.instr) {