@preventive/upstream 1.12.0 → 1.13.1

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 (52) hide show
  1. package/advisories.d.ts +125 -89
  2. package/cargo.d.ts +59 -35
  3. package/cocoapods.d.ts +44 -57
  4. package/electron.d.ts +35 -25
  5. package/git.d.ts +25 -16
  6. package/github/write.d.ts +60 -29
  7. package/github.d.ts +207 -193
  8. package/npm.d.ts +151 -87
  9. package/package.d.ts +30 -16
  10. package/package.json +1 -1
  11. package/rubygems.d.ts +22 -9
  12. package/semver.d.ts +40 -19
  13. package/soldeer.d.ts +21 -12
  14. package/src/advisories/actions.js +13 -38
  15. package/src/advisories/common.js +29 -1
  16. package/src/advisories/github.js +5 -19
  17. package/src/advisories/index.js +3 -10
  18. package/src/advisories/npm.js +4 -19
  19. package/src/advisories/osv.js +19 -41
  20. package/src/advisories/packagist.js +1 -4
  21. package/src/advisories/patched.js +6 -18
  22. package/src/advisories/repos.js +8 -13
  23. package/src/advisories/rubysec.js +2 -7
  24. package/src/args.js +5 -10
  25. package/src/attributes.js +3 -4
  26. package/src/cache.js +9 -22
  27. package/src/cargo/crate.js +4 -7
  28. package/src/cargo/repos.js +1 -7
  29. package/src/cocoapods.js +3 -19
  30. package/src/download.js +4 -12
  31. package/src/electron.js +6 -8
  32. package/src/github/commit.js +1 -13
  33. package/src/github/read.js +19 -68
  34. package/src/github/write.js +0 -1
  35. package/src/http.js +2 -7
  36. package/src/lockfiles.js +3 -11
  37. package/src/npm/cacache.js +3 -8
  38. package/src/npm/registry.js +12 -4
  39. package/src/npm/repos.js +3 -15
  40. package/src/npm/tarball.js +5 -20
  41. package/src/npm/versions.js +7 -21
  42. package/src/package.js +1 -7
  43. package/src/pool.js +0 -1
  44. package/src/pypi/version.js +1 -5
  45. package/src/remote.js +4 -6
  46. package/src/rubygems/gem.js +2 -2
  47. package/src/rubygems/version.js +2 -10
  48. package/src/semver.js +3 -9
  49. package/src/soldeer.js +0 -4
  50. package/src/tree.js +14 -44
  51. package/src/weak-edges.js +0 -2
  52. package/weak-edges.d.ts +36 -24
package/advisories.d.ts CHANGED
@@ -1,101 +1,137 @@
1
- import type { Client, RepoName } from './github.js'
2
- import type { CacheStore } from './npm.js'
1
+ /**
2
+ * Advisories on packages' versions, from npm's registry, OSV, Packagist, ruby-advisory-db and packages' repositories
3
+ *
4
+ * ```js
5
+ * import { advisories } from '@preventive/upstream/advisories.js'
6
+ * ```
7
+ *
8
+ * @module @preventive/upstream/advisories.js
9
+ */
3
10
 
4
- export { HttpError } from './npm.js'
5
- export type { CacheStore } from './npm.js'
11
+ import type { Client, RepoName } from './github.js';
12
+ import type { CacheStore } from './npm.js';
6
13
 
7
- // purl's package types, and `ruby` for Ruby interpreters.
8
- export type Ecosystem = 'npm' | 'cargo' | 'composer' | 'gem' | 'ruby' | 'pypi' | 'swift' | 'cocoapods' | 'soldeer' | 'github'
14
+ export { HttpError } from './npm.js';
15
+ export type { CacheStore } from './npm.js';
9
16
 
17
+ /** purl's package types, and `ruby` for Ruby interpreters */
18
+ export type Ecosystem =
19
+ | 'npm'
20
+ | 'cargo'
21
+ | 'composer'
22
+ | 'gem'
23
+ | 'ruby'
24
+ | 'pypi'
25
+ | 'swift'
26
+ | 'cocoapods'
27
+ | 'soldeer'
28
+ | 'github';
29
+
30
+ /** A package, and the versions of it to look up */
10
31
  export interface Package {
11
- ecosystem: Ecosystem
12
- // As its lockfile names it: a pod by its root (`Firebase`), a Swift package
13
- // by its repository in any case (`github.com/vapor/vapor`), a `github` package
14
- // by `owner/name` as GitHub spells it, a Ruby by its engine (`ruby`, `jruby`).
15
- name: string
16
- // Its repository, where known, so `repoAdvisories` needn't look it up.
17
- github?: RepoName
18
- // As its lockfile writes them, matched by the ecosystem's own rules: Ruby's as
19
- // Bundler writes it (`3.3.6p108`). A `github` package takes a tag (`v4` its
20
- // whole line), a branch or a commit; an unversioned Swift pin is refused.
21
- versions: string[]
22
- // A `github` package: true to ask its repository alone, its name sent to
23
- // no other source (OSV), as for one not everyone may read. Any spelling
24
- // saying so holds for all. Not for other ecosystems. Without it, a
25
- // `github` package is asked of OSV only where github.com serves it to
26
- // anyone, its git ref advertisement asked with no credentials answering
27
- // 200; a private or internal repository, or one gone or moved, is asked
28
- // of its repository alone too, and any other answer (a rate limit, an
29
- // error) throws, before OSV is asked. A public one is cached a month.
30
- internal?: boolean
32
+ ecosystem: Ecosystem;
33
+ /**
34
+ * As its lockfile names it: a pod by its root (`Firebase`), a Swift package by its repository in any case
35
+ * (`github.com/vapor/vapor`), a `github` package by `owner/name`, a Ruby by its engine (`ruby`, `jruby`)
36
+ */
37
+ name: string;
38
+ /** Its repository, where known, so it need not be looked up; not for a `github` package */
39
+ github?: RepoName;
40
+ /**
41
+ * As its lockfile writes them, matched by the ecosystem's own rules: a Ruby's as Bundler writes it (`3.3.6p108`);
42
+ * a `github` package's a tag (`v4` its whole line), a branch or a commit
43
+ */
44
+ versions: string[];
45
+ /**
46
+ * A `github` package only: ask its repository alone, its name sent to no other source (OSV)
47
+ *
48
+ * Without it, OSV is asked only of a repository github.com serves without credentials, which is cached a month;
49
+ * any other answer than yes or no from github.com throws.
50
+ */
51
+ internal?: boolean;
31
52
  }
32
53
 
54
+ /** What else `advisories()` asks, and where it caches */
33
55
  export interface AdvisoryOptions {
34
- // Required for `ruby`, `cocoapods`, `soldeer` and `github` packages and for
35
- // `repoAdvisories`. With it, gems are also checked against ruby-advisory-db.
36
- github?: Client
37
- // Also reads advisories each package's repository has published that
38
- // GitHub hasn't reviewed yet. Needs `github`.
39
- repoAdvisories?: boolean
40
- // Where lookups and listings are cached (see CacheOptions); false keeps none.
41
- cache?: CacheStore | false
42
- // Also returns each advisory's full text, as `details`.
43
- details?: boolean
44
- // Also asks OSV about public npm packages: malware and taken-down
45
- // releases, which npm's registry has no advisories of.
46
- osv?: boolean
47
- // false: OSV's ids as OSV tells them, GitHub's own record of a GHSA read
48
- // never (raw.githubusercontent.com asked nothing). No row has `related`,
49
- // and a GHSA OSV joins with another is grouped with it, as its alias, a
50
- // version of both reported under one. Default true.
51
- githubAliases?: boolean
56
+ /**
57
+ * Required for `ruby`, `cocoapods`, `soldeer` and `github` packages and for `repoAdvisories`; with it, gems are
58
+ * also checked against ruby-advisory-db
59
+ */
60
+ github?: Client;
61
+ /** Also read advisories each package's repository has published that GitHub hasn't reviewed yet; needs `github` */
62
+ repoAdvisories?: boolean;
63
+ /** Default: `setCacheDir()`'s cache. A store takes its place; `false` still reads it, but writes nothing. */
64
+ cache?: CacheStore | false;
65
+ /** Also return each advisory's full text, as `details` */
66
+ details?: boolean;
67
+ /**
68
+ * Also ask OSV about npm packages: malware and taken-down releases, which npm's registry has no advisories of
69
+ *
70
+ * Only a package npm serves without a token is asked of OSV; any other answer counts as private.
71
+ */
72
+ osv?: boolean;
73
+ /**
74
+ * Read GitHub's own record of each GHSA OSV reports, to tell apart the advisories OSV joins as aliases (default:
75
+ * true)
76
+ *
77
+ * With `false`, raw.githubusercontent.com is asked nothing, no row has `related`, and GHSAs OSV joins are one row.
78
+ */
79
+ githubAliases?: boolean;
52
80
  }
53
81
 
54
- // One advisory on one package, one row per id, however many sources have it.
82
+ /** One advisory on one package: one row per id, however many sources have it */
55
83
  export interface Advisory {
56
- ecosystem: Ecosystem
57
- name: string
58
- // npm's registry, OSV, Packagist, ruby-advisory-db, or the package's
59
- // repository (the only source for `cocoapods` and `soldeer`).
60
- source: 'registry' | 'osv' | 'packagist' | 'rubysec' | 'repository'
61
- // The GHSA where there is one, else its source's (RUSTSEC-..., PYSEC-...,
62
- // MAL-..., CVE-...), or npm:<id>.
63
- id: string
64
- ghsa?: string
65
- url?: string
66
- // Its other ids.
67
- aliases: string[]
68
- // Those of other advisories OSV joins with a GHSA, its GitHub record telling
69
- // them apart: another GHSA, and its CVE, as GHSA-37ch-88jc-xwx2 (of
70
- // CVE-2026-4867 alone) has GHSA-9wv6-86v2-598j and its CVE-2024-45296.
71
- // Each is an advisory of its own, which these versions may not be of. None
72
- // with `githubAliases: false`.
73
- related?: string[]
74
- title?: string
75
- // With `details`: its full text, in Markdown.
76
- details?: string
77
- // `critical`, `high`, `moderate` or `low`.
78
- severity?: string
79
- cvss?: number
80
- cvssVector?: string
81
- cwe: string[]
82
- // The affected range as its source wrote it, where it has one: those
83
- // covering the asked versions. One a repository gives with no end of its
84
- // own ends below each version it names as patched, a range per release
85
- // line: `>=9.5.0` patched in `15.5.13, 16.1.7` is `>=9.5.0, < 15.5.13`
86
- // and `>= 16.0.0-0, < 16.1.7`. OSV's are as GitHub writes one, those
87
- // holding the versions it reports, else all of them.
88
- range?: string
89
- // RustSec's `unmaintained`, `unsound` or `notice`: not a vulnerability as
90
- // such. A yanked crate isn't an advisory: see cargo.js's yankedVersions.
91
- informational?: string
92
- // Malware, not a vulnerability.
93
- malware?: true
94
- // The asked versions it affects, never none.
95
- versions: string[]
84
+ ecosystem: Ecosystem;
85
+ name: string;
86
+ /**
87
+ * npm's registry, OSV, Packagist, ruby-advisory-db or the package's repository (the only source for `cocoapods`
88
+ * and `soldeer`)
89
+ */
90
+ source: 'registry' | 'osv' | 'packagist' | 'rubysec' | 'repository';
91
+ /**
92
+ * By preference RustSec's for a crate, then the GHSA, else its source's (`PYSEC-...`, `MAL-...`, `CVE-...`), or
93
+ * `npm:<id>`
94
+ */
95
+ id: string;
96
+ ghsa?: string;
97
+ url?: string;
98
+ /** Its other ids */
99
+ aliases: string[];
100
+ /**
101
+ * Ids of other advisories OSV joins with this GHSA that GitHub's record tells apart, each an advisory of its own,
102
+ * which these versions may not be of; none with `githubAliases: false`
103
+ */
104
+ related?: string[];
105
+ title?: string;
106
+ /** With `details`: its full text, in Markdown */
107
+ details?: string;
108
+ /** `critical`, `high`, `moderate`, `low` or `info` */
109
+ severity?: string;
110
+ cvss?: number;
111
+ cvssVector?: string;
112
+ cwe: string[];
113
+ /**
114
+ * The affected range as its source writes it, where it has one; OSV's as GitHub writes one (`>= 1.0.0, < 1.2.6`)
115
+ *
116
+ * A repository's range with no end of its own ends below each version it names as patched, a range per release
117
+ * line: `>=9.5.0` patched in `15.5.13, 16.1.7` is `>=9.5.0, < 15.5.13` and `>= 16.0.0-0, < 16.1.7`.
118
+ */
119
+ range?: string;
120
+ /**
121
+ * RustSec's `unmaintained`, `unsound` or `notice`: not a vulnerability as such
122
+ *
123
+ * A yanked crate is no advisory: see `yankedVersions()` (cargo.js).
124
+ */
125
+ informational?: string;
126
+ /** Malware, not a vulnerability */
127
+ malware?: true;
128
+ /** The asked versions it affects, never none */
129
+ versions: string[];
96
130
  }
97
131
 
98
- // The advisories on the asked versions, sorted by ecosystem and name. Input
99
- // is checked before any request; a failed or malformed answer throws rather
100
- // than leaving anything out.
101
- export function advisories(packages: Iterable<Package>, options?: AdvisoryOptions): Promise<Advisory[]>
132
+ /**
133
+ * The advisories on the asked versions, sorted by ecosystem and name
134
+ *
135
+ * Input is checked before any request; a failed or malformed answer throws rather than leaving anything out.
136
+ */
137
+ export function advisories(packages: Iterable<Package>, options?: AdvisoryOptions): Promise<Advisory[]>;
package/cargo.d.ts CHANGED
@@ -1,41 +1,65 @@
1
- // A name is asserted to be a crate name, a version an exact semver
2
- // version, and a checksum 64 lowercase hex digits, before any request or
3
- // cache path. The cache is setCacheDir's (npm.js).
1
+ /**
2
+ * crates.io: .crate files held to their checksums, yanked versions, and crates' GitHub repos
3
+ *
4
+ * ```js
5
+ * import { getCrate, resolveCrateRepos, verifyChecksum, yankedVersions } from '@preventive/upstream/cargo.js'
6
+ * ```
7
+ *
8
+ * Names, versions (exact semver) and checksums are checked before any request or cache path. The cache is
9
+ * `setCacheDir()`'s (npm.js).
10
+ *
11
+ * @module @preventive/upstream/cargo.js
12
+ */
4
13
 
5
- import type { CacheOptions } from './npm.js'
14
+ import type { CacheOptions } from './npm.js';
6
15
 
7
- export { HttpError } from './npm.js'
16
+ export { HttpError } from './npm.js';
8
17
 
9
- // Reads crates.io's index for that version and throws unless its sha256
10
- // is the one given, as for a checksum read off Cargo.lock. The index is
11
- // read on every call; nothing is cached.
12
- export function verifyChecksum(name: string, version: string, checksum: string): Promise<void>
18
+ /** A crate's GitHub repo */
19
+ export interface CrateRepo {
20
+ /** `owner/name`, as the crate's `repository` on crates.io names it */
21
+ github: string;
22
+ }
13
23
 
14
- // A published version's .crate, whole, in memory. `checksum` is its
15
- // sha256 as Cargo.lock records it; without one, crates.io's index is read
16
- // for it on every call, cached crate or not. Either way the bytes are
17
- // checked against it, whether they were downloaded from static.crates.io
18
- // (before they are cached) or read from a cache.
19
- //
20
- // Cargo's own cache is read first, and never written: each registry's
21
- // `<name>-<version>.crate` under $CARGO_HOME/registry/cache, else under
22
- // `~/.cargo`. A file there that does not match is passed over. One in
23
- // setCacheDir's cache that does not match throws.
24
- export function getCrate(name: string, version: string, checksum?: string): Promise<Uint8Array>
24
+ /**
25
+ * Throw unless crates.io's index has `checksum` for that version
26
+ *
27
+ * The index is read on every call; nothing is cached.
28
+ *
29
+ * @param checksum - A sha256 in lowercase hex, as Cargo.lock records it
30
+ */
31
+ export function verifyChecksum(name: string, version: string, checksum: string): Promise<void>;
25
32
 
26
- // Each asked crate's versions crates.io has yanked, as `cargo audit` warns
27
- // of, and those it doesn't have (all, for a crate of another registry or a
28
- // git source). Not advisories, so not in advisories(); cached 90 minutes.
29
- export function yankedVersions(crates: Iterable<{ name: string, versions: string[] }>, options?: CacheOptions): Promise<Map<string, { yanked: string[], unknown: string[] }>>
33
+ /**
34
+ * A published version's .crate, held to its sha256
35
+ *
36
+ * Cargo's own cache (each registry's under $CARGO_HOME/registry/cache, else `~/.cargo`'s) is read first and never
37
+ * written: a file there that does not match is passed over. One in `setCacheDir()`'s cache that does not match
38
+ * throws.
39
+ *
40
+ * @param checksum - As Cargo.lock records it; without one, crates.io's index is read for it on every call
41
+ */
42
+ export function getCrate(name: string, version: string, checksum?: string): Promise<Uint8Array>;
30
43
 
31
- // What resolveCrateRepos maps each resolved name to: `owner/name`, the
32
- // GitHub repo the crate's `repository` on crates.io names.
33
- export interface CrateRepo {
34
- github: string
35
- }
36
- // Fail-soft, as npm.js's resolvePackageRepos: a crate crates.io does not
37
- // have, one naming no GitHub repo, and those of a request that fails are
38
- // absent from the map. crates.io is asked a hundred names a request, a
39
- // second apart, as it asks; a repo found is cached for a month, and
40
- // `cachedOnly` answers from that cache alone and never fetches.
41
- export function resolveCrateRepos(crateNames: Iterable<string>, options?: { cachedOnly?: boolean }): Promise<Map<string, CrateRepo>>
44
+ /**
45
+ * Of each crate's asked versions, those crates.io has yanked, as `cargo audit` warns of, and those it has never
46
+ * published
47
+ *
48
+ * Not advisories, so not in `advisories()`. Cached 90 minutes.
49
+ */
50
+ export function yankedVersions(
51
+ crates: Iterable<{ name: string; versions: string[] }>,
52
+ options?: CacheOptions
53
+ ): Promise<Map<string, { yanked: string[]; unknown: string[] }>>;
54
+
55
+ /**
56
+ * Each crate's GitHub repo, cached a month
57
+ *
58
+ * A crate crates.io does not have, one naming no GitHub repo, and those of a request that fails are left out.
59
+ * crates.io is asked a hundred names a request, a second apart, as it asks. `cachedOnly` answers from the cache
60
+ * alone and never fetches.
61
+ */
62
+ export function resolveCrateRepos(
63
+ crateNames: Iterable<string>,
64
+ options?: { cachedOnly?: boolean }
65
+ ): Promise<Map<string, CrateRepo>>;
package/cocoapods.d.ts CHANGED
@@ -1,61 +1,48 @@
1
- // The name is asserted to be a root's as Podfile.lock writes it, printable
2
- // ASCII but for spaces, parentheses, slashes and backslashes, with no `.`
3
- // first; the version one of Pod::Version's; and the checksum 40 lowercase
4
- // hex digits, before any request or cache path. The cache is setCacheDir's
5
- // (npm.js).
1
+ /**
2
+ * CocoaPods trunk's podspecs, and the archives podspecs name, held to their checksums
3
+ *
4
+ * ```js
5
+ * import { getPodArchive, getPodspec, isPodArchiveUrl } from '@preventive/upstream/cocoapods.js'
6
+ * ```
7
+ *
8
+ * Arguments are checked before any request or cache path. The cache is `setCacheDir()`'s (npm.js). A pod built
9
+ * from a commit of a GitHub repo, as a podspec's `source` or CHECKOUT OPTIONS may name, is `getRepoTarball()`'s
10
+ * (github.js).
11
+ *
12
+ * @module @preventive/upstream/cocoapods.js
13
+ */
6
14
 
7
- export { HttpError } from './npm.js'
15
+ export { HttpError } from './npm.js';
8
16
 
9
- // A version's podspec from trunk, the JSON CocoaPods reads, whole, in
10
- // memory, as the CDN serves it under Specs/<a>/<b>/<c>/<name>/<version>/,
11
- // the first three hex digits of the md5 of the name: the files of
12
- // CocoaPods/Specs, so a pod from https://github.com/CocoaPods/Specs.git
13
- // too. Trunk says nothing of what a podspec hashes to, so `checksum` is
14
- // required: its sha1, as Podfile.lock records it in SPEC CHECKSUMS. The
15
- // bytes are checked against it, whether they were downloaded (before they
16
- // are cached) or read from a cache. The CDN's redirect to jsDelivr is
17
- // followed, as the bytes are checked whoever answers.
18
- //
19
- // A podspec is not fixed once trunk has it: `pod trunk deprecate` adds a
20
- // field to the latest version's. So one is cached by its checksum as well
21
- // as its version, and a lockfile written before such a change has a
22
- // checksum no download matches any longer, which throws.
23
- //
24
- // CocoaPods' own spec repos are read first, and never written: that path
25
- // in each directory under $CP_REPOS_DIR, else $CP_HOME_DIR/repos, else
26
- // `~/.cocoapods/repos`. A file there that does not match is passed over.
27
- // One in setCacheDir's cache that does not match throws. A cached podspec
28
- // that matches is answered with no request at all.
29
- //
30
- // What the pod is built from is not trunk's, and is not fetched here: a
31
- // commit of a GitHub repo, as a podspec's `source` or CHECKOUT OPTIONS
32
- // may name, is github.js's getRepoTarball's; an archive by :http is
33
- // getPodArchive's.
34
- export function getPodspec(name: string, version: string, checksum: string): Promise<Uint8Array>
17
+ /**
18
+ * A version's podspec from trunk's CDN, the JSON CocoaPods reads, held to `checksum`
19
+ *
20
+ * CocoaPods' own spec repos (each under $CP_REPOS_DIR, else $CP_HOME_DIR/repos, else `~/.cocoapods/repos`) are read
21
+ * first and never written: a file there that does not match is passed over. One in `setCacheDir()`'s cache that
22
+ * does not match throws. A podspec is not fixed: `pod trunk deprecate` rewrites the latest version's, after which a
23
+ * checksum recorded before matches no download, which throws.
24
+ *
25
+ * @param name - A root's, as Podfile.lock writes it
26
+ * @param checksum - Its sha1 in lowercase hex, as Podfile.lock records it in SPEC CHECKSUMS
27
+ */
28
+ export function getPodspec(name: string, version: string, checksum: string): Promise<Uint8Array>;
35
29
 
36
- // Whether `url` is an archive getPodArchive fetches, as a podspec's
37
- // `source` names one by :http, from GitHub or Meta's namespace on Maven
38
- // Central alone: https://github.com/<owner>/<repo>/ and a path under it,
39
- // such as GitHub's archive of a tag, `archive/refs/tags/<tag>.tar.gz`, or a
40
- // release's asset, `releases/download/<tag>/<file>`; or
41
- // https://repo1.maven.org/maven2/com/facebook/ and a path under it ending
42
- // in `.tar.gz` or `.zip`, such as React Native's
43
- // `react/react-native-artifacts/<version>/<file>.tar.gz`. Either exactly as
44
- // the URL parser writes it back out, `new URL(url).toString() === url`, so
45
- // that no `..`, `%2e%2e` or case takes it out from under the prefix it is
46
- // written with; with no query, fragment (an empty `?` or `#` among them),
47
- // credentials or port; and each segment of the path letters, digits, `_`,
48
- // `.`, `~`, `@`, `-` or a %-escape in capitals.
49
- export function isPodArchiveUrl(url: unknown): boolean
30
+ /**
31
+ * Whether `getPodArchive()` takes `url`: a path under `https://github.com/<owner>/<repo>/`, or a `.tar.gz` or
32
+ * `.zip` under `https://repo1.maven.org/maven2/com/facebook/`
33
+ *
34
+ * Spelled exactly as URL parsing writes it back, with no query, fragment, credentials or port, and each segment of
35
+ * the path letters, digits, `_`, `.`, `~`, `@`, `-` or %-escapes in capitals.
36
+ */
37
+ export function isPodArchiveUrl(url: unknown): boolean;
50
38
 
51
- // An archive a podspec's `source` names by :http, whole, in memory: `url`
52
- // is one isPodArchiveUrl takes. The hash is the podspec's :sha256, in
53
- // lowercase hex, as cocoapods-downloader checks it; a sha1, which two
54
- // archives made to collide share, is not taken. GitHub answers with a
55
- // redirect, to codeload.github.com or to where it keeps a release's files,
56
- // and Maven Central with one to repo.reactnative.dev for React Native's
57
- // archives, which is followed, as the bytes are held to the hash whoever
58
- // answers, downloaded (before they are cached) or read from setCacheDir's
59
- // cache. They are cached by the hash alone; one in the cache that does not
60
- // match throws. Each argument is asserted before any request.
61
- export function getPodArchive(url: string, sha256: string): Promise<Uint8Array>
39
+ /**
40
+ * An archive a podspec's `source` names by `:http`, held to its `:sha256`
41
+ *
42
+ * Redirects are followed, as the bytes are held to the hash whoever answers. Cached by the hash alone; a cached
43
+ * copy that does not match throws.
44
+ *
45
+ * @param url - One `isPodArchiveUrl()` takes
46
+ * @param sha256 - In lowercase hex; a `:sha1`, which two archives made to collide share, is not taken
47
+ */
48
+ export function getPodArchive(url: string, sha256: string): Promise<Uint8Array>;
package/electron.d.ts CHANGED
@@ -1,29 +1,39 @@
1
- // The version is asserted to be an Electron one (`45.5.0`,
2
- // `45.0.0-alpha.16`, `36.0.0-nightly.20250101`), the platform and arch
3
- // ones Electron builds for, and the checksum 64 lowercase hex digits,
4
- // before any request or cache path. The cache is setCacheDir's (npm.js).
1
+ /**
2
+ * Electron's release zips, held to their checksums
3
+ *
4
+ * ```js
5
+ * import { getElectronZip } from '@preventive/upstream/electron.js'
6
+ * ```
7
+ *
8
+ * @module @preventive/upstream/electron.js
9
+ */
5
10
 
6
- import type { CacheOptions } from './npm.js'
11
+ import type { CacheOptions } from './npm.js';
7
12
 
8
- export { HttpError } from './npm.js'
13
+ export { HttpError } from './npm.js';
9
14
 
10
- export type ElectronPlatform = 'darwin' | 'linux' | 'mas' | 'win32'
11
- export type ElectronArch = 'arm64' | 'armv7l' | 'ia32' | 'x64'
15
+ /** A platform Electron builds for */
16
+ export type ElectronPlatform = 'darwin' | 'linux' | 'mas' | 'win32';
12
17
 
13
- // `electron-v<version>-<platform>-<arch>.zip`, whole, in memory, from the
14
- // GitHub release `v<version>` of electron/electron (electron/nightlies
15
- // for a version naming a nightly), through GitHub's redirect to its asset
16
- // host. The release says nothing a lockfile holds of what the zip hashes
17
- // to, so `checksum` is required: its sha256, as the `electron` package's
18
- // checksums.json gives it. The bytes are checked against it, whether
19
- // downloaded (before they are kept) or read from upstream's or stasis's
20
- // default cache, setCacheDir's, or a `cache` store in its place, where one
21
- // that does not match throws. A kept zip that matches is answered with no
22
- // request at all.
23
- //
24
- // @electron/get's cache is read first, and never written: the zip under
25
- // $electron_config_cache where install.js is told to keep it there, else
26
- // under the platform's cache directory for electron (~/.cache/electron on
27
- // Linux), in the directory named for the sha256 of the release's URL. A
28
- // file there that does not match is passed over.
29
- export function getElectronZip(version: string, platform: ElectronPlatform, arch: ElectronArch, checksum: string, options?: CacheOptions): Promise<Uint8Array>
18
+ /** An architecture Electron builds for */
19
+ export type ElectronArch = 'arm64' | 'armv7l' | 'ia32' | 'x64';
20
+
21
+ /**
22
+ * `electron-v<version>-<platform>-<arch>.zip` from the GitHub release `v<version>` of electron/electron
23
+ * (electron/nightlies for a nightly), held to `checksum`
24
+ *
25
+ * `@electron/get`'s cache ($electron_config_cache, else the platform's cache directory for electron) and this
26
+ * package's and stasis's default caches are read first and never written: a zip there that does not match is passed
27
+ * over. One in `setCacheDir()`'s cache, or `cache`, that does not match throws; one that matches is answered with no
28
+ * request at all.
29
+ *
30
+ * @param version - An Electron version: `45.5.0`, `45.0.0-alpha.16`, `36.0.0-nightly.20250101`
31
+ * @param checksum - Its sha256 in lowercase hex, as the `electron` package's checksums.json gives it
32
+ */
33
+ export function getElectronZip(
34
+ version: string,
35
+ platform: ElectronPlatform,
36
+ arch: ElectronArch,
37
+ checksum: string,
38
+ options?: CacheOptions
39
+ ): Promise<Uint8Array>;
package/git.d.ts CHANGED
@@ -1,19 +1,28 @@
1
- // The shape getRepo (package.js) answers in, and HEAD's commit. Each
2
- // field best-effort: left out where it cannot be read.
1
+ /**
2
+ * The git checkout a directory is in, read without running git
3
+ *
4
+ * ```js
5
+ * import { findGitCheckout } from '@preventive/upstream/git.js'
6
+ * ```
7
+ *
8
+ * @module @preventive/upstream/git.js
9
+ */
10
+
11
+ /** A checkout in the shape `getRepo()` (package.js) answers in, and HEAD's commit; a field is absent where unread */
3
12
  export interface GitCheckout {
4
- // `owner/name`, when the origin remote is a GitHub one. Never the
5
- // remote's URL, which can name a private host or carry a token.
6
- github?: string
7
- // Where the directory sits in its checkout, `/`-separated; `''` at the
8
- // root.
9
- directory?: string
10
- // `https://github.com/<github>`, whenever there is a `github`.
11
- url?: string
12
- // HEAD's commit sha.
13
- commit?: string
13
+ /** `owner/name`, where the origin remote is on GitHub; never the remote's URL, which can carry a token */
14
+ github?: string;
15
+ /** Where the directory sits in its checkout, `/`-separated; `''` at the root */
16
+ directory?: string;
17
+ /** `https://github.com/<github>`, whenever there is a `github` */
18
+ url?: string;
19
+ /** HEAD's commit sha */
20
+ commit?: string;
14
21
  }
15
22
 
16
- // The checkout at or above `dir`, found by its closest `.git` (a
17
- // directory, or a `gitdir:` file) and read without running git. Empty
18
- // where there is no checkout.
19
- export function findGitCheckout(dir: string): Promise<GitCheckout>
23
+ /**
24
+ * The checkout at or above `dir`, found by its closest `.git` (a directory, or a `gitdir:` file)
25
+ *
26
+ * Empty where there is none.
27
+ */
28
+ export function findGitCheckout(dir: string): Promise<GitCheckout>;