@apifuse/provider-sdk 2.2.0-beta.5 → 2.2.0-beta.50
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/AUTHORING.md +537 -33
- package/CHANGELOG.md +201 -1
- package/README.md +83 -22
- package/SUBMISSION.md +2 -2
- package/bin/apifuse-check.ts +165 -11
- package/bin/apifuse-dev.ts +57 -13
- package/bin/apifuse-migrate-operation-declaration.ts +55 -0
- package/bin/apifuse-migrate-shape.ts +202 -0
- package/bin/apifuse-pack-check.ts +22 -2
- package/bin/apifuse-pack-smoke.ts +57 -2
- package/bin/apifuse-pack-types.ts +357 -38
- package/bin/apifuse-perf.ts +14 -13
- package/bin/apifuse-record.ts +709 -72
- package/bin/apifuse-submit-check.ts +2344 -324
- package/bin/apifuse-sync-assets.ts +117 -0
- package/bin/submit-check-delimited-text.ts +50 -0
- package/dist/auth-turn/index.d.ts +3 -3
- package/dist/auth-turn/index.js +1 -1
- package/dist/auth.d.ts +14 -0
- package/dist/auth.js +67 -0
- package/dist/ceremonies/index.d.ts +16 -0
- package/dist/ceremonies/index.js +141 -36
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +27 -0
- package/dist/cli/create.d.ts +4 -1
- package/dist/cli/create.js +42 -37
- package/dist/cli/migrate-operation-declaration.d.ts +59 -0
- package/dist/cli/migrate-operation-declaration.js +1178 -0
- package/dist/cli/migrate-operation-shape.d.ts +44 -0
- package/dist/cli/migrate-operation-shape.js +113 -0
- package/dist/cli/migrate-provider-shape.d.ts +52 -0
- package/dist/cli/migrate-provider-shape.js +578 -0
- package/dist/cli/prompt-assets.d.ts +80 -0
- package/dist/cli/prompt-assets.js +743 -0
- package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/dist/cli/templates/provider/Dockerfile.tpl +1 -1
- package/dist/cli/templates/provider/README.md.tpl +5 -5
- package/dist/cli/templates/provider/index.ts.tpl +6 -3
- package/dist/cli/templates/provider/operations/ping.ts.tpl +4 -1
- package/dist/cli/templates/provider/provider.json.tpl +6 -0
- package/dist/config/loader.d.ts +179 -16
- package/dist/config/loader.js +435 -127
- package/dist/contract-serialization.js +4 -8
- package/dist/contract-types.d.ts +12 -5
- package/dist/contract.js +24 -10
- package/dist/declaration-validation.d.ts +33 -0
- package/dist/declaration-validation.js +266 -0
- package/dist/define.d.ts +66 -29
- package/dist/define.js +778 -69
- package/dist/dev.d.ts +3 -0
- package/dist/dev.js +1 -1
- package/dist/engine.d.ts +78 -0
- package/dist/engine.js +133 -0
- package/dist/error-observability.d.ts +7 -0
- package/dist/error-observability.js +61 -0
- package/dist/error-resolution.d.ts +4 -0
- package/dist/error-resolution.js +122 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.js +40 -0
- package/dist/fixture-sanitization.d.ts +28 -0
- package/dist/fixture-sanitization.js +227 -0
- package/dist/health-scenario.d.ts +1842 -0
- package/dist/health-scenario.js +624 -0
- package/dist/index.d.ts +21 -10
- package/dist/index.js +12 -7
- package/dist/lint.d.ts +23 -11
- package/dist/lint.js +572 -69
- package/dist/native-address.d.ts +43 -0
- package/dist/native-address.js +281 -0
- package/dist/native-egress-policy.d.ts +31 -0
- package/dist/native-egress-policy.js +288 -0
- package/dist/observability.d.ts +5 -2
- package/dist/observability.js +48 -1
- package/dist/provider.d.ts +10 -2
- package/dist/provider.js +4 -1
- package/dist/runtime/auth-flow.d.ts +5 -1
- package/dist/runtime/auth-flow.js +6 -0
- package/dist/runtime/browser.d.ts +1 -0
- package/dist/runtime/browser.js +492 -49
- package/dist/runtime/cache.d.ts +1 -0
- package/dist/runtime/cache.js +169 -15
- package/dist/runtime/choice-wordlist.d.ts +9 -0
- package/dist/runtime/choice-wordlist.js +138 -0
- package/dist/runtime/choice.d.ts +13 -1
- package/dist/runtime/choice.js +490 -102
- package/dist/runtime/chrome149-header-order.d.ts +58 -0
- package/dist/runtime/chrome149-header-order.js +289 -0
- package/dist/runtime/env.js +12 -0
- package/dist/runtime/executor.d.ts +3 -2
- package/dist/runtime/executor.js +26 -25
- package/dist/runtime/http.d.ts +1 -0
- package/dist/runtime/http.js +515 -53
- package/dist/runtime/insights.js +2 -2
- package/dist/runtime/instrumentation.d.ts +2 -2
- package/dist/runtime/instrumentation.js +366 -8
- package/dist/runtime/native-network-errors.d.ts +33 -0
- package/dist/runtime/native-network-errors.js +69 -0
- package/dist/runtime/native-network.d.ts +96 -0
- package/dist/runtime/native-network.js +1232 -0
- package/dist/runtime/ocr.d.ts +29 -0
- package/dist/runtime/ocr.js +440 -0
- package/dist/runtime/otlp.d.ts +71 -2
- package/dist/runtime/otlp.js +397 -16
- package/dist/runtime/proxy-errors.js +6 -2
- package/dist/runtime/proxy-nodemaven.d.ts +56 -0
- package/dist/runtime/proxy-nodemaven.js +146 -0
- package/dist/runtime/proxy-telemetry.d.ts +80 -1
- package/dist/runtime/proxy-telemetry.js +154 -47
- package/dist/runtime/redirects.d.ts +29 -0
- package/dist/runtime/redirects.js +36 -0
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +4 -2
- package/dist/runtime/request-options.d.ts +68 -1
- package/dist/runtime/request-options.js +548 -0
- package/dist/runtime/resolver-config.d.ts +6 -0
- package/dist/runtime/resolver-config.js +6 -0
- package/dist/runtime/resolver-public.d.ts +1 -0
- package/dist/runtime/resolver-public.js +1 -0
- package/dist/runtime/resolver-shared.d.ts +14 -0
- package/dist/runtime/resolver-shared.js +12 -0
- package/dist/runtime/resolver-vendors/bindings.d.ts +48 -0
- package/dist/runtime/resolver-vendors/bindings.js +40 -0
- package/dist/runtime/resolver-vendors/browser.d.ts +22 -0
- package/dist/runtime/resolver-vendors/browser.js +377 -0
- package/dist/runtime/resolver-vendors/capsolver.d.ts +22 -0
- package/dist/runtime/resolver-vendors/capsolver.js +531 -0
- package/dist/runtime/resolver-vendors/hosts.d.ts +2 -0
- package/dist/runtime/resolver-vendors/hosts.js +33 -0
- package/dist/runtime/resolver-vendors/twocaptcha.d.ts +24 -0
- package/dist/runtime/resolver-vendors/twocaptcha.js +408 -0
- package/dist/runtime/resolver-vendors/types.d.ts +94 -0
- package/dist/runtime/resolver-vendors/types.js +96 -0
- package/dist/runtime/resolver.d.ts +72 -0
- package/dist/runtime/resolver.js +771 -0
- package/dist/runtime/secrets.d.ts +27 -0
- package/dist/runtime/secrets.js +51 -0
- package/dist/runtime/state.d.ts +3 -0
- package/dist/runtime/state.js +277 -71
- package/dist/runtime/stealth-cookies.d.ts +20 -0
- package/dist/runtime/stealth-cookies.js +111 -0
- package/dist/runtime/stealth.d.ts +41 -5
- package/dist/runtime/stealth.js +997 -291
- package/dist/runtime/stt.js +1 -12
- package/dist/runtime/timeout.d.ts +5 -0
- package/dist/runtime/timeout.js +12 -0
- package/dist/runtime/trace-config.d.ts +12 -0
- package/dist/runtime/trace-config.js +62 -0
- package/dist/runtime/trace.d.ts +5 -0
- package/dist/runtime/trace.js +43 -10
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/error-observability.d.ts +1 -0
- package/dist/server/error-observability.js +1 -0
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.js +2 -2
- package/dist/server/self-test-input-tokens.d.ts +2 -1
- package/dist/server/self-test-input-tokens.js +18 -14
- package/dist/server/self-test.d.ts +14 -3
- package/dist/server/self-test.js +129 -58
- package/dist/server/serve-implementation.d.ts +230 -0
- package/dist/server/serve-implementation.js +2265 -0
- package/dist/server/serve.d.ts +1 -70
- package/dist/server/serve.js +1 -1131
- package/dist/server/trace-output.d.ts +6 -0
- package/dist/server/trace-output.js +79 -0
- package/dist/server/types.d.ts +30 -5
- package/dist/server/types.js +13 -1
- package/dist/stateful/errors.d.ts +19 -0
- package/dist/stateful/errors.js +24 -0
- package/dist/stateful/http-provider-event-emitter.d.ts +40 -0
- package/dist/stateful/http-provider-event-emitter.js +237 -0
- package/dist/stateful/http-session-owner-registry.d.ts +44 -0
- package/dist/stateful/http-session-owner-registry.js +210 -0
- package/dist/stateful/index.d.ts +18 -0
- package/dist/stateful/index.js +18 -0
- package/dist/stateful/provider-event-delivery-failures.d.ts +32 -0
- package/dist/stateful/provider-event-delivery-failures.js +43 -0
- package/dist/stateful/provider-event-pipeline-metrics.d.ts +46 -0
- package/dist/stateful/provider-event-pipeline-metrics.js +48 -0
- package/dist/stateful/provider-event-pipeline.d.ts +50 -0
- package/dist/stateful/provider-event-pipeline.js +1 -0
- package/dist/stateful/provider-events.d.ts +101 -0
- package/dist/stateful/provider-events.js +289 -0
- package/dist/stateful/session-key.d.ts +15 -0
- package/dist/stateful/session-key.js +86 -0
- package/dist/stateful/stateful-provider-adapter-context.d.ts +5 -0
- package/dist/stateful/stateful-provider-adapter-context.js +42 -0
- package/dist/stateful/stateful-provider-adapter-metrics.d.ts +15 -0
- package/dist/stateful/stateful-provider-adapter-metrics.js +21 -0
- package/dist/stateful/stateful-provider-adapter.d.ts +98 -0
- package/dist/stateful/stateful-provider-adapter.js +287 -0
- package/dist/stateful/stateful-provider-observability.d.ts +62 -0
- package/dist/stateful/stateful-provider-observability.js +161 -0
- package/dist/stateful/stateful-provider-owner-forwarder.d.ts +41 -0
- package/dist/stateful/stateful-provider-owner-forwarder.js +215 -0
- package/dist/stateful/stateful-provider-runtime-context.d.ts +32 -0
- package/dist/stateful/stateful-provider-runtime-context.js +60 -0
- package/dist/stateful/stateful-provider-runtime-executor.d.ts +34 -0
- package/dist/stateful/stateful-provider-runtime-executor.js +52 -0
- package/dist/stateful/stateful-provider-session-routing.d.ts +67 -0
- package/dist/stateful/stateful-provider-session-routing.js +345 -0
- package/dist/stateful/stateful-provider-session-runtime.d.ts +98 -0
- package/dist/stateful/stateful-provider-session-runtime.js +245 -0
- package/dist/stateful-signing.d.ts +18 -0
- package/dist/stateful-signing.js +27 -0
- package/dist/stealth/profiles.d.ts +9 -4
- package/dist/stealth/profiles.js +160 -211
- package/dist/stream-evidence.d.ts +74 -0
- package/dist/stream-evidence.js +785 -0
- package/dist/stream.js +7 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +2 -1
- package/dist/testing/run.d.ts +32 -2
- package/dist/testing/run.js +489 -21
- package/dist/trace-sanitization.d.ts +5 -0
- package/dist/trace-sanitization.js +45 -0
- package/dist/types.d.ts +673 -131
- package/dist/types.js +1 -0
- package/package.json +45 -5
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +118 -0
- package/src/ceremonies/index.ts +189 -46
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/approval-override.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/codemod-syntax.ts.txt +3 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/connection-precedence.ts.txt +10 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/docs-conflict.ts.txt +8 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-map.ts.txt +5 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/examples-operation.ts.txt +16 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/factory-map.ts.txt +3 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoist-all.ts.txt +31 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/hoisted-const.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/imported-spread.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-map.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-cast-tail.ts.txt +21 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-ekitan.ts.txt +11 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/inline-spread-override.ts.txt +14 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/missing-english-locale.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/no-safety.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/non-literal.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/redundant-approval.ts.txt +6 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/safety-conflict.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/stream.ts.txt +7 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/tool-router-spread.ts.txt +15 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/unparseable.ts.txt +4 -0
- package/src/cli/__tests__/fixtures/migrate-operation-declaration/verbatim-template.ts.txt +12 -0
- package/src/cli/commands.ts +33 -0
- package/src/cli/create.ts +50 -37
- package/src/cli/migrate-operation-declaration.ts +1654 -0
- package/src/cli/migrate-operation-shape.ts +184 -0
- package/src/cli/migrate-provider-shape.ts +772 -0
- package/src/cli/prompt-assets.ts +865 -0
- package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/src/cli/templates/provider/Dockerfile.tpl +1 -1
- package/src/cli/templates/provider/README.md.tpl +5 -5
- package/src/cli/templates/provider/index.ts.tpl +6 -3
- package/src/cli/templates/provider/operations/ping.ts.tpl +4 -1
- package/src/cli/templates/provider/provider.json.tpl +6 -0
- package/src/config/loader.ts +690 -163
- package/src/contract-serialization.ts +5 -7
- package/src/contract-types.ts +12 -5
- package/src/contract.ts +24 -10
- package/src/declaration-validation.ts +330 -0
- package/src/define.ts +1048 -131
- package/src/dev.ts +4 -1
- package/src/engine.ts +279 -0
- package/src/error-observability.ts +64 -0
- package/src/error-resolution.ts +127 -0
- package/src/errors.ts +68 -0
- package/src/fixture-sanitization.ts +264 -0
- package/src/health-scenario.ts +875 -0
- package/src/index.ts +220 -13
- package/src/lint.ts +698 -90
- package/src/native-address.ts +340 -0
- package/src/native-egress-policy.ts +358 -0
- package/src/observability.ts +51 -1
- package/src/provider.ts +161 -3
- package/src/runtime/auth-flow.ts +12 -0
- package/src/runtime/browser.ts +661 -63
- package/src/runtime/cache.ts +189 -14
- package/src/runtime/choice-wordlist.ts +145 -0
- package/src/runtime/choice.ts +631 -120
- package/src/runtime/chrome149-header-order.ts +330 -0
- package/src/runtime/env.ts +13 -0
- package/src/runtime/executor.ts +43 -31
- package/src/runtime/http.ts +641 -61
- package/src/runtime/insights.ts +2 -2
- package/src/runtime/instrumentation.ts +520 -15
- package/src/runtime/native-network-errors.ts +99 -0
- package/src/runtime/native-network.ts +1605 -0
- package/src/runtime/ocr.ts +523 -0
- package/src/runtime/otlp.ts +467 -21
- package/src/runtime/proxy-errors.ts +12 -4
- package/src/runtime/proxy-nodemaven.ts +221 -0
- package/src/runtime/proxy-telemetry.ts +244 -75
- package/src/runtime/redirects.ts +66 -0
- package/src/runtime/redis.ts +7 -2
- package/src/runtime/request-options.ts +680 -1
- package/src/runtime/resolver-config.ts +6 -0
- package/src/runtime/resolver-public.ts +23 -0
- package/src/runtime/resolver-shared.ts +33 -0
- package/src/runtime/resolver-vendors/bindings.ts +56 -0
- package/src/runtime/resolver-vendors/browser.ts +533 -0
- package/src/runtime/resolver-vendors/capsolver.ts +707 -0
- package/src/runtime/resolver-vendors/hosts.ts +38 -0
- package/src/runtime/resolver-vendors/twocaptcha.ts +540 -0
- package/src/runtime/resolver-vendors/types.ts +212 -0
- package/src/runtime/resolver.ts +1157 -0
- package/src/runtime/secrets.ts +64 -0
- package/src/runtime/state.ts +394 -77
- package/src/runtime/stealth-cookies.ts +132 -0
- package/src/runtime/stealth.ts +1280 -336
- package/src/runtime/stt.ts +1 -19
- package/src/runtime/timeout.ts +18 -0
- package/src/runtime/trace-config.ts +78 -0
- package/src/runtime/trace.ts +57 -17
- package/src/serve.ts +6 -1
- package/src/server/error-observability.ts +1 -0
- package/src/server/index.ts +34 -2
- package/src/server/self-test-input-tokens.ts +29 -14
- package/src/server/self-test.ts +191 -68
- package/src/server/serve-implementation.ts +3378 -0
- package/src/server/serve.ts +1 -1632
- package/src/server/trace-output.ts +129 -0
- package/src/server/types.ts +13 -1
- package/src/stateful/README.md +146 -0
- package/src/stateful/errors.ts +35 -0
- package/src/stateful/http-provider-event-emitter.ts +314 -0
- package/src/stateful/http-session-owner-registry.ts +306 -0
- package/src/stateful/index.ts +18 -0
- package/src/stateful/provider-event-delivery-failures.ts +80 -0
- package/src/stateful/provider-event-pipeline-metrics.ts +95 -0
- package/src/stateful/provider-event-pipeline.ts +61 -0
- package/src/stateful/provider-events.ts +462 -0
- package/src/stateful/session-key.ts +111 -0
- package/src/stateful/stateful-provider-adapter-context.ts +59 -0
- package/src/stateful/stateful-provider-adapter-metrics.ts +48 -0
- package/src/stateful/stateful-provider-adapter.ts +562 -0
- package/src/stateful/stateful-provider-observability.ts +261 -0
- package/src/stateful/stateful-provider-owner-forwarder.ts +287 -0
- package/src/stateful/stateful-provider-runtime-context.ts +92 -0
- package/src/stateful/stateful-provider-runtime-executor.ts +96 -0
- package/src/stateful/stateful-provider-session-routing.ts +546 -0
- package/src/stateful/stateful-provider-session-runtime.ts +403 -0
- package/src/stateful-signing.ts +46 -0
- package/src/stealth/profiles.ts +202 -231
- package/src/stream-evidence.ts +988 -0
- package/src/stream.ts +8 -1
- package/src/testing/index.ts +10 -1
- package/src/testing/run.ts +658 -15
- package/src/trace-sanitization.ts +63 -0
- package/src/types.ts +788 -174
- package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
- package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
- /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
package/src/stealth/profiles.ts
CHANGED
|
@@ -1,57 +1,29 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
import type { BrowserProfile, EmulationOS } from "wreq-js";
|
|
4
|
+
|
|
1
5
|
import { SDKError } from "../errors.js";
|
|
2
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
StealthBrowser,
|
|
8
|
+
StealthProfile,
|
|
9
|
+
StealthProfileDescriptor,
|
|
10
|
+
StealthProfileSelection,
|
|
11
|
+
StealthOS,
|
|
12
|
+
} from "../types.js";
|
|
3
13
|
|
|
4
|
-
type StealthProfileDefinition = Omit<StealthProfile, "
|
|
5
|
-
|
|
6
|
-
};
|
|
14
|
+
type StealthProfileDefinition = Omit<StealthProfile, "browser" | "os">;
|
|
15
|
+
type WreqProfileApi = Pick<typeof import("wreq-js"), "getEmulationHeaders" | "getProfiles">;
|
|
7
16
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
":authority",
|
|
11
|
-
":scheme",
|
|
12
|
-
":path",
|
|
13
|
-
"user-agent",
|
|
14
|
-
"accept",
|
|
15
|
-
"accept-encoding",
|
|
16
|
-
"accept-language",
|
|
17
|
-
"cache-control",
|
|
18
|
-
"pragma",
|
|
19
|
-
"cookie",
|
|
20
|
-
"sec-ch-ua",
|
|
21
|
-
"sec-ch-ua-mobile",
|
|
22
|
-
"sec-ch-ua-platform",
|
|
23
|
-
];
|
|
17
|
+
const requireModule = createRequire(import.meta.url);
|
|
18
|
+
let wreqProfileApi: WreqProfileApi | undefined;
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
":scheme",
|
|
30
|
-
"user-agent",
|
|
31
|
-
"accept",
|
|
32
|
-
"accept-language",
|
|
33
|
-
"accept-encoding",
|
|
34
|
-
"referer",
|
|
35
|
-
"cookie",
|
|
36
|
-
"upgrade-insecure-requests",
|
|
37
|
-
"sec-fetch-dest",
|
|
38
|
-
"sec-fetch-mode",
|
|
39
|
-
"sec-fetch-site",
|
|
40
|
-
"sec-fetch-user",
|
|
41
|
-
];
|
|
20
|
+
function getWreqProfileApi(): WreqProfileApi {
|
|
21
|
+
wreqProfileApi ??= requireModule("wreq-js") as WreqProfileApi;
|
|
22
|
+
return wreqProfileApi;
|
|
23
|
+
}
|
|
42
24
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
":scheme",
|
|
46
|
-
":path",
|
|
47
|
-
":authority",
|
|
48
|
-
"accept",
|
|
49
|
-
"user-agent",
|
|
50
|
-
"accept-language",
|
|
51
|
-
"accept-encoding",
|
|
52
|
-
"cookie",
|
|
53
|
-
"upgrade-insecure-requests",
|
|
54
|
-
];
|
|
25
|
+
export const DEFAULT_STEALTH_BROWSER = "chrome" as const;
|
|
26
|
+
export const DEFAULT_STEALTH_OS = "macos" as const;
|
|
55
27
|
|
|
56
28
|
const CHROMIUM_H2_SETTINGS = {
|
|
57
29
|
HEADER_TABLE_SIZE: 65536,
|
|
@@ -68,7 +40,7 @@ const FIREFOX_H2_SETTINGS = {
|
|
|
68
40
|
};
|
|
69
41
|
|
|
70
42
|
const SAFARI_H2_SETTINGS = {
|
|
71
|
-
|
|
43
|
+
// Safari 17 also sends a connection-level WINDOW_UPDATE increment of 10485760.
|
|
72
44
|
ENABLE_PUSH: 0,
|
|
73
45
|
INITIAL_WINDOW_SIZE: 4194304,
|
|
74
46
|
MAX_CONCURRENT_STREAMS: 100,
|
|
@@ -81,212 +53,211 @@ const FIREFOX_JA3 =
|
|
|
81
53
|
const SAFARI_JA3 =
|
|
82
54
|
"771,4865-4866-4867-49196-49195-52393-49200-49199-49188-49192-159-158-107-103-57-51-157-156-61-60-53-47-255,0-23-65281-10-11-16-5-13-18-51-45-43-27,29-23-24-25,0";
|
|
83
55
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
56
|
+
const SUPPORTED_STEALTH_PROFILES: readonly StealthProfileDescriptor[] = [
|
|
57
|
+
{ browser: "chrome", os: "windows" },
|
|
58
|
+
{ browser: "chrome", os: "macos" },
|
|
59
|
+
{ browser: "chrome", os: "linux" },
|
|
60
|
+
{ browser: "firefox", os: "windows" },
|
|
61
|
+
{ browser: "firefox", os: "macos" },
|
|
62
|
+
{ browser: "firefox", os: "linux" },
|
|
63
|
+
{ browser: "safari", os: "macos" },
|
|
64
|
+
{ browser: "safari", os: "ios" },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const DESKTOP_OSES = new Set<StealthOS>(["windows", "macos", "linux"]);
|
|
68
|
+
|
|
69
|
+
function structuredReplacement(browser: StealthBrowser, os: StealthOS): string {
|
|
70
|
+
return `stealth: { browser: "${browser}", os: "${os}" }`;
|
|
96
71
|
}
|
|
97
72
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
73
|
+
/** Internal detector used to keep version-pinned string failures actionable. */
|
|
74
|
+
export function getVersionPinnedStealthReplacement(name: string): string | undefined {
|
|
75
|
+
if (/^(?:chrome|chromium|edge)[-_]\d/i.test(name)) {
|
|
76
|
+
return structuredReplacement("chrome", DEFAULT_STEALTH_OS);
|
|
102
77
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
78
|
+
if (/^firefox[-_]\d/i.test(name)) {
|
|
79
|
+
return structuredReplacement("firefox", DEFAULT_STEALTH_OS);
|
|
80
|
+
}
|
|
81
|
+
if (/^(?:ios[-_]safari|safari[-_](?:ios|ipad))[-_]\d/i.test(name)) {
|
|
82
|
+
return structuredReplacement("safari", "ios");
|
|
83
|
+
}
|
|
84
|
+
if (/^safari[-_]\d/i.test(name)) {
|
|
85
|
+
return structuredReplacement("safari", DEFAULT_STEALTH_OS);
|
|
107
86
|
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
108
89
|
|
|
109
|
-
|
|
90
|
+
function rejectStringSelection(name: string): never {
|
|
91
|
+
const replacement = getVersionPinnedStealthReplacement(name);
|
|
92
|
+
if (replacement) {
|
|
93
|
+
throw new SDKError(
|
|
94
|
+
`Stealth profile "${name}" pins a browser version and is not supported. Use ${replacement}.`,
|
|
95
|
+
{ code: "STEALTH_VERSION_PIN_UNSUPPORTED" },
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
throw new SDKError(
|
|
99
|
+
`Stealth profile names are no longer supported: "${name}". Use structured browser/os options.`,
|
|
100
|
+
{ code: "STEALTH_PROFILE_NAME_UNSUPPORTED" },
|
|
101
|
+
);
|
|
110
102
|
}
|
|
111
103
|
|
|
112
|
-
function
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return '"iOS"';
|
|
104
|
+
function assertSupportedDescriptor(browser: StealthBrowser, os: StealthOS): void {
|
|
105
|
+
const supported =
|
|
106
|
+
(browser === "chrome" && DESKTOP_OSES.has(os)) ||
|
|
107
|
+
(browser === "firefox" && DESKTOP_OSES.has(os)) ||
|
|
108
|
+
(browser === "safari" && (os === "macos" || os === "ios"));
|
|
109
|
+
if (!supported) {
|
|
110
|
+
throw new SDKError(
|
|
111
|
+
`Unsupported stealth browser/OS combination: ${browser}/${os}. ` +
|
|
112
|
+
"Chrome and Firefox support windows, macos, and linux; Safari supports macos and ios.",
|
|
113
|
+
{ code: "STEALTH_PROFILE_UNAVAILABLE" },
|
|
114
|
+
);
|
|
124
115
|
}
|
|
125
116
|
}
|
|
126
117
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
/** Resolve omitted axes and validate that the resulting pair is supported. */
|
|
119
|
+
export function resolveStealthProfileSelection(
|
|
120
|
+
selection: StealthProfileSelection | undefined,
|
|
121
|
+
base?: StealthProfileDescriptor,
|
|
122
|
+
): StealthProfileDescriptor {
|
|
123
|
+
if (typeof selection === "string") rejectStringSelection(selection);
|
|
124
|
+
if (selection !== undefined && (typeof selection !== "object" || selection === null)) {
|
|
125
|
+
throw new SDKError("Stealth profile selection must use structured browser/os options.");
|
|
126
|
+
}
|
|
127
|
+
const unsafeSelection = selection as
|
|
128
|
+
| (Record<string, unknown> & { browser?: unknown; os?: unknown })
|
|
129
|
+
| undefined;
|
|
130
|
+
if (unsafeSelection && "profile" in unsafeSelection) {
|
|
131
|
+
if (typeof unsafeSelection.profile === "string") rejectStringSelection(unsafeSelection.profile);
|
|
132
|
+
throw new SDKError(
|
|
133
|
+
"stealth.profile is no longer supported. Use stealth.browser and stealth.os.",
|
|
134
|
+
{ code: "STEALTH_PROFILE_NAME_UNSUPPORTED" },
|
|
135
|
+
);
|
|
136
|
+
}
|
|
131
137
|
|
|
132
|
-
const
|
|
133
|
-
|
|
138
|
+
const browser = unsafeSelection?.browser ?? base?.browser ?? DEFAULT_STEALTH_BROWSER;
|
|
139
|
+
if (browser !== "chrome" && browser !== "firefox" && browser !== "safari") {
|
|
140
|
+
throw new SDKError(`Unsupported stealth browser: ${String(browser)}`);
|
|
141
|
+
}
|
|
142
|
+
const browserChanged =
|
|
143
|
+
base !== undefined && unsafeSelection?.browser !== undefined && browser !== base.browser;
|
|
144
|
+
const os =
|
|
145
|
+
unsafeSelection?.os ?? (browserChanged ? DEFAULT_STEALTH_OS : base?.os) ?? DEFAULT_STEALTH_OS;
|
|
146
|
+
if (os !== "windows" && os !== "macos" && os !== "linux" && os !== "ios") {
|
|
147
|
+
throw new SDKError(`Unsupported stealth OS: ${String(os)}`);
|
|
148
|
+
}
|
|
149
|
+
assertSupportedDescriptor(browser, os);
|
|
150
|
+
return { browser, os } as StealthProfileDescriptor;
|
|
151
|
+
}
|
|
134
152
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
/** Resolve the newest Chromium build exposed by the exactly pinned wreq-js package. */
|
|
154
|
+
function resolveLatestChromiumProfile(): {
|
|
155
|
+
readonly wreqName: BrowserProfile;
|
|
156
|
+
readonly version: string;
|
|
157
|
+
} {
|
|
158
|
+
const { getProfiles } = getWreqProfileApi();
|
|
159
|
+
let newest: { name: BrowserProfile; version: number } | undefined;
|
|
160
|
+
for (const name of getProfiles()) {
|
|
161
|
+
const match = /^chrome_(\d+)$/.exec(name);
|
|
162
|
+
if (!match) continue;
|
|
163
|
+
const version = Number(match[1]);
|
|
164
|
+
if (!newest || version > newest.version) newest = { name, version };
|
|
143
165
|
}
|
|
166
|
+
if (!newest) {
|
|
167
|
+
throw new SDKError("wreq-js exposes no chrome_<version> emulation profile.", {
|
|
168
|
+
code: "STEALTH_PROFILE_UNAVAILABLE",
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return { wreqName: newest.name, version: `${newest.version}.0.0.0` };
|
|
172
|
+
}
|
|
144
173
|
|
|
145
|
-
|
|
174
|
+
/** Read the identity wreq itself emits so the accessor and transport cannot diverge. */
|
|
175
|
+
function emulationUserAgent(profile: BrowserProfile, os: EmulationOS): string {
|
|
176
|
+
for (const [name, value] of getWreqProfileApi().getEmulationHeaders(profile, os)) {
|
|
177
|
+
if (String(name).toLowerCase() === "user-agent") return String(value);
|
|
178
|
+
}
|
|
179
|
+
throw new SDKError(`wreq-js profile ${profile} exposes no user-agent header.`, {
|
|
180
|
+
code: "STEALTH_PROFILE_UNAVAILABLE",
|
|
181
|
+
});
|
|
146
182
|
}
|
|
147
183
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
184
|
+
function createProfile(
|
|
185
|
+
descriptor: StealthProfileDescriptor,
|
|
186
|
+
definition: StealthProfileDefinition,
|
|
187
|
+
): StealthProfile {
|
|
188
|
+
return {
|
|
189
|
+
...descriptor,
|
|
190
|
+
...definition,
|
|
191
|
+
h2Settings: definition.h2Settings ? { ...definition.h2Settings } : undefined,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
151
194
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
version: "146.0.0.0",
|
|
156
|
-
userAgent:
|
|
157
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
|
158
|
-
tlsClientIdentifier: "chrome_146",
|
|
159
|
-
ja3: CHROMIUM_JA3,
|
|
160
|
-
h2Settings: CHROMIUM_H2_SETTINGS,
|
|
161
|
-
headerOrder: CHROMIUM_HEADER_ORDER,
|
|
162
|
-
}),
|
|
163
|
-
"firefox-147": createProfile("firefox-147", {
|
|
164
|
-
platform: "macos",
|
|
165
|
-
version: "147.0",
|
|
166
|
-
userAgent:
|
|
167
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0",
|
|
168
|
-
tlsClientIdentifier: "firefox_147",
|
|
169
|
-
ja3: FIREFOX_JA3,
|
|
170
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
171
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
172
|
-
}),
|
|
173
|
-
"firefox-135": createProfile("firefox-135", {
|
|
174
|
-
platform: "macos",
|
|
175
|
-
version: "135.0",
|
|
176
|
-
userAgent:
|
|
177
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0",
|
|
178
|
-
tlsClientIdentifier: "firefox_135",
|
|
179
|
-
ja3: FIREFOX_JA3,
|
|
180
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
181
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
182
|
-
}),
|
|
183
|
-
"firefox-133": createProfile("firefox-133", {
|
|
184
|
-
platform: "macos",
|
|
185
|
-
version: "133.0",
|
|
186
|
-
userAgent:
|
|
187
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0",
|
|
188
|
-
tlsClientIdentifier: "firefox_133",
|
|
189
|
-
ja3: FIREFOX_JA3,
|
|
190
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
191
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
192
|
-
}),
|
|
193
|
-
"firefox-132": createProfile("firefox-132", {
|
|
194
|
-
platform: "macos",
|
|
195
|
-
version: "132.0",
|
|
196
|
-
userAgent:
|
|
197
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0",
|
|
198
|
-
tlsClientIdentifier: "firefox_132",
|
|
199
|
-
ja3: FIREFOX_JA3,
|
|
200
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
201
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
202
|
-
}),
|
|
203
|
-
"safari-16": createProfile("safari-16", {
|
|
204
|
-
platform: "macos",
|
|
205
|
-
version: "16.0",
|
|
206
|
-
userAgent:
|
|
207
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15",
|
|
208
|
-
tlsClientIdentifier: "safari_16_0",
|
|
209
|
-
ja3: SAFARI_JA3,
|
|
210
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
211
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
212
|
-
}),
|
|
213
|
-
"safari-15": createProfile("safari-15", {
|
|
214
|
-
platform: "macos",
|
|
215
|
-
version: "15.6.1",
|
|
216
|
-
userAgent:
|
|
217
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15",
|
|
218
|
-
tlsClientIdentifier: "safari_15_6_1",
|
|
219
|
-
ja3: SAFARI_JA3,
|
|
220
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
221
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
222
|
-
}),
|
|
223
|
-
"ios-safari-26": createProfile("ios-safari-26", {
|
|
224
|
-
platform: "ios",
|
|
225
|
-
version: "26.0",
|
|
226
|
-
userAgent:
|
|
227
|
-
"Mozilla/5.0 (iPhone; CPU iPhone OS 26_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",
|
|
228
|
-
tlsClientIdentifier: "safari_ios_26_0",
|
|
229
|
-
ja3: SAFARI_JA3,
|
|
230
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
231
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
232
|
-
}),
|
|
233
|
-
"ios-safari-18": createProfile("ios-safari-18", {
|
|
234
|
-
platform: "ios",
|
|
235
|
-
version: "18.0",
|
|
236
|
-
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",
|
|
238
|
-
tlsClientIdentifier: "safari_ios_18_0",
|
|
239
|
-
ja3: SAFARI_JA3,
|
|
240
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
241
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
242
|
-
}),
|
|
243
|
-
"ios-safari-17": createProfile("ios-safari-17", {
|
|
244
|
-
platform: "ios",
|
|
245
|
-
version: "17.0",
|
|
246
|
-
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",
|
|
248
|
-
tlsClientIdentifier: "safari_ios_17_0",
|
|
249
|
-
ja3: SAFARI_JA3,
|
|
250
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
251
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
252
|
-
}),
|
|
253
|
-
"generic-desktop": createProfile("generic-desktop", {
|
|
254
|
-
platform: "macos",
|
|
255
|
-
version: "146.0.0.0",
|
|
256
|
-
userAgent:
|
|
257
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
|
|
258
|
-
tlsClientIdentifier: "chrome_146",
|
|
259
|
-
ja3: CHROMIUM_JA3,
|
|
260
|
-
h2Settings: CHROMIUM_H2_SETTINGS,
|
|
261
|
-
headerOrder: CHROMIUM_HEADER_ORDER,
|
|
262
|
-
}),
|
|
263
|
-
"generic-mobile": createProfile("generic-mobile", {
|
|
264
|
-
platform: "ios",
|
|
265
|
-
version: "26.0",
|
|
266
|
-
userAgent:
|
|
267
|
-
"Mozilla/5.0 (iPhone; CPU iPhone OS 26_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",
|
|
268
|
-
tlsClientIdentifier: "safari_ios_26_0",
|
|
269
|
-
ja3: SAFARI_JA3,
|
|
270
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
271
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
272
|
-
}),
|
|
273
|
-
};
|
|
195
|
+
function profileKey(descriptor: StealthProfileDescriptor): string {
|
|
196
|
+
return `${descriptor.browser}:${descriptor.os}`;
|
|
197
|
+
}
|
|
274
198
|
|
|
275
|
-
|
|
276
|
-
const canonicalName = STEALTH_PROFILE_ALIASES[name] ?? name;
|
|
277
|
-
const profile = STEALTH_PROFILES[canonicalName];
|
|
199
|
+
let stealthProfileCatalog: Map<string, StealthProfile> | undefined;
|
|
278
200
|
|
|
279
|
-
|
|
280
|
-
|
|
201
|
+
function getStealthProfileCatalog(): Map<string, StealthProfile> {
|
|
202
|
+
if (stealthProfileCatalog) return stealthProfileCatalog;
|
|
203
|
+
|
|
204
|
+
const latestChrome = resolveLatestChromiumProfile();
|
|
205
|
+
const definitions: Record<StealthBrowser, Omit<StealthProfileDefinition, "userAgent">> = {
|
|
206
|
+
chrome: {
|
|
207
|
+
version: latestChrome.version,
|
|
208
|
+
tlsClientIdentifier: latestChrome.wreqName,
|
|
209
|
+
ja3: CHROMIUM_JA3,
|
|
210
|
+
h2Settings: CHROMIUM_H2_SETTINGS,
|
|
211
|
+
},
|
|
212
|
+
firefox: {
|
|
213
|
+
version: "147.0",
|
|
214
|
+
tlsClientIdentifier: "firefox_147",
|
|
215
|
+
ja3: FIREFOX_JA3,
|
|
216
|
+
h2Settings: FIREFOX_H2_SETTINGS,
|
|
217
|
+
},
|
|
218
|
+
safari: {
|
|
219
|
+
version: "17.0",
|
|
220
|
+
tlsClientIdentifier: "safari_17.0",
|
|
221
|
+
ja3: SAFARI_JA3,
|
|
222
|
+
h2Settings: SAFARI_H2_SETTINGS,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
stealthProfileCatalog = new Map();
|
|
227
|
+
for (const descriptor of SUPPORTED_STEALTH_PROFILES) {
|
|
228
|
+
const isMobileSafari = descriptor.browser === "safari" && descriptor.os === "ios";
|
|
229
|
+
const definition = isMobileSafari
|
|
230
|
+
? {
|
|
231
|
+
version: "26.0",
|
|
232
|
+
tlsClientIdentifier: "safari_ios_26" as BrowserProfile,
|
|
233
|
+
ja3: SAFARI_JA3,
|
|
234
|
+
h2Settings: SAFARI_H2_SETTINGS,
|
|
235
|
+
}
|
|
236
|
+
: definitions[descriptor.browser];
|
|
237
|
+
const wreqName = definition.tlsClientIdentifier as BrowserProfile;
|
|
238
|
+
stealthProfileCatalog.set(
|
|
239
|
+
profileKey(descriptor),
|
|
240
|
+
createProfile(descriptor, {
|
|
241
|
+
...definition,
|
|
242
|
+
userAgent: emulationUserAgent(wreqName, descriptor.os),
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
281
245
|
}
|
|
246
|
+
return stealthProfileCatalog;
|
|
247
|
+
}
|
|
282
248
|
|
|
249
|
+
export function getStealthProfile(selection: StealthProfileSelection = {}): StealthProfile {
|
|
250
|
+
const descriptor = resolveStealthProfileSelection(selection);
|
|
251
|
+
const profile = getStealthProfileCatalog().get(profileKey(descriptor));
|
|
252
|
+
if (!profile) {
|
|
253
|
+
throw new SDKError(`Unknown stealth profile: ${descriptor.browser}/${descriptor.os}`);
|
|
254
|
+
}
|
|
283
255
|
return {
|
|
284
256
|
...profile,
|
|
285
257
|
h2Settings: profile.h2Settings ? { ...profile.h2Settings } : undefined,
|
|
286
|
-
headerOrder: profile.headerOrder ? [...profile.headerOrder] : undefined,
|
|
287
258
|
};
|
|
288
259
|
}
|
|
289
260
|
|
|
290
|
-
export function listStealthProfiles():
|
|
291
|
-
return
|
|
261
|
+
export function listStealthProfiles(): StealthProfileDescriptor[] {
|
|
262
|
+
return SUPPORTED_STEALTH_PROFILES.map((profile) => ({ ...profile }));
|
|
292
263
|
}
|