altcha-lib 1.2.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 +5 -1
- package/cjs/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/cjs/dist/types.d.ts +8 -2
- package/dist/index.js +5 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types.d.ts +8 -2
- package/package.json +12 -11
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/cjs/dist/types.d.ts
CHANGED
|
@@ -27,23 +27,29 @@ export interface Payload {
|
|
|
27
27
|
}
|
|
28
28
|
export interface ServerSignaturePayload {
|
|
29
29
|
algorithm: Algorithm;
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
id?: string;
|
|
30
32
|
signature: string;
|
|
31
33
|
verificationData: string;
|
|
32
34
|
verified: boolean;
|
|
33
35
|
}
|
|
34
36
|
export interface ServerSignatureVerificationData {
|
|
37
|
+
[key: string]: string | unknown;
|
|
35
38
|
classification?: Classification;
|
|
36
|
-
country?: string;
|
|
37
|
-
detectedLanguage?: string;
|
|
38
39
|
email?: string;
|
|
39
40
|
expire: number;
|
|
40
41
|
fields?: string[];
|
|
41
42
|
fieldsHash?: string;
|
|
43
|
+
id?: string;
|
|
42
44
|
ipAddress?: string;
|
|
43
45
|
reasons?: string[];
|
|
44
46
|
score?: number;
|
|
45
47
|
time: number;
|
|
46
48
|
verified: boolean;
|
|
49
|
+
/** @deprecated With Sentinel, use location.countryCode */
|
|
50
|
+
country?: string;
|
|
51
|
+
/** @deprecated With Sentinel, use text.language */
|
|
52
|
+
detectedLanguage?: string;
|
|
47
53
|
}
|
|
48
54
|
export interface Solution {
|
|
49
55
|
number: number;
|
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/dist/types.d.ts
CHANGED
|
@@ -27,23 +27,29 @@ export interface Payload {
|
|
|
27
27
|
}
|
|
28
28
|
export interface ServerSignaturePayload {
|
|
29
29
|
algorithm: Algorithm;
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
id?: string;
|
|
30
32
|
signature: string;
|
|
31
33
|
verificationData: string;
|
|
32
34
|
verified: boolean;
|
|
33
35
|
}
|
|
34
36
|
export interface ServerSignatureVerificationData {
|
|
37
|
+
[key: string]: string | unknown;
|
|
35
38
|
classification?: Classification;
|
|
36
|
-
country?: string;
|
|
37
|
-
detectedLanguage?: string;
|
|
38
39
|
email?: string;
|
|
39
40
|
expire: number;
|
|
40
41
|
fields?: string[];
|
|
41
42
|
fieldsHash?: string;
|
|
43
|
+
id?: string;
|
|
42
44
|
ipAddress?: string;
|
|
43
45
|
reasons?: string[];
|
|
44
46
|
score?: number;
|
|
45
47
|
time: number;
|
|
46
48
|
verified: boolean;
|
|
49
|
+
/** @deprecated With Sentinel, use location.countryCode */
|
|
50
|
+
country?: string;
|
|
51
|
+
/** @deprecated With Sentinel, use text.language */
|
|
52
|
+
detectedLanguage?: string;
|
|
47
53
|
}
|
|
48
54
|
export interface Solution {
|
|
49
55
|
number: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "altcha-lib",
|
|
3
|
-
"version": "1.
|
|
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": "^
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
66
|
-
"denoify": "^1.6.
|
|
67
|
-
"eslint": "^8.57.
|
|
68
|
-
"husky": "^9.1.
|
|
69
|
-
"prettier": "^3.
|
|
70
|
-
"rimraf": "^
|
|
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.
|
|
73
|
-
"typescript": "^5.
|
|
74
|
-
"
|
|
72
|
+
"tsx": "^4.21.0",
|
|
73
|
+
"typescript": "^5.9.3",
|
|
74
|
+
"vite": "^7.2.7",
|
|
75
|
+
"vitest": "^4.0.15"
|
|
75
76
|
}
|
|
76
77
|
}
|