@apifuse/provider-sdk 2.2.0-beta.31 → 2.2.0-beta.33
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 +9 -0
- package/dist/error-resolution.js +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +1 -1
- package/dist/runtime/browser.d.ts +1 -0
- package/dist/runtime/browser.js +344 -27
- package/dist/runtime/choice.d.ts +0 -1
- package/dist/runtime/choice.js +1 -78
- package/dist/runtime/resolver-vendors/browser.d.ts +2 -0
- package/dist/runtime/resolver-vendors/browser.js +68 -16
- package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
- package/dist/runtime/resolver-vendors/capsolver.js +526 -0
- package/dist/runtime/resolver-vendors/twocaptcha.js +46 -13
- package/dist/runtime/resolver-vendors/types.d.ts +1 -1
- package/dist/runtime/resolver-vendors/types.js +6 -3
- package/dist/runtime/resolver.d.ts +1 -1
- package/dist/runtime/resolver.js +19 -4
- package/dist/server/serve-implementation.js +1 -2
- package/dist/types.d.ts +9 -1
- package/package.json +1 -1
- package/src/error-resolution.ts +0 -1
- package/src/index.ts +0 -1
- package/src/provider.ts +0 -1
- package/src/runtime/browser.ts +430 -31
- package/src/runtime/choice.ts +1 -91
- package/src/runtime/resolver-vendors/browser.ts +82 -15
- package/src/runtime/resolver-vendors/capsolver.ts +700 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +43 -8
- package/src/runtime/resolver-vendors/types.ts +6 -3
- package/src/runtime/resolver.ts +21 -6
- package/src/server/serve-implementation.ts +0 -2
- package/src/types.ts +10 -1
package/dist/runtime/resolver.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ProviderError } from "../errors.js";
|
|
|
4
4
|
import { getStealthProfile } from "../stealth/profiles.js";
|
|
5
5
|
import { resolverChallengeAllowsDirectCache, resolverChallengeIsCacheable, resolverChallengeIsIdentityScoped, resolverChallengeIssuingIdentity, } from "./resolver-vendors/bindings.js";
|
|
6
6
|
import { createBrowserResolverVendorAdapter } from "./resolver-vendors/browser.js";
|
|
7
|
+
import { createCapsolverResolverVendorAdapter } from "./resolver-vendors/capsolver.js";
|
|
7
8
|
import { assertResolverHostAllowed } from "./resolver-vendors/hosts.js";
|
|
8
9
|
import { createTwoCaptchaResolverVendorAdapter } from "./resolver-vendors/twocaptcha.js";
|
|
9
10
|
import { RESOLVER_VENDOR_CAPABILITIES, ResolverVendorUnavailableError, resolverVendorSupports, } from "./resolver-vendors/types.js";
|
|
@@ -55,12 +56,22 @@ const SAFE_CAUSE_MESSAGE_WORDS = new Set([
|
|
|
55
56
|
]);
|
|
56
57
|
const resolverAdapterRegistry = {
|
|
57
58
|
"2captcha"(configuration, timeoutMs, allowedHosts) {
|
|
59
|
+
if (configuration === undefined) {
|
|
60
|
+
throw new Error("2captcha resolver adapter factory requires an API key");
|
|
61
|
+
}
|
|
58
62
|
return createTwoCaptchaResolverVendorAdapter({
|
|
59
63
|
allowedHosts,
|
|
60
64
|
apiKey: configuration,
|
|
61
65
|
timeoutMs,
|
|
62
66
|
});
|
|
63
67
|
},
|
|
68
|
+
capsolver(configuration, timeoutMs, allowedHosts) {
|
|
69
|
+
return createCapsolverResolverVendorAdapter({
|
|
70
|
+
allowedHosts,
|
|
71
|
+
apiKey: configuration,
|
|
72
|
+
timeoutMs,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
64
75
|
browser(configuration, timeoutMs, allowedHosts) {
|
|
65
76
|
return createBrowserResolverVendorAdapter({
|
|
66
77
|
allowedHosts,
|
|
@@ -104,7 +115,6 @@ export function swapResolverDefaultUserAgentForTests(resolver) {
|
|
|
104
115
|
// This is the sole allowlist for declared vendors whose registry entry may be absent.
|
|
105
116
|
// Remove a vendor here when its adapter is registered.
|
|
106
117
|
const KNOWN_UNIMPLEMENTED_RESOLVER_VENDORS = new Set([
|
|
107
|
-
"capsolver",
|
|
108
118
|
"capmonster",
|
|
109
119
|
"custom",
|
|
110
120
|
]);
|
|
@@ -636,13 +646,18 @@ function resolveVendorAvailability(vendor, env) {
|
|
|
636
646
|
reason: "missing_transport",
|
|
637
647
|
};
|
|
638
648
|
}
|
|
649
|
+
if (vendor === "browser") {
|
|
650
|
+
return {
|
|
651
|
+
vendor,
|
|
652
|
+
available: true,
|
|
653
|
+
configuration: normalizedEnvValue(env, APIFUSE__CDP_POOL__URL),
|
|
654
|
+
};
|
|
655
|
+
}
|
|
639
656
|
const envKey = vendor === "2captcha"
|
|
640
657
|
? APIFUSE__RESOLVER__2CAPTCHA__API_KEY
|
|
641
658
|
: vendor === "capsolver"
|
|
642
659
|
? APIFUSE__RESOLVER__CAPSOLVER__API_KEY
|
|
643
|
-
:
|
|
644
|
-
? APIFUSE__RESOLVER__CAPMONSTER__API_KEY
|
|
645
|
-
: APIFUSE__CDP_POOL__URL;
|
|
660
|
+
: APIFUSE__RESOLVER__CAPMONSTER__API_KEY;
|
|
646
661
|
const configuration = normalizedEnvValue(env, envKey);
|
|
647
662
|
return configuration
|
|
648
663
|
? { vendor, available: true, configuration }
|
|
@@ -11,7 +11,7 @@ import { loadProviderLocaleCatalogs, localizeAuthTurn, } from "../i18n/catalog.j
|
|
|
11
11
|
import { categoryForStatus, sourceForCategory, isRetryableCategory, PROVIDER_OBSERVABILITY_TAXONOMY_VERSION, } from "../observability.js";
|
|
12
12
|
import { createScratchpad } from "../runtime/auth-flow.js";
|
|
13
13
|
import { createProviderCache } from "../runtime/cache.js";
|
|
14
|
-
import { createProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV,
|
|
14
|
+
import { createProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "../runtime/choice.js";
|
|
15
15
|
import { createCredentialContext } from "../runtime/credential.js";
|
|
16
16
|
import { createEnvContext } from "../runtime/env.js";
|
|
17
17
|
import { executeOperation } from "../runtime/executor.js";
|
|
@@ -376,7 +376,6 @@ function createProviderContext(provider, request, operationId, options, state =
|
|
|
376
376
|
const env = createEnvContext([
|
|
377
377
|
...(provider.secrets?.map((secret) => secret.name) ?? []),
|
|
378
378
|
PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV,
|
|
379
|
-
PROVIDER_RUNTIME_CHOICE_WORD_ISSUANCE_ENV,
|
|
380
379
|
]);
|
|
381
380
|
const credential = createCredentialContext({
|
|
382
381
|
allowedKeys: provider.credential?.keys,
|
package/dist/types.d.ts
CHANGED
|
@@ -1451,7 +1451,7 @@ export interface BrowserCookie {
|
|
|
1451
1451
|
readonly secure: boolean;
|
|
1452
1452
|
readonly sameSite?: "Strict" | "Lax" | "None";
|
|
1453
1453
|
}
|
|
1454
|
-
export type BrowserResourceMethod = "GET" | "HEAD";
|
|
1454
|
+
export type BrowserResourceMethod = "GET" | "HEAD" | "POST";
|
|
1455
1455
|
export type BrowserResourceRequest = {
|
|
1456
1456
|
readonly url: string;
|
|
1457
1457
|
readonly method: BrowserResourceMethod;
|
|
@@ -1460,6 +1460,8 @@ export type BrowserResourceRequest = {
|
|
|
1460
1460
|
};
|
|
1461
1461
|
export type BrowserResourceBody = Buffer | Uint8Array | ArrayBuffer | string;
|
|
1462
1462
|
export type BrowserResourceDecision = {
|
|
1463
|
+
readonly action: "continue";
|
|
1464
|
+
} | {
|
|
1463
1465
|
readonly action: "fulfill";
|
|
1464
1466
|
readonly status?: number;
|
|
1465
1467
|
readonly headers?: Readonly<Record<string, string>>;
|
|
@@ -1475,6 +1477,12 @@ export type BrowserResourceRoute = {
|
|
|
1475
1477
|
export type BrowserResourcePolicy = {
|
|
1476
1478
|
readonly defaultAction?: "block";
|
|
1477
1479
|
readonly allowedMethods?: readonly BrowserResourceMethod[];
|
|
1480
|
+
/**
|
|
1481
|
+
* Appends an enforcing CSP header to every renderable document response
|
|
1482
|
+
* while the policy is active. Existing CSP headers are retained, so this
|
|
1483
|
+
* can only further restrict the document.
|
|
1484
|
+
*/
|
|
1485
|
+
readonly documentContentSecurityPolicy?: string;
|
|
1478
1486
|
readonly routes: readonly BrowserResourceRoute[];
|
|
1479
1487
|
};
|
|
1480
1488
|
export interface BrowserPage extends BrowserFrame {
|
package/package.json
CHANGED
package/src/error-resolution.ts
CHANGED
|
@@ -20,7 +20,6 @@ export const SDK_OWNED_PROVIDER_ERROR_CODES = new Set([
|
|
|
20
20
|
"RUNTIME_UNSUPPORTED",
|
|
21
21
|
"PROVIDER_STATE_UNSUPPORTED",
|
|
22
22
|
"CHOICE_TOKEN_MASTER_SECRET_NOT_CONFIGURED",
|
|
23
|
-
"CHOICE_WORD_ISSUANCE_INVALID",
|
|
24
23
|
"CHOICE_STATE_PAYLOAD_TOO_LARGE",
|
|
25
24
|
"CHOICE_STATE_UNAVAILABLE",
|
|
26
25
|
"CHOICE_CONTEXT_REQUIRED",
|
package/src/index.ts
CHANGED
package/src/provider.ts
CHANGED