@prosopo/procaptcha-pow 2.10.23 → 2.10.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +12 -10
  2. package/.turbo/turbo-build$colon$tsc.log +19 -19
  3. package/.turbo/turbo-build.log +14 -11
  4. package/CHANGELOG.md +46 -0
  5. package/dist/_virtual/_rolldown/runtime.js +3 -0
  6. package/dist/cjs/components/ProcaptchaPoW.cjs +6 -9
  7. package/dist/cjs/components/ProcaptchaWidget.cjs +117 -127
  8. package/dist/cjs/index.cjs +2 -4
  9. package/dist/cjs/services/Manager.cjs +193 -277
  10. package/dist/components/ProcaptchaPoW.js +6 -8
  11. package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
  12. package/dist/components/ProcaptchaWidget.js +117 -127
  13. package/dist/components/ProcaptchaWidget.js.map +1 -1
  14. package/dist/index.js +2 -4
  15. package/dist/services/Manager.d.ts.map +1 -1
  16. package/dist/services/Manager.js +189 -274
  17. package/dist/services/Manager.js.map +1 -1
  18. package/dist/tests/manager.unit.test.d.ts +2 -0
  19. package/dist/tests/manager.unit.test.d.ts.map +1 -0
  20. package/dist/tests/manager.unit.test.js +752 -0
  21. package/dist/tests/manager.unit.test.js.map +1 -0
  22. package/dist/tests/managerHarness.d.ts +17 -0
  23. package/dist/tests/managerHarness.d.ts.map +1 -0
  24. package/dist/tests/managerHarness.js +70 -0
  25. package/dist/tests/managerHarness.js.map +1 -0
  26. package/dist/tests/procaptchaPoW.unit.test.d.ts +2 -0
  27. package/dist/tests/procaptchaPoW.unit.test.d.ts.map +1 -0
  28. package/dist/tests/procaptchaPoW.unit.test.js +79 -0
  29. package/dist/tests/procaptchaPoW.unit.test.js.map +1 -0
  30. package/dist/tests/procaptchaPow.test-d.d.ts +2 -0
  31. package/dist/tests/procaptchaPow.test-d.d.ts.map +1 -0
  32. package/dist/tests/procaptchaPow.test-d.js +62 -0
  33. package/dist/tests/procaptchaPow.test-d.js.map +1 -0
  34. package/dist/tests/procaptchaWidget.unit.test.d.ts +2 -0
  35. package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -0
  36. package/dist/tests/procaptchaWidget.unit.test.js +410 -0
  37. package/dist/tests/procaptchaWidget.unit.test.js.map +1 -0
  38. package/package.json +18 -13
  39. package/src/components/ProcaptchaWidget.tsx +22 -5
  40. package/src/services/Manager.ts +9 -5
  41. package/src/tests/manager.unit.test.ts +1105 -0
  42. package/src/tests/managerHarness.ts +135 -0
  43. package/src/tests/procaptchaPoW.unit.test.ts +120 -0
  44. package/src/tests/procaptchaPow.test-d.ts +122 -0
  45. package/src/tests/procaptchaWidget.unit.test.ts +571 -0
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/vite.test.config.ts +25 -0
@@ -1,279 +1,195 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const string = require("@polkadot/util/string");
4
- const api = require("@prosopo/api");
5
- const common = require("@prosopo/common");
6
- const fingerprint = require("@prosopo/fingerprint");
7
- const procaptchaCommon = require("@prosopo/procaptcha-common");
8
- const types = require("@prosopo/types");
9
- const util = require("@prosopo/util");
10
- const utilCrypto = require("@prosopo/util-crypto");
11
- const Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, onEscalate, getHoneypotValue) => {
12
- const events = procaptchaCommon.getDefaultEvents(callbacks);
13
- let previousProviderUrl;
14
- const defaultState = () => {
15
- return {
16
- // note order matters! see buildUpdateState. These fields are set in order, so disable modal first, then set loading to false, etc.
17
- showModal: false,
18
- loading: false,
19
- index: 0,
20
- challenge: void 0,
21
- solutions: void 0,
22
- isHuman: false,
23
- captchaApi: void 0,
24
- account: void 0
25
- // don't handle timeout here, this should be handled by the state management
26
- };
27
- };
28
- const clearTimeout = () => {
29
- window.clearTimeout(Number(state.timeout));
30
- updateState({ timeout: void 0 });
31
- };
32
- const onFailed = () => {
33
- updateState({
34
- isHuman: false,
35
- loading: false
36
- });
37
- events.onFailed();
38
- resetState(frictionlessState?.restart);
39
- };
40
- const clearSuccessfulChallengeTimeout = () => {
41
- window.clearTimeout(Number(state.successfullChallengeTimeout));
42
- updateState({ successfullChallengeTimeout: void 0 });
43
- };
44
- const getConfig = () => {
45
- const config = {
46
- userAccountAddress: configInput.userAccountAddress || "",
47
- ...configInput
48
- };
49
- if (state.account) {
50
- config.userAccountAddress = state.account.account.address;
51
- }
52
- return types.ProcaptchaConfigSchema.parse(config);
53
- };
54
- const getAccount = () => {
55
- if (!state.account) {
56
- throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
57
- context: { error: "Account not loaded" }
58
- });
59
- }
60
- const account = state.account;
61
- return { account };
62
- };
63
- const getDappAccount = () => {
64
- if (!state.dappAccount) {
65
- throw new common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
66
- }
67
- const dappAccount = state.dappAccount;
68
- return dappAccount;
69
- };
70
- const updateState = procaptchaCommon.buildUpdateState(state, onStateUpdate);
71
- const resetState = (frictionlessRestart) => {
72
- clearTimeout();
73
- clearSuccessfulChallengeTimeout();
74
- updateState(defaultState());
75
- events.onReset();
76
- if (frictionlessRestart) {
77
- frictionlessRestart();
78
- }
79
- };
80
- const setValidChallengeTimeout = () => {
81
- const timeMillis = getConfig().captchas.pow.solutionTimeout;
82
- const successfullChallengeTimeout = setTimeout(() => {
83
- updateState({ isHuman: false });
84
- events.onExpired();
85
- resetState(frictionlessState?.restart);
86
- }, timeMillis);
87
- updateState({ successfullChallengeTimeout });
88
- };
89
- let checkboxClickX = 0;
90
- let checkboxClickY = 0;
91
- const start = async (x = 0, y = 0) => {
92
- checkboxClickX = x;
93
- checkboxClickY = y;
94
- await procaptchaCommon.providerRetry(
95
- async () => {
96
- if (state.loading) {
97
- return;
98
- }
99
- if (state.isHuman) {
100
- return;
101
- }
102
- resetState();
103
- updateState({
104
- loading: true
105
- });
106
- updateState({ attemptCount: state.attemptCount + 1 });
107
- const config = getConfig();
108
- const selectAccount = async () => {
109
- if (frictionlessState) {
110
- return frictionlessState.userAccount;
111
- }
112
- const ext = new (await procaptchaCommon.ExtensionLoader(config.web2))();
113
- return ext.getAccount(config);
114
- };
115
- const user = await selectAccount();
116
- const userAccount = user.account.address;
117
- updateState({
118
- account: { account: { address: userAccount } }
119
- });
120
- updateState({ dappAccount: config.account.address });
121
- await util.sleep(100);
122
- if (!config.web2 && !config.userAccountAddress) {
123
- throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
124
- context: {
125
- error: "Account address has not been set for web3 mode"
126
- }
127
- });
128
- }
129
- let getRandomProviderResponse = void 0;
130
- if (frictionlessState?.provider) {
131
- getRandomProviderResponse = frictionlessState.provider;
132
- } else {
133
- const currentConfig = getConfig();
134
- getRandomProviderResponse = await procaptchaCommon.getProcaptchaRandomActiveProvider(
135
- currentConfig.defaultEnvironment,
136
- procaptchaCommon.pickIpMode(currentConfig),
137
- { attempt: state.attemptCount, excludeUrl: previousProviderUrl }
138
- );
139
- }
140
- const providerUrl = getRandomProviderResponse.provider.url;
141
- previousProviderUrl = providerUrl;
142
- const providerApi = new api.ProviderApi(providerUrl, getDappAccount());
143
- const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
144
- const challenge = await providerApi.getPowCaptchaChallenge(
145
- userAccount,
146
- getDappAccount(),
147
- frictionlessState?.sessionId,
148
- simdReadingsOnChallenge
149
- );
150
- if (challenge.error) {
151
- updateState({
152
- loading: false,
153
- error: {
154
- message: challenge.error.message,
155
- key: challenge.error.key || "API.UNKNOWN_ERROR"
156
- }
157
- });
158
- } else {
159
- const solution = await util.solvePoW(
160
- challenge.challenge,
161
- challenge.difficulty
162
- );
163
- let salt;
164
- if (x !== void 0 && y !== void 0) {
165
- const coords = [x, y];
166
- const randomSalt = utilCrypto.randomAsHex(
167
- coords.map((coord) => coord.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0)
168
- );
169
- salt = util.embedData(randomSalt, coords);
170
- }
171
- const signer = user.extension?.signer;
172
- if (!signer || !signer.signRaw) {
173
- throw new common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
174
- context: {
175
- error: "Signer is not defined, cannot sign message to prove account ownership"
176
- }
177
- });
178
- }
179
- const userTimestampSignature = await signer.signRaw({
180
- address: userAccount,
181
- data: string.stringToHex(challenge[types.ApiParams.timestamp].toString()),
182
- type: "bytes"
183
- });
184
- let encryptedBehavioralData;
185
- if (frictionlessState?.encryptBehavioralData && (frictionlessState?.behaviorCollector1 || frictionlessState?.behaviorCollector2 || frictionlessState?.behaviorCollector3)) {
186
- try {
187
- const behavioralData = {
188
- collector1: frictionlessState.behaviorCollector1?.getData() || [],
189
- collector2: frictionlessState.behaviorCollector2?.getData() || [],
190
- collector3: frictionlessState.behaviorCollector3?.getData() || [],
191
- deviceCapability: frictionlessState.deviceCapability || "unknown"
192
- };
193
- const dataToEncrypt = frictionlessState.packBehavioralData ? frictionlessState.packBehavioralData(behavioralData) : behavioralData;
194
- encryptedBehavioralData = await frictionlessState.encryptBehavioralData(
195
- JSON.stringify(dataToEncrypt)
196
- );
197
- } catch {
198
- }
199
- }
200
- const simdReadings = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings() : void 0;
201
- const hpValue = getHoneypotValue?.();
202
- const clientMetaData = hpValue ? { hp: hpValue } : void 0;
203
- let fingerprintProof;
204
- try {
205
- fingerprintProof = fingerprint.encodeFingerprintProof(
206
- await fingerprint.getFingerprintProof(fingerprint.FINGERPRINT_DISCLOSURE_KEYS)
207
- );
208
- } catch {
209
- fingerprintProof = void 0;
210
- }
211
- const fpTest = globalThis.__prosopoFingerprintProofTest__;
212
- if (fpTest === "omit") {
213
- fingerprintProof = void 0;
214
- } else if (typeof fpTest === "string" && fpTest.length > 0) {
215
- fingerprintProof = "invalid-fingerprint-proof";
216
- }
217
- const verifiedSolution = await providerApi.submitPowCaptchaSolution(
218
- challenge,
219
- getAccount().account.account.address,
220
- getDappAccount(),
221
- solution,
222
- userTimestampSignature.signature.toString(),
223
- encryptedBehavioralData,
224
- salt,
225
- simdReadings,
226
- clientMetaData,
227
- fingerprintProof
228
- );
229
- const escalation = verifiedSolution[types.ApiParams.escalation];
230
- if (escalation && (escalation[types.ApiParams.captchaType] === types.CaptchaType.image || escalation[types.ApiParams.captchaType] === types.CaptchaType.puzzle)) {
231
- updateState({ loading: false });
232
- const isRealClick = checkboxClickX !== 0 || checkboxClickY !== 0;
233
- onEscalate?.(
234
- escalation[types.ApiParams.captchaType],
235
- escalation[types.ApiParams.sessionId],
236
- isRealClick ? { x: checkboxClickX, y: checkboxClickY } : void 0
237
- );
238
- } else if (verifiedSolution[types.ApiParams.verified]) {
239
- updateState({
240
- isHuman: true,
241
- loading: false
242
- });
243
- events.onHuman(
244
- types.encodeProcaptchaOutput({
245
- [types.ApiParams.providerUrl]: providerUrl,
246
- [types.ApiParams.user]: getAccount().account.account.address,
247
- [types.ApiParams.dapp]: getDappAccount(),
248
- [types.ApiParams.challenge]: challenge.challenge,
249
- [types.ApiParams.nonce]: solution,
250
- [types.ApiParams.timestamp]: challenge.timestamp,
251
- [types.ApiParams.signature]: {
252
- [types.ApiParams.provider]: challenge.signature.provider,
253
- [types.ApiParams.user]: {
254
- [types.ApiParams.timestamp]: userTimestampSignature.signature.toString()
255
- }
256
- },
257
- [types.ApiParams.captchaType]: types.CaptchaType.pow
258
- })
259
- );
260
- setValidChallengeTimeout();
261
- } else {
262
- onFailed();
263
- }
264
- }
265
- },
266
- start,
267
- () => {
268
- resetState();
269
- },
270
- state.attemptCount,
271
- 3
272
- );
273
- };
274
- return {
275
- start,
276
- resetState
277
- };
1
+ let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
2
+ let _prosopo_types = require("@prosopo/types");
3
+ let _polkadot_util_string = require("@polkadot/util/string");
4
+ let _prosopo_api = require("@prosopo/api");
5
+ let _prosopo_common = require("@prosopo/common");
6
+ let _prosopo_fingerprint = require("@prosopo/fingerprint");
7
+ let _prosopo_util = require("@prosopo/util");
8
+ let _prosopo_util_crypto = require("@prosopo/util-crypto");
9
+ //#region src/services/Manager.ts
10
+ var Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, onEscalate, getHoneypotValue) => {
11
+ const events = (0, _prosopo_procaptcha_common.getDefaultEvents)(callbacks);
12
+ let previousProviderUrl;
13
+ const defaultState = () => {
14
+ return {
15
+ showModal: false,
16
+ loading: false,
17
+ index: 0,
18
+ challenge: void 0,
19
+ solutions: void 0,
20
+ isHuman: false,
21
+ captchaApi: void 0,
22
+ account: void 0
23
+ };
24
+ };
25
+ const clearTimeout = () => {
26
+ window.clearTimeout(Number(state.timeout));
27
+ updateState({ timeout: void 0 });
28
+ };
29
+ const onFailed = () => {
30
+ updateState({
31
+ isHuman: false,
32
+ loading: false
33
+ });
34
+ events.onFailed();
35
+ resetState(frictionlessState?.restart);
36
+ };
37
+ const clearSuccessfulChallengeTimeout = () => {
38
+ window.clearTimeout(Number(state.successfullChallengeTimeout));
39
+ updateState({ successfullChallengeTimeout: void 0 });
40
+ };
41
+ const getConfig = () => {
42
+ const config = {
43
+ userAccountAddress: configInput.userAccountAddress || "",
44
+ ...configInput
45
+ };
46
+ if (state.account) config.userAccountAddress = state.account.account.address;
47
+ return _prosopo_types.ProcaptchaConfigSchema.parse(config);
48
+ };
49
+ const getAccount = () => {
50
+ if (!state.account) throw new _prosopo_common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
51
+ return { account: state.account };
52
+ };
53
+ const getDappAccount = () => {
54
+ if (!state.dappAccount) throw new _prosopo_common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
55
+ return state.dappAccount;
56
+ };
57
+ const updateState = (0, _prosopo_procaptcha_common.buildUpdateState)(state, onStateUpdate);
58
+ const resetState = (frictionlessRestart) => {
59
+ clearTimeout();
60
+ clearSuccessfulChallengeTimeout();
61
+ updateState(defaultState());
62
+ events.onReset();
63
+ if (frictionlessRestart) frictionlessRestart();
64
+ };
65
+ const setValidChallengeTimeout = () => {
66
+ const timeMillis = getConfig().captchas.pow.solutionTimeout;
67
+ const successfullChallengeTimeout = setTimeout(() => {
68
+ updateState({ isHuman: false });
69
+ events.onExpired();
70
+ resetState(frictionlessState?.restart);
71
+ }, timeMillis);
72
+ updateState({ successfullChallengeTimeout });
73
+ };
74
+ let checkboxClickX = 0;
75
+ let checkboxClickY = 0;
76
+ const start = async (x = 0, y = 0) => {
77
+ checkboxClickX = x;
78
+ checkboxClickY = y;
79
+ await (0, _prosopo_procaptcha_common.providerRetry)(async () => {
80
+ if (state.loading) return;
81
+ if (state.isHuman) return;
82
+ resetState();
83
+ updateState({ loading: true });
84
+ updateState({ attemptCount: state.attemptCount + 1 });
85
+ const config = getConfig();
86
+ const selectAccount = async () => {
87
+ if (frictionlessState) return frictionlessState.userAccount;
88
+ return new (await ((0, _prosopo_procaptcha_common.ExtensionLoader)(config.web2)))().getAccount(config);
89
+ };
90
+ const user = await selectAccount();
91
+ const userAccount = user.account.address;
92
+ updateState({ account: { account: { address: userAccount } } });
93
+ updateState({ dappAccount: config.account.address });
94
+ await (0, _prosopo_util.sleep)(100);
95
+ if (!config.web2 && !config.userAccountAddress) throw new _prosopo_common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account address has not been set for web3 mode" } });
96
+ let getRandomProviderResponse = void 0;
97
+ if (frictionlessState?.provider) getRandomProviderResponse = frictionlessState.provider;
98
+ else {
99
+ const currentConfig = getConfig();
100
+ getRandomProviderResponse = await (0, _prosopo_procaptcha_common.getProcaptchaRandomActiveProvider)(currentConfig.defaultEnvironment, (0, _prosopo_procaptcha_common.pickIpMode)(currentConfig), {
101
+ attempt: state.attemptCount,
102
+ excludeUrl: previousProviderUrl
103
+ });
104
+ }
105
+ const providerUrl = getRandomProviderResponse.provider.url;
106
+ previousProviderUrl = providerUrl;
107
+ const providerApi = new _prosopo_api.ProviderApi(providerUrl, getDappAccount());
108
+ const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
109
+ const challenge = await providerApi.getPowCaptchaChallenge(userAccount, getDappAccount(), frictionlessState?.sessionId, simdReadingsOnChallenge);
110
+ if (challenge.error) updateState({
111
+ loading: false,
112
+ error: {
113
+ message: challenge.error.message,
114
+ key: challenge.error.key || "API.UNKNOWN_ERROR"
115
+ }
116
+ });
117
+ else {
118
+ const solution = await (0, _prosopo_util.solvePoW)(challenge.challenge, challenge.difficulty);
119
+ let salt;
120
+ if (x !== void 0 && y !== void 0) {
121
+ const coords = [x, y];
122
+ const randomSalt = (0, _prosopo_util_crypto.randomAsHex)(coords.map((coord) => coord.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0));
123
+ salt = (0, _prosopo_util.embedData)(randomSalt, coords);
124
+ }
125
+ const signer = user.extension?.signer;
126
+ if (!signer || !signer.signRaw) throw new _prosopo_common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", { context: { error: "Signer is not defined, cannot sign message to prove account ownership" } });
127
+ const userTimestampSignature = await signer.signRaw({
128
+ address: userAccount,
129
+ data: (0, _polkadot_util_string.stringToHex)(challenge[_prosopo_types.ApiParams.timestamp].toString()),
130
+ type: "bytes"
131
+ });
132
+ let encryptedBehavioralData;
133
+ if (frictionlessState?.encryptBehavioralData && (frictionlessState?.behaviorCollector1 || frictionlessState?.behaviorCollector2 || frictionlessState?.behaviorCollector3)) try {
134
+ const behavioralData = {
135
+ collector1: frictionlessState.behaviorCollector1?.getData() || [],
136
+ collector2: frictionlessState.behaviorCollector2?.getData() || [],
137
+ collector3: frictionlessState.behaviorCollector3?.getData() || [],
138
+ deviceCapability: frictionlessState.deviceCapability || "unknown"
139
+ };
140
+ const dataToEncrypt = frictionlessState.packBehavioralData ? frictionlessState.packBehavioralData(behavioralData) : behavioralData;
141
+ encryptedBehavioralData = await frictionlessState.encryptBehavioralData(JSON.stringify(dataToEncrypt));
142
+ } catch {}
143
+ const simdReadings = await (0, _prosopo_procaptcha_common.getSimdReadingsForSubmit)(frictionlessState);
144
+ const hpValue = getHoneypotValue?.();
145
+ const clientMetaData = hpValue ? { hp: hpValue } : void 0;
146
+ let fingerprintProof;
147
+ try {
148
+ fingerprintProof = (0, _prosopo_fingerprint.encodeFingerprintProof)(await (0, _prosopo_fingerprint.getFingerprintProof)(_prosopo_fingerprint.FINGERPRINT_DISCLOSURE_KEYS));
149
+ } catch {
150
+ fingerprintProof = void 0;
151
+ }
152
+ const fpTest = globalThis.__prosopoFingerprintProofTest__;
153
+ if (fpTest === "omit") fingerprintProof = void 0;
154
+ else if (typeof fpTest === "string" && fpTest.length > 0) fingerprintProof = "invalid-fingerprint-proof";
155
+ const verifiedSolution = await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.account.address, getDappAccount(), solution, userTimestampSignature.signature.toString(), encryptedBehavioralData, salt, simdReadings, clientMetaData, fingerprintProof);
156
+ const escalation = verifiedSolution[_prosopo_types.ApiParams.escalation];
157
+ if (escalation && (escalation[_prosopo_types.ApiParams.captchaType] === _prosopo_types.CaptchaType.image || escalation[_prosopo_types.ApiParams.captchaType] === _prosopo_types.CaptchaType.puzzle)) {
158
+ updateState({ loading: false });
159
+ const isRealClick = checkboxClickX !== 0 || checkboxClickY !== 0;
160
+ onEscalate?.(escalation[_prosopo_types.ApiParams.captchaType], escalation[_prosopo_types.ApiParams.sessionId], isRealClick ? {
161
+ x: checkboxClickX,
162
+ y: checkboxClickY
163
+ } : void 0);
164
+ } else if (verifiedSolution[_prosopo_types.ApiParams.verified]) {
165
+ updateState({
166
+ isHuman: true,
167
+ loading: false
168
+ });
169
+ events.onHuman((0, _prosopo_types.encodeProcaptchaOutput)({
170
+ [_prosopo_types.ApiParams.providerUrl]: providerUrl,
171
+ [_prosopo_types.ApiParams.user]: getAccount().account.account.address,
172
+ [_prosopo_types.ApiParams.dapp]: getDappAccount(),
173
+ [_prosopo_types.ApiParams.challenge]: challenge.challenge,
174
+ [_prosopo_types.ApiParams.nonce]: solution,
175
+ [_prosopo_types.ApiParams.timestamp]: challenge.timestamp,
176
+ [_prosopo_types.ApiParams.signature]: {
177
+ [_prosopo_types.ApiParams.provider]: challenge.signature.provider,
178
+ [_prosopo_types.ApiParams.user]: { [_prosopo_types.ApiParams.timestamp]: userTimestampSignature.signature.toString() }
179
+ },
180
+ [_prosopo_types.ApiParams.captchaType]: _prosopo_types.CaptchaType.pow
181
+ }));
182
+ setValidChallengeTimeout();
183
+ } else onFailed();
184
+ }
185
+ }, () => start(x, y), () => {
186
+ resetState();
187
+ }, state.attemptCount, 3);
188
+ };
189
+ return {
190
+ start,
191
+ resetState
192
+ };
278
193
  };
194
+ //#endregion
279
195
  exports.Manager = Manager;
@@ -1,9 +1,7 @@
1
+ import { Suspense, lazy } from "react";
1
2
  import { jsx } from "@emotion/react/jsx-runtime";
2
- import { lazy, Suspense } from "react";
3
- const ProcaptchaWidget = lazy(
4
- async () => import("./ProcaptchaWidget.js")
5
- );
6
- const ProcaptchaPow = (props) => /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ProcaptchaWidget, { ...props }) });
7
- export {
8
- ProcaptchaPow
9
- };
3
+ //#region src/components/ProcaptchaPoW.tsx
4
+ var ProcaptchaWidget = lazy(async () => import("./ProcaptchaWidget.js"));
5
+ var ProcaptchaPow = (props) => /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ProcaptchaWidget, { ...props }) });
6
+ //#endregion
7
+ export { ProcaptchaPow };
@@ -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,4DAwKzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
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,4DAyLzC,CAAC;AAEF,eAAe,UAAU,CAAC"}