@lateos/npm-scan 0.12.1 → 0.12.3

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.
Files changed (2) hide show
  1. package/backend/fetch.js +15 -2
  2. package/package.json +1 -1
package/backend/fetch.js CHANGED
@@ -8,8 +8,21 @@ import { pipeline } from 'stream/promises';
8
8
 
9
9
  export async function fetchPackage(target, options = {}) {
10
10
  const { cacheDir, cacheTTL = 604800, cacheMaxSize = 1000000000 } = options;
11
+ let name, version;
11
12
 
12
- // Check cache if enabled
13
+ if (target.startsWith('@')) {
14
+ const lastAt = target.lastIndexOf('@');
15
+ name = target.slice(0, lastAt);
16
+ version = target.slice(lastAt + 1);
17
+ if (!version) version = undefined;
18
+ } else {
19
+ const idx = target.indexOf('@');
20
+ name = idx > -1 ? target.slice(0, idx) : target;
21
+ version = idx > -1 ? target.slice(idx + 1) : undefined;
22
+ }
23
+
24
+ const endpoint = version ? `/${encodeURIComponent(name)}/${version}` : `/${encodeURIComponent(name)}/latest`;
25
+
13
26
  if (cacheDir) {
14
27
  const cached = getFromCache(cacheDir, target, cacheTTL);
15
28
  if (cached) {
@@ -18,7 +31,7 @@ export async function fetchPackage(target, options = {}) {
18
31
  }
19
32
  }
20
33
 
21
- const metaRes = await fetch(`https://registry.npmjs.org/${target}/latest`);
34
+ const metaRes = await fetch(`https://registry.npmjs.org${endpoint}`);
22
35
  const meta = await metaRes.json();
23
36
 
24
37
  if (!metaRes.ok || !meta.dist?.tarball) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lateos/npm-scan",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "Modern npm supply chain security scanner — detects obfuscated payloads, credential stealers, conditional triggers, sandbox evasion, and worm-like propagation. 11 attack types, SBOM, NIST/EU CRA compliance reporting.",
5
5
  "main": "backend/index.js",
6
6
  "bin": {