apify 2.3.1-beta.4 → 3.0.0-alpha.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 (211) hide show
  1. package/README.md +6 -5
  2. package/package.json +69 -128
  3. package/build/actor.d.ts +0 -113
  4. package/build/actor.d.ts.map +0 -1
  5. package/build/actor.js +0 -582
  6. package/build/actor.js.map +0 -1
  7. package/build/apify.d.ts +0 -752
  8. package/build/apify.d.ts.map +0 -1
  9. package/build/apify.js +0 -877
  10. package/build/apify.js.map +0 -1
  11. package/build/autoscaling/autoscaled_pool.d.ts +0 -384
  12. package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
  13. package/build/autoscaling/autoscaled_pool.js +0 -557
  14. package/build/autoscaling/autoscaled_pool.js.map +0 -1
  15. package/build/autoscaling/snapshotter.d.ts +0 -278
  16. package/build/autoscaling/snapshotter.d.ts.map +0 -1
  17. package/build/autoscaling/snapshotter.js +0 -447
  18. package/build/autoscaling/snapshotter.js.map +0 -1
  19. package/build/autoscaling/system_status.d.ts +0 -224
  20. package/build/autoscaling/system_status.d.ts.map +0 -1
  21. package/build/autoscaling/system_status.js +0 -228
  22. package/build/autoscaling/system_status.js.map +0 -1
  23. package/build/browser_launchers/browser_launcher.d.ts +0 -154
  24. package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
  25. package/build/browser_launchers/browser_launcher.js +0 -160
  26. package/build/browser_launchers/browser_launcher.js.map +0 -1
  27. package/build/browser_launchers/browser_plugin.d.ts +0 -23
  28. package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
  29. package/build/browser_launchers/browser_plugin.js +0 -25
  30. package/build/browser_launchers/browser_plugin.js.map +0 -1
  31. package/build/browser_launchers/playwright_launcher.d.ts +0 -131
  32. package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
  33. package/build/browser_launchers/playwright_launcher.js +0 -150
  34. package/build/browser_launchers/playwright_launcher.js.map +0 -1
  35. package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
  36. package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
  37. package/build/browser_launchers/puppeteer_launcher.js +0 -197
  38. package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
  39. package/build/cache_container.d.ts +0 -31
  40. package/build/cache_container.d.ts.map +0 -1
  41. package/build/cache_container.js +0 -48
  42. package/build/cache_container.js.map +0 -1
  43. package/build/configuration.d.ts +0 -226
  44. package/build/configuration.d.ts.map +0 -1
  45. package/build/configuration.js +0 -325
  46. package/build/configuration.js.map +0 -1
  47. package/build/constants.d.ts +0 -37
  48. package/build/constants.d.ts.map +0 -1
  49. package/build/constants.js +0 -41
  50. package/build/constants.js.map +0 -1
  51. package/build/crawlers/basic_crawler.d.ts +0 -443
  52. package/build/crawlers/basic_crawler.d.ts.map +0 -1
  53. package/build/crawlers/basic_crawler.js +0 -664
  54. package/build/crawlers/basic_crawler.js.map +0 -1
  55. package/build/crawlers/browser_crawler.d.ts +0 -512
  56. package/build/crawlers/browser_crawler.d.ts.map +0 -1
  57. package/build/crawlers/browser_crawler.js +0 -540
  58. package/build/crawlers/browser_crawler.js.map +0 -1
  59. package/build/crawlers/cheerio_crawler.d.ts +0 -931
  60. package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
  61. package/build/crawlers/cheerio_crawler.js +0 -913
  62. package/build/crawlers/cheerio_crawler.js.map +0 -1
  63. package/build/crawlers/crawler_extension.d.ts +0 -10
  64. package/build/crawlers/crawler_extension.d.ts.map +0 -1
  65. package/build/crawlers/crawler_extension.js +0 -19
  66. package/build/crawlers/crawler_extension.js.map +0 -1
  67. package/build/crawlers/crawler_utils.d.ts +0 -34
  68. package/build/crawlers/crawler_utils.d.ts.map +0 -1
  69. package/build/crawlers/crawler_utils.js +0 -87
  70. package/build/crawlers/crawler_utils.js.map +0 -1
  71. package/build/crawlers/playwright_crawler.d.ts +0 -448
  72. package/build/crawlers/playwright_crawler.d.ts.map +0 -1
  73. package/build/crawlers/playwright_crawler.js +0 -299
  74. package/build/crawlers/playwright_crawler.js.map +0 -1
  75. package/build/crawlers/puppeteer_crawler.d.ts +0 -425
  76. package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
  77. package/build/crawlers/puppeteer_crawler.js +0 -299
  78. package/build/crawlers/puppeteer_crawler.js.map +0 -1
  79. package/build/crawlers/statistics.d.ts +0 -185
  80. package/build/crawlers/statistics.d.ts.map +0 -1
  81. package/build/crawlers/statistics.js +0 -331
  82. package/build/crawlers/statistics.js.map +0 -1
  83. package/build/enqueue_links/click_elements.d.ts +0 -179
  84. package/build/enqueue_links/click_elements.d.ts.map +0 -1
  85. package/build/enqueue_links/click_elements.js +0 -434
  86. package/build/enqueue_links/click_elements.js.map +0 -1
  87. package/build/enqueue_links/enqueue_links.d.ts +0 -117
  88. package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
  89. package/build/enqueue_links/enqueue_links.js +0 -163
  90. package/build/enqueue_links/enqueue_links.js.map +0 -1
  91. package/build/enqueue_links/shared.d.ts +0 -42
  92. package/build/enqueue_links/shared.d.ts.map +0 -1
  93. package/build/enqueue_links/shared.js +0 -121
  94. package/build/enqueue_links/shared.js.map +0 -1
  95. package/build/errors.d.ts +0 -29
  96. package/build/errors.d.ts.map +0 -1
  97. package/build/errors.js +0 -38
  98. package/build/errors.js.map +0 -1
  99. package/build/events.d.ts +0 -11
  100. package/build/events.d.ts.map +0 -1
  101. package/build/events.js +0 -147
  102. package/build/events.js.map +0 -1
  103. package/build/index.d.ts +0 -4
  104. package/build/index.d.ts.map +0 -1
  105. package/build/index.js +0 -7
  106. package/build/index.js.map +0 -1
  107. package/build/main.d.ts +0 -179
  108. package/build/main.d.ts.map +0 -1
  109. package/build/main.js +0 -81
  110. package/build/main.js.map +0 -1
  111. package/build/playwright_utils.d.ts +0 -9
  112. package/build/playwright_utils.d.ts.map +0 -1
  113. package/build/playwright_utils.js +0 -90
  114. package/build/playwright_utils.js.map +0 -1
  115. package/build/proxy_configuration.d.ts +0 -411
  116. package/build/proxy_configuration.d.ts.map +0 -1
  117. package/build/proxy_configuration.js +0 -517
  118. package/build/proxy_configuration.js.map +0 -1
  119. package/build/pseudo_url.d.ts +0 -86
  120. package/build/pseudo_url.d.ts.map +0 -1
  121. package/build/pseudo_url.js +0 -153
  122. package/build/pseudo_url.js.map +0 -1
  123. package/build/puppeteer_request_interception.d.ts +0 -8
  124. package/build/puppeteer_request_interception.d.ts.map +0 -1
  125. package/build/puppeteer_request_interception.js +0 -235
  126. package/build/puppeteer_request_interception.js.map +0 -1
  127. package/build/puppeteer_utils.d.ts +0 -250
  128. package/build/puppeteer_utils.d.ts.map +0 -1
  129. package/build/puppeteer_utils.js +0 -551
  130. package/build/puppeteer_utils.js.map +0 -1
  131. package/build/request.d.ts +0 -180
  132. package/build/request.d.ts.map +0 -1
  133. package/build/request.js +0 -261
  134. package/build/request.js.map +0 -1
  135. package/build/request_list.d.ts +0 -581
  136. package/build/request_list.d.ts.map +0 -1
  137. package/build/request_list.js +0 -826
  138. package/build/request_list.js.map +0 -1
  139. package/build/serialization.d.ts +0 -5
  140. package/build/serialization.d.ts.map +0 -1
  141. package/build/serialization.js +0 -139
  142. package/build/serialization.js.map +0 -1
  143. package/build/session_pool/errors.d.ts +0 -11
  144. package/build/session_pool/errors.d.ts.map +0 -1
  145. package/build/session_pool/errors.js +0 -18
  146. package/build/session_pool/errors.js.map +0 -1
  147. package/build/session_pool/events.d.ts +0 -5
  148. package/build/session_pool/events.d.ts.map +0 -1
  149. package/build/session_pool/events.js +0 -6
  150. package/build/session_pool/events.js.map +0 -1
  151. package/build/session_pool/session.d.ts +0 -286
  152. package/build/session_pool/session.d.ts.map +0 -1
  153. package/build/session_pool/session.js +0 -355
  154. package/build/session_pool/session.js.map +0 -1
  155. package/build/session_pool/session_pool.d.ts +0 -280
  156. package/build/session_pool/session_pool.d.ts.map +0 -1
  157. package/build/session_pool/session_pool.js +0 -393
  158. package/build/session_pool/session_pool.js.map +0 -1
  159. package/build/session_pool/session_utils.d.ts +0 -4
  160. package/build/session_pool/session_utils.d.ts.map +0 -1
  161. package/build/session_pool/session_utils.js +0 -24
  162. package/build/session_pool/session_utils.js.map +0 -1
  163. package/build/stealth/hiding_tricks.d.ts +0 -22
  164. package/build/stealth/hiding_tricks.d.ts.map +0 -1
  165. package/build/stealth/hiding_tricks.js +0 -308
  166. package/build/stealth/hiding_tricks.js.map +0 -1
  167. package/build/stealth/stealth.d.ts +0 -56
  168. package/build/stealth/stealth.d.ts.map +0 -1
  169. package/build/stealth/stealth.js +0 -125
  170. package/build/stealth/stealth.js.map +0 -1
  171. package/build/storages/dataset.d.ts +0 -288
  172. package/build/storages/dataset.d.ts.map +0 -1
  173. package/build/storages/dataset.js +0 -480
  174. package/build/storages/dataset.js.map +0 -1
  175. package/build/storages/key_value_store.d.ts +0 -243
  176. package/build/storages/key_value_store.d.ts.map +0 -1
  177. package/build/storages/key_value_store.js +0 -462
  178. package/build/storages/key_value_store.js.map +0 -1
  179. package/build/storages/request_queue.d.ts +0 -318
  180. package/build/storages/request_queue.d.ts.map +0 -1
  181. package/build/storages/request_queue.js +0 -636
  182. package/build/storages/request_queue.js.map +0 -1
  183. package/build/storages/storage_manager.d.ts +0 -87
  184. package/build/storages/storage_manager.d.ts.map +0 -1
  185. package/build/storages/storage_manager.js +0 -150
  186. package/build/storages/storage_manager.js.map +0 -1
  187. package/build/tsconfig.tsbuildinfo +0 -1
  188. package/build/typedefs.d.ts +0 -146
  189. package/build/typedefs.d.ts.map +0 -1
  190. package/build/typedefs.js +0 -88
  191. package/build/typedefs.js.map +0 -1
  192. package/build/utils.d.ts +0 -175
  193. package/build/utils.d.ts.map +0 -1
  194. package/build/utils.js +0 -731
  195. package/build/utils.js.map +0 -1
  196. package/build/utils_log.d.ts +0 -41
  197. package/build/utils_log.d.ts.map +0 -1
  198. package/build/utils_log.js +0 -192
  199. package/build/utils_log.js.map +0 -1
  200. package/build/utils_request.d.ts +0 -77
  201. package/build/utils_request.d.ts.map +0 -1
  202. package/build/utils_request.js +0 -385
  203. package/build/utils_request.js.map +0 -1
  204. package/build/utils_social.d.ts +0 -210
  205. package/build/utils_social.d.ts.map +0 -1
  206. package/build/utils_social.js +0 -787
  207. package/build/utils_social.js.map +0 -1
  208. package/build/validators.d.ts +0 -23
  209. package/build/validators.d.ts.map +0 -1
  210. package/build/validators.js +0 -29
  211. package/build/validators.js.map +0 -1
@@ -1,308 +0,0 @@
1
- "use strict";
2
- /* istanbul ignore file */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const hackPermissions = () => {
5
- const originalQuery = window.navigator.permissions.query;
6
- // eslint-disable-next-line
7
- window.navigator.permissions.__proto__.query = parameters => parameters.name === 'notifications'
8
- ? Promise.resolve({ state: Notification.permission }) //eslint-disable-line
9
- : originalQuery(parameters);
10
- // Inspired by: https://github.com/ikarienator/phantomjs_hide_and_seek/blob/master/5.spoofFunctionBind.js
11
- const oldCall = Function.prototype.call;
12
- function call() {
13
- return oldCall.apply(this, arguments); //eslint-disable-line
14
- }
15
- // eslint-disable-next-line
16
- Function.prototype.call = call;
17
- const nativeToStringFunctionString = Error.toString().replace(/Error/g, 'toString');
18
- const oldToString = Function.prototype.toString;
19
- function functionToString() {
20
- if (this === window.navigator.permissions.query) {
21
- return 'function query() { [native code] }';
22
- }
23
- if (this === functionToString) {
24
- return nativeToStringFunctionString;
25
- }
26
- return oldCall.call(oldToString, this);
27
- }
28
- // eslint-disable-next-line
29
- Function.prototype.toString = functionToString;
30
- };
31
- const addLanguage = () => {
32
- Object.defineProperty(Object.getPrototypeOf(navigator), 'languages', {
33
- get: () => ['en-US', 'en'],
34
- });
35
- };
36
- const emulateWebGL = () => {
37
- try {
38
- const getParameterOld = WebGLRenderingContext.getParameter;
39
- WebGLRenderingContext.prototype.getParameter = function (parameter) {
40
- // UNMASKED_VENDOR_WEBGL
41
- if (parameter === 37445) {
42
- return 'Intel Inc.';
43
- }
44
- // UNMASKED_RENDERER_WEBGL
45
- if (parameter === 37446) {
46
- return 'Intel(R) Iris(TM) Plus Graphics 640';
47
- }
48
- return getParameterOld(parameter);
49
- };
50
- }
51
- catch (err) {
52
- // eslint-disable-next-line no-console
53
- console.error('hiding_tricks: Could not emulate WebGL');
54
- }
55
- };
56
- const emulateWindowFrame = () => {
57
- if (window.outerWidth && window.outerHeight) {
58
- return; // nothing to do here
59
- }
60
- const windowFrame = 85; // probably OS and WM dependent
61
- window.outerWidth = window.innerWidth;
62
- window.outerHeight = window.innerHeight + windowFrame;
63
- };
64
- const addPlugins = () => {
65
- function mockPluginsAndMimeTypes() {
66
- // Disguise custom functions as being native
67
- const makeFnsNative = (fns = []) => {
68
- const oldCall = Function.prototype.call;
69
- function call() {
70
- return oldCall.apply(this, arguments); // eslint-disable-line
71
- }
72
- // eslint-disable-next-line
73
- Function.prototype.call = call;
74
- const nativeToStringFunctionString = Error.toString().replace(/Error/g, 'toString');
75
- const oldToString = Function.prototype.toString;
76
- function functionToString() {
77
- for (const fn of fns) {
78
- if (this === fn.ref) {
79
- return `function ${fn.name}() { [native code] }`;
80
- }
81
- }
82
- if (this === functionToString) {
83
- return nativeToStringFunctionString;
84
- }
85
- return oldCall.call(oldToString, this);
86
- }
87
- // eslint-disable-next-line
88
- Function.prototype.toString = functionToString;
89
- };
90
- const mockedFns = [];
91
- const fakeData = {
92
- mimeTypes: [
93
- {
94
- type: 'application/pdf',
95
- suffixes: 'pdf',
96
- description: '',
97
- __pluginName: 'Chrome PDF Viewer',
98
- },
99
- {
100
- type: 'application/x-google-chrome-pdf',
101
- suffixes: 'pdf',
102
- description: 'Portable Document Format',
103
- __pluginName: 'Chrome PDF Plugin',
104
- },
105
- {
106
- type: 'application/x-nacl',
107
- suffixes: '',
108
- description: 'Native Client Executable',
109
- enabledPlugin: window.Plugin,
110
- __pluginName: 'Native Client',
111
- },
112
- {
113
- type: 'application/x-pnacl',
114
- suffixes: '',
115
- description: 'Portable Native Client Executable',
116
- __pluginName: 'Native Client',
117
- },
118
- ],
119
- plugins: [
120
- {
121
- name: 'Chrome PDF Plugin',
122
- filename: 'internal-pdf-viewer',
123
- description: 'Portable Document Format',
124
- },
125
- {
126
- name: 'Chrome PDF Viewer',
127
- filename: 'mhjfbmdgcfjbbpaeojofohoefgiehjai',
128
- description: '',
129
- },
130
- {
131
- name: 'Native Client',
132
- filename: 'internal-nacl-plugin',
133
- description: '',
134
- },
135
- ],
136
- fns: {
137
- namedItem: (instanceName) => {
138
- // Returns the Plugin/MimeType with the specified name.
139
- const fn = function (name) {
140
- if (!arguments.length) {
141
- throw new TypeError(`Failed to execute 'namedItem' on '${instanceName}': 1 argument required, but only 0 present.`);
142
- }
143
- return this[name] || null;
144
- };
145
- mockedFns.push({ ref: fn, name: 'namedItem' });
146
- return fn;
147
- },
148
- item: (instanceName) => {
149
- // Returns the Plugin/MimeType at the specified index into the array.
150
- const fn = function (index) {
151
- if (!arguments.length) {
152
- throw new TypeError(`Failed to execute 'namedItem' on '${instanceName}': 1 argument required, but only 0 present.`);
153
- }
154
- return this[index] || null;
155
- };
156
- mockedFns.push({ ref: fn, name: 'item' });
157
- return fn;
158
- },
159
- refresh: () => {
160
- // Refreshes all plugins on the current page, optionally reloading documents.
161
- const fn = function () {
162
- return undefined;
163
- };
164
- mockedFns.push({ ref: fn, name: 'refresh' });
165
- return fn;
166
- },
167
- },
168
- };
169
- // Poor mans _.pluck
170
- const getSubset = (keys, obj) => keys.reduce((a, c) => ({ ...a, [c]: obj[c] }), {});
171
- function generateMimeTypeArray() {
172
- const arr = fakeData.mimeTypes
173
- .map((obj) => getSubset(['type', 'suffixes', 'description'], obj))
174
- .map((obj) => Object.setPrototypeOf(obj, MimeType.prototype));
175
- arr.forEach((obj) => {
176
- arr[obj.type] = obj;
177
- });
178
- // Mock functions
179
- arr.namedItem = fakeData.fns.namedItem('MimeTypeArray');
180
- arr.item = fakeData.fns.item('MimeTypeArray');
181
- return Object.setPrototypeOf(arr, MimeTypeArray.prototype);
182
- }
183
- const mimeTypeArray = generateMimeTypeArray();
184
- Object.defineProperty(window.navigator, 'mimeTypes', {
185
- get: () => mimeTypeArray,
186
- });
187
- function generatePluginArray() {
188
- const arr = fakeData.plugins
189
- .map((obj) => getSubset(['name', 'filename', 'description'], obj))
190
- .map((obj) => {
191
- const mimes = fakeData.mimeTypes.filter(m => m.__pluginName === obj.name);
192
- // Add mimetypes
193
- mimes.forEach((mime, index) => {
194
- window.navigator.mimeTypes[mime.type].enabledPlugin = obj;
195
- obj[mime.type] = window.navigator.mimeTypes[mime.type];
196
- obj[index] = window.navigator.mimeTypes[mime.type];
197
- });
198
- obj.length = mimes.length;
199
- return obj;
200
- })
201
- .map((obj) => {
202
- // Mock functions
203
- obj.namedItem = fakeData.fns.namedItem('Plugin');
204
- obj.item = fakeData.fns.item('Plugin');
205
- return obj;
206
- })
207
- .map((obj) => Object.setPrototypeOf(obj, window.Plugin.prototype));
208
- arr.forEach((obj) => {
209
- arr[obj.name] = obj;
210
- });
211
- // Mock functions
212
- arr.namedItem = fakeData.fns.namedItem('PluginArray');
213
- arr.item = fakeData.fns.item('PluginArray');
214
- arr.refresh = fakeData.fns.refresh('PluginArray');
215
- return Object.setPrototypeOf(arr, PluginArray.prototype);
216
- }
217
- const pluginArray = generatePluginArray();
218
- Object.defineProperty(window.navigator, 'plugins', {
219
- get: () => pluginArray,
220
- });
221
- // Make mockedFns toString() representation resemble a native function
222
- makeFnsNative(mockedFns);
223
- }
224
- const isPluginArray = window.navigator.plugins instanceof PluginArray;
225
- const hasPlugins = isPluginArray && window.navigator.plugins.length > 0;
226
- if (isPluginArray && hasPlugins) {
227
- return; // nothing to do here
228
- }
229
- mockPluginsAndMimeTypes();
230
- };
231
- const emulateConsoleDebug = () => {
232
- window.console.debug = () => {
233
- return null;
234
- };
235
- };
236
- // Should be mocked more properly - this one will bypass only some stupid tests
237
- const mockChrome = () => {
238
- if (!window.chrome) {
239
- Object.defineProperty(window, 'chrome', {
240
- value: {
241
- runtime: {},
242
- },
243
- });
244
- }
245
- };
246
- // not sure if this hack does not broke iframe on websites... Should figure out how to test properly
247
- // Should cover that it is custom function same as the permission query
248
- const mockChromeInIframe = () => {
249
- const oldCreate = document.createElement.bind(document);
250
- const newCreate = (...args) => {
251
- if (args[0] === 'iframe') {
252
- const iframe = oldCreate(...args);
253
- if (!iframe.contentWindow) {
254
- Object.defineProperty(iframe, 'contentWindow', {
255
- configurable: true,
256
- value: { chrome: {} },
257
- });
258
- }
259
- if (!iframe.contentWindow.chrome) {
260
- Object.defineProperty(iframe.contentWindow, 'chrome', {
261
- value: {},
262
- configurable: true,
263
- });
264
- }
265
- return iframe;
266
- }
267
- return oldCreate(...args);
268
- };
269
- newCreate.toString = () => 'function createElement() { [native code] }';
270
- document.createElement = newCreate;
271
- const oldCall = Function.prototype.call;
272
- function call() {
273
- return oldCall.apply(this, arguments); //eslint-disable-line
274
- }
275
- // eslint-disable-next-line
276
- Function.prototype.call = call;
277
- const nativeToStringFunctionString = Error.toString().replace(/Error/g, 'toString');
278
- const oldToString = Function.prototype.toString;
279
- function functionToString() {
280
- if (this === window.document.createElement) {
281
- return 'function createElement() { [native code] }';
282
- }
283
- if (this === functionToString) {
284
- return nativeToStringFunctionString;
285
- }
286
- return oldCall.call(oldToString, this);
287
- }
288
- // eslint-disable-next-line
289
- Function.prototype.toString = functionToString;
290
- };
291
- const mockDeviceMemory = () => {
292
- // TODO: Count from env according to - https://developer.mozilla.org/en-US/docs/Web/API/Navigator/deviceMemory
293
- Object.defineProperty(navigator, 'deviceMemory', {
294
- value: 8,
295
- });
296
- };
297
- exports.default = {
298
- addPlugins,
299
- emulateWindowFrame,
300
- emulateWebGL,
301
- emulateConsoleDebug,
302
- addLanguage,
303
- hackPermissions,
304
- mockChrome,
305
- mockChromeInIframe,
306
- mockDeviceMemory,
307
- };
308
- //# sourceMappingURL=hiding_tricks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hiding_tricks.js","sourceRoot":"","sources":["../../src/stealth/hiding_tricks.js"],"names":[],"mappings":";AAAA,0BAA0B;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 -1,56 +0,0 @@
1
- /**
2
- * The main purpose of this function is to override newPage function and attach selected tricks.
3
- * @param {Browser} browser - puppeteer browser instance
4
- * @param {StealthOptions} options
5
- * @returns {Promise<Browser>} - Instance of Browser from puppeteer package
6
- */
7
- export default function applyStealthToBrowser(browser: Browser, options: StealthOptions): Promise<Browser>;
8
- /**
9
- * Configuration of stealth tricks for a proper hiding effect all of them should be set to true.
10
- * These tricks are applied only when the `stealth` option is set to `true`.
11
- */
12
- export type StealthOptions = {
13
- /**
14
- * - If plugins should be added to the navigator.
15
- */
16
- addPlugins?: boolean | undefined;
17
- /**
18
- * - Emulates window Iframe.
19
- */
20
- emulateWindowFrame?: boolean | undefined;
21
- /**
22
- * - Emulates graphic card.
23
- */
24
- emulateWebGL?: boolean | undefined;
25
- /**
26
- * - Emulates console.debug to return null.
27
- */
28
- emulateConsoleDebug?: boolean | undefined;
29
- /**
30
- * - Adds languages to the navigator.
31
- */
32
- addLanguage?: boolean | undefined;
33
- /**
34
- * - Hides the webdriver by changing the navigator proto.
35
- */
36
- hideWebDriver?: boolean | undefined;
37
- /**
38
- * - Fakes interaction with permissions.
39
- */
40
- hackPermissions?: boolean | undefined;
41
- /**
42
- * - Adds the chrome runtime properties.
43
- */
44
- mockChrome?: boolean | undefined;
45
- /**
46
- * - Adds the chrome runtime properties inside the every newly created iframe.
47
- */
48
- mockChromeInIframe?: boolean | undefined;
49
- /**
50
- * - Sets device memory to other value than 0.
51
- */
52
- mockDeviceMemory?: boolean | undefined;
53
- };
54
- // @ts-ignore optional peer dependency
55
- import { Browser } from "puppeteer";
56
- //# sourceMappingURL=stealth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stealth.d.ts","sourceRoot":"","sources":["../../src/stealth/stealth.js"],"names":[],"mappings":"AAwCA;;;;;GAKG;AACH,uDAJW,OAAO,WACP,cAAc,GACZ,QAAQ,OAAO,CAAC,CA2B5B"}
@@ -1,125 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const underscore_1 = (0, tslib_1.__importDefault)(require("underscore"));
5
- const utilities_1 = require("@apify/utilities");
6
- const utils_log_1 = (0, tslib_1.__importDefault)(require("../utils_log"));
7
- const hiding_tricks_1 = (0, tslib_1.__importDefault)(require("./hiding_tricks"));
8
- const log = utils_log_1.default.child({ prefix: 'Stealth' });
9
- /**
10
- * Configuration of stealth tricks for a proper hiding effect all of them should be set to true.
11
- * These tricks are applied only when the `stealth` option is set to `true`.
12
- * @typedef StealthOptions
13
- * @property {boolean} [addPlugins=true] - If plugins should be added to the navigator.
14
- * @property {boolean} [emulateWindowFrame=true] - Emulates window Iframe.
15
- * @property {boolean} [emulateWebGL=true] - Emulates graphic card.
16
- * @property {boolean} [emulateConsoleDebug=true] - Emulates console.debug to return null.
17
- * @property {boolean} [addLanguage=true] - Adds languages to the navigator.
18
- * @property {boolean} [hideWebDriver=true] - Hides the webdriver by changing the navigator proto.
19
- * @property {boolean} [hackPermissions=true] - Fakes interaction with permissions.
20
- * @property {boolean} [mockChrome=true] - Adds the chrome runtime properties.
21
- * @property {boolean} [mockChromeInIframe=true] - Adds the chrome runtime properties inside the every newly created iframe.
22
- * @property {boolean} [mockDeviceMemory=true] - Sets device memory to other value than 0.
23
- */
24
- const DEFAULT_STEALTH_OPTIONS = {
25
- addPlugins: true,
26
- emulateWindowFrame: true,
27
- emulateWebGL: true,
28
- emulateConsoleDebug: true,
29
- addLanguage: true,
30
- hackPermissions: true,
31
- mockChrome: true,
32
- mockChromeInIframe: true,
33
- mockDeviceMemory: true,
34
- };
35
- const STEALTH_ERROR_MESSAGE_PREFIX = 'StealthError';
36
- const MAX_IFRAMES = 10;
37
- const alreadyWrapped = Symbol('alreadyWrapped');
38
- /**
39
- * The main purpose of this function is to override newPage function and attach selected tricks.
40
- * @param {Browser} browser - puppeteer browser instance
41
- * @param {StealthOptions} options
42
- * @returns {Promise<Browser>} - Instance of Browser from puppeteer package
43
- */
44
- function applyStealthToBrowser(browser, options) {
45
- const modifiedBrowser = browser;
46
- const opts = underscore_1.default.defaults(options, DEFAULT_STEALTH_OPTIONS);
47
- const defaultContext = browser.defaultBrowserContext();
48
- const contextPrototype = Object.getPrototypeOf(defaultContext);
49
- const prevNewPage = contextPrototype.newPage;
50
- if (!contextPrototype.newPage[alreadyWrapped]) {
51
- contextPrototype.newPage = async function (...args) {
52
- const page = await prevNewPage.bind(this)(...args);
53
- const evaluationDebugMessage = generateEvaluationDebugMessage();
54
- addStealthDebugToPage(page, evaluationDebugMessage);
55
- await applyStealthTricks(page, evaluationDebugMessage, opts);
56
- return page;
57
- };
58
- contextPrototype.newPage[alreadyWrapped] = true;
59
- }
60
- return Promise.resolve(modifiedBrowser);
61
- }
62
- exports.default = applyStealthToBrowser;
63
- function generateEvaluationDebugMessage() {
64
- const minLength = 6;
65
- const maxLength = 10;
66
- const randomLength = Math.random() * (maxLength - minLength) + minLength;
67
- return (0, utilities_1.cryptoRandomObjectId)(randomLength);
68
- }
69
- /**
70
- * Logs the stealth errors in browser to the node stdout.
71
- * @param {Page} page - puppeteer page instance
72
- * @param {string} evaluationDebugMessage - debug message
73
- */
74
- function addStealthDebugToPage(page, evaluationDebugMessage) {
75
- let warningLogged = false;
76
- let counter = 1;
77
- page.on('console', (msg) => {
78
- const text = msg.text();
79
- if (text.includes(STEALTH_ERROR_MESSAGE_PREFIX)) {
80
- log.error(text);
81
- }
82
- else if (text.includes(evaluationDebugMessage)) {
83
- if (counter > MAX_IFRAMES && !warningLogged) {
84
- log.warning(`Evaluating hiding tricks in too many iframes (limit: ${MAX_IFRAMES}).`
85
- + 'You might experience some performance issues. Try setting \'stealth\' false');
86
- warningLogged = true;
87
- }
88
- counter++;
89
- log.debug('Tricks evaluated', { counter });
90
- }
91
- });
92
- }
93
- /**
94
- * Applies stealth tricks to the puppeteer page
95
- * @param {Page} page
96
- * @param {string} evaluationDebugMessage - debug message
97
- * @param {StealthOptions} options
98
- * @returns {Promise<void>}
99
- * @private
100
- * @ignore
101
- */
102
- function applyStealthTricks(page, evaluationDebugMessage, options) {
103
- const functions = Object.keys(options)
104
- .filter((key) => {
105
- return options[key];
106
- })
107
- .map((key) => hiding_tricks_1.default[key].toString());
108
- /* istanbul ignore next */
109
- const addFunctions = (functionsArr, errorMessagePrefix, debugMessage) => {
110
- // eslint-disable-next-line no-console
111
- console.log(debugMessage);
112
- // add functions
113
- for (const func of functionsArr) {
114
- try {
115
- eval(func)(); // eslint-disable-line
116
- }
117
- catch (e) {
118
- // eslint-disable-next-line no-console
119
- console.error(`${errorMessagePrefix}: Failed to apply stealth trick reason: ${e.message}`);
120
- }
121
- }
122
- };
123
- return page.evaluateOnNewDocument(addFunctions, functions, STEALTH_ERROR_MESSAGE_PREFIX, evaluationDebugMessage);
124
- }
125
- //# sourceMappingURL=stealth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stealth.js","sourceRoot":"","sources":["../../src/stealth/stealth.js"],"names":[],"mappings":";;;AAAA,yEAA2B;AAE3B,gDAAwD;AACxD,0EAAqC;AAErC,iFAA2C;AAE3C,MAAM,GAAG,GAAG,mBAAS,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAEnD;;;;;;;;;;;;;;GAcG;AAEH,MAAM,uBAAuB,GAAG;IAC5B,UAAU,EAAE,IAAI;IAChB,kBAAkB,EAAE,IAAI;IACxB,YAAY,EAAE,IAAI;IAClB,mBAAmB,EAAE,IAAI;IACzB,WAAW,EAAE,IAAI;IACjB,eAAe,EAAE,IAAI;IACrB,UAAU,EAAE,IAAI;IAChB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;CACzB,CAAC;AAEF,MAAM,4BAA4B,GAAG,cAAc,CAAC;AACpD,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAChD;;;;;GAKG;AACH,SAAwB,qBAAqB,CAAC,OAA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