camoufox-js 0.9.2 → 0.10.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.
- package/dist/pkgman.js +17 -3
- package/dist/webgl/sample.js +8 -9
- package/package.json +4 -4
package/dist/pkgman.js
CHANGED
|
@@ -20,6 +20,16 @@ const OS_MAP = {
|
|
|
20
20
|
linux: "lin",
|
|
21
21
|
win32: "win",
|
|
22
22
|
};
|
|
23
|
+
function getAuthorizationHeaders(url) {
|
|
24
|
+
const githubToken = process.env.GITHUB_TOKEN;
|
|
25
|
+
if (!githubToken)
|
|
26
|
+
return {};
|
|
27
|
+
const host = new URL(url).hostname;
|
|
28
|
+
if (host === "api.github.com" || host === "github.com") {
|
|
29
|
+
return { Authorization: `Bearer ${githubToken}` };
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
23
33
|
if (!(process.platform in OS_MAP)) {
|
|
24
34
|
throw new UnsupportedOS(`OS ${process.platform} is not supported`);
|
|
25
35
|
}
|
|
@@ -111,7 +121,9 @@ export class GitHubDownloader {
|
|
|
111
121
|
let response;
|
|
112
122
|
while (attempts < retries) {
|
|
113
123
|
try {
|
|
114
|
-
response = await fetch(this.apiUrl
|
|
124
|
+
response = await fetch(this.apiUrl, {
|
|
125
|
+
headers: getAuthorizationHeaders(this.apiUrl),
|
|
126
|
+
});
|
|
115
127
|
if (response.ok)
|
|
116
128
|
break;
|
|
117
129
|
}
|
|
@@ -180,7 +192,9 @@ export class CamoufoxFetcher extends GitHubDownloader {
|
|
|
180
192
|
this._url = releaseData[1];
|
|
181
193
|
}
|
|
182
194
|
static async downloadFile(url) {
|
|
183
|
-
const response = await fetch(url
|
|
195
|
+
const response = await fetch(url, {
|
|
196
|
+
headers: getAuthorizationHeaders(url),
|
|
197
|
+
});
|
|
184
198
|
return Buffer.from(await response.arrayBuffer());
|
|
185
199
|
}
|
|
186
200
|
async extractZip(zipFile) {
|
|
@@ -298,7 +312,7 @@ export async function webdl(url, desc = "", bar = true, buffer = null, { retries
|
|
|
298
312
|
let response;
|
|
299
313
|
while (attempts < retries) {
|
|
300
314
|
try {
|
|
301
|
-
response = await fetch(url);
|
|
315
|
+
response = await fetch(url, { headers: getAuthorizationHeaders(url) });
|
|
302
316
|
if (response.ok)
|
|
303
317
|
break;
|
|
304
318
|
}
|
package/dist/webgl/sample.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { OS_ARCH_MATRIX } from "../pkgman.js";
|
|
4
|
-
// Cached Database constructor - loaded lazily on first use
|
|
5
4
|
let DatabaseConstructor = null;
|
|
6
|
-
/**
|
|
7
|
-
* Opens a SQLite database using the appropriate driver for the runtime.
|
|
8
|
-
* Uses bun:sqlite in Bun, better-sqlite3 in Node.js.
|
|
9
|
-
* The Database constructor is cached after first load.
|
|
10
|
-
*/
|
|
11
5
|
async function openDatabase(pathName) {
|
|
12
6
|
if (!DatabaseConstructor) {
|
|
13
7
|
if (typeof Bun !== "undefined") {
|
|
@@ -16,11 +10,16 @@ async function openDatabase(pathName) {
|
|
|
16
10
|
DatabaseConstructor = BunDatabase;
|
|
17
11
|
}
|
|
18
12
|
else {
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
try {
|
|
14
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
15
|
+
DatabaseConstructor = DatabaseSync;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
const { default: NodeDatabase } = await import("better-sqlite3");
|
|
19
|
+
DatabaseConstructor = NodeDatabase;
|
|
20
|
+
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
// DatabaseConstructor is guaranteed to be set at this point
|
|
24
23
|
return new DatabaseConstructor(pathName);
|
|
25
24
|
}
|
|
26
25
|
// Get database path relative to this file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camoufox-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"license": "MPL-2.0",
|
|
30
30
|
"description": "Experimental JS port of Camoufox for Python.",
|
|
31
|
-
"packageManager": "yarn@4.
|
|
31
|
+
"packageManager": "yarn@4.13.0",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"adm-zip": "^0.5.16",
|
|
34
34
|
"better-sqlite3": "^12.2.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"commander": "^14.0.0",
|
|
37
37
|
"fingerprint-generator": "^2.1.66",
|
|
38
38
|
"glob": "^13.0.0",
|
|
39
|
-
"impit": "^0.
|
|
39
|
+
"impit": "^0.13.0",
|
|
40
40
|
"language-tags": "^2.0.1",
|
|
41
41
|
"maxmind": "^5.0.0",
|
|
42
42
|
"pretty-bytes": "^7.1.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"xml2js": "^0.6.2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@biomejs/biome": "2.4.
|
|
47
|
+
"@biomejs/biome": "2.4.10",
|
|
48
48
|
"@types/adm-zip": "^0.5.7",
|
|
49
49
|
"@types/better-sqlite3": "^7.6.13",
|
|
50
50
|
"@types/cli-progress": "^3.11.6",
|