codemanki / cloudscraper

--DEPRECATED -- 🛑 🛑 Node.js library to bypass cloudflare's anti-ddos page
MIT License
600 stars 139 forks source link

Adjusting code to parse & submit new captcha #292

Closed drdokk closed 4 years ago

drdokk commented 4 years ago

291 #286

TravisBuddy commented 4 years ago

Travis tests have failed

Hey @drdokk, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

Node.js: node

View build log

npm test ``` > cloudscraper@4.4.0 test /home/travis/build/codemanki/cloudscraper > npm run lint && npm run test:typescript && nyc --reporter=html --reporter=text mocha > cloudscraper@4.4.0 lint /home/travis/build/codemanki/cloudscraper > eslint --ext .json --ext .js --ext .ts . /home/travis/build/codemanki/cloudscraper/index.d.ts 80:40 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any ✖ 1 problem (0 errors, 1 warning) > cloudscraper@4.4.0 test:typescript /home/travis/build/codemanki/cloudscraper > tsc *.ts --noEmit && tsd Brotli (lib) ✓ should be available ✓ should have a decompress method ✓ decompress() should accept exactly 1 argument ✓ decompress() should accept buffer as input ✓ [internal] decompress() should produce the expected result - [external] decompress() should produce the expected result ✓ optional() should throw an error if the module contains an error Cloudscraper 1) should handle onCaptcha promise being rejected with a falsy error Unhandled rejection StatusCodeError: 403 - "\n\n\n\n \n\nAttention Required! | Cloudflare\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n
Please enable cookies.
\n
\n
\n

One more step

\n

Please complete the security check to access example-site.dev

\n
\n\n
\n
\n
\n
\n \n
\n
\n \n \n
\n \n
\n\n \n\n
\n
\n\n
\n
\n\n \n\n
\n
\n
\n
\n
\n\n
\n
\n
\n

Why do I have to complete a CAPTCHA?

\n\n

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

\n
\n\n
\n

What can I do to prevent this in the future?

\n\n\n

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

\n\n

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

\n\n
\n
\n
\n\n\n \n\n\n
\n
\n\n \n\n\n\n" at new StatusCodeError (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:185:22) at onRequestComplete (/home/travis/build/codemanki/cloudscraper/index.js:77:321) at onCloudflareResponse (/home/travis/build/codemanki/cloudscraper/index.js:43:23) at onRequestResponse (/home/travis/build/codemanki/cloudscraper/index.js:39:232) at Request. (/home/travis/build/codemanki/cloudscraper/index.js:29:376) at Object.onceWrapper (events.js:300:26) at Request.emit (events.js:210:5) at Request. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1161:10) at Request.emit (events.js:210:5) at IncomingMessage. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 2) should resolve reCAPTCHA (version as on 10.04.2019) when user calls captcha.submit() Unhandled rejection StatusCodeError: 403 - "\n\n\n\n \n\nAttention Required! | Cloudflare\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n
Please enable cookies.
\n
\n
\n

One more step

\n

Please complete the security check to access example-site.dev

\n
\n\n
\n
\n
\n
\n \n
\n
\n \n \n
\n \n
\n\n \n\n
\n
\n\n
\n
\n\n \n\n
\n
\n
\n
\n
\n\n
\n
\n
\n

Why do I have to complete a CAPTCHA?

\n\n

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

\n
\n\n
\n

What can I do to prevent this in the future?

\n\n\n

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

\n\n

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

\n\n
\n
\n
\n\n\n \n\n\n
\n
\n\n \n\n\n\n" at new StatusCodeError (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:185:22) at onRequestComplete (/home/travis/build/codemanki/cloudscraper/index.js:77:321) at onCloudflareResponse (/home/travis/build/codemanki/cloudscraper/index.js:43:23) at onRequestResponse (/home/travis/build/codemanki/cloudscraper/index.js:39:232) at Request. (/home/travis/build/codemanki/cloudscraper/index.js:29:376) at Object.onceWrapper (events.js:300:26) at Request.emit (events.js:210:5) at Request. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1161:10) at Request.emit (events.js:210:5) at IncomingMessage. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 3) should callback with an error if user calls captcha.submit(error) Unhandled rejection StatusCodeError: 403 - "\n\n\n\n \n\nAttention Required! | Cloudflare\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n
Please enable cookies.
\n
\n
\n

One more step

\n

Please complete the security check to access example-site.dev

\n
\n\n
\n
\n
\n
\n \n
\n
\n \n \n
\n \n
\n\n \n\n
\n
\n\n
\n
\n\n \n\n
\n
\n
\n
\n
\n\n
\n
\n
\n

Why do I have to complete a CAPTCHA?

\n\n

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

\n
\n\n
\n

What can I do to prevent this in the future?

\n\n\n

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

\n\n

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

\n\n
\n
\n
\n\n\n \n\n\n
\n
\n\n \n\n\n\n" at new StatusCodeError (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:185:22) at onRequestComplete (/home/travis/build/codemanki/cloudscraper/index.js:77:321) at onCloudflareResponse (/home/travis/build/codemanki/cloudscraper/index.js:43:23) at onRequestResponse (/home/travis/build/codemanki/cloudscraper/index.js:39:232) at Request. (/home/travis/build/codemanki/cloudscraper/index.js:29:376) at Object.onceWrapper (events.js:300:26) at Request.emit (events.js:210:5) at Request. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1161:10) at Request.emit (events.js:210:5) at IncomingMessage. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 4) should resolve reCAPTCHA (version as on 10.04.2019) when the onCaptcha promise resolves Unhandled rejection StatusCodeError: 403 - "\n\n\n\n \n\nAttention Required! | Cloudflare\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n
Please enable cookies.
\n
\n
\n

One more step

\n

Please complete the security check to access example-site.dev

\n
\n\n
\n
\n
\n
\n \n
\n
\n \n \n
\n \n
\n\n \n\n
\n
\n\n
\n
\n\n \n\n
\n
\n
\n
\n
\n\n
\n
\n
\n

Why do I have to complete a CAPTCHA?

\n\n

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

\n
\n\n
\n

What can I do to prevent this in the future?

\n\n\n

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

\n\n

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

\n\n
\n
\n
\n\n\n \n\n\n
\n
\n\n \n\n\n\n" at new StatusCodeError (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:185:22) at onRequestComplete (/home/travis/build/codemanki/cloudscraper/index.js:77:321) at onCloudflareResponse (/home/travis/build/codemanki/cloudscraper/index.js:43:23) at onRequestResponse (/home/travis/build/codemanki/cloudscraper/index.js:39:232) at Request. (/home/travis/build/codemanki/cloudscraper/index.js:29:376) at Object.onceWrapper (events.js:300:26) at Request.emit (events.js:210:5) at Request. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1161:10) at Request.emit (events.js:210:5) at IncomingMessage. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 5) should callback with an error if the onCaptcha promise is rejected Unhandled rejection StatusCodeError: 403 - "\n\n\n\n \n\nAttention Required! | Cloudflare\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n
Please enable cookies.
\n
\n
\n

One more step

\n

Please complete the security check to access example-site.dev

\n
\n\n
\n
\n
\n
\n \n
\n
\n \n \n
\n \n
\n\n \n\n
\n
\n\n
\n
\n\n \n\n
\n
\n
\n
\n
\n\n
\n
\n
\n

Why do I have to complete a CAPTCHA?

\n\n

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

\n
\n\n
\n

What can I do to prevent this in the future?

\n\n\n

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

\n\n

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

\n\n
\n
\n
\n\n\n \n\n\n
\n
\n\n \n\n\n\n" at new StatusCodeError (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback [as _callback] (/home/travis/build/codemanki/cloudscraper/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:185:22) at onRequestComplete (/home/travis/build/codemanki/cloudscraper/index.js:77:321) at onCloudflareResponse (/home/travis/build/codemanki/cloudscraper/index.js:43:23) at onRequestResponse (/home/travis/build/codemanki/cloudscraper/index.js:39:232) at Request. (/home/travis/build/codemanki/cloudscraper/index.js:29:376) at Object.onceWrapper (events.js:300:26) at Request.emit (events.js:210:5) at Request. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1161:10) at Request.emit (events.js:210:5) at IncomingMessage. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) Email (lib) ✓ should not modify unprotected html ✓ should remove email protection ✓ should replace anchors that have a data-cfemail attribute ✓ should replace spans that have a data-cfemail attribute ✓ should be space agnostic ✓ should not replace nodes if they have children ✓ should not replace malformed html ✓ should account for self-closing nodes ✓ should update href attribute values Cloudscraper ✓ should return error if it was thrown by request ✓ should return error if cloudflare response is empty 6) should return error if captcha is served by cloudflare Unhandled rejection ParserError: ### Cloudflare may have changed their technique, or there may be a bug. ### Bug Reports: https://github.com/codemanki/cloudscraper/issues ### Check the detailed exception message that follows for the cause. challengeId (jschl_vc) extraction failed at onChallenge (/home/travis/build/codemanki/cloudscraper/index.js:47:993) at onCloudflareResponse (/home/travis/build/codemanki/cloudscraper/index.js:42:107) at onRequestResponse (/home/travis/build/codemanki/cloudscraper/index.js:39:232) at Request. (/home/travis/build/codemanki/cloudscraper/index.js:29:376) at Object.onceWrapper (events.js:300:26) at Request.emit (events.js:210:5) at Request. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1161:10) at Request.emit (events.js:210:5) at IncomingMessage. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) ✓ should return error if cloudflare returned some inner error ✓ should add a description to 5xx range cloudflare errors ✓ should not error if error description is unavailable ✓ should return error if cf presented more than 3 challenges in a row (74ms) ✓ should return error if body is undefined - should return error if content-type is brotli and missing dep ✓ should return error if challenge page failed to be parsed ✓ should return error if js challenge has error during evaluation ✓ should return error if pass extraction fails ✓ should return error if challengeId extraction fails ✓ should return error if challenge answer is not a number ✓ should return error if it was thrown by request when solving challenge 7) should properly handle a case when after a challenge another one is returned Unhandled rejection ParserError: ### Cloudflare may have changed their technique, or there may be a bug. ### Bug Reports: https://github.com/codemanki/cloudscraper/issues ### Check the detailed exception message that follows for the cause. challengeId (jschl_vc) extraction failed at onChallenge (/home/travis/build/codemanki/cloudscraper/index.js:47:993) at onCloudflareResponse (/home/travis/build/codemanki/cloudscraper/index.js:42:107) at onRequestResponse (/home/travis/build/codemanki/cloudscraper/index.js:39:232) at Request. (/home/travis/build/codemanki/cloudscraper/index.js:29:376) at Object.onceWrapper (events.js:300:26) at Request.emit (events.js:210:5) at Request. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1161:10) at Request.emit (events.js:210:5) at IncomingMessage. (/home/travis/build/codemanki/cloudscraper/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:299:28) at IncomingMessage.emit (events.js:215:7) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) ✓ should return error if challenge page cookie extraction fails ✓ should throw a TypeError if callback is not a function (123ms) ✓ should throw a TypeError if requester is not a function ✓ should throw a TypeError if challengesToSolve is not a number ✓ should throw a TypeError if cloudflareMaxTimeout is not a number ✓ should return error if cookie setting code evaluation fails ✓ should not error if Error.captureStackTrace is undefined Headers (lib) ✓ should export getDefaultHeaders function ✓ should export caseless function ✓ caseless should return an object with lowercase keys ✓ getDefaultHeaders should always return an object with user agent ✓ getDefaultHeaders should always retain insertion order Cloudscraper ✓ should return requested page, in the specified encoding ✓ should return parsed JSON ✓ should decompress Brotli and return parsed JSON ✓ should return requested data, if cloudflare is disabled for page ✓ should return requested page, if cloudflare is disabled for page ✓ should not trigger any error if recaptcha is present in page not protected by CF ✓ should resolve challenge (version as on 21.05.2015) and then return page ✓ should resolve challenge (version as on 09.06.2016) and then return page ✓ should resolve challenge (version as on 13.03.2019) and then return page ✓ should resolve challenge (version as on 21.03.2019) and then return page ✓ should resolve challenge (version as on 10.04.2019) and then return page ✓ should resolve challenge (version as on 28.11.2019) and then return page ✓ should resolve 2 consequent challenges ✓ should make post request with formData ✓ should make delete request ✓ should return raw data when encoding is null ✓ should resolve sucuri WAF (version as on 18.08.2016) and then return page ✓ should resolve sucuri WAF (version as on 11.08.2019) and then return page ✓ should not use proxy's uri ✓ should reuse the provided cookie jar ✓ should define custom defaults function ✓ should decode emails ✓ should not error when using the baseUrl option ✓ should use the provided cloudflare timeout (58ms) ✓ sandbox.document.getElementById should not error Cloudscraper ✓ should resolve with response body ✓ should resolve with full response ✓ should define catch ✓ should define finally Sandbox (lib) ✓ should export Context ✓ should export eval ✓ new Context() should return an object ✓ Context() should define atob ✓ Context() should define location.reload ✓ Context() should define document.createElement ✓ Context() should define document.geElementById 76 passing (854ms) 2 pending 7 failing 1) Cloudscraper should handle onCaptcha promise being rejected with a falsy error: Uncaught AssertionError: expected null to be an instance of CaptchaError at Proxy.assertInstanceOf (node_modules/chai/lib/chai/core/assertions.js:1676:10) at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25) at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22) at Proxy. (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20) at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33) at Request._rp_callbackOrig (test/test-captcha.js:60:27) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onRequestComplete (index.js:77:321) at onCloudflareResponse (index.js:43:23) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 2) Cloudscraper should resolve reCAPTCHA (version as on 10.04.2019) when user calls captcha.submit(): Uncaught AssertionError: expected spy to have been called exactly once, but it was called 0 times at Assertion. (node_modules/sinon-chai/lib/sinon-chai.js:83:18) at Assertion.propertyGetter (node_modules/chai/lib/chai/utils/addProperty.js:62:29) at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22) at Assertion. (node_modules/chai-as-promised/lib/chai-as-promised.js:280:43) at Assertion.overwritingPropertyGetter (node_modules/chai/lib/chai/utils/overwriteProperty.js:79:37) at Object.get () at Object.proxyGetter [as get] (node_modules/chai/lib/chai/utils/proxify.js:98:22) at Request._rp_callbackOrig (test/test-captcha.js:153:36) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onRequestComplete (index.js:77:321) at onCloudflareResponse (index.js:43:23) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 3) Cloudscraper should callback with an error if user calls captcha.submit(error): Uncaught AssertionError: expected null to be an instance of CaptchaError at Proxy.assertInstanceOf (node_modules/chai/lib/chai/core/assertions.js:1676:10) at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25) at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22) at Proxy. (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20) at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33) at Request._rp_callbackOrig (test/test-captcha.js:164:33) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onRequestComplete (index.js:77:321) at onCloudflareResponse (index.js:43:23) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 4) Cloudscraper should resolve reCAPTCHA (version as on 10.04.2019) when the onCaptcha promise resolves: Uncaught AssertionError: expected spy to have been called exactly once, but it was called 0 times at Assertion. (node_modules/sinon-chai/lib/sinon-chai.js:83:18) at Assertion.propertyGetter (node_modules/chai/lib/chai/utils/addProperty.js:62:29) at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22) at Assertion. (node_modules/chai-as-promised/lib/chai-as-promised.js:280:43) at Assertion.overwritingPropertyGetter (node_modules/chai/lib/chai/utils/overwriteProperty.js:79:37) at Object.get () at Object.proxyGetter [as get] (node_modules/chai/lib/chai/utils/proxify.js:98:22) at Request._rp_callbackOrig (test/test-captcha.js:153:36) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onRequestComplete (index.js:77:321) at onCloudflareResponse (index.js:43:23) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 5) Cloudscraper should callback with an error if the onCaptcha promise is rejected: Uncaught AssertionError: expected null to be an instance of CaptchaError at Proxy.assertInstanceOf (node_modules/chai/lib/chai/core/assertions.js:1676:10) at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25) at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22) at Proxy. (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20) at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33) at Request._rp_callbackOrig (test/test-captcha.js:164:33) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onRequestComplete (index.js:77:321) at onCloudflareResponse (index.js:43:23) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 6) Cloudscraper should return error if captcha is served by cloudflare: Uncaught AssertionError: expected { Object (name, message) } to be an instance of CaptchaError at Proxy.assertInstanceOf (node_modules/chai/lib/chai/core/assertions.js:1676:10) at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25) at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22) at Proxy. (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20) at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33) at Request._rp_callbackOrig (test/test-errors.js:86:27) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onChallenge (index.js:47:984) at onCloudflareResponse (index.js:42:107) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) 7) Cloudscraper should properly handle a case when after a challenge another one is returned: Uncaught AssertionError: expected { Object (name, message) } to be an instance of CaptchaError at Proxy.assertInstanceOf (node_modules/chai/lib/chai/core/assertions.js:1676:10) at Proxy.methodWrapper (node_modules/chai/lib/chai/utils/addMethod.js:57:25) at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:289:22) at Proxy. (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20) at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33) at Request._rp_callbackOrig (test/test-errors.js:370:27) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onChallenge (index.js:47:984) at onCloudflareResponse (index.js:42:107) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1200:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) ------------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ------------------|----------|----------|----------|----------|-------------------| All files | 70.44 | 61.29 | 78.38 | 70.67 | | cloudscraper | 66.45 | 61.7 | 70.83 | 66.89 | | errors.js | 100 | 100 | 100 | 100 | | index.js | 61.6 | 58.14 | 63.16 | 62.07 |... 46,548,549,552 | cloudscraper/lib | 90.16 | 57.14 | 92.31 | 89.83 | | brotli.js | 70.59 | 33.33 | 66.67 | 70.59 | 18,19,27,28,31 | email-decode.js | 100 | 100 | 100 | 100 | | headers.js | 93.33 | 50 | 100 | 93.33 | 23 | sandbox.js | 100 | 100 | 100 | 100 | | ------------------|----------|----------|----------|----------|-------------------| npm ERR! Test failed. See above for more details. ```

Node.js: 8

View build log

npm test ``` > cloudscraper@4.4.0 test /home/travis/build/codemanki/cloudscraper > npm run lint && npm run test:typescript && nyc --reporter=html --reporter=text mocha > cloudscraper@4.4.0 lint /home/travis/build/codemanki/cloudscraper > eslint --ext .json --ext .js --ext .ts . /home/travis/build/codemanki/cloudscraper/index.d.ts 80:40 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any ✖ 1 problem (0 errors, 1 warning) > cloudscraper@4.4.0 test:typescript /home/travis/build/codemanki/cloudscraper > tsc *.ts --noEmit && tsd Brotli (lib) ✓ should be available ✓ should have a decompress method ✓ decompress() should accept exactly 1 argument ✓ decompress() should accept buffer as input - [internal] decompress() should produce the expected result ✓ [external] decompress() should produce the expected result (518ms) ✓ optional() should throw an error if the module contains an error Cloudscraper 1) should handle onCaptcha promise being rejected with a falsy error /home/travis/build/codemanki/cloudscraper/node_modules/brotli/build/encode.js:3 1 (node_modules/chai-as-promised/lib/chai-as-promised.js:255:20) at Proxy.overwritingMethodWrapper (node_modules/chai/lib/chai/utils/overwriteMethod.js:78:33) at Request._rp_callbackOrig (test/test-captcha.js:60:27) at Request.plumbing.callback (node_modules/request-promise-core/lib/plumbing.js:76:39) at Request.RP$callback [as _callback] (node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (node_modules/request/request.js:185:22) at onRequestComplete (index.js:77:321) at onCloudflareResponse (index.js:43:23) at onRequestResponse (index.js:39:232) at Request. (index.js:29:376) at Request. (node_modules/request/request.js:1161:10) at IncomingMessage. (node_modules/request/request.js:1083:12) at endReadableNT (_stream_readable.js:1064:12) at _combinedTickCallback (internal/process/next_tick.js:139:11) at process._tickCallback (internal/process/next_tick.js:181:9) ----------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ----------|----------|----------|----------|----------|-------------------| All files | 0 | 0 | 0 | 0 | | ----------|----------|----------|----------|----------|-------------------| npm ERR! Test failed. See above for more details. ```
TravisBuddy Request Identifier: ad959b40-149f-11ea-b320-67c429a7bc90
drdokk commented 4 years ago

Now I guess CI is failing because of tests (I din't provide test update for this)

Bassintag commented 4 years ago

Please merge this, it fixed the issues with the captcha challenge

codemanki commented 4 years ago

@Bassintag I will, but I need to fix the tests first. Hopefully will do it today

Bassintag commented 4 years ago

@Bassintag I will, but I need to fix the tests first. Hopefully will do it today

Great thank you very much, this is pretty critical for our application

codemanki commented 4 years ago

@Bassintag you could then help me out and look into fixing the specs ;) Just saying

Bassintag commented 4 years ago

@codemanki true, not much free time right now but in the future I will definitely try to get involved, but I got to get familiar with the codebase first

codemanki commented 4 years ago

@Bassintag no problem. Thanks, hope to see some contributions from you in future

codemanki commented 4 years ago

Thank you @drdokk !