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 +1 -1
- package/CHANGELOG.md +11 -0
- package/DEVREADME.md +0 -0
- package/README.md +144 -68
- package/examples/puppeter/cloud-browser.js +30 -0
- package/examples/puppeter/headless.js +30 -0
- package/examples/puppeter/local-browser.js +29 -0
- package/examples/puppeter/one-time-use-profile.js +31 -0
- package/index.d.ts +22 -3
- package/package.json +2 -2
- package/src/gologin-api.js +220 -20
- package/src/gologin.js +56 -79
- package/src/utils/utils.js +1 -0
- package/types/profile-params.d.ts +127 -0
- package/example.js +0 -36
- package/examples/example-amazon-cloud-browser.js +0 -37
- package/examples/example-amazon-headless.js +0 -50
- package/examples/example-amazon.js +0 -47
- package/examples/example-cloud.js +0 -17
- package/examples/example-create-custom-profile.js +0 -39
- package/examples/example-create-profile.js +0 -40
- package/examples/example-custom-args.js +0 -34
- package/examples/example-fast-profile-settings.js +0 -69
- package/examples/example-gmail.js +0 -67
- package/examples/example-iphey.js +0 -17
- package/examples/example-local-profile.js +0 -26
- package/examples/example-login-walmart.js +0 -35
- package/examples/example-stopremote.js +0 -20
- package/examples/example-timezone.js +0 -44
package/src/gologin-api.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import puppeteer from 'puppeteer-core';
|
|
2
2
|
|
|
3
3
|
import GoLogin from './gologin.js';
|
|
4
|
+
import { API_URL, getOsAdvanced } from './utils/common.js';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
token: process.env.GOLOGIN_API_TOKEN,
|
|
8
|
-
profile_id: process.env.GOLOGIN_PROFILE_ID,
|
|
9
|
-
executablePath: process.env.GOLOGIN_EXECUTABLE_PATH,
|
|
10
|
-
autoUpdateBrowser: true,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
6
|
+
const trafficLimitMessage =
|
|
7
|
+
'You dont have free traffic to use the proxy. Please go to app https://app.gologin.com/ and buy some traffic if you want to use the proxy';
|
|
13
8
|
|
|
14
|
-
const
|
|
9
|
+
export const getDefaultParams = () => ({
|
|
10
|
+
token: process.env.GOLOGIN_API_TOKEN,
|
|
11
|
+
profile_id: process.env.GOLOGIN_PROFILE_ID,
|
|
12
|
+
executablePath: process.env.GOLOGIN_EXECUTABLE_PATH,
|
|
13
|
+
autoUpdateBrowser: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const createGologinProfileManager = ({ profileId, ...params }) => {
|
|
17
|
+
console.log({ params });
|
|
15
18
|
const defaults = getDefaultParams();
|
|
16
19
|
const mergedParams = {
|
|
17
20
|
...defaults,
|
|
@@ -27,9 +30,7 @@ const createLegacyGologin = ({ profileId, ...params }) => {
|
|
|
27
30
|
|
|
28
31
|
const createdApis = [];
|
|
29
32
|
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
export function GologinApi({ token }) {
|
|
33
|
+
export const GologinApi = ({ token }) => {
|
|
33
34
|
if (!token) {
|
|
34
35
|
throw new Error('GoLogin API token is missing');
|
|
35
36
|
}
|
|
@@ -38,7 +39,7 @@ export function GologinApi({ token }) {
|
|
|
38
39
|
const legacyGls = [];
|
|
39
40
|
|
|
40
41
|
const launchLocal = async (params) => {
|
|
41
|
-
const legacyGologin =
|
|
42
|
+
const legacyGologin = createGologinProfileManager({
|
|
42
43
|
...params,
|
|
43
44
|
token,
|
|
44
45
|
});
|
|
@@ -48,9 +49,9 @@ export function GologinApi({ token }) {
|
|
|
48
49
|
await legacyGologin.setProfileId(id);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
+
const startedProfile = await legacyGologin.start();
|
|
52
53
|
const browser = await puppeteer.connect({
|
|
53
|
-
browserWSEndpoint:
|
|
54
|
+
browserWSEndpoint: startedProfile.wsUrl,
|
|
54
55
|
ignoreHTTPSErrors: true,
|
|
55
56
|
});
|
|
56
57
|
|
|
@@ -61,7 +62,7 @@ export function GologinApi({ token }) {
|
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
const launchCloudProfile = async (params) => {
|
|
64
|
-
const legacyGologin =
|
|
65
|
+
const legacyGologin = createGologinProfileManager({
|
|
65
66
|
...params,
|
|
66
67
|
token,
|
|
67
68
|
});
|
|
@@ -87,6 +88,7 @@ export function GologinApi({ token }) {
|
|
|
87
88
|
|
|
88
89
|
const api = {
|
|
89
90
|
async launch(params = {}) {
|
|
91
|
+
console.log();
|
|
90
92
|
if (params.cloud) {
|
|
91
93
|
return launchCloudProfile(params);
|
|
92
94
|
}
|
|
@@ -94,7 +96,207 @@ export function GologinApi({ token }) {
|
|
|
94
96
|
return launchLocal(params);
|
|
95
97
|
},
|
|
96
98
|
|
|
97
|
-
async
|
|
99
|
+
async createProfileWithCustomParams(options) {
|
|
100
|
+
const response = await fetch(`${API_URL}/browser/custom`, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: {
|
|
103
|
+
'Authorization': `Bearer ${token}`,
|
|
104
|
+
'User-Agent': 'gologin-api',
|
|
105
|
+
},
|
|
106
|
+
body: JSON.stringify(options),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
if (response.status === 400) {
|
|
110
|
+
throw new Error(`gologin failed account creation with status code, ${response.status} DATA ${JSON.stringify(await response.json())}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (response.status === 500) {
|
|
114
|
+
throw new Error(`gologin failed account creation with status code, ${response.status}`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const profile = await response.json();
|
|
118
|
+
|
|
119
|
+
return profile.id;
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
async refreshProfilesFingerprint(profileIds) {
|
|
123
|
+
if (!profileIds) {
|
|
124
|
+
throw new Error('Profile ID is required');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const response = await fetch(`${API_URL}/browser/fingerprints`, {
|
|
128
|
+
headers: {
|
|
129
|
+
'Authorization': `Bearer ${token}`,
|
|
130
|
+
'User-Agent': 'gologin-api',
|
|
131
|
+
'Content-Type': 'application/json',
|
|
132
|
+
},
|
|
133
|
+
method: 'PATCH',
|
|
134
|
+
body: JSON.stringify({ browsersIds: profileIds }),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
return response.json();
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
async createProfileRandomFingerprint(name = '') {
|
|
141
|
+
const osInfo = await getOsAdvanced();
|
|
142
|
+
const { os, osSpec } = osInfo;
|
|
143
|
+
const resultName = name || 'api-generated';
|
|
144
|
+
|
|
145
|
+
const response = await fetch(`${API_URL}/browser/quick`, {
|
|
146
|
+
method: 'POST',
|
|
147
|
+
headers: {
|
|
148
|
+
'Authorization': `Bearer ${token}`,
|
|
149
|
+
'User-Agent': 'gologin-api',
|
|
150
|
+
'Content-Type': 'application/json',
|
|
151
|
+
},
|
|
152
|
+
body: JSON.stringify({
|
|
153
|
+
os,
|
|
154
|
+
osSpec,
|
|
155
|
+
name: resultName,
|
|
156
|
+
}),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return response.json();
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
async updateUserAgentToLatestBrowser(profileIds, workspaceId = '') {
|
|
163
|
+
let url = `${API_URL}/browser/update_ua_to_new_browser_v`;
|
|
164
|
+
if (workspaceId) {
|
|
165
|
+
url += `?currentWorkspace=${workspaceId}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const response = await fetch(url, {
|
|
169
|
+
method: 'PATCH',
|
|
170
|
+
headers: {
|
|
171
|
+
'Authorization': `Bearer ${token}`,
|
|
172
|
+
'User-Agent': 'gologin-api',
|
|
173
|
+
'Content-Type': 'application/json',
|
|
174
|
+
},
|
|
175
|
+
body: JSON.stringify({ browserIds: profileIds, updateUaToNewBrowserV: true, updateAllProfiles: false, testOrbita: false }),
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
return response.json();
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
async changeProfileProxy(profileId, proxyData) {
|
|
182
|
+
console.log(proxyData);
|
|
183
|
+
const response = await fetch(`${API_URL}/browser/${profileId}/proxy`, {
|
|
184
|
+
method: 'PATCH',
|
|
185
|
+
headers: {
|
|
186
|
+
Authorization: `Bearer ${token}`,
|
|
187
|
+
'user-agent': 'gologin-api',
|
|
188
|
+
'Content-Type': 'application/json',
|
|
189
|
+
},
|
|
190
|
+
body: JSON.stringify(proxyData),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
return response.status;
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
getAvailableType(availableTrafficData) {
|
|
197
|
+
switch (true) {
|
|
198
|
+
case availableTrafficData.mobileTrafficData.trafficUsedBytes > availableTrafficData.mobileTrafficData.trafficLimitBytes:
|
|
199
|
+
return 'mobile';
|
|
200
|
+
case availableTrafficData.residentialTrafficData.trafficUsedBytes < availableTrafficData.residentialTrafficData.trafficLimitBytes:
|
|
201
|
+
return 'resident';
|
|
202
|
+
case availableTrafficData.dataCenterTrafficData.trafficUsedBytes < availableTrafficData.dataCenterTrafficData.trafficLimitBytes:
|
|
203
|
+
return 'dataCenter';
|
|
204
|
+
default:
|
|
205
|
+
return 'none';
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
async addGologinProxyToProfile(profileId, countryCode, proxyType = '') {
|
|
210
|
+
if (!proxyType) {
|
|
211
|
+
const availableTraffic = await fetch(`${API_URL}/users-proxies/geolocation/traffic`, {
|
|
212
|
+
headers: {
|
|
213
|
+
Authorization: `Bearer ${token}`,
|
|
214
|
+
'user-agent': 'gologin-api',
|
|
215
|
+
'Content-Type': 'application/json',
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const availableTrafficData = await availableTraffic.json();
|
|
220
|
+
console.log(availableTrafficData);
|
|
221
|
+
const availableType = this.getAvailableType(availableTrafficData);
|
|
222
|
+
if (availableType === 'none') {
|
|
223
|
+
throw new Error(trafficLimitMessage);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
console.log(availableType);
|
|
227
|
+
proxyType = availableType;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let isDc = false;
|
|
231
|
+
let isMobile = false;
|
|
232
|
+
|
|
233
|
+
switch (proxyType) {
|
|
234
|
+
case 'mobile':
|
|
235
|
+
isMobile = true;
|
|
236
|
+
isDc = false;
|
|
237
|
+
break;
|
|
238
|
+
case 'resident':
|
|
239
|
+
isMobile = false;
|
|
240
|
+
isDc = false;
|
|
241
|
+
break;
|
|
242
|
+
case 'dataCenter':
|
|
243
|
+
isMobile = false;
|
|
244
|
+
isDc = true;
|
|
245
|
+
break;
|
|
246
|
+
default:
|
|
247
|
+
throw new Error('Invalid proxy type');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const proxyResponse = await fetch(`${API_URL}/users-proxies/mobile-proxy`, {
|
|
251
|
+
headers: {
|
|
252
|
+
Authorization: `Bearer ${token}`,
|
|
253
|
+
'user-agent': 'gologin-api',
|
|
254
|
+
'Content-Type': 'application/json',
|
|
255
|
+
},
|
|
256
|
+
method: 'POST',
|
|
257
|
+
body: JSON.stringify({
|
|
258
|
+
countryCode,
|
|
259
|
+
isDc,
|
|
260
|
+
isMobile,
|
|
261
|
+
profileIdToLink: profileId,
|
|
262
|
+
}),
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const proxy = await proxyResponse.json();
|
|
266
|
+
if (proxy.trafficLimitBytes < proxy.trafficUsedBytes) {
|
|
267
|
+
throw new Error(trafficLimitMessage);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return proxy;
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
async addCookiesToProfile(profileId, cookies) {
|
|
274
|
+
const response = await fetch(`${API_URL}/browser/${profileId}/cookies?fromUser=true`, {
|
|
275
|
+
method: 'POST',
|
|
276
|
+
headers: {
|
|
277
|
+
Authorization: `Bearer ${token}`,
|
|
278
|
+
'user-agent': 'gologin-api',
|
|
279
|
+
'Content-Type': 'application/json',
|
|
280
|
+
},
|
|
281
|
+
body: JSON.stringify(cookies),
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return response.status;
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
async deleteProfile(profileId) {
|
|
288
|
+
const response = await fetch(`${API_URL}/browser/${profileId}`, {
|
|
289
|
+
method: 'DELETE',
|
|
290
|
+
headers: {
|
|
291
|
+
Authorization: `Bearer ${token}`,
|
|
292
|
+
'user-agent': 'gologin-api',
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
return response.status;
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
async exit() {
|
|
98
300
|
Promise.allSettled(browsers.map((browser) => browser.close()));
|
|
99
301
|
Promise.allSettled(
|
|
100
302
|
legacyGls.map((gl) => gl.stopLocal({ posting: false })),
|
|
@@ -103,14 +305,12 @@ export function GologinApi({ token }) {
|
|
|
103
305
|
legacyGls.map((gl) => gl.stopRemote({ posting: true })),
|
|
104
306
|
);
|
|
105
307
|
},
|
|
106
|
-
|
|
107
|
-
delay,
|
|
108
308
|
};
|
|
109
309
|
|
|
110
310
|
createdApis.push(api);
|
|
111
311
|
|
|
112
312
|
return api;
|
|
113
|
-
}
|
|
313
|
+
};
|
|
114
314
|
|
|
115
315
|
export function exitAll() {
|
|
116
316
|
Promise.allSettled(createdApis.map((api) => api.exit()));
|
package/src/gologin.js
CHANGED
|
@@ -116,36 +116,6 @@ export class GoLogin {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
async getNewFingerPrint(os) {
|
|
120
|
-
debug('GETTING FINGERPRINT');
|
|
121
|
-
|
|
122
|
-
const fpResponse = await requests.get(`${API_URL}/browser/fingerprint?os=${os}`, {
|
|
123
|
-
json: true,
|
|
124
|
-
headers: {
|
|
125
|
-
'Authorization': `Bearer ${this.access_token}`,
|
|
126
|
-
'User-Agent': 'gologin-api',
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return fpResponse?.body || {};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async profiles() {
|
|
134
|
-
const profilesResponse = await requests.get(`${API_URL}/browser/v2`, {
|
|
135
|
-
headers: {
|
|
136
|
-
'Authorization': `Bearer ${this.access_token}`,
|
|
137
|
-
'User-Agent': 'gologin-api',
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
if (profilesResponse.statusCode !== 200) {
|
|
143
|
-
throw new Error('Gologin /browser response error');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return JSON.parse(profilesResponse.body);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
119
|
async getProfile(profile_id) {
|
|
150
120
|
const id = profile_id || this.profile_id;
|
|
151
121
|
debug('getProfile', this.access_token, id);
|
|
@@ -1235,48 +1205,6 @@ export class GoLogin {
|
|
|
1235
1205
|
return response.body.id;
|
|
1236
1206
|
}
|
|
1237
1207
|
|
|
1238
|
-
async createCustom(options) {
|
|
1239
|
-
debug('createCustomProfile', options);
|
|
1240
|
-
const response = await requests.post(`${API_URL}/browser/custom`, {
|
|
1241
|
-
headers: {
|
|
1242
|
-
'Authorization': `Bearer ${this.access_token}`,
|
|
1243
|
-
'User-Agent': 'gologin-api',
|
|
1244
|
-
},
|
|
1245
|
-
json: options,
|
|
1246
|
-
});
|
|
1247
|
-
|
|
1248
|
-
if (response.statusCode === 400) {
|
|
1249
|
-
throw new Error(`gologin failed account creation with status code, ${response.statusCode} DATA ${JSON.stringify(response.body.message)}`);
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
if (response.statusCode === 500) {
|
|
1253
|
-
throw new Error(`gologin failed account creation with status code, ${response.statusCode}`);
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
debug(JSON.stringify(response));
|
|
1257
|
-
|
|
1258
|
-
return response.body.id;
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
async quickCreateProfile(name = '') {
|
|
1262
|
-
const osInfo = await getOsAdvanced();
|
|
1263
|
-
const { os, osSpec } = osInfo;
|
|
1264
|
-
const resultName = name || 'api-generated';
|
|
1265
|
-
|
|
1266
|
-
return requests.post(`${API_URL}/browser/quick`, {
|
|
1267
|
-
headers: {
|
|
1268
|
-
'Authorization': `Bearer ${this.access_token}`,
|
|
1269
|
-
'User-Agent': 'gologin-api',
|
|
1270
|
-
},
|
|
1271
|
-
json: {
|
|
1272
|
-
os,
|
|
1273
|
-
osSpec,
|
|
1274
|
-
name: resultName,
|
|
1275
|
-
},
|
|
1276
|
-
})
|
|
1277
|
-
.then(res => res.body);
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
1208
|
async delete(pid) {
|
|
1281
1209
|
const profile_id = pid || this.profile_id;
|
|
1282
1210
|
await requests.delete(`${API_URL}/browser/${profile_id}`, {
|
|
@@ -1452,7 +1380,6 @@ export class GoLogin {
|
|
|
1452
1380
|
}
|
|
1453
1381
|
|
|
1454
1382
|
async start() {
|
|
1455
|
-
|
|
1456
1383
|
await this.createStartup();
|
|
1457
1384
|
// await this.createBrowserExtension();
|
|
1458
1385
|
const wsUrl = await this.spawnBrowser();
|
|
@@ -1525,22 +1452,72 @@ export class GoLogin {
|
|
|
1525
1452
|
}
|
|
1526
1453
|
}
|
|
1527
1454
|
|
|
1455
|
+
// api for users to manage their profiles
|
|
1456
|
+
async changeProfileProxy(proxyData) {
|
|
1457
|
+
return updateProfileProxy(this.profile_id, this.access_token, proxyData);
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
async changeProfileUserAgent(userAgent) {
|
|
1461
|
+
return updateProfileUserAgent(this.profile_id, this.access_token, userAgent);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
async changeProfileResolution(resolution) {
|
|
1465
|
+
return updateProfileResolution(this.profile_id, this.access_token, resolution);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1528
1468
|
getAvailableFonts() {
|
|
1529
1469
|
return fontsCollection
|
|
1530
1470
|
.filter(elem => elem.fileNames)
|
|
1531
1471
|
.map(elem => elem.name);
|
|
1532
1472
|
}
|
|
1533
1473
|
|
|
1534
|
-
async
|
|
1535
|
-
|
|
1474
|
+
async quickCreateProfile(name = '') {
|
|
1475
|
+
const osInfo = await getOsAdvanced();
|
|
1476
|
+
const { os, osSpec } = osInfo;
|
|
1477
|
+
const resultName = name || 'api-generated';
|
|
1478
|
+
|
|
1479
|
+
return requests.post(`${API_URL}/browser/quick`, {
|
|
1480
|
+
headers: {
|
|
1481
|
+
'Authorization': `Bearer ${this.access_token}`,
|
|
1482
|
+
'User-Agent': 'gologin-api',
|
|
1483
|
+
},
|
|
1484
|
+
json: {
|
|
1485
|
+
os,
|
|
1486
|
+
osSpec,
|
|
1487
|
+
name: resultName,
|
|
1488
|
+
},
|
|
1489
|
+
})
|
|
1490
|
+
.then(res => res.body);
|
|
1536
1491
|
}
|
|
1537
1492
|
|
|
1538
|
-
async
|
|
1539
|
-
|
|
1493
|
+
async profiles() {
|
|
1494
|
+
const profilesResponse = await requests.get(`${API_URL}/browser/v2`, {
|
|
1495
|
+
headers: {
|
|
1496
|
+
'Authorization': `Bearer ${this.access_token}`,
|
|
1497
|
+
'User-Agent': 'gologin-api',
|
|
1498
|
+
|
|
1499
|
+
},
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
if (profilesResponse.statusCode !== 200) {
|
|
1503
|
+
throw new Error('Gologin /browser response error');
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
return JSON.parse(profilesResponse.body);
|
|
1540
1507
|
}
|
|
1541
1508
|
|
|
1542
|
-
async
|
|
1543
|
-
|
|
1509
|
+
async getNewFingerPrint(os) {
|
|
1510
|
+
debug('GETTING FINGERPRINT');
|
|
1511
|
+
|
|
1512
|
+
const fpResponse = await requests.get(`${API_URL}/browser/fingerprint?os=${os}`, {
|
|
1513
|
+
json: true,
|
|
1514
|
+
headers: {
|
|
1515
|
+
'Authorization': `Bearer ${this.access_token}`,
|
|
1516
|
+
'User-Agent': 'gologin-api',
|
|
1517
|
+
},
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1520
|
+
return fpResponse?.body || {};
|
|
1544
1521
|
}
|
|
1545
1522
|
}
|
|
1546
1523
|
|
package/src/utils/utils.js
CHANGED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export type OS = 'lin' | 'mac' | 'win' | 'android';
|
|
2
|
+
export type T_OS_SPEC = 'M1' | 'M2' | 'M3' | 'M3' | 'win11' | '';
|
|
3
|
+
|
|
4
|
+
export type IBookmarkFoldersObj = {
|
|
5
|
+
[key: string]: {
|
|
6
|
+
name: string;
|
|
7
|
+
children: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type NavigatorModel = {
|
|
15
|
+
userAgent: string;
|
|
16
|
+
resolution: string;
|
|
17
|
+
language: string;
|
|
18
|
+
platform: string;
|
|
19
|
+
hardwareConcurrency: number;
|
|
20
|
+
deviceMemory: number;
|
|
21
|
+
maxTouchPoints?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type TimezoneModel = {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
fillBasedOnIp: boolean;
|
|
27
|
+
timezone: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type GeolocationModel = {
|
|
31
|
+
mode: 'prompt' | 'block' | 'allow';
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
customize: boolean;
|
|
34
|
+
fillBasedOnIp: boolean;
|
|
35
|
+
latitude: number;
|
|
36
|
+
longitude: number;
|
|
37
|
+
accuracy: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type AudioContextModel = {
|
|
41
|
+
enable: boolean;
|
|
42
|
+
noiseValue: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type CanvasModel = {
|
|
46
|
+
mode: 'off' | 'noise';
|
|
47
|
+
noise?: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type FontsModel = {
|
|
51
|
+
enableMasking: boolean;
|
|
52
|
+
enableDOMRect: boolean;
|
|
53
|
+
families: string[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type MediaDevicesModel = {
|
|
57
|
+
enableMasking: boolean;
|
|
58
|
+
videoInputs: number;
|
|
59
|
+
audioInputs: number;
|
|
60
|
+
audioOutputs: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type WebRTCModel = {
|
|
64
|
+
mode: 'real' | 'public';
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
customize: boolean;
|
|
67
|
+
localIpMasking: boolean;
|
|
68
|
+
fillBasedOnIp: boolean;
|
|
69
|
+
publicIp: string;
|
|
70
|
+
localIps: string[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type WebGlModel = {
|
|
74
|
+
mode: 'off' | 'noise';
|
|
75
|
+
getClientRectsNoise: number;
|
|
76
|
+
noise?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type ClientRectsModel = {
|
|
80
|
+
mode: 'off' | 'noise';
|
|
81
|
+
noise: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type WebGlMetadataModel {
|
|
85
|
+
mode: 'off' | 'mask';
|
|
86
|
+
vendor: string;
|
|
87
|
+
renderer: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type BrowserProxyCreateValidation {
|
|
91
|
+
mode: 'http' | 'https' | 'socks4' | 'socks5' | 'geolocation' | 'none' | 'tor' | 'gologin';
|
|
92
|
+
host: string;
|
|
93
|
+
port: number;
|
|
94
|
+
username?: string;
|
|
95
|
+
password?: string;
|
|
96
|
+
changeIpUrl?: string;
|
|
97
|
+
autoProxyRegion?: string;
|
|
98
|
+
torProxyRegion?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export declare class CreateCustomBrowserValidation {
|
|
102
|
+
name?: string;
|
|
103
|
+
notes?: string;
|
|
104
|
+
autoLang?: boolean;
|
|
105
|
+
lockEnabled?: boolean;
|
|
106
|
+
folderName?: string;
|
|
107
|
+
bookmarks?: IBookmarkFoldersObj;
|
|
108
|
+
os: OS;
|
|
109
|
+
osSpec?: T_OS_SPEC;
|
|
110
|
+
devicePixelRatio?: number;
|
|
111
|
+
navigator?: NavigatorModel;
|
|
112
|
+
proxy?: BrowserProxyCreateValidation;
|
|
113
|
+
dns?: string;
|
|
114
|
+
timezone?: TimezoneModel;
|
|
115
|
+
geolocation?: GeolocationModel;
|
|
116
|
+
audioContext?: AudioContextModel;
|
|
117
|
+
canvas?: CanvasModel;
|
|
118
|
+
fonts?: FontsModel;
|
|
119
|
+
mediaDevices?: MediaDevicesModel;
|
|
120
|
+
webRTC?: WebRTCModel;
|
|
121
|
+
webGL?: WebGlModel;
|
|
122
|
+
clientRects?: ClientRectsModel;
|
|
123
|
+
webGLMetadata?: WebGlMetadataModel;
|
|
124
|
+
chromeExtensions?: string[];
|
|
125
|
+
userChromeExtensions?: string[];
|
|
126
|
+
folders?: string[];
|
|
127
|
+
}
|
package/example.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import puppeteer from 'puppeteer-core';
|
|
2
|
-
|
|
3
|
-
import GoLogin from './src/gologin.js';
|
|
4
|
-
|
|
5
|
-
const token = 'yU0token';
|
|
6
|
-
const profile_id = 'yU0Pr0f1leiD';
|
|
7
|
-
|
|
8
|
-
(async () => {
|
|
9
|
-
const GL = new GoLogin({
|
|
10
|
-
token,
|
|
11
|
-
profile_id,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const { status, wsUrl } = await GL.start().catch((e) => {
|
|
15
|
-
console.trace(e);
|
|
16
|
-
|
|
17
|
-
return { status: 'failure' };
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
if (status !== 'success') {
|
|
21
|
-
console.log('Invalid status');
|
|
22
|
-
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const browser = await puppeteer.connect({
|
|
27
|
-
browserWSEndpoint: wsUrl.toString(),
|
|
28
|
-
ignoreHTTPSErrors: true,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const page = await browser.newPage();
|
|
32
|
-
await page.goto('https://myip.link/mini');
|
|
33
|
-
console.log(await page.content());
|
|
34
|
-
await browser.close();
|
|
35
|
-
await GL.stop();
|
|
36
|
-
})();
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Usage example: in the terminal enter
|
|
2
|
-
// node example-amazon-cloud-browser.js yU0token yU0Pr0f1leiD
|
|
3
|
-
|
|
4
|
-
// your token api (located in the settings, api)
|
|
5
|
-
// https://github.com/gologinapp/gologin#usage
|
|
6
|
-
|
|
7
|
-
import GoLogin from 'gologin';
|
|
8
|
-
import puppeteer from 'puppeteer-core';
|
|
9
|
-
|
|
10
|
-
const [_execPath, _filePath, GOLOGIN_API_TOKEN, GOLOGIN_PROFILE_ID] = process.argv;
|
|
11
|
-
|
|
12
|
-
(async () => {
|
|
13
|
-
const GL = new GoLogin({
|
|
14
|
-
token: GOLOGIN_API_TOKEN,
|
|
15
|
-
profile_id: GOLOGIN_PROFILE_ID,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const browser = await puppeteer.connect({
|
|
19
|
-
browserWSEndpoint: `https://cloudbrowser.gologin.com/connect?token=${GOLOGIN_API_TOKEN}&profile=${GOLOGIN_PROFILE_ID}`,
|
|
20
|
-
ignoreHTTPSErrors: true,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const page = await browser.newPage();
|
|
24
|
-
|
|
25
|
-
await page.goto('https://www.amazon.com/-/dp/B0771V1JZX');
|
|
26
|
-
const content = await page.content();
|
|
27
|
-
const matchData = content.match(/'initial': (.*)}/);
|
|
28
|
-
if (matchData === null || matchData.length === 0){
|
|
29
|
-
console.log('no images found');
|
|
30
|
-
} else {
|
|
31
|
-
const data = JSON.parse(matchData[1]);
|
|
32
|
-
const images = data.map(e => e.hiRes);
|
|
33
|
-
console.log('images=', images);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
await GL.stopRemote();
|
|
37
|
-
})();
|