@prosopo/procaptcha-pow 2.8.27 → 2.9.4

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.
@@ -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(config, state, updateState, callbacks, frictionlessState)
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
- }, 3e3);
52
+ }, 100);
44
53
  }
45
54
  }
46
55
  }, [state.error, frictionlessState]);
@@ -64,27 +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 null;
78
+ return honeypot;
69
79
  }
70
- return /* @__PURE__ */ jsxRuntime.jsx(
71
- procaptchaCommon.Checkbox,
72
- {
73
- checked: state.isHuman,
74
- onChange: async () => {
75
- if (loading) {
76
- return;
77
- }
78
- setLoading(true);
79
- await manager.current.start();
80
- setLoading(false);
81
- },
82
- theme,
83
- labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
84
- error: state.error?.message,
85
- "aria-label": "human checkbox",
86
- loading
87
- }
88
- );
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
+ ] });
89
113
  };
90
114
  module.exports = Procaptcha;
@@ -6,7 +6,8 @@ const common = require("@prosopo/common");
6
6
  const procaptchaCommon = require("@prosopo/procaptcha-common");
7
7
  const types = require("@prosopo/types");
8
8
  const util = require("@prosopo/util");
9
- const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState) => {
9
+ const utilCrypto = require("@prosopo/util-crypto");
10
+ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, onEscalate, getHoneypotValue) => {
10
11
  const events = procaptchaCommon.getDefaultEvents(callbacks);
11
12
  const defaultState = () => {
12
13
  return {
@@ -43,7 +44,6 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
43
44
  userAccountAddress: configInput.userAccountAddress || "",
44
45
  ...configInput
45
46
  };
46
- console.log("Using config:", config);
47
47
  if (state.account) {
48
48
  config.userAccountAddress = state.account.account.address;
49
49
  }
@@ -84,7 +84,7 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
84
84
  }, timeMillis);
85
85
  updateState({ successfullChallengeTimeout });
86
86
  };
87
- const start = async () => {
87
+ const start = async (x = 0, y = 0) => {
88
88
  await procaptchaCommon.providerRetry(
89
89
  async () => {
90
90
  if (state.loading) {
@@ -107,7 +107,6 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
107
107
  return ext.getAccount(config);
108
108
  };
109
109
  const user = await selectAccount();
110
- console.log("User", user);
111
110
  const userAccount = user.account.address;
112
111
  updateState({
113
112
  account: { account: { address: userAccount } }
@@ -131,10 +130,12 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
131
130
  }
132
131
  const providerUrl = getRandomProviderResponse.provider.url;
133
132
  const providerApi = new api.ProviderApi(providerUrl, getDappAccount());
133
+ const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
134
134
  const challenge = await providerApi.getPowCaptchaChallenge(
135
135
  userAccount,
136
136
  getDappAccount(),
137
- frictionlessState?.sessionId
137
+ frictionlessState?.sessionId,
138
+ simdReadingsOnChallenge
138
139
  );
139
140
  if (challenge.error) {
140
141
  updateState({
@@ -145,7 +146,18 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
145
146
  }
146
147
  });
147
148
  } else {
148
- const solution = util.solvePoW(challenge.challenge, challenge.difficulty);
149
+ const solution = await util.solvePoW(
150
+ challenge.challenge,
151
+ challenge.difficulty
152
+ );
153
+ let salt;
154
+ if (x !== void 0 && y !== void 0) {
155
+ const coords = [x, y];
156
+ const randomSalt = utilCrypto.randomAsHex(
157
+ coords.map((coord) => coord.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0)
158
+ );
159
+ salt = util.embedData(randomSalt, coords);
160
+ }
149
161
  const signer = user.extension?.signer;
150
162
  if (!signer || !signer.signRaw) {
151
163
  throw new common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
@@ -159,15 +171,45 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
159
171
  data: string.stringToHex(challenge[types.ApiParams.timestamp].toString()),
160
172
  type: "bytes"
161
173
  });
174
+ let encryptedBehavioralData;
175
+ if (frictionlessState?.encryptBehavioralData && (frictionlessState?.behaviorCollector1 || frictionlessState?.behaviorCollector2 || frictionlessState?.behaviorCollector3)) {
176
+ try {
177
+ const behavioralData = {
178
+ collector1: frictionlessState.behaviorCollector1?.getData() || [],
179
+ collector2: frictionlessState.behaviorCollector2?.getData() || [],
180
+ collector3: frictionlessState.behaviorCollector3?.getData() || [],
181
+ deviceCapability: frictionlessState.deviceCapability || "unknown"
182
+ };
183
+ const dataToEncrypt = frictionlessState.packBehavioralData ? frictionlessState.packBehavioralData(behavioralData) : behavioralData;
184
+ encryptedBehavioralData = await frictionlessState.encryptBehavioralData(
185
+ JSON.stringify(dataToEncrypt)
186
+ );
187
+ } catch {
188
+ }
189
+ }
190
+ const simdReadings = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings() : void 0;
191
+ const hpValue = getHoneypotValue?.();
192
+ const clientMetaData = hpValue ? { hp: hpValue } : void 0;
162
193
  const verifiedSolution = await providerApi.submitPowCaptchaSolution(
163
194
  challenge,
164
195
  getAccount().account.account.address,
165
196
  getDappAccount(),
166
197
  solution,
167
198
  userTimestampSignature.signature.toString(),
168
- config.captchas.pow.verifiedTimeout
199
+ config.captchas.pow.verifiedTimeout,
200
+ encryptedBehavioralData,
201
+ salt,
202
+ simdReadings,
203
+ clientMetaData
169
204
  );
170
- if (verifiedSolution[types.ApiParams.verified]) {
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]) {
171
213
  updateState({
172
214
  isHuman: true,
173
215
  loading: false
@@ -0,0 +1,3 @@
1
+ import type { ProcaptchaProps } from "@prosopo/types";
2
+ export declare const ProcaptchaPow: (props: ProcaptchaProps) => import("@emotion/react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=ProcaptchaPoW.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcaptchaPoW.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaPoW.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AActD,eAAO,MAAM,aAAa,UAAW,eAAe,qDASnD,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcaptchaPoW.js","sourceRoot":"","sources":["../../src/components/ProcaptchaPoW.tsx"],"names":[],"mappings":";AAeA,OAAO,EAA4B,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AASjE,MAAM,gBAAgB,GAAmD,IAAI,CAC5E,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAsB,EAAE,EAAE,CAAC,CACxD,KAAC,QAAQ,cACR,KAAC,gBAAgB,IAChB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAC1C,IAAI,EAAE,KAAK,CAAC,IAAI,GACf,GACQ,CACX,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type ProcaptchaProps } from "@prosopo/types";
2
+ declare const Procaptcha: (props: ProcaptchaProps) => import("@emotion/react/jsx-runtime").JSX.Element | null;
3
+ export default Procaptcha;
4
+ //# sourceMappingURL=ProcaptchaWidget.d.ts.map
@@ -0,0 +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,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(config, state, updateState, callbacks, frictionlessState)
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
- }, 3e3);
51
+ }, 100);
43
52
  }
44
53
  }
45
54
  }, [state.error, frictionlessState]);
@@ -63,28 +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 null;
77
+ return honeypot;
68
78
  }
69
- return /* @__PURE__ */ jsx(
70
- Checkbox,
71
- {
72
- checked: state.isHuman,
73
- onChange: async () => {
74
- if (loading) {
75
- return;
76
- }
77
- setLoading(true);
78
- await manager.current.start();
79
- setLoading(false);
80
- },
81
- theme,
82
- labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
83
- error: state.error?.message,
84
- "aria-label": "human checkbox",
85
- loading
86
- }
87
- );
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
+ ] });
88
112
  };
89
113
  export {
90
114
  Procaptcha as default
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":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{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC"}
@@ -0,0 +1,6 @@
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
+ start: (x?: number, y?: number) => Promise<void>;
4
+ resetState: (frictionlessRestart?: () => void) => void;
5
+ };
6
+ //# sourceMappingURL=Manager.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -2,9 +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";
6
- import { sleep, solvePoW } from "@prosopo/util";
7
- const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState) => {
5
+ import { ProcaptchaConfigSchema, ApiParams, CaptchaType, encodeProcaptchaOutput } from "@prosopo/types";
6
+ import { sleep, solvePoW, embedData } from "@prosopo/util";
7
+ import { randomAsHex } from "@prosopo/util-crypto";
8
+ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, onEscalate, getHoneypotValue) => {
8
9
  const events = getDefaultEvents(callbacks);
9
10
  const defaultState = () => {
10
11
  return {
@@ -41,7 +42,6 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
41
42
  userAccountAddress: configInput.userAccountAddress || "",
42
43
  ...configInput
43
44
  };
44
- console.log("Using config:", config);
45
45
  if (state.account) {
46
46
  config.userAccountAddress = state.account.account.address;
47
47
  }
@@ -82,7 +82,7 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
82
82
  }, timeMillis);
83
83
  updateState({ successfullChallengeTimeout });
84
84
  };
85
- const start = async () => {
85
+ const start = async (x = 0, y = 0) => {
86
86
  await providerRetry(
87
87
  async () => {
88
88
  if (state.loading) {
@@ -105,7 +105,6 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
105
105
  return ext.getAccount(config);
106
106
  };
107
107
  const user = await selectAccount();
108
- console.log("User", user);
109
108
  const userAccount = user.account.address;
110
109
  updateState({
111
110
  account: { account: { address: userAccount } }
@@ -129,10 +128,12 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
129
128
  }
130
129
  const providerUrl = getRandomProviderResponse.provider.url;
131
130
  const providerApi = new ProviderApi(providerUrl, getDappAccount());
131
+ const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
132
132
  const challenge = await providerApi.getPowCaptchaChallenge(
133
133
  userAccount,
134
134
  getDappAccount(),
135
- frictionlessState?.sessionId
135
+ frictionlessState?.sessionId,
136
+ simdReadingsOnChallenge
136
137
  );
137
138
  if (challenge.error) {
138
139
  updateState({
@@ -143,7 +144,18 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
143
144
  }
144
145
  });
145
146
  } else {
146
- const solution = solvePoW(challenge.challenge, challenge.difficulty);
147
+ const solution = await solvePoW(
148
+ challenge.challenge,
149
+ challenge.difficulty
150
+ );
151
+ let salt;
152
+ if (x !== void 0 && y !== void 0) {
153
+ const coords = [x, y];
154
+ const randomSalt = randomAsHex(
155
+ coords.map((coord) => coord.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0)
156
+ );
157
+ salt = embedData(randomSalt, coords);
158
+ }
147
159
  const signer = user.extension?.signer;
148
160
  if (!signer || !signer.signRaw) {
149
161
  throw new ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
@@ -157,15 +169,45 @@ const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState
157
169
  data: stringToHex(challenge[ApiParams.timestamp].toString()),
158
170
  type: "bytes"
159
171
  });
172
+ let encryptedBehavioralData;
173
+ if (frictionlessState?.encryptBehavioralData && (frictionlessState?.behaviorCollector1 || frictionlessState?.behaviorCollector2 || frictionlessState?.behaviorCollector3)) {
174
+ try {
175
+ const behavioralData = {
176
+ collector1: frictionlessState.behaviorCollector1?.getData() || [],
177
+ collector2: frictionlessState.behaviorCollector2?.getData() || [],
178
+ collector3: frictionlessState.behaviorCollector3?.getData() || [],
179
+ deviceCapability: frictionlessState.deviceCapability || "unknown"
180
+ };
181
+ const dataToEncrypt = frictionlessState.packBehavioralData ? frictionlessState.packBehavioralData(behavioralData) : behavioralData;
182
+ encryptedBehavioralData = await frictionlessState.encryptBehavioralData(
183
+ JSON.stringify(dataToEncrypt)
184
+ );
185
+ } catch {
186
+ }
187
+ }
188
+ const simdReadings = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings() : void 0;
189
+ const hpValue = getHoneypotValue?.();
190
+ const clientMetaData = hpValue ? { hp: hpValue } : void 0;
160
191
  const verifiedSolution = await providerApi.submitPowCaptchaSolution(
161
192
  challenge,
162
193
  getAccount().account.account.address,
163
194
  getDappAccount(),
164
195
  solution,
165
196
  userTimestampSignature.signature.toString(),
166
- config.captchas.pow.verifiedTimeout
197
+ config.captchas.pow.verifiedTimeout,
198
+ encryptedBehavioralData,
199
+ salt,
200
+ simdReadings,
201
+ clientMetaData
167
202
  );
168
- if (verifiedSolution[ApiParams.verified]) {
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]) {
169
211
  updateState({
170
212
  isHuman: true,
171
213
  loading: false
@@ -0,0 +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,EACT,WAAW,EAIX,sBAAsB,EAItB,sBAAsB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,C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AAS,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.8.27",
3
+ "version": "2.9.4",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,8 @@
21
21
  "source": "./src/index.ts",
22
22
  "scripts": {
23
23
  "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
24
- "build": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
24
+ "build": "npm run build:cross-env -- --mode ${NODE_ENV:-development}",
25
+ "build:cross-env": "vite build --config vite.esm.config.ts",
25
26
  "build:tsc": "tsc --build --verbose",
26
27
  "build:cjs": "NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
27
28
  "typecheck": "tsc --project tsconfig.types.json"
@@ -29,17 +30,18 @@
29
30
  "browserslist": ["> 0.5%, last 2 versions, not dead"],
30
31
  "dependencies": {
31
32
  "@polkadot/util": "13.5.7",
32
- "@prosopo/api": "3.1.37",
33
- "@prosopo/common": "3.1.26",
34
- "@prosopo/locale": "3.1.26",
35
- "@prosopo/procaptcha-common": "2.9.19",
36
- "@prosopo/types": "3.6.4",
37
- "@prosopo/util": "3.2.4",
38
- "@prosopo/widget-skeleton": "2.7.12",
33
+ "@prosopo/api": "3.4.8",
34
+ "@prosopo/common": "3.1.38",
35
+ "@prosopo/locale": "3.2.4",
36
+ "@prosopo/procaptcha-common": "2.10.17",
37
+ "@prosopo/types": "4.3.0",
38
+ "@prosopo/util": "3.2.15",
39
+ "@prosopo/util-crypto": "13.5.29",
40
+ "@prosopo/widget-skeleton": "2.8.3",
39
41
  "react": "18.3.1"
40
42
  },
41
43
  "devDependencies": {
42
- "@prosopo/config": "3.1.26",
44
+ "@prosopo/config": "3.3.1",
43
45
  "@emotion/react": "11.11.1",
44
46
  "@emotion/styled": "11.11.0",
45
47
  "@types/node": "22.10.2",
@@ -55,7 +57,8 @@
55
57
  },
56
58
  "repository": {
57
59
  "type": "git",
58
- "url": "git+https://github.com/prosopo/captcha.git"
60
+ "url": "git+https://github.com/prosopo/captcha.git",
61
+ "directory": "packages/procaptcha-pow"
59
62
  },
60
63
  "bugs": {
61
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
+ );