mirror of
https://github.com/altcha-org/altcha-lib.git
synced 2026-01-25 04:18:21 +00:00
1.1.0
This commit is contained in:
7
cjs/dist/index.js
vendored
7
cjs/dist/index.js
vendored
@@ -70,11 +70,8 @@ async function verifySolution(payload, hmacKey, checkExpires = true) {
|
||||
}
|
||||
}
|
||||
const params = extractParams(payload);
|
||||
if (checkExpires) {
|
||||
const expires = params.expires || params.expire;
|
||||
if (!expires) {
|
||||
return false;
|
||||
}
|
||||
const expires = params.expires || params.expire;
|
||||
if (checkExpires && expires) {
|
||||
const date = new Date(parseInt(expires, 10) * 1000);
|
||||
if (Number.isNaN(date.getTime()) || date.getTime() < Date.now()) {
|
||||
return false;
|
||||
|
||||
@@ -90,11 +90,8 @@ export async function verifySolution(
|
||||
}
|
||||
}
|
||||
const params = extractParams(payload);
|
||||
if (checkExpires) {
|
||||
const expires = params.expires || params.expire;
|
||||
if (!expires) {
|
||||
return false;
|
||||
}
|
||||
const expires = params.expires || params.expire;
|
||||
if (checkExpires && expires) {
|
||||
const date = new Date(parseInt(expires, 10) * 1000);
|
||||
if (Number.isNaN(date.getTime()) || date.getTime() < Date.now()) {
|
||||
return false;
|
||||
|
||||
7
dist/index.js
vendored
7
dist/index.js
vendored
@@ -61,11 +61,8 @@ export async function verifySolution(payload, hmacKey, checkExpires = true) {
|
||||
}
|
||||
}
|
||||
const params = extractParams(payload);
|
||||
if (checkExpires) {
|
||||
const expires = params.expires || params.expire;
|
||||
if (!expires) {
|
||||
return false;
|
||||
}
|
||||
const expires = params.expires || params.expire;
|
||||
if (checkExpires && expires) {
|
||||
const date = new Date(parseInt(expires, 10) * 1000);
|
||||
if (Number.isNaN(date.getTime()) || date.getTime() < Date.now()) {
|
||||
return false;
|
||||
|
||||
@@ -90,11 +90,8 @@ export async function verifySolution(
|
||||
}
|
||||
}
|
||||
const params = extractParams(payload);
|
||||
if (checkExpires) {
|
||||
const expires = params.expires || params.expire;
|
||||
if (!expires) {
|
||||
return false;
|
||||
}
|
||||
const expires = params.expires || params.expire;
|
||||
if (checkExpires && expires) {
|
||||
const date = new Date(parseInt(expires, 10) * 1000);
|
||||
if (Number.isNaN(date.getTime()) || date.getTime() < Date.now()) {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "altcha-lib",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "A library for creating and verifying ALTCHA challenges for Node.js, Bun and Deno.",
|
||||
"author": {
|
||||
"name": "Daniel Regeci",
|
||||
|
||||
@@ -150,7 +150,6 @@ describe('challenge', () => {
|
||||
signature: challenge.signature,
|
||||
},
|
||||
hmacKey,
|
||||
false // don't check expires
|
||||
);
|
||||
expect(ok).toEqual(true);
|
||||
});
|
||||
@@ -289,27 +288,6 @@ describe('challenge', () => {
|
||||
expect(ok).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return false if the challenge does not include expires param but should be checked', async () => {
|
||||
const number = 100;
|
||||
const challenge = await createChallenge({
|
||||
expires: undefined,
|
||||
number,
|
||||
hmacKey,
|
||||
});
|
||||
const ok = await verifySolution(
|
||||
{
|
||||
algorithm: challenge.algorithm,
|
||||
challenge: challenge.challenge,
|
||||
number,
|
||||
salt: challenge.salt,
|
||||
signature: challenge.signature,
|
||||
},
|
||||
hmacKey,
|
||||
true // make sure expires is checked
|
||||
);
|
||||
expect(ok).toEqual(false);
|
||||
});
|
||||
|
||||
it('should return false if the expires is malformated', async () => {
|
||||
const number = 100;
|
||||
const challenge = await createChallenge({
|
||||
|
||||
Reference in New Issue
Block a user