gologin 2.1.19 → 2.1.21

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/.eslintrc.json CHANGED
@@ -102,7 +102,7 @@
102
102
  ],
103
103
  "max-lines": [
104
104
  "warn",
105
- 1500
105
+ 2000
106
106
  ],
107
107
  "no-else-return": [
108
108
  "warn",
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ Combined changelog for GoLogin node.js SDK
4
+
5
+ ## [2.1.21] 2025-04-23
6
+
7
+
8
+ ### Miscellaneous Chores
9
+
10
+ * Deleted old exmaples and added new one that up to date
11
+ * Added changelog to track changes
package/DEVREADME.md ADDED
File without changes
package/README.md CHANGED
@@ -1,103 +1,179 @@
1
- # class GoLogin - class for working with <a href="https://gologin.com" target="_blank">gologin.com</a> API
2
- # Official Package
1
+ # GoLogin Node.js SDK
2
+ This package provides functionality to run and stop GoLogin profiles with node.js and then connect the profiles to automation tools like Selenium, Puppetteer, Playwright etc.
3
3
 
4
- ## Getting Started
5
-
6
- GoLogin supports Linux, MacOS and Windows platforms.
4
+ # How does it work?
5
+ 1. You give SDK your dev token and profile id that you want to run
6
+ 2. SDK takes care of downloading, preparing your profile and starts the browser
7
+ 3. SDK gives you websocket url for automation tools
8
+ 4. You take this websocker url and connect it to the automation tool on your choice: Puppetteer, Selenium, Playwright etc
9
+ 5. Automation tool connects to browser and you can manage it through code
7
10
 
8
- ### Installation
9
-
10
- `npm i gologin`
11
+ ## Getting Started
11
12
 
12
- for running example.js install puppeteer-core
13
+ Where is token? API token is <a href="https://app.gologin.com/#/personalArea/TokenApi" target="_blank">here</a>.
13
14
 
14
- `npm i puppeteer-core`
15
+ ![Token API in Settings](https://user-images.githubusercontent.com/12957968/146891933-c3b60b4d-c850-47a5-8adf-bc8c37372664.gif)
15
16
 
16
- ### Usage
17
17
 
18
- Where is token? API token is <a href="https://app.gologin.com/#/personalArea/TokenApi" target="_blank">here</a>.
19
- To have an access to the page below you need <a href="https://app.gologin.com/#/createUser" target="_blank">register</a> GoLogin account.
18
+ ### Installation
20
19
 
21
- ![Token API in Settings](https://user-images.githubusercontent.com/12957968/146891933-c3b60b4d-c850-47a5-8adf-bc8c37372664.gif)
20
+ `npm i gologin`
22
21
 
23
22
  ### Example
24
23
 
25
24
  ```js
26
- import puppeteer from 'puppeteer-core';
25
+ import { GologinApi } from './src/gologin-api.js';
27
26
 
28
- import GoLogin from '../src/gologin.js';
27
+ const GL = GologinApi({
28
+ token: 'your token',
29
+ });
29
30
 
30
- const { connect } = puppeteer;
31
+ const profile = await GL.createProfileRandomFingerprint('some name');
32
+ const profileId = profile.id;
31
33
 
32
- (async () => {
33
- const GL = new GoLogin({
34
- token: 'yU0token',
35
- profile_id: 'yU0Pr0f1leiD',
36
- });
37
-
38
- const { status, wsUrl } = await GL.start().catch((e) => {
39
- console.trace(e);
34
+ await GL.addGologinProxyToProfile(profileId, 'us');
35
+ const browser = await GL.launch({ profileId });
36
+ const page = await browser.newPage();
37
+ await page.goto('https://linkedin.com');
38
+ await new Promise((resolve) => setTimeout(resolve, 5000));
39
+ await browser.close();
40
+ await GL.stop();
41
+ ```
40
42
 
41
- return { status: 'failure' };
42
- });
43
+ ###
44
+ ### Methods
45
+ #### constructor
43
46
 
44
- if (status !== 'success') {
45
- console.log('Invalid status');
47
+ Required options:
48
+ - `token` <[string]> **Required** - your API <a href="https://gologin.com/#/personalArea/TokenApi" target="_blank">token</a>
46
49
 
47
- return;
48
- }
50
+ Optional options:
51
+ - `profile_id` <[string]> - profile ID (NOT PROFILE NAME) will be generated if not specified
52
+ - `executablePath` <[string]> path to executable Orbita file. Orbita will be downloaded automatically if not specified
53
+ - `extra_params` arrayof <[string]> additional flags for browser start. For example: '--headles', '--load-extentions=path/to/extension'
54
+ - `uploadCookiesToServer` <[boolean]> upload cookies to server after profile stopping (default false). It allows you to export cookies from api later.
55
+ - `writeCookesFromServer` <[boolean]> if you have predefined cookies and you want browser to import it (default true).
56
+ - `tmpdir` <[string]> absolute path to the directtory where you want to store user-data-dir. Default path in tmp folder will be picked if no specified
57
+ - `vncPort` <[integer]> port of VNC server if you using it
49
58
 
50
- const browser = await connect({
51
- browserWSEndpoint: wsUrl.toString(),
52
- ignoreHTTPSErrors: true,
53
- });
59
+ ```js
60
+ const GL = new GoLogin({
61
+ token: 'your token',
62
+ profile_id: 'profile id',
63
+ extra_params: ["--headless", "--load-extentions=path/to/extension"]
64
+ });
65
+ ```
54
66
 
55
- const page = await browser.newPage();
56
- await page.goto('https://myip.link/mini');
57
- console.log(await page.content());
58
- await browser.close();
59
- await GL.stop();
60
- })();
67
+ #### createProfileRandomFingerprint - you pass os ('lin', 'win', 'mac') and profile name and we give you brand new shiny profile
68
+ ```js
69
+ const GL = new GoLogin({
70
+ token: 'your token',
71
+ profile_id: 'profile id',
72
+ extra_params: ["--headless", "--load-extentions=path/to/extension"]
73
+ });
74
+ const profile = await gl.createProfileRandomFingerprint("some name")
75
+ const profileId = profile.id
61
76
  ```
62
77
 
63
- ### Running example:
64
78
 
65
- `DEBUG=gologin* node example.js`
79
+ #### createProfileWithCustomParams - This method creates a profile and you can pass any particular params to it. Full list of params you can find here - https://api.gologin.com/docs
80
+ ```js
81
+ const GL = GoLogin({
82
+ "token": "your token",
83
+ })
84
+ const profile = await gl.createProfileWithCustomParams({
85
+ "os": "lin",
86
+ "name": "some name",
87
+ "navigator": {
88
+ "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
89
+ "resolution": "1920x1080",
90
+ "language": "en-US",
91
+ "platform": "Linux x86_64",
92
+ "hardwareConcurrency": 8,
93
+ "deviceMemory": 8,
94
+ "maxTouchPoints": 0
95
+ }
96
+ })
97
+ const profileId = profile.id
98
+ ```
66
99
 
67
- ###
68
- ### Methods
69
- #### constructor
100
+ #### updateUserAgentToLatestBrowser - user agent is one of the most important thing in your fingerprint. It decides which browser version to run. This method help you to keep useragent up to date.
101
+ ```js
102
+ const GL = GoLogin({
103
+ "token": "your token",
104
+ })
105
+ await GL.updateUserAgentToLatestBrowser(["profineId1", "profileId2"], "workspceId(optional)")
106
+ ```
70
107
 
71
- - `options` <[Object]> Options for profile
72
- - `autoUpdateBrowser` <[boolean]> do not ask whether download new browser version (default false)
73
- - `token` <[string]> your API <a href="https://gologin.com/#/personalArea/TokenApi" target="_blank">token</a>
74
- - `profile_id` <[string]> profile ID
75
- - `executablePath` <[string]> path to executable Orbita file. Orbita will be downloaded automatically if not specified.
76
- - `remote_debugging_port` <[int]> port for remote debugging
77
- - `vncPort` <[integer]> port of VNC server if you using it
78
- - `tmpdir` <[string]> path to temporary directore for saving profiles
79
- - `extra_params` arrayof <[string]> extra params for browser orbita (ex. extentions etc.)
80
- - `uploadCookiesToServer` <[boolean]> upload cookies to server after profile stopping (default false)
81
- - `writeCookesFromServer` <[boolean]> download cookies from server and write to profile cookies file (default true)
82
- - `skipOrbitaHashChecking` <[boolean]> skip hash checking for Orbita after downloading process (default false)
108
+ #### addGologinProxyToProfile - Gologin provides high quality proxies with free traffic for paid users. Here you can add gologin proxy to profile, just pass country code
109
+ ```js
110
+ const GL = GoLogin({
111
+ "token": "your token",
112
+ })
113
+ await GL.addGologinProxyToProfile("profileId", "us")
114
+ ```
83
115
 
116
+ #### addCookiesToProfile - You can pass cookies to the profile and browser will import it before starting
84
117
  ```js
85
- import GoLogin from '../src/gologin.js';
86
- const GL = new GoLogin({
87
- token: 'yU0token',
88
- profile_id: 'yU0Pr0f1leiD',
89
- });
118
+ const GL = GoLogin({
119
+ "token": "your token",
120
+ })
121
+
122
+ await GL.addCookiesToProfile("profileId", [
123
+ {
124
+ "name": "session_id",
125
+ "value": "abc123",
126
+ "domain": "example.com",
127
+ "path": "/",
128
+ "expirationDate": 1719161018.307793,
129
+ "httpOnly": True,
130
+ "secure": True
131
+ },
132
+ {
133
+ "name": "user_preferences",
134
+ "value": "dark_mode",
135
+ "domain": "example.com",
136
+ "path": "/settings",
137
+ "sameSite": "lax"
138
+ }
139
+ ])
140
+ ```
141
+
142
+ #### refreshProfilesFingerprint - Replaces your profile fingerprint with a new one
143
+ ```js
144
+ const GL = GoLogin({
145
+ "token": "your token",
146
+ })
147
+
148
+ await GL.refreshProfilesFingerprint(["profileId1", "profileId2"])
90
149
  ```
91
150
 
92
- #### start()
151
+ #### changeProfileProxy - allows you to set a proxy to a profile
152
+ ```js
153
+ const GL = GoLogin({
154
+ "token": "your token",
155
+ })
156
+ await GL.changeProfileProxy("profileId", { "mode": "http", "host": "somehost.com", "port": 109, "username": "someusername", "password": "somepassword"})
157
+ ```
93
158
 
94
- - returns: <[object]> { status, wsUrl }
159
+ #### launch() - starts browser with profile id, returning WebSocket url for puppeteer
160
+ ```js
161
+ const GL = GoLogin({
162
+ "token": "your token",
163
+ })
164
+ await GL.launch({ profileId: 'some profileId' })
165
+ ```
95
166
 
96
- start browser with profile id, returning WebSocket url for puppeteer
97
167
 
98
- #### stop()
168
+ #### exit() stops browser and uploads it to the storage
169
+ ```js
170
+ const GL = GoLogin({
171
+ "token": "your token",
172
+ })
173
+ await GL.launch({ profileId: 'some profileId' })
174
+ await GL.exit()
175
+ ```
99
176
 
100
- stop browser with profile id
101
177
 
102
178
  ### DEBUG
103
179
 
@@ -0,0 +1,30 @@
1
+ // Gologin provides a cloud browser that can be used to run puppeteer aytomation.
2
+ // It will handle the browser start and close management - you just need to control the browser with pupputter
3
+ import { GologinApi } from 'gologin';
4
+
5
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
6
+ const gologin = GologinApi({
7
+ token,
8
+ });
9
+
10
+ async function main() {
11
+ const { browser } = await gologin.launch({
12
+ cloud: true,
13
+ // pass profileId parameter if you want to run particular profile
14
+ // profileId: 'your profileId here',
15
+ });
16
+
17
+ const page = await browser.newPage();
18
+
19
+ await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
20
+ const status = await page.$eval('.trustworthy:not(.hide)',
21
+ (elt) => elt?.innerText?.trim(),
22
+ );
23
+
24
+ console.log('status', status);
25
+
26
+ return status;
27
+ }
28
+
29
+ main().catch(console.error)
30
+ .finally(gologin.exit);
@@ -0,0 +1,30 @@
1
+ // SDK will prepare the browser and will start it on your machine then you can control it with puppeteer
2
+ import { GologinApi } from 'gologin';
3
+
4
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
5
+ const gologin = GologinApi({
6
+ token,
7
+ });
8
+
9
+ async function main() {
10
+ const { browser } = await gologin.launch({
11
+ extra_params: ['--headless'],
12
+ // pass profileId parameter if you want to run particular profile
13
+ // profileId: 'your profileId here',
14
+ });
15
+
16
+ const page = await browser.newPage();
17
+
18
+ await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
19
+ const status = await page.$eval('.trustworthy:not(.hide)',
20
+ (elt) => elt?.innerText?.trim(),
21
+ );
22
+
23
+ await new Promise((resolve) => setTimeout(resolve, 10000));
24
+ console.log('status', status);
25
+
26
+ return status;
27
+ }
28
+
29
+ main().catch(console.error)
30
+ .finally(gologin.exit);
@@ -0,0 +1,29 @@
1
+ // SDK will prepare the browser and will start it on your machine then you can control it with puppeteer
2
+ import { GologinApi } from 'gologin';
3
+
4
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
5
+ const gologin = GologinApi({
6
+ token,
7
+ });
8
+
9
+ async function main() {
10
+ const { browser } = await gologin.launch({
11
+ // pass profileId parameter if you want to run particular profile
12
+ // profileId: 'your profileId here',
13
+ });
14
+
15
+ const page = await browser.newPage();
16
+
17
+ await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
18
+ const status = await page.$eval('.trustworthy:not(.hide)',
19
+ (elt) => elt?.innerText?.trim(),
20
+ );
21
+
22
+ await new Promise((resolve) => setTimeout(resolve, 10000));
23
+ console.log('status', status);
24
+
25
+ return status;
26
+ }
27
+
28
+ main().catch(console.error)
29
+ .finally(gologin.exit);
@@ -0,0 +1,31 @@
1
+ // You need to create profile add proxy, use it with puppetter and then delete it
2
+ import { GologinApi } from '../../src/gologin-api.js';
3
+
4
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
5
+ const gologin = GologinApi({
6
+ token,
7
+ });
8
+
9
+ async function main() {
10
+ const profile = await gologin.createProfileRandomFingerprint();
11
+ const profileId = profile.id;
12
+ await gologin.addGologinProxyToProfile(profileId, 'US');
13
+
14
+ const { browser } = await gologin.launch({ profileId });
15
+ const page = await browser.newPage();
16
+
17
+ await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
18
+ const status = await page.$eval('.trustworthy:not(.hide)',
19
+ (elt) => elt?.innerText?.trim(),
20
+ );
21
+
22
+ await new Promise((resolve) => setTimeout(resolve, 10000));
23
+ console.log('status', status);
24
+
25
+ await gologin.deleteProfile(profileId);
26
+
27
+ return status;
28
+ }
29
+
30
+ main().catch(console.error)
31
+ .finally(gologin.exit);
package/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { type Browser } from 'puppeteer-core/lib/Browser';
2
2
 
3
+ import { CreateCustomBrowserValidation, BrowserProxyCreateValidation } from './types/profile-params';
4
+
3
5
  export const OPERATING_SYSTEMS = {
4
6
  win: 'win',
5
7
  lin: 'lin',
@@ -45,12 +47,29 @@ type LaunchParams =
45
47
  os: OsType;
46
48
  };
47
49
 
48
- type LaunchFn = (params?: LaunchParams) => Promise<{ browser: Browser }>;
50
+ type Cookie = {
51
+ name: string;
52
+ value: string;
53
+ domain: string;
54
+ path: string;
55
+ expirationDate?: number;
56
+ creationDate?: number;
57
+ hostOnly?: boolean;
58
+ httpOnly?: boolean;
59
+ sameSite?: 'no_restriction' | 'lax' | 'strict';
60
+ secure?: boolean;
61
+ session?: boolean;
62
+ url?: string;
63
+ };
49
64
 
50
65
  type GologinApiType = {
51
- launch: LaunchFn;
66
+ launch: (params?: LaunchParams) => Promise<{ browser: Browser }>;
52
67
  exit: (status = 0) => Promise<void>;
53
- delay: (ms: number) => Promise<void>;
68
+ createCustom: (params: CreateCustomBrowserValidation) => Promise<string>;
69
+ updateProfileFingerprint: (profileId: string[]) => Promise<void>;
70
+ updateUserAgentToLatestBrowser: (profileIds: string[], workspaceId?: string) => Promise<void>;
71
+ updateProfileProxy: (profileId: string, proxyData: BrowserProxyCreateValidation) => Promise<void>;
72
+ addCookiesToProfile: (profileId: string, cookies: Cookie[]) => Promise<void>;
54
73
  };
55
74
 
56
75
  type GologinApiParams = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "2.1.19",
3
+ "version": "2.1.21",
4
4
  "description": "A high-level API to control Orbita browser over GoLogin API",
5
5
  "types": "./index.d.ts",
6
6
  "main": "./src/gologin.js",
@@ -46,4 +46,4 @@
46
46
  "format": "npx prettier --single-quote src/* --write",
47
47
  "iphey": "GOLOGIN_PROFILE_ID= GOLOGIN_API_TOKEN= node examples/example-iphey "
48
48
  }
49
- }
49
+ }