gologin-commonjs 1.2.8 → 1.3.0

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.
Files changed (93) hide show
  1. package/babel.config.json +4 -3
  2. package/dist/examples/puppeter/cloud-browser.js +27 -0
  3. package/dist/examples/puppeter/headless.js +27 -0
  4. package/dist/examples/puppeter/local-browser.js +26 -0
  5. package/dist/examples/puppeter/one-time-use-profile.js +29 -0
  6. package/dist/package.json +53 -0
  7. package/dist/src/browser/browser-api.js +21 -22
  8. package/dist/src/browser/browser-checker.js +133 -132
  9. package/dist/src/browser/browser-download-manager.js +199 -0
  10. package/dist/src/browser/browser-user-data-manager.js +24 -21
  11. package/dist/src/cookies/cookies-manager.js +25 -5
  12. package/dist/src/extensions/extensions-manager.js +22 -27
  13. package/dist/src/extensions/get-extensions.js +45 -0
  14. package/dist/src/extensions/user-extensions-manager.js +9 -10
  15. package/dist/src/gologin-api.js +198 -34
  16. package/dist/src/gologin.js +642 -585
  17. package/dist/src/utils/browser.js +49 -4
  18. package/dist/src/utils/common.js +25 -5
  19. package/dist/src/utils/constants.js +1 -1
  20. package/dist/src/utils/http.js +75 -0
  21. package/dist/src/utils/sentry.js +99 -0
  22. package/dist/src/utils/utils.js +4 -2
  23. package/dist/test/e2e/run-tests.js +69 -0
  24. package/gologin/examples/puppeter/cloud-browser.js +30 -0
  25. package/gologin/examples/puppeter/headless.js +30 -0
  26. package/gologin/examples/puppeter/local-browser.js +29 -0
  27. package/gologin/examples/puppeter/one-time-use-profile.js +31 -0
  28. package/gologin/index.d.ts +68 -24
  29. package/gologin/src/browser/browser-api.js +22 -23
  30. package/gologin/src/browser/browser-checker.js +136 -141
  31. package/gologin/src/browser/browser-download-manager.js +222 -0
  32. package/gologin/src/browser/browser-user-data-manager.js +23 -20
  33. package/gologin/src/cookies/cookies-manager.js +30 -5
  34. package/gologin/src/extensions/extensions-manager.js +21 -26
  35. package/gologin/src/extensions/get-extensions.js +42 -0
  36. package/gologin/src/extensions/user-extensions-manager.js +9 -10
  37. package/gologin/src/gologin-api.js +182 -32
  38. package/gologin/src/gologin.js +704 -939
  39. package/gologin/src/utils/browser.js +66 -3
  40. package/gologin/src/utils/common.js +22 -5
  41. package/gologin/src/utils/constants.js +1 -1
  42. package/gologin/src/utils/http.js +81 -0
  43. package/gologin/src/utils/sentry.js +73 -0
  44. package/gologin/src/utils/utils.js +1 -0
  45. package/gologin/test/e2e/run-tests.js +73 -0
  46. package/gologin/types/profile-params.d.ts +126 -0
  47. package/package.json +5 -4
  48. package/tes.js +2 -2
  49. package/types/src/browser/browser-api.d.ts +3 -3
  50. package/types/src/browser/browser-checker.d.ts +21 -13
  51. package/types/src/browser/browser-download-manager.d.ts +13 -0
  52. package/types/src/browser/browser-user-data-manager.d.ts +3 -3
  53. package/types/src/cookies/cookies-manager.d.ts +2 -15
  54. package/types/src/extensions/extensions-extractor.d.ts +2 -2
  55. package/types/src/extensions/extensions-manager.d.ts +4 -4
  56. package/types/src/extensions/get-extensions.d.ts +1 -0
  57. package/types/src/extensions/user-extensions-manager.d.ts +3 -3
  58. package/types/src/gologin-api.d.ts +14 -8
  59. package/types/src/gologin.d.ts +120 -29
  60. package/types/src/utils/browser.d.ts +3 -1
  61. package/types/src/utils/common.d.ts +7 -5
  62. package/types/src/utils/constants.d.ts +1 -1
  63. package/types/src/utils/http.d.ts +2 -0
  64. package/types/src/utils/sentry.d.ts +1 -0
  65. package/types/src/utils/utils.d.ts +3 -2
  66. package/dist/examples/example-amazon-cloud-browser.js +0 -34
  67. package/dist/examples/example-amazon-headless.js +0 -56
  68. package/dist/examples/example-amazon.js +0 -53
  69. package/dist/examples/example-create-custom-profile.js +0 -42
  70. package/dist/examples/example-create-profile.js +0 -43
  71. package/dist/examples/example-custom-args.js +0 -34
  72. package/dist/examples/example-fast-profile-settings.js +0 -59
  73. package/dist/examples/example-gmail.js +0 -82
  74. package/dist/examples/example-iphey.js +0 -19
  75. package/dist/examples/example-local-profile.js +0 -28
  76. package/dist/examples/example-login-walmart.js +0 -38
  77. package/dist/examples/example-stopremote.js +0 -22
  78. package/dist/examples/example-timezone.js +0 -51
  79. package/dist/src/utils/timezone.js +0 -21
  80. package/gologin/examples/example-amazon-cloud-browser.js +0 -37
  81. package/gologin/examples/example-amazon-headless.js +0 -50
  82. package/gologin/examples/example-amazon.js +0 -47
  83. package/gologin/examples/example-create-custom-profile.js +0 -39
  84. package/gologin/examples/example-create-profile.js +0 -40
  85. package/gologin/examples/example-custom-args.js +0 -34
  86. package/gologin/examples/example-fast-profile-settings.js +0 -69
  87. package/gologin/examples/example-gmail.js +0 -67
  88. package/gologin/examples/example-iphey.js +0 -17
  89. package/gologin/examples/example-local-profile.js +0 -26
  90. package/gologin/examples/example-login-walmart.js +0 -35
  91. package/gologin/examples/example-stopremote.js +0 -20
  92. package/gologin/examples/example-timezone.js +0 -44
  93. package/gologin/src/utils/timezone.js +0 -470
package/babel.config.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "plugins": [
3
+ "@babel/plugin-syntax-import-attributes",
4
+ [
5
+ "babel-plugin-transform-import-meta"
6
+ ],
3
7
  [
4
8
  "@babel/plugin-transform-modules-commonjs",
5
9
  {
6
10
  "importInterop": "babel"
7
11
  }
8
- ],
9
- [
10
- "babel-plugin-transform-import-meta"
11
12
  ]
12
13
  ],
13
14
  "ignore": [
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _gologin = require("gologin");
4
+ // Gologin provides a cloud browser that can be used to run puppeteer aytomation.
5
+ // It will handle the browser start and close management - you just need to control the browser with pupputter
6
+
7
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
8
+ const gologin = (0, _gologin.GologinApi)({
9
+ token
10
+ });
11
+ async function main() {
12
+ const {
13
+ browser
14
+ } = await gologin.launch({
15
+ cloud: true
16
+ // pass profileId parameter if you want to run particular profile
17
+ // profileId: 'your profileId here',
18
+ });
19
+ const page = await browser.newPage();
20
+ await page.goto('https://iphey.com/', {
21
+ waitUntil: 'networkidle2'
22
+ });
23
+ const status = await page.$eval('.trustworthy:not(.hide)', elt => elt?.innerText?.trim());
24
+ console.log('status', status);
25
+ return status;
26
+ }
27
+ main().catch(console.error).finally(gologin.exit);
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _gologin = require("gologin");
4
+ // SDK will prepare the browser and will start it on your machine then you can control it with puppeteer
5
+
6
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
7
+ const gologin = (0, _gologin.GologinApi)({
8
+ token
9
+ });
10
+ async function main() {
11
+ const {
12
+ browser
13
+ } = await gologin.launch({
14
+ extra_params: ['--headless']
15
+ // pass profileId parameter if you want to run particular profile
16
+ // profileId: 'your profileId here',
17
+ });
18
+ const page = await browser.newPage();
19
+ await page.goto('https://iphey.com/', {
20
+ waitUntil: 'networkidle2'
21
+ });
22
+ const status = await page.$eval('.trustworthy:not(.hide)', elt => elt?.innerText?.trim());
23
+ await new Promise(resolve => setTimeout(resolve, 10000));
24
+ console.log('status', status);
25
+ return status;
26
+ }
27
+ main().catch(console.error).finally(gologin.exit);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _gologin = require("gologin");
4
+ // SDK will prepare the browser and will start it on your machine then you can control it with puppeteer
5
+
6
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
7
+ const gologin = (0, _gologin.GologinApi)({
8
+ token
9
+ });
10
+ async function main() {
11
+ const {
12
+ browser
13
+ } = await gologin.launch({
14
+ // pass profileId parameter if you want to run particular profile
15
+ // profileId: 'your profileId here',
16
+ });
17
+ const page = await browser.newPage();
18
+ await page.goto('https://iphey.com/', {
19
+ waitUntil: 'networkidle2'
20
+ });
21
+ const status = await page.$eval('.trustworthy:not(.hide)', elt => elt?.innerText?.trim());
22
+ await new Promise(resolve => setTimeout(resolve, 10000));
23
+ console.log('status', status);
24
+ return status;
25
+ }
26
+ main().catch(console.error).finally(gologin.exit);
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ var _gologinApi = require("../../src/gologin-api.js");
4
+ // You need to create profile add proxy, use it with puppetter and then delete it
5
+
6
+ const token = process.env.GL_API_TOKEN || 'your dev token here';
7
+ const gologin = (0, _gologinApi.GologinApi)({
8
+ token
9
+ });
10
+ async function main() {
11
+ const profile = await gologin.createProfileRandomFingerprint();
12
+ const profileId = profile.id;
13
+ await gologin.addGologinProxyToProfile(profileId, 'US');
14
+ const {
15
+ browser
16
+ } = await gologin.launch({
17
+ profileId
18
+ });
19
+ const page = await browser.newPage();
20
+ await page.goto('https://iphey.com/', {
21
+ waitUntil: 'networkidle2'
22
+ });
23
+ const status = await page.$eval('.trustworthy:not(.hide)', elt => elt?.innerText?.trim());
24
+ await new Promise(resolve => setTimeout(resolve, 10000));
25
+ console.log('status', status);
26
+ await gologin.deleteProfile(profileId);
27
+ return status;
28
+ }
29
+ main().catch(console.error).finally(gologin.exit);
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "gologin-commonjs",
3
+ "version": "1.2.9",
4
+ "description": "A Transpiled GoLogin API ESM to CommonJS",
5
+ "types": "./types/src/gologin.d.ts",
6
+ "main": "./dist/src/gologin.js",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/faridfadhlan/gologin-commonjs.git"
10
+ },
11
+ "engines": {
12
+ "node": ">=16.0.0"
13
+ },
14
+ "author": "Muhammad Farid Fadhlan",
15
+ "license": "GPL-3.0",
16
+ "dependencies": {
17
+ "adm-zip": "^0.5.1",
18
+ "archiver": "^3.1.1",
19
+ "axios": "^1.11.0",
20
+ "child_process": "^1.0.2",
21
+ "decompress": "^4.2.1",
22
+ "decompress-unzip": "^4.0.1",
23
+ "form-data": "^3.0.0",
24
+ "gologin": "^2.1.33",
25
+ "ncp": "^2.0.0",
26
+ "progress": "^2.0.3",
27
+ "puppeteer-core": "^2.1.1",
28
+ "request": "^2.88.2",
29
+ "requestretry": "^4.1.0",
30
+ "rimraf": "^3.0.2",
31
+ "socks-proxy-agent": "^8.0.3",
32
+ "sqlite": "^4.0.23",
33
+ "sqlite3": "^5.0.2"
34
+ },
35
+ "devDependencies": {
36
+ "@babel/cli": "^7.25.6",
37
+ "@babel/core": "^7.25.2",
38
+ "@babel/plugin-transform-modules-commonjs": "^7.24.8",
39
+ "@babel/plugin-syntax-import-attributes": "^7.25.0",
40
+ "babel-plugin-transform-import-meta": "^2.2.1",
41
+ "eslint": "^8.21.0",
42
+ "eslint-plugin-simple-import-sort": "^8.0.0",
43
+ "typescript": "^5.5.4"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc && npm run build:common",
47
+ "build:common": "babel gologin --out-dir dist && npm run copy",
48
+ "copy": "ncp gologin/fonts_config dist/fonts_config && ncp gologin/gologin_zeroprofile.b64 dist/gologin_zeroprofile.b64 && ncp gologin/gologin-browser-ext.zip dist/gologin-browser-ext.zip && ncp gologin/zero_profile.zip dist/zero_profile.zip && ncp package.json dist/package.json",
49
+ "test": "echo \"Error: no test specified\" && exit 1",
50
+ "format": "npx prettier --single-quote src/* --write",
51
+ "iphey": "GOLOGIN_PROFILE_ID= GOLOGIN_API_TOKEN= node examples/example-iphey "
52
+ }
53
+ }
@@ -4,25 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.updateProfileUserAgent = exports.updateProfileResolution = exports.updateProfileProxy = exports.updateProfileBookmarks = void 0;
7
- var _requestretry = _interopRequireDefault(require("requestretry"));
8
7
  var _common = require("../utils/common.js");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ var _http = require("../utils/http.js");
10
9
  /**
11
10
  * @param {string} profileId
12
11
  * @param {string} ACCESS_TOKEN
13
12
  * @param {string} resolution
14
13
  */
15
- const updateProfileResolution = (profileId, ACCESS_TOKEN, resolution) => _requestretry.default.patch(`${_common.API_URL}/browser/${profileId}/resolution`, {
16
- headers: {
17
- Authorization: `Bearer ${ACCESS_TOKEN}`,
18
- 'user-agent': 'gologin-api'
19
- },
14
+ const updateProfileResolution = (profileId, ACCESS_TOKEN, resolution) => (0, _http.makeRequest)(`${_common.API_URL}/browser/${profileId}/resolution`, {
15
+ method: 'PATCH',
20
16
  json: {
21
17
  resolution
22
18
  },
23
19
  maxAttempts: 3,
24
20
  retryDelay: 2000,
25
21
  timeout: 10 * 1000
22
+ }, {
23
+ token: ACCESS_TOKEN,
24
+ fallbackUrl: `${_common.FALLBACK_API_URL}/browser/${profileId}/resolution`
26
25
  }).catch(e => {
27
26
  console.log(e);
28
27
  return {
@@ -36,17 +35,17 @@ const updateProfileResolution = (profileId, ACCESS_TOKEN, resolution) => _reques
36
35
  * @param {string} userAgent
37
36
  */
38
37
  exports.updateProfileResolution = updateProfileResolution;
39
- const updateProfileUserAgent = (profileId, ACCESS_TOKEN, userAgent) => _requestretry.default.patch(`${_common.API_URL}/browser/${profileId}/ua`, {
40
- headers: {
41
- Authorization: `Bearer ${ACCESS_TOKEN}`,
42
- 'user-agent': 'gologin-api'
43
- },
38
+ const updateProfileUserAgent = (profileId, ACCESS_TOKEN, userAgent) => (0, _http.makeRequest)(`${_common.API_URL}/browser/${profileId}/ua`, {
39
+ method: 'PATCH',
44
40
  json: {
45
41
  userAgent
46
42
  },
47
43
  maxAttempts: 3,
48
44
  retryDelay: 2000,
49
45
  timeout: 10 * 1000
46
+ }, {
47
+ token: ACCESS_TOKEN,
48
+ fallbackUrl: `${_common.FALLBACK_API_URL}/browser/${profileId}/ua`
50
49
  }).catch(e => {
51
50
  console.log(e);
52
51
  return {
@@ -65,15 +64,15 @@ const updateProfileUserAgent = (profileId, ACCESS_TOKEN, userAgent) => _requestr
65
64
  * @param {string} [browserProxyData.password]
66
65
  */
67
66
  exports.updateProfileUserAgent = updateProfileUserAgent;
68
- const updateProfileProxy = (profileId, ACCESS_TOKEN, browserProxyData) => _requestretry.default.patch(`${_common.API_URL}/browser/${profileId}/proxy`, {
69
- headers: {
70
- Authorization: `Bearer ${ACCESS_TOKEN}`,
71
- 'user-agent': 'gologin-api'
72
- },
67
+ const updateProfileProxy = (profileId, ACCESS_TOKEN, browserProxyData) => (0, _http.makeRequest)(`${_common.API_URL}/browser/${profileId}/proxy`, {
68
+ method: 'PATCH',
73
69
  json: browserProxyData,
74
70
  maxAttempts: 3,
75
71
  retryDelay: 2000,
76
72
  timeout: 10 * 1000
73
+ }, {
74
+ token: ACCESS_TOKEN,
75
+ fallbackUrl: `${_common.FALLBACK_API_URL}/browser/${profileId}/proxy`
77
76
  }).catch(e => {
78
77
  console.log(e);
79
78
  return {
@@ -92,15 +91,15 @@ const updateProfileBookmarks = async (profileIds, ACCESS_TOKEN, bookmarks) => {
92
91
  profileIds,
93
92
  bookmarks
94
93
  };
95
- return _requestretry.default.patch(`${_common.API_URL}/browser/bookmarks/many`, {
96
- headers: {
97
- Authorization: `Bearer ${ACCESS_TOKEN}`,
98
- 'user-agent': 'gologin-api'
99
- },
94
+ return (0, _http.makeRequest)(`${_common.API_URL}/browser/bookmarks/many`, {
95
+ method: 'PATCH',
100
96
  json: params,
101
97
  maxAttempts: 3,
102
98
  retryDelay: 2000,
103
99
  timeout: 10 * 1000
100
+ }, {
101
+ token: ACCESS_TOKEN,
102
+ fallbackUrl: `${_common.FALLBACK_API_URL}/browser/bookmarks/many`
104
103
  }).catch(error => console.log(error));
105
104
  };
106
105
  exports.updateProfileBookmarks = updateProfileBookmarks;