gologin 2.1.21 โ†’ 2.1.23

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.
@@ -0,0 +1,55 @@
1
+ import { get as _get } from 'https';
2
+ import requests from 'requestretry';
3
+
4
+ const TIMEZONE_URL = 'https://geo.myip.link';
5
+
6
+ const attemptRequest = async (requestUrl, options) => {
7
+ const { body } = await requests(requestUrl, options);
8
+ if (body.statusCode >= 400) {
9
+ const error = new Error(body);
10
+ error.statusCode = body.statusCode;
11
+ throw error;
12
+ }
13
+
14
+ return body;
15
+ };
16
+
17
+ export const makeRequest = async (url, options, internalOptions) => {
18
+ options.headers = {
19
+ ...options.headers,
20
+ 'User-Agent': 'gologin-nodejs-sdk',
21
+ };
22
+
23
+ if (internalOptions?.token) {
24
+ options.headers = {
25
+ ...options.headers,
26
+ Authorization: `Bearer ${internalOptions.token}`,
27
+ };
28
+ }
29
+
30
+ try {
31
+ return await attemptRequest(url, options);
32
+ } catch (error) {
33
+ if (internalOptions?.fallbackUrl && !error.statusCode) {
34
+ return attemptRequest(internalOptions.fallbackUrl, options);
35
+ }
36
+
37
+ throw error;
38
+ }
39
+ };
40
+
41
+ export const checkSocksProxy = async (agent) => new Promise((resolve, reject) => {
42
+ _get(TIMEZONE_URL, { agent, timeout: 10000 }, (res) => {
43
+ let resultResponse = '';
44
+ res.on('data', (data) => {
45
+ resultResponse += data;
46
+ });
47
+
48
+ res.on('end', () => {
49
+ resolve({
50
+ ...res,
51
+ body: JSON.parse(resultResponse),
52
+ });
53
+ });
54
+ }).on('error', (err) => reject(err));
55
+ });
@@ -0,0 +1,73 @@
1
+ import { GologinApi } from '../../src/gologin-api.js';
2
+
3
+ const token = process.env.GL_API_TOKEN;
4
+ const profileId = process.env.GOLOGIN_PROFILE_ID;
5
+
6
+ if (!token) {
7
+ console.error('GL_API_TOKEN environment variable is required');
8
+ process.exit(1);
9
+ }
10
+
11
+ const gologin = GologinApi({ token });
12
+
13
+ async function runTest(testName, testFunction) {
14
+ console.log(`\n๐Ÿงช Running test: ${testName}`);
15
+ const startTime = Date.now();
16
+
17
+ try {
18
+ const result = await testFunction();
19
+ const duration = Date.now() - startTime;
20
+ console.log(`โœ… ${testName} passed (${duration}ms)`);
21
+
22
+ return { name: testName, status: 'passed', duration, result };
23
+ } catch (error) {
24
+ const duration = Date.now() - startTime;
25
+ console.error(`โŒ ${testName} failed (${duration}ms):`, error.message);
26
+
27
+ return { name: testName, status: 'failed', duration, error: error.message };
28
+ }
29
+ }
30
+
31
+ async function testIpCheck() {
32
+ const { browser } = await gologin.launch({
33
+ profileId,
34
+ extra_params: ['--headless', '--no-sandbox'],
35
+ });
36
+
37
+ const page = await browser.newPage();
38
+ await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
39
+
40
+ // Wait for the page to load completely
41
+ await page.waitForSelector('.trustworthy:not(.hide)', { timeout: 30000 });
42
+
43
+ const status = await page.$eval('.trustworthy:not(.hide)',
44
+ (elt) => elt?.innerText?.trim(),
45
+ );
46
+
47
+ await browser.close();
48
+
49
+ if (!status) {
50
+ throw new Error('Could not get IP check status');
51
+ }
52
+
53
+ return `IP check status: ${status}`;
54
+ }
55
+
56
+ async function main() {
57
+ console.log('๐Ÿš€ Starting E2E tests...');
58
+
59
+ const tests = [
60
+ ['IP Check Test', testIpCheck],
61
+ ];
62
+
63
+ const results = [];
64
+
65
+ for (const [name, testFn] of tests) {
66
+ const result = await runTest(name, testFn);
67
+ results.push(result);
68
+ }
69
+ }
70
+
71
+ main()
72
+ .catch(console.error)
73
+ .finally(() => gologin.exit());
@@ -81,13 +81,13 @@ export type ClientRectsModel = {
81
81
  noise: number;
82
82
  }
83
83
 
84
- export type WebGlMetadataModel {
84
+ export type WebGlMetadataModel = {
85
85
  mode: 'off' | 'mask';
86
86
  vendor: string;
87
87
  renderer: string;
88
88
  }
89
89
 
90
- export type BrowserProxyCreateValidation {
90
+ export type BrowserProxyCreateValidation = {
91
91
  mode: 'http' | 'https' | 'socks4' | 'socks5' | 'geolocation' | 'none' | 'tor' | 'gologin';
92
92
  host: string;
93
93
  port: number;
@@ -97,7 +97,6 @@ export type BrowserProxyCreateValidation {
97
97
  autoProxyRegion?: string;
98
98
  torProxyRegion?: string;
99
99
  }
100
-
101
100
  export declare class CreateCustomBrowserValidation {
102
101
  name?: string;
103
102
  notes?: string;
@@ -124,4 +123,4 @@ export declare class CreateCustomBrowserValidation {
124
123
  chromeExtensions?: string[];
125
124
  userChromeExtensions?: string[];
126
125
  folders?: string[];
127
- }
126
+ }
Binary file