@apifuse/provider-sdk 2.2.0-beta.47 → 2.2.0-beta.49
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 +91 -36
- package/CHANGELOG.md +8 -0
- package/README.md +11 -9
- package/SUBMISSION.md +1 -1
- package/bin/apifuse-dev.ts +24 -13
- package/bin/apifuse-migrate-operation-declaration.ts +55 -0
- package/bin/apifuse-pack-smoke.ts +1 -1
- package/bin/apifuse-pack-types.ts +2 -1
- package/bin/apifuse-record.ts +30 -16
- package/bin/apifuse-submit-check.ts +20 -35
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +11 -0
- package/dist/cli/migrate-operation-declaration.d.ts +59 -0
- package/dist/cli/migrate-operation-declaration.js +1178 -0
- package/dist/cli/templates/provider/README.md.tpl +3 -3
- package/dist/cli/templates/provider/operations/ping.ts.tpl +2 -0
- package/dist/config/loader.d.ts +2 -0
- package/dist/config/loader.js +18 -7
- package/dist/contract-types.d.ts +11 -5
- package/dist/contract.js +21 -10
- package/dist/define.d.ts +25 -22
- package/dist/define.js +49 -75
- 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/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/lint.d.ts +7 -15
- package/dist/lint.js +45 -70
- package/dist/provider.d.ts +3 -1
- package/dist/provider.js +1 -0
- 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 +2 -1
- package/dist/runtime/executor.js +3 -36
- package/dist/runtime/insights.js +2 -2
- package/dist/runtime/otlp.d.ts +71 -2
- package/dist/runtime/otlp.js +397 -16
- package/dist/runtime/resolver-public.d.ts +1 -1
- package/dist/runtime/resolver-public.js +1 -1
- package/dist/runtime/resolver-vendors/capsolver.js +9 -3
- package/dist/runtime/resolver-vendors/twocaptcha.js +1 -0
- package/dist/runtime/resolver.d.ts +12 -0
- package/dist/runtime/resolver.js +45 -11
- package/dist/runtime/stealth.d.ts +13 -4
- package/dist/runtime/stealth.js +362 -85
- package/dist/runtime/trace-config.js +2 -1
- package/dist/runtime/trace.d.ts +5 -0
- package/dist/runtime/trace.js +43 -10
- package/dist/server/self-test.d.ts +1 -3
- package/dist/server/self-test.js +2 -12
- package/dist/server/serve-implementation.d.ts +6 -1
- package/dist/server/serve-implementation.js +55 -40
- package/dist/server/trace-output.d.ts +3 -1
- package/dist/server/trace-output.js +61 -2
- package/dist/stealth/profiles.d.ts +9 -8
- package/dist/stealth/profiles.js +123 -286
- package/dist/types.d.ts +116 -108
- package/package.json +2 -1
- 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 +13 -0
- package/src/cli/migrate-operation-declaration.ts +1654 -0
- package/src/cli/templates/provider/README.md.tpl +3 -3
- package/src/cli/templates/provider/operations/ping.ts.tpl +2 -0
- package/src/config/loader.ts +31 -6
- package/src/contract-types.ts +11 -5
- package/src/contract.ts +21 -10
- package/src/define.ts +107 -119
- package/src/dev.ts +4 -1
- package/src/engine.ts +279 -0
- package/src/index.ts +13 -5
- package/src/lint.ts +58 -92
- package/src/provider.ts +25 -3
- package/src/runtime/chrome149-header-order.ts +330 -0
- package/src/runtime/env.ts +13 -0
- package/src/runtime/executor.ts +7 -40
- package/src/runtime/insights.ts +2 -2
- package/src/runtime/otlp.ts +467 -21
- package/src/runtime/resolver-public.ts +3 -0
- package/src/runtime/resolver-vendors/capsolver.ts +12 -4
- package/src/runtime/resolver-vendors/twocaptcha.ts +1 -0
- package/src/runtime/resolver.ts +68 -19
- package/src/runtime/stealth.ts +435 -103
- package/src/runtime/trace-config.ts +3 -2
- package/src/runtime/trace.ts +57 -17
- package/src/server/self-test.ts +2 -9
- package/src/server/serve-implementation.ts +89 -72
- package/src/server/trace-output.ts +99 -2
- package/src/stealth/profiles.ts +169 -327
- package/src/types.ts +114 -137
package/dist/engine.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ProviderError } from "./errors.js";
|
|
2
|
+
import { OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_HEADERS, OTEL_RESOURCE_ATTRIBUTES, OTEL_SERVICE_NAME, } from "./runtime/otlp.js";
|
|
3
|
+
/** Versioned envelope protocol used by out-of-process engine transports. */
|
|
4
|
+
export const PROVIDER_ENGINE_PROTOCOL_VERSION = "provider-engine.v1";
|
|
5
|
+
/** Credential names owned by the engine and forbidden in provider declarations. */
|
|
6
|
+
export const ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAMES = [
|
|
7
|
+
"APIFUSE__PROXY__SMARTPROXY_APP_KEY",
|
|
8
|
+
"APIFUSE__PROXY__NODEMAVEN_USERNAME",
|
|
9
|
+
"APIFUSE__PROXY__NODEMAVEN_PASSWORD",
|
|
10
|
+
];
|
|
11
|
+
const ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAME_SET = new Set(ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAMES);
|
|
12
|
+
/**
|
|
13
|
+
* Environment names are compared case-insensitively: Windows resolves `otel_exporter_otlp_headers`
|
|
14
|
+
* to the same variable as `OTEL_EXPORTER_OTLP_HEADERS`, so a mixed-case alias must be treated as
|
|
15
|
+
* the engine-owned name it resolves to.
|
|
16
|
+
*/
|
|
17
|
+
function canonicalEnvName(name) {
|
|
18
|
+
return name.toUpperCase();
|
|
19
|
+
}
|
|
20
|
+
export function isEngineOwnedProxyCredentialName(name) {
|
|
21
|
+
return ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAME_SET.has(canonicalEnvName(name));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Trace-export configuration owned by the engine and forbidden in provider
|
|
25
|
+
* declarations. The header variables carry collector credentials; the rest are
|
|
26
|
+
* engine deployment settings a provider has no reason to read.
|
|
27
|
+
*/
|
|
28
|
+
export const ENGINE_OWNED_TELEMETRY_ENV_NAMES = [
|
|
29
|
+
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,
|
|
30
|
+
OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
31
|
+
OTEL_EXPORTER_OTLP_TRACES_HEADERS,
|
|
32
|
+
OTEL_EXPORTER_OTLP_HEADERS,
|
|
33
|
+
OTEL_SERVICE_NAME,
|
|
34
|
+
OTEL_RESOURCE_ATTRIBUTES,
|
|
35
|
+
];
|
|
36
|
+
const ENGINE_OWNED_TELEMETRY_ENV_NAME_SET = new Set(ENGINE_OWNED_TELEMETRY_ENV_NAMES);
|
|
37
|
+
export function isEngineOwnedTelemetryEnvName(name) {
|
|
38
|
+
return ENGINE_OWNED_TELEMETRY_ENV_NAME_SET.has(canonicalEnvName(name));
|
|
39
|
+
}
|
|
40
|
+
/** Every environment name the engine owns: rejected in declarations and filtered from provider projections. */
|
|
41
|
+
export function isEngineOwnedEnvName(name) {
|
|
42
|
+
return isEngineOwnedProxyCredentialName(name) || isEngineOwnedTelemetryEnvName(name);
|
|
43
|
+
}
|
|
44
|
+
/** Capture credentials in the engine host before constructing provider bindings. */
|
|
45
|
+
export function readEngineProxyCredentials(environment = process.env) {
|
|
46
|
+
return Object.fromEntries(ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAMES.flatMap((name) => {
|
|
47
|
+
const value = environment[name]?.trim();
|
|
48
|
+
return value ? [[name, value]] : [];
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
/** Build the exact environment projection permitted to enter a provider runtime. */
|
|
52
|
+
export function createProviderEnvironment(environment, declaredNames) {
|
|
53
|
+
return Object.fromEntries(declaredNames.flatMap((name) => {
|
|
54
|
+
if (isEngineOwnedEnvName(name))
|
|
55
|
+
return [];
|
|
56
|
+
const value = environment[name];
|
|
57
|
+
return value === undefined ? [] : [[name, value]];
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
export const PROVIDER_CAPABILITY_KEYS = [
|
|
61
|
+
"env",
|
|
62
|
+
"credential",
|
|
63
|
+
"http",
|
|
64
|
+
"files",
|
|
65
|
+
"native",
|
|
66
|
+
"cache",
|
|
67
|
+
"state",
|
|
68
|
+
"stealth",
|
|
69
|
+
"browser",
|
|
70
|
+
"auth",
|
|
71
|
+
"ocr",
|
|
72
|
+
"stt",
|
|
73
|
+
"resolver",
|
|
74
|
+
"choice",
|
|
75
|
+
];
|
|
76
|
+
const CAPABILITY_KEY_SET = new Set(PROVIDER_CAPABILITY_KEYS);
|
|
77
|
+
function declaresCapability(provider, capability) {
|
|
78
|
+
return Object.hasOwn(provider, capability) && provider[capability] !== undefined;
|
|
79
|
+
}
|
|
80
|
+
function attachmentError(provider, capability) {
|
|
81
|
+
return new ProviderError(`Provider engine could not attach declared capability "${capability}" for provider "${provider.id}"`, {
|
|
82
|
+
code: "PROVIDER_ENGINE_ATTACHMENT_FAILED",
|
|
83
|
+
details: { providerId: provider.id, capability },
|
|
84
|
+
fix: `Configure the engine binding for "${capability}" before starting the provider.`,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function undeclaredCapabilityError(provider, capability) {
|
|
88
|
+
return new ProviderError(`Provider "${provider.id}" accessed undeclared capability "${capability}"; add the "${capability}" declaration`, {
|
|
89
|
+
code: "PROVIDER_CAPABILITY_UNDECLARED",
|
|
90
|
+
details: { providerId: provider.id, capability },
|
|
91
|
+
fix: `Add ${capability}: {} to the provider declaration, or remove the access.`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function attachInProcess(input) {
|
|
95
|
+
const { provider, bindings } = input;
|
|
96
|
+
if (provider.runtimeTarget === "vanilla" && declaresCapability(provider, "native")) {
|
|
97
|
+
throw new ProviderError(`Provider "${provider.id}" cannot attach capability "native" to runtime target "vanilla"; native requires an engine-resident runtime`, {
|
|
98
|
+
code: "PROVIDER_RUNTIME_CAPABILITY_CONFLICT",
|
|
99
|
+
details: { providerId: provider.id, capability: "native", runtimeTarget: "vanilla" },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const context = { trace: bindings.trace };
|
|
103
|
+
if (bindings.request !== undefined)
|
|
104
|
+
context.request = bindings.request;
|
|
105
|
+
for (const capability of PROVIDER_CAPABILITY_KEYS) {
|
|
106
|
+
if (!declaresCapability(provider, capability))
|
|
107
|
+
continue;
|
|
108
|
+
const binding = bindings[capability];
|
|
109
|
+
if (binding === undefined || binding === null)
|
|
110
|
+
throw attachmentError(provider, capability);
|
|
111
|
+
context[capability] = binding;
|
|
112
|
+
}
|
|
113
|
+
return new Proxy(context, {
|
|
114
|
+
get(target, property, receiver) {
|
|
115
|
+
if (typeof property === "string" &&
|
|
116
|
+
CAPABILITY_KEY_SET.has(property) &&
|
|
117
|
+
!declaresCapability(provider, property)) {
|
|
118
|
+
throw undeclaredCapabilityError(provider, property);
|
|
119
|
+
}
|
|
120
|
+
return Reflect.get(target, property, receiver);
|
|
121
|
+
},
|
|
122
|
+
has(target, property) {
|
|
123
|
+
if (typeof property === "string" && CAPABILITY_KEY_SET.has(property)) {
|
|
124
|
+
return declaresCapability(provider, property);
|
|
125
|
+
}
|
|
126
|
+
return Reflect.has(target, property);
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** Local engine attachment; deployed bridges implement the same interface with RPC clients. */
|
|
131
|
+
export function createInProcessProviderEngine() {
|
|
132
|
+
return { attach: attachInProcess };
|
|
133
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type { AssertionExpression, AssertionPredicate, AttemptReference, AssertR
|
|
|
10
10
|
export type { DevServerOptions } from "./dev.js";
|
|
11
11
|
export { createDevServer, startDevServer } from "./dev.js";
|
|
12
12
|
export * from "./errors.js";
|
|
13
|
+
export * from "./engine.js";
|
|
13
14
|
export * from "./observability.js";
|
|
14
15
|
export * from "./user-input.js";
|
|
15
16
|
export * from "./i18n/index.js";
|
|
@@ -43,9 +44,9 @@ export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIF
|
|
|
43
44
|
export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace.js";
|
|
44
45
|
export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, z, } from "./schema.js";
|
|
45
46
|
export { createServerApp, createServerAppAsync, ERROR_OBSERVABILITY_HEADER, type ProviderErrorCauseFrame, type ServeOptions, serve, } from "./server/serve.js";
|
|
46
|
-
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
47
|
+
export { DEFAULT_STEALTH_BROWSER, DEFAULT_STEALTH_OS, getStealthProfile, listStealthProfiles, } from "./stealth/profiles.js";
|
|
47
48
|
export * from "./stream.js";
|
|
48
|
-
export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserCookie, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, ChallengeSolution, ConnectionMode, ContextDeclaration, CookieJar, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, HealthScheduleRandomization, HealthJourneySmsContext, HealthJourneyStep, HttpClient, HttpMethod, HttpRedirectFailureReason, HttpRedirectPolicy, HttpRedirectPolicyMode, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration, NativeContext, NativeNetworkClient, NativeNetworkCloseReason, NativeNetworkConnection, NativeNetworkConnectInput, NativeNetworkConnectOptions, NativeNetworkDynamicGrantOptions, NativeNetworkEgressGrant, NativeProviderConfig, NativeProxyDrainHandler, NativeProxyEgressInfo, NativeProxyExpiringEvent, NativeProxyExpiringReason, NativeTcpDynamicEgressRule, NativeTcpEgressGrant, NativeTcpEgressRule, NativeTcpPortRange, NativeTcpTlsMode, NativeTlsConnectOptions, OcrCaptchaCandidate, OcrCaptchaOptions, OcrCaptchaResult, OcrContext, OcrImageInput, OcrRecognizeRequest, OcrResult, OcrWarning,
|
|
49
|
+
export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserCookie, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, ChallengeSolution, ConnectionMode, ContextDeclaration, CookieJar, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, HealthScheduleRandomization, HealthJourneySmsContext, HealthJourneyStep, HttpClient, HttpMethod, HttpRedirectFailureReason, HttpRedirectPolicy, HttpRedirectPolicyMode, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration, NativeContext, NativeNetworkClient, NativeNetworkCloseReason, NativeNetworkConnection, NativeNetworkConnectInput, NativeNetworkConnectOptions, NativeNetworkDynamicGrantOptions, NativeNetworkEgressGrant, NativeProviderConfig, NativeProxyDrainHandler, NativeProxyEgressInfo, NativeProxyExpiringEvent, NativeProxyExpiringReason, NativeTcpDynamicEgressRule, NativeTcpEgressGrant, NativeTcpEgressRule, NativeTcpPortRange, NativeTcpTlsMode, NativeTlsConnectOptions, OcrCaptchaCandidate, OcrCaptchaOptions, OcrCaptchaResult, OcrContext, OcrImageInput, OcrRecognizeRequest, OcrResult, OcrWarning, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDeprecationMetadata, OperationExample, OperationErrorCode, ProviderErrorStatus, OperationHandlerResult, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationTransport, OperationTransportKind, ProbeInterval, ProviderAccessConfig, ProviderAccessVisibility, ProviderCache, ProviderCacheGetOrSetOptions, ProviderCacheKeyOptions, ProviderCacheLookupMeta, ProviderCacheResponseMeta, ProviderCacheResult, ProviderChoiceBindingOptions, ProviderChoiceConsumeMode, ProviderChoiceConsumeResult, ProviderChoiceContext, ProviderChoiceExplicitParseResult, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderChallenge, ProviderChallengeKind, ProviderContext, ProviderContextFor, ProviderDefinition, ProviderDeploymentOverrides, ProviderFileRef, ProviderFilesContext, ProviderHealthMonitorConfig, ProviderHealthProbeConfig, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderLogoSource, ProviderMeta, ProviderOcrConfig, ProviderProxyConfig, ProviderProxyMode, ProviderProxyPolicy, ProxiedOAuthConfig, ProviderProxyProvider, ProviderProxySessionAffinity, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderReviewed, ProviderResolvedFile, ProviderResolverConfig, ProviderResolverVendor, ProviderRuntimeTarget, ProviderRuntimeState, ProviderSecretDeclaration, ProviderStateDurationString, ProviderStateNamespace, ProviderStreamEvent, ProviderSttConfig, ProviderSttMode, ProviderSupportLevel, RequestOptions, RedirectRunReason, ResolverContext, Rfc3339Instant, SchemaLike, SmsOrigin, SmsOtpExtractionPattern, SmsOtpMatcherDefinition, SseMessage, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateNamespaceScope, StateValue, StateWriteOptions, StealthClient, StealthBrowser, StealthCookieStore, StealthCookieStoreV1, StealthFetchOptions, StealthPlatform, StealthProfile, StealthProfileDescriptor, StealthProfileSelection, StealthOS, StealthRedirectHop, StealthRedirectRunOptions, StealthRedirectRunResult, StealthResponse, StealthSession, StealthSessionCookies, SttAudioInput, SttContext, SttPromptPolicy, SttSegment, SttTranscribeMode, SttTranscribeRequest, SttTranscript, SttUnsupportedOptionPolicy, SttUsage, SttVerificationCodeOptions, SttWarning, TraceConfig, TraceSpan, VerificationCodeCandidate, VerificationCodeCandidateSource, VerificationCodeExtractionResult, } from "./types.js";
|
|
49
50
|
export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
|
|
50
51
|
export * from "./utils/date.js";
|
|
51
52
|
export * from "./utils/parse.js";
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { centered, delayed, defineHealthJourney, defineOperation, defineProvider
|
|
|
8
8
|
export { AssertionExpressionSchema, AssertionPredicateSchema, AssertStepSchema, BoundedJsonPathSchema, CandidateBlockSchema, CandidatePolicySchema, CredentialRefDeclarationSchema, defineHealthScenario, HealthScenarioSchema, HealthStepSchema, ExtractStepSchema, FindFirstSchema, GuardStepSchema, JournalPolicySchema, JsonTemplateSchema, ManualTriggerPolicySchema, OperandSchema, OperationStepSchema, QuantifierSchema, ReferenceSchema, RetryPolicySchema, SafeRegexSchema, ScopedAssertionExpressionSchema, ScopedAssertionPredicateSchema, ScopedItemReferenceSchema, ScopedOperandSchema, StepReferenceSchema, RelativeDateNodeSchema, ValueTypeSchema, } from "./health-scenario.js";
|
|
9
9
|
export { createDevServer, startDevServer } from "./dev.js";
|
|
10
10
|
export * from "./errors.js";
|
|
11
|
+
export * from "./engine.js";
|
|
11
12
|
export * from "./observability.js";
|
|
12
13
|
export * from "./user-input.js";
|
|
13
14
|
export * from "./i18n/index.js";
|
|
@@ -34,7 +35,7 @@ export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIF
|
|
|
34
35
|
export { createTraceContext, } from "./runtime/trace.js";
|
|
35
36
|
export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, sensitive, z, } from "./schema.js";
|
|
36
37
|
export { createServerApp, createServerAppAsync, ERROR_OBSERVABILITY_HEADER, serve, } from "./server/serve.js";
|
|
37
|
-
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
38
|
+
export { DEFAULT_STEALTH_BROWSER, DEFAULT_STEALTH_OS, getStealthProfile, listStealthProfiles, } from "./stealth/profiles.js";
|
|
38
39
|
export * from "./stream.js";
|
|
39
40
|
export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
|
|
40
41
|
export * from "./utils/date.js";
|
package/dist/lint.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OperationApprovalPolicy, OperationRiskClass } from "./types.js";
|
|
1
2
|
type AuthModeLike = "none" | "platform-managed" | "credentials" | "oauth2" | "oauth2_proxied" | "api-key";
|
|
2
3
|
type ProviderAuthLike = {
|
|
3
4
|
mode?: AuthModeLike;
|
|
@@ -37,17 +38,12 @@ export interface ProviderLintResult {
|
|
|
37
38
|
information: ProviderLintInformation[];
|
|
38
39
|
}
|
|
39
40
|
export declare function lintOperation(op: {
|
|
40
|
-
description?: string;
|
|
41
41
|
descriptionKey?: string;
|
|
42
|
-
whenToUse?: readonly string[];
|
|
43
42
|
whenToUseKeys?: readonly string[];
|
|
44
|
-
whenNotToUse?: readonly string[];
|
|
45
43
|
whenNotToUseKeys?: readonly string[];
|
|
46
44
|
input: unknown;
|
|
47
45
|
output: unknown;
|
|
48
46
|
fixtures?: unknown;
|
|
49
|
-
inputExamples?: readonly unknown[];
|
|
50
|
-
derivations?: Record<string, string>;
|
|
51
47
|
}): LintDiagnostic[];
|
|
52
48
|
export declare function lintProvider(provider: {
|
|
53
49
|
id?: string;
|
|
@@ -65,24 +61,20 @@ export declare function lintProvider(provider: {
|
|
|
65
61
|
authFlowSource?: string;
|
|
66
62
|
providerSourceFiles?: Record<string, string>;
|
|
67
63
|
operations?: Record<string, {
|
|
68
|
-
description?: string;
|
|
69
64
|
descriptionKey?: string;
|
|
70
|
-
whenToUse?: readonly string[];
|
|
71
65
|
whenToUseKeys?: readonly string[];
|
|
72
|
-
whenNotToUse?: readonly string[];
|
|
73
66
|
whenNotToUseKeys?: readonly string[];
|
|
67
|
+
connectionMode?: "none" | "optional" | "required";
|
|
68
|
+
riskClass?: OperationRiskClass;
|
|
69
|
+
approval?: OperationApprovalPolicy;
|
|
74
70
|
input: unknown;
|
|
75
71
|
output: unknown;
|
|
76
72
|
fixtures?: unknown;
|
|
77
|
-
inputExamples?: readonly unknown[];
|
|
78
|
-
derivations?: Record<string, string>;
|
|
79
73
|
handler?: unknown;
|
|
80
74
|
source?: string;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}>;
|
|
85
|
-
};
|
|
75
|
+
errorCodes?: ReadonlyArray<{
|
|
76
|
+
code: string;
|
|
77
|
+
}>;
|
|
86
78
|
}>;
|
|
87
79
|
meta?: {
|
|
88
80
|
contract?: ProviderContractMetaLike;
|
package/dist/lint.js
CHANGED
|
@@ -11,6 +11,21 @@ function getTypeScript() {
|
|
|
11
11
|
typeScriptModule ??= requireModule("typescript");
|
|
12
12
|
return typeScriptModule;
|
|
13
13
|
}
|
|
14
|
+
const CREDENTIAL_BEARING_AUTH_MODES = [
|
|
15
|
+
"credentials",
|
|
16
|
+
"oauth2",
|
|
17
|
+
"oauth2_proxied",
|
|
18
|
+
];
|
|
19
|
+
function isCredentialBearingAuthMode(mode) {
|
|
20
|
+
return CREDENTIAL_BEARING_AUTH_MODES.some((credentialMode) => credentialMode === mode);
|
|
21
|
+
}
|
|
22
|
+
function defaultApprovalPolicy(riskClass) {
|
|
23
|
+
if (riskClass === "read")
|
|
24
|
+
return "never";
|
|
25
|
+
if (riskClass === "write")
|
|
26
|
+
return "risk-based";
|
|
27
|
+
return "always";
|
|
28
|
+
}
|
|
14
29
|
// Operations that perform an auth-lifecycle action belong on the single
|
|
15
30
|
// `auth.flow` interface, never on a provider operation:
|
|
16
31
|
// - entry (login / signin / authenticate) => auth.flow.start/continue
|
|
@@ -510,18 +525,6 @@ function collectSchemaDescriptionKeyDiagnostics(schema, basePath, seen = new Set
|
|
|
510
525
|
}
|
|
511
526
|
return diagnostics;
|
|
512
527
|
}
|
|
513
|
-
function isComplexSchema(schema, seen = new Set()) {
|
|
514
|
-
if (!isSchema(schema) || seen.has(schema)) {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
seen.add(schema);
|
|
518
|
-
const children = getChildSchemas(schema);
|
|
519
|
-
const hasNestedComposite = children.some(({ schema: child }) => {
|
|
520
|
-
const childChildren = getChildSchemas(child);
|
|
521
|
-
return childChildren.length > 0;
|
|
522
|
-
});
|
|
523
|
-
return hasNestedComposite || children.some(({ schema: child }) => isComplexSchema(child, seen));
|
|
524
|
-
}
|
|
525
528
|
function hasBidirectionalFixtures(fixtures) {
|
|
526
529
|
if (!fixtures || typeof fixtures !== "object") {
|
|
527
530
|
return true;
|
|
@@ -752,11 +755,11 @@ function collectBrowserVersionLiteralFindings(source) {
|
|
|
752
755
|
function browserVersionLiteralMessage(finding) {
|
|
753
756
|
switch (finding.kind) {
|
|
754
757
|
case "profile":
|
|
755
|
-
return `Hardcoded stealth profile "${finding.literal}" pins a browser version and will rot.
|
|
758
|
+
return `Hardcoded stealth profile "${finding.literal}" pins a browser version and will rot. Select the browser and OS structurally, for example stealth: { browser: "chrome", os: "macos" }.`;
|
|
756
759
|
case "user-agent":
|
|
757
|
-
return `Hardcoded User-Agent browser version "${finding.literal}" can disagree with the stealth TLS fingerprint. Remove the literal and derive it from the
|
|
760
|
+
return `Hardcoded User-Agent browser version "${finding.literal}" can disagree with the stealth TLS fingerprint. Remove the literal and derive it from the structured profile, for example getStealthProfile({ browser: "chrome", os: "macos" }).userAgent.`;
|
|
758
761
|
case "sec-ch-ua":
|
|
759
|
-
return 'Hardcoded sec-ch-ua versions can disagree with the stealth TLS fingerprint. Remove the literal and let ctx.stealth generate client hints from
|
|
762
|
+
return 'Hardcoded sec-ch-ua versions can disagree with the stealth TLS fingerprint. Remove the literal and let ctx.stealth generate client hints from stealth: { browser: "chrome", os: "macos" }; derive any explicit User-Agent with getStealthProfile({ browser: "chrome", os: "macos" }).userAgent.';
|
|
760
763
|
}
|
|
761
764
|
}
|
|
762
765
|
function lintBrowserVersionLiterals(provider) {
|
|
@@ -1002,7 +1005,7 @@ function collectLiteralThrownErrorCodes(source) {
|
|
|
1002
1005
|
* `new ProviderError(...)` / `new ValidationError(...)` constructions whose
|
|
1003
1006
|
* literal `code` is neither SDK-registered (SDK_RUNTIME_OWNED_ERROR_CODES
|
|
1004
1007
|
* plus the canonical status-mapped codes shared with serve.ts toStatusCode)
|
|
1005
|
-
* nor declared in any operation's
|
|
1008
|
+
* nor declared in any operation's errorCodes. At runtime such a code
|
|
1006
1009
|
* serves HTTP 500 and emits the signal; this rule surfaces it at check time.
|
|
1007
1010
|
*
|
|
1008
1011
|
* A throw site cannot be attributed to a specific operation statically —
|
|
@@ -1020,7 +1023,7 @@ function lintUndeclaredThrownErrorCodes(provider) {
|
|
|
1020
1023
|
...SDK_STATUS_MAPPED_PROVIDER_ERROR_CODES.keys(),
|
|
1021
1024
|
]);
|
|
1022
1025
|
for (const operation of Object.values(provider.operations ?? {})) {
|
|
1023
|
-
for (const entry of operation.
|
|
1026
|
+
for (const entry of operation.errorCodes ?? []) {
|
|
1024
1027
|
if (typeof entry?.code === "string") {
|
|
1025
1028
|
knownCodes.add(entry.code);
|
|
1026
1029
|
}
|
|
@@ -1052,7 +1055,7 @@ function lintUndeclaredThrownErrorCodes(provider) {
|
|
|
1052
1055
|
rule: "thrown-error-code-undeclared",
|
|
1053
1056
|
level: "warn",
|
|
1054
1057
|
field,
|
|
1055
|
-
message: `Thrown error code "${code}" (${field}) is neither SDK-registered nor declared in any operation's
|
|
1058
|
+
message: `Thrown error code "${code}" (${field}) is neither SDK-registered nor declared in any operation's errorCodes; at runtime it serves HTTP 500 and emits the unregistered_provider_error_code signal. Declare it in the owning operation's errorCodes with status and retryable.`,
|
|
1056
1059
|
});
|
|
1057
1060
|
}
|
|
1058
1061
|
}
|
|
@@ -1060,48 +1063,13 @@ function lintUndeclaredThrownErrorCodes(provider) {
|
|
|
1060
1063
|
}
|
|
1061
1064
|
export function lintOperation(op) {
|
|
1062
1065
|
const diagnostics = [];
|
|
1063
|
-
const description = op.description ?? "";
|
|
1064
1066
|
const hasDescriptionKey = typeof op.descriptionKey === "string" && op.descriptionKey.length > 0;
|
|
1065
|
-
if (
|
|
1066
|
-
diagnostics.push({
|
|
1067
|
-
rule: "operation-description-raw-prose",
|
|
1068
|
-
level: "error",
|
|
1069
|
-
field: "description",
|
|
1070
|
-
message: "Operation description must use descriptionKey instead of raw static prose.",
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1073
|
-
if (!hasDescriptionKey && description.length < 150) {
|
|
1074
|
-
diagnostics.push({
|
|
1075
|
-
rule: "description-min-length",
|
|
1076
|
-
level: "error",
|
|
1077
|
-
field: "description",
|
|
1078
|
-
message: "Operation description must be at least 150 characters.",
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
if ((op.whenToUse?.length ?? 0) > 0 && !(op.whenToUseKeys?.length ?? 0)) {
|
|
1082
|
-
diagnostics.push({
|
|
1083
|
-
rule: "operation-when-to-use-raw-prose",
|
|
1084
|
-
level: "error",
|
|
1085
|
-
field: "whenToUse",
|
|
1086
|
-
message: "Operation whenToUse must use whenToUseKeys instead of raw static prose.",
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
if ((op.whenNotToUse?.length ?? 0) > 0 && !(op.whenNotToUseKeys?.length ?? 0)) {
|
|
1067
|
+
if (!hasDescriptionKey) {
|
|
1090
1068
|
diagnostics.push({
|
|
1091
|
-
rule: "
|
|
1069
|
+
rule: "description-key-required",
|
|
1092
1070
|
level: "error",
|
|
1093
|
-
field: "
|
|
1094
|
-
message: "Operation
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
const lowerDescription = description.toLowerCase();
|
|
1098
|
-
if (!hasDescriptionKey &&
|
|
1099
|
-
!(lowerDescription.includes("use") && lowerDescription.includes("when"))) {
|
|
1100
|
-
diagnostics.push({
|
|
1101
|
-
rule: "description-has-when-clause",
|
|
1102
|
-
level: "warn",
|
|
1103
|
-
field: "description",
|
|
1104
|
-
message: 'Operation description should include both "use" and "when".',
|
|
1071
|
+
field: "descriptionKey",
|
|
1072
|
+
message: "Operation must declare a locale-backed descriptionKey.",
|
|
1105
1073
|
});
|
|
1106
1074
|
}
|
|
1107
1075
|
diagnostics.push(...collectSchemaDescriptionKeyDiagnostics(op.input, "input"), ...collectSchemaDescriptionKeyDiagnostics(op.output, "output"));
|
|
@@ -1113,14 +1081,6 @@ export function lintOperation(op) {
|
|
|
1113
1081
|
message: "Fixtures must include both request and response.",
|
|
1114
1082
|
});
|
|
1115
1083
|
}
|
|
1116
|
-
if (isComplexSchema(op.input) && (op.inputExamples?.length ?? 0) < 2) {
|
|
1117
|
-
diagnostics.push({
|
|
1118
|
-
rule: "complex-input-has-examples",
|
|
1119
|
-
level: "warn",
|
|
1120
|
-
field: "inputExamples",
|
|
1121
|
-
message: "Complex input schemas should provide at least 2 input examples.",
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
1084
|
for (const field of uniqueFields(collectUnmarkedSensitiveFields(op.input, "input"))) {
|
|
1125
1085
|
diagnostics.push({
|
|
1126
1086
|
rule: "sensitive-field-unmarked",
|
|
@@ -1203,6 +1163,26 @@ export function lintProviderWithInformation(provider, options = {}) {
|
|
|
1203
1163
|
];
|
|
1204
1164
|
if (provider.operations) {
|
|
1205
1165
|
const authMode = provider.auth?.mode;
|
|
1166
|
+
for (const [operationKey, operation] of Object.entries(provider.operations)) {
|
|
1167
|
+
if (isCredentialBearingAuthMode(authMode) && operation.connectionMode === undefined) {
|
|
1168
|
+
diagnostics.push({
|
|
1169
|
+
rule: "mixed-auth-connection-mode-required",
|
|
1170
|
+
level: "error",
|
|
1171
|
+
field: `operations.${operationKey}.connectionMode`,
|
|
1172
|
+
message: `Provider "${provider.id ?? "unknown"}" uses credential-bearing auth.mode "${authMode}"; operation "${operationKey}" must declare connectionMode explicitly.`,
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
if (operation.riskClass !== undefined &&
|
|
1176
|
+
operation.approval !== undefined &&
|
|
1177
|
+
operation.approval === defaultApprovalPolicy(operation.riskClass)) {
|
|
1178
|
+
diagnostics.push({
|
|
1179
|
+
rule: "redundant-approval",
|
|
1180
|
+
level: "error",
|
|
1181
|
+
field: `operations.${operationKey}.approval`,
|
|
1182
|
+
message: `Operation "${operationKey}" approval "${operation.approval}" repeats the default for riskClass "${operation.riskClass}"; omit approval unless it is a deliberate override.`,
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1206
1186
|
// Every authenticated mode owns an auth.flow; `oauth2_proxied` was
|
|
1207
1187
|
// previously exempt, which let auth-lifecycle operations ship on
|
|
1208
1188
|
// proxied providers unchecked.
|
|
@@ -1226,17 +1206,12 @@ export function lintProviderWithInformation(provider, options = {}) {
|
|
|
1226
1206
|
}
|
|
1227
1207
|
diagnostics.push(...Object.entries(provider.operations).flatMap(([operationKey, operation]) => [
|
|
1228
1208
|
...lintOperation({
|
|
1229
|
-
description: operation.description ?? "",
|
|
1230
1209
|
descriptionKey: operation.descriptionKey,
|
|
1231
|
-
whenToUse: operation.whenToUse,
|
|
1232
1210
|
whenToUseKeys: operation.whenToUseKeys,
|
|
1233
|
-
whenNotToUse: operation.whenNotToUse,
|
|
1234
1211
|
whenNotToUseKeys: operation.whenNotToUseKeys,
|
|
1235
1212
|
input: operation.input,
|
|
1236
1213
|
output: operation.output,
|
|
1237
1214
|
fixtures: operation.fixtures,
|
|
1238
|
-
inputExamples: operation.inputExamples,
|
|
1239
|
-
derivations: operation.derivations,
|
|
1240
1215
|
}),
|
|
1241
1216
|
...lintPublicSchemaFieldNames(provider.id, operationKey, operation.input, operation.output, provider.meta?.contract?.publicSchemaFieldNames === "normalized"),
|
|
1242
1217
|
].map((diagnostic) => ({
|
package/dist/provider.d.ts
CHANGED
|
@@ -8,10 +8,12 @@ export type { JsonPrimitive, JsonValue } from "./contract-json.js";
|
|
|
8
8
|
export { AssertionExpressionSchema, AssertionPredicateSchema, AssertStepSchema, BoundedJsonPathSchema, CandidateBlockSchema, CandidatePolicySchema, CredentialRefDeclarationSchema, defineHealthScenario, HealthScenarioSchema, HealthStepSchema, ExtractStepSchema, FindFirstSchema, GuardStepSchema, JournalPolicySchema, JsonTemplateSchema, ManualTriggerPolicySchema, OperandSchema, OperationStepSchema, QuantifierSchema, ReferenceSchema, RetryPolicySchema, SafeRegexSchema, ScopedAssertionExpressionSchema, ScopedAssertionPredicateSchema, ScopedItemReferenceSchema, ScopedOperandSchema, StepReferenceSchema, RelativeDateNodeSchema, ValueTypeSchema, } from "./health-scenario.js";
|
|
9
9
|
export type { AssertionExpression, AssertionPredicate, AttemptReference, AssertResult, AssertStep, BoundedJsonPath, CandidateBlock, CandidatePolicy, CandidateReference, CredentialReference, CredentialRefDeclaration, EstablishedConnectionReference, ExtractStep, FindFirst, GuardAttribution, GuardReasonCode, GuardResult, GuardStep, HealthScenario, HealthStep, JsonTemplate, JournalPolicy, ManualTriggerPolicy, NonEmpty, OperationResult, OperationStep, Operand, Quantifier, ReferenceNode, Reference, RelativeDateNode, RetryPolicy, SafeRegex, ScopedAssertionExpression, ScopedAssertionPredicate, ScopedItemReference, ScopedOperand, StepBase, StepReference, ExtractResult, ValueType, } from "./health-scenario.js";
|
|
10
10
|
export { AuthError, HttpRedirectError, isProviderError, isSessionExpiredError, isTransportError, ProviderError, type ProviderErrorObservability, SessionExpiredError, TransportError, ValidationError, } from "./errors.js";
|
|
11
|
+
export { createProviderEnvironment, createInProcessProviderEngine, ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAMES, ENGINE_OWNED_TELEMETRY_ENV_NAMES, isEngineOwnedEnvName, isEngineOwnedProxyCredentialName, isEngineOwnedTelemetryEnvName, PROVIDER_CAPABILITY_KEYS, PROVIDER_ENGINE_PROTOCOL_VERSION, readEngineProxyCredentials, } from "./engine.js";
|
|
12
|
+
export type { ProviderCapabilityKey, ProviderEngine, ProviderEngineAttachmentInput, ProviderEngineBindingCandidates, ProviderEngineCapabilitySurface, ProviderEngineRequest, ProviderEngineResidentSurface, ProviderEngineSession, ProviderEngineTransport, } from "./engine.js";
|
|
11
13
|
export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n/index.js";
|
|
12
14
|
export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
13
15
|
export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, z, } from "./schema.js";
|
|
14
|
-
export type { AuthAbortData, AuthAbortRetry, AuthFlowTerminalContext, AuthMode, AuthSafeData, AuthSafeJson, FlowContext, HealthCheckAssertionContext, HealthCheckCase, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthScheduleRandomization, HttpRedirectFailureReason, HttpRedirectPolicy, HttpRedirectPolicyMode, HttpRetryOptions, HttpRetrySummary, InferSchemaOutput, NativeContext, NativeNetworkClient, NativeNetworkCloseReason, NativeNetworkConnection, NativeNetworkConnectInput, NativeNetworkConnectOptions, NativeNetworkDynamicGrantOptions, NativeNetworkEgressGrant, NativeProviderConfig, NativeProxyDrainHandler, NativeProxyEgressInfo, NativeProxyExpiringEvent, NativeProxyExpiringReason, NativeTcpDynamicEgressRule, NativeTcpEgressGrant, NativeTcpEgressRule, NativeTcpPortRange, NativeTcpTlsMode, NativeTlsConnectOptions, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition,
|
|
16
|
+
export type { AuthAbortData, AuthAbortRetry, AuthFlowTerminalContext, AuthMode, AuthSafeData, AuthSafeJson, FlowContext, HealthCheckAssertionContext, HealthCheckCase, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthScheduleRandomization, HttpRedirectFailureReason, HttpRedirectPolicy, HttpRedirectPolicyMode, HttpRetryOptions, HttpRetrySummary, InferSchemaOutput, NativeContext, NativeNetworkClient, NativeNetworkCloseReason, NativeNetworkConnection, NativeNetworkConnectInput, NativeNetworkConnectOptions, NativeNetworkDynamicGrantOptions, NativeNetworkEgressGrant, NativeProviderConfig, NativeProxyDrainHandler, NativeProxyEgressInfo, NativeProxyExpiringEvent, NativeProxyExpiringReason, NativeTcpDynamicEgressRule, NativeTcpEgressGrant, NativeTcpEgressRule, NativeTcpPortRange, NativeTcpTlsMode, NativeTlsConnectOptions, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationExample, OperationErrorCode, ProviderErrorStatus, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationTransport, ProviderAccessVisibility, ProviderChoiceBindingOptions, ProviderChoiceConsumeMode, ProviderChoiceConsumeResult, ProviderChoiceContext, ProviderChoiceExplicitParseResult, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderContextFor, ProviderDefinition, ProviderDeploymentOverrides, ProviderFileRef, ProviderFilesContext, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderProxyPolicy, ProxiedOAuthConfig, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderResolvedFile, ProviderRuntimeTarget, ProviderRuntimeState, ProviderStateDurationString, ProviderStateNamespace, ProviderSupportLevel, RedirectRunReason, SchemaLike, SmsOtpMatcherDefinition, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateNamespaceScope, StateValue, StateWriteOptions, } from "./types.js";
|
|
15
17
|
export { NativeEgressGrantExpiredError, NativeEgressNotDeclaredError, NativeIdleTimeoutError, NativeNetworkError, NativeProxyExpiredError, } from "./runtime/native-network-errors.js";
|
|
16
18
|
export type { NativeGatewayProxy, NativeGatewayProxyResolutionInput, NativeGatewayProxySkipReason, NativeGatewayProxySynthesizer, NativeGatewayProxySynthesisResult, NativeGatewayProxySynthesisInput, NativeNetworkClientOptions, NativeNetworkErrorCode, VendorCredentialLookup, VendorCredentialResolver, } from "./runtime/native-network.js";
|
|
17
19
|
export { HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, } from "./types.js";
|
package/dist/provider.js
CHANGED
|
@@ -4,6 +4,7 @@ export { assertFreshProviderChoiceIssuedAt, createProviderChoiceToken, ProviderC
|
|
|
4
4
|
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, every, } from "./define.js";
|
|
5
5
|
export { AssertionExpressionSchema, AssertionPredicateSchema, AssertStepSchema, BoundedJsonPathSchema, CandidateBlockSchema, CandidatePolicySchema, CredentialRefDeclarationSchema, defineHealthScenario, HealthScenarioSchema, HealthStepSchema, ExtractStepSchema, FindFirstSchema, GuardStepSchema, JournalPolicySchema, JsonTemplateSchema, ManualTriggerPolicySchema, OperandSchema, OperationStepSchema, QuantifierSchema, ReferenceSchema, RetryPolicySchema, SafeRegexSchema, ScopedAssertionExpressionSchema, ScopedAssertionPredicateSchema, ScopedItemReferenceSchema, ScopedOperandSchema, StepReferenceSchema, RelativeDateNodeSchema, ValueTypeSchema, } from "./health-scenario.js";
|
|
6
6
|
export { AuthError, HttpRedirectError, isProviderError, isSessionExpiredError, isTransportError, ProviderError, SessionExpiredError, TransportError, ValidationError, } from "./errors.js";
|
|
7
|
+
export { createProviderEnvironment, createInProcessProviderEngine, ENGINE_OWNED_PROXY_CREDENTIAL_ENV_NAMES, ENGINE_OWNED_TELEMETRY_ENV_NAMES, isEngineOwnedEnvName, isEngineOwnedProxyCredentialName, isEngineOwnedTelemetryEnvName, PROVIDER_CAPABILITY_KEYS, PROVIDER_ENGINE_PROTOCOL_VERSION, readEngineProxyCredentials, } from "./engine.js";
|
|
7
8
|
export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n/index.js";
|
|
8
9
|
export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
9
10
|
export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, sensitive, z, } from "./schema.js";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @internal Chromium 149 DeprecatedCaseFoldingHash for an LChar string. */
|
|
2
|
+
export declare function chrome149CaseFoldingHash(name: string): number;
|
|
3
|
+
/** @internal Numeric rapidhash fixture from Chromium's string_hasher_test.cc. */
|
|
4
|
+
export declare function chrome149RapidhashFixture(): {
|
|
5
|
+
full: bigint;
|
|
6
|
+
masked: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* HTTPHeaderMap insertion sequence of the fixed headers in a real Chrome
|
|
10
|
+
* 149.0.7827.155 page fetch/XHR (insertion order, not bucket order). Caller
|
|
11
|
+
* headers precede all of these (core/fetch/fetch_manager.cc:1128-1130).
|
|
12
|
+
*
|
|
13
|
+
* platform/loader/fetch/resource_request_utils.cc:146 UpgradeResourceRequestForLoader
|
|
14
|
+
* :166 context.UpgradeResourceRequestForLoader
|
|
15
|
+
* -> core/loader/frame_fetch_context.cc:1000 AddClientHintsIfNecessary
|
|
16
|
+
* Set sec-ch-ua @737, sec-ch-ua-mobile @748, sec-ch-ua-platform @761
|
|
17
|
+
* -> :1001 AddReducedAcceptLanguageIfNecessary is a no-op
|
|
18
|
+
* (kReduceAcceptLanguage[HTTP] are FEATURE_DISABLED_BY_DEFAULT,
|
|
19
|
+
* services/network/public/cpp/features.cc:204,214)
|
|
20
|
+
* :214 context.PrepareRequest
|
|
21
|
+
* -> core/loader/frame_fetch_context.cc:419 SetHTTPUserAgent
|
|
22
|
+
* -> :455 probe::PrepareRequest, which only touches the map when a
|
|
23
|
+
* DevTools session has set an Accept-Language override:
|
|
24
|
+
* InspectorEmulationAgent::PrepareRequest (inspector_emulation_agent.cc
|
|
25
|
+
* :626-636, Emulation.setUserAgentOverride acceptLanguage; skips a key
|
|
26
|
+
* the page already set) or InspectorNetworkAgent::PrepareRequest
|
|
27
|
+
* (inspector_network_agent.cc:1524-1547, Network.setExtraHTTPHeaders;
|
|
28
|
+
* overwrites)
|
|
29
|
+
*
|
|
30
|
+
* Accept-Language is therefore NOT a map key in real Chrome. //net appends it
|
|
31
|
+
* in URLRequestHttpJob::AddExtraHeaders (net/url_request/url_request_http_job.cc
|
|
32
|
+
* :784-797) after Accept-Encoding, and only when the request does not already
|
|
33
|
+
* carry one (SetHeaderIfMissing), which is why a caller-supplied Accept-Language
|
|
34
|
+
* stays at its map bucket and is never emitted twice. al-placement-capture.json
|
|
35
|
+
* (B: no locale, C: --accept-lang=ja) confirms both the four-key map and the
|
|
36
|
+
* downstream slot.
|
|
37
|
+
*
|
|
38
|
+
* Every earlier corpus (placement-rule-sweep, expansion-sweep, holdout-capture,
|
|
39
|
+
* m1-capture) was captured through Playwright `newContext({ locale })`, which
|
|
40
|
+
* sets that override (Emulation.setUserAgentOverride acceptLanguage) and so
|
|
41
|
+
* inserts Accept-Language into the map as a fifth fixed key. Those fixtures still
|
|
42
|
+
* validate the hash and table mechanics;
|
|
43
|
+
* the tests interpret them through that harness insertion list. No production
|
|
44
|
+
* path uses it.
|
|
45
|
+
*/
|
|
46
|
+
export declare const CHROME149_FIXED_MAP_INSERTION: readonly ["sec-ch-ua", "sec-ch-ua-mobile", "sec-ch-ua-platform", "User-Agent"];
|
|
47
|
+
/**
|
|
48
|
+
* @internal Header-name order model parameterised by the fixed map insertion
|
|
49
|
+
* sequence. Production always passes {@link CHROME149_FIXED_MAP_INSERTION};
|
|
50
|
+
* tests pass the DevTools-harness sequence to validate corpora captured through
|
|
51
|
+
* Playwright's `locale` option.
|
|
52
|
+
*/
|
|
53
|
+
export declare function chrome149HeaderOrderForMapInsertion(callerNames: Iterable<string>, fixedMapInsertion: readonly string[]): string[];
|
|
54
|
+
/**
|
|
55
|
+
* @internal Predict real Chrome 149's non-pseudo HTTP/2 fetch/XHR header-name
|
|
56
|
+
* order for the given caller header names (no DevTools session attached).
|
|
57
|
+
*/
|
|
58
|
+
export declare function chrome149HeaderOrder(callerNames: Iterable<string>): string[];
|