@prosopo/procaptcha-common 2.11.35 → 2.12.1

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @prosopo/procaptcha-common@2.11.35 build:cjs
2
+ > @prosopo/procaptcha-common@2.12.1 build:cjs
3
3
  > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
4
 
5
5
  ViteCommonJSConfig: .
@@ -39,23 +39,24 @@ ViteCommonJSConfig: .
39
39
  vite v8.1.5 building ssr environment for production...
40
40
  Bundle build started
41
41
  
42
- 15 modules transformed.
42
+ 16 modules transformed.
43
43
  rendering chunks...
44
44
  computing gzip size...
45
45
  dist/cjs/extensionLoader.cjs 0.27 kB │ gzip: 0.16 kB
46
46
  dist/cjs/callbacks/defaultEvents.cjs 0.28 kB │ gzip: 0.16 kB
47
47
  dist/cjs/elements/form.cjs 0.62 kB │ gzip: 0.31 kB
48
48
  dist/cjs/simdReadings.cjs 0.79 kB │ gzip: 0.36 kB
49
+ dist/cjs/clientMetaData.cjs 0.83 kB │ gzip: 0.47 kB
49
50
  dist/cjs/events/trust.cjs 0.91 kB │ gzip: 0.53 kB
50
51
  dist/cjs/elements/window.cjs 0.96 kB │ gzip: 0.54 kB
51
52
  dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
52
53
  dist/cjs/reactComponents/TestModeBanner.cjs 1.36 kB │ gzip: 0.75 kB
53
54
  dist/cjs/providers.cjs 1.54 kB │ gzip: 0.64 kB
54
55
  dist/cjs/reactComponents/Honeypot.cjs 2.03 kB │ gzip: 0.91 kB
55
- dist/cjs/index.cjs 2.08 kB │ gzip: 0.57 kB
56
+ dist/cjs/index.cjs 2.22 kB │ gzip: 0.59 kB
56
57
  dist/cjs/reactComponents/Reload.cjs 2.94 kB │ gzip: 1.30 kB
57
58
  dist/cjs/state/builder.cjs 3.13 kB │ gzip: 0.84 kB
58
59
  dist/cjs/callbacks/defaultCallbacks.cjs 3.84 kB │ gzip: 1.03 kB
59
60
  dist/cjs/reactComponents/Checkbox.cjs 5.39 kB │ gzip: 2.12 kB
60
61
 
61
- ✓ built in 84ms
62
+ ✓ built in 69ms
@@ -1,8 +1,8 @@
1
1
 
2
- > @prosopo/procaptcha-common@2.11.35 build:tsc
2
+ > @prosopo/procaptcha-common@2.12.1 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 12:32:26 PM - Projects in this build:
5
+ 6:42:35 PM - Projects in this build:
6
6
  * ../../dev/config/tsconfig.json
7
7
  * ../locale/tsconfig.json
8
8
  * ../util/tsconfig.json
@@ -18,35 +18,35 @@
18
18
  * ../account/tsconfig.json
19
19
  * tsconfig.json
20
20
 
21
- 12:32:26 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
21
+ 6:42:35 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
22
22
 
23
- 12:32:26 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
23
+ 6:42:35 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
24
24
 
25
- 12:32:26 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
25
+ 6:42:35 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
26
26
 
27
- 12:32:26 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/tests/loggerBrowser.unit.test.ts' is older than output '../logger/tsconfig.tsbuildinfo'
27
+ 6:42:35 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
28
28
 
29
- 12:32:26 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
29
+ 6:42:35 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
30
30
 
31
- 12:32:26 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
31
+ 6:42:35 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
32
32
 
33
- 12:32:26 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/objectUtils.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
33
+ 6:42:36 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/error.ts' is older than output '../common/tsconfig.tsbuildinfo'
34
34
 
35
- 12:32:26 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/tests/providers.unit.test.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
35
+ 6:42:36 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/index.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
36
36
 
37
- 12:32:26 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/webComponent/createWidget.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
37
+ 6:42:36 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/theme.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
38
38
 
39
- 12:32:26 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
39
+ 6:42:36 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
40
40
 
41
- 12:32:26 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
41
+ 6:42:36 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
42
42
 
43
- 12:32:26 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
43
+ 6:42:36 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.test.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
44
44
 
45
- 12:32:26 PM - Project '../account/tsconfig.json' is out of date because output file '../account/tsconfig.tsbuildinfo' does not exist
45
+ 6:42:36 PM - Project '../account/tsconfig.json' is out of date because output file '../account/tsconfig.tsbuildinfo' does not exist
46
46
 
47
- 12:32:26 PM - Building project '/home/runner/work/captcha/captcha/packages/account/tsconfig.json'...
47
+ 6:42:36 PM - Building project '/home/runner/work/captcha/captcha/packages/account/tsconfig.json'...
48
48
 
49
- 12:32:29 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
49
+ 6:42:40 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
50
50
 
51
- 12:32:29 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json'...
51
+ 6:42:40 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json'...
52
52
 
@@ -1,9 +1,9 @@
1
1
 
2
- > @prosopo/procaptcha-common@2.11.35 build
2
+ > @prosopo/procaptcha-common@2.12.1 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/procaptcha-common@2.11.35 build:cross-env
6
+ > @prosopo/procaptcha-common@2.12.1 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
@@ -43,7 +43,7 @@ ViteEsmConfig: .
43
43
  vite v8.1.5 building ssr environment for production...
44
44
  Bundle build started
45
45
  
46
- 15 modules transformed.
46
+ 16 modules transformed.
47
47
  rendering chunks...
48
48
  computing gzip size...
49
49
  dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
@@ -51,10 +51,11 @@ dist/callbacks/defaultEvents.js 0.23 kB │ gzip: 0.15 kB
51
51
  dist/extensionLoader.js 0.25 kB │ gzip: 0.16 kB
52
52
  dist/elements/form.js 0.56 kB │ gzip: 0.30 kB
53
53
  dist/simdReadings.js 0.72 kB │ gzip: 0.35 kB
54
+ dist/clientMetaData.js 0.81 kB │ gzip: 0.47 kB
54
55
  dist/events/trust.js 0.89 kB │ gzip: 0.52 kB
55
56
  dist/elements/window.js 0.91 kB │ gzip: 0.53 kB
56
57
  dist/reactComponents/TestModeBanner.js 1.23 kB │ gzip: 0.71 kB
57
- dist/index.js 1.27 kB │ gzip: 0.44 kB
58
+ dist/index.js 1.35 kB │ gzip: 0.46 kB
58
59
  dist/providers.js 1.41 kB │ gzip: 0.62 kB
59
60
  dist/reactComponents/Honeypot.js 1.86 kB │ gzip: 0.89 kB
60
61
  dist/reactComponents/Reload.js 2.69 kB │ gzip: 1.26 kB
@@ -62,4 +63,4 @@ dist/state/builder.js 3.09 kB │ gzip: 0.84 kB
62
63
  dist/callbacks/defaultCallbacks.js 3.64 kB │ gzip: 1.00 kB
63
64
  dist/reactComponents/Checkbox.js 4.87 kB │ gzip: 2.04 kB
64
65
 
65
- ✓ built in 90ms
66
+ ✓ built in 42ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @prosopo/procaptcha-common
2
2
 
3
+ ## 2.12.1
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [eb34de6]
7
+ - @prosopo/types@5.5.0
8
+ - @prosopo/account@2.8.83
9
+ - @prosopo/load-balancer@2.10.34
10
+
11
+ ## 2.12.0
12
+ ### Minor Changes
13
+
14
+ - 4b1cb19: Correlate a site-supplied session id across render and verify.
15
+
16
+ A site can now hand the widget its own session identifier — Protect's JTI, or any per-user session id it already holds — and have the provider confirm at verify time that the token was earned in that same session. Render it with `data-sessionid="..."` or `renderOptions.sessionId`, resolved the same way `mode` and `language` already are, so implicit, explicit and invisible-button renders all pick it up. Pass the same value as the new trailing `clientSessionId` argument to `ProsopoServer.isVerified`.
17
+
18
+ The widget attaches it to the solution as `clientMetaData.clientSessionId`. It is persisted on the captcha record (PoW, puzzle and image alike) and mirrored to a new top-level `clientMetaData` key on the session record — an object rather than a flat field, because more render-time metadata is expected to land there. It survives the PoW→image/puzzle escalation handoff, since the escalated widget is mounted with the same config.
19
+
20
+ At verify, when the value is supplied and the solve does not carry exactly that value — including carrying none at all, which is what a token minted outside the site's session looks like — the token is disapproved with the new `ResultReason.CLIENT_SESSION_MISMATCH` (`API.CLIENT_SESSION_MISMATCH`, translated in all 31 locales), recorded on both the captcha record and the session.
21
+
22
+ Omitting the id preserves existing behaviour, so this is opt-in and backward compatible. The verify request field is `clientSessionId` rather than `sessionId` because `VerificationResponse.sessionId` already means the provider's own frictionless session; same-named request and response fields meaning different things would be a trap for integrators.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies [4b1cb19]
27
+ - @prosopo/types@5.4.0
28
+ - @prosopo/account@2.8.82
29
+ - @prosopo/load-balancer@2.10.33
30
+
3
31
  ## 2.11.35
4
32
  ### Patch Changes
5
33
 
@@ -0,0 +1,22 @@
1
+ //#region src/clientMetaData.ts
2
+ /**
3
+ * Assembles the widget-controlled metadata attached to a captcha solution.
4
+ * Shared by the image, PoW and puzzle managers so a new field only has to be
5
+ * threaded in once.
6
+ *
7
+ * Returns `undefined` when nothing is set, so the submission body omits the
8
+ * key entirely rather than carrying an empty object.
9
+ *
10
+ * @param hp - live honeypot input value, if the honeypot was filled in
11
+ * @param clientSessionId - the site's session id, if the widget was rendered
12
+ * with `data-sessionid` / `renderOptions.sessionId`
13
+ */
14
+ var buildClientMetaData = (hp, clientSessionId) => {
15
+ const clientMetaData = {
16
+ ...hp && { hp },
17
+ ...clientSessionId && { clientSessionId }
18
+ };
19
+ return Object.keys(clientMetaData).length > 0 ? clientMetaData : void 0;
20
+ };
21
+ //#endregion
22
+ exports.buildClientMetaData = buildClientMetaData;
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_providers = require("./providers.cjs");
3
+ const require_clientMetaData = require("./clientMetaData.cjs");
3
4
  const require_trust = require("./events/trust.cjs");
4
5
  const require_builder = require("./state/builder.cjs");
5
6
  const require_window = require("./elements/window.cjs");
@@ -17,6 +18,7 @@ exports.Honeypot = require_Honeypot.Honeypot;
17
18
  exports.ReloadButton = require_Reload.ReloadButton;
18
19
  exports.SIMD_READINGS_SUBMIT_TIMEOUT_MS = require_simdReadings.SIMD_READINGS_SUBMIT_TIMEOUT_MS;
19
20
  exports.TestModeBanner = require_TestModeBanner.TestModeBanner;
21
+ exports.buildClientMetaData = require_clientMetaData.buildClientMetaData;
20
22
  exports.buildUpdateState = require_builder.buildUpdateState;
21
23
  exports.getDefaultCallbacks = require_defaultCallbacks.getDefaultCallbacks;
22
24
  exports.getDefaultEvents = require_defaultEvents.getDefaultEvents;
@@ -0,0 +1,3 @@
1
+ import type { ClientMetaData } from "@prosopo/types";
2
+ export declare const buildClientMetaData: (hp?: string, clientSessionId?: string) => ClientMetaData | undefined;
3
+ //# sourceMappingURL=clientMetaData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientMetaData.d.ts","sourceRoot":"","sources":["../src/clientMetaData.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAcrD,eAAO,MAAM,mBAAmB,QAC1B,MAAM,oBACO,MAAM,KACtB,cAAc,GAAG,SAOnB,CAAC"}
@@ -0,0 +1,22 @@
1
+ //#region src/clientMetaData.ts
2
+ /**
3
+ * Assembles the widget-controlled metadata attached to a captcha solution.
4
+ * Shared by the image, PoW and puzzle managers so a new field only has to be
5
+ * threaded in once.
6
+ *
7
+ * Returns `undefined` when nothing is set, so the submission body omits the
8
+ * key entirely rather than carrying an empty object.
9
+ *
10
+ * @param hp - live honeypot input value, if the honeypot was filled in
11
+ * @param clientSessionId - the site's session id, if the widget was rendered
12
+ * with `data-sessionid` / `renderOptions.sessionId`
13
+ */
14
+ var buildClientMetaData = (hp, clientSessionId) => {
15
+ const clientMetaData = {
16
+ ...hp && { hp },
17
+ ...clientSessionId && { clientSessionId }
18
+ };
19
+ return Object.keys(clientMetaData).length > 0 ? clientMetaData : void 0;
20
+ };
21
+ //#endregion
22
+ export { buildClientMetaData };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientMetaData.js","sourceRoot":"","sources":["../src/clientMetaData.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAClC,EAAW,EACX,eAAwB,EACK,EAAE;IAC/B,MAAM,cAAc,GAAmB;QACtC,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACjB,GAAG,CAAC,eAAe,IAAI,EAAE,eAAe,EAAE,CAAC;KAC3C,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./providers.js";
2
+ export * from "./clientMetaData.js";
2
3
  export * from "./events/trust.js";
3
4
  export * from "./state/builder.js";
4
5
  export * from "./callbacks/defaultCallbacks.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import "./_virtual/_rolldown/runtime.js";
2
2
  import { getProcaptchaRandomActiveProvider, getRetryDelayMs, pickIpMode, providerRetry } from "./providers.js";
3
+ import { buildClientMetaData } from "./clientMetaData.js";
3
4
  import { isEventTrusted } from "./events/trust.js";
4
5
  import { buildUpdateState, useProcaptcha } from "./state/builder.js";
5
6
  import { getWindowCallback, isSecureBrowserContext } from "./elements/window.js";
@@ -11,4 +12,4 @@ import { ReloadButton } from "./reactComponents/Reload.js";
11
12
  import { Checkbox } from "./reactComponents/Checkbox.js";
12
13
  import { Honeypot } from "./reactComponents/Honeypot.js";
13
14
  import { TestModeBanner } from "./reactComponents/TestModeBanner.js";
14
- export { Checkbox, ExtensionLoader, Honeypot, ReloadButton, SIMD_READINGS_SUBMIT_TIMEOUT_MS, TestModeBanner, buildUpdateState, getDefaultCallbacks, getDefaultEvents, getProcaptchaRandomActiveProvider, getRetryDelayMs, getSimdReadingsForSubmit, getWindowCallback, isEventTrusted, isSecureBrowserContext, pickIpMode, providerRetry, setUserCallbacks, useProcaptcha };
15
+ export { Checkbox, ExtensionLoader, Honeypot, ReloadButton, SIMD_READINGS_SUBMIT_TIMEOUT_MS, TestModeBanner, buildClientMetaData, buildUpdateState, getDefaultCallbacks, getDefaultEvents, getProcaptchaRandomActiveProvider, getRetryDelayMs, getSimdReadingsForSubmit, getWindowCallback, isEventTrusted, isSecureBrowserContext, pickIpMode, providerRetry, setUserCallbacks, useProcaptcha };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=clientMetaData.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientMetaData.test.d.ts","sourceRoot":"","sources":["../../src/tests/clientMetaData.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { buildClientMetaData } from "../clientMetaData.js";
3
+ describe("buildClientMetaData", () => {
4
+ it("returns undefined when the widget has nothing to report", () => {
5
+ expect(buildClientMetaData(undefined, undefined)).toBeUndefined();
6
+ });
7
+ it("returns undefined for empty strings rather than an empty object", () => {
8
+ expect(buildClientMetaData("", "")).toBeUndefined();
9
+ });
10
+ it("reports the honeypot value alone", () => {
11
+ expect(buildClientMetaData("bot-typed-this", undefined)).toEqual({
12
+ hp: "bot-typed-this",
13
+ });
14
+ });
15
+ it("reports the client session id alone", () => {
16
+ expect(buildClientMetaData(undefined, "jti-1")).toEqual({
17
+ clientSessionId: "jti-1",
18
+ });
19
+ });
20
+ it("reports both when both are present", () => {
21
+ expect(buildClientMetaData("trap", "jti-1")).toEqual({
22
+ hp: "trap",
23
+ clientSessionId: "jti-1",
24
+ });
25
+ });
26
+ });
27
+ //# sourceMappingURL=clientMetaData.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientMetaData.test.js","sourceRoot":"","sources":["../../src/tests/clientMetaData.test.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QAC1E,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;YAChE,EAAE,EAAE,gBAAgB;SACpB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;YACvD,eAAe,EAAE,OAAO;SACxB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;YACpD,EAAE,EAAE,MAAM;YACV,eAAe,EAAE,OAAO;SACxB,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-common",
3
- "version": "2.11.35",
3
+ "version": "2.12.1",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -34,9 +34,9 @@
34
34
  "dependencies": {
35
35
  "@emotion/react": "11.14.0",
36
36
  "@emotion/styled": "11.14.1",
37
- "@prosopo/account": "2.8.81",
38
- "@prosopo/load-balancer": "2.10.32",
39
- "@prosopo/types": "5.3.0",
37
+ "@prosopo/account": "2.8.83",
38
+ "@prosopo/load-balancer": "2.10.34",
39
+ "@prosopo/types": "5.5.0",
40
40
  "@prosopo/widget-skeleton": "2.8.6",
41
41
  "react": "19.2.8",
42
42
  "react-dom": "19.2.8"
@@ -0,0 +1,39 @@
1
+ // Copyright 2021-2026 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import type { ClientMetaData } from "@prosopo/types";
16
+
17
+ /**
18
+ * Assembles the widget-controlled metadata attached to a captcha solution.
19
+ * Shared by the image, PoW and puzzle managers so a new field only has to be
20
+ * threaded in once.
21
+ *
22
+ * Returns `undefined` when nothing is set, so the submission body omits the
23
+ * key entirely rather than carrying an empty object.
24
+ *
25
+ * @param hp - live honeypot input value, if the honeypot was filled in
26
+ * @param clientSessionId - the site's session id, if the widget was rendered
27
+ * with `data-sessionid` / `renderOptions.sessionId`
28
+ */
29
+ export const buildClientMetaData = (
30
+ hp?: string,
31
+ clientSessionId?: string,
32
+ ): ClientMetaData | undefined => {
33
+ const clientMetaData: ClientMetaData = {
34
+ ...(hp && { hp }),
35
+ ...(clientSessionId && { clientSessionId }),
36
+ };
37
+
38
+ return Object.keys(clientMetaData).length > 0 ? clientMetaData : undefined;
39
+ };
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@
13
13
  // limitations under the License.
14
14
 
15
15
  export * from "./providers.js";
16
+ export * from "./clientMetaData.js";
16
17
  export * from "./events/trust.js";
17
18
  export * from "./state/builder.js";
18
19
  export * from "./callbacks/defaultCallbacks.js";
@@ -0,0 +1,45 @@
1
+ // Copyright 2021-2026 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import { describe, expect, it } from "vitest";
16
+ import { buildClientMetaData } from "../clientMetaData.js";
17
+
18
+ describe("buildClientMetaData", () => {
19
+ it("returns undefined when the widget has nothing to report", () => {
20
+ expect(buildClientMetaData(undefined, undefined)).toBeUndefined();
21
+ });
22
+
23
+ it("returns undefined for empty strings rather than an empty object", () => {
24
+ expect(buildClientMetaData("", "")).toBeUndefined();
25
+ });
26
+
27
+ it("reports the honeypot value alone", () => {
28
+ expect(buildClientMetaData("bot-typed-this", undefined)).toEqual({
29
+ hp: "bot-typed-this",
30
+ });
31
+ });
32
+
33
+ it("reports the client session id alone", () => {
34
+ expect(buildClientMetaData(undefined, "jti-1")).toEqual({
35
+ clientSessionId: "jti-1",
36
+ });
37
+ });
38
+
39
+ it("reports both when both are present", () => {
40
+ expect(buildClientMetaData("trap", "jti-1")).toEqual({
41
+ hp: "trap",
42
+ clientSessionId: "jti-1",
43
+ });
44
+ });
45
+ });