gologin 1.0.58 → 2.0.1

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 ADDED
@@ -0,0 +1,265 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "es2021": true,
5
+ "node": true
6
+ },
7
+ "extends": "eslint:recommended",
8
+ "overrides": [
9
+ ],
10
+ "parserOptions": {
11
+ "ecmaVersion": "latest",
12
+ "sourceType": "module"
13
+ },
14
+ "plugins": [
15
+ "simple-import-sort"
16
+ ],
17
+ "rules": {
18
+ "padding-line-between-statements": [
19
+ "warn",
20
+ { "blankLine": "always", "prev": ["if", "switch", "while", "function", "multiline-const", "try"], "next": "*" },
21
+ { "blankLine": "always", "prev": "*", "next": ["return"] }
22
+ ],
23
+ "indent": [
24
+ "warn",
25
+ 2,
26
+ {
27
+ "SwitchCase": 1,
28
+ "ignoredNodes": [
29
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
30
+ ]
31
+ }
32
+ ],
33
+ "linebreak-style": [
34
+ "warn",
35
+ "windows"
36
+ ],
37
+ "quotes": [
38
+ "warn",
39
+ "single"
40
+ ],
41
+ "semi": [
42
+ "warn",
43
+ "always"
44
+ ],
45
+ "array-callback-return": [
46
+ "warn"
47
+ ],
48
+ "no-await-in-loop": [
49
+ "off"
50
+ ],
51
+ "no-duplicate-imports": [
52
+ "warn"
53
+ ],
54
+ "arrow-body-style": [
55
+ "warn",
56
+ "as-needed"
57
+ ],
58
+ "camelcase": [
59
+ "warn",
60
+ {
61
+ "ignoreGlobals": true
62
+ }
63
+ ],
64
+ "curly": [
65
+ "warn",
66
+ "all"
67
+ ],
68
+ "default-case": [
69
+ "warn"
70
+ ],
71
+ "default-case-last": [
72
+ "warn"
73
+ ],
74
+ "dot-notation": [
75
+ "warn"
76
+ ],
77
+ "eqeqeq": [
78
+ "warn",
79
+ "always"
80
+ ],
81
+ "id-length": [
82
+ "warn",
83
+ {
84
+ "min": 1,
85
+ "max": 40,
86
+ "properties": "never"
87
+ }
88
+ ],
89
+ "max-depth": [
90
+ "warn",
91
+ {
92
+ "max": 4
93
+ }
94
+ ],
95
+ "max-lines": [
96
+ "warn",
97
+ 1500
98
+ ],
99
+ "no-else-return": [
100
+ "warn",
101
+ {
102
+ "allowElseIf": true
103
+ }
104
+ ],
105
+ "no-unused-vars": [
106
+ "warn", {
107
+ "vars": "all",
108
+ "args": "after-used",
109
+ "ignoreRestSiblings": false
110
+ }
111
+ ],
112
+ "keyword-spacing": [
113
+ "error", {
114
+ "before": true,
115
+ "after": true
116
+ }
117
+ ],
118
+ "no-empty-function": [
119
+ "warn",
120
+ {
121
+ "allow": ["constructors"]
122
+ }
123
+ ],
124
+ "no-inline-comments": [
125
+ "warn"
126
+ ],
127
+ "no-labels": [
128
+ "warn"
129
+ ],
130
+ "no-lone-blocks": [
131
+ "warn"
132
+ ],
133
+ "no-lonely-if": [
134
+ "warn"
135
+ ],
136
+ "no-magic-numbers": [
137
+ "off",
138
+ {
139
+ "ignoreArrayIndexes": true,
140
+ "ignoreDefaultValues": true,
141
+ "ignore": [1, 2, 3, 10, 1000, -1, 0]
142
+ }
143
+ ],
144
+ "no-multi-assign": [
145
+ "warn"
146
+ ],
147
+ "no-multi-str": [
148
+ "warn"
149
+ ],
150
+ "no-nested-ternary": [
151
+ "warn"
152
+ ],
153
+ "no-return-assign": [
154
+ "warn"
155
+ ],
156
+ "no-return-await": [
157
+ "warn"
158
+ ],
159
+ "no-sequences": [
160
+ "warn"
161
+ ],
162
+ "no-shadow": [
163
+ "warn"
164
+ ],
165
+ "no-undefined": [
166
+ "warn"
167
+ ],
168
+ "no-underscore-dangle": [
169
+ "warn",
170
+ {
171
+ "allow": ["_id"]
172
+ }
173
+ ],
174
+ "no-unneeded-ternary": [
175
+ "warn"
176
+ ],
177
+ "no-unused-expressions": [
178
+ "warn",
179
+ {
180
+ "allowShortCircuit": true,
181
+ "allowTernary": true
182
+ }
183
+ ],
184
+ "no-useless-return": [
185
+ "warn"
186
+ ],
187
+ "object-shorthand": [
188
+ "warn",
189
+ "always"
190
+ ],
191
+ "prefer-arrow-callback": [
192
+ "warn"
193
+ ],
194
+ "prefer-const": [
195
+ "warn"
196
+ ],
197
+ "prefer-destructuring": [
198
+ "warn"
199
+ ],
200
+ "prefer-object-spread": [
201
+ "warn"
202
+ ],
203
+ "prefer-spread": [
204
+ "warn"
205
+ ],
206
+ "prefer-template": [
207
+ "off"
208
+ ],
209
+ "spaced-comment": [
210
+ "warn"
211
+ ],
212
+ "yoda": [
213
+ "warn"
214
+ ],
215
+ "arrow-spacing": [
216
+ "warn"
217
+ ],
218
+ "brace-style": [
219
+ "warn",
220
+ "1tbs",
221
+ { "allowSingleLine": false }
222
+ ],
223
+ "comma-dangle": [
224
+ "warn",
225
+ "always-multiline"
226
+ ],
227
+ "dot-location": [
228
+ "warn",
229
+ "property"
230
+ ],
231
+ "eol-last": [
232
+ "warn"
233
+ ],
234
+ "no-extra-parens": [
235
+ "off"
236
+ ],
237
+ "no-multiple-empty-lines": [
238
+ "warn",
239
+ {
240
+ "max": 1
241
+ }
242
+ ],
243
+ "no-trailing-spaces": [
244
+ "warn"
245
+ ],
246
+ "no-whitespace-before-property": [
247
+ "warn"
248
+ ],
249
+ "object-curly-spacing": [
250
+ "warn",
251
+ "always"
252
+ ],
253
+ "space-in-parens": [
254
+ "warn"
255
+ ],
256
+ "template-curly-spacing": [
257
+ "warn"
258
+ ],
259
+ "max-len": [
260
+ "warn",
261
+ 150
262
+ ],
263
+ "simple-import-sort/imports": "warn"
264
+ }
265
+ }
package/README.md CHANGED
@@ -23,35 +23,40 @@ To have an access to the page below you need <a href="https://app.gologin.com/#/
23
23
  ### Example
24
24
 
25
25
  ```js
26
- const puppeteer = require('puppeteer-core');
27
- const GoLogin = require('gologin');
28
-
29
- (async () =>{
30
- const GL = new GoLogin({
31
- token: 'yU0token',
32
- profile_id: 'yU0Pr0f1leiD',
33
- });
34
-
35
- const { status, wsUrl } = await GL.start().catch((e) => {
36
- console.trace(e);
37
- return { status: 'failure' };
38
- });
39
-
40
- if (status !== 'success') {
41
- console.log('Invalid status');
42
- return;
43
- }
44
-
45
- const browser = await puppeteer.connect({
46
- browserWSEndpoint: wsUrl.toString(),
47
- ignoreHTTPSErrors: true,
48
- });
49
-
50
- const page = await browser.newPage();
51
- await page.goto('https://myip.link/mini');
52
- console.log(await page.content());
53
- await browser.close();
54
- await GL.stop();
26
+ import pkg from 'puppeteer-core';
27
+
28
+ import GoLogin from './gologin.js';
29
+
30
+ const { connect } = pkg;
31
+
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);
40
+
41
+ return { status: 'failure' };
42
+ });
43
+
44
+ if (status !== 'success') {
45
+ console.log('Invalid status');
46
+
47
+ return;
48
+ }
49
+
50
+ const browser = await connect({
51
+ browserWSEndpoint: wsUrl.toString(),
52
+ ignoreHTTPSErrors: true,
53
+ });
54
+
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();
55
60
  })();
56
61
  ```
57
62
 
@@ -77,7 +82,7 @@ const GoLogin = require('gologin');
77
82
  - `skipOrbitaHashChecking` <[boolean]> skip hash checking for Orbita after downloading process (default false)
78
83
 
79
84
  ```js
80
- const GoLogin = require('gologin');
85
+ import GoLogin from './gologin.js';
81
86
  const GL = new GoLogin({
82
87
  token: 'yU0token',
83
88
  profile_id: 'yU0Pr0f1leiD',
@@ -123,26 +128,31 @@ stop current browser without removing archived profile
123
128
  ### example-local-profile.js
124
129
 
125
130
  ```js
126
- const puppeteer = require('puppeteer-core');
127
- const GoLogin = require('gologin');
128
-
129
- (async () =>{
130
- const GL = new GoLogin({
131
- token: 'yU0token',
132
- profile_id: 'yU0Pr0f1leiD',
133
- tmpdir: '/my/tmp/dir',
134
- });
135
- const { status, wsUrl } = await GL.start();
136
- const browser = await puppeteer.connect({
137
- browserWSEndpoint: wsUrl.toString(),
138
- ignoreHTTPSErrors: true,
139
- });
140
-
141
- const page = await browser.newPage();
142
- await page.goto('https://myip.link/mini');
143
- console.log(await page.content());
144
- await browser.close();
145
- await GL.stopLocal({posting: false});
131
+ import pkg from 'puppeteer-core';
132
+
133
+ import GoLogin from './gologin.js';
134
+
135
+ const { connect } = pkg;
136
+
137
+ (async () => {
138
+ const GL = new GoLogin({
139
+ token: 'yU0token',
140
+ profile_id: 'yU0Pr0f1leiD',
141
+ executablePath: '/usr/bin/orbita-browser/chrome',
142
+ tmpdir: '/my/tmp/dir',
143
+ });
144
+
145
+ const wsUrl = await GL.startLocal();
146
+ const browser = await connect({
147
+ browserWSEndpoint: wsUrl.toString(),
148
+ ignoreHTTPSErrors: true,
149
+ });
150
+
151
+ const page = await browser.newPage();
152
+ await page.goto('https://myip.link');
153
+ console.log(await page.content());
154
+ await browser.close();
155
+ await GL.stopLocal({ posting: false });
146
156
  })();
147
157
  ```
148
158