@prosopo/procaptcha-puzzle 2.10.39 → 2.10.41
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 +13 -11
- package/.turbo/turbo-build$colon$tsc.log +19 -19
- package/.turbo/turbo-build.log +15 -12
- package/CHANGELOG.md +41 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/components/ProcaptchaPuzzle.cjs +6 -9
- package/dist/cjs/components/ProcaptchaWidget.cjs +191 -213
- package/dist/cjs/components/PuzzleCanvas.cjs +228 -270
- package/dist/cjs/index.cjs +2 -4
- package/dist/cjs/services/Manager.cjs +209 -289
- package/dist/components/ProcaptchaPuzzle.js +6 -8
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +190 -212
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/dist/components/PuzzleCanvas.js +229 -271
- package/dist/index.js +2 -4
- package/dist/services/Manager.d.ts.map +1 -1
- package/dist/services/Manager.js +205 -286
- package/dist/services/Manager.js.map +1 -1
- package/dist/tests/manager.unit.test.d.ts +2 -0
- package/dist/tests/manager.unit.test.d.ts.map +1 -0
- package/dist/tests/manager.unit.test.js +506 -0
- package/dist/tests/manager.unit.test.js.map +1 -0
- package/dist/tests/managerHarness.d.ts +20 -0
- package/dist/tests/managerHarness.d.ts.map +1 -0
- package/dist/tests/managerHarness.js +86 -0
- package/dist/tests/managerHarness.js.map +1 -0
- package/dist/tests/procaptchaPuzzle.test-d.d.ts +2 -0
- package/dist/tests/procaptchaPuzzle.test-d.d.ts.map +1 -0
- package/dist/tests/procaptchaPuzzle.test-d.js +97 -0
- package/dist/tests/procaptchaPuzzle.test-d.js.map +1 -0
- package/dist/tests/procaptchaPuzzle.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaPuzzle.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaPuzzle.unit.test.js +81 -0
- package/dist/tests/procaptchaPuzzle.unit.test.js.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.js +547 -0
- package/dist/tests/procaptchaWidget.unit.test.js.map +1 -0
- package/dist/tests/puzzleCanvas.unit.test.d.ts +2 -0
- package/dist/tests/puzzleCanvas.unit.test.d.ts.map +1 -0
- package/dist/tests/puzzleCanvas.unit.test.js +312 -0
- package/dist/tests/puzzleCanvas.unit.test.js.map +1 -0
- package/dist/tests/setup.d.ts +5 -0
- package/dist/tests/setup.d.ts.map +1 -0
- package/dist/tests/setup.js +3 -0
- package/dist/tests/setup.js.map +1 -0
- package/package.json +17 -12
- package/src/components/ProcaptchaWidget.tsx +17 -6
- package/src/services/Manager.ts +14 -10
- package/src/tests/manager.unit.test.ts +763 -0
- package/src/tests/managerHarness.ts +169 -0
- package/src/tests/procaptchaPuzzle.test-d.ts +191 -0
- package/src/tests/procaptchaPuzzle.unit.test.ts +123 -0
- package/src/tests/procaptchaWidget.unit.test.ts +789 -0
- package/src/tests/puzzleCanvas.unit.test.ts +418 -0
- package/src/tests/setup.ts +26 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.test.config.ts +27 -0
|
@@ -1,291 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const userTimestampSignature = await signer.signRaw({
|
|
210
|
-
address: user.account.address,
|
|
211
|
-
data: string.stringToHex(challenge[types.ApiParams.timestamp].toString()),
|
|
212
|
-
type: "bytes"
|
|
213
|
-
});
|
|
214
|
-
let encryptedBehavioralData;
|
|
215
|
-
if (frictionlessState?.encryptBehavioralData && (frictionlessState?.behaviorCollector1 || frictionlessState?.behaviorCollector2 || frictionlessState?.behaviorCollector3)) {
|
|
216
|
-
try {
|
|
217
|
-
const behavioralData = {
|
|
218
|
-
collector1: frictionlessState.behaviorCollector1?.getData() || [],
|
|
219
|
-
collector2: frictionlessState.behaviorCollector2?.getData() || [],
|
|
220
|
-
collector3: frictionlessState.behaviorCollector3?.getData() || [],
|
|
221
|
-
deviceCapability: frictionlessState.deviceCapability || "unknown"
|
|
222
|
-
};
|
|
223
|
-
const dataToEncrypt = frictionlessState.packBehavioralData ? frictionlessState.packBehavioralData(behavioralData) : behavioralData;
|
|
224
|
-
encryptedBehavioralData = await frictionlessState.encryptBehavioralData(
|
|
225
|
-
JSON.stringify(dataToEncrypt)
|
|
226
|
-
);
|
|
227
|
-
} catch {
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
let salt;
|
|
231
|
-
if (storedClickX !== void 0 && storedClickY !== void 0) {
|
|
232
|
-
const coords = [storedClickX, storedClickY];
|
|
233
|
-
const randomSalt = utilCrypto.randomAsHex(
|
|
234
|
-
coords.map((coord) => coord.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0)
|
|
235
|
-
);
|
|
236
|
-
salt = util.embedData(randomSalt, coords);
|
|
237
|
-
}
|
|
238
|
-
const simdReadings = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings() : void 0;
|
|
239
|
-
const hpValue = getHoneypotValue?.();
|
|
240
|
-
const clientMetaData = hpValue ? { hp: hpValue } : void 0;
|
|
241
|
-
const verifiedSolution = await providerApi.submitPuzzleCaptchaSolution(
|
|
242
|
-
challenge,
|
|
243
|
-
getAccount().account.account.address,
|
|
244
|
-
getDappAccount(),
|
|
245
|
-
finalX,
|
|
246
|
-
finalY,
|
|
247
|
-
puzzleEvents,
|
|
248
|
-
userTimestampSignature.signature.toString(),
|
|
249
|
-
encryptedBehavioralData,
|
|
250
|
-
salt,
|
|
251
|
-
simdReadings,
|
|
252
|
-
clientMetaData
|
|
253
|
-
);
|
|
254
|
-
if (verifiedSolution[types.ApiParams.verified]) {
|
|
255
|
-
updateState({
|
|
256
|
-
isHuman: true,
|
|
257
|
-
loading: false
|
|
258
|
-
});
|
|
259
|
-
events.onHuman(
|
|
260
|
-
types.encodeProcaptchaOutput({
|
|
261
|
-
[types.ApiParams.providerUrl]: providerUrl,
|
|
262
|
-
[types.ApiParams.user]: getAccount().account.account.address,
|
|
263
|
-
[types.ApiParams.dapp]: getDappAccount(),
|
|
264
|
-
[types.ApiParams.challenge]: challenge.challenge,
|
|
265
|
-
[types.ApiParams.timestamp]: challenge.timestamp,
|
|
266
|
-
[types.ApiParams.signature]: {
|
|
267
|
-
[types.ApiParams.provider]: challenge.signature.provider,
|
|
268
|
-
[types.ApiParams.user]: {
|
|
269
|
-
[types.ApiParams.timestamp]: userTimestampSignature.signature.toString()
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
[types.ApiParams.captchaType]: types.CaptchaType.puzzle
|
|
273
|
-
})
|
|
274
|
-
);
|
|
275
|
-
setValidChallengeTimeout();
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
onFailed();
|
|
279
|
-
return false;
|
|
280
|
-
} catch (error) {
|
|
281
|
-
updateState({ loading: false });
|
|
282
|
-
throw error;
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
return {
|
|
286
|
-
start,
|
|
287
|
-
submitSolution,
|
|
288
|
-
resetState
|
|
289
|
-
};
|
|
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_util = require("@prosopo/util");
|
|
7
|
+
let _prosopo_util_crypto = require("@prosopo/util-crypto");
|
|
8
|
+
//#region src/services/Manager.ts
|
|
9
|
+
var Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, getHoneypotValue) => {
|
|
10
|
+
const events = (0, _prosopo_procaptcha_common.getDefaultEvents)(callbacks);
|
|
11
|
+
let storedChallengeResponse;
|
|
12
|
+
let storedProviderApi;
|
|
13
|
+
let storedProviderUrl;
|
|
14
|
+
let storedUser;
|
|
15
|
+
let storedClickX;
|
|
16
|
+
let storedClickY;
|
|
17
|
+
let previousProviderUrl;
|
|
18
|
+
const defaultState = () => {
|
|
19
|
+
return {
|
|
20
|
+
showModal: false,
|
|
21
|
+
loading: false,
|
|
22
|
+
index: 0,
|
|
23
|
+
challenge: void 0,
|
|
24
|
+
solutions: void 0,
|
|
25
|
+
isHuman: false,
|
|
26
|
+
captchaApi: void 0,
|
|
27
|
+
account: void 0
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const clearTimeout = () => {
|
|
31
|
+
window.clearTimeout(Number(state.timeout));
|
|
32
|
+
updateState({ timeout: void 0 });
|
|
33
|
+
};
|
|
34
|
+
const onFailed = () => {
|
|
35
|
+
updateState({
|
|
36
|
+
isHuman: false,
|
|
37
|
+
loading: false
|
|
38
|
+
});
|
|
39
|
+
events.onFailed();
|
|
40
|
+
resetState(frictionlessState?.restart);
|
|
41
|
+
};
|
|
42
|
+
const clearSuccessfulChallengeTimeout = () => {
|
|
43
|
+
window.clearTimeout(Number(state.successfullChallengeTimeout));
|
|
44
|
+
updateState({ successfullChallengeTimeout: void 0 });
|
|
45
|
+
};
|
|
46
|
+
const getConfig = () => {
|
|
47
|
+
const config = {
|
|
48
|
+
userAccountAddress: configInput.userAccountAddress || "",
|
|
49
|
+
...configInput
|
|
50
|
+
};
|
|
51
|
+
if (state.account) config.userAccountAddress = state.account.account.address;
|
|
52
|
+
return _prosopo_types.ProcaptchaConfigSchema.parse(config);
|
|
53
|
+
};
|
|
54
|
+
const getAccount = () => {
|
|
55
|
+
if (!state.account) throw new _prosopo_common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
|
|
56
|
+
return { account: state.account };
|
|
57
|
+
};
|
|
58
|
+
const getDappAccount = () => {
|
|
59
|
+
if (!state.dappAccount) throw new _prosopo_common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
|
|
60
|
+
return state.dappAccount;
|
|
61
|
+
};
|
|
62
|
+
const updateState = (0, _prosopo_procaptcha_common.buildUpdateState)(state, onStateUpdate);
|
|
63
|
+
const resetState = (frictionlessRestart) => {
|
|
64
|
+
clearTimeout();
|
|
65
|
+
clearSuccessfulChallengeTimeout();
|
|
66
|
+
updateState(defaultState());
|
|
67
|
+
events.onReset();
|
|
68
|
+
if (frictionlessRestart) frictionlessRestart();
|
|
69
|
+
storedChallengeResponse = void 0;
|
|
70
|
+
storedProviderApi = void 0;
|
|
71
|
+
storedProviderUrl = void 0;
|
|
72
|
+
storedUser = void 0;
|
|
73
|
+
storedClickX = void 0;
|
|
74
|
+
storedClickY = void 0;
|
|
75
|
+
};
|
|
76
|
+
const setValidChallengeTimeout = () => {
|
|
77
|
+
const timeMillis = getConfig().captchas.puzzle.solutionTimeout;
|
|
78
|
+
const successfullChallengeTimeout = setTimeout(() => {
|
|
79
|
+
updateState({ isHuman: false });
|
|
80
|
+
events.onExpired();
|
|
81
|
+
resetState(frictionlessState?.restart);
|
|
82
|
+
}, timeMillis);
|
|
83
|
+
updateState({ successfullChallengeTimeout });
|
|
84
|
+
};
|
|
85
|
+
const start = async (x = 0, y = 0) => {
|
|
86
|
+
await (0, _prosopo_procaptcha_common.providerRetry)(async () => {
|
|
87
|
+
if (state.loading) return;
|
|
88
|
+
if (state.isHuman) return;
|
|
89
|
+
resetState();
|
|
90
|
+
storedClickX = x;
|
|
91
|
+
storedClickY = y;
|
|
92
|
+
updateState({ loading: true });
|
|
93
|
+
updateState({ attemptCount: state.attemptCount + 1 });
|
|
94
|
+
const config = getConfig();
|
|
95
|
+
const selectAccount = async () => {
|
|
96
|
+
if (frictionlessState) return frictionlessState.userAccount;
|
|
97
|
+
return new (await ((0, _prosopo_procaptcha_common.ExtensionLoader)(config.web2)))().getAccount(config);
|
|
98
|
+
};
|
|
99
|
+
const user = await selectAccount();
|
|
100
|
+
const userAccount = user.account.address;
|
|
101
|
+
updateState({ account: { account: { address: userAccount } } });
|
|
102
|
+
updateState({ dappAccount: config.account.address });
|
|
103
|
+
await (0, _prosopo_util.sleep)(100);
|
|
104
|
+
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" } });
|
|
105
|
+
let getRandomProviderResponse = void 0;
|
|
106
|
+
if (frictionlessState?.provider) getRandomProviderResponse = frictionlessState.provider;
|
|
107
|
+
else {
|
|
108
|
+
const currentConfig = getConfig();
|
|
109
|
+
getRandomProviderResponse = await (0, _prosopo_procaptcha_common.getProcaptchaRandomActiveProvider)(currentConfig.defaultEnvironment, (0, _prosopo_procaptcha_common.pickIpMode)(currentConfig), {
|
|
110
|
+
attempt: state.attemptCount,
|
|
111
|
+
excludeUrl: previousProviderUrl
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const providerUrl = getRandomProviderResponse.provider.url;
|
|
115
|
+
previousProviderUrl = providerUrl;
|
|
116
|
+
const providerApi = new _prosopo_api.ProviderApi(providerUrl, getDappAccount());
|
|
117
|
+
const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
|
|
118
|
+
const challenge = await providerApi.getPuzzleCaptchaChallenge(userAccount, getDappAccount(), frictionlessState?.sessionId, simdReadingsOnChallenge);
|
|
119
|
+
if (challenge.error) {
|
|
120
|
+
updateState({
|
|
121
|
+
loading: false,
|
|
122
|
+
error: {
|
|
123
|
+
message: challenge.error.message,
|
|
124
|
+
key: challenge.error.key || "API.UNKNOWN_ERROR"
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
storedChallengeResponse = challenge;
|
|
130
|
+
storedProviderApi = providerApi;
|
|
131
|
+
storedProviderUrl = providerUrl;
|
|
132
|
+
storedUser = user;
|
|
133
|
+
updateState({ loading: false });
|
|
134
|
+
}, async () => {
|
|
135
|
+
await start(x, y);
|
|
136
|
+
}, () => {
|
|
137
|
+
resetState();
|
|
138
|
+
}, state.attemptCount, 3);
|
|
139
|
+
return storedChallengeResponse;
|
|
140
|
+
};
|
|
141
|
+
const submitSolution = async (finalX, finalY, puzzleEvents) => {
|
|
142
|
+
if (!storedChallengeResponse || !storedProviderApi || !storedProviderUrl || !storedUser) throw new _prosopo_common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "No challenge data available. Call start() first." } });
|
|
143
|
+
updateState({ loading: true });
|
|
144
|
+
try {
|
|
145
|
+
const challenge = storedChallengeResponse;
|
|
146
|
+
const providerApi = storedProviderApi;
|
|
147
|
+
const providerUrl = storedProviderUrl;
|
|
148
|
+
const user = storedUser;
|
|
149
|
+
getConfig();
|
|
150
|
+
const signer = user.extension?.signer;
|
|
151
|
+
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" } });
|
|
152
|
+
const userTimestampSignature = await signer.signRaw({
|
|
153
|
+
address: user.account.address,
|
|
154
|
+
data: (0, _polkadot_util_string.stringToHex)(challenge[_prosopo_types.ApiParams.timestamp].toString()),
|
|
155
|
+
type: "bytes"
|
|
156
|
+
});
|
|
157
|
+
let encryptedBehavioralData;
|
|
158
|
+
if (frictionlessState?.encryptBehavioralData && (frictionlessState?.behaviorCollector1 || frictionlessState?.behaviorCollector2 || frictionlessState?.behaviorCollector3)) try {
|
|
159
|
+
const behavioralData = {
|
|
160
|
+
collector1: frictionlessState.behaviorCollector1?.getData() || [],
|
|
161
|
+
collector2: frictionlessState.behaviorCollector2?.getData() || [],
|
|
162
|
+
collector3: frictionlessState.behaviorCollector3?.getData() || [],
|
|
163
|
+
deviceCapability: frictionlessState.deviceCapability || "unknown"
|
|
164
|
+
};
|
|
165
|
+
const dataToEncrypt = frictionlessState.packBehavioralData ? frictionlessState.packBehavioralData(behavioralData) : behavioralData;
|
|
166
|
+
encryptedBehavioralData = await frictionlessState.encryptBehavioralData(JSON.stringify(dataToEncrypt));
|
|
167
|
+
} catch {}
|
|
168
|
+
let salt;
|
|
169
|
+
if (storedClickX !== void 0 && storedClickY !== void 0) {
|
|
170
|
+
const coords = [storedClickX, storedClickY];
|
|
171
|
+
const randomSalt = (0, _prosopo_util_crypto.randomAsHex)(coords.map((coord) => coord.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0));
|
|
172
|
+
salt = (0, _prosopo_util.embedData)(randomSalt, coords);
|
|
173
|
+
}
|
|
174
|
+
const simdReadings = await (0, _prosopo_procaptcha_common.getSimdReadingsForSubmit)(frictionlessState);
|
|
175
|
+
const hpValue = getHoneypotValue?.();
|
|
176
|
+
const clientMetaData = hpValue ? { hp: hpValue } : void 0;
|
|
177
|
+
if ((await providerApi.submitPuzzleCaptchaSolution(challenge, getAccount().account.account.address, getDappAccount(), finalX, finalY, puzzleEvents, userTimestampSignature.signature.toString(), encryptedBehavioralData, salt, simdReadings, clientMetaData))[_prosopo_types.ApiParams.verified]) {
|
|
178
|
+
updateState({
|
|
179
|
+
isHuman: true,
|
|
180
|
+
loading: false
|
|
181
|
+
});
|
|
182
|
+
events.onHuman((0, _prosopo_types.encodeProcaptchaOutput)({
|
|
183
|
+
[_prosopo_types.ApiParams.providerUrl]: providerUrl,
|
|
184
|
+
[_prosopo_types.ApiParams.user]: getAccount().account.account.address,
|
|
185
|
+
[_prosopo_types.ApiParams.dapp]: getDappAccount(),
|
|
186
|
+
[_prosopo_types.ApiParams.challenge]: challenge.challenge,
|
|
187
|
+
[_prosopo_types.ApiParams.timestamp]: challenge.timestamp,
|
|
188
|
+
[_prosopo_types.ApiParams.signature]: {
|
|
189
|
+
[_prosopo_types.ApiParams.provider]: challenge.signature.provider,
|
|
190
|
+
[_prosopo_types.ApiParams.user]: { [_prosopo_types.ApiParams.timestamp]: userTimestampSignature.signature.toString() }
|
|
191
|
+
},
|
|
192
|
+
[_prosopo_types.ApiParams.captchaType]: _prosopo_types.CaptchaType.puzzle
|
|
193
|
+
}));
|
|
194
|
+
setValidChallengeTimeout();
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
onFailed();
|
|
198
|
+
return false;
|
|
199
|
+
} catch (error) {
|
|
200
|
+
updateState({ loading: false });
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
start,
|
|
206
|
+
submitSolution,
|
|
207
|
+
resetState
|
|
208
|
+
};
|
|
290
209
|
};
|
|
210
|
+
//#endregion
|
|
291
211
|
exports.Manager = Manager;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { Suspense, lazy } from "react";
|
|
1
2
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
ProcaptchaPuzzle
|
|
9
|
-
};
|
|
3
|
+
//#region src/components/ProcaptchaPuzzle.tsx
|
|
4
|
+
var ProcaptchaWidget = lazy(async () => import("./ProcaptchaWidget.js"));
|
|
5
|
+
var ProcaptchaPuzzle = (props) => /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ProcaptchaWidget, { ...props }) });
|
|
6
|
+
//#endregion
|
|
7
|
+
export { ProcaptchaPuzzle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAGN,KAAK,eAAe,EAEpB,MAAM,gBAAgB,CAAC;AAWxB,QAAA,MAAM,UAAU,UAAW,eAAe,
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAGN,KAAK,eAAe,EAEpB,MAAM,gBAAgB,CAAC;AAWxB,QAAA,MAAM,UAAU,UAAW,eAAe,qDA0QzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|