gologin 2.1.14 → 2.1.15

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,17 @@
1
+ import { exitAll, GologinApi } from '../src/gologin-api.js';
2
+
3
+ const token = process.env.GOLOGIN_API_TOKEN; // get token https://app.gologin.com/personalArea/TokenApi
4
+ const gologin = GologinApi({ token });
5
+
6
+ async function main() {
7
+ const { browser } = await gologin.launch({ cloud: true });
8
+ const page = await browser.newPage();
9
+ await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
10
+ const status = await page.$eval('.trustworthy:not(.hide)', (elt) =>
11
+ elt?.innerText?.trim(),
12
+ );
13
+
14
+ return status; // Expecting 'Trustworthy'
15
+ }
16
+
17
+ main().catch(console.error).then(console.info).finally(exitAll);
@@ -7,7 +7,7 @@ async function main() {
7
7
  const { browser } = await gologin.launch();
8
8
  const page = await browser.newPage();
9
9
  await page.goto('https://iphey.com/', { waitUntil: 'networkidle2' });
10
- const status = await page.$eval('.trustworthy-status:not(.hide)', (elt) =>
10
+ const status = await page.$eval('.trustworthy:not(.hide)', (elt) =>
11
11
  elt?.innerText?.trim(),
12
12
  );
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin",
3
- "version": "2.1.14",
3
+ "version": "2.1.15",
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",
@@ -61,15 +61,20 @@ export function GologinApi({ token }) {
61
61
  };
62
62
 
63
63
  const launchCloudProfile = async (params) => {
64
- const profileParam = params.profileId
65
- ? `&profile=${params.profileId}`
66
- : '';
64
+ const legacyGologin = createLegacyGologin({
65
+ ...params,
66
+ token,
67
+ });
68
+
69
+ if (!params.profileId) {
70
+ const { id } = await legacyGologin.quickCreateProfile();
71
+ await legacyGologin.setProfileId(id);
72
+ params.profileId = id;
73
+ }
67
74
 
68
- const geolocationParam = params.geolocation
69
- ? `&geolocation=${params.geolocation}`
70
- : '';
75
+ legacyGls.push(legacyGologin);
71
76
 
72
- const browserWSEndpoint = `https://cloud.gologin.com/connect?token=${token}${profileParam}${geolocationParam}`;
77
+ const browserWSEndpoint = `https://cloudbrowser.gologin.com/connect?token=${token}&profile=${params.profileId}`;
73
78
  const browser = await puppeteer.connect({
74
79
  browserWSEndpoint,
75
80
  ignoreHTTPSErrors: true,
@@ -94,7 +99,9 @@ export function GologinApi({ token }) {
94
99
  Promise.allSettled(
95
100
  legacyGls.map((gl) => gl.stopLocal({ posting: false })),
96
101
  );
97
- process.exit(status);
102
+ Promise.allSettled(
103
+ legacyGls.map((gl) => gl.stopRemote({ posting: true })),
104
+ );
98
105
  },
99
106
 
100
107
  delay,