MCPcopy Index your code
hub / github.com/darkreader/darkreader / firefoxFetchAllReleases

Function firefoxFetchAllReleases

tasks/integrity.js:16–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14}
15
16async function firefoxFetchAllReleases() {
17 try {
18 const file = await readFile(`${tmpDirParent}/firefox-index.json`);
19 log.ok('Found previously stored index');
20 return JSON.parse(file);
21 } catch {
22 log.ok('Fetching release URLs from Mozilla');
23 }
24 const versions = [];
25 let dataUrl = 'https://addons.mozilla.org/api/v5/addons/addon/darkreader/versions/';
26 while (dataUrl) {
27 const {next, results} = await (await fetch(dataUrl)).json();
28 dataUrl = next;
29 for (const {file, version} of results) {
30 const {hash, url, size} = file;
31 versions.push({version, hash, url, size});
32 }
33 }
34 return versions;
35}
36
37function toBuffer(arrayBuffer) {
38 const buffer = Buffer.alloc(arrayBuffer.byteLength);

Callers 1

firefoxFetchAllMetadataFunction · 0.85

Calls 1

readFileFunction · 0.85

Tested by

no test coverage detected