@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.
@@ -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
- : vendor === "capmonster"
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, PROVIDER_RUNTIME_CHOICE_WORD_ISSUANCE_ENV, } from "../runtime/choice.js";
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0-beta.31",
2
+ "version": "2.2.0-beta.33",
3
3
  "name": "@apifuse/provider-sdk",
4
4
  "private": false,
5
5
  "type": "module",
@@ -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
@@ -61,7 +61,6 @@ export {
61
61
  createProviderChoiceContext,
62
62
  createTestProviderChoiceContext,
63
63
  PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV,
64
- PROVIDER_RUNTIME_CHOICE_WORD_ISSUANCE_ENV,
65
64
  } from "./runtime/choice.js";
66
65
  export {
67
66
  type CreateCredentialContextOptions,
package/src/provider.ts CHANGED
@@ -56,7 +56,6 @@ export {
56
56
  createProviderChoiceContext,
57
57
  createTestProviderChoiceContext,
58
58
  PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV,
59
- PROVIDER_RUNTIME_CHOICE_WORD_ISSUANCE_ENV,
60
59
  } from "./runtime/choice.js";
61
60
  export {
62
61
  APIFUSE_DESCRIPTION_KEY_META_KEY,