capskip 1.2.0 → 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.
- package/CHANGELOG.md +43 -0
- package/README.md +94 -8
- package/docs/API_REFERENCE.md +268 -2
- package/examples/captchafox.js +102 -0
- package/examples/capy.js +101 -0
- package/examples/friendly_captcha.js +115 -0
- package/package.json +1 -1
- package/src/apiParams.js +138 -0
- package/src/solver.js +205 -0
- package/types/index.d.ts +137 -5
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Type definitions for the CapSkip Node.js SDK.
|
|
2
2
|
|
|
3
|
-
/** Proxy passed to
|
|
3
|
+
/** Proxy passed to any solve except image captcha. */
|
|
4
4
|
export interface Proxy {
|
|
5
5
|
/** Proxy type: `HTTP`, `HTTPS`, `SOCKS5`, or `SOCKS5H`. */
|
|
6
6
|
type: string;
|
|
@@ -18,7 +18,11 @@ export interface CapSkipOptions {
|
|
|
18
18
|
port?: number;
|
|
19
19
|
/** Seconds to poll an image captcha before timing out. Default `120`. */
|
|
20
20
|
defaultTimeout?: number;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Seconds to poll reCAPTCHA / Turnstile / GeeTest / CaptchaFox / Friendly
|
|
23
|
+
* Captcha before timing out. Default `300`. ALTCHA and Capy use
|
|
24
|
+
* `defaultTimeout` instead — neither is a browser solve.
|
|
25
|
+
*/
|
|
22
26
|
recaptchaTimeout?: number;
|
|
23
27
|
/** Max seconds between polls; starts at `0.25` and backs off to this. Default `5`. */
|
|
24
28
|
pollingInterval?: number;
|
|
@@ -32,10 +36,15 @@ export interface SolveResult {
|
|
|
32
36
|
* The solution: recognized text for images, a token otherwise. For GeeTest
|
|
33
37
|
* this is the raw JSON string CapSkip returns — prefer the parsed
|
|
34
38
|
* `challenge` / `validate` / `seccode` fields below. For ALTCHA it is the
|
|
35
|
-
* base64 token, also exposed as `token`.
|
|
39
|
+
* base64 token, also exposed as `token`. For Capy it is the raw answer
|
|
40
|
+
* object, expanded into the three fields below.
|
|
41
|
+
*/
|
|
42
|
+
code: string | Record<string, unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Turnstile and CaptchaFox — the User-Agent to use when submitting the token.
|
|
45
|
+
* For CaptchaFox this is the browser's own, not one you sent, and it is absent
|
|
46
|
+
* when the solve captured none rather than guessed.
|
|
36
47
|
*/
|
|
37
|
-
code: string;
|
|
38
|
-
/** Turnstile only — the User-Agent to use when submitting the token. */
|
|
39
48
|
userAgent?: string;
|
|
40
49
|
/** GeeTest only — the `geetest_challenge` value to post back. */
|
|
41
50
|
challenge?: string;
|
|
@@ -50,6 +59,20 @@ export interface SolveResult {
|
|
|
50
59
|
token?: string;
|
|
51
60
|
/** ALTCHA only — the counter that solved the challenge. */
|
|
52
61
|
number?: number;
|
|
62
|
+
/** Capy only — the value for the target form's `capy_captchakey` field. */
|
|
63
|
+
captchakey?: string;
|
|
64
|
+
/** Capy only — the value for the target form's `capy_challengekey` field. */
|
|
65
|
+
challengekey?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Capy only — the value for the target form's `capy_answer` field. The drag
|
|
68
|
+
* path the widget would have recorded; submit it verbatim.
|
|
69
|
+
*/
|
|
70
|
+
answer?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Capy only — empty for a puzzle solve. Present for shape compatibility with
|
|
73
|
+
* 2Captcha's documented response; it carries nothing.
|
|
74
|
+
*/
|
|
75
|
+
respKey?: string;
|
|
53
76
|
}
|
|
54
77
|
|
|
55
78
|
/** Extra options for {@link CapSkip.normal}. */
|
|
@@ -141,6 +164,81 @@ export interface AltchaOptions {
|
|
|
141
164
|
[key: string]: unknown;
|
|
142
165
|
}
|
|
143
166
|
|
|
167
|
+
/** Extra options for {@link CapSkip.capy}. */
|
|
168
|
+
export interface CapyOptions {
|
|
169
|
+
/** Root of the Capy API the key lives behind (alias for `api_server`). */
|
|
170
|
+
apiServer?: string;
|
|
171
|
+
/** Root of the Capy API the key lives behind. Default `https://jp.api.capy.me`. */
|
|
172
|
+
api_server?: string;
|
|
173
|
+
/**
|
|
174
|
+
* The challenge family. Only `"puzzle"` (the default) is solved — `"avatar"`
|
|
175
|
+
* is refused before the request is made.
|
|
176
|
+
*/
|
|
177
|
+
version?: string;
|
|
178
|
+
/** User-Agent to send with the puzzle request (alias for `useragent`). */
|
|
179
|
+
userAgent?: string;
|
|
180
|
+
/** User-Agent to send with the puzzle request. */
|
|
181
|
+
useragent?: string;
|
|
182
|
+
/** `1` to request the raw JSON response from CapSkip. */
|
|
183
|
+
json?: number;
|
|
184
|
+
/** Proxy — used for the puzzle-image fetch, the only request a Capy solve makes. */
|
|
185
|
+
proxy?: Proxy | string;
|
|
186
|
+
/** Proxy type when `proxy` is a bare string. */
|
|
187
|
+
proxytype?: string;
|
|
188
|
+
[key: string]: unknown;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Extra options for {@link CapSkip.captchafox}. */
|
|
192
|
+
export interface CaptchaFoxOptions {
|
|
193
|
+
/** Widget entry point (alias for `api_server`). */
|
|
194
|
+
apiServer?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Widget entry point. Default `https://cdn.captchafox.com/`. The MAM package
|
|
197
|
+
* path returns a `MAM_` prefixed token instead.
|
|
198
|
+
*/
|
|
199
|
+
api_server?: string;
|
|
200
|
+
/** Accepted for compatibility and not applied (alias for `useragent`). */
|
|
201
|
+
userAgent?: string;
|
|
202
|
+
/** Accepted for compatibility and not applied — CapSkip uses its own browser. */
|
|
203
|
+
useragent?: string;
|
|
204
|
+
/** `1` to request the raw JSON response from CapSkip. */
|
|
205
|
+
json?: number;
|
|
206
|
+
/** Proxy used for solving. */
|
|
207
|
+
proxy?: Proxy | string;
|
|
208
|
+
/** Proxy type when `proxy` is a bare string. */
|
|
209
|
+
proxytype?: string;
|
|
210
|
+
[key: string]: unknown;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Extra options for {@link CapSkip.friendlyCaptcha}. */
|
|
214
|
+
export interface FriendlyCaptchaOptions {
|
|
215
|
+
/** Protocol version: `"v1"` (default) or `"v2"`; a bare `1` or `2` works too. */
|
|
216
|
+
version?: string | number;
|
|
217
|
+
/** `src` of the widget script tag carrying `type="module"` (alias). */
|
|
218
|
+
moduleScript?: string;
|
|
219
|
+
/** `src` of the widget script tag carrying `type="module"`. */
|
|
220
|
+
module_script?: string;
|
|
221
|
+
/** `src` of the widget script tag carrying `nomodule` (alias). */
|
|
222
|
+
nomoduleScript?: string;
|
|
223
|
+
/** `src` of the widget script tag carrying `nomodule`. */
|
|
224
|
+
nomodule_script?: string;
|
|
225
|
+
/** Data residency tenant (alias for `api_server`). */
|
|
226
|
+
apiServer?: string;
|
|
227
|
+
/** Data residency tenant: `"global"` (default), `"eu"`, or a full URL. */
|
|
228
|
+
api_server?: string;
|
|
229
|
+
/** User-Agent to send with the request (alias for `useragent`). */
|
|
230
|
+
userAgent?: string;
|
|
231
|
+
/** User-Agent to send with the request. */
|
|
232
|
+
useragent?: string;
|
|
233
|
+
/** `1` to request the raw JSON response from CapSkip. */
|
|
234
|
+
json?: number;
|
|
235
|
+
/** Proxy used for solving. */
|
|
236
|
+
proxy?: Proxy | string;
|
|
237
|
+
/** Proxy type when `proxy` is a bare string. */
|
|
238
|
+
proxytype?: string;
|
|
239
|
+
[key: string]: unknown;
|
|
240
|
+
}
|
|
241
|
+
|
|
144
242
|
/** Options for the {@link CapSkip.solve} manual workflow. */
|
|
145
243
|
export interface SolveOptions {
|
|
146
244
|
/** Poll timeout in seconds (falls back to the configured default). */
|
|
@@ -188,6 +286,40 @@ export class CapSkip {
|
|
|
188
286
|
* wins. Challenges expire fast, so fetch one immediately before calling.
|
|
189
287
|
*/
|
|
190
288
|
altcha(url: string, options?: AltchaOptions): Promise<SolveResult>;
|
|
289
|
+
/**
|
|
290
|
+
* Solve a Capy Puzzle captcha.
|
|
291
|
+
*
|
|
292
|
+
* `sitekey` is the site's public Capy key, conventionally prefixed `PUZZLE_`,
|
|
293
|
+
* and is sent as the `captchakey` the API documents. The result is not a
|
|
294
|
+
* token: it carries `captchakey`, `challengekey` and `answer`, all three of
|
|
295
|
+
* which go into the target form.
|
|
296
|
+
*/
|
|
297
|
+
capy(sitekey: string, url: string, options?: CapyOptions): Promise<SolveResult>;
|
|
298
|
+
/**
|
|
299
|
+
* Solve a CaptchaFox challenge.
|
|
300
|
+
*
|
|
301
|
+
* `url` has to be the page the widget actually runs on — CaptchaFox checks it
|
|
302
|
+
* against the domains the key is registered for. The result carries `token`
|
|
303
|
+
* for the form's `cf-captcha-response` field.
|
|
304
|
+
*/
|
|
305
|
+
captchafox(
|
|
306
|
+
sitekey: string,
|
|
307
|
+
url: string,
|
|
308
|
+
options?: CaptchaFoxOptions,
|
|
309
|
+
): Promise<SolveResult>;
|
|
310
|
+
/**
|
|
311
|
+
* Solve a Friendly Captcha proof-of-work challenge.
|
|
312
|
+
*
|
|
313
|
+
* Two different protocols ship under this name and a sitekey does not say
|
|
314
|
+
* which, so pass `version`, or pass `moduleScript` and let CapSkip read it off
|
|
315
|
+
* the build the site loads. The token goes into `frc-captcha-solution` on v1
|
|
316
|
+
* or `frc-captcha-response` on v2.
|
|
317
|
+
*/
|
|
318
|
+
friendlyCaptcha(
|
|
319
|
+
sitekey: string,
|
|
320
|
+
url: string,
|
|
321
|
+
options?: FriendlyCaptchaOptions,
|
|
322
|
+
): Promise<SolveResult>;
|
|
191
323
|
/** Submit then poll to completion. Used by the higher-level solve methods. */
|
|
192
324
|
solve(options?: SolveOptions): Promise<SolveResult>;
|
|
193
325
|
/** Submit a captcha without polling; resolves to the captcha id. */
|