From 29f4e21bf2351bef5e5c607a5a215be63922ca13 Mon Sep 17 00:00:00 2001 From: Max Shyn Date: Sun, 18 Feb 2024 00:40:33 +0600 Subject: [PATCH 1/5] remove node-version --- .github/workflows/coverage-report.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/coverage-report.yaml b/.github/workflows/coverage-report.yaml index 1ecf2b0..646e140 100644 --- a/.github/workflows/coverage-report.yaml +++ b/.github/workflows/coverage-report.yaml @@ -6,10 +6,6 @@ jobs: pr_pipeline: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] - if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - uses: actions/checkout@v3 From 0abbb1e53cfe29adae9d7aea5da7d048cc216aa1 Mon Sep 17 00:00:00 2001 From: Max Shyn Date: Sun, 18 Feb 2024 00:53:32 +0600 Subject: [PATCH 2/5] Install deps run --- .github/workflows/coverage-report.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage-report.yaml b/.github/workflows/coverage-report.yaml index 646e140..a171dae 100644 --- a/.github/workflows/coverage-report.yaml +++ b/.github/workflows/coverage-report.yaml @@ -22,7 +22,14 @@ jobs: cache: npm - name: Install Dependencies - run: npm ci + run: | + if [ -e yarn.lock ]; then + yarn install --frozen-lockfile + elif [ -e package-lock.json ]; then + npm ci + else + npm i + fi - name: Build (Nx Affected) uses: mansagroup/nrwl-nx-action@v2 From 41a55c3e6cdb7032b5f2e342224a2d6711f907f9 Mon Sep 17 00:00:00 2001 From: Max Shyn Date: Sun, 18 Feb 2024 00:54:42 +0600 Subject: [PATCH 3/5] Install deps run --- .github/workflows/coverage-report.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage-report.yaml b/.github/workflows/coverage-report.yaml index 646e140..af9f640 100644 --- a/.github/workflows/coverage-report.yaml +++ b/.github/workflows/coverage-report.yaml @@ -22,7 +22,7 @@ jobs: cache: npm - name: Install Dependencies - run: npm ci + run: npm install && npm ci - name: Build (Nx Affected) uses: mansagroup/nrwl-nx-action@v2 From 86aa69e8ebeee4410f5fb17a056fc385bc537480 Mon Sep 17 00:00:00 2001 From: Max Shyn Date: Sun, 18 Feb 2024 02:27:54 +0600 Subject: [PATCH 4/5] Workflow --- .github/workflows/coverage-report.yaml | 39 +++++--------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/.github/workflows/coverage-report.yaml b/.github/workflows/coverage-report.yaml index af9f640..28f6f3f 100644 --- a/.github/workflows/coverage-report.yaml +++ b/.github/workflows/coverage-report.yaml @@ -23,48 +23,23 @@ jobs: - name: Install Dependencies run: npm install && npm ci - - - name: Build (Nx Affected) - uses: mansagroup/nrwl-nx-action@v2 - with: - targets: build - affected: true - nxCloud: false - - - name: Lint (Nx Affected) - uses: mansagroup/nrwl-nx-action@v2 - with: - targets: lint - affected: true - nxCloud: false - + - name: Test with Coverage (Nx Affected) - uses: mansagroup/nrwl-nx-action@v2 - with: - targets: test - affected: true - nxCloud: false - args: '--coverage --coverageReporters=json,json-summary' + run: 'rm -rf coverage && npx nx affected -t test --skip-nx-cache --coverage --coverageReporters=json,json-summary' - - name: Download Artifact (base code coverage results) - uses: dawidd6/action-download-artifact@v2 - id: restoreCodeCoverage + - name: Archive сode сoverage results + uses: actions/upload-artifact@v3 with: - workflow: coverage-report.yaml - workflow_conclusion: success - branch: main name: code-coverage-report - path: ./coverage-base - continue-on-error: true + path: ./coverage/**/coverage-summary.json + if-no-files-found: error - - name: Comment Code Coverage on PR + - name: Code сoverage uses: dkhunt27/nx-code-coverage@v1 with: github-token: ${{ secrets.AUTH_TOKEN }} no-coverage-ran: false coverage-folder: ./coverage - coverage-base-folder: ./coverage-base - gist-processing: true gist-token: ${{ secrets.GIST_SECRET }} gist-id: d34d7d9392f4f0e6aa927cb035b86d34 color: green From 47dd23866f82d0e3f0667cbc8c3f2086bf9cfa4f Mon Sep 17 00:00:00 2001 From: Max Shyn Date: Sun, 18 Feb 2024 02:46:00 +0600 Subject: [PATCH 5/5] Update docs --- capsolver/README.md | 46 ++++++++++++++------ capsolver/package-lock.json | 85 +++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 12 deletions(-) create mode 100644 capsolver/package-lock.json diff --git a/capsolver/README.md b/capsolver/README.md index 6f65eaa..6bafecb 100644 --- a/capsolver/README.md +++ b/capsolver/README.md @@ -8,40 +8,62 @@ Docs: https://docs.capsolver.com ## Installation Via [npm](https://www.npmjs.com/package/@captcha-libs/capsolver) ```npm i @captcha-libs/capsolver``` +pnpm + ```$ pnpm i @captcha-libs/capsolver``` +yarn + ```$ yarn add @captcha-libs/capsolver``` -Usage +### Usage ```javascript +//import CapSolver client and desired task import { CapSolver, ReCaptchaV3EnterpriseTask } from "@captcha-libs/capsolver"; const capsolverClient = new CapSolver({ clientKey: "", - pollingInterval: 5000, //optional. Delay in milliseconds to fetch task result, default: 5000ms - timeout: 120_000 //optional. Max time in milliseconds to wait for settled task result, default: 120000ms + pollingInterval: 5000, // optional. Delay in milliseconds to fetch task result, default: 5000ms + timeout: 120_000 // optional. Max time in milliseconds to wait for settled task result, default: 120000ms }); + +// Pass captcha params to solve const reCaptchaV3Request = new ReCaptchaV3EnterpriseTask({ - proxy: "http:ip:port:user:pass", - websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", - websiteURL: "https://www.google.com/recaptcha/api2/demo" -}); + proxy: "http:ip:port:user:pass", + websiteKey: "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", + websiteURL: "https://www.google.com/recaptcha/api2/demo" +}); +// returns solution or throws an exception const reCaptchaV3Solution = await capsolverClient.solve(reCaptchaV3Request); const { - solution: { expireTime, gRecaptchaResponse, userAgent, taskId } + solution, //returns generic captcha type specific solution + errorId, + errorCode, + errorDescription, + status } = reCaptchaV3Solution; +const { + gRecaptchaResponse, userAgent, expireTime +} = solution; + //if you want to submit feedback const feedback = await capsolverClient.feedbackTask({ - taskId, - invalid: false, //is captcha solved successfully? required. - message: "success", //optional - code: 1, //optional + taskId, + invalid: false, //is captcha solved successfully? required. + message: "success", //optional + code: 1, //optional }); //to get balance const balance = await capsolverClient.getBalance() ``` +### Features +* Supports all captcha types, solutions and methods from CapSolver docs (updated at Feb. 2024) +* TypeScript-first design +* Automatically waits for solution +* Fully tested task payloads + ### Currently supported task payloads What 'custom' does mean? Custom means that the parameters and solutions have been narrowed down from the official documentation from more general cases. However, you can still use classes strictly according to the official documentation. diff --git a/capsolver/package-lock.json b/capsolver/package-lock.json new file mode 100644 index 0000000..877f94e --- /dev/null +++ b/capsolver/package-lock.json @@ -0,0 +1,85 @@ +{ + "name": "@captcha-libs/capsolver", + "version": "1.1.4", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@captcha-libs/capsolver", + "version": "1.1.4", + "license": "ISC", + "dependencies": { + "@captcha-libs/captcha-client": "latest", + "ofetch": "^1.3.3" + } + }, + "node_modules/@captcha-libs/captcha-client": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@captcha-libs/captcha-client/-/captcha-client-0.0.5.tgz", + "integrity": "sha512-oz0LIWvN0gvrE3RaJfwkwy3Sf+YVpzD8Fd2Xaqnpev+RJ7/rynHa0rupFd2W2PGFoGNR72oZWvb+ESBl6vrA8Q==", + "dependencies": { + "ofetch": "^1.3.3" + } + }, + "node_modules/destr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.2.tgz", + "integrity": "sha512-65AlobnZMiCET00KaFFjUefxDX0khFA/E4myqZ7a6Sq1yZtR8+FVIvilVX66vF2uobSumxooYZChiRPCKNqhmg==" + }, + "node_modules/node-fetch-native": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.1.tgz", + "integrity": "sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==" + }, + "node_modules/ofetch": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.3.3.tgz", + "integrity": "sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg==", + "dependencies": { + "destr": "^2.0.1", + "node-fetch-native": "^1.4.0", + "ufo": "^1.3.0" + } + }, + "node_modules/ufo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.3.2.tgz", + "integrity": "sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==" + } + }, + "dependencies": { + "@captcha-libs/captcha-client": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@captcha-libs/captcha-client/-/captcha-client-0.0.5.tgz", + "integrity": "sha512-oz0LIWvN0gvrE3RaJfwkwy3Sf+YVpzD8Fd2Xaqnpev+RJ7/rynHa0rupFd2W2PGFoGNR72oZWvb+ESBl6vrA8Q==", + "requires": { + "ofetch": "^1.3.3" + } + }, + "destr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.2.tgz", + "integrity": "sha512-65AlobnZMiCET00KaFFjUefxDX0khFA/E4myqZ7a6Sq1yZtR8+FVIvilVX66vF2uobSumxooYZChiRPCKNqhmg==" + }, + "node-fetch-native": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.1.tgz", + "integrity": "sha512-bW9T/uJDPAJB2YNYEpWzE54U5O3MQidXsOyTfnbKYtTtFexRvGzb1waphBN4ZwP6EcIvYYEOwW0b72BpAqydTw==" + }, + "ofetch": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.3.3.tgz", + "integrity": "sha512-s1ZCMmQWXy4b5K/TW9i/DtiN8Ku+xCiHcjQ6/J/nDdssirrQNOoB165Zu8EqLMA2lln1JUth9a0aW9Ap2ctrUg==", + "requires": { + "destr": "^2.0.1", + "node-fetch-native": "^1.4.0", + "ufo": "^1.3.0" + } + }, + "ufo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.3.2.tgz", + "integrity": "sha512-o+ORpgGwaYQXgqGDwd+hkS4PuZ3QnmqMMxRuajK/a38L6fTpcE5GPIfrf+L/KemFzfUpeUQc1rRS1iDBozvnFA==" + } + } +}