@apifuse/provider-sdk 2.2.0-beta.27 → 2.2.0-beta.29
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/CHANGELOG.md +8 -0
- package/bin/apifuse-dev.ts +34 -5
- package/bin/apifuse-pack-smoke.ts +1 -1
- package/bin/apifuse-pack-types.ts +26 -2
- package/bin/apifuse-perf.ts +2 -4
- package/bin/apifuse-record.ts +39 -6
- package/dist/auth-turn/index.d.ts +1 -1
- package/dist/auth-turn/index.js +1 -1
- package/dist/auth.d.ts +14 -0
- package/dist/auth.js +38 -0
- package/dist/ceremonies/index.js +52 -11
- package/dist/config/loader.d.ts +3 -1
- package/dist/config/loader.js +4 -2
- package/dist/index.d.ts +8 -7
- package/dist/index.js +5 -7
- package/dist/provider.d.ts +2 -1
- package/dist/provider.js +1 -1
- package/dist/runtime/auth-flow.js +1 -1
- package/dist/runtime/browser.js +45 -2
- package/dist/runtime/http.d.ts +1 -0
- package/dist/runtime/http.js +135 -12
- package/dist/runtime/instrumentation.js +1 -1
- 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 +2 -33
- package/dist/runtime/native-network.js +2 -68
- package/dist/runtime/proxy-telemetry.js +3 -0
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +4 -2
- 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 +3 -0
- package/dist/runtime/resolver-shared.js +12 -0
- package/dist/runtime/resolver-vendors/browser.js +14 -4
- package/dist/runtime/resolver-vendors/twocaptcha.d.ts +2 -1
- package/dist/runtime/resolver-vendors/twocaptcha.js +157 -53
- package/dist/runtime/resolver-vendors/types.d.ts +2 -2
- package/dist/runtime/resolver-vendors/types.js +3 -1
- package/dist/runtime/resolver.d.ts +15 -10
- package/dist/runtime/resolver.js +92 -23
- package/dist/runtime/state.js +5 -115
- package/dist/runtime/stealth-cookies.d.ts +20 -0
- package/dist/runtime/stealth-cookies.js +111 -0
- package/dist/runtime/stealth.d.ts +1 -0
- package/dist/runtime/stealth.js +8 -131
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/self-test.d.ts +13 -0
- package/dist/server/self-test.js +124 -46
- package/dist/server/serve-implementation.d.ts +199 -0
- package/dist/server/serve-implementation.js +2072 -0
- package/dist/server/serve.d.ts +1 -187
- package/dist/server/serve.js +1 -1827
- package/dist/stateful/errors.d.ts +5 -0
- package/dist/stateful/errors.js +10 -0
- package/dist/stateful/stateful-provider-session-routing.d.ts +1 -5
- package/dist/stateful/stateful-provider-session-routing.js +2 -10
- package/dist/stream.js +7 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +1 -0
- package/package.json +27 -2
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +78 -0
- package/src/ceremonies/index.ts +68 -18
- package/src/config/loader.ts +8 -2
- package/src/index.ts +18 -24
- package/src/provider.ts +12 -14
- package/src/runtime/auth-flow.ts +1 -1
- package/src/runtime/browser.ts +50 -2
- package/src/runtime/http.ts +155 -11
- package/src/runtime/instrumentation.ts +1 -1
- package/src/runtime/native-network-errors.ts +99 -0
- package/src/runtime/native-network.ts +16 -97
- package/src/runtime/proxy-telemetry.ts +5 -0
- package/src/runtime/redis.ts +7 -2
- package/src/runtime/resolver-config.ts +6 -0
- package/src/runtime/resolver-public.ts +18 -0
- package/src/runtime/resolver-shared.ts +17 -0
- package/src/runtime/resolver-vendors/browser.ts +14 -4
- package/src/runtime/resolver-vendors/twocaptcha.ts +190 -56
- package/src/runtime/resolver-vendors/types.ts +8 -2
- package/src/runtime/resolver.ts +140 -28
- package/src/runtime/state.ts +5 -144
- package/src/runtime/stealth-cookies.ts +132 -0
- package/src/runtime/stealth.ts +15 -158
- package/src/serve.ts +6 -1
- package/src/server/index.ts +1 -0
- package/src/server/self-test.ts +184 -59
- package/src/server/serve-implementation.ts +3042 -0
- package/src/server/serve.ts +1 -2661
- package/src/stateful/errors.ts +12 -0
- package/src/stateful/stateful-provider-session-routing.ts +2 -11
- package/src/stream.ts +8 -1
- package/src/testing/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @apifuse/provider-sdk Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.0-beta.29
|
|
4
|
+
|
|
5
|
+
- Release candidate for main commit b7243459ab12403e11d7b5b93292f09b734b0a96.
|
|
6
|
+
|
|
7
|
+
## 2.2.0-beta.28
|
|
8
|
+
|
|
9
|
+
- Release candidate for main commit 2936f1891d4e2326502f0585081f8a58060d6dd7.
|
|
10
|
+
|
|
3
11
|
## 2.2.0-beta.27
|
|
4
12
|
|
|
5
13
|
- Release candidate for main commit 579d9e7fd22d8414b151be2b71a43a0990456911.
|
package/bin/apifuse-dev.ts
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { dirname, relative, resolve } from "node:path";
|
|
5
|
-
import type { ProviderDefinition } from "../src/index.js";
|
|
6
5
|
import {
|
|
7
|
-
createBrowserClient,
|
|
8
6
|
createCredentialContext,
|
|
9
7
|
createEnvContext,
|
|
10
8
|
createHttpClient,
|
|
@@ -12,13 +10,18 @@ import {
|
|
|
12
10
|
createProviderCache,
|
|
13
11
|
createProviderChoiceContext,
|
|
14
12
|
createUnsupportedResolverClient,
|
|
15
|
-
createStealthClient,
|
|
16
13
|
createSttClientFromEnv,
|
|
17
14
|
PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV,
|
|
15
|
+
type ProviderDefinition,
|
|
18
16
|
ProviderError,
|
|
17
|
+
type ProviderProxyPolicy,
|
|
19
18
|
} from "../src/index.js";
|
|
19
|
+
import { createBrowserClient } from "../src/runtime/browser.js";
|
|
20
|
+
import { createResolverClientFromEnv } from "../src/runtime/resolver.js";
|
|
20
21
|
import { createMemoryProviderRuntimeState } from "../src/runtime/state.js";
|
|
22
|
+
import { createStealthClient } from "../src/runtime/stealth.js";
|
|
21
23
|
import { createTraceContext } from "../src/runtime/trace.js";
|
|
24
|
+
import { getStealthProfile } from "../src/stealth/profiles.js";
|
|
22
25
|
import type { BrowserClient, ProviderContext } from "../src/types.js";
|
|
23
26
|
|
|
24
27
|
const HELP_TEXT = `Usage: apifuse dev [path]
|
|
@@ -82,6 +85,11 @@ export function createProviderContext(provider: ProviderDefinition): {
|
|
|
82
85
|
]);
|
|
83
86
|
const credential = createCredentialContext();
|
|
84
87
|
const state = createMemoryProviderRuntimeState();
|
|
88
|
+
const cache = createProviderCache({ providerId: provider.id });
|
|
89
|
+
const proxyPolicy = resolveNativeProxyPolicy(provider);
|
|
90
|
+
const stealthProfile = provider.stealth?.profile
|
|
91
|
+
? getStealthProfile(provider.stealth.profile)
|
|
92
|
+
: undefined;
|
|
85
93
|
const ctx: ProviderContext = {
|
|
86
94
|
env,
|
|
87
95
|
credential,
|
|
@@ -94,13 +102,27 @@ export function createProviderContext(provider: ProviderDefinition): {
|
|
|
94
102
|
})
|
|
95
103
|
: createUnsupportedBrowserStub(),
|
|
96
104
|
http: createHttpClient(),
|
|
97
|
-
cache
|
|
105
|
+
cache,
|
|
98
106
|
state,
|
|
99
107
|
trace: createTraceContext(),
|
|
100
108
|
stealth: createStealthClient("http://localhost"),
|
|
101
109
|
ocr: createOcrClientFromEnv(provider.ocr),
|
|
102
110
|
stt: createSttClientFromEnv(provider.stt),
|
|
103
|
-
resolver:
|
|
111
|
+
resolver: provider.resolver
|
|
112
|
+
? createResolverClientFromEnv(provider.resolver, undefined, {
|
|
113
|
+
allowedHosts: provider.allowedHosts,
|
|
114
|
+
cache,
|
|
115
|
+
...(proxyPolicy
|
|
116
|
+
? {
|
|
117
|
+
proxyIntent: {
|
|
118
|
+
mode: proxyPolicy.mode,
|
|
119
|
+
upstream: { proxy: provider.proxy },
|
|
120
|
+
...(stealthProfile ? { userAgent: stealthProfile.userAgent } : {}),
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
: {}),
|
|
124
|
+
})
|
|
125
|
+
: createUnsupportedResolverClient("Provider does not declare resolver capability"),
|
|
104
126
|
choice: createProviderChoiceContext({
|
|
105
127
|
providerId: provider.id,
|
|
106
128
|
env,
|
|
@@ -112,6 +134,13 @@ export function createProviderContext(provider: ProviderDefinition): {
|
|
|
112
134
|
return { ctx };
|
|
113
135
|
}
|
|
114
136
|
|
|
137
|
+
function resolveNativeProxyPolicy(provider: ProviderDefinition): ProviderProxyPolicy | undefined {
|
|
138
|
+
if (typeof provider.proxy === "object") return provider.proxy;
|
|
139
|
+
if (provider.proxy === true) return { mode: "optional" };
|
|
140
|
+
if (provider.proxy === false) return { mode: "disabled" };
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
115
144
|
function normalizeArgs(argv: string[]): string[] {
|
|
116
145
|
return argv[0] === "dev" ? argv.slice(1) : argv;
|
|
117
146
|
}
|
|
@@ -224,7 +224,7 @@ function smokePackedStealthNative(consumerDir: string): void {
|
|
|
224
224
|
"--eval",
|
|
225
225
|
[
|
|
226
226
|
'import { createServer } from "node:http";',
|
|
227
|
-
'import { createStealthClient } from "@apifuse/provider-sdk";',
|
|
227
|
+
'import { createStealthClient } from "@apifuse/provider-sdk/runtime/stealth";',
|
|
228
228
|
"const server = createServer((_request, response) => {",
|
|
229
229
|
' response.setHeader("set-cookie", "pack_native_cookie=landed; Path=/");',
|
|
230
230
|
' response.end("packed native stealth ok");',
|
|
@@ -242,6 +242,28 @@ const NEGATIVE_CONTROLS = [
|
|
|
242
242
|
"",
|
|
243
243
|
].join("\n"),
|
|
244
244
|
},
|
|
245
|
+
{
|
|
246
|
+
filename: "negative-control-resolver-default-user-agent-test-seam.ts",
|
|
247
|
+
expectedCode: "TS2305",
|
|
248
|
+
description: "the resolver subpath does not expose its default user-agent test seam",
|
|
249
|
+
source: [
|
|
250
|
+
'import { swapResolverDefaultUserAgentForTests } from "@apifuse/provider-sdk/runtime/resolver";',
|
|
251
|
+
"",
|
|
252
|
+
"export const mustNotCompile = swapResolverDefaultUserAgentForTests;",
|
|
253
|
+
"",
|
|
254
|
+
].join("\n"),
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
filename: "negative-control-cache-reset-test-seam.ts",
|
|
258
|
+
expectedCode: "TS2305",
|
|
259
|
+
description: "the package root does not expose its cache-reset test seam",
|
|
260
|
+
source: [
|
|
261
|
+
'import { resetProviderCacheForTests } from "@apifuse/provider-sdk";',
|
|
262
|
+
"",
|
|
263
|
+
"export const mustNotCompile = resetProviderCacheForTests;",
|
|
264
|
+
"",
|
|
265
|
+
].join("\n"),
|
|
266
|
+
},
|
|
245
267
|
{
|
|
246
268
|
filename: "negative-control-resolver-runtime-allowed-hosts.ts",
|
|
247
269
|
expectedCode: "TS2322",
|
|
@@ -357,7 +379,8 @@ function setUpFixtureConsumer(consumerDir: string, tarballPath: string): void {
|
|
|
357
379
|
writeFileSync(
|
|
358
380
|
join(consumerDir, "consumer.ts"),
|
|
359
381
|
[
|
|
360
|
-
'import { defineProvider,
|
|
382
|
+
'import { defineProvider, ProviderError, resolveProxy, SessionExpiredError, z } from "@apifuse/provider-sdk";',
|
|
383
|
+
'import { invalidateResolverSolution } from "@apifuse/provider-sdk/runtime/resolver";',
|
|
361
384
|
'import type { BrowserCookie, ChallengeSolution, NativeNetworkClient, NativeNetworkConnection, NativeProviderConfig, NativeProviderContext, NativeTcpEgressGrant, ProviderChallenge, ProviderContext, ProviderFileRef, ProviderFilesContext, ProviderResolvedFile, ProviderResolverConfig, ResolverContext, ResolverRuntimeOptions } from "@apifuse/provider-sdk";',
|
|
362
385
|
'import type { ProxyProtocol, ProxyResolutionOptions, ProxyResolutionSource, ProxyVendorName, RequestOptions, ResolvedProxyConfig } from "@apifuse/provider-sdk";',
|
|
363
386
|
'import { defineCredentialsAuth } from "@apifuse/provider-sdk/provider";',
|
|
@@ -365,7 +388,7 @@ function setUpFixtureConsumer(consumerDir: string, tarballPath: string): void {
|
|
|
365
388
|
'import { extractProviderContract } from "@apifuse/provider-sdk/contract";',
|
|
366
389
|
'import { AUTH_TURN_SCHEMA } from "@apifuse/provider-sdk/auth-turn";',
|
|
367
390
|
'import { serve } from "@apifuse/provider-sdk/server";',
|
|
368
|
-
'import { runStandardTests } from "@apifuse/provider-sdk/testing";',
|
|
391
|
+
'import { resetProviderCacheForTests, runStandardTests } from "@apifuse/provider-sdk/testing";',
|
|
369
392
|
"",
|
|
370
393
|
"// ProviderError must keep its inherited Error members under nodenext.",
|
|
371
394
|
"// When dist d.ts imports fail to resolve, the class type degrades and",
|
|
@@ -450,6 +473,7 @@ function setUpFixtureConsumer(consumerDir: string, tarballPath: string): void {
|
|
|
450
473
|
" extractProviderContract,",
|
|
451
474
|
" AUTH_TURN_SCHEMA,",
|
|
452
475
|
" serve,",
|
|
476
|
+
" resetProviderCacheForTests,",
|
|
453
477
|
" runStandardTests,",
|
|
454
478
|
"};",
|
|
455
479
|
"",
|
package/bin/apifuse-perf.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
createBypassProviderCache,
|
|
12
12
|
createHttpClient,
|
|
13
13
|
createProviderChoiceContext,
|
|
14
|
-
createStealthClient,
|
|
15
14
|
createSttClientFromEnv,
|
|
16
15
|
executeOperation,
|
|
17
16
|
getProviderBaseUrl,
|
|
@@ -28,6 +27,7 @@ import {
|
|
|
28
27
|
} from "../src/index.js";
|
|
29
28
|
import { computeStats, groupSpansByName, type PerfStats } from "../src/runtime/perf.js";
|
|
30
29
|
import { createMemoryProviderRuntimeState } from "../src/runtime/state.js";
|
|
30
|
+
import { createStealthClient } from "../src/runtime/stealth.js";
|
|
31
31
|
import { createTraceContext, resolveTraceContextOptions } from "../src/runtime/trace.js";
|
|
32
32
|
import { renderWaterfall } from "../src/runtime/waterfall.js";
|
|
33
33
|
import type { BrowserClient } from "../src/types.js";
|
|
@@ -458,9 +458,7 @@ async function loadFixtureReplay(providerDirectory: string): Promise<FixtureRepl
|
|
|
458
458
|
async function assertProxyConfigured(provider: ProviderDefinition): Promise<void> {
|
|
459
459
|
const policy = provider.proxy;
|
|
460
460
|
if (!policy || typeof policy !== "object" || policy.mode === "disabled") {
|
|
461
|
-
throw new Error(
|
|
462
|
-
"--compare-proxy requires an enabled ProviderProxyPolicy on the provider.",
|
|
463
|
-
);
|
|
461
|
+
throw new Error("--compare-proxy requires an enabled ProviderProxyPolicy on the provider.");
|
|
464
462
|
}
|
|
465
463
|
|
|
466
464
|
const resolved = await resolveProxy({ proxyPolicy: policy });
|
package/bin/apifuse-record.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
createHttpClient,
|
|
11
11
|
createOcrClientFromEnv,
|
|
12
12
|
createProviderChoiceContext,
|
|
13
|
-
createStealthClient,
|
|
14
13
|
createSttClientFromEnv,
|
|
15
14
|
createUnsupportedResolverClient,
|
|
16
15
|
executeOperation,
|
|
@@ -20,6 +19,7 @@ import {
|
|
|
20
19
|
type ProviderContext,
|
|
21
20
|
type ProviderDefinition,
|
|
22
21
|
ProviderError,
|
|
22
|
+
type ProviderProxyPolicy,
|
|
23
23
|
type RequestOptions,
|
|
24
24
|
type StealthClient,
|
|
25
25
|
TransportError,
|
|
@@ -32,12 +32,12 @@ import {
|
|
|
32
32
|
sanitizeDiagnosticText,
|
|
33
33
|
sanitizeFixtureString,
|
|
34
34
|
} from "../src/fixture-sanitization.js";
|
|
35
|
-
import {
|
|
35
|
+
import { createResolverClientFromEnv } from "../src/runtime/resolver.js";
|
|
36
36
|
import {
|
|
37
|
-
REDACTED_QUERY_VALUE,
|
|
38
37
|
isSensitiveKey,
|
|
39
38
|
normalizeSensitiveParams,
|
|
40
39
|
parseHttpRequestInvocation,
|
|
40
|
+
REDACTED_QUERY_VALUE,
|
|
41
41
|
redactSensitiveError,
|
|
42
42
|
redactSensitiveText,
|
|
43
43
|
redactUrlQueryParams,
|
|
@@ -45,7 +45,10 @@ import {
|
|
|
45
45
|
requestOptionsFromHttpInvocation,
|
|
46
46
|
serializeRequestUrl,
|
|
47
47
|
} from "../src/runtime/request-options.js";
|
|
48
|
+
import { createMemoryProviderRuntimeState } from "../src/runtime/state.js";
|
|
49
|
+
import { createStealthClient } from "../src/runtime/stealth.js";
|
|
48
50
|
import { parseSchema } from "../src/schema.js";
|
|
51
|
+
import { getStealthProfile } from "../src/stealth/profiles.js";
|
|
49
52
|
import {
|
|
50
53
|
captureStreamEvidence,
|
|
51
54
|
createStreamCaptureEnvelope,
|
|
@@ -422,7 +425,18 @@ function resolveOperationBaseUrl(provider: ProviderRuntime, operationName: strin
|
|
|
422
425
|
return baseUrl;
|
|
423
426
|
}
|
|
424
427
|
|
|
425
|
-
function
|
|
428
|
+
function resolveNativeProxyPolicy(provider: ProviderDefinition): ProviderProxyPolicy | undefined {
|
|
429
|
+
if (typeof provider.proxy === "object") return provider.proxy;
|
|
430
|
+
if (provider.proxy === true) return { mode: "optional" };
|
|
431
|
+
if (provider.proxy === false) return { mode: "disabled" };
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export function createCaptureContext(
|
|
436
|
+
provider: ProviderRuntime,
|
|
437
|
+
baseUrl: string,
|
|
438
|
+
sanitize: boolean,
|
|
439
|
+
) {
|
|
426
440
|
let nextCaptureOrder = 0;
|
|
427
441
|
let nextStreamOrdinal = 0;
|
|
428
442
|
let capturedRaw: JsonValue | undefined;
|
|
@@ -506,12 +520,17 @@ function createCaptureContext(provider: ProviderRuntime, baseUrl: string, saniti
|
|
|
506
520
|
getScopes: () => [],
|
|
507
521
|
};
|
|
508
522
|
const state = createMemoryProviderRuntimeState();
|
|
523
|
+
const cache = createBypassProviderCache({ providerId: provider.id });
|
|
524
|
+
const proxyPolicy = resolveNativeProxyPolicy(provider);
|
|
525
|
+
const stealthProfile = provider.stealth?.profile
|
|
526
|
+
? getStealthProfile(provider.stealth.profile)
|
|
527
|
+
: undefined;
|
|
509
528
|
const ctx: ProviderContext = {
|
|
510
529
|
env,
|
|
511
530
|
credential,
|
|
512
531
|
request: { headers: {} },
|
|
513
532
|
http,
|
|
514
|
-
cache
|
|
533
|
+
cache,
|
|
515
534
|
state,
|
|
516
535
|
stealth,
|
|
517
536
|
browser: {
|
|
@@ -540,7 +559,21 @@ function createCaptureContext(provider: ProviderRuntime, baseUrl: string, saniti
|
|
|
540
559
|
},
|
|
541
560
|
ocr: createOcrClientFromEnv(provider.ocr),
|
|
542
561
|
stt: createSttClientFromEnv(provider.stt),
|
|
543
|
-
resolver:
|
|
562
|
+
resolver: provider.resolver
|
|
563
|
+
? createResolverClientFromEnv(provider.resolver, undefined, {
|
|
564
|
+
allowedHosts: provider.allowedHosts,
|
|
565
|
+
cache,
|
|
566
|
+
...(proxyPolicy
|
|
567
|
+
? {
|
|
568
|
+
proxyIntent: {
|
|
569
|
+
mode: proxyPolicy.mode,
|
|
570
|
+
upstream: { proxy: provider.proxy },
|
|
571
|
+
...(stealthProfile ? { userAgent: stealthProfile.userAgent } : {}),
|
|
572
|
+
},
|
|
573
|
+
}
|
|
574
|
+
: {}),
|
|
575
|
+
})
|
|
576
|
+
: createUnsupportedResolverClient("Provider does not declare resolver capability"),
|
|
544
577
|
choice: createProviderChoiceContext({
|
|
545
578
|
providerId: provider.id,
|
|
546
579
|
env,
|
|
@@ -20,7 +20,7 @@ export declare const AUTH_TURN_SCHEMA_ARTIFACT_PATH = "dist/auth-turn/auth-turn.
|
|
|
20
20
|
*
|
|
21
21
|
* This is the exact codification of the runtime validation the SDK applies to
|
|
22
22
|
* ceremony outputs (see `validateCeremonyOutput` in `src/ceremonies`), which
|
|
23
|
-
*
|
|
23
|
+
* evaluates this same document. `kind` is an OPEN string on the wire: the known
|
|
24
24
|
* kinds in {@link TURN_KINDS} are tooling metadata, never a wire constraint.
|
|
25
25
|
*
|
|
26
26
|
* The committed artifact at `src/auth-turn/auth-turn.v1.schema.json` (shipped
|
package/dist/auth-turn/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export const AUTH_TURN_SCHEMA_ARTIFACT_PATH = "dist/auth-turn/auth-turn.v1.schem
|
|
|
18
18
|
*
|
|
19
19
|
* This is the exact codification of the runtime validation the SDK applies to
|
|
20
20
|
* ceremony outputs (see `validateCeremonyOutput` in `src/ceremonies`), which
|
|
21
|
-
*
|
|
21
|
+
* evaluates this same document. `kind` is an OPEN string on the wire: the known
|
|
22
22
|
* kinds in {@link TURN_KINDS} are tooling metadata, never a wire constraint.
|
|
23
23
|
*
|
|
24
24
|
* The committed artifact at `src/auth-turn/auth-turn.v1.schema.json` (shipped
|
package/dist/auth.d.ts
CHANGED
|
@@ -66,6 +66,20 @@ export interface DefineCredentialsAuthOptions<TFields extends CredentialsAuthFie
|
|
|
66
66
|
/** Extra auth-flow context keys used by custom login/challenge code. */
|
|
67
67
|
contextKeys?: readonly string[];
|
|
68
68
|
login(ctx: FlowContext, input: CredentialsAuthInput<TFields>): CredentialsAuthLoginResult<TCredentialKeys, keyof TChallenges & string> | Promise<CredentialsAuthLoginResult<TCredentialKeys, keyof TChallenges & string>>;
|
|
69
|
+
/**
|
|
70
|
+
* Optional re-mint of an expired session from the stored credential, wired
|
|
71
|
+
* to `auth.flow.refresh`.
|
|
72
|
+
*
|
|
73
|
+
* Credential-auth upstreams routinely invalidate a session well before the
|
|
74
|
+
* `expiresAt` the provider advertised, which leaves every operation failing
|
|
75
|
+
* with a reauth error until a human repeats the whole interactive login.
|
|
76
|
+
* Implement this to re-establish the session from what is already stored on
|
|
77
|
+
* the connection; the result is resolved exactly like `login`, so it may
|
|
78
|
+
* also raise a challenge when the upstream demands one. Omit it when the
|
|
79
|
+
* upstream has no non-interactive path and re-authentication genuinely
|
|
80
|
+
* requires the user.
|
|
81
|
+
*/
|
|
82
|
+
refresh?(ctx: FlowContext, input: Partial<CredentialsAuthInput<TFields>>): CredentialsAuthLoginResult<TCredentialKeys, keyof TChallenges & string> | Promise<CredentialsAuthLoginResult<TCredentialKeys, keyof TChallenges & string>>;
|
|
69
83
|
}
|
|
70
84
|
export interface DefinedCredentialsAuth {
|
|
71
85
|
auth: AuthConfig;
|
package/dist/auth.js
CHANGED
|
@@ -199,6 +199,23 @@ function normalizeInput(fields, input) {
|
|
|
199
199
|
}
|
|
200
200
|
return result;
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Refresh variant of {@link normalizeInput}. `login` coerces every declared
|
|
204
|
+
* field to a string because the interactive turn has already enforced that they
|
|
205
|
+
* are present; refresh runs with no user present, so an absent field is omitted
|
|
206
|
+
* rather than turned into an empty string. That keeps "the user did not supply
|
|
207
|
+
* this" distinguishable from "the user supplied an empty value".
|
|
208
|
+
*/
|
|
209
|
+
function normalizePartialInput(fields, input) {
|
|
210
|
+
const result = {};
|
|
211
|
+
for (const name of Object.keys(fields)) {
|
|
212
|
+
const value = input?.[name];
|
|
213
|
+
if (typeof value === "string") {
|
|
214
|
+
result[name] = value;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
202
219
|
function assertCredentialKeys(credentialKeys, credential) {
|
|
203
220
|
const missing = credentialKeys.filter((key) => {
|
|
204
221
|
const value = credential[key];
|
|
@@ -413,6 +430,27 @@ export function defineCredentialsAuth(options) {
|
|
|
413
430
|
}
|
|
414
431
|
return await pollPendingChallenge(ctx, options.credentialKeys, challenges, pending, completeTurnId);
|
|
415
432
|
},
|
|
433
|
+
// Only advertise refresh when the provider implements it: the
|
|
434
|
+
// protocol treats the hook's presence as "this connection can be
|
|
435
|
+
// re-established without the user", and exposing a stub that
|
|
436
|
+
// cannot actually re-mint would turn a recoverable expiry into a
|
|
437
|
+
// silent failure.
|
|
438
|
+
...(options.refresh
|
|
439
|
+
? {
|
|
440
|
+
refresh: async (ctx, rawInput) => {
|
|
441
|
+
// A pending challenge belongs to the interactive flow that
|
|
442
|
+
// raised it; finish it there rather than restarting.
|
|
443
|
+
const pending = getPendingChallenge(ctx);
|
|
444
|
+
if (pending) {
|
|
445
|
+
return await continuePendingChallenge(ctx, options.credentialKeys, challenges, pending, rawInput, completeTurnId);
|
|
446
|
+
}
|
|
447
|
+
// Refresh runs without user input, so fields are optional
|
|
448
|
+
// here — unlike `continue`, missing ones are not a retry.
|
|
449
|
+
const result = await options.refresh(ctx, normalizePartialInput(options.fields, rawInput));
|
|
450
|
+
return await resolveAuthResult(ctx, options.credentialKeys, challenges, result, completeTurnId);
|
|
451
|
+
},
|
|
452
|
+
}
|
|
453
|
+
: {}),
|
|
416
454
|
},
|
|
417
455
|
},
|
|
418
456
|
credential: {
|
package/dist/ceremonies/index.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
2
|
-
import Ajv2020 from "ajv/dist/2020.js";
|
|
3
2
|
import { AUTH_TURN_SCHEMA } from "../auth-turn/index.js";
|
|
4
3
|
import { FlowExpiredError, ProviderSecretError, TurnValidationError, ValidationError, } from "../errors.js";
|
|
5
|
-
const ajv = new Ajv2020({ allErrors: true, strict: true, strictSchema: true });
|
|
6
|
-
// Runtime ceremony-output validation derives from the exported versioned
|
|
7
|
-
// contract: it compiles the exact AUTH_TURN_SCHEMA document shipped at
|
|
8
|
-
// dist/auth-turn/auth-turn.v1.schema.json, so the two cannot drift.
|
|
9
|
-
const validateAuthTurn = ajv.compile(AUTH_TURN_SCHEMA);
|
|
10
4
|
const OAUTH2_STATE_KEY = "__oauth2_state";
|
|
11
5
|
const OAUTH2_PKCE_VERIFIER_KEY = "__oauth2_pkce_verifier";
|
|
12
6
|
export const OAUTH2_PROXIED_AUTH_PROXY_ORIGIN_ENV_KEY = "APIFUSE__AUTH_PROXY__URL";
|
|
@@ -26,6 +20,50 @@ const FORM_FIELD_ORDER_EXTENSION = "x-apifuse-field-order";
|
|
|
26
20
|
function isRecord(value) {
|
|
27
21
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
28
22
|
}
|
|
23
|
+
function validateSchemaNode(value, schema, path, errors) {
|
|
24
|
+
if (schema.type === "object") {
|
|
25
|
+
if (!isRecord(value)) {
|
|
26
|
+
errors.push(`${path} must be object`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const properties = schema.properties ?? {};
|
|
30
|
+
for (const required of schema.required ?? []) {
|
|
31
|
+
if (!Object.hasOwn(value, required) || value[required] === undefined) {
|
|
32
|
+
errors.push(`${path} must have required property '${required}'`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (schema.additionalProperties === false) {
|
|
36
|
+
for (const key of Object.keys(value)) {
|
|
37
|
+
if (!Object.hasOwn(properties, key)) {
|
|
38
|
+
errors.push(`${path} must NOT have additional property '${key}'`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const [key, childSchema] of Object.entries(properties)) {
|
|
43
|
+
if (Object.hasOwn(value, key) && value[key] !== undefined) {
|
|
44
|
+
validateSchemaNode(value[key], childSchema, `${path}/${key}`, errors);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (schema.type === "string") {
|
|
50
|
+
if (typeof value !== "string") {
|
|
51
|
+
errors.push(`${path} must be string`);
|
|
52
|
+
}
|
|
53
|
+
else if (schema.minLength !== undefined && value.length < schema.minLength) {
|
|
54
|
+
errors.push(`${path} must NOT have fewer than ${schema.minLength} characters`);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (schema.type === "number") {
|
|
59
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
60
|
+
errors.push(`${path} must be number`);
|
|
61
|
+
}
|
|
62
|
+
else if (schema.minimum !== undefined && value < schema.minimum) {
|
|
63
|
+
errors.push(`${path} must be >= ${schema.minimum}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
29
67
|
function ensureRecord(value) {
|
|
30
68
|
return isRecord(value) ? value : {};
|
|
31
69
|
}
|
|
@@ -114,11 +152,14 @@ function withDeclaredFormFieldOrder(expectedInput) {
|
|
|
114
152
|
};
|
|
115
153
|
}
|
|
116
154
|
export function validateCeremonyOutput(turn) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
155
|
+
// Evaluate the exact exported versioned schema without eagerly initializing
|
|
156
|
+
// a general-purpose JSON Schema compiler in every provider process. Contract
|
|
157
|
+
// parity tests compare this focused evaluator with AJV over all fixtures and
|
|
158
|
+
// edge probes, so the runtime and shipped document remain locked together.
|
|
159
|
+
const errors = [];
|
|
160
|
+
validateSchemaNode(turn, AUTH_TURN_SCHEMA, "", errors);
|
|
161
|
+
if (errors.length > 0) {
|
|
162
|
+
throw new TurnValidationError(errors.join("; "));
|
|
122
163
|
}
|
|
123
164
|
return turn;
|
|
124
165
|
}
|
package/dist/config/loader.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Redis } from "ioredis";
|
|
1
|
+
import type { Redis } from "ioredis";
|
|
2
2
|
import type { ProviderProxyPolicy, TraceConfig } from "../types.js";
|
|
3
3
|
import { type ProxyProtocol } from "../runtime/proxy-nodemaven.js";
|
|
4
4
|
export type { ProxyProtocol } from "../runtime/proxy-nodemaven.js";
|
|
@@ -61,8 +61,10 @@ export type ProxyResolutionOptions = {
|
|
|
61
61
|
};
|
|
62
62
|
export type ProxyCacheStatus = "memory_hit" | "redis_hit" | "allocator" | "soft_stale_refresh" | "lock_wait" | "redis_error" | "redis_corrupt" | "disabled";
|
|
63
63
|
export type SmartproxyAllocatorBodyClass = "network_error" | "http_error" | "empty" | "json_without_proxies" | "text_without_proxies" | "usable_proxy_endpoints";
|
|
64
|
+
export type ProxyUserAgentSource = "declared" | "defaulted";
|
|
64
65
|
export type ProxyResolutionTelemetryEvent = {
|
|
65
66
|
provider: ProxyVendorName;
|
|
67
|
+
userAgentSource?: ProxyUserAgentSource;
|
|
66
68
|
protocol?: ProxyProtocol;
|
|
67
69
|
cacheStatus: ProxyCacheStatus;
|
|
68
70
|
cacheHit: boolean;
|
package/dist/config/loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import { Redis } from "ioredis";
|
|
5
5
|
import { NODEMAVEN_DEFAULT_PROTOCOL, NODEMAVEN_FILTER_ENV, NODEMAVEN_MAX_POOL_SIZE, NODEMAVEN_PASSWORD_ENV, NODEMAVEN_USERNAME_ENV, hasNodemavenCredentials, nodemavenPoolSize, synthesizeNodemavenProxy, } from "../runtime/proxy-nodemaven.js";
|
|
6
6
|
// "smartproxy" here is api.smartproxy.org — a residential proxy with an IP
|
|
7
7
|
// extraction API (app_key → raw ip:port pool). It is NOT the company formerly
|
|
@@ -34,6 +34,7 @@ export class ProxyResolutionError extends Error {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
const proxyCache = new Map();
|
|
37
|
+
const require = createRequire(import.meta.url);
|
|
37
38
|
const proxyInflight = new Map();
|
|
38
39
|
const invalidatedProxyKeys = new Map();
|
|
39
40
|
const redisClients = new Map();
|
|
@@ -84,7 +85,8 @@ function getProxyRedis() {
|
|
|
84
85
|
const existing = redisClients.get(redisUrl);
|
|
85
86
|
if (existing)
|
|
86
87
|
return existing;
|
|
87
|
-
const
|
|
88
|
+
const { Redis: RedisClient } = require("ioredis");
|
|
89
|
+
const redis = new RedisClient(redisUrl, {
|
|
88
90
|
connectTimeout: REDIS_TIMEOUT_MS,
|
|
89
91
|
enableOfflineQueue: false,
|
|
90
92
|
lazyConnect: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -16,29 +16,30 @@ export * from "./recipes/gov-api.js";
|
|
|
16
16
|
export * from "./recipes/rest-api.js";
|
|
17
17
|
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
18
18
|
export type { BrowserClientOptions } from "./runtime/browser.js";
|
|
19
|
-
export {
|
|
20
|
-
export { APIFUSE__CACHE__KEY_PEPPER_ENV, createBypassProviderCache, createProviderCache, type ProviderCacheOptions, resetProviderCacheForTests, } from "./runtime/cache.js";
|
|
19
|
+
export { APIFUSE__CACHE__KEY_PEPPER_ENV, createBypassProviderCache, createProviderCache, type ProviderCacheOptions, } from "./runtime/cache.js";
|
|
21
20
|
export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
22
21
|
export { type CreateCredentialContextOptions, createCredentialContext, } from "./runtime/credential.js";
|
|
23
22
|
export { createEnvContext } from "./runtime/env.js";
|
|
24
23
|
export { executeOperation } from "./runtime/executor.js";
|
|
25
24
|
export { createHttpClient } from "./runtime/http.js";
|
|
26
|
-
export {
|
|
25
|
+
export { NativeEgressGrantExpiredError, NativeEgressNotDeclaredError, NativeIdleTimeoutError, NativeNetworkError, NativeProxyExpiredError, } from "./runtime/native-network-errors.js";
|
|
26
|
+
export type { NativeGatewayProxy, NativeGatewayProxyResolutionInput, NativeGatewayProxySkipReason, NativeGatewayProxySynthesizer, NativeGatewayProxySynthesisResult, NativeGatewayProxySynthesisInput, NativeNetworkClientOptions, NativeNetworkErrorCode, VendorCredentialLookup, VendorCredentialResolver, } from "./runtime/native-network.js";
|
|
27
27
|
export type { Insight, InsightSeverity } from "./runtime/insights.js";
|
|
28
28
|
export { generateInsights } from "./runtime/insights.js";
|
|
29
29
|
export { type InstrumentationOptions, type InstrumentedProviderContext, wrapWithInstrumentation, } from "./runtime/instrumentation.js";
|
|
30
|
-
export {
|
|
30
|
+
export type { PrevalidateResult } from "./runtime/prevalidate.js";
|
|
31
31
|
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
32
|
-
export { APIFUSE__CDP_POOL__URL, APIFUSE__RESOLVER__2CAPTCHA__API_KEY, APIFUSE__RESOLVER__CAPMONSTER__API_KEY, APIFUSE__RESOLVER__CAPSOLVER__API_KEY, APIFUSE__RESOLVER__TIMEOUT_MS,
|
|
32
|
+
export { APIFUSE__CDP_POOL__URL, APIFUSE__RESOLVER__2CAPTCHA__API_KEY, APIFUSE__RESOLVER__CAPMONSTER__API_KEY, APIFUSE__RESOLVER__CAPSOLVER__API_KEY, APIFUSE__RESOLVER__TIMEOUT_MS, DEFAULT_RESOLVER_TIMEOUT_MS, } from "./runtime/resolver-config.js";
|
|
33
|
+
export { createUnsupportedResolverClient } from "./runtime/resolver-shared.js";
|
|
34
|
+
export type { ResolverRuntimeOptions } from "./runtime/resolver.js";
|
|
33
35
|
export type { ResolverVendorTransport } from "./runtime/resolver-vendors/types.js";
|
|
34
36
|
export { assertRequiredSecretsPresent, listMissingRequiredSecrets, MISSING_SECRET_CODE, } from "./runtime/secrets.js";
|
|
35
37
|
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
36
|
-
export { createStealthClient } from "./runtime/stealth.js";
|
|
37
38
|
export { APIFUSE__OCR__API_KEY_ENV, APIFUSE__OCR__BACKEND_ENV, APIFUSE__OCR__BASE_URL_ENV, APIFUSE__OCR__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__OCR__MODEL_ENV, CLOUDFLARE_ACCOUNT_ID_ENV, CLOUDFLARE_WORKERS_AI_OCR_BACKEND, createCloudflareWorkersAiOcrClient, createOcrClientFromEnv, createOpenAiCompatibleOcrClient, createUnsupportedOcrClient, DEFAULT_CLOUDFLARE_WORKERS_AI_OCR_MODEL, extractCaptchaCandidates, OPENAI_COMPATIBLE_OCR_BACKEND, } from "./runtime/ocr.js";
|
|
38
39
|
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
39
40
|
export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace.js";
|
|
40
41
|
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";
|
|
41
|
-
export { createServerApp, ERROR_OBSERVABILITY_HEADER, type ServeOptions, serve, } from "./server/
|
|
42
|
+
export { createServerApp, createServerAppAsync, ERROR_OBSERVABILITY_HEADER, type ServeOptions, serve, } from "./server/serve.js";
|
|
42
43
|
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
43
44
|
export * from "./stream.js";
|
|
44
45
|
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, NativeProviderContext, NativeProxyDrainHandler, NativeProxyEgressInfo, NativeProxyExpiringEvent, NativeProxyExpiringReason, NativeTcpDynamicEgressRule, NativeTcpEgressGrant, NativeTcpEgressRule, NativeTcpPortRange, NativeTcpTlsMode, NativeTlsConnectOptions, OcrCaptchaCandidate, OcrCaptchaOptions, OcrCaptchaResult, OcrContext, OcrImageInput, OcrRecognizeRequest, OcrResult, OcrWarning, OperationAnnotations, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDeprecationMetadata, OperationDocMeta, OperationErrorCode, ProviderErrorStatus, OperationHandlerResult, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, OperationTransportKind, ProbeInterval, ProviderAccessConfig, ProviderAccessVisibility, ProviderCache, ProviderCacheGetOrSetOptions, ProviderCacheKeyOptions, ProviderCacheLookupMeta, ProviderCacheResponseMeta, ProviderCacheResult, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderChallenge, ProviderChallengeKind, ProviderContext, 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, ProviderRuntimeState, ProviderSecretDeclaration, ProviderStateDurationString, ProviderStateNamespace, ProviderStreamEvent, ProviderSttConfig, ProviderSttMode, ProviderSupportLevel, RequestOptions, RedirectRunReason, ResolverContext, Rfc3339Instant, SchemaLike, SmsOrigin, SmsOtpExtractionPattern, SmsOtpMatcherDefinition, SseMessage, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateNamespaceScope, StateValue, StateWriteOptions, StealthClient, StealthCookieStore, StealthCookieStoreV1, StealthFetchOptions, StealthPlatform, StealthProfile, 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";
|
package/dist/index.js
CHANGED
|
@@ -14,27 +14,25 @@ export { lintOperation, lintProvider, } from "./lint.js";
|
|
|
14
14
|
export * from "./recipes/gov-api.js";
|
|
15
15
|
export * from "./recipes/rest-api.js";
|
|
16
16
|
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
17
|
-
export {
|
|
18
|
-
export { APIFUSE__CACHE__KEY_PEPPER_ENV, createBypassProviderCache, createProviderCache, resetProviderCacheForTests, } from "./runtime/cache.js";
|
|
17
|
+
export { APIFUSE__CACHE__KEY_PEPPER_ENV, createBypassProviderCache, createProviderCache, } from "./runtime/cache.js";
|
|
19
18
|
export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
20
19
|
export { createCredentialContext, } from "./runtime/credential.js";
|
|
21
20
|
export { createEnvContext } from "./runtime/env.js";
|
|
22
21
|
export { executeOperation } from "./runtime/executor.js";
|
|
23
22
|
export { createHttpClient } from "./runtime/http.js";
|
|
24
|
-
export {
|
|
23
|
+
export { NativeEgressGrantExpiredError, NativeEgressNotDeclaredError, NativeIdleTimeoutError, NativeNetworkError, NativeProxyExpiredError, } from "./runtime/native-network-errors.js";
|
|
25
24
|
export { generateInsights } from "./runtime/insights.js";
|
|
26
25
|
export { wrapWithInstrumentation, } from "./runtime/instrumentation.js";
|
|
27
|
-
export { prevalidate } from "./runtime/prevalidate.js";
|
|
28
26
|
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
29
|
-
export { APIFUSE__CDP_POOL__URL, APIFUSE__RESOLVER__2CAPTCHA__API_KEY, APIFUSE__RESOLVER__CAPMONSTER__API_KEY, APIFUSE__RESOLVER__CAPSOLVER__API_KEY, APIFUSE__RESOLVER__TIMEOUT_MS,
|
|
27
|
+
export { APIFUSE__CDP_POOL__URL, APIFUSE__RESOLVER__2CAPTCHA__API_KEY, APIFUSE__RESOLVER__CAPMONSTER__API_KEY, APIFUSE__RESOLVER__CAPSOLVER__API_KEY, APIFUSE__RESOLVER__TIMEOUT_MS, DEFAULT_RESOLVER_TIMEOUT_MS, } from "./runtime/resolver-config.js";
|
|
28
|
+
export { createUnsupportedResolverClient } from "./runtime/resolver-shared.js";
|
|
30
29
|
export { assertRequiredSecretsPresent, listMissingRequiredSecrets, MISSING_SECRET_CODE, } from "./runtime/secrets.js";
|
|
31
30
|
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
32
|
-
export { createStealthClient } from "./runtime/stealth.js";
|
|
33
31
|
export { APIFUSE__OCR__API_KEY_ENV, APIFUSE__OCR__BACKEND_ENV, APIFUSE__OCR__BASE_URL_ENV, APIFUSE__OCR__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__OCR__MODEL_ENV, CLOUDFLARE_ACCOUNT_ID_ENV, CLOUDFLARE_WORKERS_AI_OCR_BACKEND, createCloudflareWorkersAiOcrClient, createOcrClientFromEnv, createOpenAiCompatibleOcrClient, createUnsupportedOcrClient, DEFAULT_CLOUDFLARE_WORKERS_AI_OCR_MODEL, extractCaptchaCandidates, OPENAI_COMPATIBLE_OCR_BACKEND, } from "./runtime/ocr.js";
|
|
34
32
|
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
35
33
|
export { createTraceContext, } from "./runtime/trace.js";
|
|
36
34
|
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";
|
|
37
|
-
export { createServerApp, ERROR_OBSERVABILITY_HEADER, serve, } from "./server/
|
|
35
|
+
export { createServerApp, createServerAppAsync, ERROR_OBSERVABILITY_HEADER, serve, } from "./server/serve.js";
|
|
38
36
|
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
39
37
|
export * from "./stream.js";
|
|
40
38
|
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";
|
package/dist/provider.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } f
|
|
|
8
8
|
export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
9
9
|
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";
|
|
10
10
|
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, NativeProviderContext, NativeProxyDrainHandler, NativeProxyEgressInfo, NativeProxyExpiringEvent, NativeProxyExpiringReason, NativeTcpDynamicEgressRule, NativeTcpEgressGrant, NativeTcpEgressRule, NativeTcpPortRange, NativeTcpTlsMode, NativeTlsConnectOptions, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDocMeta, OperationErrorCode, ProviderErrorStatus, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, ProviderAccessVisibility, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderDefinition, ProviderDeploymentOverrides, ProviderFileRef, ProviderFilesContext, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderProxyPolicy, ProxiedOAuthConfig, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderResolvedFile, ProviderRuntimeState, ProviderStateDurationString, ProviderStateNamespace, ProviderSupportLevel, RedirectRunReason, SchemaLike, SmsOtpMatcherDefinition, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateNamespaceScope, StateValue, StateWriteOptions, } from "./types.js";
|
|
11
|
-
export {
|
|
11
|
+
export { NativeEgressGrantExpiredError, NativeEgressNotDeclaredError, NativeIdleTimeoutError, NativeNetworkError, NativeProxyExpiredError, } from "./runtime/native-network-errors.js";
|
|
12
|
+
export type { NativeGatewayProxy, NativeGatewayProxyResolutionInput, NativeGatewayProxySkipReason, NativeGatewayProxySynthesizer, NativeGatewayProxySynthesisResult, NativeGatewayProxySynthesisInput, NativeNetworkClientOptions, NativeNetworkErrorCode, VendorCredentialLookup, VendorCredentialResolver, } from "./runtime/native-network.js";
|
|
12
13
|
export { HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, } from "./types.js";
|
package/dist/provider.js
CHANGED
|
@@ -6,5 +6,5 @@ export { AuthError, HttpRedirectError, isProviderError, isSessionExpiredError, i
|
|
|
6
6
|
export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n/index.js";
|
|
7
7
|
export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
8
8
|
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";
|
|
9
|
-
export {
|
|
9
|
+
export { NativeEgressGrantExpiredError, NativeEgressNotDeclaredError, NativeIdleTimeoutError, NativeNetworkError, NativeProxyExpiredError, } from "./runtime/native-network-errors.js";
|
|
10
10
|
export { HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, } from "./types.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContextAccessError } from "../errors.js";
|
|
2
2
|
import { createAuthFlowHelpers } from "../auth.js";
|
|
3
3
|
import { createUnsupportedOcrClient } from "./ocr.js";
|
|
4
|
-
import { createUnsupportedResolverClient } from "./resolver.js";
|
|
4
|
+
import { createUnsupportedResolverClient } from "./resolver-shared.js";
|
|
5
5
|
import { createUnsupportedSttClient } from "./stt.js";
|
|
6
6
|
function normalizeAllowedKeys(allowedKeys) {
|
|
7
7
|
return new Set(allowedKeys.filter((key) => key.trim().length > 0));
|