@prosopo/procaptcha-pow 2.8.31 → 2.9.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.
- package/.turbo/turbo-build$colon$cjs.log +8 -4
- package/.turbo/turbo-build$colon$tsc.log +23 -17
- package/.turbo/turbo-build.log +9 -5
- package/CHANGELOG.md +432 -0
- package/dist/cjs/components/ProcaptchaWidget.cjs +46 -33
- package/dist/cjs/services/Manager.cjs +18 -4
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +48 -35
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/dist/services/Manager.d.ts +2 -2
- package/dist/services/Manager.d.ts.map +1 -1
- package/dist/services/Manager.js +19 -5
- package/dist/services/Manager.js.map +1 -1
- package/package.json +11 -10
- package/src/components/ProcaptchaPoW.tsx +38 -0
- package/src/components/ProcaptchaWidget.tsx +164 -0
- package/src/index.ts +15 -0
- package/src/services/Manager.ts +390 -0
- package/tsconfig.cjs.json +44 -0
- package/tsconfig.json +45 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsconfig.types.json +9 -0
|
@@ -17,8 +17,17 @@ const Procaptcha = (props) => {
|
|
|
17
17
|
const [state, _updateState] = procaptchaCommon.useProcaptcha(react.useState, react.useRef);
|
|
18
18
|
const [loading, setLoading] = react.useState(false);
|
|
19
19
|
const updateState = procaptchaCommon.buildUpdateState(state, _updateState);
|
|
20
|
+
const hpRef = react.useRef(null);
|
|
20
21
|
const manager = react.useRef(
|
|
21
|
-
Manager.Manager(
|
|
22
|
+
Manager.Manager(
|
|
23
|
+
config,
|
|
24
|
+
state,
|
|
25
|
+
updateState,
|
|
26
|
+
callbacks,
|
|
27
|
+
frictionlessState,
|
|
28
|
+
props.onEscalate,
|
|
29
|
+
() => hpRef.current?.value || void 0
|
|
30
|
+
)
|
|
22
31
|
);
|
|
23
32
|
react.useEffect(() => {
|
|
24
33
|
if (config.language) {
|
|
@@ -40,7 +49,7 @@ const Procaptcha = (props) => {
|
|
|
40
49
|
if (state.error.key === "CAPTCHA.NO_SESSION_FOUND" && frictionlessState) {
|
|
41
50
|
setTimeout(() => {
|
|
42
51
|
frictionlessState.restart();
|
|
43
|
-
},
|
|
52
|
+
}, 100);
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
}, [state.error, frictionlessState]);
|
|
@@ -64,38 +73,42 @@ const Procaptcha = (props) => {
|
|
|
64
73
|
return () => {
|
|
65
74
|
};
|
|
66
75
|
}, [config.mode]);
|
|
76
|
+
const honeypot = frictionlessState?.hp ? /* @__PURE__ */ jsxRuntime.jsx(procaptchaCommon.Honeypot, { ref: hpRef, encodedQuestion: frictionlessState.hp }) : null;
|
|
67
77
|
if (config.mode === types.ModeEnum.invisible) {
|
|
68
|
-
return
|
|
78
|
+
return honeypot;
|
|
69
79
|
}
|
|
70
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
81
|
+
honeypot,
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
83
|
+
procaptchaCommon.Checkbox,
|
|
84
|
+
{
|
|
85
|
+
checked: state.isHuman,
|
|
86
|
+
theme,
|
|
87
|
+
onChange: async (event) => {
|
|
88
|
+
if (loading) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
setLoading(true);
|
|
92
|
+
let x = 0;
|
|
93
|
+
let y = 0;
|
|
94
|
+
const mouseOrTouchEvent = event.nativeEvent;
|
|
95
|
+
if (!mouseOrTouchEvent.isTrusted) {
|
|
96
|
+
} else if ("touches" in mouseOrTouchEvent && mouseOrTouchEvent.touches.length > 0 && mouseOrTouchEvent.touches[0]) {
|
|
97
|
+
x = mouseOrTouchEvent.touches[0].clientX;
|
|
98
|
+
y = mouseOrTouchEvent.touches[0].clientY;
|
|
99
|
+
} else if ("clientX" in mouseOrTouchEvent && "clientY" in mouseOrTouchEvent) {
|
|
100
|
+
x = mouseOrTouchEvent.clientX;
|
|
101
|
+
y = mouseOrTouchEvent.clientY;
|
|
102
|
+
}
|
|
103
|
+
await manager.current.start(x, y);
|
|
104
|
+
setLoading(false);
|
|
105
|
+
},
|
|
106
|
+
labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
|
|
107
|
+
error: state.error?.message,
|
|
108
|
+
"aria-label": "human checkbox",
|
|
109
|
+
loading
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] });
|
|
100
113
|
};
|
|
101
114
|
module.exports = Procaptcha;
|
|
@@ -7,7 +7,7 @@ const procaptchaCommon = require("@prosopo/procaptcha-common");
|
|
|
7
7
|
const types = require("@prosopo/types");
|
|
8
8
|
const util = require("@prosopo/util");
|
|
9
9
|
const utilCrypto = require("@prosopo/util-crypto");
|
|
10
|
-
const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState) => {
|
|
10
|
+
const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, onEscalate, getHoneypotValue) => {
|
|
11
11
|
const events = procaptchaCommon.getDefaultEvents(callbacks);
|
|
12
12
|
const defaultState = () => {
|
|
13
13
|
return {
|
|
@@ -130,10 +130,12 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
|
|
|
130
130
|
}
|
|
131
131
|
const providerUrl = getRandomProviderResponse.provider.url;
|
|
132
132
|
const providerApi = new api.ProviderApi(providerUrl, getDappAccount());
|
|
133
|
+
const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
|
|
133
134
|
const challenge = await providerApi.getPowCaptchaChallenge(
|
|
134
135
|
userAccount,
|
|
135
136
|
getDappAccount(),
|
|
136
|
-
frictionlessState?.sessionId
|
|
137
|
+
frictionlessState?.sessionId,
|
|
138
|
+
simdReadingsOnChallenge
|
|
137
139
|
);
|
|
138
140
|
if (challenge.error) {
|
|
139
141
|
updateState({
|
|
@@ -185,6 +187,9 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
|
|
|
185
187
|
} catch {
|
|
186
188
|
}
|
|
187
189
|
}
|
|
190
|
+
const simdReadings = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings() : void 0;
|
|
191
|
+
const hpValue = getHoneypotValue?.();
|
|
192
|
+
const clientMetaData = hpValue ? { hp: hpValue } : void 0;
|
|
188
193
|
const verifiedSolution = await providerApi.submitPowCaptchaSolution(
|
|
189
194
|
challenge,
|
|
190
195
|
getAccount().account.account.address,
|
|
@@ -193,9 +198,18 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
|
|
|
193
198
|
userTimestampSignature.signature.toString(),
|
|
194
199
|
config.captchas.pow.verifiedTimeout,
|
|
195
200
|
encryptedBehavioralData,
|
|
196
|
-
salt
|
|
201
|
+
salt,
|
|
202
|
+
simdReadings,
|
|
203
|
+
clientMetaData
|
|
197
204
|
);
|
|
198
|
-
|
|
205
|
+
const escalation = verifiedSolution[types.ApiParams.escalation];
|
|
206
|
+
if (escalation && (escalation[types.ApiParams.captchaType] === types.CaptchaType.image || escalation[types.ApiParams.captchaType] === types.CaptchaType.puzzle)) {
|
|
207
|
+
updateState({ loading: false });
|
|
208
|
+
onEscalate?.(
|
|
209
|
+
escalation[types.ApiParams.captchaType],
|
|
210
|
+
escalation[types.ApiParams.sessionId]
|
|
211
|
+
);
|
|
212
|
+
} else if (verifiedSolution[types.ApiParams.verified]) {
|
|
199
213
|
updateState({
|
|
200
214
|
isHuman: true,
|
|
201
215
|
loading: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQhE,QAAA,MAAM,UAAU,UAAW,eAAe,
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQhE,QAAA,MAAM,UAAU,UAAW,eAAe,4DAwIzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx } from "@emotion/react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs, Fragment } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useTranslation, loadI18next } from "@prosopo/locale";
|
|
3
|
-
import { useProcaptcha, buildUpdateState, Checkbox } from "@prosopo/procaptcha-common";
|
|
3
|
+
import { useProcaptcha, buildUpdateState, Honeypot, Checkbox } from "@prosopo/procaptcha-common";
|
|
4
4
|
import { ModeEnum } from "@prosopo/types";
|
|
5
5
|
import { lightTheme, darkTheme } from "@prosopo/widget-skeleton";
|
|
6
6
|
import { useState, useRef, useEffect } from "react";
|
|
@@ -16,8 +16,17 @@ const Procaptcha = (props) => {
|
|
|
16
16
|
const [state, _updateState] = useProcaptcha(useState, useRef);
|
|
17
17
|
const [loading, setLoading] = useState(false);
|
|
18
18
|
const updateState = buildUpdateState(state, _updateState);
|
|
19
|
+
const hpRef = useRef(null);
|
|
19
20
|
const manager = useRef(
|
|
20
|
-
Manager(
|
|
21
|
+
Manager(
|
|
22
|
+
config,
|
|
23
|
+
state,
|
|
24
|
+
updateState,
|
|
25
|
+
callbacks,
|
|
26
|
+
frictionlessState,
|
|
27
|
+
props.onEscalate,
|
|
28
|
+
() => hpRef.current?.value || void 0
|
|
29
|
+
)
|
|
21
30
|
);
|
|
22
31
|
useEffect(() => {
|
|
23
32
|
if (config.language) {
|
|
@@ -39,7 +48,7 @@ const Procaptcha = (props) => {
|
|
|
39
48
|
if (state.error.key === "CAPTCHA.NO_SESSION_FOUND" && frictionlessState) {
|
|
40
49
|
setTimeout(() => {
|
|
41
50
|
frictionlessState.restart();
|
|
42
|
-
},
|
|
51
|
+
}, 100);
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
54
|
}, [state.error, frictionlessState]);
|
|
@@ -63,39 +72,43 @@ const Procaptcha = (props) => {
|
|
|
63
72
|
return () => {
|
|
64
73
|
};
|
|
65
74
|
}, [config.mode]);
|
|
75
|
+
const honeypot = frictionlessState?.hp ? /* @__PURE__ */ jsx(Honeypot, { ref: hpRef, encodedQuestion: frictionlessState.hp }) : null;
|
|
66
76
|
if (config.mode === ModeEnum.invisible) {
|
|
67
|
-
return
|
|
77
|
+
return honeypot;
|
|
68
78
|
}
|
|
69
|
-
return /* @__PURE__ */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
+
honeypot,
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
Checkbox,
|
|
83
|
+
{
|
|
84
|
+
checked: state.isHuman,
|
|
85
|
+
theme,
|
|
86
|
+
onChange: async (event) => {
|
|
87
|
+
if (loading) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setLoading(true);
|
|
91
|
+
let x = 0;
|
|
92
|
+
let y = 0;
|
|
93
|
+
const mouseOrTouchEvent = event.nativeEvent;
|
|
94
|
+
if (!mouseOrTouchEvent.isTrusted) {
|
|
95
|
+
} else if ("touches" in mouseOrTouchEvent && mouseOrTouchEvent.touches.length > 0 && mouseOrTouchEvent.touches[0]) {
|
|
96
|
+
x = mouseOrTouchEvent.touches[0].clientX;
|
|
97
|
+
y = mouseOrTouchEvent.touches[0].clientY;
|
|
98
|
+
} else if ("clientX" in mouseOrTouchEvent && "clientY" in mouseOrTouchEvent) {
|
|
99
|
+
x = mouseOrTouchEvent.clientX;
|
|
100
|
+
y = mouseOrTouchEvent.clientY;
|
|
101
|
+
}
|
|
102
|
+
await manager.current.start(x, y);
|
|
103
|
+
setLoading(false);
|
|
104
|
+
},
|
|
105
|
+
labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
|
|
106
|
+
error: state.error?.message,
|
|
107
|
+
"aria-label": "human checkbox",
|
|
108
|
+
loading
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
] });
|
|
99
112
|
};
|
|
100
113
|
export {
|
|
101
114
|
Procaptcha as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":";AAcA,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U,CAAC,IAAI,CAAC,CAAC;oBAGjB,IAAI,CAAC,GAAG,CAAC,CAAC;oBACV,IAAI,CAAC,GAAG,CAAC,CAAC;oBAIV,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC;oBAC5C,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC;oBAEnC,CAAC;yBAAM,IACN,SAAS,IAAI,iBAAiB;wBAC9B,iBAAiB,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;wBACpC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,EAC3B,CAAC;wBACF,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;wBACzC,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;oBAC1C,CAAC;yBAAM,IACN,SAAS,IAAI,iBAAiB;wBAC9B,SAAS,IAAI,iBAAiB,EAC7B,CAAC;wBACF,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC;wBAC9B,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC;oBAC/B,CAAC;oBAED,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAClC,UAAU,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC,EACD,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,EAC3D,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,gBAChB,gBAAgB,EAC3B,OAAO,EAAE,OAAO,GACf,IACA,CACH,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type FrictionlessState, type ProcaptchaCallbacks, type ProcaptchaClientConfigInput, type ProcaptchaState, type ProcaptchaStateUpdateFn } from "@prosopo/types";
|
|
2
|
-
export declare const Manager: (configInput: ProcaptchaClientConfigInput, state: ProcaptchaState, onStateUpdate: ProcaptchaStateUpdateFn, callbacks: ProcaptchaCallbacks, frictionlessState?: FrictionlessState) => {
|
|
1
|
+
import { type FrictionlessState, type ProcaptchaCallbacks, type ProcaptchaClientConfigInput, type ProcaptchaEscalationHandler, type ProcaptchaState, type ProcaptchaStateUpdateFn } from "@prosopo/types";
|
|
2
|
+
export declare const Manager: (configInput: ProcaptchaClientConfigInput, state: ProcaptchaState, onStateUpdate: ProcaptchaStateUpdateFn, callbacks: ProcaptchaCallbacks, frictionlessState?: FrictionlessState, onEscalate?: ProcaptchaEscalationHandler, getHoneypotValue?: () => string | undefined) => {
|
|
3
3
|
start: (x?: number, y?: number) => Promise<void>;
|
|
4
4
|
resetState: (frictionlessRestart?: () => void) => void;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"AAwBA,OAAO,
|
|
1
|
+
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"AAwBA,OAAO,EAIN,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAEhC,KAAK,2BAA2B,EAChC,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE5B,MAAM,gBAAgB,CAAC;AAKxB,eAAO,MAAM,OAAO,gBACN,2BAA2B,SACjC,eAAe,iBACP,uBAAuB,aAC3B,mBAAmB,sBACV,iBAAiB,eACxB,2BAA2B,qBAIrB,MAAM,MAAM,GAAG,SAAS;;uCA+ED,MAAM,IAAI;CAmQpD,CAAC"}
|
package/dist/services/Manager.js
CHANGED
|
@@ -2,10 +2,10 @@ import { stringToHex } from "@polkadot/util/string";
|
|
|
2
2
|
import { ProviderApi } from "@prosopo/api";
|
|
3
3
|
import { ProsopoEnvError } from "@prosopo/common";
|
|
4
4
|
import { getDefaultEvents, buildUpdateState, providerRetry, ExtensionLoader, getProcaptchaRandomActiveProvider } from "@prosopo/procaptcha-common";
|
|
5
|
-
import { ProcaptchaConfigSchema, ApiParams, encodeProcaptchaOutput } from "@prosopo/types";
|
|
5
|
+
import { ProcaptchaConfigSchema, ApiParams, CaptchaType, encodeProcaptchaOutput } from "@prosopo/types";
|
|
6
6
|
import { sleep, solvePoW, embedData } from "@prosopo/util";
|
|
7
7
|
import { randomAsHex } from "@prosopo/util-crypto";
|
|
8
|
-
const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState) => {
|
|
8
|
+
const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, onEscalate, getHoneypotValue) => {
|
|
9
9
|
const events = getDefaultEvents(callbacks);
|
|
10
10
|
const defaultState = () => {
|
|
11
11
|
return {
|
|
@@ -128,10 +128,12 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
|
|
|
128
128
|
}
|
|
129
129
|
const providerUrl = getRandomProviderResponse.provider.url;
|
|
130
130
|
const providerApi = new ProviderApi(providerUrl, getDappAccount());
|
|
131
|
+
const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
|
|
131
132
|
const challenge = await providerApi.getPowCaptchaChallenge(
|
|
132
133
|
userAccount,
|
|
133
134
|
getDappAccount(),
|
|
134
|
-
frictionlessState?.sessionId
|
|
135
|
+
frictionlessState?.sessionId,
|
|
136
|
+
simdReadingsOnChallenge
|
|
135
137
|
);
|
|
136
138
|
if (challenge.error) {
|
|
137
139
|
updateState({
|
|
@@ -183,6 +185,9 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
|
|
|
183
185
|
} catch {
|
|
184
186
|
}
|
|
185
187
|
}
|
|
188
|
+
const simdReadings = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings() : void 0;
|
|
189
|
+
const hpValue = getHoneypotValue?.();
|
|
190
|
+
const clientMetaData = hpValue ? { hp: hpValue } : void 0;
|
|
186
191
|
const verifiedSolution = await providerApi.submitPowCaptchaSolution(
|
|
187
192
|
challenge,
|
|
188
193
|
getAccount().account.account.address,
|
|
@@ -191,9 +196,18 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
|
|
|
191
196
|
userTimestampSignature.signature.toString(),
|
|
192
197
|
config.captchas.pow.verifiedTimeout,
|
|
193
198
|
encryptedBehavioralData,
|
|
194
|
-
salt
|
|
199
|
+
salt,
|
|
200
|
+
simdReadings,
|
|
201
|
+
clientMetaData
|
|
195
202
|
);
|
|
196
|
-
|
|
203
|
+
const escalation = verifiedSolution[ApiParams.escalation];
|
|
204
|
+
if (escalation && (escalation[ApiParams.captchaType] === CaptchaType.image || escalation[ApiParams.captchaType] === CaptchaType.puzzle)) {
|
|
205
|
+
updateState({ loading: false });
|
|
206
|
+
onEscalate?.(
|
|
207
|
+
escalation[ApiParams.captchaType],
|
|
208
|
+
escalation[ApiParams.sessionId]
|
|
209
|
+
);
|
|
210
|
+
} else if (verifiedSolution[ApiParams.verified]) {
|
|
197
211
|
updateState({
|
|
198
212
|
isHuman: true,
|
|
199
213
|
loading: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manager.js","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACN,eAAe,EACf,gBAAgB,EAChB,iCAAiC,EACjC,aAAa,GACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAEN,SAAS,
|
|
1
|
+
{"version":3,"file":"Manager.js","sourceRoot":"","sources":["../../src/services/Manager.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,u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CACb,sBAAsB,CAAC;wBACtB,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW;wBACpC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO;wBACtD,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE;wBAClC,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS;wBAC1C,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,QAAQ;wBAC3B,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS;wBAC1C,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;4BACtB,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,QAAQ;4BAClD,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gCACjB,CAAC,SAAS,CAAC,SAAS,CAAC,EACpB,sBAAsB,CAAC,SAAS,CAAC,QAAQ,EAAE;6BAC5C;yBACD;qBACD,CAAC,CACF,CAAC;oBACF,wBAAwB,EAAE,CAAC;gBAC5B,CAAC;qBAAM,CAAC;oBACP,QAAQ,EAAE,CAAC;gBACZ,CAAC;YACF,CAAC;QACF,CAAC,EACD,KAAK,EACL,GAAG,EAAE;YACJ,UAAU,EAAE,CAAC;QACd,CAAC,EACD,KAAK,CAAC,YAAY,EAClB,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACN,KAAK;QACL,UAAU;KACV,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-pow",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.5",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"browserslist": ["> 0.5%, last 2 versions, not dead"],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@polkadot/util": "13.5.7",
|
|
33
|
-
"@prosopo/api": "3.
|
|
34
|
-
"@prosopo/common": "3.1.
|
|
35
|
-
"@prosopo/locale": "3.
|
|
36
|
-
"@prosopo/procaptcha-common": "2.
|
|
37
|
-
"@prosopo/types": "3.
|
|
38
|
-
"@prosopo/util": "3.2.
|
|
33
|
+
"@prosopo/api": "3.4.9",
|
|
34
|
+
"@prosopo/common": "3.1.38",
|
|
35
|
+
"@prosopo/locale": "3.2.4",
|
|
36
|
+
"@prosopo/procaptcha-common": "2.10.18",
|
|
37
|
+
"@prosopo/types": "4.3.1",
|
|
38
|
+
"@prosopo/util": "3.2.15",
|
|
39
39
|
"@prosopo/util-crypto": "13.5.29",
|
|
40
|
-
"@prosopo/widget-skeleton": "2.
|
|
40
|
+
"@prosopo/widget-skeleton": "2.8.3",
|
|
41
41
|
"react": "18.3.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@prosopo/config": "3.3.
|
|
44
|
+
"@prosopo/config": "3.3.1",
|
|
45
45
|
"@emotion/react": "11.11.1",
|
|
46
46
|
"@emotion/styled": "11.11.0",
|
|
47
47
|
"@types/node": "22.10.2",
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
|
60
|
-
"url": "git+https://github.com/prosopo/captcha.git"
|
|
60
|
+
"url": "git+https://github.com/prosopo/captcha.git",
|
|
61
|
+
"directory": "packages/procaptcha-pow"
|
|
61
62
|
},
|
|
62
63
|
"bugs": {
|
|
63
64
|
"url": "https://github.com/prosopo/captcha/issues"
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { ProcaptchaProps } from "@prosopo/types";
|
|
16
|
+
import { type LazyExoticComponent, Suspense, lazy } from "react";
|
|
17
|
+
import type { ReactElement } from "react";
|
|
18
|
+
|
|
19
|
+
// Define the function signature more precisely
|
|
20
|
+
type ProcaptchaWidgetComponent = (
|
|
21
|
+
props: ProcaptchaProps,
|
|
22
|
+
) => ReactElement | null;
|
|
23
|
+
|
|
24
|
+
// Lazy load the widget with the correct type signature
|
|
25
|
+
const ProcaptchaWidget: LazyExoticComponent<ProcaptchaWidgetComponent> = lazy(
|
|
26
|
+
async () => import("./ProcaptchaWidget.js"),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const ProcaptchaPow = (props: ProcaptchaProps) => (
|
|
30
|
+
<Suspense>
|
|
31
|
+
<ProcaptchaWidget
|
|
32
|
+
config={props.config}
|
|
33
|
+
callbacks={props.callbacks}
|
|
34
|
+
frictionlessState={props.frictionlessState}
|
|
35
|
+
i18n={props.i18n}
|
|
36
|
+
/>
|
|
37
|
+
</Suspense>
|
|
38
|
+
);
|