gologin 1.0.22 → 1.0.26
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/cookies-manager.js +4 -3
- package/examples/example-create-profile.js +2 -2
- package/examples/example-local-profile.js +1 -1
- package/gologin.js +14 -5
- package/package.json +1 -1
- package/selenium/example.js +1 -1
- package/selenium/gologin-create-profile.py +30 -0
- package/selenium/gologin.py +8 -6
package/cookies-manager.js
CHANGED
|
@@ -29,10 +29,11 @@ class CookiesManager {
|
|
|
29
29
|
const chunckedCookiesArr = this.chunk(cookiesArr, MAX_SQLITE_VARIABLES);
|
|
30
30
|
|
|
31
31
|
return chunckedCookiesArr.map((cookies) => {
|
|
32
|
-
const queryPlaceholders = cookies.map(() => '(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)').join(', ');
|
|
33
|
-
const query = `insert or replace into cookies (creation_utc, host_key, name, value, path, expires_utc, is_secure, is_httponly, last_access_utc, is_persistent, encrypted_value, samesite, has_expires) values ${queryPlaceholders}`;
|
|
32
|
+
const queryPlaceholders = cookies.map(() => '(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)').join(', ');
|
|
33
|
+
const query = `insert or replace into cookies (creation_utc, top_frame_site_key, host_key, name, value, path, expires_utc, is_secure, is_httponly, last_access_utc, is_persistent, encrypted_value, samesite, has_expires) values ${queryPlaceholders}`;
|
|
34
34
|
const queryParams = cookies.flatMap((cookie) => {
|
|
35
35
|
const creationDate = cookie.creationDate ? cookie.creationDate : this.unixToLDAP(todayUnix);
|
|
36
|
+
let expirationDate = cookie.session ? 0 : this.unixToLDAP(cookie.expirationDate);
|
|
36
37
|
const encryptedValue = cookie.value;
|
|
37
38
|
const samesite = Object.keys(SAME_SITE).find((key) => SAME_SITE[key] === (cookie.sameSite || '-1'));
|
|
38
39
|
const isSecure =
|
|
@@ -40,7 +41,6 @@ class CookiesManager {
|
|
|
40
41
|
let isPersistent = [undefined, null].includes(cookie.session)
|
|
41
42
|
? Number(expirationDate !== 0)
|
|
42
43
|
: Number(!cookie.session);
|
|
43
|
-
let expirationDate = cookie.session ? 0 : this.unixToLDAP(cookie.expirationDate);
|
|
44
44
|
|
|
45
45
|
if (/^(\.)?mail.google.com$/.test(cookie.domain) && cookie.name === 'COMPASS') {
|
|
46
46
|
expirationDate = 0;
|
|
@@ -49,6 +49,7 @@ class CookiesManager {
|
|
|
49
49
|
|
|
50
50
|
return [
|
|
51
51
|
creationDate,
|
|
52
|
+
'', // top_frame_site_key
|
|
52
53
|
cookie.domain,
|
|
53
54
|
cookie.name,
|
|
54
55
|
'', // value
|
|
@@ -15,7 +15,7 @@ const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
|
15
15
|
os: 'mac',
|
|
16
16
|
navigator: {
|
|
17
17
|
language: 'enUS',
|
|
18
|
-
userAgent: '
|
|
18
|
+
userAgent: 'random', // get random user agent for selected os
|
|
19
19
|
resolution: '1024x768',
|
|
20
20
|
platform: 'mac',
|
|
21
21
|
}
|
|
@@ -31,6 +31,6 @@ const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
|
31
31
|
const profile = await GL.getProfile(profile_id);
|
|
32
32
|
|
|
33
33
|
console.log('new profile name=', profile.name);
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
//await GL.delete(profile_id);
|
|
36
36
|
})();
|
|
@@ -15,7 +15,7 @@ const GoLogin = require('../gologin');
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
const page = await browser.newPage();
|
|
18
|
-
await page.goto('https://myip.
|
|
18
|
+
await page.goto('https://myip.link');
|
|
19
19
|
console.log(await page.content());
|
|
20
20
|
await browser.close();
|
|
21
21
|
await GL.stopLocal({posting: false});
|
package/gologin.js
CHANGED
|
@@ -879,9 +879,12 @@ class GoLogin {
|
|
|
879
879
|
mode: 'alerted',
|
|
880
880
|
},
|
|
881
881
|
};
|
|
882
|
-
|
|
882
|
+
let user_agent = options.navigator?.userAgent;
|
|
883
|
+
let orig_user_agent = json.navigator.userAgent;
|
|
883
884
|
Object.keys(options).map((e)=>{ json[e] = options[e] });
|
|
884
|
-
|
|
885
|
+
if(user_agent=='random'){
|
|
886
|
+
json.navigator.userAgent = orig_user_agent;
|
|
887
|
+
}
|
|
885
888
|
// console.log('profileOptions', json);
|
|
886
889
|
|
|
887
890
|
const response = await requests.post(`${API_URL}/browser`, {
|
|
@@ -891,7 +894,15 @@ class GoLogin {
|
|
|
891
894
|
},
|
|
892
895
|
json,
|
|
893
896
|
});
|
|
894
|
-
|
|
897
|
+
|
|
898
|
+
if(response.body.statusCode==400){
|
|
899
|
+
throw new Error(`gologin failed account creation with status code, ${data.statusCode} DATA ${JSON.stringify(response.body.message)}`);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
if(response.body.statusCode==500){
|
|
903
|
+
throw new Error(`gologin failed account creation with status code, ${data.statusCode}`);
|
|
904
|
+
}
|
|
905
|
+
debug(JSON.stringify(response.body));
|
|
895
906
|
return response.body.id;
|
|
896
907
|
}
|
|
897
908
|
|
|
@@ -1102,8 +1113,6 @@ class GoLogin {
|
|
|
1102
1113
|
|
|
1103
1114
|
if (profileResponse.body === 'ok') {
|
|
1104
1115
|
let wsUrl = await this.waitDebuggingUrl(delay_ms);
|
|
1105
|
-
// const wsUrl = `wss://${this.profile_id}.orbita.gologin.app`
|
|
1106
|
-
// const wsUrl = `wss://${this.profile_id}.orbita.gologin.com`
|
|
1107
1116
|
return { 'status': 'success', wsUrl }
|
|
1108
1117
|
}
|
|
1109
1118
|
|
package/package.json
CHANGED
package/selenium/example.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from gologin import GoLogin
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
gl = GoLogin({
|
|
5
|
+
"token": "yU0token",
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
profile_id = gl.create({
|
|
9
|
+
"name": 'profile_mac',
|
|
10
|
+
"os": 'mac',
|
|
11
|
+
"navigator": {
|
|
12
|
+
"language": 'enUS',
|
|
13
|
+
"userAgent": 'MyUserAgent',
|
|
14
|
+
"resolution": '1024x768',
|
|
15
|
+
"platform": 'mac',
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
print('profile id=', profile_id);
|
|
20
|
+
|
|
21
|
+
gl.update({
|
|
22
|
+
"id": profile_id,
|
|
23
|
+
"name": 'profile_mac2',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
profile = gl.getProfile(profile_id);
|
|
27
|
+
|
|
28
|
+
print('new profile name=', profile.get("name"));
|
|
29
|
+
|
|
30
|
+
gl.delete(profile_id)
|
package/selenium/gologin.py
CHANGED
|
@@ -170,9 +170,9 @@ class GoLogin(object):
|
|
|
170
170
|
proxy = self.proxy
|
|
171
171
|
if proxy:
|
|
172
172
|
proxies = {proxy.get('mode'): self.formatProxyUrlPassword(proxy)}
|
|
173
|
-
data = requests.get('https://time.gologin.
|
|
173
|
+
data = requests.get('https://time.gologin.com', proxies=proxies)
|
|
174
174
|
else:
|
|
175
|
-
data = requests.get('https://time.gologin.
|
|
175
|
+
data = requests.get('https://time.gologin.com')
|
|
176
176
|
return json.loads(data.content.decode('utf-8'))
|
|
177
177
|
|
|
178
178
|
|
|
@@ -305,9 +305,8 @@ class GoLogin(object):
|
|
|
305
305
|
|
|
306
306
|
def updatePreferences(self):
|
|
307
307
|
pref_file = os.path.join(self.profile_path, 'Default/Preferences')
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
pfile.close()
|
|
308
|
+
with open(pref_file, 'r', encoding="utf-8") as pfile:
|
|
309
|
+
preferences = json.load(pfile)
|
|
311
310
|
profile = self.profile
|
|
312
311
|
proxy = self.profile.get('proxy')
|
|
313
312
|
# print('proxy=', proxy)
|
|
@@ -423,9 +422,12 @@ class GoLogin(object):
|
|
|
423
422
|
def update(self, options):
|
|
424
423
|
self.profile_id = options.get('id')
|
|
425
424
|
profile = self.getProfile()
|
|
425
|
+
#print("profile", profile)
|
|
426
426
|
for k,v in options.items():
|
|
427
427
|
profile[k] = v
|
|
428
|
-
|
|
428
|
+
resp = requests.put(API_URL + '/browser/' + self.profile_id, headers=self.headers(), json=profile).content.decode('utf-8')
|
|
429
|
+
#print("update", resp)
|
|
430
|
+
#return json.loads(resp)
|
|
429
431
|
|
|
430
432
|
def waitDebuggingUrl(self, delay_s, try_count=3):
|
|
431
433
|
url = 'https://' + self.profile_id + '.orbita.gologin.com/json/version'
|