gologin 1.0.23 → 1.0.24

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.
@@ -29,18 +29,18 @@ 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
- const creationDate = cookie.creationDate ? cookie.creationDate : this.unixToLDAP(todayUnix);
36
- const encryptedValue = cookie.value;
35
+ const creationDate = cookie.creationDate ? cookie.creationDate : unixToLDAP(todayUnix);
36
+ let expirationDate = cookie.session ? 0 : unixToLDAP(cookie.expirationDate);
37
+ const encryptedValue = Buffer.concat([Buffer.from('v11'), Buffer.from(encrypt(cookie.value), 'binary')]);
37
38
  const samesite = Object.keys(SAME_SITE).find((key) => SAME_SITE[key] === (cookie.sameSite || '-1'));
38
39
  const isSecure =
39
40
  cookie.name.startsWith('__Host-') || cookie.name.startsWith('__Secure-') ? 1 : Number(cookie.secure);
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: 'MyUserAgent',
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
  })();
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
- // console.log(JSON.stringify(response.body));
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "main": "./gologin.js",
6
6
  "repository": {
@@ -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)
@@ -422,9 +422,12 @@ class GoLogin(object):
422
422
  def update(self, options):
423
423
  self.profile_id = options.get('id')
424
424
  profile = self.getProfile()
425
+ #print("profile", profile)
425
426
  for k,v in options.items():
426
427
  profile[k] = v
427
- return json.loads(requests.put(API_URL + '/browser/' + self.profile_id, headers=self.headers(), json=profile).content.decode('utf-8'))
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)
428
431
 
429
432
  def waitDebuggingUrl(self, delay_s, try_count=3):
430
433
  url = 'https://' + self.profile_id + '.orbita.gologin.com/json/version'