@apifuse/provider-sdk 2.2.0-beta.1 → 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 +106 -0
- package/CHANGELOG.md +37 -0
- package/README.md +5 -1
- 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 +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 +510 -45
- 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 +1 -1
- package/dist/ceremonies/index.js +8 -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 +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 +4 -6
- package/dist/define.d.ts +8 -1
- package/dist/define.js +119 -122
- 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 -42
- package/dist/index.js +39 -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 +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 +144 -348
- 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 +2 -2
- package/dist/runtime/stealth.js +108 -212
- 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 +104 -3
- package/dist/server/self-test.js +673 -115
- package/dist/server/serve.d.ts +8 -3
- package/dist/server/serve.js +105 -59
- 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 +7 -14
- package/dist/types.d.ts +87 -1
- package/dist/user-input.d.ts +30 -0
- package/dist/user-input.js +66 -0
- package/package.json +9 -5
- package/src/auth-turn/index.ts +1 -1
- package/src/auth.ts +28 -86
- package/src/ceremonies/index.ts +24 -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 +543 -208
- package/src/contract-serialization.ts +5 -11
- package/src/contract-types.ts +2 -2
- package/src/contract.ts +12 -28
- package/src/define.ts +247 -505
- 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 +49 -42
- package/src/lint.ts +89 -159
- package/src/provider.ts +15 -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 +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 +195 -559
- 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 +162 -377
- 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 +12 -7
- package/src/server/self-test-redaction.ts +2 -2
- package/src/server/self-test.ts +857 -132
- package/src/server/serve.ts +172 -245
- 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 +19 -67
- package/src/types.ts +88 -1
- 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/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,42 +1,44 @@
|
|
|
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
|
|
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 { 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,38 +1,40 @@
|
|
|
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 * from "./
|
|
36
|
-
export
|
|
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 { 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.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, 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, 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