altcha-lib 1.0.0 → 1.1.1
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/cjs/dist/index.js +3 -6
- package/dist/index.js +3 -6
- package/package.json +1 -1
package/cjs/dist/index.js
CHANGED
|
@@ -70,11 +70,8 @@ async function verifySolution(payload, hmacKey, checkExpires = true) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
const params = extractParams(payload);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!expires) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
73
|
+
const expires = params.expires || params.expire;
|
|
74
|
+
if (checkExpires && expires) {
|
|
78
75
|
const date = new Date(parseInt(expires, 10) * 1000);
|
|
79
76
|
if (Number.isNaN(date.getTime()) || date.getTime() < Date.now()) {
|
|
80
77
|
return false;
|
|
@@ -199,7 +196,7 @@ function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6, start
|
|
|
199
196
|
*/
|
|
200
197
|
async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) {
|
|
201
198
|
const workers = [];
|
|
202
|
-
concurrency = Math.
|
|
199
|
+
concurrency = Math.max(1, Math.min(16, concurrency));
|
|
203
200
|
for (let i = 0; i < concurrency; i++) {
|
|
204
201
|
if (typeof workerScript === 'function') {
|
|
205
202
|
workers.push(workerScript());
|
package/dist/index.js
CHANGED
|
@@ -61,11 +61,8 @@ export async function verifySolution(payload, hmacKey, checkExpires = true) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
const params = extractParams(payload);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (!expires) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
64
|
+
const expires = params.expires || params.expire;
|
|
65
|
+
if (checkExpires && expires) {
|
|
69
66
|
const date = new Date(parseInt(expires, 10) * 1000);
|
|
70
67
|
if (Number.isNaN(date.getTime()) || date.getTime() < Date.now()) {
|
|
71
68
|
return false;
|
|
@@ -190,7 +187,7 @@ export function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6
|
|
|
190
187
|
*/
|
|
191
188
|
export async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) {
|
|
192
189
|
const workers = [];
|
|
193
|
-
concurrency = Math.
|
|
190
|
+
concurrency = Math.max(1, Math.min(16, concurrency));
|
|
194
191
|
for (let i = 0; i < concurrency; i++) {
|
|
195
192
|
if (typeof workerScript === 'function') {
|
|
196
193
|
workers.push(workerScript());
|