@prosopo/procaptcha 2.10.56 → 2.10.58
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 -12
- package/.turbo/turbo-build$colon$tsc.log +20 -20
- package/.turbo/turbo-build.log +15 -12
- package/CHANGELOG.md +43 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/index.cjs +6 -8
- package/dist/cjs/modules/Manager.cjs +286 -384
- package/dist/cjs/modules/ProsopoCaptchaApi.cjs +41 -74
- package/dist/cjs/modules/collector.cjs +43 -73
- package/dist/cjs/modules/index.cjs +6 -8
- package/dist/index.js +3 -7
- package/dist/modules/Manager.d.ts.map +1 -1
- package/dist/modules/Manager.js +283 -382
- package/dist/modules/Manager.js.map +1 -1
- package/dist/modules/ProsopoCaptchaApi.js +40 -74
- package/dist/modules/collector.js +44 -74
- package/dist/modules/index.js +2 -6
- package/package.json +11 -11
|
@@ -1,76 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
async submitCaptchaSolution(userTimestampSignature, requestHash, solutions, timestamp, providerRequestHashSignature, behavioralData, simdReadings, clientMetaData) {
|
|
43
|
-
const tree = new datasets.CaptchaMerkleTree();
|
|
44
|
-
const captchasHashed = solutions.map(
|
|
45
|
-
(captcha) => datasets.computeCaptchaSolutionHash(captcha)
|
|
46
|
-
);
|
|
47
|
-
tree.build(captchasHashed);
|
|
48
|
-
if (!tree.root) {
|
|
49
|
-
throw new common.ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
50
|
-
context: { error: "Merkle tree root is undefined" }
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
const commitmentId = tree.root.hash;
|
|
54
|
-
let result;
|
|
55
|
-
try {
|
|
56
|
-
result = await this.providerApi.submitCaptchaSolution(
|
|
57
|
-
solutions,
|
|
58
|
-
requestHash,
|
|
59
|
-
this.userAccount,
|
|
60
|
-
timestamp,
|
|
61
|
-
providerRequestHashSignature,
|
|
62
|
-
userTimestampSignature,
|
|
63
|
-
behavioralData,
|
|
64
|
-
simdReadings,
|
|
65
|
-
clientMetaData
|
|
66
|
-
);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
throw new common.ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
69
|
-
context: { error }
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return [result, commitmentId];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
let _prosopo_common = require("@prosopo/common");
|
|
2
|
+
let _prosopo_types = require("@prosopo/types");
|
|
3
|
+
let _prosopo_datasets = require("@prosopo/datasets");
|
|
4
|
+
//#region src/modules/ProsopoCaptchaApi.ts
|
|
5
|
+
var ProsopoCaptchaApi = class {
|
|
6
|
+
constructor(userAccount, provider, providerApi, web2, dappAccount) {
|
|
7
|
+
this.userAccount = userAccount;
|
|
8
|
+
this.provider = provider;
|
|
9
|
+
this.providerApi = providerApi;
|
|
10
|
+
this._web2 = web2;
|
|
11
|
+
this.dappAccount = dappAccount;
|
|
12
|
+
}
|
|
13
|
+
get web2() {
|
|
14
|
+
return this._web2;
|
|
15
|
+
}
|
|
16
|
+
async getCaptchaChallenge(sessionId, simdReadings) {
|
|
17
|
+
try {
|
|
18
|
+
const captchaChallenge = await this.providerApi.getCaptchaChallenge(this.userAccount, this.provider, sessionId, simdReadings);
|
|
19
|
+
if (captchaChallenge[_prosopo_types.ApiParams.error]) return captchaChallenge;
|
|
20
|
+
for (const captcha of captchaChallenge.captchas) for (const item of captcha.items) if (item.data) item.data = `https://${item.data.replace(/^http(s)*:\/\//, "")}`;
|
|
21
|
+
return captchaChallenge;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
throw new _prosopo_common.ProsopoEnvError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error } });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async submitCaptchaSolution(userTimestampSignature, requestHash, solutions, timestamp, providerRequestHashSignature, behavioralData, simdReadings, clientMetaData) {
|
|
27
|
+
const tree = new _prosopo_datasets.CaptchaMerkleTree();
|
|
28
|
+
const captchasHashed = solutions.map((captcha) => (0, _prosopo_datasets.computeCaptchaSolutionHash)(captcha));
|
|
29
|
+
tree.build(captchasHashed);
|
|
30
|
+
if (!tree.root) throw new _prosopo_common.ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: "Merkle tree root is undefined" } });
|
|
31
|
+
const commitmentId = tree.root.hash;
|
|
32
|
+
let result;
|
|
33
|
+
try {
|
|
34
|
+
result = await this.providerApi.submitCaptchaSolution(solutions, requestHash, this.userAccount, timestamp, providerRequestHashSignature, userTimestampSignature, behavioralData, simdReadings, clientMetaData);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new _prosopo_common.ProsopoDatasetError("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error } });
|
|
37
|
+
}
|
|
38
|
+
return [result, commitmentId];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
75
42
|
exports.ProsopoCaptchaApi = ProsopoCaptchaApi;
|
|
76
43
|
exports.default = ProsopoCaptchaApi;
|
|
@@ -1,80 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return newEvents;
|
|
11
|
-
});
|
|
1
|
+
//#region src/modules/collector.ts
|
|
2
|
+
var COLLECTOR_LIMIT = 1e4;
|
|
3
|
+
var storeLog = (event, setEvents) => {
|
|
4
|
+
setEvents((currentEvents) => {
|
|
5
|
+
let newEvents = [...currentEvents, event];
|
|
6
|
+
if (newEvents.length > COLLECTOR_LIMIT) newEvents = newEvents.slice(1);
|
|
7
|
+
return newEvents;
|
|
8
|
+
});
|
|
12
9
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
storeLog(storedEvent, setMouseEvent);
|
|
10
|
+
var logMouseEvent = (event, setMouseEvent) => {
|
|
11
|
+
storeLog({
|
|
12
|
+
x: event.x,
|
|
13
|
+
y: event.y,
|
|
14
|
+
timestamp: event.timeStamp
|
|
15
|
+
}, setMouseEvent);
|
|
20
16
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
storeLog(storedEvent, setKeyboardEvent);
|
|
17
|
+
var logKeyboardEvent = (event, setKeyboardEvent) => {
|
|
18
|
+
storeLog({
|
|
19
|
+
key: event.key,
|
|
20
|
+
timestamp: event.timeStamp,
|
|
21
|
+
isShiftKey: event.shiftKey,
|
|
22
|
+
isCtrlKey: event.ctrlKey
|
|
23
|
+
}, setKeyboardEvent);
|
|
29
24
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
25
|
+
var logTouchEvent = (event, setTouchEvent) => {
|
|
26
|
+
for (const touch of Array.from(event.touches)) storeLog({
|
|
27
|
+
x: touch.clientX,
|
|
28
|
+
y: touch.clientY,
|
|
29
|
+
timestamp: event.timeStamp
|
|
30
|
+
}, setTouchEvent);
|
|
37
31
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
form.addEventListener(
|
|
50
|
-
"keyup",
|
|
51
|
-
(e) => logKeyboardEvent(e, setStoredKeyboardEvents)
|
|
52
|
-
);
|
|
53
|
-
form.addEventListener(
|
|
54
|
-
"touchstart",
|
|
55
|
-
(e) => logTouchEvent(e, setStoredTouchEvents)
|
|
56
|
-
);
|
|
57
|
-
form.addEventListener(
|
|
58
|
-
"touchend",
|
|
59
|
-
(e) => logTouchEvent(e, setStoredTouchEvents)
|
|
60
|
-
);
|
|
61
|
-
form.addEventListener(
|
|
62
|
-
"touchcancel",
|
|
63
|
-
(e) => logTouchEvent(e, setStoredTouchEvents)
|
|
64
|
-
);
|
|
65
|
-
form.addEventListener(
|
|
66
|
-
"touchmove",
|
|
67
|
-
(e) => logTouchEvent(e, setStoredTouchEvents)
|
|
68
|
-
);
|
|
69
|
-
}
|
|
32
|
+
var startCollector = (setStoredMouseEvents, setStoredTouchEvents, setStoredKeyboardEvents, rootElement) => {
|
|
33
|
+
const form = findContainingForm(rootElement);
|
|
34
|
+
if (form) {
|
|
35
|
+
form.addEventListener("mousemove", (e) => logMouseEvent(e, setStoredMouseEvents));
|
|
36
|
+
form.addEventListener("keydown", (e) => logKeyboardEvent(e, setStoredKeyboardEvents));
|
|
37
|
+
form.addEventListener("keyup", (e) => logKeyboardEvent(e, setStoredKeyboardEvents));
|
|
38
|
+
form.addEventListener("touchstart", (e) => logTouchEvent(e, setStoredTouchEvents));
|
|
39
|
+
form.addEventListener("touchend", (e) => logTouchEvent(e, setStoredTouchEvents));
|
|
40
|
+
form.addEventListener("touchcancel", (e) => logTouchEvent(e, setStoredTouchEvents));
|
|
41
|
+
form.addEventListener("touchmove", (e) => logTouchEvent(e, setStoredTouchEvents));
|
|
42
|
+
}
|
|
70
43
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (element.parentElement) {
|
|
76
|
-
return findContainingForm(element.parentElement);
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
44
|
+
var findContainingForm = (element) => {
|
|
45
|
+
if (element.tagName === "FORM") return element;
|
|
46
|
+
if (element.parentElement) return findContainingForm(element.parentElement);
|
|
47
|
+
return null;
|
|
79
48
|
};
|
|
49
|
+
//#endregion
|
|
80
50
|
exports.startCollector = startCollector;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
exports.ProsopoCaptchaApi = ProsopoCaptchaApi.ProsopoCaptchaApi;
|
|
8
|
-
exports.startCollector = collector.startCollector;
|
|
1
|
+
const require_ProsopoCaptchaApi = require("./ProsopoCaptchaApi.cjs");
|
|
2
|
+
const require_Manager = require("./Manager.cjs");
|
|
3
|
+
const require_collector = require("./collector.cjs");
|
|
4
|
+
exports.Manager = require_Manager.Manager;
|
|
5
|
+
exports.ProsopoCaptchaApi = require_ProsopoCaptchaApi.ProsopoCaptchaApi;
|
|
6
|
+
exports.startCollector = require_collector.startCollector;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { Manager } from "./modules/Manager.js";
|
|
1
|
+
import "./_virtual/_rolldown/runtime.js";
|
|
3
2
|
import { ProsopoCaptchaApi } from "./modules/ProsopoCaptchaApi.js";
|
|
3
|
+
import { Manager } from "./modules/Manager.js";
|
|
4
4
|
import { startCollector } from "./modules/collector.js";
|
|
5
|
-
export {
|
|
6
|
-
Manager,
|
|
7
|
-
ProsopoCaptchaApi,
|
|
8
|
-
startCollector
|
|
9
|
-
};
|
|
5
|
+
export { Manager, ProsopoCaptchaApi, startCollector };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/modules/Manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Manager.d.ts","sourceRoot":"","sources":["../../src/modules/Manager.ts"],"names":[],"mappings":"AA8BA,OAAO,EAMN,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAExB,KAAK,4BAA4B,EAEjC,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAG5B,MAAM,gBAAgB,CAAC;AAwBxB,wBAAgB,OAAO,CACtB,cAAc,EAAE,4BAA4B,EAC5C,KAAK,EAAE,eAAe,EACtB,aAAa,EAAE,uBAAuB,EACtC,SAAS,EAAE,mBAAmB,EAC9B,iBAAiB,CAAC,EAAE,iBAAiB,EAGrC,gBAAgB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS;;;;mBAoWrB,MAAM,MAAM,MAAM,MAAM,MAAM;;;EAyJpD"}
|