@prosopo/procaptcha 2.7.14 → 2.7.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @prosopo/procaptcha
2
2
 
3
+ ## 2.7.16
4
+ ### Patch Changes
5
+
6
+ - @prosopo/datasets@3.0.11
7
+
8
+ ## 2.7.15
9
+ ### Patch Changes
10
+
11
+ - 3573f0b: fix npm scripts bundle command
12
+ - 3573f0b: build using vite, typecheck using tsc
13
+ - efd8102: Add tests for unwrap error helper
14
+ - 3573f0b: standardise all vite based npm scripts for bundling
15
+ - Updated dependencies [52dbf21]
16
+ - Updated dependencies [93d5e50]
17
+ - Updated dependencies [3573f0b]
18
+ - Updated dependencies [8a64429]
19
+ - Updated dependencies [3573f0b]
20
+ - Updated dependencies [efd8102]
21
+ - Updated dependencies [93d5e50]
22
+ - Updated dependencies [63519d7]
23
+ - Updated dependencies [f29fc7e]
24
+ - Updated dependencies [3573f0b]
25
+ - Updated dependencies [2d0dd8a]
26
+ - Updated dependencies [6d604ad]
27
+ - @prosopo/util@3.0.3
28
+ - @prosopo/util-crypto@13.5.2
29
+ - @prosopo/types@3.0.4
30
+ - @prosopo/procaptcha-common@2.7.10
31
+ - @prosopo/load-balancer@2.6.15
32
+ - @prosopo/datasets@3.0.10
33
+ - @prosopo/account@2.7.10
34
+ - @prosopo/common@3.1.0
35
+ - @prosopo/api@3.1.1
36
+ - @prosopo/config@3.1.1
37
+
3
38
  ## 2.7.14
4
39
  ### Patch Changes
5
40
 
package/dist/index.js CHANGED
@@ -1,2 +1,9 @@
1
- export * from "./modules/index.js";
2
- //# sourceMappingURL=index.js.map
1
+ import "./modules/index.js";
2
+ import { Manager } from "./modules/Manager.js";
3
+ import { ProsopoCaptchaApi } from "./modules/ProsopoCaptchaApi.js";
4
+ import { startCollector } from "./modules/collector.js";
5
+ export {
6
+ Manager,
7
+ ProsopoCaptchaApi,
8
+ startCollector
9
+ };
@@ -1,312 +1,348 @@
1
1
  import { stringToHex } from "@polkadot/util/string";
2
2
  import { ProviderApi } from "@prosopo/api";
3
- import { ProsopoDatasetError, ProsopoEnvError, ProsopoError, } from "@prosopo/common";
4
- import { ExtensionLoader, buildUpdateState, getRandomActiveProvider, providerRetry, } from "@prosopo/procaptcha-common";
5
- import { getDefaultEvents } from "@prosopo/procaptcha-common";
6
- import { ApiParams, ProcaptchaConfigSchema, encodeProcaptchaOutput, } from "@prosopo/types";
7
- import { at, hashToHex } from "@prosopo/util";
8
- import { sleep } from "@prosopo/util";
3
+ import { ProsopoDatasetError, ProsopoError, ProsopoEnvError } from "@prosopo/common";
4
+ import { getDefaultEvents, buildUpdateState, providerRetry, getRandomActiveProvider, ExtensionLoader } from "@prosopo/procaptcha-common";
5
+ import { ProcaptchaConfigSchema, ApiParams, encodeProcaptchaOutput } from "@prosopo/types";
6
+ import { sleep, at, hashToHex } from "@prosopo/util";
9
7
  import { randomAsHex } from "@prosopo/util-crypto";
10
- import ProsopoCaptchaApi from "./ProsopoCaptchaApi.js";
8
+ import { ProsopoCaptchaApi } from "./ProsopoCaptchaApi.js";
11
9
  const defaultState = () => {
12
- return {
13
- showModal: false,
14
- loading: false,
15
- index: 0,
16
- challenge: undefined,
17
- solutions: undefined,
18
- isHuman: false,
19
- captchaApi: undefined,
20
- account: undefined,
21
- };
10
+ return {
11
+ // note order matters! see buildUpdateState. These fields are set in order, so disable modal first, then set loading to false, etc.
12
+ showModal: false,
13
+ loading: false,
14
+ index: 0,
15
+ challenge: void 0,
16
+ solutions: void 0,
17
+ isHuman: false,
18
+ captchaApi: void 0,
19
+ account: void 0
20
+ // don't handle timeout here, this should be handled by the state management
21
+ };
22
22
  };
23
- export function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessState) {
24
- const events = getDefaultEvents(callbacks);
25
- const updateState = buildUpdateState(state, onStateUpdate);
26
- const getConfig = () => {
27
- const config = {
28
- userAccountAddress: "",
29
- ...configOptional,
30
- };
31
- if (state.account) {
32
- config.userAccountAddress = state.account.account.address;
33
- }
34
- return ProcaptchaConfigSchema.parse(config);
35
- };
36
- const start = async () => {
37
- events.onOpen();
38
- await providerRetry(async () => {
39
- if (state.loading) {
40
- return;
41
- }
42
- if (state.isHuman) {
43
- return;
44
- }
45
- updateState({ loading: true });
46
- updateState({
47
- attemptCount: state.attemptCount ? state.attemptCount + 1 : 1,
48
- });
49
- updateState({
50
- sessionId: frictionlessState?.sessionId,
51
- });
52
- const config = getConfig();
53
- updateState({ dappAccount: config.account.address });
54
- await sleep(100);
55
- const account = await loadAccount();
56
- let captchaApi = state.captchaApi;
57
- if (!frictionlessState?.provider) {
58
- const getRandomProviderResponse = await getRandomActiveProvider(getConfig());
59
- const providerUrl = getRandomProviderResponse.provider.url;
60
- const providerApi = await loadProviderApi(providerUrl);
61
- captchaApi = new ProsopoCaptchaApi(account.account.address, getRandomProviderResponse, providerApi, config.web2, config.account.address || "");
62
- updateState({ captchaApi });
63
- }
64
- else {
65
- const providerUrl = frictionlessState.provider.provider.url;
66
- const providerApi = await loadProviderApi(providerUrl);
67
- captchaApi = new ProsopoCaptchaApi(account.account.address, frictionlessState.provider, providerApi, config.web2, config.account.address || "");
68
- updateState({ captchaApi });
69
- }
70
- const challenge = await captchaApi?.getCaptchaChallenge(state.sessionId);
71
- if (challenge.error) {
72
- updateState({
73
- loading: false,
74
- error: {
75
- message: challenge.error.message,
76
- key: challenge.error.key || "API.UNKNOWN_ERROR",
77
- },
78
- });
79
- events.onError(new Error(challenge.error?.message));
80
- }
81
- else {
82
- if (challenge.captchas.length <= 0) {
83
- throw new ProsopoDatasetError("DEVELOPER.PROVIDER_NO_CAPTCHA");
84
- }
85
- const timeMillis = challenge.captchas
86
- .map((captcha) => captcha.timeLimitMs || config.captchas.image.challengeTimeout)
87
- .reduce((a, b) => a + b);
88
- const timeout = setTimeout(() => {
89
- events.onChallengeExpired();
90
- updateState({ isHuman: false, showModal: false, loading: false });
91
- }, timeMillis);
92
- updateState({
93
- index: 0,
94
- solutions: challenge.captchas.map(() => []),
95
- challenge,
96
- showModal: true,
97
- timeout,
98
- loading: false,
99
- });
100
- }
101
- }, start, resetState, state.attemptCount, 10);
102
- };
103
- const submit = async () => {
104
- await providerRetry(async () => {
105
- clearTimeout();
106
- if (!state.challenge) {
107
- throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
108
- context: { error: "Cannot submit, no Captcha found in state" },
109
- });
110
- }
111
- updateState({ showModal: false });
112
- const challenge = state.challenge;
113
- const salt = randomAsHex();
114
- const captchaSolution = state.challenge.captchas.map((captcha, index) => {
115
- const solution = at(state.solutions, index);
116
- return {
117
- captchaId: captcha.captchaId,
118
- captchaContentId: captcha.captchaContentId,
119
- salt,
120
- solution,
121
- };
122
- });
123
- const account = getAccount();
124
- const signer = getExtension(account).signer;
125
- const first = at(challenge.captchas, 0);
126
- if (!first.datasetId) {
127
- throw new ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_ID", {
128
- context: { error: "No datasetId set for challenge" },
129
- });
130
- }
131
- const captchaApi = state.captchaApi;
132
- if (!captchaApi) {
133
- throw new ProsopoError("CAPTCHA.INVALID_TOKEN", {
134
- context: { error: "No Captcha API found in state" },
135
- });
136
- }
137
- if (!signer || !signer.signRaw) {
138
- throw new ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
139
- context: {
140
- error: "Signer is not defined, cannot sign message to prove account ownership",
141
- },
142
- });
143
- }
144
- const userTimestampSignature = await signer.signRaw({
145
- address: account.account.address,
146
- data: stringToHex(challenge[ApiParams.timestamp]),
147
- type: "bytes",
148
- });
149
- const submission = await captchaApi.submitCaptchaSolution(userTimestampSignature.signature, challenge.requestHash, captchaSolution, challenge.timestamp, challenge.signature.provider.requestHash);
150
- const isHuman = submission[0].verified;
151
- updateState({
152
- submission,
153
- isHuman,
154
- loading: false,
155
- });
156
- if (state.isHuman) {
157
- const providerUrl = captchaApi.provider.provider.url;
158
- events.onHuman(encodeProcaptchaOutput({
159
- [ApiParams.providerUrl]: providerUrl,
160
- [ApiParams.user]: account.account.address,
161
- [ApiParams.dapp]: getDappAccount(),
162
- [ApiParams.commitmentId]: hashToHex(submission[1]),
163
- [ApiParams.timestamp]: challenge.timestamp,
164
- [ApiParams.signature]: {
165
- [ApiParams.provider]: {
166
- [ApiParams.requestHash]: challenge.signature.provider.requestHash,
167
- },
168
- [ApiParams.user]: {
169
- [ApiParams.timestamp]: userTimestampSignature.signature,
170
- },
171
- },
172
- }));
173
- setValidChallengeTimeout();
174
- }
175
- else {
176
- events.onFailed();
177
- resetState(frictionlessState?.restart);
178
- }
179
- }, start, resetState, state.attemptCount, 10);
180
- };
181
- const cancel = async () => {
182
- clearTimeout();
183
- resetState(frictionlessState?.restart);
184
- events.onClose();
185
- };
186
- const reload = async () => {
187
- clearTimeout();
188
- events.onReload();
189
- resetState(frictionlessState?.restart);
190
- if (!frictionlessState?.restart) {
191
- await start();
192
- }
23
+ function Manager(configOptional, state, onStateUpdate, callbacks, frictionlessState) {
24
+ const events = getDefaultEvents(callbacks);
25
+ const updateState = buildUpdateState(state, onStateUpdate);
26
+ const getConfig = () => {
27
+ const config = {
28
+ userAccountAddress: "",
29
+ ...configOptional
193
30
  };
194
- const select = (hash) => {
195
- if (!state.challenge) {
196
- throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
197
- context: { error: "Cannot select, no Captcha found in state" },
198
- });
31
+ if (state.account) {
32
+ config.userAccountAddress = state.account.account.address;
33
+ }
34
+ return ProcaptchaConfigSchema.parse(config);
35
+ };
36
+ const start = async () => {
37
+ events.onOpen();
38
+ await providerRetry(
39
+ async () => {
40
+ if (state.loading) {
41
+ return;
199
42
  }
200
- if (state.index >= state.challenge.captchas.length || state.index < 0) {
201
- throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
202
- context: {
203
- error: "Cannot select, index is out of range for this Captcha",
204
- },
205
- });
43
+ if (state.isHuman) {
44
+ return;
206
45
  }
207
- const index = state.index;
208
- const solutions = state.solutions;
209
- const solution = at(solutions, index);
210
- if (solution.includes(hash)) {
211
- solution.splice(solution.indexOf(hash), 1);
46
+ updateState({ loading: true });
47
+ updateState({
48
+ attemptCount: state.attemptCount ? state.attemptCount + 1 : 1
49
+ });
50
+ updateState({
51
+ sessionId: frictionlessState?.sessionId
52
+ });
53
+ const config = getConfig();
54
+ updateState({ dappAccount: config.account.address });
55
+ await sleep(100);
56
+ const account = await loadAccount();
57
+ let captchaApi = state.captchaApi;
58
+ if (!frictionlessState?.provider) {
59
+ const getRandomProviderResponse = await getRandomActiveProvider(
60
+ getConfig()
61
+ );
62
+ const providerUrl = getRandomProviderResponse.provider.url;
63
+ const providerApi = await loadProviderApi(providerUrl);
64
+ captchaApi = new ProsopoCaptchaApi(
65
+ account.account.address,
66
+ getRandomProviderResponse,
67
+ providerApi,
68
+ config.web2,
69
+ config.account.address || ""
70
+ );
71
+ updateState({ captchaApi });
72
+ } else {
73
+ const providerUrl = frictionlessState.provider.provider.url;
74
+ const providerApi = await loadProviderApi(providerUrl);
75
+ captchaApi = new ProsopoCaptchaApi(
76
+ account.account.address,
77
+ frictionlessState.provider,
78
+ providerApi,
79
+ config.web2,
80
+ config.account.address || ""
81
+ );
82
+ updateState({ captchaApi });
212
83
  }
213
- else {
214
- solution.push(hash);
84
+ const challenge = await captchaApi?.getCaptchaChallenge(
85
+ state.sessionId
86
+ );
87
+ if (challenge.error) {
88
+ updateState({
89
+ loading: false,
90
+ error: {
91
+ message: challenge.error.message,
92
+ key: challenge.error.key || "API.UNKNOWN_ERROR"
93
+ }
94
+ });
95
+ events.onError(new Error(challenge.error?.message));
96
+ } else {
97
+ if (challenge.captchas.length <= 0) {
98
+ throw new ProsopoDatasetError("DEVELOPER.PROVIDER_NO_CAPTCHA");
99
+ }
100
+ const timeMillis = challenge.captchas.map(
101
+ (captcha) => captcha.timeLimitMs || config.captchas.image.challengeTimeout
102
+ ).reduce((a, b) => a + b);
103
+ const timeout = setTimeout(() => {
104
+ events.onChallengeExpired();
105
+ updateState({ isHuman: false, showModal: false, loading: false });
106
+ }, timeMillis);
107
+ updateState({
108
+ index: 0,
109
+ solutions: challenge.captchas.map(() => []),
110
+ challenge,
111
+ showModal: true,
112
+ timeout,
113
+ loading: false
114
+ });
215
115
  }
216
- updateState({ solutions });
217
- };
218
- const nextRound = () => {
116
+ },
117
+ start,
118
+ resetState,
119
+ state.attemptCount,
120
+ 10
121
+ );
122
+ };
123
+ const submit = async () => {
124
+ await providerRetry(
125
+ async () => {
126
+ clearTimeout();
219
127
  if (!state.challenge) {
220
- throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
221
- context: { error: "Cannot select, no Captcha found in state" },
222
- });
223
- }
224
- if (state.index + 1 >= state.challenge.captchas.length) {
225
- throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
226
- context: {
227
- error: "Cannot select, index is out of range for this Captcha",
228
- },
229
- });
128
+ throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
129
+ context: { error: "Cannot submit, no Captcha found in state" }
130
+ });
230
131
  }
231
- updateState({ index: state.index + 1 });
232
- };
233
- const loadProviderApi = async (providerUrl) => {
234
- const config = getConfig();
235
- if (!config.account.address) {
236
- throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
132
+ updateState({ showModal: false });
133
+ const challenge = state.challenge;
134
+ const salt = randomAsHex();
135
+ const captchaSolution = state.challenge.captchas.map(
136
+ (captcha, index) => {
137
+ const solution = at(state.solutions, index);
138
+ return {
139
+ captchaId: captcha.captchaId,
140
+ captchaContentId: captcha.captchaContentId,
141
+ salt,
142
+ solution
143
+ };
144
+ }
145
+ );
146
+ const account = getAccount();
147
+ const signer = getExtension(account).signer;
148
+ const first = at(challenge.captchas, 0);
149
+ if (!first.datasetId) {
150
+ throw new ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_ID", {
151
+ context: { error: "No datasetId set for challenge" }
152
+ });
237
153
  }
238
- return new ProviderApi(providerUrl, config.account.address);
239
- };
240
- const clearTimeout = () => {
241
- window.clearTimeout(Number(state.timeout));
242
- updateState({ timeout: undefined });
243
- };
244
- const setValidChallengeTimeout = () => {
245
- const timeMillis = configOptional.captchas.image.solutionTimeout;
246
- const successfullChallengeTimeout = setTimeout(() => {
247
- updateState({ isHuman: false });
248
- events.onExpired();
249
- }, timeMillis);
250
- updateState({ successfullChallengeTimeout });
251
- };
252
- const resetState = (frictionlessRestart) => {
253
- clearTimeout();
254
- updateState(defaultState());
255
- events.onReset();
256
- if (frictionlessRestart) {
257
- frictionlessRestart();
154
+ const captchaApi = state.captchaApi;
155
+ if (!captchaApi) {
156
+ throw new ProsopoError("CAPTCHA.INVALID_TOKEN", {
157
+ context: { error: "No Captcha API found in state" }
158
+ });
258
159
  }
259
- };
260
- const loadAccount = async () => {
261
- const config = getConfig();
262
- if (!config.web2 && !config.userAccountAddress) {
263
- throw new ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
264
- context: { error: "Account address has not been set for web3 mode" },
265
- });
266
- }
267
- const selectAccount = async () => {
268
- const ext = new (await ExtensionLoader(config.web2))();
269
- if (frictionlessState) {
270
- return frictionlessState.userAccount;
160
+ if (!signer || !signer.signRaw) {
161
+ throw new ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", {
162
+ context: {
163
+ error: "Signer is not defined, cannot sign message to prove account ownership"
271
164
  }
272
- return await ext.getAccount(config);
273
- };
274
- const account = await selectAccount();
275
- updateState({ account });
276
- return getAccount();
277
- };
278
- const getAccount = () => {
279
- if (!state.account) {
280
- throw new ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
281
- context: { error: "Account not loaded" },
282
- });
165
+ });
283
166
  }
284
- const account = state.account;
285
- return account;
286
- };
287
- const getDappAccount = () => {
288
- if (!state.dappAccount) {
289
- throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
167
+ const userTimestampSignature = await signer.signRaw({
168
+ address: account.account.address,
169
+ data: stringToHex(challenge[ApiParams.timestamp]),
170
+ type: "bytes"
171
+ });
172
+ const submission = await captchaApi.submitCaptchaSolution(
173
+ userTimestampSignature.signature,
174
+ challenge.requestHash,
175
+ captchaSolution,
176
+ challenge.timestamp,
177
+ challenge.signature.provider.requestHash
178
+ );
179
+ const isHuman = submission[0].verified;
180
+ updateState({
181
+ submission,
182
+ isHuman,
183
+ loading: false
184
+ });
185
+ if (state.isHuman) {
186
+ const providerUrl = captchaApi.provider.provider.url;
187
+ events.onHuman(
188
+ encodeProcaptchaOutput({
189
+ [ApiParams.providerUrl]: providerUrl,
190
+ [ApiParams.user]: account.account.address,
191
+ [ApiParams.dapp]: getDappAccount(),
192
+ [ApiParams.commitmentId]: hashToHex(submission[1]),
193
+ [ApiParams.timestamp]: challenge.timestamp,
194
+ [ApiParams.signature]: {
195
+ [ApiParams.provider]: {
196
+ [ApiParams.requestHash]: challenge.signature.provider.requestHash
197
+ },
198
+ [ApiParams.user]: {
199
+ [ApiParams.timestamp]: userTimestampSignature.signature
200
+ }
201
+ }
202
+ })
203
+ );
204
+ setValidChallengeTimeout();
205
+ } else {
206
+ events.onFailed();
207
+ resetState(frictionlessState?.restart);
290
208
  }
291
- const dappAccount = state.dappAccount;
292
- return dappAccount;
293
- };
294
- const getExtension = (possiblyAccount) => {
295
- const account = possiblyAccount || getAccount();
296
- if (!account.extension) {
297
- throw new ProsopoEnvError("ACCOUNT.NO_POLKADOT_EXTENSION", {
298
- context: { error: "Extension not loaded" },
299
- });
209
+ },
210
+ start,
211
+ resetState,
212
+ state.attemptCount,
213
+ 10
214
+ );
215
+ };
216
+ const cancel = async () => {
217
+ clearTimeout();
218
+ resetState(frictionlessState?.restart);
219
+ events.onClose();
220
+ };
221
+ const reload = async () => {
222
+ clearTimeout();
223
+ events.onReload();
224
+ resetState(frictionlessState?.restart);
225
+ if (!frictionlessState?.restart) {
226
+ await start();
227
+ }
228
+ };
229
+ const select = (hash) => {
230
+ if (!state.challenge) {
231
+ throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
232
+ context: { error: "Cannot select, no Captcha found in state" }
233
+ });
234
+ }
235
+ if (state.index >= state.challenge.captchas.length || state.index < 0) {
236
+ throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
237
+ context: {
238
+ error: "Cannot select, index is out of range for this Captcha"
300
239
  }
301
- return account.extension;
302
- };
303
- return {
304
- start,
305
- cancel,
306
- submit,
307
- select,
308
- nextRound,
309
- reload,
240
+ });
241
+ }
242
+ const index = state.index;
243
+ const solutions = state.solutions;
244
+ const solution = at(solutions, index);
245
+ if (solution.includes(hash)) {
246
+ solution.splice(solution.indexOf(hash), 1);
247
+ } else {
248
+ solution.push(hash);
249
+ }
250
+ updateState({ solutions });
251
+ };
252
+ const nextRound = () => {
253
+ if (!state.challenge) {
254
+ throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
255
+ context: { error: "Cannot select, no Captcha found in state" }
256
+ });
257
+ }
258
+ if (state.index + 1 >= state.challenge.captchas.length) {
259
+ throw new ProsopoError("CAPTCHA.NO_CAPTCHA", {
260
+ context: {
261
+ error: "Cannot select, index is out of range for this Captcha"
262
+ }
263
+ });
264
+ }
265
+ updateState({ index: state.index + 1 });
266
+ };
267
+ const loadProviderApi = async (providerUrl) => {
268
+ const config = getConfig();
269
+ if (!config.account.address) {
270
+ throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
271
+ }
272
+ return new ProviderApi(providerUrl, config.account.address);
273
+ };
274
+ const clearTimeout = () => {
275
+ window.clearTimeout(Number(state.timeout));
276
+ updateState({ timeout: void 0 });
277
+ };
278
+ const setValidChallengeTimeout = () => {
279
+ const timeMillis = configOptional.captchas.image.solutionTimeout;
280
+ const successfullChallengeTimeout = setTimeout(() => {
281
+ updateState({ isHuman: false });
282
+ events.onExpired();
283
+ }, timeMillis);
284
+ updateState({ successfullChallengeTimeout });
285
+ };
286
+ const resetState = (frictionlessRestart) => {
287
+ clearTimeout();
288
+ updateState(defaultState());
289
+ events.onReset();
290
+ if (frictionlessRestart) {
291
+ frictionlessRestart();
292
+ }
293
+ };
294
+ const loadAccount = async () => {
295
+ const config = getConfig();
296
+ if (!config.web2 && !config.userAccountAddress) {
297
+ throw new ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
298
+ context: { error: "Account address has not been set for web3 mode" }
299
+ });
300
+ }
301
+ const selectAccount = async () => {
302
+ const ext = new (await ExtensionLoader(config.web2))();
303
+ if (frictionlessState) {
304
+ return frictionlessState.userAccount;
305
+ }
306
+ return await ext.getAccount(config);
310
307
  };
308
+ const account = await selectAccount();
309
+ updateState({ account });
310
+ return getAccount();
311
+ };
312
+ const getAccount = () => {
313
+ if (!state.account) {
314
+ throw new ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
315
+ context: { error: "Account not loaded" }
316
+ });
317
+ }
318
+ const account = state.account;
319
+ return account;
320
+ };
321
+ const getDappAccount = () => {
322
+ if (!state.dappAccount) {
323
+ throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
324
+ }
325
+ const dappAccount = state.dappAccount;
326
+ return dappAccount;
327
+ };
328
+ const getExtension = (possiblyAccount) => {
329
+ const account = possiblyAccount || getAccount();
330
+ if (!account.extension) {
331
+ throw new ProsopoEnvError("ACCOUNT.NO_POLKADOT_EXTENSION", {
332
+ context: { error: "Extension not loaded" }
333
+ });
334
+ }
335
+ return account.extension;
336
+ };
337
+ return {
338
+ start,
339
+ cancel,
340
+ submit,
341
+ select,
342
+ nextRound,
343
+ reload
344
+ };
311
345
  }
312
- //# sourceMappingURL=Manager.js.map
346
+ export {
347
+ Manager
348
+ };
@@ -1,59 +1,72 @@
1
- import { ProsopoDatasetError, ProsopoEnvError } from "@prosopo/common";
2
- import { CaptchaMerkleTree, computeCaptchaSolutionHash, } from "@prosopo/datasets";
3
- import { ApiParams, } from "@prosopo/types";
4
- export class ProsopoCaptchaApi {
5
- constructor(userAccount, provider, providerApi, web2, dappAccount) {
6
- this.userAccount = userAccount;
7
- this.provider = provider;
8
- this.providerApi = providerApi;
9
- this._web2 = web2;
10
- this.dappAccount = dappAccount;
11
- }
12
- get web2() {
13
- return this._web2;
14
- }
15
- async getCaptchaChallenge(sessionId) {
16
- try {
17
- const captchaChallenge = await this.providerApi.getCaptchaChallenge(this.userAccount, this.provider, sessionId);
18
- if (captchaChallenge[ApiParams.error]) {
19
- return captchaChallenge;
20
- }
21
- for (const captcha of captchaChallenge.captchas) {
22
- for (const item of captcha.items) {
23
- if (item.data) {
24
- item.data = `https://${item.data.replace(/^http(s)*:\/\//, "")}`;
25
- }
26
- }
27
- }
28
- return captchaChallenge;
29
- }
30
- catch (error) {
31
- throw new ProsopoEnvError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
32
- context: { error },
33
- });
1
+ import { ProsopoEnvError, ProsopoDatasetError } from "@prosopo/common";
2
+ import { CaptchaMerkleTree, computeCaptchaSolutionHash } from "@prosopo/datasets";
3
+ import { ApiParams } from "@prosopo/types";
4
+ class ProsopoCaptchaApi {
5
+ constructor(userAccount, provider, providerApi, web2, dappAccount) {
6
+ this.userAccount = userAccount;
7
+ this.provider = provider;
8
+ this.providerApi = providerApi;
9
+ this._web2 = web2;
10
+ this.dappAccount = dappAccount;
11
+ }
12
+ get web2() {
13
+ return this._web2;
14
+ }
15
+ async getCaptchaChallenge(sessionId) {
16
+ try {
17
+ const captchaChallenge = await this.providerApi.getCaptchaChallenge(
18
+ this.userAccount,
19
+ this.provider,
20
+ sessionId
21
+ );
22
+ if (captchaChallenge[ApiParams.error]) {
23
+ return captchaChallenge;
24
+ }
25
+ for (const captcha of captchaChallenge.captchas) {
26
+ for (const item of captcha.items) {
27
+ if (item.data) {
28
+ item.data = `https://${item.data.replace(/^http(s)*:\/\//, "")}`;
29
+ }
34
30
  }
31
+ }
32
+ return captchaChallenge;
33
+ } catch (error) {
34
+ throw new ProsopoEnvError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
35
+ context: { error }
36
+ });
35
37
  }
36
- async submitCaptchaSolution(userTimestampSignature, requestHash, solutions, timestamp, providerRequestHashSignature) {
37
- const tree = new CaptchaMerkleTree();
38
- const captchasHashed = solutions.map((captcha) => computeCaptchaSolutionHash(captcha));
39
- tree.build(captchasHashed);
40
- if (!tree.root) {
41
- throw new ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
42
- context: { error: "Merkle tree root is undefined" },
43
- });
44
- }
45
- const commitmentId = tree.root.hash;
46
- let result;
47
- try {
48
- result = await this.providerApi.submitCaptchaSolution(solutions, requestHash, this.userAccount, timestamp, providerRequestHashSignature, userTimestampSignature);
49
- }
50
- catch (error) {
51
- throw new ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
52
- context: { error },
53
- });
54
- }
55
- return [result, commitmentId];
38
+ }
39
+ async submitCaptchaSolution(userTimestampSignature, requestHash, solutions, timestamp, providerRequestHashSignature) {
40
+ const tree = new CaptchaMerkleTree();
41
+ const captchasHashed = solutions.map(
42
+ (captcha) => computeCaptchaSolutionHash(captcha)
43
+ );
44
+ tree.build(captchasHashed);
45
+ if (!tree.root) {
46
+ throw new ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
47
+ context: { error: "Merkle tree root is undefined" }
48
+ });
49
+ }
50
+ const commitmentId = tree.root.hash;
51
+ let result;
52
+ try {
53
+ result = await this.providerApi.submitCaptchaSolution(
54
+ solutions,
55
+ requestHash,
56
+ this.userAccount,
57
+ timestamp,
58
+ providerRequestHashSignature,
59
+ userTimestampSignature
60
+ );
61
+ } catch (error) {
62
+ throw new ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
63
+ context: { error }
64
+ });
56
65
  }
66
+ return [result, commitmentId];
67
+ }
57
68
  }
58
- export default ProsopoCaptchaApi;
59
- //# sourceMappingURL=ProsopoCaptchaApi.js.map
69
+ export {
70
+ ProsopoCaptchaApi,
71
+ ProsopoCaptchaApi as default
72
+ };
@@ -1,54 +1,80 @@
1
- const COLLECTOR_LIMIT = 10000;
1
+ const COLLECTOR_LIMIT = 1e4;
2
2
  const storeLog = (event, setEvents) => {
3
- setEvents((currentEvents) => {
4
- let newEvents = [...currentEvents, event];
5
- if (newEvents.length > COLLECTOR_LIMIT) {
6
- newEvents = newEvents.slice(1);
7
- }
8
- return newEvents;
9
- });
3
+ setEvents((currentEvents) => {
4
+ let newEvents = [...currentEvents, event];
5
+ if (newEvents.length > COLLECTOR_LIMIT) {
6
+ newEvents = newEvents.slice(1);
7
+ }
8
+ return newEvents;
9
+ });
10
10
  };
11
11
  const logMouseEvent = (event, setMouseEvent) => {
12
- const storedEvent = {
13
- x: event.x,
14
- y: event.y,
15
- timestamp: event.timeStamp,
16
- };
17
- storeLog(storedEvent, setMouseEvent);
12
+ const storedEvent = {
13
+ x: event.x,
14
+ y: event.y,
15
+ timestamp: event.timeStamp
16
+ };
17
+ storeLog(storedEvent, setMouseEvent);
18
18
  };
19
19
  const logKeyboardEvent = (event, setKeyboardEvent) => {
20
- const storedEvent = {
21
- key: event.key,
22
- timestamp: event.timeStamp,
23
- isShiftKey: event.shiftKey,
24
- isCtrlKey: event.ctrlKey,
25
- };
26
- storeLog(storedEvent, setKeyboardEvent);
20
+ const storedEvent = {
21
+ key: event.key,
22
+ timestamp: event.timeStamp,
23
+ isShiftKey: event.shiftKey,
24
+ isCtrlKey: event.ctrlKey
25
+ };
26
+ storeLog(storedEvent, setKeyboardEvent);
27
27
  };
28
28
  const logTouchEvent = (event, setTouchEvent) => {
29
- for (const touch of Array.from(event.touches)) {
30
- storeLog({ x: touch.clientX, y: touch.clientY, timestamp: event.timeStamp }, setTouchEvent);
31
- }
29
+ for (const touch of Array.from(event.touches)) {
30
+ storeLog(
31
+ { x: touch.clientX, y: touch.clientY, timestamp: event.timeStamp },
32
+ setTouchEvent
33
+ );
34
+ }
32
35
  };
33
- export const startCollector = (setStoredMouseEvents, setStoredTouchEvents, setStoredKeyboardEvents, rootElement) => {
34
- const form = findContainingForm(rootElement);
35
- if (form) {
36
- form.addEventListener("mousemove", (e) => logMouseEvent(e, setStoredMouseEvents));
37
- form.addEventListener("keydown", (e) => logKeyboardEvent(e, setStoredKeyboardEvents));
38
- form.addEventListener("keyup", (e) => logKeyboardEvent(e, setStoredKeyboardEvents));
39
- form.addEventListener("touchstart", (e) => logTouchEvent(e, setStoredTouchEvents));
40
- form.addEventListener("touchend", (e) => logTouchEvent(e, setStoredTouchEvents));
41
- form.addEventListener("touchcancel", (e) => logTouchEvent(e, setStoredTouchEvents));
42
- form.addEventListener("touchmove", (e) => logTouchEvent(e, setStoredTouchEvents));
43
- }
36
+ const startCollector = (setStoredMouseEvents, setStoredTouchEvents, setStoredKeyboardEvents, rootElement) => {
37
+ const form = findContainingForm(rootElement);
38
+ if (form) {
39
+ form.addEventListener(
40
+ "mousemove",
41
+ (e) => logMouseEvent(e, setStoredMouseEvents)
42
+ );
43
+ form.addEventListener(
44
+ "keydown",
45
+ (e) => logKeyboardEvent(e, setStoredKeyboardEvents)
46
+ );
47
+ form.addEventListener(
48
+ "keyup",
49
+ (e) => logKeyboardEvent(e, setStoredKeyboardEvents)
50
+ );
51
+ form.addEventListener(
52
+ "touchstart",
53
+ (e) => logTouchEvent(e, setStoredTouchEvents)
54
+ );
55
+ form.addEventListener(
56
+ "touchend",
57
+ (e) => logTouchEvent(e, setStoredTouchEvents)
58
+ );
59
+ form.addEventListener(
60
+ "touchcancel",
61
+ (e) => logTouchEvent(e, setStoredTouchEvents)
62
+ );
63
+ form.addEventListener(
64
+ "touchmove",
65
+ (e) => logTouchEvent(e, setStoredTouchEvents)
66
+ );
67
+ }
44
68
  };
45
69
  const findContainingForm = (element) => {
46
- if (element.tagName === "FORM") {
47
- return element;
48
- }
49
- if (element.parentElement) {
50
- return findContainingForm(element.parentElement);
51
- }
52
- return null;
70
+ if (element.tagName === "FORM") {
71
+ return element;
72
+ }
73
+ if (element.parentElement) {
74
+ return findContainingForm(element.parentElement);
75
+ }
76
+ return null;
77
+ };
78
+ export {
79
+ startCollector
53
80
  };
54
- //# sourceMappingURL=collector.js.map
@@ -1,4 +1,8 @@
1
- export * from "./Manager.js";
2
- export * from "./ProsopoCaptchaApi.js";
3
- export * from "./collector.js";
4
- //# sourceMappingURL=index.js.map
1
+ import { Manager } from "./Manager.js";
2
+ import { ProsopoCaptchaApi } from "./ProsopoCaptchaApi.js";
3
+ import { startCollector } from "./collector.js";
4
+ export {
5
+ Manager,
6
+ ProsopoCaptchaApi,
7
+ startCollector
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha",
3
- "version": "2.7.14",
3
+ "version": "2.7.16",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -11,13 +11,16 @@
11
11
  "npm": "10.8.2"
12
12
  },
13
13
  "scripts": {
14
- "clean": "tsc --build --clean",
15
- "build": "tsc --build --verbose",
16
- "build:cjs": "npx vite --config vite.cjs.config.ts build",
17
- "test": "echo \"No test specified\""
14
+ "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
15
+ "build": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
16
+ "build:tsc": "tsc --build --verbose",
17
+ "build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
18
+ "typecheck": "tsc --build --declaration --emitDeclarationOnly",
19
+ "test": "echo no tests"
18
20
  },
19
21
  "exports": {
20
22
  ".": {
23
+ "types": "./dist/index.d.ts",
21
24
  "import": "./dist/index.js",
22
25
  "require": "./dist/cjs/index.cjs"
23
26
  },
@@ -30,20 +33,21 @@
30
33
  },
31
34
  "dependencies": {
32
35
  "@polkadot/util": "12.6.2",
33
- "@prosopo/account": "2.7.9",
34
- "@prosopo/api": "3.1.0",
35
- "@prosopo/common": "3.0.2",
36
- "@prosopo/datasets": "3.0.9",
37
- "@prosopo/load-balancer": "2.6.14",
38
- "@prosopo/procaptcha-common": "2.7.9",
39
- "@prosopo/types": "3.0.3",
40
- "@prosopo/util": "3.0.2",
41
- "@prosopo/util-crypto": "13.5.1",
36
+ "@prosopo/account": "2.7.10",
37
+ "@prosopo/api": "3.1.1",
38
+ "@prosopo/common": "3.1.0",
39
+ "@prosopo/datasets": "3.0.11",
40
+ "@prosopo/load-balancer": "2.6.15",
41
+ "@prosopo/procaptcha-common": "2.7.10",
42
+ "@prosopo/types": "3.0.4",
43
+ "@prosopo/util": "3.0.3",
44
+ "@prosopo/util-crypto": "13.5.2",
42
45
  "@typegoose/auto-increment": "4.13.0",
43
46
  "axios": "1.10.0",
44
47
  "esbuild": "0.25.6",
45
48
  "express": "4.21.2",
46
49
  "jsdom": "25.0.0",
50
+ "@prosopo/config": "3.1.1",
47
51
  "openpgp": "5.11.3",
48
52
  "webpack-dev-server": "5.2.2"
49
53
  },
@@ -60,7 +64,6 @@
60
64
  }
61
65
  },
62
66
  "devDependencies": {
63
- "@prosopo/config": "3.1.0",
64
67
  "@vitest/coverage-v8": "3.0.9",
65
68
  "concurrently": "9.0.1",
66
69
  "del-cli": "6.0.0",
@@ -15,5 +15,8 @@ import path from "node:path";
15
15
  import { ViteCommonJSConfig } from "@prosopo/config";
16
16
 
17
17
  export default function () {
18
- return ViteCommonJSConfig("procaptcha", path.resolve("./tsconfig.cjs.json"));
18
+ return ViteCommonJSConfig(
19
+ path.basename("."),
20
+ path.resolve("./tsconfig.json"),
21
+ );
19
22
  }
@@ -1,6 +1,3 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import dotenv from "dotenv";
4
1
  // Copyright 2021-2025 Prosopo (UK) Ltd.
5
2
  //
6
3
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,23 +11,10 @@ import dotenv from "dotenv";
14
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
12
  // See the License for the specific language governing permissions and
16
13
  // limitations under the License.
17
- import { defineConfig } from "vitest/config";
18
- process.env.NODE_ENV = "test";
19
- // if .env.test exists at this level, use it, otherwise use the one at the root
20
- const envFile = `.env.${process.env.NODE_ENV || "development"}`;
21
- let envPath = envFile;
22
- if (fs.existsSync(envFile)) {
23
- envPath = path.resolve(envFile);
24
- } else if (fs.existsSync(`../../${envFile}`)) {
25
- envPath = path.resolve(`../../${envFile}`);
26
- } else {
27
- throw new Error(`No ${envFile} file found`);
28
- }
29
14
 
30
- dotenv.config({ path: envPath });
15
+ import path from "node:path";
16
+ import { ViteEsmConfig } from "@prosopo/config";
31
17
 
32
- export default defineConfig({
33
- test: {
34
- environment: "jsdom",
35
- },
36
- });
18
+ export default function () {
19
+ return ViteEsmConfig(path.basename("."), path.resolve("./tsconfig.json"));
20
+ }
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from "./modules/index.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC"}
@@ -1,10 +0,0 @@
1
- import { type FrictionlessState, type ProcaptchaCallbacks, type ProcaptchaClientConfigOutput, type ProcaptchaState, type ProcaptchaStateUpdateFn } from "@prosopo/types";
2
- export declare function Manager(configOptional: ProcaptchaClientConfigOutput, state: ProcaptchaState, onStateUpdate: ProcaptchaStateUpdateFn, callbacks: ProcaptchaCallbacks, frictionlessState?: FrictionlessState): {
3
- start: () => Promise<void>;
4
- cancel: () => Promise<void>;
5
- submit: () => Promise<void>;
6
- select: (hash: string) => void;
7
- nextRound: () => void;
8
- reload: () => Promise<void>;
9
- };
10
- //# sourceMappingURL=Manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/modules/Manager.ts"],"names":[],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KAAK,CAAC,WAAW,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,0BAA0B,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,WAAW,GAAW,KAAK,CAAC,WAAW,CAAC;QAC9C,OAAO,WAAW,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,CAAC,eAAyB,EAAE,EAAE;QAClD,MAAM,OAAO,GAAG,eAAe,IAAI,UAAU,EAAE,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CAAC,+BAA+B,EAAE;gBAC1D,OAAO,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE;aAC1C,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC,SAAS,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO;QACN,KAAK;QACL,MAAM;QACN,MAAM;QACN,MAAM;QACN,SAAS;QACT,MAAM;KACN,CAAC;AACH,CAAC"}
@@ -1,16 +0,0 @@
1
- import type { ProviderApi } from "@prosopo/api";
2
- import { type CaptchaResponseBody, type CaptchaSolution, type ProcaptchaApiInterface, type RandomProvider } from "@prosopo/types";
3
- import type { TCaptchaSubmitResult } from "@prosopo/types";
4
- export declare class ProsopoCaptchaApi implements ProcaptchaApiInterface {
5
- userAccount: string;
6
- provider: RandomProvider;
7
- providerApi: ProviderApi;
8
- dappAccount: string;
9
- _web2: boolean;
10
- constructor(userAccount: string, provider: RandomProvider, providerApi: ProviderApi, web2: boolean, dappAccount: string);
11
- get web2(): boolean;
12
- getCaptchaChallenge(sessionId?: string): Promise<CaptchaResponseBody>;
13
- submitCaptchaSolution(userTimestampSignature: string, requestHash: string, solutions: CaptchaSolution[], timestamp: string, providerRequestHashSignature: string): Promise<TCaptchaSubmitResult>;
14
- }
15
- export default ProsopoCaptchaApi;
16
- //# sourceMappingURL=ProsopoCaptchaApi.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProsopoCaptchaApi.d.ts","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaApi.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAEpB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,qBAAa,iBAAkB,YAAW,sBAAsB;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;gBAGd,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,MAAM;IASpB,IAAI,IAAI,IAAI,OAAO,CAElB;IAEY,mBAAmB,CAC/B,SAAS,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,mBAAmB,CAAC;IA8BlB,qBAAqB,CACjC,sBAAsB,EAAE,MAAM,EAC9B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,eAAe,EAAE,EAC5B,SAAS,EAAE,MAAM,EACjB,4BAA4B,EAAE,MAAM,GAClC,OAAO,CAAC,oBAAoB,CAAC;CAoChC;AAED,eAAe,iBAAiB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProsopoCaptchaApi.js","sourceRoot":"","sources":["../../src/modules/ProsopoCaptchaApi.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EACN,iBAAiB,EACjB,0BAA0B,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,SAAS,GAMT,MAAM,gBAAgB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C,sBAA8B,EAC9B,WAAmB,EACnB,SAA4B,EAC5B,SAAiB,EACjB,4BAAoC;QAEpC,MAAM,IAAI,GAAG,IAAI,iBAAiB,EAAE,CAAC;QAErC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAChD,0BAA0B,CAAC,OAAO,CAAC,CACnC,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAE3B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,EAAE;gBAClE,OAAO,EAAE,EAAE,KAAK,EAAE,+BAA+B,EAAE;aACnD,CAAC,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAEpC,IAAI,MAA+B,CAAC;QAEpC,IAAI,CAAC;YACJ,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,qBAAqB,CACpD,SAAS,EACT,WAAW,EACX,IAAI,CAAC,WAAW,EAChB,SAAS,EACT,4BAA4B,EAC5B,sBAAsB,CACtB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,mBAAmB,CAAC,mCAAmC,EAAE;gBAClE,OAAO,EAAE,EAAE,KAAK,EAAE;aAClB,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC/B,CAAC;CACD;AAED,eAAe,iBAAiB,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { ProsopoKeyboardEvent, ProsopoMouseEvent, ProsopoTouchEvent } from "@prosopo/types";
2
- type SetStateAction<T> = T | ((prevState: T) => T);
3
- type SetMouseEvent = (setValueFunc: SetStateAction<ProsopoMouseEvent[]>) => void;
4
- type SetKeyboardEvent = (setValueFunc: SetStateAction<ProsopoKeyboardEvent[]>) => void;
5
- type SetTouchEvent = (setValueFunc: SetStateAction<ProsopoTouchEvent[]>) => void;
6
- export declare const startCollector: (setStoredMouseEvents: SetMouseEvent, setStoredTouchEvents: SetTouchEvent, setStoredKeyboardEvents: SetKeyboardEvent, rootElement: HTMLDivElement) => void;
7
- export {};
8
- //# sourceMappingURL=collector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/modules/collector.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACX,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,gBAAgB,CAAC;AAIxB,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAEnD,KAAK,aAAa,GAAG,CACpB,YAAY,EAAE,cAAc,CAAC,iBAAiB,EAAE,CAAC,KAC7C,IAAI,CAAC;AACV,KAAK,gBAAgB,GAAG,CACvB,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,CAAC,KAChD,IAAI,CAAC;AACV,KAAK,aAAa,GAAG,CACpB,YAAY,EAAE,cAAc,CAAC,iBAAiB,EAAE,CAAC,KAC7C,IAAI,CAAC;AAiDV,eAAO,MAAM,cAAc,yBACJ,aAAa,wBACb,aAAa,2BACV,gBAAgB,eAC5B,cAAc,SA+B3B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/modules/collector.ts"],"names":[],"mappings":"AAmBA,MAAM,eAAe,GAAG,KAAK,CAAC;AAc9B,MAAM,QAAQ,GAAG,CAAI,KAAQ,EAAE,SAA2B,EAAE,EAAE;IAC7D,SAAS,CAAC,CAAC,aAAa,EAAE,EAAE;QAC3B,IAAI,SAAS,GAAG,CAAC,GAAG,aAAa,EAAE,KAAK,CAAC,CAAC;QAC1C,IAAI,SAAS,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;YACxC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,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- export * from "./ProsopoCaptchaApi.js";
3
- export * from "./collector.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC"}