@owlmeans/package-registry-npm 0.0.0-stage → 0.2.1-alpha.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.
Files changed (67) hide show
  1. package/README.md +110 -2
  2. package/agent-meta/manifest.json +16 -0
  3. package/agent-meta/skills/package-registry-npm/SKILL.md +101 -0
  4. package/build/append.d.ts +9 -0
  5. package/build/append.d.ts.map +1 -0
  6. package/build/append.js +12 -0
  7. package/build/append.js.map +1 -0
  8. package/build/consts.d.ts +63 -0
  9. package/build/consts.d.ts.map +1 -0
  10. package/build/consts.js +64 -0
  11. package/build/consts.js.map +1 -0
  12. package/build/index.d.ts +7 -0
  13. package/build/index.d.ts.map +1 -0
  14. package/build/index.js +5 -0
  15. package/build/index.js.map +1 -0
  16. package/build/registry/facts.d.ts +3 -0
  17. package/build/registry/facts.d.ts.map +1 -0
  18. package/build/registry/facts.js +89 -0
  19. package/build/registry/facts.js.map +1 -0
  20. package/build/registry/http.d.ts +3 -0
  21. package/build/registry/http.d.ts.map +1 -0
  22. package/build/registry/http.js +105 -0
  23. package/build/registry/http.js.map +1 -0
  24. package/build/registry/types.local.d.ts +48 -0
  25. package/build/registry/types.local.d.ts.map +1 -0
  26. package/build/registry/types.local.js +2 -0
  27. package/build/registry/types.local.js.map +1 -0
  28. package/build/registry.d.ts +20 -0
  29. package/build/registry.d.ts.map +1 -0
  30. package/build/registry.js +202 -0
  31. package/build/registry.js.map +1 -0
  32. package/build/repository/types.d.ts +24 -0
  33. package/build/repository/types.d.ts.map +1 -0
  34. package/build/repository/types.js +2 -0
  35. package/build/repository/types.js.map +1 -0
  36. package/build/repository.d.ts +5 -0
  37. package/build/repository.d.ts.map +1 -0
  38. package/build/repository.js +79 -0
  39. package/build/repository.js.map +1 -0
  40. package/build/types.d.ts +45 -0
  41. package/build/types.d.ts.map +1 -0
  42. package/build/types.js +2 -0
  43. package/build/types.js.map +1 -0
  44. package/build/types.local.d.ts +64 -0
  45. package/build/types.local.d.ts.map +1 -0
  46. package/build/types.local.js +2 -0
  47. package/build/types.local.js.map +1 -0
  48. package/package.json +49 -4
  49. package/src/append.ts +17 -0
  50. package/src/consts.ts +91 -0
  51. package/src/index.ts +8 -0
  52. package/src/registry/facts.ts +101 -0
  53. package/src/registry/http.ts +117 -0
  54. package/src/registry/types.local.ts +52 -0
  55. package/src/registry.ts +234 -0
  56. package/src/repository/types.ts +25 -0
  57. package/src/repository.ts +90 -0
  58. package/src/types.local.ts +50 -0
  59. package/src/types.ts +47 -0
  60. package/tests/append.spec.ts +26 -0
  61. package/tests/context.ts +118 -0
  62. package/tests/fixtures.ts +99 -0
  63. package/tests/live.spec.ts +39 -0
  64. package/tests/registry.spec.ts +137 -0
  65. package/tests/repository.spec.ts +41 -0
  66. package/tests/tsconfig.json +12 -0
  67. package/tsconfig.json +16 -0
package/README.md CHANGED
@@ -1,3 +1,111 @@
1
- # Temporary Holding Version
1
+ # @owlmeans/package-registry-npm
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The npm registry adapter of [`@owlmeans/package-inspector`](https://github.com/owlmeans/common/tree/main/packages/package-inspector):
4
+ packuments and readmes, bulk weekly download counts of a name's neighbours, and the repository's own
5
+ `package.json` name check — so the inspector can tell `dayjs` (genuine) from `loadsh` (a lookalike of
6
+ `lodash` with its description copied) or `momnet` (an npm security holding package).
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ bun add @owlmeans/package-registry-npm@^0.2.1-alpha.0 @owlmeans/package-inspector@^0.2.1-alpha.0
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ts
17
+ import { createPackageInspector, PackageVerdictKind } from '@owlmeans/package-inspector'
18
+ import { createNpmRegistry } from '@owlmeans/package-registry-npm'
19
+
20
+ const inspector = createPackageInspector({ registry: createNpmRegistry() })
21
+ const verdict = await inspector.inspect('loadsh')
22
+ // verdict.verdict === PackageVerdictKind.Suspicious, verdict.lookalikeOf === 'lodash'
23
+ ```
24
+
25
+ In a context:
26
+
27
+ ```ts
28
+ import { ensurePackageInspectorService } from '@owlmeans/package-inspector'
29
+ import { appendNpmRegistry, NPM_REGISTRY } from '@owlmeans/package-registry-npm'
30
+
31
+ appendNpmRegistry(context, { timeoutMs: 8_000, thresholds: { popularDownloads: 500_000 } })
32
+ const inspector = ensurePackageInspectorService(context).get(NPM_REGISTRY)
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ `createNpmRegistry(options?)`; `appendNpmRegistry(ctx, options?)` takes the same options plus the
38
+ inspector's `thresholds`, `concurrency` and `now`.
39
+
40
+ | Option | Default | Purpose |
41
+ |---|---|---|
42
+ | `fetch` | the global `fetch` | The one call the adapter makes — a pinned or proxied client, or a test stand-in. |
43
+ | `registryUrl` | `NPM_REGISTRY_URL` (`https://registry.npmjs.org`) | Where packuments are read. |
44
+ | `downloadsUrl` | `NPM_DOWNLOADS_URL` (`https://api.npmjs.org`) | Where download counts are read. |
45
+ | `repositoryHosts` | `{ githubRaw: GITHUB_RAW_URL, gitlab: GITLAB_URL }` | Where repository manifests are read. |
46
+ | `timeoutMs` | `NPM_TIMEOUT` (10 s) | Per request, headers and body. |
47
+ | `userAgent` | `NPM_USER_AGENT` | Sent with every request. |
48
+ | `retries` | `NPM_RETRIES` (3) | Retries of a 429/502/503/504, after `retry-after` (else 1 s doubling, ≤ 10 s). |
49
+ | `maxNeighbours` · `maxVariants` · `maxScopedLookups` | 5 · 1024 · 8 | Neighbours returned; name variants priced; scoped variants looked up one by one. |
50
+ | `maxDocumentBytes` | `NPM_MAX_DOCUMENT_BYTES` (4 MiB) | A larger packument is read through its latest version (`partial` facts). |
51
+ | `maxReadmeChars` | `NPM_MAX_README_CHARS` (64 000) | A longer readme is cut (`readmeTruncated`). |
52
+ | `cacheTtlMs` | `NPM_CACHE_TTL` (10 min) | How long a download count is reused; `0` disables the cache. |
53
+
54
+ ## Security and limits
55
+
56
+ - Every request carries a timeout and a byte cap (4 MiB packument, 1 MiB for a version document, a
57
+ downloads answer or a repository manifest); a packument declared past its cap is not read.
58
+ - Install scripts are reported by hook name only, never their commands.
59
+ - A 404 is `null`; any other failure throws `PackageRegistryError`
60
+ (`npm:<packument|latest|downloads|repository|readme>:<subject>:<status|timeout|unreachable|malformed>`),
61
+ which the inspector turns into an `unknown` verdict — a throttled npm never yields `genuine`.
62
+ - Repository manifests are read only from GitHub and GitLab, at `HEAD`; other hosts are `null`.
63
+ - Nothing registers on import: call `appendNpmRegistry` or pass the registry to `createPackageInspector`.
64
+
65
+ ## API
66
+
67
+ | Export | Purpose |
68
+ |---|---|
69
+ | `createNpmRegistry(options?)` | An `NpmRegistry` (`PackageRegistry`, id `'npm'`): `manifest`, `downloads`, `neighbours`, `repositoryManifest`. |
70
+ | `appendNpmRegistry(ctx, options?)` | Register an npm inspector in the context's package inspector host under `NPM_REGISTRY`. |
71
+ | `createRepositoryLocator(hosts?)` · `repositoryLocator` | `locate(url, directory?)` → `RepositoryLocation \| null`, `webOf(location)`, `rawUrlOf(location, file)`. |
72
+ | `RepositoryHost` | `github`, `gitlab`. |
73
+ | `NPM_REGISTRY`, `NPM_REGISTRY_URL`, `NPM_DOWNLOADS_URL`, `NPM_PACKAGE_PAGE_URL`, `NPM_DOWNLOADS_PERIOD` | The registry id, npm's hosts and the counted period (`last-week`). |
74
+ | `NPM_BULK_LIMIT`, `NPM_BULK_CONCURRENCY`, `NPM_SCOPED_CONCURRENCY`, `NPM_RETRIES`, `NPM_RETRY_STATUSES`, `NPM_RETRY_BACKOFF`, `NPM_RETRY_MAX_WAIT`, `NPM_TIMEOUT` | Request pacing: 128 names a bulk call, 2 calls in flight, retry policy, 10 s timeout. |
75
+ | `NPM_MAX_DOCUMENT_BYTES`, `NPM_MAX_SMALL_BYTES`, `NPM_MAX_README_CHARS`, `NPM_README_FILES`, `NPM_MAX_NEIGHBOURS`, `NPM_MAX_VARIANTS`, `NPM_MAX_SCOPED_LOOKUPS`, `NPM_CACHE_TTL`, `NPM_CACHE_SIZE`, `NPM_USER_AGENT` | Caps and defaults. |
76
+ | `NPM_HOLDING_VERSION`, `NPM_HOLDING_DESCRIPTION`, `NPM_INSTALL_SCRIPTS` | npm's security-holding marker (`0.0.1-security`) and the install hooks read. |
77
+ | `GITHUB_RAW_URL`, `GITHUB_URL`, `GITLAB_URL` | The repository hosts. |
78
+ | `NpmRegistry`, `NpmRegistryOptions`, `AppendNpmRegistryOptions`, `NpmFetch`, `NpmRepositoryHosts`, `RepositoryLocation`, `RepositoryLocator` | Types. |
79
+
80
+ The package has one entry point; there are no subpath exports.
81
+
82
+ ## Common pitfalls
83
+
84
+ - Neighbours come from name variants priced in bulk (`api.npmjs.org`, ≤ 128 names per call); npm
85
+ search does not surface `lodash` for `loadsh`.
86
+ - A packument past `maxDocumentBytes` (4 MiB) is read through its latest version, the readme from the
87
+ repository; such facts are `partial` (no dates, no version count).
88
+ - Download counts are cached per registry instance for `cacheTtlMs`.
89
+
90
+ ## Related packages
91
+
92
+ - [`@owlmeans/package-inspector`](https://github.com/owlmeans/common/tree/main/packages/package-inspector) — the verdict engine, its rules, thresholds and context host
93
+ - [`@owlmeans/web-research`](https://github.com/owlmeans/common/tree/main/packages/web-research) — package research and skills built on the inspector's verdicts
94
+
95
+ The `package-registry-npm` skill covers the same adapter for agents.
96
+
97
+ <!-- owlmeans:agent-guidance:start -->
98
+ ## Agent guidance
99
+
100
+ This package ships embedded agent skills under `agent-meta/`. After installing your
101
+ `@owlmeans/*` packages, run the OwlMeans agent-skills installer to place them into
102
+ your project's skill store (`.agents/skills/`):
103
+
104
+ ```sh
105
+ npx @owlmeans/agent-skills@^0.2.1-alpha.0
106
+ ```
107
+
108
+ The embedded files are version-matched to this package release. Do not edit them
109
+ directly — they are regenerated on each publish. To contribute guidance edits,
110
+ open a PR against the source monorepo.
111
+ <!-- owlmeans:agent-guidance:end -->
@@ -0,0 +1,16 @@
1
+ {
2
+ "schemaVersion": 3,
3
+ "package": "@owlmeans/package-registry-npm",
4
+ "version": "0.2.1-alpha.0",
5
+ "generatedAt": "2026-11-15T18:54:03.857Z",
6
+ "canonicalRepo": "https://github.com/owlmeans/common",
7
+ "entries": [
8
+ {
9
+ "kind": "skill",
10
+ "name": "package-registry-npm",
11
+ "category": "package-specific",
12
+ "file": "skills/package-registry-npm/SKILL.md",
13
+ "canonicalPath": ".agents/skills/package-registry-npm/SKILL.md"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: package-registry-npm
3
+ description: "How to use @owlmeans/package-registry-npm (OwlMeans connect) — the npm adapter of @owlmeans/package-inspector's PackageRegistry port: createNpmRegistry (packuments with a size cap and the latest-version fallback, bulk weekly download counts with a cache and 429 retries, name neighbours priced from the inspector's variants, the repository's own package.json on GitHub/GitLab), appendNpmRegistry (explicit registration in the context's package inspector host), the repository locator, npm's security-holding marker and timeouts over an injectable fetch. Auto-invoked when verifying an npm package a person named (typosquat, lookalike, security holding package), reading npm packuments or download counts, or debugging an npm verdict that came back unknown."
4
+ user-invocable: false
5
+ ---
6
+ <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
7
+
8
+ # @owlmeans/package-registry-npm
9
+
10
+ **Layer:** Server (Node/Bun; any runtime with `fetch`)
11
+ **Repo:** OwlMeans connect — the npm half; the verdict engine, rules and host are common's
12
+ `@owlmeans/package-inspector`
13
+ **Install:** `"@owlmeans/package-registry-npm": "^0.2.1-alpha.0"` in `dependencies`
14
+
15
+ ## Public API
16
+
17
+ | Symbol | Kind | Purpose |
18
+ |---|---|---|
19
+ | `createNpmRegistry(opts?)` | factory | `NpmRegistry` (a `PackageRegistry`, `id` `'npm'`): `manifest`, `downloads`, `neighbours`, `repositoryManifest` |
20
+ | `appendNpmRegistry(ctx, opts?)` | fn | `appendPackageInspector(ctx, { registry: createNpmRegistry(opts), thresholds, concurrency, now })` — reach it with `ensurePackageInspectorService(ctx).get(NPM_REGISTRY)` |
21
+ | `createRepositoryLocator(hosts?)` / `repositoryLocator` | helper | `locate(url, directory?)` → `{ host, path, directory? } \| null`, `webOf(location)`, `rawUrlOf(location, file)` |
22
+ | `NpmRegistryOptions` | interface | `fetch?`, `registryUrl?`, `downloadsUrl?`, `repositoryHosts?` (`{ githubRaw?, gitlab? }`), `timeoutMs?` (10 s), `userAgent?`, `retries?` (3), `maxNeighbours?` (5), `maxVariants?` (1024), `maxScopedLookups?` (8), `maxDocumentBytes?` (4 MiB), `maxReadmeChars?` (64 000), `cacheTtlMs?` (10 min, `0` off) |
23
+ | `AppendNpmRegistryOptions` | interface | `NpmRegistryOptions` + the inspector's `thresholds?`, `concurrency?`, `now?` |
24
+ | `NPM_REGISTRY`, `NPM_REGISTRY_URL`, `NPM_DOWNLOADS_URL`, `NPM_PACKAGE_PAGE_URL`, `NPM_HOLDING_VERSION`, `NPM_HOLDING_DESCRIPTION`, `NPM_INSTALL_SCRIPTS`, `NPM_BULK_LIMIT` | const | `'npm'`, `https://registry.npmjs.org`, `https://api.npmjs.org`, `https://www.npmjs.com/package`, `'0.0.1-security'`, `'security holding package'`, `preinstall`/`install`/`postinstall`, `128` |
25
+ | `NPM_DOWNLOADS_PERIOD`, `NPM_BULK_CONCURRENCY`, `NPM_SCOPED_CONCURRENCY`, `NPM_RETRIES`, `NPM_RETRY_STATUSES`, `NPM_RETRY_BACKOFF`, `NPM_RETRY_MAX_WAIT`, `NPM_TIMEOUT`, `NPM_MAX_DOCUMENT_BYTES`, `NPM_MAX_SMALL_BYTES`, `NPM_MAX_README_CHARS`, `NPM_README_FILES`, `NPM_MAX_NEIGHBOURS`, `NPM_MAX_VARIANTS`, `NPM_MAX_SCOPED_LOOKUPS`, `NPM_CACHE_TTL`, `NPM_CACHE_SIZE`, `NPM_USER_AGENT` | const | `last-week`; 2 / 2 calls in flight; 3 retries on 429/502/503/504, 1 s doubling, ≤ 10 s; 10 s; 4 MiB packument, 1 MiB other documents; 64 000-char readme from `README.md`/`readme.md`; 5 neighbours of ≤ 1024 variants, ≤ 8 scoped lookups; 10 min / 20 000 cached counts; `@owlmeans/package-registry-npm` |
26
+ | `GITHUB_RAW_URL`, `GITHUB_URL`, `GITLAB_URL` | const | `https://raw.githubusercontent.com`, `https://github.com`, `https://gitlab.com` |
27
+ | `RepositoryHost` | enum | `github`, `gitlab` |
28
+ | `NpmFetch`, `NpmRepositoryHosts`, `NpmRegistry`, `RepositoryLocation`, `RepositoryLocator` | types | |
29
+
30
+ ## Usage
31
+
32
+ ```typescript
33
+ import { createPackageInspector, PackageVerdictKind } from '@owlmeans/package-inspector'
34
+ import { createNpmRegistry } from '@owlmeans/package-registry-npm'
35
+
36
+ const inspector = createPackageInspector({ registry: createNpmRegistry({ timeoutMs: 8_000 }) })
37
+ const [dayjs, loadsh] = await inspector.inspectAll(['dayjs', 'loadsh'])
38
+ // dayjs: genuine (provenance, popular); loadsh: suspicious, lookalikeOf 'lodash', copied-description
39
+ ```
40
+
41
+ ## What each member reads
42
+
43
+ - **`manifest`** — the full packument `GET <registry>/<name>` (scoped: `@scope%2fname`), read up to
44
+ `maxDocumentBytes` (a declared length past the cap skips the read). Larger documents — `react`,
45
+ `vite`, `next`, `typescript`, `@types/node` run to 7–40 MB — are read through
46
+ `<registry>/<name>/latest` instead, the readme from the repository (`README.md`, `readme.md`), and
47
+ the facts are `partial` (no dates, no version count). Holding = latest `0.0.1-security` or the
48
+ description "security holding package". `unpublished` = `time.unpublished` with no versions.
49
+ `installScripts` = the latest version's `preinstall`/`install`/`postinstall`, plus `install` for a
50
+ `gypfile`. `provenance` = `dist.attestations.provenance`. `entry` = the latest version's `type`,
51
+ `main`, `module`, `types` (else `typings`) and `exports` (JSON values only), absent when it declares none.
52
+ - **`downloads`** — `GET <downloads>/downloads/point/last-week/<a,b,…>`: unscoped names in bulk calls of
53
+ ≤ 128 (npm answers 400 past that), two in flight; scoped names one call each (npm refuses them in
54
+ bulk). A missing name is `null` in the bulk map, a 404 alone. A single name gets npm's single-package
55
+ shape. Counts are cached per registry instance.
56
+ - **`neighbours`** — `packageNameHelper.variants(name)` (≤ `maxVariants`, ≤ `maxScopedLookups` scoped
57
+ ones) priced through `downloads`; the existing ones, most downloaded first, ≤ `maxNeighbours`. npm
58
+ search is never used: `/-/v1/search?text=loadsh` does not return `lodash`.
59
+ - **`repositoryManifest`** — `package.json` at `HEAD` of the repository on GitHub
60
+ (`raw.githubusercontent.com/<o>/<r>/HEAD/<dir>/package.json`) or GitLab (`/-/raw/HEAD/`), at the
61
+ declared `directory`; `root` when it is `private` or declares workspaces. Other hosts → `null`.
62
+
63
+ Every request carries `user-agent`, a timeout, and is retried on 429/502/503/504 after `retry-after`
64
+ (else 1 s, 2 s, 4 s; ≤ 10 s each, `retries` times) — npm's download counts API throttles bursts.
65
+
66
+ ## Rules
67
+
68
+ - A 404 is `null`; anything else throws `PackageRegistryError` (`npm:<packument|latest|downloads|repository|readme>:<subject>:<status|timeout|unreachable|malformed>`).
69
+ The inspector turns that into an `unknown` verdict, so a throttled npm never yields `genuine`.
70
+ - Pass `fetch` for a pinned or proxied client; keep the defaults' public hosts in production.
71
+ - Register only through `appendNpmRegistry(ctx, opts)` (or pass the registry to
72
+ `createPackageInspector`) — nothing registers on import.
73
+ - Keep npm's wire values here — `@owlmeans/package-inspector` stays registry-neutral; the rules
74
+ for any adapter are its skill's "Writing a registry adapter".
75
+
76
+ ## Pitfalls
77
+
78
+ - An `unknown` verdict with `unavailable` means npm could not be asked (a timeout, a throttle past
79
+ `retries`, an unreadable answer) — retry later; never treat it as installable.
80
+ - Facts marked `partial` (a packument past `maxDocumentBytes`) carry no dates or version count, so
81
+ the `young` rule cannot fire for them.
82
+ - One registry instance caches download counts for `cacheTtlMs`; build a new one (or pass
83
+ `cacheTtlMs: 0`) where fresh counts matter.
84
+
85
+ ## Tests
86
+
87
+ `bun test ./tests` in the package.
88
+
89
+ - Offline specs run against a real local HTTP stand-in (`startStandIn` in the test context:
90
+ packuments, bulk downloads with `null`s, the 128 limit, raw repository files, 404s, a streamed
91
+ oversized packument, a throttled call): `registry.spec` (facts mapping, scoped names, the
92
+ latest-version fallback, failures naming their cause, bulk pricing, retries, neighbours, the
93
+ repository manifest), `repository.spec` (every declared repository form, browse and raw URLs),
94
+ `append.spec` (registration in the context's host).
95
+ - `live.spec` is gated by `PACKAGE_REGISTRY_NPM_LIVE=1`: `dayjs` genuine, `loadsh` suspicious
96
+ lookalike of `lodash` with a copied description, `momnet` holding, a random name `not-found`.
97
+
98
+ ## Related
99
+
100
+ - [[package-inspector]] (`@owlmeans/package-inspector`) — the verdict engine, its rules and host; "Writing a registry adapter"
101
+ - [[web-research]] (`@owlmeans/web-research`) — `research:packages` and `research:skill` read npm facts through the inspector
@@ -0,0 +1,9 @@
1
+ import type { BasicConfig, BasicContext } from '@owlmeans/context';
2
+ import type { AppendNpmRegistryOptions } from './types.js';
3
+ /**
4
+ * Register an inspector over the npm registry in the context's package inspector host, under the id
5
+ * `NPM_REGISTRY`; `ensurePackageInspectorService(ctx).get(NPM_REGISTRY)` reaches it. The inspector's
6
+ * own options (`thresholds`, `concurrency`, `now`) pass through.
7
+ */
8
+ export declare const appendNpmRegistry: <C extends BasicConfig, T extends BasicContext<C>>(context: T, options?: AppendNpmRegistryOptions) => T;
9
+ //# sourceMappingURL=append.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../src/append.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGlE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAE1D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,WACvE,CAAC,YAAW,wBAAwB,KAC5C,CAIF,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { appendPackageInspector } from '@owlmeans/package-inspector';
2
+ import { createNpmRegistry } from './registry.js';
3
+ /**
4
+ * Register an inspector over the npm registry in the context's package inspector host, under the id
5
+ * `NPM_REGISTRY`; `ensurePackageInspectorService(ctx).get(NPM_REGISTRY)` reaches it. The inspector's
6
+ * own options (`thresholds`, `concurrency`, `now`) pass through.
7
+ */
8
+ export const appendNpmRegistry = (context, options = {}) => {
9
+ const { thresholds, concurrency, now, ...registry } = options;
10
+ return appendPackageInspector(context, { registry: createNpmRegistry(registry), thresholds, concurrency, now });
11
+ };
12
+ //# sourceMappingURL=append.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"append.js","sourceRoot":"","sources":["../src/append.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,OAAU,EAAE,OAAO,GAA6B,EAAE,EAC/C,EAAE;IACL,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAA;IAE7D,OAAO,sBAAsB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAA;AACjH,CAAC,CAAA"}
@@ -0,0 +1,63 @@
1
+ /** The registry id the npm adapter registers under in the package inspector host. */
2
+ export declare const NPM_REGISTRY = "npm";
3
+ /** The public npm registry: packuments at `/<name>`, a version's document at `/<name>/<version>`. */
4
+ export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org";
5
+ /** npm's download counts API: `/downloads/point/<period>/<names>`. */
6
+ export declare const NPM_DOWNLOADS_URL = "https://api.npmjs.org";
7
+ /** The public page of a package: `<url>/<name>`. */
8
+ export declare const NPM_PACKAGE_PAGE_URL = "https://www.npmjs.com/package";
9
+ /** The period every count covers. */
10
+ export declare const NPM_DOWNLOADS_PERIOD = "last-week";
11
+ /** The most unscoped names one bulk downloads call accepts; scoped names are never bulk. */
12
+ export declare const NPM_BULK_LIMIT = 128;
13
+ /** Bulk downloads calls in flight at once — npm's download counts API throttles bursts. */
14
+ export declare const NPM_BULK_CONCURRENCY = 2;
15
+ /** Single scoped downloads calls in flight at once. */
16
+ export declare const NPM_SCOPED_CONCURRENCY = 2;
17
+ /** How many times a throttled (429) or briefly unavailable request is retried. */
18
+ export declare const NPM_RETRIES = 3;
19
+ /** The statuses that are retried. */
20
+ export declare const NPM_RETRY_STATUSES: readonly number[];
21
+ /** The first backoff without a `retry-after`, in ms; it doubles per retry. */
22
+ export declare const NPM_RETRY_BACKOFF = 1000;
23
+ /** The longest single wait before a retry, in ms, whatever `retry-after` says. */
24
+ export declare const NPM_RETRY_MAX_WAIT = 10000;
25
+ /** Milliseconds before one request (headers and body) is abandoned. */
26
+ export declare const NPM_TIMEOUT = 10000;
27
+ /** The packument is read up to this many bytes; a larger one is read through the latest version's document. */
28
+ export declare const NPM_MAX_DOCUMENT_BYTES: number;
29
+ /** The cap of a version document, a downloads answer and a repository manifest. */
30
+ export declare const NPM_MAX_SMALL_BYTES: number;
31
+ /** A readme longer than this is cut (`readmeTruncated`). */
32
+ export declare const NPM_MAX_README_CHARS = 64000;
33
+ /** The readme files tried in a repository when the packument was too large to carry its readme. */
34
+ export declare const NPM_README_FILES: readonly string[];
35
+ /** How many neighbours `neighbours` returns. */
36
+ export declare const NPM_MAX_NEIGHBOURS = 5;
37
+ /** How many name variants are priced by downloads. */
38
+ export declare const NPM_MAX_VARIANTS = 1024;
39
+ /** How many scoped variants are looked up — each one is a call of its own. */
40
+ export declare const NPM_MAX_SCOPED_LOOKUPS = 8;
41
+ /** How long a download count is reused, in ms; `0` disables the cache. */
42
+ export declare const NPM_CACHE_TTL: number;
43
+ /** The most download counts kept. */
44
+ export declare const NPM_CACHE_SIZE = 20000;
45
+ /** The `user-agent` every request carries unless the options name another. */
46
+ export declare const NPM_USER_AGENT = "@owlmeans/package-registry-npm";
47
+ /** The version npm publishes over a removed malicious package's name. */
48
+ export declare const NPM_HOLDING_VERSION = "0.0.1-security";
49
+ /** The description of npm's security holding packages. */
50
+ export declare const NPM_HOLDING_DESCRIPTION = "security holding package";
51
+ /** The lifecycle scripts npm runs while a package is installed. */
52
+ export declare const NPM_INSTALL_SCRIPTS: readonly string[];
53
+ /** Where GitHub serves a repository's raw files: `<url>/<owner>/<name>/<ref>/<path>`. */
54
+ export declare const GITHUB_RAW_URL = "https://raw.githubusercontent.com";
55
+ export declare const GITHUB_URL = "https://github.com";
56
+ /** GitLab's web host; raw files at `<url>/<path>/-/raw/<ref>/<file>`. */
57
+ export declare const GITLAB_URL = "https://gitlab.com";
58
+ /** The repository hosts whose manifests the adapter reads. */
59
+ export declare enum RepositoryHost {
60
+ GitHub = "github",
61
+ GitLab = "gitlab"
62
+ }
63
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,eAAO,MAAM,YAAY,QAAQ,CAAA;AAEjC,qGAAqG;AACrG,eAAO,MAAM,gBAAgB,+BAA+B,CAAA;AAE5D,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,0BAA0B,CAAA;AAExD,oDAAoD;AACpD,eAAO,MAAM,oBAAoB,kCAAkC,CAAA;AAEnE,qCAAqC;AACrC,eAAO,MAAM,oBAAoB,cAAc,CAAA;AAE/C,4FAA4F;AAC5F,eAAO,MAAM,cAAc,MAAM,CAAA;AAEjC,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,IAAI,CAAA;AAErC,uDAAuD;AACvD,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC,kFAAkF;AAClF,eAAO,MAAM,WAAW,IAAI,CAAA;AAE5B,qCAAqC;AACrC,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAwC,CAAA;AAExF,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,OAAQ,CAAA;AAEtC,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,QAAS,CAAA;AAExC,uEAAuE;AACvE,eAAO,MAAM,WAAW,QAAS,CAAA;AAEjC,+GAA+G;AAC/G,eAAO,MAAM,sBAAsB,QAAkB,CAAA;AAErD,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,QAAc,CAAA;AAE9C,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,QAAS,CAAA;AAE1C,mGAAmG;AACnG,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAA8C,CAAA;AAE5F,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,IAAI,CAAA;AAEnC,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC,0EAA0E;AAC1E,eAAO,MAAM,aAAa,QAAc,CAAA;AAExC,qCAAqC;AACrC,eAAO,MAAM,cAAc,QAAS,CAAA;AAEpC,8EAA8E;AAC9E,eAAO,MAAM,cAAc,mCAAmC,CAAA;AAE9D,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAEnD,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB,6BAA6B,CAAA;AAEjE,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAA4D,CAAA;AAE7G,yFAAyF;AACzF,eAAO,MAAM,cAAc,sCAAsC,CAAA;AAEjE,eAAO,MAAM,UAAU,uBAAuB,CAAA;AAE9C,yEAAyE;AACzE,eAAO,MAAM,UAAU,uBAAuB,CAAA;AAE9C,8DAA8D;AAC9D,oBAAY,cAAc;IACxB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB"}
@@ -0,0 +1,64 @@
1
+ /** The registry id the npm adapter registers under in the package inspector host. */
2
+ export const NPM_REGISTRY = 'npm';
3
+ /** The public npm registry: packuments at `/<name>`, a version's document at `/<name>/<version>`. */
4
+ export const NPM_REGISTRY_URL = 'https://registry.npmjs.org';
5
+ /** npm's download counts API: `/downloads/point/<period>/<names>`. */
6
+ export const NPM_DOWNLOADS_URL = 'https://api.npmjs.org';
7
+ /** The public page of a package: `<url>/<name>`. */
8
+ export const NPM_PACKAGE_PAGE_URL = 'https://www.npmjs.com/package';
9
+ /** The period every count covers. */
10
+ export const NPM_DOWNLOADS_PERIOD = 'last-week';
11
+ /** The most unscoped names one bulk downloads call accepts; scoped names are never bulk. */
12
+ export const NPM_BULK_LIMIT = 128;
13
+ /** Bulk downloads calls in flight at once — npm's download counts API throttles bursts. */
14
+ export const NPM_BULK_CONCURRENCY = 2;
15
+ /** Single scoped downloads calls in flight at once. */
16
+ export const NPM_SCOPED_CONCURRENCY = 2;
17
+ /** How many times a throttled (429) or briefly unavailable request is retried. */
18
+ export const NPM_RETRIES = 3;
19
+ /** The statuses that are retried. */
20
+ export const NPM_RETRY_STATUSES = Object.freeze([429, 502, 503, 504]);
21
+ /** The first backoff without a `retry-after`, in ms; it doubles per retry. */
22
+ export const NPM_RETRY_BACKOFF = 1_000;
23
+ /** The longest single wait before a retry, in ms, whatever `retry-after` says. */
24
+ export const NPM_RETRY_MAX_WAIT = 10_000;
25
+ /** Milliseconds before one request (headers and body) is abandoned. */
26
+ export const NPM_TIMEOUT = 10_000;
27
+ /** The packument is read up to this many bytes; a larger one is read through the latest version's document. */
28
+ export const NPM_MAX_DOCUMENT_BYTES = 4 * 1024 * 1024;
29
+ /** The cap of a version document, a downloads answer and a repository manifest. */
30
+ export const NPM_MAX_SMALL_BYTES = 1024 * 1024;
31
+ /** A readme longer than this is cut (`readmeTruncated`). */
32
+ export const NPM_MAX_README_CHARS = 64_000;
33
+ /** The readme files tried in a repository when the packument was too large to carry its readme. */
34
+ export const NPM_README_FILES = Object.freeze(['README.md', 'readme.md']);
35
+ /** How many neighbours `neighbours` returns. */
36
+ export const NPM_MAX_NEIGHBOURS = 5;
37
+ /** How many name variants are priced by downloads. */
38
+ export const NPM_MAX_VARIANTS = 1024;
39
+ /** How many scoped variants are looked up — each one is a call of its own. */
40
+ export const NPM_MAX_SCOPED_LOOKUPS = 8;
41
+ /** How long a download count is reused, in ms; `0` disables the cache. */
42
+ export const NPM_CACHE_TTL = 10 * 60_000;
43
+ /** The most download counts kept. */
44
+ export const NPM_CACHE_SIZE = 20_000;
45
+ /** The `user-agent` every request carries unless the options name another. */
46
+ export const NPM_USER_AGENT = '@owlmeans/package-registry-npm';
47
+ /** The version npm publishes over a removed malicious package's name. */
48
+ export const NPM_HOLDING_VERSION = '0.0.1-security';
49
+ /** The description of npm's security holding packages. */
50
+ export const NPM_HOLDING_DESCRIPTION = 'security holding package';
51
+ /** The lifecycle scripts npm runs while a package is installed. */
52
+ export const NPM_INSTALL_SCRIPTS = Object.freeze(['preinstall', 'install', 'postinstall']);
53
+ /** Where GitHub serves a repository's raw files: `<url>/<owner>/<name>/<ref>/<path>`. */
54
+ export const GITHUB_RAW_URL = 'https://raw.githubusercontent.com';
55
+ export const GITHUB_URL = 'https://github.com';
56
+ /** GitLab's web host; raw files at `<url>/<path>/-/raw/<ref>/<file>`. */
57
+ export const GITLAB_URL = 'https://gitlab.com';
58
+ /** The repository hosts whose manifests the adapter reads. */
59
+ export var RepositoryHost;
60
+ (function (RepositoryHost) {
61
+ RepositoryHost["GitHub"] = "github";
62
+ RepositoryHost["GitLab"] = "gitlab";
63
+ })(RepositoryHost || (RepositoryHost = {}));
64
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAA;AAEjC,qGAAqG;AACrG,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAA;AAE5D,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAA;AAExD,oDAAoD;A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MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,GAAG,MAAM,CAAA;AAExC,qCAAqC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAA;AAEpC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,gCAAgC,CAAA;AAE9D,yEAAyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAA;AAEnD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAA;AAEjE,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAA;AAE7G,yFAAyF;AACzF,MAAM,CAAC,MAAM,cAAc,GAAG,mCAAmC,CAAA;AAEjE,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAA;AAE9C,yEAAyE;AACzE,MAAM,CAAC,MAAM,UAAU,GAAG,oBAAoB,CAAA;AAE9C,8DAA8D;AAC9D,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB"}
@@ -0,0 +1,7 @@
1
+ export type * from './types.js';
2
+ export type * from './repository/types.js';
3
+ export * from './consts.js';
4
+ export * from './repository.js';
5
+ export * from './registry.js';
6
+ export * from './append.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,uBAAuB,CAAA;AAE1C,cAAc,aAAa,CAAA;AAE3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './consts.js';
2
+ export * from './repository.js';
3
+ export * from './registry.js';
4
+ export * from './append.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAA;AAE3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { NpmFactsMapper, NpmFactsOptions } from './types.local.js';
2
+ export declare const createNpmFactsMapper: (options: NpmFactsOptions) => NpmFactsMapper;
3
+ //# sourceMappingURL=facts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../../src/registry/facts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEvE,eAAO,MAAM,oBAAoB,YAAa,eAAe,KAAG,cA+F/D,CAAA"}
@@ -0,0 +1,89 @@
1
+ import { NPM_HOLDING_DESCRIPTION, NPM_HOLDING_VERSION, NPM_INSTALL_SCRIPTS, NPM_PACKAGE_PAGE_URL } from '../consts.js';
2
+ export const createNpmFactsMapper = (options) => {
3
+ const text = (value) => typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
4
+ const repositoryOf = (field) => {
5
+ const url = text(typeof field === 'string' ? field : field?.url);
6
+ if (url == null) {
7
+ return undefined;
8
+ }
9
+ const directory = typeof field === 'object' ? text(field.directory) : undefined;
10
+ const location = options.locator.locate(url, directory);
11
+ return {
12
+ url,
13
+ ...(location?.directory != null ? { directory: location.directory } : directory != null ? { directory } : {}),
14
+ ...(location != null ? { web: options.locator.webOf(location) } : {}),
15
+ };
16
+ };
17
+ const licenseOf = (field) => typeof field === 'string' ? text(field) : text(field?.type);
18
+ /** The exports map as JSON allows it — strings, `null`, lists and objects; anything else dropped. */
19
+ const exportsOf = (value) => {
20
+ if (value === null || typeof value === 'string')
21
+ return value;
22
+ if (Array.isArray(value))
23
+ return value.map(exportsOf).filter((item) => item !== undefined);
24
+ if (typeof value !== 'object')
25
+ return undefined;
26
+ const entries = Object.entries(value)
27
+ .map(([key, item]) => [key, exportsOf(item)])
28
+ .filter((entry) => entry[1] !== undefined);
29
+ return Object.fromEntries(entries);
30
+ };
31
+ /** How the version is imported, as its manifest declares it; absent when it declares nothing. */
32
+ const entryOf = (version) => {
33
+ const type = text(version?.type);
34
+ const main = text(version?.main);
35
+ const module = text(version?.module);
36
+ const types = text(version?.types) ?? text(version?.typings);
37
+ const exports = exportsOf(version?.exports);
38
+ const entry = {
39
+ ...(type != null ? { type } : {}), ...(main != null ? { main } : {}), ...(module != null ? { module } : {}),
40
+ ...(types != null ? { types } : {}), ...(exports !== undefined ? { exports } : {}),
41
+ };
42
+ return Object.keys(entry).length > 0 ? entry : undefined;
43
+ };
44
+ const factsOf = (name, packument, latestDocument) => {
45
+ const latest = text(packument?.['dist-tags']?.latest) ?? text(latestDocument?.version);
46
+ const versions = packument?.versions ?? {};
47
+ const version = latestDocument ?? (latest != null ? versions[latest] : undefined);
48
+ const description = text(packument?.description) ?? text(version?.description);
49
+ const scripts = version?.scripts ?? {};
50
+ const installScripts = NPM_INSTALL_SCRIPTS.filter(script => text(scripts[script]) != null);
51
+ // npm runs `node-gyp rebuild` as the install script of a package that ships a binding and names none.
52
+ if (version?.gypfile === true && !installScripts.includes('install')) {
53
+ installScripts.push('install');
54
+ }
55
+ const maintainers = packument?.maintainers ?? version?.maintainers;
56
+ const readme = text(packument?.readme);
57
+ const repository = repositoryOf(packument?.repository ?? version?.repository);
58
+ const homepage = text(packument?.homepage) ?? text(version?.homepage);
59
+ const license = licenseOf(packument?.license ?? version?.license);
60
+ const deprecated = typeof version?.deprecated === 'string' ? text(version.deprecated) : undefined;
61
+ const entry = entryOf(version);
62
+ const created = text(packument?.time?.created);
63
+ const modified = text(packument?.time?.modified);
64
+ return {
65
+ name: text(packument?.name) ?? text(version?.name) ?? name,
66
+ ...(description != null ? { description } : {}),
67
+ ...(latest != null ? { latest } : {}),
68
+ ...(created != null ? { created } : {}),
69
+ ...(modified != null ? { modified } : {}),
70
+ ...(packument != null ? { versionCount: Object.keys(versions).length } : {}),
71
+ ...(Array.isArray(maintainers) ? { maintainerCount: maintainers.length } : {}),
72
+ ...(deprecated != null ? { deprecated } : {}),
73
+ installScripts,
74
+ ...(repository != null ? { repository } : {}),
75
+ ...(homepage != null ? { homepage } : {}),
76
+ ...(license != null ? { license } : {}),
77
+ page: `${NPM_PACKAGE_PAGE_URL}/${name}`,
78
+ provenance: version?.dist?.attestations?.provenance != null,
79
+ holding: latest === NPM_HOLDING_VERSION || description?.toLowerCase() === NPM_HOLDING_DESCRIPTION,
80
+ unpublished: packument?.time?.unpublished != null && Object.keys(versions).length === 0,
81
+ ...(readme != null ? { readme: readme.slice(0, options.maxReadmeChars) } : {}),
82
+ ...(readme != null && readme.length > options.maxReadmeChars ? { readmeTruncated: true } : {}),
83
+ ...(entry != null ? { entry } : {}),
84
+ ...(packument == null ? { partial: true } : {}),
85
+ };
86
+ };
87
+ return { factsOf };
88
+ };
89
+ //# sourceMappingURL=facts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facts.js","sourceRoot":"","sources":["../../src/registry/facts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAItH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAwB,EAAkB,EAAE;IAC/E,MAAM,IAAI,GAAG,CAAC,KAAc,EAAsB,EAAE,CAClD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CA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ACjG,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC;YACvF,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9E,GAAG,CAAC,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9F,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,GAAG,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD,CAAA;IACH,CAAC,CAAA;IAED,OAAO,EAAE,OAAO,EAAE,CAAA;AACpB,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { NpmHttp, NpmHttpOptions } from './types.local.js';
2
+ export declare const createNpmHttp: (options: NpmHttpOptions) => NpmHttp;
3
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/registry/http.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAI/D,eAAO,MAAM,aAAa,YAAa,cAAc,KAAG,OA6GvD,CAAA"}