camoufox-js 0.1.2 → 0.2.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/__main__.js +5 -6
- package/dist/locale.js +5 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +8 -0
- package/package.json +3 -3
package/dist/__main__.js
CHANGED
|
@@ -5,6 +5,7 @@ import { INSTALL_DIR, CamoufoxFetcher, installedVerStr } from './pkgman.js';
|
|
|
5
5
|
import { Command } from 'commander';
|
|
6
6
|
import { Camoufox } from './sync_api.js';
|
|
7
7
|
import { existsSync, rmSync } from 'fs';
|
|
8
|
+
import { getAsBooleanFromENV } from './utils.js';
|
|
8
9
|
class CamoufoxUpdate extends CamoufoxFetcher {
|
|
9
10
|
currentVerStr;
|
|
10
11
|
constructor() {
|
|
@@ -28,13 +29,11 @@ class CamoufoxUpdate extends CamoufoxFetcher {
|
|
|
28
29
|
return updater;
|
|
29
30
|
}
|
|
30
31
|
isUpdateNeeded() {
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (this.currentVerStr !== this.verstr) {
|
|
35
|
-
return true;
|
|
32
|
+
if (getAsBooleanFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD', false)) {
|
|
33
|
+
console.log("Skipping browser download / update check due to PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD set!");
|
|
34
|
+
return false;
|
|
36
35
|
}
|
|
37
|
-
return
|
|
36
|
+
return this.currentVerStr === null || this.currentVerStr !== this.verstr;
|
|
38
37
|
}
|
|
39
38
|
async update() {
|
|
40
39
|
if (!this.isUpdateNeeded()) {
|
package/dist/locale.js
CHANGED
|
@@ -7,6 +7,7 @@ import * as fs from 'fs';
|
|
|
7
7
|
import * as path from 'path';
|
|
8
8
|
import maxmind from 'maxmind';
|
|
9
9
|
import xml2js from 'xml2js';
|
|
10
|
+
import { getAsBooleanFromENV } from './utils.js';
|
|
10
11
|
export const ALLOW_GEOIP = true;
|
|
11
12
|
class Locale {
|
|
12
13
|
language;
|
|
@@ -145,6 +146,10 @@ export function geoipAllowed() {
|
|
|
145
146
|
}
|
|
146
147
|
export async function downloadMMDB() {
|
|
147
148
|
geoipAllowed();
|
|
149
|
+
if (getAsBooleanFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD', false)) {
|
|
150
|
+
console.log("Skipping GeoIP database download due to PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD set!");
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
148
153
|
const assetUrl = await (new MaxMindDownloader(MMDB_REPO).getAsset());
|
|
149
154
|
const fileStream = fs.createWriteStream(MMDB_FILE);
|
|
150
155
|
await webdl(assetUrl, 'Downloading GeoIP database', true, fileStream);
|
package/dist/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { VirtualDisplay } from './virtdisplay.js';
|
|
|
3
3
|
import { PathLike } from 'fs';
|
|
4
4
|
import { Fingerprint, FingerprintGeneratorOptions } from 'fingerprint-generator';
|
|
5
5
|
type Screen = FingerprintGeneratorOptions['screen'];
|
|
6
|
+
export declare function getAsBooleanFromENV(name: string, defaultValue?: boolean | undefined): boolean;
|
|
6
7
|
export declare function syncAttachVD(browser: any, virtualDisplay?: VirtualDisplay | null): any;
|
|
7
8
|
export interface LaunchOptions {
|
|
8
9
|
/** Operating system to use for the fingerprint generation.
|
package/dist/utils.js
CHANGED
|
@@ -50,6 +50,14 @@ function getEnvVars(configMap, userAgentOS) {
|
|
|
50
50
|
}
|
|
51
51
|
return envVars;
|
|
52
52
|
}
|
|
53
|
+
export function getAsBooleanFromENV(name, defaultValue) {
|
|
54
|
+
const value = process.env[name];
|
|
55
|
+
if (value === 'false' || value === '0')
|
|
56
|
+
return false;
|
|
57
|
+
if (value)
|
|
58
|
+
return true;
|
|
59
|
+
return !!defaultValue;
|
|
60
|
+
}
|
|
53
61
|
function loadProperties(filePath) {
|
|
54
62
|
let propFile;
|
|
55
63
|
filePath = filePath?.toString();
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camoufox-js",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"types": "index.d.ts",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rimraf dist && tsc && npm run copy-files",
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|