@prosopo/procaptcha-frictionless 2.16.5 → 2.18.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 (77) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +7 -7
  2. package/.turbo/turbo-build$colon$tsc.log +24 -24
  3. package/.turbo/turbo-build.log +12 -12
  4. package/CHANGELOG.md +69 -0
  5. package/dist/{AuthenticatedBadge.d.ts → authenticatedBadge.d.ts} +3 -3
  6. package/dist/authenticatedBadge.d.ts.map +1 -0
  7. package/dist/authenticatedBadge.js +79 -0
  8. package/dist/authenticatedBadge.js.map +1 -0
  9. package/dist/cjs/authenticatedBadge.cjs +79 -0
  10. package/dist/cjs/customDetectBot.cjs +3 -2
  11. package/dist/cjs/detectorPrefetch.cjs +2 -2
  12. package/dist/cjs/index.cjs +2 -2
  13. package/dist/cjs/procaptchaFrictionless.cjs +269 -0
  14. package/dist/customDetectBot.d.ts.map +1 -1
  15. package/dist/customDetectBot.js +4 -3
  16. package/dist/customDetectBot.js.map +1 -1
  17. package/dist/detectorPrefetch.js +2 -2
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/procaptchaFrictionless.d.ts +6 -0
  21. package/dist/procaptchaFrictionless.d.ts.map +1 -0
  22. package/dist/procaptchaFrictionless.js +269 -0
  23. package/dist/procaptchaFrictionless.js.map +1 -0
  24. package/dist/tests/customDetectBotAssignTimeout.test.js +1 -0
  25. package/dist/tests/customDetectBotAssignTimeout.test.js.map +1 -1
  26. package/dist/tests/customDetectBotSimd.test.js +1 -0
  27. package/dist/tests/customDetectBotSimd.test.js.map +1 -1
  28. package/dist/tests/escalationClientSession.test.d.ts +0 -3
  29. package/dist/tests/escalationClientSession.test.d.ts.map +1 -1
  30. package/dist/tests/escalationClientSession.test.js +52 -61
  31. package/dist/tests/escalationClientSession.test.js.map +1 -1
  32. package/dist/tests/escalationHandoff.integration.test.d.ts +0 -3
  33. package/dist/tests/escalationHandoff.integration.test.d.ts.map +1 -1
  34. package/dist/tests/escalationHandoff.integration.test.js +62 -61
  35. package/dist/tests/escalationHandoff.integration.test.js.map +1 -1
  36. package/dist/tests/executeBeforeMount.test.d.ts +0 -3
  37. package/dist/tests/executeBeforeMount.test.d.ts.map +1 -1
  38. package/dist/tests/executeBeforeMount.test.js +53 -49
  39. package/dist/tests/executeBeforeMount.test.js.map +1 -1
  40. package/dist/tests/manualStart.test.d.ts +0 -3
  41. package/dist/tests/manualStart.test.d.ts.map +1 -1
  42. package/dist/tests/manualStart.test.js +55 -52
  43. package/dist/tests/manualStart.test.js.map +1 -1
  44. package/dist/tests/procaptchaFrictionless.test.d.ts +2 -0
  45. package/dist/tests/procaptchaFrictionless.test.d.ts.map +1 -0
  46. package/dist/tests/procaptchaFrictionless.test.js +244 -0
  47. package/dist/tests/procaptchaFrictionless.test.js.map +1 -0
  48. package/dist/tests/sessionInvalidatedRemint.test.d.ts +0 -3
  49. package/dist/tests/sessionInvalidatedRemint.test.d.ts.map +1 -1
  50. package/dist/tests/sessionInvalidatedRemint.test.js +49 -43
  51. package/dist/tests/sessionInvalidatedRemint.test.js.map +1 -1
  52. package/package.json +11 -13
  53. package/src/authenticatedBadge.ts +151 -0
  54. package/src/customDetectBot.ts +11 -2
  55. package/src/detectorPrefetch.ts +2 -2
  56. package/src/index.ts +1 -1
  57. package/src/{ProcaptchaFrictionless.tsx → procaptchaFrictionless.ts} +285 -314
  58. package/src/tests/customDetectBotAssignTimeout.test.ts +5 -0
  59. package/src/tests/customDetectBotSimd.test.ts +5 -0
  60. package/src/tests/{escalationClientSession.test.tsx → escalationClientSession.test.ts} +83 -92
  61. package/src/tests/{escalationHandoff.integration.test.tsx → escalationHandoff.integration.test.ts} +110 -108
  62. package/src/tests/{executeBeforeMount.test.tsx → executeBeforeMount.test.ts} +79 -77
  63. package/src/tests/{manualStart.test.tsx → manualStart.test.ts} +87 -83
  64. package/src/tests/procaptchaFrictionless.test.ts +408 -0
  65. package/src/tests/{sessionInvalidatedRemint.test.tsx → sessionInvalidatedRemint.test.ts} +67 -64
  66. package/tsconfig.cjs.json +1 -2
  67. package/tsconfig.tsbuildinfo +1 -1
  68. package/dist/AuthenticatedBadge.d.ts.map +0 -1
  69. package/dist/AuthenticatedBadge.js +0 -75
  70. package/dist/AuthenticatedBadge.js.map +0 -1
  71. package/dist/ProcaptchaFrictionless.d.ts +0 -3
  72. package/dist/ProcaptchaFrictionless.d.ts.map +0 -1
  73. package/dist/ProcaptchaFrictionless.js +0 -287
  74. package/dist/ProcaptchaFrictionless.js.map +0 -1
  75. package/dist/cjs/AuthenticatedBadge.cjs +0 -75
  76. package/dist/cjs/ProcaptchaFrictionless.cjs +0 -287
  77. package/src/AuthenticatedBadge.tsx +0 -141
@@ -18,6 +18,7 @@ import {
18
18
  ExtensionLoader,
19
19
  getProcaptchaRandomActiveProvider,
20
20
  pickIpMode,
21
+ resolveClientSessionId,
21
22
  } from "@prosopo/procaptcha-common";
22
23
  import type {
23
24
  BotDetectionFunction,
@@ -175,8 +176,8 @@ const customDetectBot: BotDetectionFunction = async (
175
176
  // same stack. Resolved up front — before detection rather than alongside it —
176
177
  // because the detector bundle is served BY this provider.
177
178
  // The bundle entry starts provider resolution + assign as soon as it has read
178
- // the site key off the DOM, which is well before React has mounted this
179
- // widget. Claim that in-flight work if it exists rather than repeating it.
179
+ // the site key off the DOM, which is well before this widget has mounted.
180
+ // Claim that in-flight work if it exists rather than repeating it.
180
181
  // Only valid on a first attempt: a retry is retrying *because* the pinned
181
182
  // pronode failed, so it must re-resolve.
182
183
  const isFirstAttempt = !retryContext || retryContext.attempt <= 1;
@@ -261,6 +262,12 @@ const customDetectBot: BotDetectionFunction = async (
261
262
  const ExtClass = await extClassPromise;
262
263
  const ext = new ExtClass();
263
264
 
265
+ // Sent on this hop as well as on solution submit, so a session that is
266
+ // allowed frictionlessly — or abandoned before a solve — still correlates
267
+ // back to the site's (or Protect's) session. Undefined when Protect has not
268
+ // finished initialising yet; the solve-time read then supplies it.
269
+ const clientSessionId = resolveClientSessionId(config.clientSessionId);
270
+
264
271
  // No provider detector ⇒ no detection is possible, so there is nothing to
265
272
  // send. The request goes out with an empty token and the provider decides
266
273
  // what to serve; the client gets no say in that.
@@ -279,6 +286,7 @@ const customDetectBot: BotDetectionFunction = async (
279
286
  undefined,
280
287
  fallbackUrl,
281
288
  fallbackIframeUrl,
289
+ clientSessionId,
282
290
  ),
283
291
  10000,
284
292
  );
@@ -335,6 +343,7 @@ const customDetectBot: BotDetectionFunction = async (
335
343
  detectorSessionId,
336
344
  currentUrl,
337
345
  iframeUrl,
346
+ clientSessionId,
338
347
  );
339
348
  if (detectionResult.getSimdReadings) {
340
349
  // Fire-and-forget: triggers the memoised prefetch inside the catcher
@@ -17,12 +17,12 @@
17
17
  *
18
18
  * Since the detector moved into the provider-served pool, the frictionless flow
19
19
  * cannot start until `/detector/assign` has returned. That request is issued by
20
- * `customDetectBot`, which only runs once React has mounted the widget — and
20
+ * `customDetectBot`, which only runs once the widget has mounted — and
21
21
  * that mount sits behind the bundle's dynamic-import chain. Measured on a
22
22
  * staging demo page the assign request did not leave the browser until 1513 ms,
23
23
  * of which ~700 ms was purely waiting for chunks to arrive in sequence.
24
24
  *
25
- * Nothing in the request depends on React, i18n or the widget config: it needs
25
+ * Nothing in the request depends on the widget, i18n or its config: it needs
26
26
  * the site key (a DOM attribute, readable immediately), the environment (a
27
27
  * build-time constant) and the IP-mode flags (DOM attributes). So the entry
28
28
  * point kicks it off as soon as it has read those, and `customDetectBot` picks
package/src/index.ts CHANGED
@@ -11,5 +11,5 @@
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- export * from "./ProcaptchaFrictionless.js";
14
+ export * from "./procaptchaFrictionless.js";
15
15
  export * from "./detectorPrefetch.js";