@apifuse/provider-sdk 2.2.0-beta.2 → 2.2.0-beta.21
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 +487 -0
- package/CHANGELOG.md +90 -0
- package/README.md +49 -3
- package/SUBMISSION.md +1 -1
- package/bin/apifuse-check.ts +44 -59
- package/bin/apifuse-create.ts +1 -1
- package/bin/apifuse-dev.ts +27 -52
- package/bin/apifuse-pack-check.ts +14 -0
- package/bin/apifuse-pack-smoke.ts +36 -81
- package/bin/apifuse-pack-types.ts +305 -0
- package/bin/apifuse-perf.ts +45 -127
- package/bin/apifuse-record.ts +659 -111
- package/bin/apifuse-submit-check.ts +546 -48
- package/bin/apifuse-sync-assets.ts +117 -0
- package/bin/apifuse.ts +1 -1
- package/bin/submit-check-delimited-text.ts +50 -0
- package/bin/submit-check-xml-semantics.ts +204 -0
- package/bin/submit-check-xml.ts +134 -0
- package/dist/auth-turn/index.d.ts +3 -3
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +9 -18
- package/dist/ceremonies/index.d.ts +9 -1
- package/dist/ceremonies/index.js +65 -18
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +8 -0
- package/dist/cli/create.d.ts +3 -0
- package/dist/cli/create.js +34 -35
- package/dist/cli/prompt-assets.d.ts +80 -0
- package/dist/cli/prompt-assets.js +743 -0
- package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/dist/config/loader.d.ts +176 -8
- package/dist/config/loader.js +424 -95
- 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 +9 -1
- package/dist/define.js +304 -119
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/error-resolution.d.ts +2 -0
- package/dist/error-resolution.js +90 -0
- package/dist/errors.d.ts +22 -1
- package/dist/errors.js +88 -0
- package/dist/fixture-sanitization.d.ts +26 -0
- package/dist/fixture-sanitization.js +216 -0
- 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 +46 -42
- package/dist/index.js +41 -37
- package/dist/lint.d.ts +1 -1
- package/dist/lint.js +8 -15
- package/dist/native-address.d.ts +43 -0
- package/dist/native-address.js +281 -0
- package/dist/native-egress-policy.d.ts +31 -0
- package/dist/native-egress-policy.js +288 -0
- package/dist/observability.d.ts +5 -2
- package/dist/observability.js +48 -1
- package/dist/provider.d.ts +12 -11
- package/dist/provider.js +10 -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 +2 -1
- package/dist/runtime/auth-flow.js +4 -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 +31 -35
- 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 +31 -4
- package/dist/runtime/http.d.ts +2 -2
- package/dist/runtime/http.js +387 -47
- 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 +345 -22
- package/dist/runtime/keyring.js +1 -1
- package/dist/runtime/namespace.js +1 -1
- package/dist/runtime/native-network.d.ts +127 -0
- package/dist/runtime/native-network.js +1298 -0
- 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 +9 -7
- package/dist/runtime/proxy-nodemaven.d.ts +56 -0
- package/dist/runtime/proxy-nodemaven.js +146 -0
- 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 +2 -1
- package/dist/runtime/proxy-telemetry.js +55 -52
- package/dist/runtime/redirects.d.ts +29 -0
- package/dist/runtime/redirects.js +36 -0
- package/dist/runtime/redis.d.ts +1 -1
- package/dist/runtime/redis.js +2 -4
- package/dist/runtime/request-options.d.ts +68 -1
- package/dist/runtime/request-options.js +548 -0
- package/dist/runtime/secrets.d.ts +27 -0
- package/dist/runtime/secrets.js +51 -0
- package/dist/runtime/state.d.ts +2 -2
- package/dist/runtime/state.js +238 -26
- package/dist/runtime/stealth.d.ts +5 -3
- package/dist/runtime/stealth.js +423 -143
- 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-input-tokens.d.ts +2 -1
- package/dist/server/self-test-input-tokens.js +18 -14
- 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 +104 -3
- package/dist/server/self-test.js +673 -115
- package/dist/server/serve.d.ts +116 -4
- package/dist/server/serve.js +799 -128
- package/dist/server/types.d.ts +34 -9
- package/dist/server/types.js +8 -1
- package/dist/stateful/errors.d.ts +14 -0
- package/dist/stateful/errors.js +14 -0
- package/dist/stateful/http-provider-event-emitter.d.ts +40 -0
- package/dist/stateful/http-provider-event-emitter.js +237 -0
- package/dist/stateful/http-session-owner-registry.d.ts +44 -0
- package/dist/stateful/http-session-owner-registry.js +210 -0
- package/dist/stateful/index.d.ts +18 -0
- package/dist/stateful/index.js +18 -0
- package/dist/stateful/provider-event-delivery-failures.d.ts +32 -0
- package/dist/stateful/provider-event-delivery-failures.js +43 -0
- package/dist/stateful/provider-event-pipeline-metrics.d.ts +46 -0
- package/dist/stateful/provider-event-pipeline-metrics.js +48 -0
- package/dist/stateful/provider-event-pipeline.d.ts +50 -0
- package/dist/stateful/provider-event-pipeline.js +1 -0
- package/dist/stateful/provider-events.d.ts +101 -0
- package/dist/stateful/provider-events.js +289 -0
- package/dist/stateful/session-key.d.ts +15 -0
- package/dist/stateful/session-key.js +86 -0
- package/dist/stateful/stateful-provider-adapter-context.d.ts +5 -0
- package/dist/stateful/stateful-provider-adapter-context.js +42 -0
- package/dist/stateful/stateful-provider-adapter-metrics.d.ts +15 -0
- package/dist/stateful/stateful-provider-adapter-metrics.js +21 -0
- package/dist/stateful/stateful-provider-adapter.d.ts +98 -0
- package/dist/stateful/stateful-provider-adapter.js +287 -0
- package/dist/stateful/stateful-provider-observability.d.ts +62 -0
- package/dist/stateful/stateful-provider-observability.js +161 -0
- package/dist/stateful/stateful-provider-owner-forwarder.d.ts +41 -0
- package/dist/stateful/stateful-provider-owner-forwarder.js +215 -0
- package/dist/stateful/stateful-provider-runtime-context.d.ts +32 -0
- package/dist/stateful/stateful-provider-runtime-context.js +60 -0
- package/dist/stateful/stateful-provider-runtime-executor.d.ts +34 -0
- package/dist/stateful/stateful-provider-runtime-executor.js +52 -0
- package/dist/stateful/stateful-provider-session-routing.d.ts +71 -0
- package/dist/stateful/stateful-provider-session-routing.js +353 -0
- package/dist/stateful/stateful-provider-session-runtime.d.ts +98 -0
- package/dist/stateful/stateful-provider-session-runtime.js +245 -0
- package/dist/stateful-signing.d.ts +18 -0
- package/dist/stateful-signing.js +27 -0
- package/dist/stealth/profiles.d.ts +1 -1
- package/dist/stealth/profiles.js +5 -14
- package/dist/stream-evidence.d.ts +74 -0
- package/dist/stream-evidence.js +785 -0
- 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 +32 -2
- package/dist/testing/run.js +478 -28
- package/dist/types.d.ts +342 -14
- package/dist/types.js +1 -0
- package/dist/user-input.d.ts +30 -0
- package/dist/user-input.js +66 -0
- package/package.json +16 -5
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +28 -86
- package/src/ceremonies/index.ts +103 -78
- package/src/cli/commands.ts +10 -0
- package/src/cli/create.ts +42 -35
- package/src/cli/prompt-assets.ts +865 -0
- package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/src/config/loader.ts +652 -204
- package/src/contract-serialization.ts +5 -11
- package/src/contract-types.ts +2 -2
- package/src/contract.ts +12 -28
- package/src/define.ts +499 -498
- package/src/dev.ts +4 -9
- package/src/error-resolution.ts +91 -0
- package/src/errors.ts +110 -5
- package/src/fixture-sanitization.ts +247 -0
- 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 +112 -42
- package/src/lint.ts +88 -152
- package/src/native-address.ts +340 -0
- package/src/native-egress-policy.ts +358 -0
- package/src/observability.ts +51 -1
- package/src/provider.ts +66 -11
- package/src/public-schema-field-lint.ts +7 -33
- package/src/recipes/gov-api.ts +2 -5
- package/src/runtime/auth-flow.ts +7 -7
- package/src/runtime/browser.ts +64 -187
- package/src/runtime/cache.ts +20 -67
- package/src/runtime/choice.ts +79 -132
- package/src/runtime/credential.ts +2 -2
- package/src/runtime/env.ts +1 -1
- package/src/runtime/executor.ts +43 -20
- package/src/runtime/http.ts +494 -57
- package/src/runtime/insights.ts +15 -53
- package/src/runtime/instrumentation.ts +495 -66
- package/src/runtime/keyring.ts +7 -19
- package/src/runtime/namespace.ts +2 -7
- package/src/runtime/native-network.ts +1686 -0
- 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 +29 -42
- package/src/runtime/proxy-nodemaven.ts +221 -0
- package/src/runtime/proxy-retry-policy.ts +3 -3
- package/src/runtime/proxy-telemetry.ts +79 -77
- package/src/runtime/redirects.ts +66 -0
- package/src/runtime/redis.ts +4 -12
- package/src/runtime/request-options.ts +679 -9
- package/src/runtime/secrets.ts +64 -0
- package/src/runtime/state.ts +353 -133
- package/src/runtime/stealth.ts +505 -154
- 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 +29 -7
- package/src/server/self-test-input-tokens.ts +29 -14
- package/src/server/self-test-redaction.ts +2 -2
- package/src/server/self-test.ts +857 -132
- package/src/server/serve.ts +1151 -328
- package/src/server/types.ts +12 -13
- package/src/stateful/README.md +146 -0
- package/src/stateful/errors.ts +23 -0
- package/src/stateful/http-provider-event-emitter.ts +314 -0
- package/src/stateful/http-session-owner-registry.ts +306 -0
- package/src/stateful/index.ts +18 -0
- package/src/stateful/provider-event-delivery-failures.ts +80 -0
- package/src/stateful/provider-event-pipeline-metrics.ts +95 -0
- package/src/stateful/provider-event-pipeline.ts +61 -0
- package/src/stateful/provider-events.ts +462 -0
- package/src/stateful/session-key.ts +111 -0
- package/src/stateful/stateful-provider-adapter-context.ts +59 -0
- package/src/stateful/stateful-provider-adapter-metrics.ts +48 -0
- package/src/stateful/stateful-provider-adapter.ts +562 -0
- package/src/stateful/stateful-provider-observability.ts +261 -0
- package/src/stateful/stateful-provider-owner-forwarder.ts +287 -0
- package/src/stateful/stateful-provider-runtime-context.ts +92 -0
- package/src/stateful/stateful-provider-runtime-executor.ts +96 -0
- package/src/stateful/stateful-provider-session-routing.ts +555 -0
- package/src/stateful/stateful-provider-session-runtime.ts +403 -0
- package/src/stateful-signing.ts +46 -0
- package/src/stealth/profiles.ts +10 -26
- package/src/stream-evidence.ts +988 -0
- package/src/stream.ts +8 -19
- package/src/testing/index.ts +10 -2
- package/src/testing/run.ts +653 -74
- package/src/types.ts +408 -28
- package/src/user-input.ts +118 -0
- package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
- package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
- /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
package/dist/runtime/stt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProviderSttConfig, SttContext, SttTranscribeRequest, SttVerificationCodeOptions, VerificationCodeExtractionResult } from "../types";
|
|
1
|
+
import type { ProviderSttConfig, SttContext, SttTranscribeRequest, SttVerificationCodeOptions, VerificationCodeExtractionResult } from "../types.js";
|
|
2
2
|
export declare const APIFUSE__STT__BACKEND_ENV = "APIFUSE__STT__BACKEND";
|
|
3
3
|
export declare const APIFUSE__STT__MODEL_ENV = "APIFUSE__STT__MODEL";
|
|
4
4
|
export declare const CLOUDFLARE_ACCOUNT_ID_ENV = "APIFUSE__CLOUDFLARE__ACCOUNT_ID";
|
package/dist/runtime/stt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProviderError, TransportError, ValidationError } from "../errors";
|
|
1
|
+
import { ProviderError, TransportError, ValidationError } from "../errors.js";
|
|
2
2
|
export const APIFUSE__STT__BACKEND_ENV = "APIFUSE__STT__BACKEND";
|
|
3
3
|
export const APIFUSE__STT__MODEL_ENV = "APIFUSE__STT__MODEL";
|
|
4
4
|
export const CLOUDFLARE_ACCOUNT_ID_ENV = "APIFUSE__CLOUDFLARE__ACCOUNT_ID";
|
|
@@ -59,17 +59,12 @@ export function createSttClientFromEnv(config, env = process.env) {
|
|
|
59
59
|
return createCloudflareWorkersAiSttClient({
|
|
60
60
|
accountId,
|
|
61
61
|
apiToken,
|
|
62
|
-
model: normalizedEnvValue(env, APIFUSE__STT__MODEL_ENV) ??
|
|
63
|
-
DEFAULT_CLOUDFLARE_WORKERS_AI_STT_MODEL,
|
|
62
|
+
model: normalizedEnvValue(env, APIFUSE__STT__MODEL_ENV) ?? DEFAULT_CLOUDFLARE_WORKERS_AI_STT_MODEL,
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
function base64ByteLength(data) {
|
|
67
66
|
const normalized = data.trim();
|
|
68
|
-
const padding = normalized.endsWith("==")
|
|
69
|
-
? 2
|
|
70
|
-
: normalized.endsWith("=")
|
|
71
|
-
? 1
|
|
72
|
-
: 0;
|
|
67
|
+
const padding = normalized.endsWith("==") ? 2 : normalized.endsWith("=") ? 1 : 0;
|
|
73
68
|
return Math.floor((normalized.length * 3) / 4) - padding;
|
|
74
69
|
}
|
|
75
70
|
function assertBase64Audio(audio, maxAudioBytes) {
|
|
@@ -80,9 +75,7 @@ function assertBase64Audio(audio, maxAudioBytes) {
|
|
|
80
75
|
});
|
|
81
76
|
}
|
|
82
77
|
const data = audio.data.trim();
|
|
83
|
-
if (data.length === 0 ||
|
|
84
|
-
data.length % 4 !== 0 ||
|
|
85
|
-
!BASE64_AUDIO_PATTERN.test(data)) {
|
|
78
|
+
if (data.length === 0 || data.length % 4 !== 0 || !BASE64_AUDIO_PATTERN.test(data)) {
|
|
86
79
|
throw new ValidationError("STT audio.data must be a base64-encoded string", {
|
|
87
80
|
code: "INVALID_STT_AUDIO",
|
|
88
81
|
});
|
|
@@ -90,7 +83,9 @@ function assertBase64Audio(audio, maxAudioBytes) {
|
|
|
90
83
|
const bytes = base64ByteLength(data);
|
|
91
84
|
const maxBytes = maxAudioBytes ?? DEFAULT_STT_MAX_AUDIO_BYTES;
|
|
92
85
|
if (bytes > maxBytes) {
|
|
93
|
-
throw new ValidationError(`STT audio exceeds maxAudioBytes (${bytes} > ${maxBytes})`, {
|
|
86
|
+
throw new ValidationError(`STT audio exceeds maxAudioBytes (${bytes} > ${maxBytes})`, {
|
|
87
|
+
code: "STT_AUDIO_TOO_LARGE",
|
|
88
|
+
});
|
|
94
89
|
}
|
|
95
90
|
return bytes;
|
|
96
91
|
}
|
|
@@ -227,8 +222,7 @@ export function createCloudflareWorkersAiSttClient(options) {
|
|
|
227
222
|
return {
|
|
228
223
|
async transcribe(request) {
|
|
229
224
|
const warnings = [];
|
|
230
|
-
if (request.initialPrompt &&
|
|
231
|
-
effectivePromptPolicy(request) !== "custom-hint") {
|
|
225
|
+
if (request.initialPrompt && effectivePromptPolicy(request) !== "custom-hint") {
|
|
232
226
|
const warning = warnOrThrowUnsupportedOption(request, "initialPrompt is honored only when promptPolicy is custom-hint");
|
|
233
227
|
if (warning)
|
|
234
228
|
warnings.push(warning);
|
|
@@ -350,7 +344,9 @@ function lengthSet(codeLengths) {
|
|
|
350
344
|
}
|
|
351
345
|
function validCodeLength(value) {
|
|
352
346
|
if (!Number.isInteger(value) || value < 1 || value > 32) {
|
|
353
|
-
throw new ValidationError("STT verification code length must be an integer between 1 and 32", {
|
|
347
|
+
throw new ValidationError("STT verification code length must be an integer between 1 and 32", {
|
|
348
|
+
code: "INVALID_STT_VERIFICATION_CODE_OPTIONS",
|
|
349
|
+
});
|
|
354
350
|
}
|
|
355
351
|
return value;
|
|
356
352
|
}
|
package/dist/runtime/trace.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TraceContext as BaseTraceContext, TraceAttributeValue, TraceConfig, TraceSpan } from "../types";
|
|
2
|
-
import { type OTLPExportOptions } from "./otlp";
|
|
1
|
+
import type { TraceContext as BaseTraceContext, TraceAttributeValue, TraceConfig, TraceSpan } from "../types.js";
|
|
2
|
+
import { type OTLPExportOptions } from "./otlp.js";
|
|
3
3
|
export type SpanAttributeValue = TraceAttributeValue;
|
|
4
4
|
export type Span = TraceSpan;
|
|
5
5
|
export interface TraceContext extends BaseTraceContext {
|
package/dist/runtime/trace.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { exportSpansOTLP } from "./otlp";
|
|
2
|
+
import { exportSpansOTLP } from "./otlp.js";
|
|
3
3
|
export const TRACE_RECORDER = Symbol.for("@apifuse/provider-sdk/runtime/trace-recorder");
|
|
4
4
|
function buildOTLPExportOptions(config) {
|
|
5
5
|
if (config?.exporter !== "otlp") {
|
|
@@ -23,9 +23,7 @@ export function resolveTraceContextOptions(config) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function normalizeAttributeValue(value) {
|
|
26
|
-
if (typeof value === "string" ||
|
|
27
|
-
typeof value === "number" ||
|
|
28
|
-
typeof value === "boolean") {
|
|
26
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
29
27
|
return value;
|
|
30
28
|
}
|
|
31
29
|
if (value === null || value === undefined) {
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZodString, type ZodType, z } from "zod";
|
|
2
|
-
import type { InferSchemaOutput, ProviderLocaleKey, SchemaLike } from "./types";
|
|
2
|
+
import type { InferSchemaOutput, ProviderLocaleKey, SchemaLike } from "./types.js";
|
|
3
3
|
export { z };
|
|
4
4
|
export type SchemaValidationResult<TSchema extends SchemaLike> = {
|
|
5
5
|
success: true;
|
package/dist/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { ValidationError } from "./errors";
|
|
3
|
-
import { providerLocaleKey } from "./i18n/keys";
|
|
2
|
+
import { ValidationError } from "./errors.js";
|
|
3
|
+
import { providerLocaleKey } from "./i18n/keys.js";
|
|
4
4
|
export { z };
|
|
5
5
|
function isFailureResult(result) {
|
|
6
6
|
return "issues" in result;
|
|
@@ -99,21 +99,15 @@ export function field(schema, options = {}) {
|
|
|
99
99
|
const metadata = described.meta() ?? {};
|
|
100
100
|
return described.meta({
|
|
101
101
|
...metadata,
|
|
102
|
-
...((options.sensitive ?? true)
|
|
103
|
-
|
|
104
|
-
: {}),
|
|
105
|
-
...(options.kind
|
|
106
|
-
? { [APIFUSE_SENSITIVE_KIND_META_KEY]: options.kind }
|
|
107
|
-
: {}),
|
|
102
|
+
...((options.sensitive ?? true) ? { [APIFUSE_SENSITIVE_META_KEY]: true } : {}),
|
|
103
|
+
...(options.kind ? { [APIFUSE_SENSITIVE_KIND_META_KEY]: options.kind } : {}),
|
|
108
104
|
});
|
|
109
105
|
}
|
|
110
106
|
export function sensitive(schema, kind) {
|
|
111
107
|
return field(schema, { sensitive: true, kind });
|
|
112
108
|
}
|
|
113
109
|
function sensitiveString(kind, description, options = {}) {
|
|
114
|
-
const schema = options.minLength === undefined
|
|
115
|
-
? z.string()
|
|
116
|
-
: z.string().min(options.minLength);
|
|
110
|
+
const schema = options.minLength === undefined ? z.string() : z.string().min(options.minLength);
|
|
117
111
|
return field(schema, {
|
|
118
112
|
kind,
|
|
119
113
|
description: options.description ?? description,
|
|
@@ -132,8 +126,7 @@ export const fields = {
|
|
|
132
126
|
};
|
|
133
127
|
export function isSensitiveSchema(schema) {
|
|
134
128
|
const metadata = readZodMetadata(schema);
|
|
135
|
-
return
|
|
136
|
-
Reflect.get(metadata, APIFUSE_SENSITIVE_META_KEY) === true);
|
|
129
|
+
return metadata !== undefined && Reflect.get(metadata, APIFUSE_SENSITIVE_META_KEY) === true;
|
|
137
130
|
}
|
|
138
131
|
export function collectSensitivePaths(schema) {
|
|
139
132
|
const out = [];
|
|
@@ -217,8 +210,7 @@ function pathMatches(path, patterns) {
|
|
|
217
210
|
}
|
|
218
211
|
function isReservedSensitiveKey(key) {
|
|
219
212
|
const normalized = key.toLowerCase().replace(/[-_\s]/g, "");
|
|
220
|
-
return
|
|
221
|
-
RESERVED_SENSITIVE_KEYS.has(key.toLowerCase()));
|
|
213
|
+
return RESERVED_SENSITIVE_KEYS.has(normalized) || RESERVED_SENSITIVE_KEYS.has(key.toLowerCase());
|
|
222
214
|
}
|
|
223
215
|
function readZodMetadata(schema) {
|
|
224
216
|
if (!schema || typeof schema !== "object" || !("meta" in schema)) {
|
package/dist/serve.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createServerApp, type ServeOptions, serve } from "./server/serve";
|
|
1
|
+
export { createServerApp, type ServeOptions, serve } from "./server/serve.js";
|
package/dist/serve.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createServerApp, serve } from "./server/serve";
|
|
1
|
+
export { createServerApp, serve } from "./server/serve.js";
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createServerApp, type ServeOptions, serve } from "./serve";
|
|
2
|
-
export { computeSelfTestPlanDigest, createSelfTestApp, createSelfTestInvoke, DEFAULT_SELF_TEST_REQUEST_BUDGET_MS, isSelfTestReadOnlyOperation, PROVIDER_RUNTIME_SELF_TEST_REQUEST_BUDGET_MS_ENV, resolveSelfTestPort, SELF_TEST_HEALTHZ_PATH, SELF_TEST_PATH, SELF_TEST_SCHEMA_VERSION, type SelfTestAppOptions, type SelfTestCaseResult, type SelfTestCaseStatus, type SelfTestOperationInvoke, type SelfTestRequest, SelfTestRequestSchema, type SelfTestResponse, } from "./self-test";
|
|
3
|
-
export { resolveHealthCheckInputDateTokens } from "./self-test-input-tokens";
|
|
4
|
-
export { collectSelfTestSensitiveValues, redactSelfTestText, SELF_TEST_MAX_TEXT_LENGTH, SELF_TEST_REDACTED_PLACEHOLDER, } from "./self-test-redaction";
|
|
5
|
-
export { DEFAULT_SELF_TEST_PORT, deriveSelfTestToken, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_ENV, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_PREVIOUS_ENV, PROVIDER_RUNTIME_SELF_TEST_PORT_ENV, resolveSelfTestMasterSecrets, type SelfTestMasterSecrets, verifySelfTestAuthorization, } from "./self-test-token";
|
|
6
|
-
export type { AuthFlowRequest, AuthFlowResponse, AuthFlowSuccessResponse, ConnectionMode, OperationConnection, OperationErrorResponse, OperationRequest, OperationResponse, OperationSuccessResponse, } from "./types";
|
|
7
|
-
export { AuthFlowRequestSchema, AuthFlowSuccessResponseSchema, ConnectionModeSchema, ErrorEnvelopeSchema, OperationConnectionSchema, OperationErrorResponseSchema, OperationRequestSchema, OperationSuccessResponseSchema, } from "./types";
|
|
1
|
+
export { createServerApp, ERROR_OBSERVABILITY_HEADER, type ErrorObservabilityDetails, type ProviderServerCloseOptions, type ProviderServerHandle, type ProviderServerLogEvent, type ProviderServerLogger, type ProviderServerOperationExecutor, type ProviderServerOperationExecutorInput, type ProviderServerOptions, type ProviderServerStatefulForwardEnvelope, type ServeOptions, serve, } from "./serve.js";
|
|
2
|
+
export { computeSelfTestPlanDigest, createSelfTestApp, createSelfTestAuthFlowInvoke, createSelfTestInvoke, DEFAULT_SELF_TEST_REQUEST_BUDGET_MS, isSelfTestReadOnlyOperation, PROVIDER_RUNTIME_SELF_TEST_REQUEST_BUDGET_MS_ENV, resolveSelfTestPort, SELF_TEST_AUTH_FLOW_MULTI_TURN_SKIP_REASON, SELF_TEST_AUTH_FLOW_REJECTED_SKIP_REASON, SELF_TEST_HEALTHZ_PATH, SELF_TEST_PATH, SELF_TEST_SCHEMA_VERSION, type SelfTestAppOptions, type SelfTestAuthFlowInvoke, type SelfTestAuthFlowRoute, type SelfTestCaseResult, type SelfTestCaseStatus, type SelfTestOperationInvoke, type SelfTestRequest, SelfTestRequestSchema, type SelfTestResponse, } from "./self-test.js";
|
|
3
|
+
export { type InputDateTokenCalendar, resolveHealthCheckInputDateTokens, } from "./self-test-input-tokens.js";
|
|
4
|
+
export { collectSelfTestSensitiveValues, redactSelfTestText, SELF_TEST_MAX_TEXT_LENGTH, SELF_TEST_REDACTED_PLACEHOLDER, } from "./self-test-redaction.js";
|
|
5
|
+
export { DEFAULT_SELF_TEST_PORT, deriveSelfTestToken, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_ENV, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_PREVIOUS_ENV, PROVIDER_RUNTIME_SELF_TEST_PORT_ENV, resolveSelfTestMasterSecrets, type SelfTestMasterSecrets, verifySelfTestAuthorization, } from "./self-test-token.js";
|
|
6
|
+
export type { AuthFlowRequest, AuthFlowResponse, AuthFlowSuccessResponse, ConnectionMode, OperationConnection, OperationErrorResponse, OperationRequest, OperationResponse, OperationSuccessResponse, } from "./types.js";
|
|
7
|
+
export { AuthFlowRequestSchema, AuthFlowSuccessResponseSchema, ConnectionModeSchema, ErrorEnvelopeSchema, OperationConnectionSchema, OperationErrorResponseSchema, OperationRequestSchema, OperationSuccessResponseSchema, } from "./types.js";
|
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createServerApp, serve } from "./serve";
|
|
2
|
-
export { computeSelfTestPlanDigest, createSelfTestApp, createSelfTestInvoke, DEFAULT_SELF_TEST_REQUEST_BUDGET_MS, isSelfTestReadOnlyOperation, PROVIDER_RUNTIME_SELF_TEST_REQUEST_BUDGET_MS_ENV, resolveSelfTestPort, SELF_TEST_HEALTHZ_PATH, SELF_TEST_PATH, SELF_TEST_SCHEMA_VERSION, SelfTestRequestSchema, } from "./self-test";
|
|
3
|
-
export { resolveHealthCheckInputDateTokens } from "./self-test-input-tokens";
|
|
4
|
-
export { collectSelfTestSensitiveValues, redactSelfTestText, SELF_TEST_MAX_TEXT_LENGTH, SELF_TEST_REDACTED_PLACEHOLDER, } from "./self-test-redaction";
|
|
5
|
-
export { DEFAULT_SELF_TEST_PORT, deriveSelfTestToken, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_ENV, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_PREVIOUS_ENV, PROVIDER_RUNTIME_SELF_TEST_PORT_ENV, resolveSelfTestMasterSecrets, verifySelfTestAuthorization, } from "./self-test-token";
|
|
6
|
-
export { AuthFlowRequestSchema, AuthFlowSuccessResponseSchema, ConnectionModeSchema, ErrorEnvelopeSchema, OperationConnectionSchema, OperationErrorResponseSchema, OperationRequestSchema, OperationSuccessResponseSchema, } from "./types";
|
|
1
|
+
export { createServerApp, ERROR_OBSERVABILITY_HEADER, serve, } from "./serve.js";
|
|
2
|
+
export { computeSelfTestPlanDigest, createSelfTestApp, createSelfTestAuthFlowInvoke, createSelfTestInvoke, DEFAULT_SELF_TEST_REQUEST_BUDGET_MS, isSelfTestReadOnlyOperation, PROVIDER_RUNTIME_SELF_TEST_REQUEST_BUDGET_MS_ENV, resolveSelfTestPort, SELF_TEST_AUTH_FLOW_MULTI_TURN_SKIP_REASON, SELF_TEST_AUTH_FLOW_REJECTED_SKIP_REASON, SELF_TEST_HEALTHZ_PATH, SELF_TEST_PATH, SELF_TEST_SCHEMA_VERSION, SelfTestRequestSchema, } from "./self-test.js";
|
|
3
|
+
export { resolveHealthCheckInputDateTokens, } from "./self-test-input-tokens.js";
|
|
4
|
+
export { collectSelfTestSensitiveValues, redactSelfTestText, SELF_TEST_MAX_TEXT_LENGTH, SELF_TEST_REDACTED_PLACEHOLDER, } from "./self-test-redaction.js";
|
|
5
|
+
export { DEFAULT_SELF_TEST_PORT, deriveSelfTestToken, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_ENV, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_PREVIOUS_ENV, PROVIDER_RUNTIME_SELF_TEST_PORT_ENV, resolveSelfTestMasterSecrets, verifySelfTestAuthorization, } from "./self-test-token.js";
|
|
6
|
+
export { AuthFlowRequestSchema, AuthFlowSuccessResponseSchema, ConnectionModeSchema, ErrorEnvelopeSchema, OperationConnectionSchema, OperationErrorResponseSchema, OperationRequestSchema, OperationSuccessResponseSchema, } from "./types.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type InputDateTokenCalendar = "KST" | "UTC";
|
|
2
|
+
export declare function resolveHealthCheckInputDateTokens(value: unknown, now?: Date, calendar?: InputDateTokenCalendar): unknown;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Relative
|
|
3
|
-
*
|
|
4
|
-
* so
|
|
2
|
+
* Relative date-token resolution for health-check case inputs and fixture
|
|
3
|
+
* requests. The calendar defaults to KST; callers that need UTC must opt in
|
|
4
|
+
* explicitly so UTC and KST do not silently disagree from 15:00–23:59 UTC.
|
|
5
5
|
*
|
|
6
|
-
* Supported token: `+<days>d` or `+<days>d:YYYYMMDD` (1..365 days ahead
|
|
6
|
+
* Supported token: `+<days>d` or `+<days>d:YYYYMMDD` (1..365 days ahead).
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
const date = new Date(Date.UTC(
|
|
8
|
+
const RELATIVE_DATE_TOKEN = /^\+(\d{1,3})d(?::(YYYYMMDD))?$/i;
|
|
9
|
+
function dateFromDaysAhead(daysAhead, now = new Date(), format = "YYYY-MM-DD", calendar = "KST") {
|
|
10
|
+
const calendarNow = new Date(now.getTime() + (calendar === "KST" ? 9 * 60 * 60 * 1000 : 0));
|
|
11
|
+
const date = new Date(Date.UTC(calendarNow.getUTCFullYear(), calendarNow.getUTCMonth(), calendarNow.getUTCDate() + daysAhead));
|
|
12
12
|
const isoDate = date.toISOString().slice(0, 10);
|
|
13
13
|
return format === "YYYYMMDD" ? isoDate.replace(/-/g, "") : isoDate;
|
|
14
14
|
}
|
|
15
|
-
export function resolveHealthCheckInputDateTokens(value, now = new Date()) {
|
|
15
|
+
export function resolveHealthCheckInputDateTokens(value, now = new Date(), calendar = "KST") {
|
|
16
16
|
if (typeof value === "string") {
|
|
17
|
-
const relative = value.match(
|
|
17
|
+
const relative = value.match(RELATIVE_DATE_TOKEN);
|
|
18
18
|
if (!relative)
|
|
19
19
|
return value;
|
|
20
20
|
const daysAhead = Number(relative[1]);
|
|
@@ -22,16 +22,20 @@ export function resolveHealthCheckInputDateTokens(value, now = new Date()) {
|
|
|
22
22
|
return value;
|
|
23
23
|
}
|
|
24
24
|
const format = relative[2]?.toUpperCase() === "YYYYMMDD" ? "YYYYMMDD" : "YYYY-MM-DD";
|
|
25
|
-
return
|
|
25
|
+
return dateFromDaysAhead(daysAhead, now, format, calendar);
|
|
26
26
|
}
|
|
27
27
|
if (Array.isArray(value)) {
|
|
28
|
-
|
|
28
|
+
const resolved = value.map((entry) => resolveHealthCheckInputDateTokens(entry, now, calendar));
|
|
29
|
+
return resolved.some((entry, index) => entry !== value[index]) ? resolved : value;
|
|
29
30
|
}
|
|
30
31
|
if (value && typeof value === "object") {
|
|
31
|
-
|
|
32
|
+
const resolved = Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
32
33
|
key,
|
|
33
|
-
resolveHealthCheckInputDateTokens(entry, now),
|
|
34
|
+
resolveHealthCheckInputDateTokens(entry, now, calendar),
|
|
34
35
|
]));
|
|
36
|
+
return Object.entries(resolved).some(([key, entry]) => entry !== Reflect.get(value, key))
|
|
37
|
+
? resolved
|
|
38
|
+
: value;
|
|
35
39
|
}
|
|
36
40
|
return value;
|
|
37
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProviderDefinition } from "../types";
|
|
1
|
+
import type { ProviderDefinition } from "../types.js";
|
|
2
2
|
export declare const SELF_TEST_REDACTED_PLACEHOLDER = "[REDACTED]";
|
|
3
3
|
/** Maximum length of any string echoed in a self-test response. */
|
|
4
4
|
export declare const SELF_TEST_MAX_TEXT_LENGTH = 300;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_ENV, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_PREVIOUS_ENV, } from "./self-test-token";
|
|
1
|
+
import { PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_ENV, PROVIDER_RUNTIME_SELF_TEST_MASTER_SECRET_PREVIOUS_ENV, } from "./self-test-token.js";
|
|
2
2
|
export const SELF_TEST_REDACTED_PLACEHOLDER = "[REDACTED]";
|
|
3
3
|
/** Maximum length of any string echoed in a self-test response. */
|
|
4
4
|
export const SELF_TEST_MAX_TEXT_LENGTH = 300;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import type { OperationDefinition, ProviderDefinition } from "../types";
|
|
4
|
-
import { type SelfTestMasterSecrets } from "./self-test-token";
|
|
5
|
-
import type { OperationConnection } from "./types";
|
|
3
|
+
import type { OperationDefinition, ProviderDefinition } from "../types.js";
|
|
4
|
+
import { type SelfTestMasterSecrets } from "./self-test-token.js";
|
|
5
|
+
import type { OperationConnection } from "./types.js";
|
|
6
6
|
export declare const SELF_TEST_SCHEMA_VERSION: 1;
|
|
7
7
|
export declare const SELF_TEST_PATH = "/internal/health/self-test";
|
|
8
8
|
export declare const SELF_TEST_HEALTHZ_PATH = "/healthz";
|
|
@@ -61,11 +61,53 @@ export type SelfTestOperationInvoke = (args: {
|
|
|
61
61
|
data: unknown;
|
|
62
62
|
meta?: Record<string, unknown>;
|
|
63
63
|
}>;
|
|
64
|
+
export type SelfTestAuthFlowRoute = "start" | "continue";
|
|
65
|
+
/**
|
|
66
|
+
* In-process driver for the tenant app's /auth pipeline. Self-test uses it to
|
|
67
|
+
* materialize `requiresConnection` credentials through the provider's declared
|
|
68
|
+
* auth flow — the exact path production connections take — instead of
|
|
69
|
+
* injecting raw credential inputs as connection secrets.
|
|
70
|
+
*/
|
|
71
|
+
export type SelfTestAuthFlowInvoke = (args: {
|
|
72
|
+
route: SelfTestAuthFlowRoute;
|
|
73
|
+
requestId: string;
|
|
74
|
+
flowId: string;
|
|
75
|
+
/** Stable per-credential connection id — keeps login on the probe's affinity. */
|
|
76
|
+
connectionId?: string;
|
|
77
|
+
/** The probe connection's externalRef — flows reading ctx.externalRef see the same identity. */
|
|
78
|
+
externalRef?: string;
|
|
79
|
+
input?: Record<string, unknown>;
|
|
80
|
+
context?: Record<string, unknown>;
|
|
81
|
+
}) => Promise<{
|
|
82
|
+
status: number;
|
|
83
|
+
body: unknown;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Skip reason reported when a declared auth flow does not complete in a single
|
|
87
|
+
* continue (OTP, retry loop). Cross-repo contract: the health-monitor maps
|
|
88
|
+
* this exact string to `self_test_incapable`; never vary it.
|
|
89
|
+
*/
|
|
90
|
+
export declare const SELF_TEST_AUTH_FLOW_MULTI_TURN_SKIP_REASON = "auth_flow_multi_turn";
|
|
91
|
+
/**
|
|
92
|
+
* A `retry` turn after credential submission: the flow REJECTED the
|
|
93
|
+
* configured inputs (bad password, exchange failure). Distinct from the
|
|
94
|
+
* multi-turn gap so monitoring surfaces it as a real credential outage, and
|
|
95
|
+
* memoized like multi-turn so the probe does not re-submit rejected
|
|
96
|
+
* credentials every cycle (lockout safety).
|
|
97
|
+
*/
|
|
98
|
+
export declare const SELF_TEST_AUTH_FLOW_REJECTED_SKIP_REASON = "auth_flow_rejected";
|
|
64
99
|
export interface SelfTestAppOptions {
|
|
65
100
|
/** Derived-token verification secrets; without them every self-test route 404s. */
|
|
66
101
|
secrets?: SelfTestMasterSecrets;
|
|
67
102
|
/** In-process invoke bound to the tenant-facing app's /v1 pipeline. */
|
|
68
103
|
invoke: SelfTestOperationInvoke;
|
|
104
|
+
/**
|
|
105
|
+
* In-process auth-flow driver bound to the tenant-facing app's /auth
|
|
106
|
+
* pipeline. Required for providers that declare `auth.mode: "credentials"`
|
|
107
|
+
* with a flow; without it their requiresConnection cases report a visible
|
|
108
|
+
* auth_flow_unavailable error instead of probing with raw inputs.
|
|
109
|
+
*/
|
|
110
|
+
authFlow?: SelfTestAuthFlowInvoke;
|
|
69
111
|
/** Overall request budget; defaults to env / 120s. */
|
|
70
112
|
requestBudgetMs?: number;
|
|
71
113
|
/** Env override for secret collection + budget resolution (tests). */
|
|
@@ -88,6 +130,65 @@ export declare function isSelfTestReadOnlyOperation(operation: OperationDefiniti
|
|
|
88
130
|
export declare function createSelfTestInvoke(app: {
|
|
89
131
|
request: (input: string, requestInit?: RequestInit) => Response | Promise<Response>;
|
|
90
132
|
}): SelfTestOperationInvoke;
|
|
133
|
+
/** Binds the self-test auth-flow driver to a tenant app's /auth pipeline in-process. */
|
|
134
|
+
export declare function createSelfTestAuthFlowInvoke(app: {
|
|
135
|
+
request: (input: string, requestInit?: RequestInit) => Response | Promise<Response>;
|
|
136
|
+
}): SelfTestAuthFlowInvoke;
|
|
137
|
+
/**
|
|
138
|
+
* How long a memoized multi-turn flow outcome suppresses re-driving the auth
|
|
139
|
+
* flow. Generous on purpose: a multi-turn ceremony (OTP, device approval) is a
|
|
140
|
+
* provider property that changes on the timescale of releases, not probe
|
|
141
|
+
* cycles, and every re-drive is a REAL upstream login submission. The cache is
|
|
142
|
+
* in-process, so a pod restart also clears the entry.
|
|
143
|
+
*/
|
|
144
|
+
export declare const SELF_TEST_MULTI_TURN_RETRY_AFTER_MS: number;
|
|
145
|
+
/**
|
|
146
|
+
* Age bound for POSITIVE cached credentials. Expiry modes that never produce
|
|
147
|
+
* a 401/403 (a 200 login page, an assertion failure) would otherwise replay
|
|
148
|
+
* the same stale session until pod restart — one re-login per day is the
|
|
149
|
+
* upstream-safe recovery for them.
|
|
150
|
+
*/
|
|
151
|
+
export declare const SELF_TEST_CREDENTIAL_MAX_AGE_MS: number;
|
|
152
|
+
export type SelfTestCredentialSessionEntry =
|
|
153
|
+
/** Flow-materialized credential reused across probe cycles. */
|
|
154
|
+
{
|
|
155
|
+
kind: "credential";
|
|
156
|
+
credential: Record<string, string>;
|
|
157
|
+
cachedAtMs: number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Negative entry: the flow did not complete in a single continue turn
|
|
161
|
+
* (`auth_flow_multi_turn`). Memoized so subsequent cycles report the skip
|
|
162
|
+
* WITHOUT contacting the upstream again — the first attempt already
|
|
163
|
+
* submitted real credentials (and may have triggered an OTP send).
|
|
164
|
+
*/
|
|
165
|
+
| {
|
|
166
|
+
kind: "multi_turn";
|
|
167
|
+
cachedAtMs: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Negative entry: the flow REJECTED the submitted credential inputs
|
|
171
|
+
* (`retry` turn after continue — bad password, exchange failure).
|
|
172
|
+
* Memoized so the probe does not re-submit rejected credentials every
|
|
173
|
+
* cycle; a new entry is attempted when the inputs rotate (new hash),
|
|
174
|
+
* the TTL lapses, or the process restarts.
|
|
175
|
+
*/
|
|
176
|
+
| {
|
|
177
|
+
kind: "rejected";
|
|
178
|
+
cachedAtMs: number;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* In-process cache of per-(providerId + stable hash of credentialInputs) auth
|
|
182
|
+
* flow outcomes, so consecutive probe cycles reuse the session — or the
|
|
183
|
+
* memoized multi-turn skip — instead of logging in every cycle (upstream
|
|
184
|
+
* account safety, DR-7). Credential entries are invalidated on a probe auth
|
|
185
|
+
* failure, at most once; multi-turn entries expire after
|
|
186
|
+
* `SELF_TEST_MULTI_TURN_RETRY_AFTER_MS` or on process restart. Flow ERRORS
|
|
187
|
+
* (transport/protocol failures, thrown start/continue) are deliberately NEVER
|
|
188
|
+
* cached: they are typically transient, and retrying a failed request next
|
|
189
|
+
* cycle is not a repeated login submission.
|
|
190
|
+
*/
|
|
191
|
+
export type SelfTestCredentialSessionCache = Map<string, SelfTestCredentialSessionEntry>;
|
|
91
192
|
export declare function resolveSelfTestPort(env?: Readonly<Record<string, string | undefined>>): number;
|
|
92
193
|
/**
|
|
93
194
|
* Builds the internal self-test Hono app. This app is served on a SEPARATE
|