@prosopo/procaptcha-common 2.11.35 → 2.12.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.
- package/.turbo/turbo-build$colon$cjs.log +5 -4
- package/.turbo/turbo-build$colon$tsc.log +18 -18
- package/.turbo/turbo-build.log +6 -5
- package/CHANGELOG.md +20 -0
- package/dist/cjs/clientMetaData.cjs +22 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/clientMetaData.d.ts +3 -0
- package/dist/clientMetaData.d.ts.map +1 -0
- package/dist/clientMetaData.js +22 -0
- package/dist/clientMetaData.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/tests/clientMetaData.test.d.ts +2 -0
- package/dist/tests/clientMetaData.test.d.ts.map +1 -0
- package/dist/tests/clientMetaData.test.js +27 -0
- package/dist/tests/clientMetaData.test.js.map +1 -0
- package/package.json +4 -4
- package/src/clientMetaData.ts +39 -0
- package/src/index.ts +1 -0
- package/src/tests/clientMetaData.test.ts +45 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-common@2.
|
|
2
|
+
> @prosopo/procaptcha-common@2.12.0 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
|
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
40
40
|
Bundle build started
|
|
41
41
|
[2K
|
|
42
|
-
✓
|
|
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.
|
|
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
|
-
[32m✓ built in
|
|
62
|
+
[32m✓ built in 77ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-common@2.
|
|
2
|
+
> @prosopo/procaptcha-common@2.12.0 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
1:43:10 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
|
-
|
|
21
|
+
1:43:10 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
|
-
|
|
23
|
+
1:43:10 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
|
-
|
|
25
|
+
1:43:10 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
|
-
|
|
27
|
+
1:43:10 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
|
-
|
|
29
|
+
1:43:10 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
|
-
|
|
31
|
+
1:43:10 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
|
-
|
|
33
|
+
1:43:10 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
1:43:10 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/balancer.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
1:43:10 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
|
-
|
|
39
|
+
1:43:10 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
|
-
|
|
41
|
+
1:43:10 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/merkle.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
1:43:10 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
|
-
|
|
45
|
+
1:43:10 PM - Project '../account/tsconfig.json' is out of date because output file '../account/tsconfig.tsbuildinfo' does not exist
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
1:43:10 PM - Building project '/home/runner/work/captcha/captcha/packages/account/tsconfig.json'...
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
1:43:13 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
1:43:13 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-common/tsconfig.json'...
|
|
52
52
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/procaptcha-common@2.
|
|
2
|
+
> @prosopo/procaptcha-common@2.12.0 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/procaptcha-common@2.
|
|
6
|
+
> @prosopo/procaptcha-common@2.12.0 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
|
[36mvite v8.1.5 [32mbuilding ssr environment for production...[36m[39m
|
|
44
44
|
Bundle build started
|
|
45
45
|
[2K
|
|
46
|
-
✓
|
|
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.
|
|
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
|
-
[32m✓ built in
|
|
66
|
+
[32m✓ built in 92ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @prosopo/procaptcha-common
|
|
2
2
|
|
|
3
|
+
## 2.12.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- 4b1cb19: Correlate a site-supplied session id across render and verify.
|
|
7
|
+
|
|
8
|
+
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`.
|
|
9
|
+
|
|
10
|
+
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.
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [4b1cb19]
|
|
19
|
+
- @prosopo/types@5.4.0
|
|
20
|
+
- @prosopo/account@2.8.82
|
|
21
|
+
- @prosopo/load-balancer@2.10.33
|
|
22
|
+
|
|
3
23
|
## 2.11.35
|
|
4
24
|
### Patch Changes
|
|
5
25
|
|
|
@@ -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;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -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 @@
|
|
|
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
package/dist/index.d.ts.map
CHANGED
|
@@ -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 @@
|
|
|
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.
|
|
3
|
+
"version": "2.12.0",
|
|
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.
|
|
38
|
-
"@prosopo/load-balancer": "2.10.
|
|
39
|
-
"@prosopo/types": "5.
|
|
37
|
+
"@prosopo/account": "2.8.82",
|
|
38
|
+
"@prosopo/load-balancer": "2.10.33",
|
|
39
|
+
"@prosopo/types": "5.4.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
|
@@ -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
|
+
});
|