gologin 2.0.14 → 2.0.15
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/package.json
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { open } from 'sqlite';
|
|
2
2
|
import sqlite3 from 'sqlite3';
|
|
3
|
+
import { promises as fsPromises } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
const { access } = fsPromises;
|
|
3
7
|
const { Database, OPEN_READONLY } = sqlite3;
|
|
4
8
|
|
|
5
9
|
const MAX_SQLITE_VARIABLES = 76;
|
|
@@ -171,3 +175,15 @@ export const chunk = (arr, chunkSize = 1, cache = []) => {
|
|
|
171
175
|
|
|
172
176
|
return cache;
|
|
173
177
|
}
|
|
178
|
+
|
|
179
|
+
export const getCookiesFilePath = async (profileId, tmpdir) => {
|
|
180
|
+
const baseCookiesFilePath = join(tmpdir, `gologin_profile_${profileId}`, 'Default', 'Cookies');
|
|
181
|
+
const bypassCookiesFilePath = join(tmpdir, `gologin_profile_${profileId}`, 'Default', 'Network', 'Cookies');
|
|
182
|
+
|
|
183
|
+
return access(baseCookiesFilePath)
|
|
184
|
+
.then(() => baseCookiesFilePath)
|
|
185
|
+
.catch(() => access(bypassCookiesFilePath)
|
|
186
|
+
.then(() => bypassCookiesFilePath)
|
|
187
|
+
.catch(() => baseCookiesFilePath)
|
|
188
|
+
);
|
|
189
|
+
}
|
package/src/gologin.js
CHANGED
|
@@ -17,7 +17,12 @@ import BrowserChecker from './browser/browser-checker.js';
|
|
|
17
17
|
import {
|
|
18
18
|
composeFonts, downloadCookies, setExtPathsAndRemoveDeleted, setOriginalExtPaths, uploadCookies,
|
|
19
19
|
} from './browser/browser-user-data-manager.js';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
getChunckedInsertValues,
|
|
22
|
+
getDB,
|
|
23
|
+
loadCookiesFromFile,
|
|
24
|
+
getCookiesFilePath,
|
|
25
|
+
} from './cookies/cookies-manager.js';
|
|
21
26
|
import ExtensionsManager from './extensions/extensions-manager.js';
|
|
22
27
|
import { archiveProfile } from './profile/profile-archiver.js';
|
|
23
28
|
import { checkAutoLang } from './utils/browser.js';
|
|
@@ -57,7 +62,7 @@ export class GoLogin {
|
|
|
57
62
|
this.autoUpdateBrowser = !!options.autoUpdateBrowser;
|
|
58
63
|
this.browserChecker = new BrowserChecker(options.skipOrbitaHashChecking);
|
|
59
64
|
this.uploadCookiesToServer = options.uploadCookiesToServer || false;
|
|
60
|
-
this.
|
|
65
|
+
this.writeCookiesFromServer = options.writeCookiesFromServer;
|
|
61
66
|
this.remote_debugging_port = options.remote_debugging_port || 0;
|
|
62
67
|
this.timezone = options.timezone;
|
|
63
68
|
this.extensionPathsToInstall = [];
|
|
@@ -71,7 +76,6 @@ export class GoLogin {
|
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
this.cookiesFilePath = join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Network', 'Cookies');
|
|
75
79
|
this.profile_zip_path = join(this.tmpdir, `gologin_${this.profile_id}.zip`);
|
|
76
80
|
this.bookmarksFilePath = join(this.tmpdir, `gologin_profile_${this.profile_id}`, 'Default', 'Bookmarks');
|
|
77
81
|
debug('INIT GOLOGIN', this.profile_id);
|
|
@@ -83,7 +87,7 @@ export class GoLogin {
|
|
|
83
87
|
|
|
84
88
|
async setProfileId(profile_id) {
|
|
85
89
|
this.profile_id = profile_id;
|
|
86
|
-
this.cookiesFilePath =
|
|
90
|
+
this.cookiesFilePath = await getCookiesFilePath(profile_id, this.tmpdir);
|
|
87
91
|
this.profile_zip_path = join(this.tmpdir, `gologin_${this.profile_id}.zip`);
|
|
88
92
|
}
|
|
89
93
|
|
|
@@ -582,8 +586,9 @@ export class GoLogin {
|
|
|
582
586
|
debug(`Writing profile for screenWidth ${profilePath}`, JSON.stringify(gologin));
|
|
583
587
|
gologin.screenWidth = this.resolution.width;
|
|
584
588
|
gologin.screenHeight = this.resolution.height;
|
|
585
|
-
debug('
|
|
586
|
-
|
|
589
|
+
debug('writeCookiesFromServer', this.writeCookiesFromServer);
|
|
590
|
+
this.cookiesFilePath = await getCookiesFilePath(this.profile_id, this.tmpdir);
|
|
591
|
+
if (this.writeCookiesFromServer) {
|
|
587
592
|
await this.writeCookiesToFile();
|
|
588
593
|
}
|
|
589
594
|
|