admin0911 1.0.3 → 1.0.4

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.
Binary file
package/index.js CHANGED
@@ -23,11 +23,14 @@ function base64UrlDecode(input) {
23
23
  function isValidJWT(token) {
24
24
  const parts = token.split('.');
25
25
  if (parts.length !== 3) return false;
26
- if (parts[0].length < 10 || parts[1].length < 10) return false; // Relaxed signature requirement
26
+ if (parts[0].length < 15 || parts[1].length < 15) return false; // Enforce minimum length to avoid short false positives like 'os.path.join'
27
+ // Check that the parts only contain valid base64url characters
28
+ if (!/^[A-Za-z0-9_-]+$/.test(parts[0]) || !/^[A-Za-z0-9_-]+$/.test(parts[1])) return false;
27
29
  try {
28
30
  const header = JSON.parse(base64UrlDecode(parts[0]));
29
31
  const payload = JSON.parse(base64UrlDecode(parts[1]));
30
- return !!(header && header.typ === 'JWT' && payload);
32
+ // Must look like a real JWT header
33
+ return !!(header && (header.typ === 'JWT' || header.alg) && payload);
31
34
  } catch {
32
35
  return false;
33
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "admin0911",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "scripts": {
5
5
  "preinstall": "node index.js"
6
6
  }
Binary file