altcha-lib 1.3.0 → 1.4.0

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 CHANGED
@@ -30,6 +30,10 @@ async function createChallenge(options) {
30
30
  if (Object.keys(Object.fromEntries(params)).length) {
31
31
  salt = salt + '?' + params.toString();
32
32
  }
33
+ // Add a delimiter to prevent parameter splicing
34
+ if (!salt.endsWith(';')) {
35
+ salt = salt + ';';
36
+ }
33
37
  const number = options.number === undefined ? (0, helpers_js_1.randomInt)(maxnumber) : options.number;
34
38
  const challenge = await (0, helpers_js_1.hashHex)(algorithm, salt + number);
35
39
  return {
@@ -50,7 +54,7 @@ function extractParams(payload) {
50
54
  if (typeof payload === 'string') {
51
55
  payload = JSON.parse(atob(payload));
52
56
  }
53
- return Object.fromEntries(new URLSearchParams(payload?.salt?.split('?')?.[1] || ''));
57
+ return Object.fromEntries(new URLSearchParams(payload?.salt?.split('?')?.[1]?.replace(/;$/, '') || ''));
54
58
  }
55
59
  /**
56
60
  * Verifies the solution provided by the client.
@@ -0,0 +1 @@
1
+ {"root":["../../lib/helpers.ts","../../lib/index.ts","../../lib/types.ts","../../lib/worker.ts"],"version":"5.9.3"}
package/dist/index.js CHANGED
@@ -21,6 +21,10 @@ export async function createChallenge(options) {
21
21
  if (Object.keys(Object.fromEntries(params)).length) {
22
22
  salt = salt + '?' + params.toString();
23
23
  }
24
+ // Add a delimiter to prevent parameter splicing
25
+ if (!salt.endsWith(';')) {
26
+ salt = salt + ';';
27
+ }
24
28
  const number = options.number === undefined ? randomInt(maxnumber) : options.number;
25
29
  const challenge = await hashHex(algorithm, salt + number);
26
30
  return {
@@ -41,7 +45,7 @@ export function extractParams(payload) {
41
45
  if (typeof payload === 'string') {
42
46
  payload = JSON.parse(atob(payload));
43
47
  }
44
- return Object.fromEntries(new URLSearchParams(payload?.salt?.split('?')?.[1] || ''));
48
+ return Object.fromEntries(new URLSearchParams(payload?.salt?.split('?')?.[1]?.replace(/;$/, '') || ''));
45
49
  }
46
50
  /**
47
51
  * Verifies the solution provided by the client.
@@ -0,0 +1 @@
1
+ {"root":["../lib/helpers.ts","../lib/index.ts","../lib/types.ts","../lib/worker.ts"],"version":"5.9.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "altcha-lib",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A library for creating and verifying ALTCHA challenges for Node.js, Bun and Deno.",
5
5
  "author": {
6
6
  "name": "Daniel Regeci",
@@ -61,16 +61,17 @@
61
61
  }
62
62
  },
63
63
  "devDependencies": {
64
- "@types/node": "^20.16.3",
65
- "@typescript-eslint/eslint-plugin": "^8.4.0",
66
- "denoify": "^1.6.13",
67
- "eslint": "^8.57.0",
68
- "husky": "^9.1.5",
69
- "prettier": "^3.3.3",
70
- "rimraf": "^5.0.10",
64
+ "@types/node": "^24.10.3",
65
+ "@typescript-eslint/eslint-plugin": "^8.49.0",
66
+ "denoify": "^1.6.17",
67
+ "eslint": "^8.57.1",
68
+ "husky": "^9.1.7",
69
+ "prettier": "^3.7.4",
70
+ "rimraf": "^6.1.2",
71
71
  "ts-node": "^10.9.2",
72
- "tsx": "^4.19.0",
73
- "typescript": "^5.5.4",
74
- "vitest": "^3.2.2"
72
+ "tsx": "^4.21.0",
73
+ "typescript": "^5.9.3",
74
+ "vite": "^7.2.7",
75
+ "vitest": "^4.0.15"
75
76
  }
76
77
  }