@apifuse/provider-sdk 2.1.0-beta.9 → 2.2.0-beta.10
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 +240 -0
- package/CHANGELOG.md +93 -0
- package/README.md +26 -10
- package/SUBMISSION.md +11 -12
- 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 +36 -0
- 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 +53 -70
- package/bin/apifuse-submit-check.ts +2177 -353
- 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/auth-turn.v1.schema.json +89 -0
- package/dist/auth-turn/fixtures/invalid/empty-kind.json +4 -0
- package/dist/auth-turn/fixtures/invalid/expires-at-not-string.json +5 -0
- package/dist/auth-turn/fixtures/invalid/missing-kind.json +3 -0
- package/dist/auth-turn/fixtures/invalid/missing-turn-id.json +3 -0
- package/dist/auth-turn/fixtures/invalid/timing-unknown-field.json +7 -0
- package/dist/auth-turn/fixtures/invalid/turn-id-snake-case.json +4 -0
- package/dist/auth-turn/fixtures/invalid/unknown-top-level-field.json +5 -0
- package/dist/auth-turn/fixtures/valid/abort.json +8 -0
- package/dist/auth-turn/fixtures/valid/challenge.json +17 -0
- package/dist/auth-turn/fixtures/valid/complete.json +13 -0
- package/dist/auth-turn/fixtures/valid/form.json +14 -0
- package/dist/auth-turn/fixtures/valid/message.json +13 -0
- package/dist/auth-turn/fixtures/valid/multi_choice.json +15 -0
- package/dist/auth-turn/fixtures/valid/pending.json +5 -0
- package/dist/auth-turn/fixtures/valid/poll.json +9 -0
- package/dist/auth-turn/fixtures/valid/redirect.json +16 -0
- package/dist/auth-turn/fixtures/valid/retry.json +8 -0
- package/dist/auth-turn/fixtures/valid/unknown-kind.json +7 -0
- package/dist/auth-turn/index.d.ts +195 -0
- package/dist/auth-turn/index.js +133 -0
- package/dist/auth.d.ts +76 -0
- package/dist/auth.js +427 -0
- package/dist/ceremonies/index.d.ts +1 -1
- package/dist/ceremonies/index.js +14 -48
- 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 +47 -33
- package/dist/cli/prompt-assets.d.ts +80 -0
- package/dist/cli/prompt-assets.js +743 -0
- package/dist/cli/templates/provider/.agents/skills/fixtures-and-recording/SKILL.md.tpl +58 -0
- package/dist/cli/templates/provider/.agents/skills/health-checks-and-fail-closed/SKILL.md.tpl +65 -0
- package/dist/cli/templates/provider/.agents/skills/normalization-standards/SKILL.md.tpl +57 -0
- package/dist/cli/templates/provider/.agents/skills/pagination-and-counts/SKILL.md.tpl +52 -0
- package/dist/cli/templates/provider/.agents/skills/upstream-contract-verification/SKILL.md.tpl +45 -0
- package/dist/cli/templates/provider/.agents/skills/upstream-notes/README.md.tpl +13 -0
- package/dist/cli/templates/provider/.dockerignore.tpl +22 -0
- package/dist/cli/templates/provider/.gitignore.tpl +22 -0
- package/dist/cli/templates/provider/AGENTS.md.tpl +96 -0
- package/dist/cli/templates/provider/Dockerfile.tpl +7 -0
- package/dist/cli/templates/provider/README.md.tpl +163 -0
- package/dist/cli/templates/provider/dev.ts.tpl +5 -0
- package/dist/cli/templates/provider/domain/README.md.tpl +3 -0
- package/dist/cli/templates/provider/index.test.ts.tpl +13 -0
- package/dist/cli/templates/provider/index.ts.tpl +15 -0
- package/dist/cli/templates/provider/mappers/README.md.tpl +3 -0
- package/dist/cli/templates/provider/meta.ts.tpl +7 -0
- package/dist/cli/templates/provider/operations/index.ts.tpl +5 -0
- package/dist/cli/templates/provider/operations/ping.ts.tpl +24 -0
- package/dist/cli/templates/provider/schemas/ping.ts.tpl +24 -0
- package/dist/cli/templates/provider/start.ts.tpl +5 -0
- package/dist/cli/templates/provider/upstream/README.md.tpl +3 -0
- package/dist/config/loader.d.ts +149 -8
- package/dist/config/loader.js +378 -89
- 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 +5 -6
- package/dist/define.d.ts +13 -1
- package/dist/define.js +245 -178
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +1 -1
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +48 -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 +44 -41
- package/dist/index.js +39 -36
- package/dist/lint.d.ts +1 -0
- package/dist/lint.js +35 -15
- package/dist/provider.d.ts +11 -9
- package/dist/provider.js +9 -8
- 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 +4 -2
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.js +214 -25
- 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 +15 -3
- package/dist/runtime/http.d.ts +2 -2
- package/dist/runtime/http.js +160 -344
- 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 +56 -19
- 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 +9 -7
- package/dist/runtime/proxy-nodemaven.d.ts +35 -0
- package/dist/runtime/proxy-nodemaven.js +128 -0
- package/dist/runtime/proxy-retry-policy.d.ts +40 -0
- package/dist/runtime/proxy-retry-policy.js +326 -0
- package/dist/runtime/proxy-telemetry.d.ts +2 -1
- package/dist/runtime/proxy-telemetry.js +55 -52
- 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/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 +15 -4
- package/dist/runtime/stealth.d.ts +7 -4
- package/dist/runtime/stealth.js +257 -215
- 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 -3
- package/dist/server/index.js +6 -2
- package/dist/server/self-test-input-tokens.d.ts +1 -0
- package/dist/server/self-test-input-tokens.js +37 -0
- package/dist/server/self-test-redaction.d.ts +20 -0
- package/dist/server/self-test-redaction.js +70 -0
- package/dist/server/self-test-token.d.ts +30 -0
- package/dist/server/self-test-token.js +50 -0
- package/dist/server/self-test.d.ts +199 -0
- package/dist/server/self-test.js +1113 -0
- package/dist/server/serve.d.ts +14 -3
- package/dist/server/serve.js +135 -64
- package/dist/server/types.d.ts +10 -9
- package/dist/server/types.js +3 -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 +12 -15
- package/dist/types.d.ts +237 -1
- package/dist/user-input.d.ts +30 -0
- package/dist/user-input.js +66 -0
- package/package.json +16 -5
- package/src/auth-turn/auth-turn.v1.schema.json +89 -0
- package/src/auth-turn/fixtures/invalid/empty-kind.json +4 -0
- package/src/auth-turn/fixtures/invalid/expires-at-not-string.json +5 -0
- package/src/auth-turn/fixtures/invalid/missing-kind.json +3 -0
- package/src/auth-turn/fixtures/invalid/missing-turn-id.json +3 -0
- package/src/auth-turn/fixtures/invalid/timing-unknown-field.json +7 -0
- package/src/auth-turn/fixtures/invalid/turn-id-snake-case.json +4 -0
- package/src/auth-turn/fixtures/invalid/unknown-top-level-field.json +5 -0
- package/src/auth-turn/fixtures/valid/abort.json +8 -0
- package/src/auth-turn/fixtures/valid/challenge.json +17 -0
- package/src/auth-turn/fixtures/valid/complete.json +13 -0
- package/src/auth-turn/fixtures/valid/form.json +14 -0
- package/src/auth-turn/fixtures/valid/message.json +13 -0
- package/src/auth-turn/fixtures/valid/multi_choice.json +15 -0
- package/src/auth-turn/fixtures/valid/pending.json +5 -0
- package/src/auth-turn/fixtures/valid/poll.json +9 -0
- package/src/auth-turn/fixtures/valid/redirect.json +16 -0
- package/src/auth-turn/fixtures/valid/retry.json +8 -0
- package/src/auth-turn/fixtures/valid/unknown-kind.json +7 -0
- package/src/auth-turn/index.ts +177 -0
- package/src/auth.ts +728 -0
- package/src/ceremonies/index.ts +33 -121
- package/src/cli/commands.ts +10 -0
- package/src/cli/create.ts +69 -99
- package/src/cli/prompt-assets.ts +865 -0
- package/src/cli/templates/provider/.agents/skills/fixtures-and-recording/SKILL.md.tpl +58 -0
- package/src/cli/templates/provider/.agents/skills/health-checks-and-fail-closed/SKILL.md.tpl +65 -0
- package/src/cli/templates/provider/.agents/skills/normalization-standards/SKILL.md.tpl +57 -0
- package/src/cli/templates/provider/.agents/skills/pagination-and-counts/SKILL.md.tpl +52 -0
- package/src/cli/templates/provider/.agents/skills/upstream-contract-verification/SKILL.md.tpl +45 -0
- package/src/cli/templates/provider/.agents/skills/upstream-notes/README.md.tpl +13 -0
- package/src/cli/templates/provider/AGENTS.md.tpl +96 -0
- package/src/cli/templates/provider/README.md.tpl +7 -4
- package/src/config/loader.ts +543 -208
- package/src/contract-serialization.ts +5 -11
- package/src/contract-types.ts +2 -2
- package/src/contract.ts +13 -28
- package/src/define.ts +397 -528
- package/src/dev.ts +4 -9
- package/src/errors.ts +58 -5
- 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 +64 -41
- package/src/lint.ts +122 -159
- package/src/provider.ts +40 -9
- package/src/public-schema-field-lint.ts +7 -33
- package/src/recipes/gov-api.ts +2 -5
- package/src/runtime/auth-flow.ts +6 -6
- package/src/runtime/browser.ts +320 -151
- 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 +23 -20
- package/src/runtime/http.ts +216 -539
- package/src/runtime/insights.ts +15 -53
- package/src/runtime/instrumentation.ts +78 -65
- 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 +29 -42
- package/src/runtime/proxy-nodemaven.ts +178 -0
- package/src/runtime/proxy-retry-policy.ts +469 -0
- package/src/runtime/proxy-telemetry.ts +79 -77
- package/src/runtime/redis.ts +4 -12
- package/src/runtime/request-options.ts +4 -13
- package/src/runtime/secrets.ts +64 -0
- package/src/runtime/state.ts +41 -110
- package/src/runtime/stealth.ts +331 -369
- 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 +44 -3
- package/src/server/self-test-input-tokens.ts +46 -0
- package/src/server/self-test-redaction.ts +97 -0
- package/src/server/self-test-token.ts +70 -0
- package/src/server/self-test.ts +1450 -0
- package/src/server/serve.ts +206 -216
- package/src/server/types.ts +7 -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 +24 -64
- package/src/types.ts +274 -1
- package/src/user-input.ts +118 -0
package/dist/dev.d.ts
CHANGED
package/dist/dev.js
CHANGED
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProviderErrorCategory } from "./observability";
|
|
1
|
+
import type { ProviderErrorCategory } from "./observability.js";
|
|
2
2
|
export type ProviderErrorOptions = {
|
|
3
3
|
fix?: string;
|
|
4
4
|
code?: string;
|
|
@@ -39,6 +39,9 @@ export declare class TransportError extends ProviderError {
|
|
|
39
39
|
readonly upstreamStatus?: number;
|
|
40
40
|
constructor(message: string, options?: TransportErrorOptions);
|
|
41
41
|
}
|
|
42
|
+
export declare function isProviderError(value: unknown): value is ProviderError;
|
|
43
|
+
export declare function isSessionExpiredError(value: unknown): value is SessionExpiredError;
|
|
44
|
+
export declare function isTransportError(value: unknown): value is TransportError;
|
|
42
45
|
export declare class ProviderSecretError extends ProviderError {
|
|
43
46
|
constructor(message: string, options?: ProviderErrorOptions);
|
|
44
47
|
}
|
package/dist/errors.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
// Versioned, cross-realm brands. `Symbol.for` resolves to the same symbol in
|
|
2
|
+
// any copy/entrypoint of this SDK major version, so an error created by a
|
|
3
|
+
// duplicate module instance (e.g. the packaged CLI's src/* server vs a
|
|
4
|
+
// provider's dist/* import) still carries a brand the server can recognize even
|
|
5
|
+
// though `instanceof` splits across the two constructors. The `@1` suffix lets a
|
|
6
|
+
// future breaking change to this contract mint a distinct key.
|
|
7
|
+
const PROVIDER_ERROR_BRAND = Symbol.for("@apifuse/provider-sdk/error-brand@1");
|
|
8
|
+
const PROVIDER_ERROR_BRAND_VALUE = 1;
|
|
9
|
+
const SESSION_EXPIRED_BRAND = Symbol.for("@apifuse/provider-sdk/error-kind/session-expired@1");
|
|
10
|
+
const TRANSPORT_BRAND = Symbol.for("@apifuse/provider-sdk/error-kind/transport@1");
|
|
11
|
+
// Defines a non-enumerable, non-writable, non-configurable own data property.
|
|
12
|
+
// Immutable + own means a guard can trust it via a single descriptor read
|
|
13
|
+
// without invoking attacker-controlled getters or accepting inherited brands.
|
|
14
|
+
function defineErrorBrand(target, brand, value) {
|
|
15
|
+
Object.defineProperty(target, brand, {
|
|
16
|
+
value,
|
|
17
|
+
enumerable: false,
|
|
18
|
+
writable: false,
|
|
19
|
+
configurable: false,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// Recognizes an own data-property brand with the expected value. Rejects
|
|
23
|
+
// missing brands (unbranded lookalikes), accessor brands (no own `value`
|
|
24
|
+
// slot — the getter is never called), and inherited brands (own-descriptor
|
|
25
|
+
// lookup returns undefined on the child).
|
|
26
|
+
function hasOwnBrand(value, brand, expected) {
|
|
27
|
+
if (value === null || (typeof value !== "object" && typeof value !== "function")) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, brand);
|
|
31
|
+
return (descriptor !== undefined && Object.hasOwn(descriptor, "value") && descriptor.value === expected);
|
|
32
|
+
}
|
|
1
33
|
export class ProviderError extends Error {
|
|
2
34
|
options;
|
|
3
35
|
constructor(message, options) {
|
|
@@ -7,6 +39,7 @@ export class ProviderError extends Error {
|
|
|
7
39
|
if (options?.cause) {
|
|
8
40
|
this.cause = options.cause;
|
|
9
41
|
}
|
|
42
|
+
defineErrorBrand(this, PROVIDER_ERROR_BRAND, PROVIDER_ERROR_BRAND_VALUE);
|
|
10
43
|
}
|
|
11
44
|
get fix() {
|
|
12
45
|
return this.options?.fix;
|
|
@@ -39,6 +72,7 @@ export class SessionExpiredError extends AuthError {
|
|
|
39
72
|
...options,
|
|
40
73
|
});
|
|
41
74
|
this.name = "SessionExpiredError";
|
|
75
|
+
defineErrorBrand(this, SESSION_EXPIRED_BRAND, true);
|
|
42
76
|
}
|
|
43
77
|
}
|
|
44
78
|
export class ValidationError extends ProviderError {
|
|
@@ -57,8 +91,22 @@ export class TransportError extends ProviderError {
|
|
|
57
91
|
this.name = "TransportError";
|
|
58
92
|
this.status = options?.status;
|
|
59
93
|
this.upstreamStatus = options?.upstreamStatus ?? options?.status;
|
|
94
|
+
defineErrorBrand(this, TRANSPORT_BRAND, true);
|
|
60
95
|
}
|
|
61
96
|
}
|
|
97
|
+
// Cross-module type guards. Prefer these over `instanceof` at any boundary that
|
|
98
|
+
// may receive an error from a different copy/entrypoint of the SDK (see the HTTP
|
|
99
|
+
// server error boundary). They recognize branded errors regardless of which
|
|
100
|
+
// module instance constructed them, while rejecting unbranded lookalikes.
|
|
101
|
+
export function isProviderError(value) {
|
|
102
|
+
return hasOwnBrand(value, PROVIDER_ERROR_BRAND, PROVIDER_ERROR_BRAND_VALUE);
|
|
103
|
+
}
|
|
104
|
+
export function isSessionExpiredError(value) {
|
|
105
|
+
return isProviderError(value) && hasOwnBrand(value, SESSION_EXPIRED_BRAND, true);
|
|
106
|
+
}
|
|
107
|
+
export function isTransportError(value) {
|
|
108
|
+
return isProviderError(value) && hasOwnBrand(value, TRANSPORT_BRAND, true);
|
|
109
|
+
}
|
|
62
110
|
export class ProviderSecretError extends ProviderError {
|
|
63
111
|
constructor(message, options) {
|
|
64
112
|
super(message, { code: "provider_secret_error", ...options });
|
package/dist/i18n/catalog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AuthTurn } from "../types";
|
|
2
|
-
import { type ProviderLocale, type ProviderLocaleCatalog, type ProviderLocaleKey, type ProviderLocaleValue } from "./keys";
|
|
1
|
+
import type { AuthTurn } from "../types.js";
|
|
2
|
+
import { type ProviderLocale, type ProviderLocaleCatalog, type ProviderLocaleKey, type ProviderLocaleValue } from "./keys.js";
|
|
3
3
|
export type ProviderLocaleCatalogMap = Record<ProviderLocale, ProviderLocaleCatalog>;
|
|
4
4
|
export interface LoadProviderLocaleCatalogsOptions {
|
|
5
5
|
providerDir: string;
|
package/dist/i18n/catalog.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { getProviderLocalePath, isProviderLocaleValue, providerLocaleKey, } from "./keys";
|
|
3
|
+
import { getProviderLocalePath, isProviderLocaleValue, providerLocaleKey, } from "./keys.js";
|
|
4
4
|
export function loadProviderLocaleCatalogs(options) {
|
|
5
5
|
const catalogs = {};
|
|
6
6
|
for (const locale of options.locales) {
|
|
@@ -26,9 +26,7 @@ function isStringRecord(value) {
|
|
|
26
26
|
function localizeAuthInputSchema(expectedInput, options) {
|
|
27
27
|
if (!expectedInput)
|
|
28
28
|
return undefined;
|
|
29
|
-
const schema = isRecord(expectedInput.schema)
|
|
30
|
-
? expectedInput.schema
|
|
31
|
-
: expectedInput;
|
|
29
|
+
const schema = isRecord(expectedInput.schema) ? expectedInput.schema : expectedInput;
|
|
32
30
|
const localizedSchema = localizeAuthSchemaObject(schema, options);
|
|
33
31
|
if (localizedSchema === schema)
|
|
34
32
|
return undefined;
|
|
@@ -40,9 +38,7 @@ function isRecord(value) {
|
|
|
40
38
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
41
39
|
}
|
|
42
40
|
function localizeAuthSchemaObject(schema, options) {
|
|
43
|
-
const properties = isRecord(schema.properties)
|
|
44
|
-
? schema.properties
|
|
45
|
-
: undefined;
|
|
41
|
+
const properties = isRecord(schema.properties) ? schema.properties : undefined;
|
|
46
42
|
if (!properties)
|
|
47
43
|
return schema;
|
|
48
44
|
let changed = false;
|
|
@@ -50,9 +46,7 @@ function localizeAuthSchemaObject(schema, options) {
|
|
|
50
46
|
if (!isRecord(property))
|
|
51
47
|
return [fieldName, property];
|
|
52
48
|
const nameKey = typeof property.nameKey === "string" ? property.nameKey : undefined;
|
|
53
|
-
const descriptionKey = typeof property.descriptionKey === "string"
|
|
54
|
-
? property.descriptionKey
|
|
55
|
-
: undefined;
|
|
49
|
+
const descriptionKey = typeof property.descriptionKey === "string" ? property.descriptionKey : undefined;
|
|
56
50
|
const title = nameKey
|
|
57
51
|
? asStringValue(resolveProviderLocaleValue(options.catalogs, nameKey, options.locale, options.fallbackLocale))
|
|
58
52
|
: undefined;
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./catalog";
|
|
2
|
-
export * from "./keys";
|
|
1
|
+
export * from "./catalog.js";
|
|
2
|
+
export * from "./keys.js";
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./catalog";
|
|
2
|
-
export * from "./keys";
|
|
1
|
+
export * from "./catalog.js";
|
|
2
|
+
export * from "./keys.js";
|
package/dist/i18n/keys.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ProviderLocaleKey } from "../types";
|
|
2
|
-
export type { ProviderLocale, ProviderLocaleKey } from "../types";
|
|
1
|
+
import type { ProviderLocaleKey } from "../types.js";
|
|
2
|
+
export type { ProviderLocale, ProviderLocaleKey } from "../types.js";
|
|
3
3
|
export declare function providerLocaleKey(key: string): ProviderLocaleKey;
|
|
4
4
|
export declare function isProviderLocaleKey(value: unknown): value is ProviderLocaleKey;
|
|
5
5
|
export declare function assertProviderLocaleKey(value: unknown): asserts value is ProviderLocaleKey;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export type
|
|
8
|
-
export {
|
|
9
|
-
export
|
|
10
|
-
export * from "./
|
|
11
|
-
export
|
|
12
|
-
export * from "./
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export {
|
|
17
|
-
export
|
|
18
|
-
export {
|
|
19
|
-
export { type
|
|
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
|
|
37
|
-
export {
|
|
38
|
-
export * from "./
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
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 { assertRequiredSecretsPresent, listMissingRequiredSecrets, MISSING_SECRET_CODE, } from "./runtime/secrets.js";
|
|
31
|
+
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
32
|
+
export { createStealthClient } from "./runtime/stealth.js";
|
|
33
|
+
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
34
|
+
export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace.js";
|
|
35
|
+
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";
|
|
36
|
+
export { createServerApp, type ServeOptions, serve } from "./server/index.js";
|
|
37
|
+
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
38
|
+
export * from "./stream.js";
|
|
39
|
+
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";
|
|
40
|
+
export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
|
|
41
|
+
export * from "./utils/date.js";
|
|
42
|
+
export * from "./utils/parse.js";
|
|
43
|
+
export * from "./utils/text.js";
|
|
44
|
+
export * from "./utils/transform.js";
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
// @apifuse/provider-sdk
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
9
|
-
export * from "./
|
|
10
|
-
export
|
|
11
|
-
export * from "./
|
|
12
|
-
export
|
|
13
|
-
export
|
|
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 * from "./
|
|
36
|
-
export
|
|
37
|
-
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 { assertRequiredSecretsPresent, listMissingRequiredSecrets, MISSING_SECRET_CODE, } from "./runtime/secrets.js";
|
|
28
|
+
export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
|
|
29
|
+
export { createStealthClient } from "./runtime/stealth.js";
|
|
30
|
+
export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
|
|
31
|
+
export { createTraceContext, } from "./runtime/trace.js";
|
|
32
|
+
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";
|
|
33
|
+
export { createServerApp, serve } from "./server/index.js";
|
|
34
|
+
export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
|
|
35
|
+
export * from "./stream.js";
|
|
36
|
+
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";
|
|
37
|
+
export * from "./utils/date.js";
|
|
38
|
+
export * from "./utils/parse.js";
|
|
39
|
+
export * from "./utils/text.js";
|
|
40
|
+
export * from "./utils/transform.js";
|
package/dist/lint.d.ts
CHANGED
package/dist/lint.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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
|
+
const AUTH_OPERATION_ID_PATTERN = /^(?:auth[-_])?(?:login|exchange|continue|refresh|callback)(?:[-_]|$)/i;
|
|
3
4
|
function lintAllowedHosts(providerId, allowedHosts) {
|
|
4
5
|
const prefix = providerId ? `Provider "${providerId}"` : "Provider";
|
|
5
6
|
if (!allowedHosts) {
|
|
@@ -49,6 +50,9 @@ function lintReviewed(providerId, reviewed) {
|
|
|
49
50
|
},
|
|
50
51
|
];
|
|
51
52
|
}
|
|
53
|
+
function isProviderAuthLike(value) {
|
|
54
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
55
|
+
}
|
|
52
56
|
function hasReusableSecretKeys(keys) {
|
|
53
57
|
if (!keys) {
|
|
54
58
|
return false;
|
|
@@ -99,6 +103,14 @@ function lintAuthModel(provider) {
|
|
|
99
103
|
message: `${providerLabel} must define auth.flow.continue for ${authMode} auth mode.`,
|
|
100
104
|
});
|
|
101
105
|
}
|
|
106
|
+
if (isProviderAuthLike(provider.auth) && "exchange" in provider.auth) {
|
|
107
|
+
diagnostics.push({
|
|
108
|
+
rule: "auth-exchange-unsupported",
|
|
109
|
+
level: "error",
|
|
110
|
+
field: "auth.exchange",
|
|
111
|
+
message: `${providerLabel} must not define auth.exchange. The Provider SDK has one auth interface: auth.flow. Gateway only calls auth.flow.start/continue/poll/abort/refresh and persists complete turn data.credential as-is; put login/token/session exchange inside auth.flow.continue.`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
102
114
|
if (authMode === "credentials" && credentialKeys.length === 0) {
|
|
103
115
|
diagnostics.push({
|
|
104
116
|
rule: "credential-keys-required-when-credentials-mode",
|
|
@@ -108,8 +120,7 @@ function lintAuthModel(provider) {
|
|
|
108
120
|
});
|
|
109
121
|
}
|
|
110
122
|
if (hasReusableSecretKeys(credentialKeys) &&
|
|
111
|
-
(!provider.credential?.storesReusableSecret ||
|
|
112
|
-
!provider.credential.justification)) {
|
|
123
|
+
(!provider.credential?.storesReusableSecret || !provider.credential.justification)) {
|
|
113
124
|
diagnostics.push({
|
|
114
125
|
rule: "credential-reusable-secret",
|
|
115
126
|
level: "error",
|
|
@@ -119,8 +130,7 @@ function lintAuthModel(provider) {
|
|
|
119
130
|
}
|
|
120
131
|
if (typeof provider.auth?.flow?.refresh === "function" &&
|
|
121
132
|
hasReusableReloginSecretKeys(credentialKeys) &&
|
|
122
|
-
(!provider.credential?.storesReusableSecret ||
|
|
123
|
-
!provider.credential.justification)) {
|
|
133
|
+
(!provider.credential?.storesReusableSecret || !provider.credential.justification)) {
|
|
124
134
|
diagnostics.push({
|
|
125
135
|
rule: "auth-refresh-reusable-secret",
|
|
126
136
|
level: "error",
|
|
@@ -137,8 +147,7 @@ function lintAuthModel(provider) {
|
|
|
137
147
|
});
|
|
138
148
|
}
|
|
139
149
|
const authFlowSource = getAuthFlowSource(provider);
|
|
140
|
-
if (authFlowSource.includes("ctx.context") &&
|
|
141
|
-
(provider.context?.keys?.length ?? 0) === 0) {
|
|
150
|
+
if (authFlowSource.includes("ctx.context") && (provider.context?.keys?.length ?? 0) === 0) {
|
|
142
151
|
diagnostics.push({
|
|
143
152
|
rule: "context-keys-required",
|
|
144
153
|
level: "warn",
|
|
@@ -423,8 +432,7 @@ function isComplexSchema(schema, seen = new Set()) {
|
|
|
423
432
|
const childChildren = getChildSchemas(child);
|
|
424
433
|
return childChildren.length > 0;
|
|
425
434
|
});
|
|
426
|
-
return
|
|
427
|
-
children.some(({ schema: child }) => isComplexSchema(child, seen)));
|
|
435
|
+
return hasNestedComposite || children.some(({ schema: child }) => isComplexSchema(child, seen));
|
|
428
436
|
}
|
|
429
437
|
function hasBidirectionalFixtures(fixtures) {
|
|
430
438
|
if (!fixtures || typeof fixtures !== "object") {
|
|
@@ -436,9 +444,7 @@ function getOperationSource(operation) {
|
|
|
436
444
|
if (operation.source) {
|
|
437
445
|
return operation.source;
|
|
438
446
|
}
|
|
439
|
-
return typeof operation.handler === "function"
|
|
440
|
-
? operation.handler.toString()
|
|
441
|
-
: "";
|
|
447
|
+
return typeof operation.handler === "function" ? operation.handler.toString() : "";
|
|
442
448
|
}
|
|
443
449
|
function lintStealthTransportUsage(provider) {
|
|
444
450
|
if (provider.stealth || !provider.operations) {
|
|
@@ -609,8 +615,7 @@ export function lintOperation(op) {
|
|
|
609
615
|
message: "Operation whenToUse must use whenToUseKeys instead of raw static prose.",
|
|
610
616
|
});
|
|
611
617
|
}
|
|
612
|
-
if ((op.whenNotToUse?.length ?? 0) > 0 &&
|
|
613
|
-
!(op.whenNotToUseKeys?.length ?? 0)) {
|
|
618
|
+
if ((op.whenNotToUse?.length ?? 0) > 0 && !(op.whenNotToUseKeys?.length ?? 0)) {
|
|
614
619
|
diagnostics.push({
|
|
615
620
|
rule: "operation-when-not-to-use-raw-prose",
|
|
616
621
|
level: "error",
|
|
@@ -673,6 +678,21 @@ export function lintProvider(provider, options = {}) {
|
|
|
673
678
|
...lintPlaywrightDirectImports(provider),
|
|
674
679
|
...lintSelfHostedBrowserPatterns(provider, options),
|
|
675
680
|
];
|
|
681
|
+
if (provider.operations) {
|
|
682
|
+
const authMode = provider.auth?.mode;
|
|
683
|
+
if (authMode === "credentials" || authMode === "oauth2") {
|
|
684
|
+
for (const operationKey of Object.keys(provider.operations)) {
|
|
685
|
+
if (AUTH_OPERATION_ID_PATTERN.test(operationKey)) {
|
|
686
|
+
diagnostics.push({
|
|
687
|
+
rule: "auth-operation-unsupported",
|
|
688
|
+
level: "error",
|
|
689
|
+
field: `operations.${operationKey}`,
|
|
690
|
+
message: `Provider "${provider.id ?? "unknown"}" operation "${operationKey}" looks like a login/token/session exchange endpoint. Authenticated providers must expose login through the single auth.flow interface because Gateway persists only auth.flow complete turn data.credential as the connection credential. Move this logic into auth.flow.continue instead of a provider operation.`,
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
676
696
|
if (!provider.operations) {
|
|
677
697
|
return diagnostics;
|
|
678
698
|
}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
9
|
-
export {
|
|
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,8 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
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,5 +1,6 @@
|
|
|
1
|
-
import { ContextAccessError } from "../errors";
|
|
2
|
-
import {
|
|
1
|
+
import { ContextAccessError } from "../errors.js";
|
|
2
|
+
import { createAuthFlowHelpers } from "../auth.js";
|
|
3
|
+
import { createUnsupportedSttClient } from "./stt.js";
|
|
3
4
|
function normalizeAllowedKeys(allowedKeys) {
|
|
4
5
|
return new Set(allowedKeys.filter((key) => key.trim().length > 0));
|
|
5
6
|
}
|
|
@@ -40,5 +41,6 @@ export function createFlowContext(options) {
|
|
|
40
41
|
env: options.env,
|
|
41
42
|
context: createScratchpad(options.allowedKeys, options.initialContext),
|
|
42
43
|
stt: options.stt ?? createUnsupportedSttClient(),
|
|
44
|
+
auth: createAuthFlowHelpers(),
|
|
43
45
|
};
|
|
44
46
|
}
|
|
@@ -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[];
|