@apifuse/provider-sdk 2.2.0-beta.3 → 2.2.0-beta.4
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 +14 -0
- package/CHANGELOG.md +4 -0
- package/bin/apifuse-check.ts +18 -58
- package/bin/apifuse-create.ts +1 -1
- package/bin/apifuse-dev.ts +27 -52
- package/bin/apifuse-pack-smoke.ts +22 -81
- package/bin/apifuse-pack-types.ts +266 -0
- package/bin/apifuse-perf.ts +45 -127
- package/bin/apifuse-record.ts +23 -61
- package/bin/apifuse-submit-check.ts +26 -21
- package/bin/apifuse.ts +1 -1
- package/bin/submit-check-xml.ts +1 -1
- package/dist/auth-turn/index.d.ts +1 -1
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +9 -18
- package/dist/ceremonies/index.d.ts +1 -1
- package/dist/ceremonies/index.js +8 -18
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/loader.js +19 -42
- package/dist/contract-serialization.d.ts +2 -2
- package/dist/contract-serialization.js +3 -6
- package/dist/contract-types.d.ts +2 -2
- package/dist/contract.d.ts +3 -3
- package/dist/contract.js +4 -6
- package/dist/define.d.ts +8 -1
- package/dist/define.js +57 -115
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -3
- package/dist/i18n/catalog.d.ts +2 -2
- package/dist/i18n/catalog.js +4 -10
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/keys.d.ts +2 -2
- package/dist/index.d.ts +43 -42
- package/dist/index.js +38 -37
- package/dist/lint.js +8 -15
- package/dist/provider.d.ts +11 -11
- package/dist/provider.js +9 -9
- package/dist/public-schema-field-lint.d.ts +1 -1
- package/dist/recipes/gov-api.js +1 -1
- package/dist/runtime/auth-flow.d.ts +1 -1
- package/dist/runtime/auth-flow.js +3 -3
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.js +15 -29
- package/dist/runtime/cache.d.ts +1 -1
- package/dist/runtime/cache.js +4 -8
- package/dist/runtime/choice.d.ts +1 -1
- package/dist/runtime/choice.js +12 -34
- package/dist/runtime/credential.d.ts +1 -1
- package/dist/runtime/credential.js +1 -1
- package/dist/runtime/env.d.ts +1 -1
- package/dist/runtime/executor.d.ts +1 -1
- package/dist/runtime/executor.js +2 -2
- package/dist/runtime/http.d.ts +2 -2
- package/dist/runtime/http.js +5 -5
- package/dist/runtime/insights.d.ts +1 -1
- package/dist/runtime/insights.js +6 -13
- package/dist/runtime/instrumentation.d.ts +2 -2
- package/dist/runtime/instrumentation.js +5 -15
- package/dist/runtime/keyring.js +1 -1
- package/dist/runtime/namespace.js +1 -1
- package/dist/runtime/otlp.d.ts +1 -1
- package/dist/runtime/perf.d.ts +1 -1
- package/dist/runtime/provider.d.ts +1 -1
- package/dist/runtime/provider.js +1 -2
- package/dist/runtime/proxy-errors.d.ts +1 -1
- package/dist/runtime/proxy-errors.js +3 -5
- package/dist/runtime/proxy-retry-policy.d.ts +2 -2
- package/dist/runtime/proxy-retry-policy.js +2 -2
- package/dist/runtime/proxy-telemetry.d.ts +1 -1
- package/dist/runtime/proxy-telemetry.js +16 -48
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +2 -4
- package/dist/runtime/request-options.d.ts +1 -1
- package/dist/runtime/state.d.ts +2 -2
- package/dist/runtime/state.js +3 -3
- package/dist/runtime/stealth.d.ts +2 -2
- package/dist/runtime/stealth.js +6 -6
- package/dist/runtime/stt.d.ts +1 -1
- package/dist/runtime/stt.js +11 -15
- package/dist/runtime/trace.d.ts +2 -2
- package/dist/runtime/trace.js +2 -4
- package/dist/runtime/waterfall.d.ts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +7 -15
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/dist/server/index.d.ts +7 -7
- package/dist/server/index.js +6 -6
- package/dist/server/self-test-redaction.d.ts +1 -1
- package/dist/server/self-test-redaction.js +1 -1
- package/dist/server/self-test.d.ts +3 -3
- package/dist/server/self-test.js +3 -3
- package/dist/server/serve.d.ts +3 -3
- package/dist/server/serve.js +36 -49
- package/dist/server/types.js +2 -7
- package/dist/stealth/profiles.d.ts +1 -1
- package/dist/stealth/profiles.js +5 -14
- package/dist/stream.d.ts +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/run.d.ts +1 -1
- package/dist/testing/run.js +7 -14
- package/dist/types.d.ts +57 -0
- package/dist/user-input.d.ts +30 -0
- package/dist/user-input.js +66 -0
- package/package.json +6 -4
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +28 -86
- package/src/ceremonies/index.ts +24 -78
- package/src/config/loader.ts +58 -176
- package/src/contract-serialization.ts +5 -11
- package/src/contract-types.ts +2 -2
- package/src/contract.ts +12 -28
- package/src/define.ts +174 -495
- package/src/dev.ts +4 -9
- package/src/errors.ts +4 -11
- package/src/i18n/catalog.ts +10 -32
- package/src/i18n/index.ts +2 -2
- package/src/i18n/keys.ts +5 -11
- package/src/index.ts +44 -42
- package/src/lint.ts +89 -159
- package/src/provider.ts +12 -11
- package/src/public-schema-field-lint.ts +7 -33
- package/src/recipes/gov-api.ts +2 -5
- package/src/runtime/auth-flow.ts +5 -7
- package/src/runtime/browser.ts +64 -187
- package/src/runtime/cache.ts +20 -67
- package/src/runtime/choice.ts +55 -129
- package/src/runtime/credential.ts +2 -2
- package/src/runtime/env.ts +1 -1
- package/src/runtime/executor.ts +9 -19
- package/src/runtime/http.ts +7 -7
- package/src/runtime/insights.ts +15 -53
- package/src/runtime/instrumentation.ts +19 -58
- package/src/runtime/keyring.ts +7 -19
- package/src/runtime/namespace.ts +2 -7
- package/src/runtime/otlp.ts +12 -23
- package/src/runtime/perf.ts +1 -1
- package/src/runtime/provider.ts +4 -9
- package/src/runtime/proxy-errors.ts +17 -38
- package/src/runtime/proxy-retry-policy.ts +3 -3
- package/src/runtime/proxy-telemetry.ts +23 -72
- package/src/runtime/redis.ts +4 -12
- package/src/runtime/request-options.ts +4 -13
- package/src/runtime/state.ts +30 -109
- package/src/runtime/stealth.ts +8 -8
- package/src/runtime/stt.ts +38 -94
- package/src/runtime/trace.ts +14 -44
- package/src/runtime/waterfall.ts +5 -18
- package/src/schema.ts +23 -84
- package/src/serve.ts +1 -1
- package/src/server/index.ts +7 -7
- package/src/server/self-test-redaction.ts +2 -2
- package/src/server/self-test.ts +5 -5
- package/src/server/serve.ts +87 -242
- package/src/server/types.ts +6 -19
- package/src/stealth/profiles.ts +10 -26
- package/src/stream.ts +8 -19
- package/src/testing/index.ts +2 -2
- package/src/testing/run.ts +19 -67
- package/src/types.ts +58 -0
- package/src/user-input.ts +118 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
export * from "./auth";
|
|
2
|
-
export * from "./ceremonies";
|
|
3
|
-
export * from "./choice-token";
|
|
4
|
-
export type { ApiFuseConfig, BrowserConfig, ProxyConfig, SessionConfig, } from "./config/loader";
|
|
5
|
-
export { defineConfig, loadApiFuseConfig } from "./config/loader";
|
|
6
|
-
export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract";
|
|
7
|
-
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type ProviderConfig, } from "./define";
|
|
8
|
-
export type { DevServerOptions } from "./dev";
|
|
9
|
-
export { createDevServer, startDevServer } from "./dev";
|
|
10
|
-
export * from "./errors";
|
|
11
|
-
export * from "./
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export * from "./recipes/
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export { type
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export { type
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export {
|
|
39
|
-
export
|
|
40
|
-
export * from "./utils/
|
|
41
|
-
export * from "./utils/
|
|
42
|
-
export * from "./utils/
|
|
1
|
+
export * from "./auth.js";
|
|
2
|
+
export * from "./ceremonies/index.js";
|
|
3
|
+
export * from "./choice-token.js";
|
|
4
|
+
export type { ApiFuseConfig, BrowserConfig, ProxyConfig, SessionConfig, } from "./config/loader.js";
|
|
5
|
+
export { defineConfig, loadApiFuseConfig } from "./config/loader.js";
|
|
6
|
+
export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract.js";
|
|
7
|
+
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type ProviderConfig, } from "./define.js";
|
|
8
|
+
export type { DevServerOptions } from "./dev.js";
|
|
9
|
+
export { createDevServer, startDevServer } from "./dev.js";
|
|
10
|
+
export * from "./errors.js";
|
|
11
|
+
export * from "./user-input.js";
|
|
12
|
+
export * from "./i18n/index.js";
|
|
13
|
+
export { type LintDiagnostic, lintOperation, lintProvider, } from "./lint.js";
|
|
14
|
+
export * from "./recipes/gov-api.js";
|
|
15
|
+
export * from "./recipes/rest-api.js";
|
|
16
|
+
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
17
|
+
export type { BrowserClientOptions } from "./runtime/browser.js";
|
|
18
|
+
export { BrowserClient, createBrowserClient } from "./runtime/browser.js";
|
|
19
|
+
export { createBypassProviderCache, createProviderCache, type ProviderCacheOptions, resetProviderCacheForTests, } from "./runtime/cache.js";
|
|
20
|
+
export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
21
|
+
export { type CreateCredentialContextOptions, createCredentialContext, } from "./runtime/credential.js";
|
|
22
|
+
export { createEnvContext } from "./runtime/env.js";
|
|
23
|
+
export { executeOperation } from "./runtime/executor.js";
|
|
24
|
+
export { createHttpClient } from "./runtime/http.js";
|
|
25
|
+
export type { Insight, InsightSeverity } from "./runtime/insights.js";
|
|
26
|
+
export { generateInsights } from "./runtime/insights.js";
|
|
27
|
+
export { type InstrumentationOptions, type InstrumentedProviderContext, wrapWithInstrumentation, } from "./runtime/instrumentation.js";
|
|
28
|
+
export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate.js";
|
|
29
|
+
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
30
|
+
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
31
|
+
export { createStealthClient } from "./runtime/stealth.js";
|
|
32
|
+
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
33
|
+
export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace.js";
|
|
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, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, z, } from "./schema.js";
|
|
35
|
+
export { createServerApp, type ServeOptions, serve } from "./server/index.js";
|
|
36
|
+
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
37
|
+
export * from "./stream.js";
|
|
38
|
+
export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, 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, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration, OperationAnnotations, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDeprecationMetadata, OperationDocMeta, OperationErrorCode, OperationHandlerResult, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, OperationTransportKind, ProbeInterval, ProviderAccessConfig, ProviderAccessVisibility, ProviderCache, ProviderCacheGetOrSetOptions, ProviderCacheKeyOptions, ProviderCacheLookupMeta, ProviderCacheResponseMeta, ProviderCacheResult, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderDefinition, ProviderDeploymentOverrides, ProviderHealthMonitorConfig, ProviderHealthProbeConfig, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderLogoSource, ProviderMeta, ProviderProxyConfig, ProviderProxyMode, ProviderProxyPolicy, ProviderProxyProvider, ProviderProxySessionAffinity, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderReviewed, ProviderRuntimeState, ProviderSecretDeclaration, ProviderStateDurationString, ProviderStateNamespace, ProviderStreamEvent, ProviderSttConfig, ProviderSttMode, ProviderSupportLevel, RequestOptions, Rfc3339Instant, SchemaLike, SmsOrigin, SmsOtpExtractionPattern, SmsOtpMatcherDefinition, SseMessage, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateValue, StateWriteOptions, StealthClient, 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";
|
|
39
|
+
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
|
+
export * from "./utils/date.js";
|
|
41
|
+
export * from "./utils/parse.js";
|
|
42
|
+
export * from "./utils/text.js";
|
|
43
|
+
export * from "./utils/transform.js";
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
// @apifuse/provider-sdk
|
|
2
|
-
export * from "./auth";
|
|
3
|
-
export * from "./ceremonies";
|
|
4
|
-
export * from "./choice-token";
|
|
5
|
-
export { defineConfig, loadApiFuseConfig } from "./config/loader";
|
|
6
|
-
export { canonicalJson, digestProviderContract, extractProviderContract, PROVIDER_CONTRACT_SCHEMA_VERSION, } from "./contract";
|
|
7
|
-
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, } from "./define";
|
|
8
|
-
export { createDevServer, startDevServer } from "./dev";
|
|
9
|
-
export * from "./errors";
|
|
10
|
-
export * from "./
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export * from "./recipes/
|
|
14
|
-
export
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export * from "./utils/
|
|
37
|
-
export * from "./utils/
|
|
38
|
-
export * from "./utils/
|
|
2
|
+
export * from "./auth.js";
|
|
3
|
+
export * from "./ceremonies/index.js";
|
|
4
|
+
export * from "./choice-token.js";
|
|
5
|
+
export { defineConfig, loadApiFuseConfig } from "./config/loader.js";
|
|
6
|
+
export { canonicalJson, digestProviderContract, extractProviderContract, PROVIDER_CONTRACT_SCHEMA_VERSION, } from "./contract.js";
|
|
7
|
+
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, } from "./define.js";
|
|
8
|
+
export { createDevServer, startDevServer } from "./dev.js";
|
|
9
|
+
export * from "./errors.js";
|
|
10
|
+
export * from "./user-input.js";
|
|
11
|
+
export * from "./i18n/index.js";
|
|
12
|
+
export { lintOperation, lintProvider, } from "./lint.js";
|
|
13
|
+
export * from "./recipes/gov-api.js";
|
|
14
|
+
export * from "./recipes/rest-api.js";
|
|
15
|
+
export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
|
|
16
|
+
export { BrowserClient, createBrowserClient } from "./runtime/browser.js";
|
|
17
|
+
export { createBypassProviderCache, createProviderCache, resetProviderCacheForTests, } from "./runtime/cache.js";
|
|
18
|
+
export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
19
|
+
export { createCredentialContext, } from "./runtime/credential.js";
|
|
20
|
+
export { createEnvContext } from "./runtime/env.js";
|
|
21
|
+
export { executeOperation } from "./runtime/executor.js";
|
|
22
|
+
export { createHttpClient } from "./runtime/http.js";
|
|
23
|
+
export { generateInsights } from "./runtime/insights.js";
|
|
24
|
+
export { wrapWithInstrumentation, } from "./runtime/instrumentation.js";
|
|
25
|
+
export { prevalidate } from "./runtime/prevalidate.js";
|
|
26
|
+
export { getProviderBaseUrl } from "./runtime/provider.js";
|
|
27
|
+
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
28
|
+
export { createStealthClient } from "./runtime/stealth.js";
|
|
29
|
+
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
30
|
+
export { createTraceContext, } from "./runtime/trace.js";
|
|
31
|
+
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";
|
|
32
|
+
export { createServerApp, serve } from "./server/index.js";
|
|
33
|
+
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
34
|
+
export * from "./stream.js";
|
|
35
|
+
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";
|
|
36
|
+
export * from "./utils/date.js";
|
|
37
|
+
export * from "./utils/parse.js";
|
|
38
|
+
export * from "./utils/text.js";
|
|
39
|
+
export * from "./utils/transform.js";
|
package/dist/lint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { lintPublicSchemaFieldNames } from "./public-schema-field-lint";
|
|
2
|
-
import { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_SENSITIVE_META_KEY
|
|
1
|
+
import { lintPublicSchemaFieldNames } from "./public-schema-field-lint.js";
|
|
2
|
+
import { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_SENSITIVE_META_KEY } from "./schema.js";
|
|
3
3
|
const AUTH_OPERATION_ID_PATTERN = /^(?:auth[-_])?(?:login|exchange|continue|refresh|callback)(?:[-_]|$)/i;
|
|
4
4
|
function lintAllowedHosts(providerId, allowedHosts) {
|
|
5
5
|
const prefix = providerId ? `Provider "${providerId}"` : "Provider";
|
|
@@ -120,8 +120,7 @@ function lintAuthModel(provider) {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
if (hasReusableSecretKeys(credentialKeys) &&
|
|
123
|
-
(!provider.credential?.storesReusableSecret ||
|
|
124
|
-
!provider.credential.justification)) {
|
|
123
|
+
(!provider.credential?.storesReusableSecret || !provider.credential.justification)) {
|
|
125
124
|
diagnostics.push({
|
|
126
125
|
rule: "credential-reusable-secret",
|
|
127
126
|
level: "error",
|
|
@@ -131,8 +130,7 @@ function lintAuthModel(provider) {
|
|
|
131
130
|
}
|
|
132
131
|
if (typeof provider.auth?.flow?.refresh === "function" &&
|
|
133
132
|
hasReusableReloginSecretKeys(credentialKeys) &&
|
|
134
|
-
(!provider.credential?.storesReusableSecret ||
|
|
135
|
-
!provider.credential.justification)) {
|
|
133
|
+
(!provider.credential?.storesReusableSecret || !provider.credential.justification)) {
|
|
136
134
|
diagnostics.push({
|
|
137
135
|
rule: "auth-refresh-reusable-secret",
|
|
138
136
|
level: "error",
|
|
@@ -149,8 +147,7 @@ function lintAuthModel(provider) {
|
|
|
149
147
|
});
|
|
150
148
|
}
|
|
151
149
|
const authFlowSource = getAuthFlowSource(provider);
|
|
152
|
-
if (authFlowSource.includes("ctx.context") &&
|
|
153
|
-
(provider.context?.keys?.length ?? 0) === 0) {
|
|
150
|
+
if (authFlowSource.includes("ctx.context") && (provider.context?.keys?.length ?? 0) === 0) {
|
|
154
151
|
diagnostics.push({
|
|
155
152
|
rule: "context-keys-required",
|
|
156
153
|
level: "warn",
|
|
@@ -435,8 +432,7 @@ function isComplexSchema(schema, seen = new Set()) {
|
|
|
435
432
|
const childChildren = getChildSchemas(child);
|
|
436
433
|
return childChildren.length > 0;
|
|
437
434
|
});
|
|
438
|
-
return
|
|
439
|
-
children.some(({ schema: child }) => isComplexSchema(child, seen)));
|
|
435
|
+
return hasNestedComposite || children.some(({ schema: child }) => isComplexSchema(child, seen));
|
|
440
436
|
}
|
|
441
437
|
function hasBidirectionalFixtures(fixtures) {
|
|
442
438
|
if (!fixtures || typeof fixtures !== "object") {
|
|
@@ -448,9 +444,7 @@ function getOperationSource(operation) {
|
|
|
448
444
|
if (operation.source) {
|
|
449
445
|
return operation.source;
|
|
450
446
|
}
|
|
451
|
-
return typeof operation.handler === "function"
|
|
452
|
-
? operation.handler.toString()
|
|
453
|
-
: "";
|
|
447
|
+
return typeof operation.handler === "function" ? operation.handler.toString() : "";
|
|
454
448
|
}
|
|
455
449
|
function lintStealthTransportUsage(provider) {
|
|
456
450
|
if (provider.stealth || !provider.operations) {
|
|
@@ -621,8 +615,7 @@ export function lintOperation(op) {
|
|
|
621
615
|
message: "Operation whenToUse must use whenToUseKeys instead of raw static prose.",
|
|
622
616
|
});
|
|
623
617
|
}
|
|
624
|
-
if ((op.whenNotToUse?.length ?? 0) > 0 &&
|
|
625
|
-
!(op.whenNotToUseKeys?.length ?? 0)) {
|
|
618
|
+
if ((op.whenNotToUse?.length ?? 0) > 0 && !(op.whenNotToUseKeys?.length ?? 0)) {
|
|
626
619
|
diagnostics.push({
|
|
627
620
|
rule: "operation-when-not-to-use-raw-prose",
|
|
628
621
|
level: "error",
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { AuthAbortError, credentialsAuthChallenge, createAuthFlowHelpers, defineCredentialsAuth, } from "./auth";
|
|
2
|
-
export type { CredentialsAuthChallengeDefinition, CredentialsAuthChallengeRequest, CredentialsAuthCompleteResult, CredentialsAuthCredential, CredentialsAuthField, CredentialsAuthFields, CredentialsAuthFieldType, CredentialsAuthInput, CredentialsAuthLoginResult, DefineCredentialsAuthOptions, DefinedCredentialsAuth, } from "./auth";
|
|
3
|
-
export { createFormCeremony } from "./ceremonies";
|
|
4
|
-
export { assertFreshProviderChoiceIssuedAt, createProviderChoiceToken, ProviderChoiceTokenError, type ProviderChoiceTokenErrorReason, type ProviderChoiceTokenPayload, parseProviderChoiceToken, } from "./choice-token";
|
|
5
|
-
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, every, } from "./define";
|
|
6
|
-
export { AuthError, isProviderError, isSessionExpiredError, isTransportError, ProviderError, SessionExpiredError, TransportError, ValidationError, } from "./errors";
|
|
7
|
-
export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n";
|
|
8
|
-
export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice";
|
|
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";
|
|
10
|
-
export type { AuthAbortData, AuthAbortRetry, AuthFlowTerminalContext, AuthMode, AuthSafeData, AuthSafeJson, FlowContext, HealthCheckAssertionContext, HealthCheckCase, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthScheduleRandomization, HttpRetryOptions, HttpRetrySummary, InferSchemaOutput, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDocMeta, OperationErrorCode, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, ProviderAccessVisibility, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderDefinition, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderProxyPolicy, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderRuntimeState, ProviderStateDurationString, ProviderStateNamespace, ProviderSupportLevel, SchemaLike, SmsOtpMatcherDefinition, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateValue, StateWriteOptions, } from "./types";
|
|
11
|
-
export { HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, } from "./types";
|
|
1
|
+
export { AuthAbortError, credentialsAuthChallenge, createAuthFlowHelpers, defineCredentialsAuth, } from "./auth.js";
|
|
2
|
+
export type { CredentialsAuthChallengeDefinition, CredentialsAuthChallengeRequest, CredentialsAuthCompleteResult, CredentialsAuthCredential, CredentialsAuthField, CredentialsAuthFields, CredentialsAuthFieldType, CredentialsAuthInput, CredentialsAuthLoginResult, DefineCredentialsAuthOptions, DefinedCredentialsAuth, } from "./auth.js";
|
|
3
|
+
export { createFormCeremony } from "./ceremonies/index.js";
|
|
4
|
+
export { assertFreshProviderChoiceIssuedAt, createProviderChoiceToken, ProviderChoiceTokenError, type ProviderChoiceTokenErrorReason, type ProviderChoiceTokenPayload, parseProviderChoiceToken, } from "./choice-token.js";
|
|
5
|
+
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, every, } from "./define.js";
|
|
6
|
+
export { AuthError, isProviderError, isSessionExpiredError, isTransportError, ProviderError, SessionExpiredError, TransportError, ValidationError, } from "./errors.js";
|
|
7
|
+
export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n/index.js";
|
|
8
|
+
export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
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
|
+
export type { AuthAbortData, AuthAbortRetry, AuthFlowTerminalContext, AuthMode, AuthSafeData, AuthSafeJson, FlowContext, HealthCheckAssertionContext, HealthCheckCase, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthScheduleRandomization, HttpRetryOptions, HttpRetrySummary, InferSchemaOutput, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDocMeta, OperationErrorCode, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, ProviderAccessVisibility, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderDefinition, ProviderDeploymentOverrides, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderProxyPolicy, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderRuntimeState, ProviderStateDurationString, ProviderStateNamespace, ProviderSupportLevel, SchemaLike, SmsOtpMatcherDefinition, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateValue, StateWriteOptions, } from "./types.js";
|
|
11
|
+
export { HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, } from "./types.js";
|
package/dist/provider.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { AuthAbortError, credentialsAuthChallenge, createAuthFlowHelpers, defineCredentialsAuth, } from "./auth";
|
|
2
|
-
export { createFormCeremony } from "./ceremonies";
|
|
3
|
-
export { assertFreshProviderChoiceIssuedAt, createProviderChoiceToken, ProviderChoiceTokenError, parseProviderChoiceToken, } from "./choice-token";
|
|
4
|
-
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, every, } from "./define";
|
|
5
|
-
export { AuthError, isProviderError, isSessionExpiredError, isTransportError, ProviderError, SessionExpiredError, TransportError, ValidationError, } from "./errors";
|
|
6
|
-
export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n";
|
|
7
|
-
export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice";
|
|
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";
|
|
9
|
-
export { HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, } from "./types";
|
|
1
|
+
export { AuthAbortError, credentialsAuthChallenge, createAuthFlowHelpers, defineCredentialsAuth, } from "./auth.js";
|
|
2
|
+
export { createFormCeremony } from "./ceremonies/index.js";
|
|
3
|
+
export { assertFreshProviderChoiceIssuedAt, createProviderChoiceToken, ProviderChoiceTokenError, parseProviderChoiceToken, } from "./choice-token.js";
|
|
4
|
+
export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, every, } from "./define.js";
|
|
5
|
+
export { AuthError, isProviderError, isSessionExpiredError, isTransportError, ProviderError, SessionExpiredError, TransportError, ValidationError, } from "./errors.js";
|
|
6
|
+
export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n/index.js";
|
|
7
|
+
export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
|
|
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 { HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, } from "./types.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { LintDiagnostic } from "./lint";
|
|
1
|
+
import type { LintDiagnostic } from "./lint.js";
|
|
2
2
|
export declare function lintPublicSchemaFieldNames(providerId: string | undefined, operationId: string, input: unknown, output: unknown, enforce: boolean): LintDiagnostic[];
|
package/dist/recipes/gov-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContextScratchpad, EnvContext, FlowContext, HttpClient, StealthClient, SttContext } from "../types";
|
|
1
|
+
import type { ContextScratchpad, EnvContext, FlowContext, HttpClient, StealthClient, SttContext } from "../types.js";
|
|
2
2
|
export declare function createScratchpad(allowedKeys: string[], initial?: Record<string, unknown>): ContextScratchpad;
|
|
3
3
|
export declare function createFlowContext(options: {
|
|
4
4
|
http: HttpClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ContextAccessError } from "../errors";
|
|
2
|
-
import { createAuthFlowHelpers } from "../auth";
|
|
3
|
-
import { createUnsupportedSttClient } from "./stt";
|
|
1
|
+
import { ContextAccessError } from "../errors.js";
|
|
2
|
+
import { createAuthFlowHelpers } from "../auth.js";
|
|
3
|
+
import { createUnsupportedSttClient } from "./stt.js";
|
|
4
4
|
function normalizeAllowedKeys(allowedKeys) {
|
|
5
5
|
return new Set(allowedKeys.filter((key) => key.trim().length > 0));
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BrowserChallengeRequest, BrowserChallengeResult, BrowserClient as BrowserClientContract, BrowserEngine, BrowserOptions, BrowserPage } from "../types";
|
|
1
|
+
import type { BrowserChallengeRequest, BrowserChallengeResult, BrowserClient as BrowserClientContract, BrowserEngine, BrowserOptions, BrowserPage } from "../types.js";
|
|
2
2
|
type BrowserPageContract = BrowserPage;
|
|
3
3
|
export type BrowserClientOptions = BrowserOptions & {
|
|
4
4
|
allowedHosts?: string[];
|
package/dist/runtime/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { ProviderError } from "../errors";
|
|
2
|
+
import { ProviderError } from "../errors.js";
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
const DEFAULT_WAIT_TIMEOUT_MS = 30_000;
|
|
5
5
|
const SELECTOR_POLL_INTERVAL_MS = 100;
|
|
@@ -83,13 +83,14 @@ function matchesResourceRoute(match, request) {
|
|
|
83
83
|
function toCdpFulfillParams(requestId, decision) {
|
|
84
84
|
const body = toResourceBody(decision.body);
|
|
85
85
|
return {
|
|
86
|
-
...(body === undefined
|
|
87
|
-
? {}
|
|
88
|
-
: { body: Buffer.from(body).toString("base64") }),
|
|
86
|
+
...(body === undefined ? {} : { body: Buffer.from(body).toString("base64") }),
|
|
89
87
|
...(decision.headers === undefined
|
|
90
88
|
? {}
|
|
91
89
|
: {
|
|
92
|
-
responseHeaders: Object.entries(decision.headers).map(([name, value]) => ({
|
|
90
|
+
responseHeaders: Object.entries(decision.headers).map(([name, value]) => ({
|
|
91
|
+
name,
|
|
92
|
+
value,
|
|
93
|
+
})),
|
|
93
94
|
}),
|
|
94
95
|
requestId,
|
|
95
96
|
responseCode: decision.status ?? 200,
|
|
@@ -574,16 +575,13 @@ function parsePoolAcquireResponse(value) {
|
|
|
574
575
|
code: "BROWSER_RUNTIME_UNSUPPORTED",
|
|
575
576
|
});
|
|
576
577
|
}
|
|
577
|
-
if (value.browserContextId !== undefined &&
|
|
578
|
-
typeof value.browserContextId !== "string") {
|
|
578
|
+
if (value.browserContextId !== undefined && typeof value.browserContextId !== "string") {
|
|
579
579
|
throw new ProviderError("CDP Pool returned an invalid acquire response", {
|
|
580
580
|
code: "BROWSER_RUNTIME_UNSUPPORTED",
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
583
|
return {
|
|
584
|
-
...(value.browserContextId
|
|
585
|
-
? { browserContextId: value.browserContextId }
|
|
586
|
-
: {}),
|
|
584
|
+
...(value.browserContextId ? { browserContextId: value.browserContextId } : {}),
|
|
587
585
|
pageId: value.pageId,
|
|
588
586
|
wsEndpoint: value.wsEndpoint,
|
|
589
587
|
};
|
|
@@ -605,9 +603,7 @@ function parseCdpFrameTreeNode(value) {
|
|
|
605
603
|
frame: {
|
|
606
604
|
id: frameId,
|
|
607
605
|
name: typeof value.frame.name === "string" ? value.frame.name : undefined,
|
|
608
|
-
parentId: typeof value.frame.parentId === "string"
|
|
609
|
-
? value.frame.parentId
|
|
610
|
-
: undefined,
|
|
606
|
+
parentId: typeof value.frame.parentId === "string" ? value.frame.parentId : undefined,
|
|
611
607
|
url: typeof value.frame.url === "string" ? value.frame.url : undefined,
|
|
612
608
|
},
|
|
613
609
|
...(childFrames ? { childFrames } : {}),
|
|
@@ -620,9 +616,7 @@ function getCdpExecutionContext(params) {
|
|
|
620
616
|
const contextId = params.context.id;
|
|
621
617
|
const auxData = params.context.auxData;
|
|
622
618
|
return {
|
|
623
|
-
frameId: isRecord(auxData) && typeof auxData.frameId === "string"
|
|
624
|
-
? auxData.frameId
|
|
625
|
-
: undefined,
|
|
619
|
+
frameId: isRecord(auxData) && typeof auxData.frameId === "string" ? auxData.frameId : undefined,
|
|
626
620
|
id: typeof contextId === "number" ? contextId : undefined,
|
|
627
621
|
};
|
|
628
622
|
}
|
|
@@ -773,8 +767,7 @@ class CdpPoolBrowserPage {
|
|
|
773
767
|
returnByValue: true,
|
|
774
768
|
});
|
|
775
769
|
if (result.exceptionDetails) {
|
|
776
|
-
throw new Error(String(result.exceptionDetails.text ??
|
|
777
|
-
"Browser evaluation failed"));
|
|
770
|
+
throw new Error(String(result.exceptionDetails.text ?? "Browser evaluation failed"));
|
|
778
771
|
}
|
|
779
772
|
return result.result?.value;
|
|
780
773
|
}
|
|
@@ -859,9 +852,7 @@ class CdpPoolBrowserPage {
|
|
|
859
852
|
this.closed = true;
|
|
860
853
|
try {
|
|
861
854
|
await this.release({
|
|
862
|
-
...(this.browserContextId
|
|
863
|
-
? { browserContextId: this.browserContextId }
|
|
864
|
-
: {}),
|
|
855
|
+
...(this.browserContextId ? { browserContextId: this.browserContextId } : {}),
|
|
865
856
|
pageId: this.pageId,
|
|
866
857
|
});
|
|
867
858
|
}
|
|
@@ -1002,12 +993,8 @@ class CdpPoolBrowserClient {
|
|
|
1002
993
|
}
|
|
1003
994
|
async acquirePage(options) {
|
|
1004
995
|
const acquireResult = parsePoolAcquireResponse(await this.poolClient.send("acquire", {
|
|
1005
|
-
...(this.allowedHosts.length > 0
|
|
1006
|
-
|
|
1007
|
-
: {}),
|
|
1008
|
-
...(options?.isolatedContext
|
|
1009
|
-
? { isolationMode: "browserContext" }
|
|
1010
|
-
: {}),
|
|
996
|
+
...(this.allowedHosts.length > 0 ? { allowedHosts: this.allowedHosts } : {}),
|
|
997
|
+
...(options?.isolatedContext ? { isolationMode: "browserContext" } : {}),
|
|
1011
998
|
}));
|
|
1012
999
|
const pageClient = new JsonRpcWebSocketClient(acquireResult.wsEndpoint);
|
|
1013
1000
|
const page = new CdpPoolBrowserPage(acquireResult.pageId, acquireResult.browserContextId, pageClient, async (request) => {
|
|
@@ -1223,8 +1210,7 @@ async function solveRecaptchaChallenge(page, request) {
|
|
|
1223
1210
|
async function findRecaptchaFrame(frames, siteKey) {
|
|
1224
1211
|
for (const frame of frames) {
|
|
1225
1212
|
const url = await frame.url();
|
|
1226
|
-
const matchesRecaptcha = url.includes("google.com/recaptcha") ||
|
|
1227
|
-
url.includes("recaptcha.net/recaptcha");
|
|
1213
|
+
const matchesRecaptcha = url.includes("google.com/recaptcha") || url.includes("recaptcha.net/recaptcha");
|
|
1228
1214
|
const matchesSiteKey = !siteKey || url.includes(siteKey);
|
|
1229
1215
|
if (matchesRecaptcha && matchesSiteKey) {
|
|
1230
1216
|
return frame;
|
package/dist/runtime/cache.d.ts
CHANGED
package/dist/runtime/cache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { providerCacheRedisUrlFromEnv } from "../config/loader";
|
|
3
|
-
import { createProviderRedisClient, ensureRedisReady, withRedisTimeout, } from "./redis";
|
|
2
|
+
import { providerCacheRedisUrlFromEnv } from "../config/loader.js";
|
|
3
|
+
import { createProviderRedisClient, ensureRedisReady, withRedisTimeout, } from "./redis.js";
|
|
4
4
|
const DEFAULT_PREFIX = "apifuse:provider-cache:v1";
|
|
5
5
|
const DEFAULT_MEMORY_MAX_ENTRIES = 1_000;
|
|
6
6
|
const DEFAULT_REDIS_TIMEOUT_MS = 150;
|
|
@@ -71,10 +71,7 @@ function normalizeKeyPart(value, extra) {
|
|
|
71
71
|
return value;
|
|
72
72
|
}
|
|
73
73
|
function stableHash(value) {
|
|
74
|
-
return createHash("sha256")
|
|
75
|
-
.update(JSON.stringify(value))
|
|
76
|
-
.digest("hex")
|
|
77
|
-
.slice(0, 32);
|
|
74
|
+
return createHash("sha256").update(JSON.stringify(value)).digest("hex").slice(0, 32);
|
|
78
75
|
}
|
|
79
76
|
function jitteredTtlMs(ttlMs, jitterPct) {
|
|
80
77
|
if (!jitterPct || jitterPct <= 0)
|
|
@@ -282,8 +279,7 @@ export function createProviderCache(options) {
|
|
|
282
279
|
async delete(key) {
|
|
283
280
|
backend.memory.delete(key);
|
|
284
281
|
const redis = backend.redis;
|
|
285
|
-
if (!redis ||
|
|
286
|
-
!(await ensureRedisReady(redis, DEFAULT_REDIS_TIMEOUT_MS))) {
|
|
282
|
+
if (!redis || !(await ensureRedisReady(redis, DEFAULT_REDIS_TIMEOUT_MS))) {
|
|
287
283
|
return;
|
|
288
284
|
}
|
|
289
285
|
await withRedisFallback(() => redis.del(key));
|
package/dist/runtime/choice.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CredentialContext, EnvContext, ProviderChoiceContext, ProviderRequestContext, ProviderRuntimeState } from "../types";
|
|
1
|
+
import type { CredentialContext, EnvContext, ProviderChoiceContext, ProviderRequestContext, ProviderRuntimeState } from "../types.js";
|
|
2
2
|
export declare const PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV = "APIFUSE__PROVIDER_RUNTIME__CHOICE_TOKEN_MASTER_SECRET";
|
|
3
3
|
export type CreateProviderChoiceContextOptions = {
|
|
4
4
|
readonly providerId: string;
|
package/dist/runtime/choice.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes, timingSafeEqual, } from "node:crypto";
|
|
2
|
-
import { assertFreshProviderChoiceIssuedAt, ProviderChoiceTokenError, } from "../choice-token";
|
|
3
|
-
import { ProviderError } from "../errors";
|
|
2
|
+
import { assertFreshProviderChoiceIssuedAt, ProviderChoiceTokenError, } from "../choice-token.js";
|
|
3
|
+
import { ProviderError } from "../errors.js";
|
|
4
4
|
export const PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV = "APIFUSE__PROVIDER_RUNTIME__CHOICE_TOKEN_MASTER_SECRET";
|
|
5
5
|
const PRIMARY_CHOICE_TOKEN_KID = "v1";
|
|
6
6
|
const MANAGED_CHOICE_TOKEN_VERSION = 1;
|
|
@@ -53,7 +53,7 @@ export function createProviderChoiceContext(options) {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
function parse(parseOptions) {
|
|
56
|
-
const [actualPrefix, tokenKid, encodedIv, encryptedPayload, authTag, signature
|
|
56
|
+
const [actualPrefix, tokenKid, encodedIv, encryptedPayload, authTag, signature] = parseManagedChoiceTokenParts(parseOptions.token);
|
|
57
57
|
if (actualPrefix !== parseOptions.prefix ||
|
|
58
58
|
tokenKid !== kid ||
|
|
59
59
|
!encodedIv ||
|
|
@@ -68,13 +68,7 @@ export function createProviderChoiceContext(options) {
|
|
|
68
68
|
purpose: parseOptions.purpose,
|
|
69
69
|
kid: tokenKid,
|
|
70
70
|
});
|
|
71
|
-
const signedBody = [
|
|
72
|
-
parseOptions.prefix,
|
|
73
|
-
tokenKid,
|
|
74
|
-
encodedIv,
|
|
75
|
-
encryptedPayload,
|
|
76
|
-
authTag,
|
|
77
|
-
].join(".");
|
|
71
|
+
const signedBody = [parseOptions.prefix, tokenKid, encodedIv, encryptedPayload, authTag].join(".");
|
|
78
72
|
assertManagedChoiceSignature({
|
|
79
73
|
signedBody,
|
|
80
74
|
signature,
|
|
@@ -117,13 +111,11 @@ export function createProviderChoiceContext(options) {
|
|
|
117
111
|
export function createTestProviderChoiceContext(options) {
|
|
118
112
|
return createProviderChoiceContext({
|
|
119
113
|
...options,
|
|
120
|
-
masterSecret: options.masterSecret ??
|
|
121
|
-
"apifuse-test-provider-runtime-choice-token-master-secret",
|
|
114
|
+
masterSecret: options.masterSecret ?? "apifuse-test-provider-runtime-choice-token-master-secret",
|
|
122
115
|
});
|
|
123
116
|
}
|
|
124
117
|
function resolveChoiceMasterSecret(options) {
|
|
125
|
-
const configured = options.masterSecret ??
|
|
126
|
-
options.env?.get(PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV);
|
|
118
|
+
const configured = options.masterSecret ?? options.env?.get(PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV);
|
|
127
119
|
const trimmed = configured?.trim();
|
|
128
120
|
if (trimmed)
|
|
129
121
|
return trimmed;
|
|
@@ -165,13 +157,7 @@ function encryptManagedChoiceToken(options) {
|
|
|
165
157
|
]).toString("base64url");
|
|
166
158
|
const authTag = cipher.getAuthTag().toString("base64url");
|
|
167
159
|
const encodedIv = iv.toString("base64url");
|
|
168
|
-
const signedBody = [
|
|
169
|
-
options.prefix,
|
|
170
|
-
options.kid,
|
|
171
|
-
encodedIv,
|
|
172
|
-
encryptedPayload,
|
|
173
|
-
authTag,
|
|
174
|
-
].join(".");
|
|
160
|
+
const signedBody = [options.prefix, options.kid, encodedIv, encryptedPayload, authTag].join(".");
|
|
175
161
|
const signature = createHmac("sha256", options.keys.signing)
|
|
176
162
|
.update(signedBody)
|
|
177
163
|
.digest("base64url");
|
|
@@ -345,9 +331,7 @@ function isManagedChoiceEnvelope(value) {
|
|
|
345
331
|
typeof value.issued_at_ms === "number" &&
|
|
346
332
|
"ttl_ms" in value &&
|
|
347
333
|
typeof value.ttl_ms === "number" &&
|
|
348
|
-
(!("binding" in value) ||
|
|
349
|
-
value.binding === undefined ||
|
|
350
|
-
isChoiceBinding(value.binding)));
|
|
334
|
+
(!("binding" in value) || value.binding === undefined || isChoiceBinding(value.binding)));
|
|
351
335
|
}
|
|
352
336
|
function isChoicePayload(value) {
|
|
353
337
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
@@ -355,29 +339,23 @@ function isChoicePayload(value) {
|
|
|
355
339
|
function isChoiceBinding(value) {
|
|
356
340
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
357
341
|
return false;
|
|
358
|
-
return ((!("connection_hash" in value) ||
|
|
359
|
-
typeof value.connection_hash === "string") &&
|
|
342
|
+
return ((!("connection_hash" in value) || typeof value.connection_hash === "string") &&
|
|
360
343
|
(!("credential_hash" in value) || typeof value.credential_hash === "string"));
|
|
361
344
|
}
|
|
362
345
|
function assertManagedChoiceEnvelope(envelope, options) {
|
|
363
|
-
if (envelope.provider_id !== options.providerId ||
|
|
364
|
-
envelope.purpose !== options.purpose) {
|
|
346
|
+
if (envelope.provider_id !== options.providerId || envelope.purpose !== options.purpose) {
|
|
365
347
|
throw new ProviderChoiceTokenError("invalid_payload", "Provider choice token payload is invalid.");
|
|
366
348
|
}
|
|
367
349
|
assertFreshProviderChoiceIssuedAt(envelope.issued_at_ms, {
|
|
368
350
|
// Clamp to the issuer's embedded TTL so a caller-supplied value cannot
|
|
369
351
|
// silently extend token validity past the deadline the issuer intended.
|
|
370
|
-
ttlMs: options.ttlMs != null
|
|
371
|
-
? Math.min(options.ttlMs, envelope.ttl_ms)
|
|
372
|
-
: envelope.ttl_ms,
|
|
352
|
+
ttlMs: options.ttlMs != null ? Math.min(options.ttlMs, envelope.ttl_ms) : envelope.ttl_ms,
|
|
373
353
|
nowMs: options.nowMs,
|
|
374
354
|
futureToleranceMs: options.futureToleranceMs,
|
|
375
355
|
});
|
|
376
356
|
}
|
|
377
357
|
function createChoiceBinding(options) {
|
|
378
|
-
const connectionHash = options.options?.connection
|
|
379
|
-
? hashRequiredConnection(options)
|
|
380
|
-
: undefined;
|
|
358
|
+
const connectionHash = options.options?.connection ? hashRequiredConnection(options) : undefined;
|
|
381
359
|
const credentialHash = options.options?.credentialKeys?.length
|
|
382
360
|
? hashCredentialKeys(options)
|
|
383
361
|
: undefined;
|