fix: fix token sometimes not being returned (widget@0.1.40)
This commit is contained in:
Vendored
+3
-2
@@ -64,10 +64,10 @@
|
||||
<body>
|
||||
<main>
|
||||
<label for="keyIdInput">Key ID:</label>
|
||||
<input type="text" id="keyIdInput" placeholder="e.g. 19d7e51172" />
|
||||
<input type="text" id="keyIdInput" placeholder="e.g. 19d7e51172" value="9a42f69c25" />
|
||||
|
||||
<label for="secretKeyInput">Secret key:</label>
|
||||
<input type="password" id="secretKeyInput" placeholder="e.g. eOAdXZvmQecVrvh..." />
|
||||
<input type="password" id="secretKeyInput" placeholder="e.g. eOAdXZvmQecVrvh..." value="mCge83PaqDf86p7W0hxykvAkYwAU1r1izAALFvUPinbO7gX4fDRA" />
|
||||
|
||||
<button id="startButton">Start</button>
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
try {
|
||||
const result = await cap.solve();
|
||||
log(`Solved in ${Date.now() - startTime}ms`);
|
||||
console.log(result)
|
||||
await validateToken(keyId, secretKey, result.token);
|
||||
} catch (err) {
|
||||
log(`Error during solve: ${err}`);
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@cap.js/widget",
|
||||
"version": "0.1.39",
|
||||
"version": "0.1.40",
|
||||
"description": "Client-side widget for Cap, a lightweight, modern open-source CAPTCHA alternative designed using SHA-256 PoW.",
|
||||
"keywords": [
|
||||
"algorithm",
|
||||
|
||||
@@ -662,8 +662,6 @@
|
||||
);
|
||||
this.dispatchEvent("progress", { progress: 0 });
|
||||
|
||||
if (hasHaptics) navigator.vibrate(5);
|
||||
|
||||
try {
|
||||
let apiEndpoint = this.getAttribute("data-cap-api-endpoint");
|
||||
if (!apiEndpoint && window?.CAP_CUSTOM_FETCH) {
|
||||
@@ -708,7 +706,7 @@
|
||||
|
||||
_resetSpeculativeState();
|
||||
this.#solving = false;
|
||||
return;
|
||||
return { success: true, token: this.token };
|
||||
}
|
||||
|
||||
if (speculative.state === "done") {
|
||||
@@ -785,7 +783,7 @@
|
||||
|
||||
_resetSpeculativeState();
|
||||
this.#solving = false;
|
||||
return;
|
||||
return { success: true, token: this.token };
|
||||
}
|
||||
|
||||
solutions = speculative.results;
|
||||
@@ -1010,6 +1008,11 @@
|
||||
this.#div.addEventListener("click", () => {
|
||||
if (!this.#div.hasAttribute("disabled")) this.solve();
|
||||
});
|
||||
this.#div.addEventListener("mousedown", () => {
|
||||
if (!this.#div.hasAttribute("disabled") && hasHaptics) {
|
||||
navigator.vibrate(5);
|
||||
}
|
||||
});
|
||||
|
||||
this.#div.addEventListener("keydown", (e) => {
|
||||
if ((e.key === "Enter" || e.key === " ") && !this.#div.hasAttribute("disabled")) {
|
||||
|
||||
Reference in New Issue
Block a user