2025-04-12 14:33:36 +01:00
# @cap.js/solver
2025-07-02 13:12:54 +01:00
`@cap.js/solver` is a standalone library that can be used to solve Cap challenges from the server. It's extremely simple (no dependencies, one single file) yet as fast and efficient as the widget. Note that it can **only be used with Bun** . Node.js support is not planned.
2025-04-12 14:33:36 +01:00
## Installation
```bash
bun add @cap.js/solver
```
## Usage
2025-07-02 13:12:54 +01:00
#### From seeded challenges
2025-04-12 14:33:36 +01:00
```js
import solver from "@cap.js/solver" ;
2025-07-02 13:12:54 +01:00
console . log (
await solver ( "challenge token" , {
c : 50 , // challenge count
s : 32 , // salt size
d : 4 , // difficulty
})
);
```
#### From challenge list
```js
import solver from "@cap.js/solver" ;
const challenges = [
2025-04-12 14:33:36 +01:00
[ "a5b6fda4aaed97cf61d7dd9259f733b5" , "d455" ],
[ "286bcc39249f9ee698314b600c32e40f" , "f0ff" ],
[ "501350aa7c46573cb604284554045703" , "4971" ],
[ "a55c02f3b9b4cd088a5a7ee3d4941c14" , "eab7" ],
[ "5f3362c12e2779f56f4ef75b4494f5e6" , "999f" ],
/* ... */
];
2025-07-02 13:12:54 +01:00
console . log ( await solver ( challenges ));
2025-04-12 14:33:36 +01:00
```
**Output:**
```json
2025-07-02 13:12:54 +01:00
[ 67302 , 64511 , 40440 , 27959 , 71259 /* ... */ ]
2025-04-12 14:33:36 +01:00
```
2025-04-12 14:36:01 +01:00
2025-07-02 13:12:54 +01:00
The 2nd argument is optional but can always be provided. It's always an object.
- For **all challenge types** , `workerCount` indicates the number of workers to use (default is the number of CPU cores).
- For **all challenge types** , `onProgress` can also be used to provide a callback for progress updates.
- For **seeded challenges only** , it is used to specify the number of solutions to generate, the size of the challenges, and the difficulty
2025-04-12 14:36:01 +01:00
## FAQ
### Why is this needed?
2025-07-02 13:12:54 +01:00
2025-05-30 17:52:07 +01:00
Mainly for M2M interactions, where you want to solve Cap challenges on the server without user interaction.
2025-04-12 14:36:01 +01:00
### Doesn't this defeat the purpose of Cap?
2025-07-02 13:12:54 +01:00
Not really. Server-side solving is a core use case of proof-of-work CAPTCHAs like Cap or altcha. It's about proving effort, not necessarily involving a human. [Learn more ](./effectiveness.md )