@apifuse/provider-sdk 2.2.0-beta.25 → 2.2.0-beta.27

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.
Files changed (51) hide show
  1. package/AUTHORING.md +7 -6
  2. package/CHANGELOG.md +9 -1
  3. package/README.md +3 -3
  4. package/bin/apifuse-check.ts +62 -3
  5. package/bin/apifuse-pack-check.ts +8 -2
  6. package/bin/apifuse-pack-smoke.ts +43 -2
  7. package/bin/apifuse-pack-types.ts +58 -0
  8. package/dist/auth.js +29 -0
  9. package/dist/cli/templates/provider/README.md.tpl +4 -4
  10. package/dist/contract-serialization.js +4 -8
  11. package/dist/declaration-validation.d.ts +23 -0
  12. package/dist/declaration-validation.js +159 -0
  13. package/dist/define.d.ts +1 -1
  14. package/dist/define.js +13 -2
  15. package/dist/index.d.ts +1 -0
  16. package/dist/lint.js +85 -3
  17. package/dist/runtime/resolver-vendors/bindings.d.ts +42 -2
  18. package/dist/runtime/resolver-vendors/bindings.js +31 -6
  19. package/dist/runtime/resolver-vendors/browser.d.ts +3 -7
  20. package/dist/runtime/resolver-vendors/browser.js +7 -22
  21. package/dist/runtime/resolver-vendors/hosts.d.ts +2 -0
  22. package/dist/runtime/resolver-vendors/hosts.js +33 -0
  23. package/dist/runtime/resolver-vendors/twocaptcha.d.ts +23 -0
  24. package/dist/runtime/resolver-vendors/twocaptcha.js +264 -0
  25. package/dist/runtime/resolver-vendors/types.d.ts +44 -3
  26. package/dist/runtime/resolver-vendors/types.js +10 -0
  27. package/dist/runtime/resolver.d.ts +17 -2
  28. package/dist/runtime/resolver.js +237 -15
  29. package/dist/runtime/stealth.d.ts +26 -4
  30. package/dist/runtime/stealth.js +224 -114
  31. package/dist/server/serve.js +8 -0
  32. package/dist/stealth/profiles.js +16 -7
  33. package/dist/types.d.ts +34 -1
  34. package/package.json +2 -2
  35. package/src/auth.ts +40 -0
  36. package/src/cli/templates/provider/README.md.tpl +4 -4
  37. package/src/contract-serialization.ts +5 -7
  38. package/src/declaration-validation.ts +202 -0
  39. package/src/define.ts +23 -2
  40. package/src/index.ts +1 -0
  41. package/src/lint.ts +98 -3
  42. package/src/runtime/resolver-vendors/bindings.ts +40 -15
  43. package/src/runtime/resolver-vendors/browser.ts +9 -31
  44. package/src/runtime/resolver-vendors/hosts.ts +38 -0
  45. package/src/runtime/resolver-vendors/twocaptcha.ts +366 -0
  46. package/src/runtime/resolver-vendors/types.ts +54 -0
  47. package/src/runtime/resolver.ts +304 -24
  48. package/src/runtime/stealth.ts +317 -136
  49. package/src/server/serve.ts +8 -0
  50. package/src/stealth/profiles.ts +17 -7
  51. package/src/types.ts +36 -3
@@ -68,7 +68,7 @@ const FIREFOX_H2_SETTINGS = {
68
68
  };
69
69
 
70
70
  const SAFARI_H2_SETTINGS = {
71
- HEADER_TABLE_SIZE: 4096,
71
+ // Safari 17 also sends a connection-level WINDOW_UPDATE increment of 10485760.
72
72
  ENABLE_PUSH: 0,
73
73
  INITIAL_WINDOW_SIZE: 4194304,
74
74
  MAX_CONCURRENT_STREAMS: 100,
@@ -192,9 +192,9 @@ const STEALTH_PROFILES: Record<string, StealthProfile> = {
192
192
  }),
193
193
  "firefox-132": createProfile("firefox-132", {
194
194
  platform: "macos",
195
- version: "132.0",
195
+ version: "133.0",
196
196
  userAgent:
197
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0",
197
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0",
198
198
  tlsClientIdentifier: "firefox_132",
199
199
  ja3: FIREFOX_JA3,
200
200
  h2Settings: FIREFOX_H2_SETTINGS,
@@ -210,6 +210,16 @@ const STEALTH_PROFILES: Record<string, StealthProfile> = {
210
210
  h2Settings: SAFARI_H2_SETTINGS,
211
211
  headerOrder: SAFARI_HEADER_ORDER,
212
212
  }),
213
+ "safari-17": createProfile("safari-17", {
214
+ platform: "macos",
215
+ version: "17.0",
216
+ userAgent:
217
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15",
218
+ tlsClientIdentifier: "safari_17_0",
219
+ ja3: SAFARI_JA3,
220
+ h2Settings: SAFARI_H2_SETTINGS,
221
+ headerOrder: SAFARI_HEADER_ORDER,
222
+ }),
213
223
  "safari-15": createProfile("safari-15", {
214
224
  platform: "macos",
215
225
  version: "15.6.1",
@@ -232,9 +242,9 @@ const STEALTH_PROFILES: Record<string, StealthProfile> = {
232
242
  }),
233
243
  "ios-safari-18": createProfile("ios-safari-18", {
234
244
  platform: "ios",
235
- version: "18.0",
245
+ version: "18.1.1",
236
246
  userAgent:
237
- "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1",
247
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 18_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1.1 Mobile/15E148 Safari/604.1",
238
248
  tlsClientIdentifier: "safari_ios_18_0",
239
249
  ja3: SAFARI_JA3,
240
250
  h2Settings: SAFARI_H2_SETTINGS,
@@ -242,9 +252,9 @@ const STEALTH_PROFILES: Record<string, StealthProfile> = {
242
252
  }),
243
253
  "ios-safari-17": createProfile("ios-safari-17", {
244
254
  platform: "ios",
245
- version: "17.0",
255
+ version: "17.2",
246
256
  userAgent:
247
- "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1",
257
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1",
248
258
  tlsClientIdentifier: "safari_ios_17_0",
249
259
  ja3: SAFARI_JA3,
250
260
  h2Settings: SAFARI_H2_SETTINGS,
package/src/types.ts CHANGED
@@ -366,9 +366,29 @@ export type ProviderChallenge =
366
366
  | {
367
367
  readonly kind: "aws_waf";
368
368
  readonly pageUrl: string;
369
+ /** `window.gokuProps.key`; solver vendors require it, while `"browser"` does not. */
370
+ readonly siteKey?: string;
369
371
  readonly captchaScript?: string;
370
372
  readonly context?: string;
371
373
  readonly iv?: string;
374
+ }
375
+ | {
376
+ readonly kind: "akamai_sec_cpt";
377
+ readonly pageUrl: string;
378
+ /** The admitted challenge document, needed for tile/context extraction. */
379
+ readonly challengeHtml?: string;
380
+ }
381
+ | {
382
+ readonly kind: "akamai_sensor";
383
+ readonly pageUrl: string;
384
+ /** Upstream sensor script URL the payload must be POSTed to. */
385
+ readonly scriptUrl: string;
386
+ /** Current `_abck` cookie value, rotates each round. */
387
+ readonly abck?: string;
388
+ /** Current `bm_sz` / `ak_bmsc` value when the upstream set one. */
389
+ readonly bmsz?: string;
390
+ /** Bot Manager major version when known ("3" measured on zozo.jp). */
391
+ readonly version?: string;
372
392
  };
373
393
 
374
394
  export type ProviderChallengeKind = ProviderChallenge["kind"];
@@ -386,6 +406,8 @@ export type ChallengeSolution =
386
406
  readonly form: "cookies";
387
407
  readonly cookies: Readonly<Record<string, string>>;
388
408
  readonly userAgent: string;
409
+ /** Epoch seconds copied from the upstream cookie's own expiry attribute; never a constant. */
410
+ readonly expires?: number;
389
411
  };
390
412
 
391
413
  export interface ProviderResolverConfig {
@@ -393,6 +415,13 @@ export interface ProviderResolverConfig {
393
415
  readonly vendors: readonly ProviderResolverVendor[];
394
416
  /** Challenge kinds this provider is permitted to request. */
395
417
  readonly kinds: readonly ProviderChallengeKind[];
418
+ /**
419
+ * Client fingerprint profile the SDK must use when reaching this upstream.
420
+ * Measured on zozo.jp: Chrome/Firefox profiles are refused 403 before any
421
+ * challenge is served, while a Safari profile is admitted. Provider-declared
422
+ * because only the provider knows its upstream's admission rule.
423
+ */
424
+ readonly clientProfile?: string;
396
425
  }
397
426
 
398
427
  export type SttAudioInput = {
@@ -628,9 +657,13 @@ export interface HealthJourneyDefinition {
628
657
  requiredSecrets?: readonly string[];
629
658
  manualTrigger?: HealthJourneyManualTriggerPolicy;
630
659
  steps: readonly [HealthJourneyStep, ...HealthJourneyStep[]];
631
- run?: (
632
- ctx: HealthJourneyRunContext,
633
- ) => Promise<HealthJourneyRunResult | undefined>;
660
+ /**
661
+ * Required: a journey always declares `coversOperations`, and the health
662
+ * monitor reports a run-less journey as `journey_run_missing`. Declaration
663
+ * validation rejects a missing `run` (`health-journey-executable`), so this
664
+ * is typed required to fail at compile time rather than at boot.
665
+ */
666
+ run: (ctx: HealthJourneyRunContext) => Promise<HealthJourneyRunResult | undefined>;
634
667
  }
635
668
 
636
669
  /**