@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const STATEFUL_SIGNATURE_HEADER = "x-apifuse-stateful-signature";
|
|
2
|
+
export declare const STATEFUL_TIMESTAMP_HEADER = "x-apifuse-stateful-timestamp";
|
|
3
|
+
export declare const STATEFUL_NONCE_HEADER = "x-apifuse-stateful-nonce";
|
|
4
|
+
export type StatefulSigningInput = {
|
|
5
|
+
readonly secret: string;
|
|
6
|
+
readonly timestamp: string;
|
|
7
|
+
readonly rawBody: string;
|
|
8
|
+
readonly method: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly nonce: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function signStatefulRequestBody(input: StatefulSigningInput): string;
|
|
13
|
+
export declare function verifyStatefulRequestSignature(input: StatefulSigningInput & {
|
|
14
|
+
readonly signature: string;
|
|
15
|
+
}): boolean;
|
|
16
|
+
export declare function statefulSignedHeaders(input: Omit<StatefulSigningInput, "nonce"> & {
|
|
17
|
+
readonly nonce?: string;
|
|
18
|
+
}): Record<string, string>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
2
|
+
export const STATEFUL_SIGNATURE_HEADER = "x-apifuse-stateful-signature";
|
|
3
|
+
export const STATEFUL_TIMESTAMP_HEADER = "x-apifuse-stateful-timestamp";
|
|
4
|
+
export const STATEFUL_NONCE_HEADER = "x-apifuse-stateful-nonce";
|
|
5
|
+
export function signStatefulRequestBody(input) {
|
|
6
|
+
return `v1=${createHmac("sha256", input.secret)
|
|
7
|
+
.update(`v1:${input.method.toUpperCase()}:${input.path}:${input.timestamp}:${input.nonce}.${input.rawBody}`)
|
|
8
|
+
.digest("hex")}`;
|
|
9
|
+
}
|
|
10
|
+
export function verifyStatefulRequestSignature(input) {
|
|
11
|
+
return safeEqualAscii(input.signature, signStatefulRequestBody(input));
|
|
12
|
+
}
|
|
13
|
+
export function statefulSignedHeaders(input) {
|
|
14
|
+
const nonce = input.nonce ?? randomUUID();
|
|
15
|
+
return {
|
|
16
|
+
[STATEFUL_SIGNATURE_HEADER]: signStatefulRequestBody({ ...input, nonce }),
|
|
17
|
+
[STATEFUL_TIMESTAMP_HEADER]: input.timestamp,
|
|
18
|
+
[STATEFUL_NONCE_HEADER]: nonce,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function safeEqualAscii(actual, expected) {
|
|
22
|
+
const actualBytes = Buffer.from(actual);
|
|
23
|
+
const expectedBytes = Buffer.from(expected);
|
|
24
|
+
if (actualBytes.byteLength !== expectedBytes.byteLength)
|
|
25
|
+
return false;
|
|
26
|
+
return timingSafeEqual(actualBytes, expectedBytes);
|
|
27
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { StealthProfile } from "../types.js";
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
|
|
1
|
+
import type { StealthProfile, StealthProfileDescriptor, StealthProfileSelection } from "../types.js";
|
|
2
|
+
export declare const DEFAULT_STEALTH_BROWSER: "chrome";
|
|
3
|
+
export declare const DEFAULT_STEALTH_OS: "macos";
|
|
4
|
+
/** Internal detector used to keep version-pinned string failures actionable. */
|
|
5
|
+
export declare function getVersionPinnedStealthReplacement(name: string): string | undefined;
|
|
6
|
+
/** Resolve omitted axes and validate that the resulting pair is supported. */
|
|
7
|
+
export declare function resolveStealthProfileSelection(selection: StealthProfileSelection | undefined, base?: StealthProfileDescriptor): StealthProfileDescriptor;
|
|
8
|
+
export declare function getStealthProfile(selection?: StealthProfileSelection): StealthProfile;
|
|
9
|
+
export declare function listStealthProfiles(): StealthProfileDescriptor[];
|
package/dist/stealth/profiles.js
CHANGED
|
@@ -1,49 +1,13 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { SDKError } from "../errors.js";
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"accept-language",
|
|
11
|
-
"cache-control",
|
|
12
|
-
"pragma",
|
|
13
|
-
"cookie",
|
|
14
|
-
"sec-ch-ua",
|
|
15
|
-
"sec-ch-ua-mobile",
|
|
16
|
-
"sec-ch-ua-platform",
|
|
17
|
-
];
|
|
18
|
-
const FIREFOX_HEADER_ORDER = [
|
|
19
|
-
":method",
|
|
20
|
-
":path",
|
|
21
|
-
":authority",
|
|
22
|
-
":scheme",
|
|
23
|
-
"user-agent",
|
|
24
|
-
"accept",
|
|
25
|
-
"accept-language",
|
|
26
|
-
"accept-encoding",
|
|
27
|
-
"referer",
|
|
28
|
-
"cookie",
|
|
29
|
-
"upgrade-insecure-requests",
|
|
30
|
-
"sec-fetch-dest",
|
|
31
|
-
"sec-fetch-mode",
|
|
32
|
-
"sec-fetch-site",
|
|
33
|
-
"sec-fetch-user",
|
|
34
|
-
];
|
|
35
|
-
const SAFARI_HEADER_ORDER = [
|
|
36
|
-
":method",
|
|
37
|
-
":scheme",
|
|
38
|
-
":path",
|
|
39
|
-
":authority",
|
|
40
|
-
"accept",
|
|
41
|
-
"user-agent",
|
|
42
|
-
"accept-language",
|
|
43
|
-
"accept-encoding",
|
|
44
|
-
"cookie",
|
|
45
|
-
"upgrade-insecure-requests",
|
|
46
|
-
];
|
|
3
|
+
const requireModule = createRequire(import.meta.url);
|
|
4
|
+
let wreqProfileApi;
|
|
5
|
+
function getWreqProfileApi() {
|
|
6
|
+
wreqProfileApi ??= requireModule("wreq-js");
|
|
7
|
+
return wreqProfileApi;
|
|
8
|
+
}
|
|
9
|
+
export const DEFAULT_STEALTH_BROWSER = "chrome";
|
|
10
|
+
export const DEFAULT_STEALTH_OS = "macos";
|
|
47
11
|
const CHROMIUM_H2_SETTINGS = {
|
|
48
12
|
HEADER_TABLE_SIZE: 65536,
|
|
49
13
|
ENABLE_PUSH: 0,
|
|
@@ -57,7 +21,7 @@ const FIREFOX_H2_SETTINGS = {
|
|
|
57
21
|
MAX_HEADER_LIST_SIZE: 65536,
|
|
58
22
|
};
|
|
59
23
|
const SAFARI_H2_SETTINGS = {
|
|
60
|
-
|
|
24
|
+
// Safari 17 also sends a connection-level WINDOW_UPDATE increment of 10485760.
|
|
61
25
|
ENABLE_PUSH: 0,
|
|
62
26
|
INITIAL_WINDOW_SIZE: 4194304,
|
|
63
27
|
MAX_CONCURRENT_STREAMS: 100,
|
|
@@ -65,186 +29,171 @@ const SAFARI_H2_SETTINGS = {
|
|
|
65
29
|
const CHROMIUM_JA3 = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-65037,29-23-24,0";
|
|
66
30
|
const FIREFOX_JA3 = "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-28-27-43-45-51,29-23-24-25,0";
|
|
67
31
|
const SAFARI_JA3 = "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";
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
32
|
+
const SUPPORTED_STEALTH_PROFILES = [
|
|
33
|
+
{ browser: "chrome", os: "windows" },
|
|
34
|
+
{ browser: "chrome", os: "macos" },
|
|
35
|
+
{ browser: "chrome", os: "linux" },
|
|
36
|
+
{ browser: "firefox", os: "windows" },
|
|
37
|
+
{ browser: "firefox", os: "macos" },
|
|
38
|
+
{ browser: "firefox", os: "linux" },
|
|
39
|
+
{ browser: "safari", os: "macos" },
|
|
40
|
+
{ browser: "safari", os: "ios" },
|
|
41
|
+
];
|
|
42
|
+
const DESKTOP_OSES = new Set(["windows", "macos", "linux"]);
|
|
43
|
+
function structuredReplacement(browser, os) {
|
|
44
|
+
return `stealth: { browser: "${browser}", os: "${os}" }`;
|
|
80
45
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
return
|
|
46
|
+
/** Internal detector used to keep version-pinned string failures actionable. */
|
|
47
|
+
export function getVersionPinnedStealthReplacement(name) {
|
|
48
|
+
if (/^(?:chrome|chromium|edge)[-_]\d/i.test(name)) {
|
|
49
|
+
return structuredReplacement("chrome", DEFAULT_STEALTH_OS);
|
|
85
50
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return identifierVersion;
|
|
51
|
+
if (/^firefox[-_]\d/i.test(name)) {
|
|
52
|
+
return structuredReplacement("firefox", DEFAULT_STEALTH_OS);
|
|
89
53
|
}
|
|
90
|
-
|
|
54
|
+
if (/^(?:ios[-_]safari|safari[-_](?:ios|ipad))[-_]\d/i.test(name)) {
|
|
55
|
+
return structuredReplacement("safari", "ios");
|
|
56
|
+
}
|
|
57
|
+
if (/^safari[-_]\d/i.test(name)) {
|
|
58
|
+
return structuredReplacement("safari", DEFAULT_STEALTH_OS);
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
function rejectStringSelection(name) {
|
|
63
|
+
const replacement = getVersionPinnedStealthReplacement(name);
|
|
64
|
+
if (replacement) {
|
|
65
|
+
throw new SDKError(`Stealth profile "${name}" pins a browser version and is not supported. Use ${replacement}.`, { code: "STEALTH_VERSION_PIN_UNSUPPORTED" });
|
|
66
|
+
}
|
|
67
|
+
throw new SDKError(`Stealth profile names are no longer supported: "${name}". Use structured browser/os options.`, { code: "STEALTH_PROFILE_NAME_UNSUPPORTED" });
|
|
91
68
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return '"Linux"';
|
|
100
|
-
case "android":
|
|
101
|
-
return '"Android"';
|
|
102
|
-
case "ios":
|
|
103
|
-
return '"iOS"';
|
|
69
|
+
function assertSupportedDescriptor(browser, os) {
|
|
70
|
+
const supported = (browser === "chrome" && DESKTOP_OSES.has(os)) ||
|
|
71
|
+
(browser === "firefox" && DESKTOP_OSES.has(os)) ||
|
|
72
|
+
(browser === "safari" && (os === "macos" || os === "ios"));
|
|
73
|
+
if (!supported) {
|
|
74
|
+
throw new SDKError(`Unsupported stealth browser/OS combination: ${browser}/${os}. ` +
|
|
75
|
+
"Chrome and Firefox support windows, macos, and linux; Safari supports macos and ios.", { code: "STEALTH_PROFILE_UNAVAILABLE" });
|
|
104
76
|
}
|
|
105
77
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
78
|
+
/** Resolve omitted axes and validate that the resulting pair is supported. */
|
|
79
|
+
export function resolveStealthProfileSelection(selection, base) {
|
|
80
|
+
if (typeof selection === "string")
|
|
81
|
+
rejectStringSelection(selection);
|
|
82
|
+
if (selection !== undefined && (typeof selection !== "object" || selection === null)) {
|
|
83
|
+
throw new SDKError("Stealth profile selection must use structured browser/os options.");
|
|
84
|
+
}
|
|
85
|
+
const unsafeSelection = selection;
|
|
86
|
+
if (unsafeSelection && "profile" in unsafeSelection) {
|
|
87
|
+
if (typeof unsafeSelection.profile === "string")
|
|
88
|
+
rejectStringSelection(unsafeSelection.profile);
|
|
89
|
+
throw new SDKError("stealth.profile is no longer supported. Use stealth.browser and stealth.os.", { code: "STEALTH_PROFILE_NAME_UNSUPPORTED" });
|
|
90
|
+
}
|
|
91
|
+
const browser = unsafeSelection?.browser ?? base?.browser ?? DEFAULT_STEALTH_BROWSER;
|
|
92
|
+
if (browser !== "chrome" && browser !== "firefox" && browser !== "safari") {
|
|
93
|
+
throw new SDKError(`Unsupported stealth browser: ${String(browser)}`);
|
|
94
|
+
}
|
|
95
|
+
const browserChanged = base !== undefined && unsafeSelection?.browser !== undefined && browser !== base.browser;
|
|
96
|
+
const os = unsafeSelection?.os ?? (browserChanged ? DEFAULT_STEALTH_OS : base?.os) ?? DEFAULT_STEALTH_OS;
|
|
97
|
+
if (os !== "windows" && os !== "macos" && os !== "linux" && os !== "ios") {
|
|
98
|
+
throw new SDKError(`Unsupported stealth OS: ${String(os)}`);
|
|
99
|
+
}
|
|
100
|
+
assertSupportedDescriptor(browser, os);
|
|
101
|
+
return { browser, os };
|
|
102
|
+
}
|
|
103
|
+
/** Resolve the newest Chromium build exposed by the exactly pinned wreq-js package. */
|
|
104
|
+
function resolveLatestChromiumProfile() {
|
|
105
|
+
const { getProfiles } = getWreqProfileApi();
|
|
106
|
+
let newest;
|
|
107
|
+
for (const name of getProfiles()) {
|
|
108
|
+
const match = /^chrome_(\d+)$/.exec(name);
|
|
109
|
+
if (!match)
|
|
110
|
+
continue;
|
|
111
|
+
const version = Number(match[1]);
|
|
112
|
+
if (!newest || version > newest.version)
|
|
113
|
+
newest = { name, version };
|
|
114
|
+
}
|
|
115
|
+
if (!newest) {
|
|
116
|
+
throw new SDKError("wreq-js exposes no chrome_<version> emulation profile.", {
|
|
117
|
+
code: "STEALTH_PROFILE_UNAVAILABLE",
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return { wreqName: newest.name, version: `${newest.version}.0.0.0` };
|
|
121
|
+
}
|
|
122
|
+
/** Read the identity wreq itself emits so the accessor and transport cannot diverge. */
|
|
123
|
+
function emulationUserAgent(profile, os) {
|
|
124
|
+
for (const [name, value] of getWreqProfileApi().getEmulationHeaders(profile, os)) {
|
|
125
|
+
if (String(name).toLowerCase() === "user-agent")
|
|
126
|
+
return String(value);
|
|
127
|
+
}
|
|
128
|
+
throw new SDKError(`wreq-js profile ${profile} exposes no user-agent header.`, {
|
|
129
|
+
code: "STEALTH_PROFILE_UNAVAILABLE",
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function createProfile(descriptor, definition) {
|
|
133
|
+
return {
|
|
134
|
+
...descriptor,
|
|
135
|
+
...definition,
|
|
136
|
+
h2Settings: definition.h2Settings ? { ...definition.h2Settings } : undefined,
|
|
109
137
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
138
|
+
}
|
|
139
|
+
function profileKey(descriptor) {
|
|
140
|
+
return `${descriptor.browser}:${descriptor.os}`;
|
|
141
|
+
}
|
|
142
|
+
let stealthProfileCatalog;
|
|
143
|
+
function getStealthProfileCatalog() {
|
|
144
|
+
if (stealthProfileCatalog)
|
|
145
|
+
return stealthProfileCatalog;
|
|
146
|
+
const latestChrome = resolveLatestChromiumProfile();
|
|
147
|
+
const definitions = {
|
|
148
|
+
chrome: {
|
|
149
|
+
version: latestChrome.version,
|
|
150
|
+
tlsClientIdentifier: latestChrome.wreqName,
|
|
151
|
+
ja3: CHROMIUM_JA3,
|
|
152
|
+
h2Settings: CHROMIUM_H2_SETTINGS,
|
|
153
|
+
},
|
|
154
|
+
firefox: {
|
|
155
|
+
version: "147.0",
|
|
156
|
+
tlsClientIdentifier: "firefox_147",
|
|
157
|
+
ja3: FIREFOX_JA3,
|
|
158
|
+
h2Settings: FIREFOX_H2_SETTINGS,
|
|
159
|
+
},
|
|
160
|
+
safari: {
|
|
161
|
+
version: "17.0",
|
|
162
|
+
tlsClientIdentifier: "safari_17.0",
|
|
163
|
+
ja3: SAFARI_JA3,
|
|
164
|
+
h2Settings: SAFARI_H2_SETTINGS,
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
stealthProfileCatalog = new Map();
|
|
168
|
+
for (const descriptor of SUPPORTED_STEALTH_PROFILES) {
|
|
169
|
+
const isMobileSafari = descriptor.browser === "safari" && descriptor.os === "ios";
|
|
170
|
+
const definition = isMobileSafari
|
|
171
|
+
? {
|
|
172
|
+
version: "26.0",
|
|
173
|
+
tlsClientIdentifier: "safari_ios_26",
|
|
174
|
+
ja3: SAFARI_JA3,
|
|
175
|
+
h2Settings: SAFARI_H2_SETTINGS,
|
|
176
|
+
}
|
|
177
|
+
: definitions[descriptor.browser];
|
|
178
|
+
const wreqName = definition.tlsClientIdentifier;
|
|
179
|
+
stealthProfileCatalog.set(profileKey(descriptor), createProfile(descriptor, {
|
|
180
|
+
...definition,
|
|
181
|
+
userAgent: emulationUserAgent(wreqName, descriptor.os),
|
|
182
|
+
}));
|
|
120
183
|
}
|
|
121
|
-
return
|
|
184
|
+
return stealthProfileCatalog;
|
|
122
185
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const STEALTH_PROFILES = {
|
|
127
|
-
"chrome-146": createProfile("chrome-146", {
|
|
128
|
-
platform: "macos",
|
|
129
|
-
version: "146.0.0.0",
|
|
130
|
-
userAgent: "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",
|
|
131
|
-
tlsClientIdentifier: "chrome_146",
|
|
132
|
-
ja3: CHROMIUM_JA3,
|
|
133
|
-
h2Settings: CHROMIUM_H2_SETTINGS,
|
|
134
|
-
headerOrder: CHROMIUM_HEADER_ORDER,
|
|
135
|
-
}),
|
|
136
|
-
"firefox-147": createProfile("firefox-147", {
|
|
137
|
-
platform: "macos",
|
|
138
|
-
version: "147.0",
|
|
139
|
-
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0",
|
|
140
|
-
tlsClientIdentifier: "firefox_147",
|
|
141
|
-
ja3: FIREFOX_JA3,
|
|
142
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
143
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
144
|
-
}),
|
|
145
|
-
"firefox-135": createProfile("firefox-135", {
|
|
146
|
-
platform: "macos",
|
|
147
|
-
version: "135.0",
|
|
148
|
-
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0",
|
|
149
|
-
tlsClientIdentifier: "firefox_135",
|
|
150
|
-
ja3: FIREFOX_JA3,
|
|
151
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
152
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
153
|
-
}),
|
|
154
|
-
"firefox-133": createProfile("firefox-133", {
|
|
155
|
-
platform: "macos",
|
|
156
|
-
version: "133.0",
|
|
157
|
-
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:133.0) Gecko/20100101 Firefox/133.0",
|
|
158
|
-
tlsClientIdentifier: "firefox_133",
|
|
159
|
-
ja3: FIREFOX_JA3,
|
|
160
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
161
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
162
|
-
}),
|
|
163
|
-
"firefox-132": createProfile("firefox-132", {
|
|
164
|
-
platform: "macos",
|
|
165
|
-
version: "132.0",
|
|
166
|
-
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0",
|
|
167
|
-
tlsClientIdentifier: "firefox_132",
|
|
168
|
-
ja3: FIREFOX_JA3,
|
|
169
|
-
h2Settings: FIREFOX_H2_SETTINGS,
|
|
170
|
-
headerOrder: FIREFOX_HEADER_ORDER,
|
|
171
|
-
}),
|
|
172
|
-
"safari-16": createProfile("safari-16", {
|
|
173
|
-
platform: "macos",
|
|
174
|
-
version: "16.0",
|
|
175
|
-
userAgent: "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",
|
|
176
|
-
tlsClientIdentifier: "safari_16_0",
|
|
177
|
-
ja3: SAFARI_JA3,
|
|
178
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
179
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
180
|
-
}),
|
|
181
|
-
"safari-15": createProfile("safari-15", {
|
|
182
|
-
platform: "macos",
|
|
183
|
-
version: "15.6.1",
|
|
184
|
-
userAgent: "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",
|
|
185
|
-
tlsClientIdentifier: "safari_15_6_1",
|
|
186
|
-
ja3: SAFARI_JA3,
|
|
187
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
188
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
189
|
-
}),
|
|
190
|
-
"ios-safari-26": createProfile("ios-safari-26", {
|
|
191
|
-
platform: "ios",
|
|
192
|
-
version: "26.0",
|
|
193
|
-
userAgent: "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",
|
|
194
|
-
tlsClientIdentifier: "safari_ios_26_0",
|
|
195
|
-
ja3: SAFARI_JA3,
|
|
196
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
197
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
198
|
-
}),
|
|
199
|
-
"ios-safari-18": createProfile("ios-safari-18", {
|
|
200
|
-
platform: "ios",
|
|
201
|
-
version: "18.0",
|
|
202
|
-
userAgent: "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",
|
|
203
|
-
tlsClientIdentifier: "safari_ios_18_0",
|
|
204
|
-
ja3: SAFARI_JA3,
|
|
205
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
206
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
207
|
-
}),
|
|
208
|
-
"ios-safari-17": createProfile("ios-safari-17", {
|
|
209
|
-
platform: "ios",
|
|
210
|
-
version: "17.0",
|
|
211
|
-
userAgent: "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",
|
|
212
|
-
tlsClientIdentifier: "safari_ios_17_0",
|
|
213
|
-
ja3: SAFARI_JA3,
|
|
214
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
215
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
216
|
-
}),
|
|
217
|
-
"generic-desktop": createProfile("generic-desktop", {
|
|
218
|
-
platform: "macos",
|
|
219
|
-
version: "146.0.0.0",
|
|
220
|
-
userAgent: "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",
|
|
221
|
-
tlsClientIdentifier: "chrome_146",
|
|
222
|
-
ja3: CHROMIUM_JA3,
|
|
223
|
-
h2Settings: CHROMIUM_H2_SETTINGS,
|
|
224
|
-
headerOrder: CHROMIUM_HEADER_ORDER,
|
|
225
|
-
}),
|
|
226
|
-
"generic-mobile": createProfile("generic-mobile", {
|
|
227
|
-
platform: "ios",
|
|
228
|
-
version: "26.0",
|
|
229
|
-
userAgent: "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",
|
|
230
|
-
tlsClientIdentifier: "safari_ios_26_0",
|
|
231
|
-
ja3: SAFARI_JA3,
|
|
232
|
-
h2Settings: SAFARI_H2_SETTINGS,
|
|
233
|
-
headerOrder: SAFARI_HEADER_ORDER,
|
|
234
|
-
}),
|
|
235
|
-
};
|
|
236
|
-
export function getStealthProfile(name) {
|
|
237
|
-
const canonicalName = STEALTH_PROFILE_ALIASES[name] ?? name;
|
|
238
|
-
const profile = STEALTH_PROFILES[canonicalName];
|
|
186
|
+
export function getStealthProfile(selection = {}) {
|
|
187
|
+
const descriptor = resolveStealthProfileSelection(selection);
|
|
188
|
+
const profile = getStealthProfileCatalog().get(profileKey(descriptor));
|
|
239
189
|
if (!profile) {
|
|
240
|
-
throw new SDKError(`Unknown stealth profile: ${
|
|
190
|
+
throw new SDKError(`Unknown stealth profile: ${descriptor.browser}/${descriptor.os}`);
|
|
241
191
|
}
|
|
242
192
|
return {
|
|
243
193
|
...profile,
|
|
244
194
|
h2Settings: profile.h2Settings ? { ...profile.h2Settings } : undefined,
|
|
245
|
-
headerOrder: profile.headerOrder ? [...profile.headerOrder] : undefined,
|
|
246
195
|
};
|
|
247
196
|
}
|
|
248
197
|
export function listStealthProfiles() {
|
|
249
|
-
return
|
|
198
|
+
return SUPPORTED_STEALTH_PROFILES.map((profile) => ({ ...profile }));
|
|
250
199
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type JsonValue } from "./contract-json.js";
|
|
2
|
+
import type { HttpStreamResponse } from "./types.js";
|
|
3
|
+
export declare const STREAM_PREVIEW_BYTES = 4096;
|
|
4
|
+
export declare const STREAM_FINALIZE_TIMEOUT_MS = 30000;
|
|
5
|
+
declare const STREAM_EVIDENCE_HEADER_NAMES: readonly ["content-disposition", "content-length", "content-type"];
|
|
6
|
+
type StreamEvidenceHeaderName = (typeof STREAM_EVIDENCE_HEADER_NAMES)[number];
|
|
7
|
+
export type StreamEvidenceHeaders = Partial<Record<StreamEvidenceHeaderName, string>>;
|
|
8
|
+
export interface StreamEvidenceRequest {
|
|
9
|
+
ordinal: number;
|
|
10
|
+
method: string;
|
|
11
|
+
path: string;
|
|
12
|
+
}
|
|
13
|
+
declare const STREAM_EVIDENCE_REDACTION_REASONS: readonly ["high-entropy-token", "malformed-json", "pem-private-key", "sanitized-preview-too-large", "sanitizer-output-invalid", "sensitive-delimited-column", "textual-xml", "truncated-form", "truncated-json", "undecodable-text"];
|
|
14
|
+
export type StreamEvidenceRedactionReason = (typeof STREAM_EVIDENCE_REDACTION_REASONS)[number];
|
|
15
|
+
export interface StreamEvidenceRecord {
|
|
16
|
+
__apifuse_stream__: true;
|
|
17
|
+
status: number;
|
|
18
|
+
ok: boolean;
|
|
19
|
+
headers: StreamEvidenceHeaders;
|
|
20
|
+
body_sha256: string;
|
|
21
|
+
body_bytes: number;
|
|
22
|
+
body_preview_base64: string;
|
|
23
|
+
request?: StreamEvidenceRequest;
|
|
24
|
+
preview_sanitized?: true;
|
|
25
|
+
preview_redaction_reason?: StreamEvidenceRedactionReason;
|
|
26
|
+
}
|
|
27
|
+
export type StreamEvidenceReplayResponse = HttpStreamResponse & {
|
|
28
|
+
evidence_only: true;
|
|
29
|
+
body_sha256: string;
|
|
30
|
+
body_bytes: number;
|
|
31
|
+
preview_sanitized?: true;
|
|
32
|
+
preview_redaction_reason?: StreamEvidenceRedactionReason;
|
|
33
|
+
};
|
|
34
|
+
export interface StreamEvidenceCapture {
|
|
35
|
+
response: HttpStreamResponse;
|
|
36
|
+
getEvidence(): Promise<StreamEvidenceRecord>;
|
|
37
|
+
}
|
|
38
|
+
export type StreamCaptureGroupItem = {
|
|
39
|
+
kind: "stream";
|
|
40
|
+
evidence: StreamEvidenceRecord;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "response";
|
|
43
|
+
value: JsonValue;
|
|
44
|
+
};
|
|
45
|
+
export interface StreamCaptureGroup {
|
|
46
|
+
items: StreamCaptureGroupItem[];
|
|
47
|
+
}
|
|
48
|
+
export interface StreamCaptureEnvelope {
|
|
49
|
+
__apifuse_capture__: true;
|
|
50
|
+
items: StreamCaptureGroupItem[];
|
|
51
|
+
}
|
|
52
|
+
export type StreamEvidenceCaptureOptions = {
|
|
53
|
+
requestUrl: string;
|
|
54
|
+
sanitizeFixture?: (value: JsonValue) => JsonValue;
|
|
55
|
+
request?: StreamEvidenceRequest;
|
|
56
|
+
finalizeTimeoutMs?: number;
|
|
57
|
+
};
|
|
58
|
+
export declare function parseStreamEvidenceRecord(value: unknown): StreamEvidenceRecord;
|
|
59
|
+
export declare function isStreamEvidenceRecord(value: unknown): value is StreamEvidenceRecord;
|
|
60
|
+
export declare function findStreamEvidenceRecord(value: unknown): StreamEvidenceRecord | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Selects every stream captured by the latest recording invocation, in stream call order.
|
|
63
|
+
* Evidence without request ordinals uses the legacy latest-record-only behavior.
|
|
64
|
+
*/
|
|
65
|
+
export declare function findStreamEvidenceRecords(value: unknown): StreamEvidenceRecord[];
|
|
66
|
+
/** Returns a tagged latest mixed response group used by evidence-only snapshot replay. */
|
|
67
|
+
export declare function findStreamCaptureGroup(value: unknown): StreamCaptureGroup | undefined;
|
|
68
|
+
/** Creates a discriminated invocation envelope so ordinary arrays cannot mimic capture timelines. */
|
|
69
|
+
export declare function createStreamCaptureEnvelope(items: StreamCaptureGroupItem[]): StreamCaptureEnvelope;
|
|
70
|
+
export declare function isStreamEvidenceReplayResponse(response: HttpStreamResponse): response is StreamEvidenceReplayResponse;
|
|
71
|
+
export declare function captureStreamEvidence(response: HttpStreamResponse, options: StreamEvidenceCaptureOptions): StreamEvidenceCapture;
|
|
72
|
+
export declare function replayStreamEvidence(evidence: StreamEvidenceRecord): StreamEvidenceReplayResponse;
|
|
73
|
+
export declare function hasStreamEvidenceMarker(value: unknown): boolean;
|
|
74
|
+
export {};
|