@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.
Files changed (263) hide show
  1. package/AUTHORING.md +240 -0
  2. package/CHANGELOG.md +93 -0
  3. package/README.md +26 -10
  4. package/SUBMISSION.md +11 -12
  5. package/bin/apifuse-check.ts +44 -59
  6. package/bin/apifuse-create.ts +1 -1
  7. package/bin/apifuse-dev.ts +27 -52
  8. package/bin/apifuse-pack-check.ts +36 -0
  9. package/bin/apifuse-pack-smoke.ts +22 -81
  10. package/bin/apifuse-pack-types.ts +266 -0
  11. package/bin/apifuse-perf.ts +45 -127
  12. package/bin/apifuse-record.ts +53 -70
  13. package/bin/apifuse-submit-check.ts +2177 -353
  14. package/bin/apifuse-sync-assets.ts +117 -0
  15. package/bin/apifuse.ts +1 -1
  16. package/bin/submit-check-delimited-text.ts +50 -0
  17. package/bin/submit-check-xml-semantics.ts +204 -0
  18. package/bin/submit-check-xml.ts +134 -0
  19. package/dist/auth-turn/auth-turn.v1.schema.json +89 -0
  20. package/dist/auth-turn/fixtures/invalid/empty-kind.json +4 -0
  21. package/dist/auth-turn/fixtures/invalid/expires-at-not-string.json +5 -0
  22. package/dist/auth-turn/fixtures/invalid/missing-kind.json +3 -0
  23. package/dist/auth-turn/fixtures/invalid/missing-turn-id.json +3 -0
  24. package/dist/auth-turn/fixtures/invalid/timing-unknown-field.json +7 -0
  25. package/dist/auth-turn/fixtures/invalid/turn-id-snake-case.json +4 -0
  26. package/dist/auth-turn/fixtures/invalid/unknown-top-level-field.json +5 -0
  27. package/dist/auth-turn/fixtures/valid/abort.json +8 -0
  28. package/dist/auth-turn/fixtures/valid/challenge.json +17 -0
  29. package/dist/auth-turn/fixtures/valid/complete.json +13 -0
  30. package/dist/auth-turn/fixtures/valid/form.json +14 -0
  31. package/dist/auth-turn/fixtures/valid/message.json +13 -0
  32. package/dist/auth-turn/fixtures/valid/multi_choice.json +15 -0
  33. package/dist/auth-turn/fixtures/valid/pending.json +5 -0
  34. package/dist/auth-turn/fixtures/valid/poll.json +9 -0
  35. package/dist/auth-turn/fixtures/valid/redirect.json +16 -0
  36. package/dist/auth-turn/fixtures/valid/retry.json +8 -0
  37. package/dist/auth-turn/fixtures/valid/unknown-kind.json +7 -0
  38. package/dist/auth-turn/index.d.ts +195 -0
  39. package/dist/auth-turn/index.js +133 -0
  40. package/dist/auth.d.ts +76 -0
  41. package/dist/auth.js +427 -0
  42. package/dist/ceremonies/index.d.ts +1 -1
  43. package/dist/ceremonies/index.js +14 -48
  44. package/dist/cli/commands.d.ts +1 -1
  45. package/dist/cli/commands.js +8 -0
  46. package/dist/cli/create.d.ts +3 -0
  47. package/dist/cli/create.js +47 -33
  48. package/dist/cli/prompt-assets.d.ts +80 -0
  49. package/dist/cli/prompt-assets.js +743 -0
  50. package/dist/cli/templates/provider/.agents/skills/fixtures-and-recording/SKILL.md.tpl +58 -0
  51. package/dist/cli/templates/provider/.agents/skills/health-checks-and-fail-closed/SKILL.md.tpl +65 -0
  52. package/dist/cli/templates/provider/.agents/skills/normalization-standards/SKILL.md.tpl +57 -0
  53. package/dist/cli/templates/provider/.agents/skills/pagination-and-counts/SKILL.md.tpl +52 -0
  54. package/dist/cli/templates/provider/.agents/skills/upstream-contract-verification/SKILL.md.tpl +45 -0
  55. package/dist/cli/templates/provider/.agents/skills/upstream-notes/README.md.tpl +13 -0
  56. package/dist/cli/templates/provider/.dockerignore.tpl +22 -0
  57. package/dist/cli/templates/provider/.gitignore.tpl +22 -0
  58. package/dist/cli/templates/provider/AGENTS.md.tpl +96 -0
  59. package/dist/cli/templates/provider/Dockerfile.tpl +7 -0
  60. package/dist/cli/templates/provider/README.md.tpl +163 -0
  61. package/dist/cli/templates/provider/dev.ts.tpl +5 -0
  62. package/dist/cli/templates/provider/domain/README.md.tpl +3 -0
  63. package/dist/cli/templates/provider/index.test.ts.tpl +13 -0
  64. package/dist/cli/templates/provider/index.ts.tpl +15 -0
  65. package/dist/cli/templates/provider/mappers/README.md.tpl +3 -0
  66. package/dist/cli/templates/provider/meta.ts.tpl +7 -0
  67. package/dist/cli/templates/provider/operations/index.ts.tpl +5 -0
  68. package/dist/cli/templates/provider/operations/ping.ts.tpl +24 -0
  69. package/dist/cli/templates/provider/schemas/ping.ts.tpl +24 -0
  70. package/dist/cli/templates/provider/start.ts.tpl +5 -0
  71. package/dist/cli/templates/provider/upstream/README.md.tpl +3 -0
  72. package/dist/config/loader.d.ts +149 -8
  73. package/dist/config/loader.js +378 -89
  74. package/dist/contract-serialization.d.ts +2 -2
  75. package/dist/contract-serialization.js +3 -6
  76. package/dist/contract-types.d.ts +2 -2
  77. package/dist/contract.d.ts +3 -3
  78. package/dist/contract.js +5 -6
  79. package/dist/define.d.ts +13 -1
  80. package/dist/define.js +245 -178
  81. package/dist/dev.d.ts +1 -1
  82. package/dist/dev.js +1 -1
  83. package/dist/errors.d.ts +4 -1
  84. package/dist/errors.js +48 -0
  85. package/dist/i18n/catalog.d.ts +2 -2
  86. package/dist/i18n/catalog.js +4 -10
  87. package/dist/i18n/index.d.ts +2 -2
  88. package/dist/i18n/index.js +2 -2
  89. package/dist/i18n/keys.d.ts +2 -2
  90. package/dist/index.d.ts +44 -41
  91. package/dist/index.js +39 -36
  92. package/dist/lint.d.ts +1 -0
  93. package/dist/lint.js +35 -15
  94. package/dist/provider.d.ts +11 -9
  95. package/dist/provider.js +9 -8
  96. package/dist/public-schema-field-lint.d.ts +1 -1
  97. package/dist/recipes/gov-api.js +1 -1
  98. package/dist/runtime/auth-flow.d.ts +1 -1
  99. package/dist/runtime/auth-flow.js +4 -2
  100. package/dist/runtime/browser.d.ts +1 -1
  101. package/dist/runtime/browser.js +214 -25
  102. package/dist/runtime/cache.d.ts +1 -1
  103. package/dist/runtime/cache.js +4 -8
  104. package/dist/runtime/choice.d.ts +1 -1
  105. package/dist/runtime/choice.js +31 -35
  106. package/dist/runtime/credential.d.ts +1 -1
  107. package/dist/runtime/credential.js +1 -1
  108. package/dist/runtime/env.d.ts +1 -1
  109. package/dist/runtime/executor.d.ts +1 -1
  110. package/dist/runtime/executor.js +15 -3
  111. package/dist/runtime/http.d.ts +2 -2
  112. package/dist/runtime/http.js +160 -344
  113. package/dist/runtime/insights.d.ts +1 -1
  114. package/dist/runtime/insights.js +6 -13
  115. package/dist/runtime/instrumentation.d.ts +2 -2
  116. package/dist/runtime/instrumentation.js +56 -19
  117. package/dist/runtime/keyring.js +1 -1
  118. package/dist/runtime/namespace.js +1 -1
  119. package/dist/runtime/otlp.d.ts +1 -1
  120. package/dist/runtime/perf.d.ts +1 -1
  121. package/dist/runtime/provider.d.ts +1 -1
  122. package/dist/runtime/provider.js +1 -2
  123. package/dist/runtime/proxy-errors.d.ts +1 -1
  124. package/dist/runtime/proxy-errors.js +9 -7
  125. package/dist/runtime/proxy-nodemaven.d.ts +35 -0
  126. package/dist/runtime/proxy-nodemaven.js +128 -0
  127. package/dist/runtime/proxy-retry-policy.d.ts +40 -0
  128. package/dist/runtime/proxy-retry-policy.js +326 -0
  129. package/dist/runtime/proxy-telemetry.d.ts +2 -1
  130. package/dist/runtime/proxy-telemetry.js +55 -52
  131. package/dist/runtime/redis.d.ts +1 -1
  132. package/dist/runtime/redis.js +2 -4
  133. package/dist/runtime/request-options.d.ts +1 -1
  134. package/dist/runtime/secrets.d.ts +27 -0
  135. package/dist/runtime/secrets.js +51 -0
  136. package/dist/runtime/state.d.ts +2 -2
  137. package/dist/runtime/state.js +15 -4
  138. package/dist/runtime/stealth.d.ts +7 -4
  139. package/dist/runtime/stealth.js +257 -215
  140. package/dist/runtime/stt.d.ts +1 -1
  141. package/dist/runtime/stt.js +11 -15
  142. package/dist/runtime/trace.d.ts +2 -2
  143. package/dist/runtime/trace.js +2 -4
  144. package/dist/runtime/waterfall.d.ts +1 -1
  145. package/dist/schema.d.ts +1 -1
  146. package/dist/schema.js +7 -15
  147. package/dist/serve.d.ts +1 -1
  148. package/dist/serve.js +1 -1
  149. package/dist/server/index.d.ts +7 -3
  150. package/dist/server/index.js +6 -2
  151. package/dist/server/self-test-input-tokens.d.ts +1 -0
  152. package/dist/server/self-test-input-tokens.js +37 -0
  153. package/dist/server/self-test-redaction.d.ts +20 -0
  154. package/dist/server/self-test-redaction.js +70 -0
  155. package/dist/server/self-test-token.d.ts +30 -0
  156. package/dist/server/self-test-token.js +50 -0
  157. package/dist/server/self-test.d.ts +199 -0
  158. package/dist/server/self-test.js +1113 -0
  159. package/dist/server/serve.d.ts +14 -3
  160. package/dist/server/serve.js +135 -64
  161. package/dist/server/types.d.ts +10 -9
  162. package/dist/server/types.js +3 -7
  163. package/dist/stealth/profiles.d.ts +1 -1
  164. package/dist/stealth/profiles.js +5 -14
  165. package/dist/stream.d.ts +1 -1
  166. package/dist/testing/index.d.ts +2 -2
  167. package/dist/testing/index.js +2 -2
  168. package/dist/testing/run.d.ts +1 -1
  169. package/dist/testing/run.js +12 -15
  170. package/dist/types.d.ts +237 -1
  171. package/dist/user-input.d.ts +30 -0
  172. package/dist/user-input.js +66 -0
  173. package/package.json +16 -5
  174. package/src/auth-turn/auth-turn.v1.schema.json +89 -0
  175. package/src/auth-turn/fixtures/invalid/empty-kind.json +4 -0
  176. package/src/auth-turn/fixtures/invalid/expires-at-not-string.json +5 -0
  177. package/src/auth-turn/fixtures/invalid/missing-kind.json +3 -0
  178. package/src/auth-turn/fixtures/invalid/missing-turn-id.json +3 -0
  179. package/src/auth-turn/fixtures/invalid/timing-unknown-field.json +7 -0
  180. package/src/auth-turn/fixtures/invalid/turn-id-snake-case.json +4 -0
  181. package/src/auth-turn/fixtures/invalid/unknown-top-level-field.json +5 -0
  182. package/src/auth-turn/fixtures/valid/abort.json +8 -0
  183. package/src/auth-turn/fixtures/valid/challenge.json +17 -0
  184. package/src/auth-turn/fixtures/valid/complete.json +13 -0
  185. package/src/auth-turn/fixtures/valid/form.json +14 -0
  186. package/src/auth-turn/fixtures/valid/message.json +13 -0
  187. package/src/auth-turn/fixtures/valid/multi_choice.json +15 -0
  188. package/src/auth-turn/fixtures/valid/pending.json +5 -0
  189. package/src/auth-turn/fixtures/valid/poll.json +9 -0
  190. package/src/auth-turn/fixtures/valid/redirect.json +16 -0
  191. package/src/auth-turn/fixtures/valid/retry.json +8 -0
  192. package/src/auth-turn/fixtures/valid/unknown-kind.json +7 -0
  193. package/src/auth-turn/index.ts +177 -0
  194. package/src/auth.ts +728 -0
  195. package/src/ceremonies/index.ts +33 -121
  196. package/src/cli/commands.ts +10 -0
  197. package/src/cli/create.ts +69 -99
  198. package/src/cli/prompt-assets.ts +865 -0
  199. package/src/cli/templates/provider/.agents/skills/fixtures-and-recording/SKILL.md.tpl +58 -0
  200. package/src/cli/templates/provider/.agents/skills/health-checks-and-fail-closed/SKILL.md.tpl +65 -0
  201. package/src/cli/templates/provider/.agents/skills/normalization-standards/SKILL.md.tpl +57 -0
  202. package/src/cli/templates/provider/.agents/skills/pagination-and-counts/SKILL.md.tpl +52 -0
  203. package/src/cli/templates/provider/.agents/skills/upstream-contract-verification/SKILL.md.tpl +45 -0
  204. package/src/cli/templates/provider/.agents/skills/upstream-notes/README.md.tpl +13 -0
  205. package/src/cli/templates/provider/AGENTS.md.tpl +96 -0
  206. package/src/cli/templates/provider/README.md.tpl +7 -4
  207. package/src/config/loader.ts +543 -208
  208. package/src/contract-serialization.ts +5 -11
  209. package/src/contract-types.ts +2 -2
  210. package/src/contract.ts +13 -28
  211. package/src/define.ts +397 -528
  212. package/src/dev.ts +4 -9
  213. package/src/errors.ts +58 -5
  214. package/src/i18n/catalog.ts +10 -32
  215. package/src/i18n/index.ts +2 -2
  216. package/src/i18n/keys.ts +5 -11
  217. package/src/index.ts +64 -41
  218. package/src/lint.ts +122 -159
  219. package/src/provider.ts +40 -9
  220. package/src/public-schema-field-lint.ts +7 -33
  221. package/src/recipes/gov-api.ts +2 -5
  222. package/src/runtime/auth-flow.ts +6 -6
  223. package/src/runtime/browser.ts +320 -151
  224. package/src/runtime/cache.ts +20 -67
  225. package/src/runtime/choice.ts +79 -132
  226. package/src/runtime/credential.ts +2 -2
  227. package/src/runtime/env.ts +1 -1
  228. package/src/runtime/executor.ts +23 -20
  229. package/src/runtime/http.ts +216 -539
  230. package/src/runtime/insights.ts +15 -53
  231. package/src/runtime/instrumentation.ts +78 -65
  232. package/src/runtime/keyring.ts +7 -19
  233. package/src/runtime/namespace.ts +2 -7
  234. package/src/runtime/otlp.ts +12 -23
  235. package/src/runtime/perf.ts +1 -1
  236. package/src/runtime/provider.ts +4 -9
  237. package/src/runtime/proxy-errors.ts +29 -42
  238. package/src/runtime/proxy-nodemaven.ts +178 -0
  239. package/src/runtime/proxy-retry-policy.ts +469 -0
  240. package/src/runtime/proxy-telemetry.ts +79 -77
  241. package/src/runtime/redis.ts +4 -12
  242. package/src/runtime/request-options.ts +4 -13
  243. package/src/runtime/secrets.ts +64 -0
  244. package/src/runtime/state.ts +41 -110
  245. package/src/runtime/stealth.ts +331 -369
  246. package/src/runtime/stt.ts +38 -94
  247. package/src/runtime/trace.ts +14 -44
  248. package/src/runtime/waterfall.ts +5 -18
  249. package/src/schema.ts +23 -84
  250. package/src/serve.ts +1 -1
  251. package/src/server/index.ts +44 -3
  252. package/src/server/self-test-input-tokens.ts +46 -0
  253. package/src/server/self-test-redaction.ts +97 -0
  254. package/src/server/self-test-token.ts +70 -0
  255. package/src/server/self-test.ts +1450 -0
  256. package/src/server/serve.ts +206 -216
  257. package/src/server/types.ts +7 -19
  258. package/src/stealth/profiles.ts +10 -26
  259. package/src/stream.ts +8 -19
  260. package/src/testing/index.ts +2 -2
  261. package/src/testing/run.ts +24 -64
  262. package/src/types.ts +274 -1
  263. package/src/user-input.ts +118 -0
package/dist/dev.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProviderDefinition } from "./types";
1
+ import type { ProviderDefinition } from "./types.js";
2
2
  export interface DevServerOptions {
3
3
  port?: number;
4
4
  sessionDbPath?: string;
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { serve } from "./server/serve";
1
+ import { serve } from "./server/serve.js";
2
2
  export function createDevServer(provider, options) {
3
3
  const port = options?.port ?? 3900;
4
4
  return {
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 });
@@ -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;
@@ -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;
@@ -1,2 +1,2 @@
1
- export * from "./catalog";
2
- export * from "./keys";
1
+ export * from "./catalog.js";
2
+ export * from "./keys.js";
@@ -1,2 +1,2 @@
1
- export * from "./catalog";
2
- export * from "./keys";
1
+ export * from "./catalog.js";
2
+ export * from "./keys.js";
@@ -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 "./ceremonies";
2
- export * from "./choice-token";
3
- export type { ApiFuseConfig, BrowserConfig, ProxyConfig, SessionConfig, } from "./config/loader";
4
- export { defineConfig, loadApiFuseConfig } from "./config/loader";
5
- export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract";
6
- export { defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type ProviderConfig, } from "./define";
7
- export type { DevServerOptions } from "./dev";
8
- export { createDevServer, startDevServer } from "./dev";
9
- export * from "./errors";
10
- export * from "./i18n";
11
- export { type LintDiagnostic, lintOperation, lintProvider, } from "./lint";
12
- export * from "./recipes/gov-api";
13
- export * from "./recipes/rest-api";
14
- export { createFlowContext, createScratchpad } from "./runtime/auth-flow";
15
- export type { BrowserClientOptions } from "./runtime/browser";
16
- export { BrowserClient, createBrowserClient } from "./runtime/browser";
17
- export { createBypassProviderCache, createProviderCache, type ProviderCacheOptions, resetProviderCacheForTests, } from "./runtime/cache";
18
- export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice";
19
- export { type CreateCredentialContextOptions, createCredentialContext, } from "./runtime/credential";
20
- export { createEnvContext } from "./runtime/env";
21
- export { executeOperation } from "./runtime/executor";
22
- export { createHttpClient } from "./runtime/http";
23
- export type { Insight, InsightSeverity } from "./runtime/insights";
24
- export { generateInsights } from "./runtime/insights";
25
- export { type InstrumentationOptions, type InstrumentedProviderContext, wrapWithInstrumentation, } from "./runtime/instrumentation";
26
- export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate";
27
- export { getProviderBaseUrl } from "./runtime/provider";
28
- export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state";
29
- export { createStealthClient } from "./runtime/stealth";
30
- export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt";
31
- export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace";
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, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, z, } from "./schema";
33
- export { createServerApp, type ServeOptions, serve } from "./server";
34
- export { getStealthProfile, listStealthProfiles } from "./stealth/profiles";
35
- export * from "./stream";
36
- export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserEngine, BrowserOptions, ConnectionMode, ContextDeclaration, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, 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, ProviderHealthMonitorConfig, 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, StealthResponse, StealthSession, SttAudioInput, SttContext, SttPromptPolicy, SttSegment, SttTranscribeMode, SttTranscribeRequest, SttTranscript, SttUnsupportedOptionPolicy, SttUsage, SttVerificationCodeOptions, SttWarning, TraceConfig, TraceSpan, VerificationCodeCandidate, VerificationCodeCandidateSource, VerificationCodeExtractionResult, } from "./types";
37
- 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";
38
- export * from "./utils/date";
39
- export * from "./utils/parse";
40
- export * from "./utils/text";
41
- export * from "./utils/transform";
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 "./ceremonies";
3
- export * from "./choice-token";
4
- export { defineConfig, loadApiFuseConfig } from "./config/loader";
5
- export { canonicalJson, digestProviderContract, extractProviderContract, PROVIDER_CONTRACT_SCHEMA_VERSION, } from "./contract";
6
- export { defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, } from "./define";
7
- export { createDevServer, startDevServer } from "./dev";
8
- export * from "./errors";
9
- export * from "./i18n";
10
- export { lintOperation, lintProvider, } from "./lint";
11
- export * from "./recipes/gov-api";
12
- export * from "./recipes/rest-api";
13
- export { createFlowContext, createScratchpad } from "./runtime/auth-flow";
14
- export { BrowserClient, createBrowserClient } from "./runtime/browser";
15
- export { createBypassProviderCache, createProviderCache, resetProviderCacheForTests, } from "./runtime/cache";
16
- export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice";
17
- export { createCredentialContext, } from "./runtime/credential";
18
- export { createEnvContext } from "./runtime/env";
19
- export { executeOperation } from "./runtime/executor";
20
- export { createHttpClient } from "./runtime/http";
21
- export { generateInsights } from "./runtime/insights";
22
- export { wrapWithInstrumentation, } from "./runtime/instrumentation";
23
- export { prevalidate } from "./runtime/prevalidate";
24
- export { getProviderBaseUrl } from "./runtime/provider";
25
- export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state";
26
- export { createStealthClient } from "./runtime/stealth";
27
- export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt";
28
- export { createTraceContext, } from "./runtime/trace";
29
- 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";
30
- export { createServerApp, serve } from "./server";
31
- export { getStealthProfile, listStealthProfiles } from "./stealth/profiles";
32
- export * from "./stream";
33
- 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";
34
- export * from "./utils/date";
35
- export * from "./utils/parse";
36
- export * from "./utils/text";
37
- export * from "./utils/transform";
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
@@ -8,6 +8,7 @@ type ProviderAuthLike = {
8
8
  abort?: unknown;
9
9
  refresh?: unknown;
10
10
  };
11
+ exchange?: unknown;
11
12
  };
12
13
  type ProviderContractMetaLike = {
13
14
  publicSchemaFieldNames?: "normalized";
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, } from "./schema";
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 (hasNestedComposite ||
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
  }
@@ -1,9 +1,11 @@
1
- export { createFormCeremony } from "./ceremonies";
2
- export { assertFreshProviderChoiceIssuedAt, createProviderChoiceToken, ProviderChoiceTokenError, type ProviderChoiceTokenErrorReason, type ProviderChoiceTokenPayload, parseProviderChoiceToken, } from "./choice-token";
3
- export { defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, every, } from "./define";
4
- export { AuthError, ProviderError, SessionExpiredError, TransportError, ValidationError, } from "./errors";
5
- export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n";
6
- export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice";
7
- 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";
8
- export type { AuthMode, FlowContext, HealthCheckAssertionContext, HealthCheckCase, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, 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";
9
- 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,8 +1,9 @@
1
- export { createFormCeremony } from "./ceremonies";
2
- export { assertFreshProviderChoiceIssuedAt, createProviderChoiceToken, ProviderChoiceTokenError, parseProviderChoiceToken, } from "./choice-token";
3
- export { defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, every, } from "./define";
4
- export { AuthError, ProviderError, SessionExpiredError, TransportError, ValidationError, } from "./errors";
5
- export { getProviderLocalePath, providerLocaleKey, qualifyProviderLocaleKey, } from "./i18n";
6
- export { createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice";
7
- 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";
8
- 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[];
@@ -1,4 +1,4 @@
1
- import { unwrapEnvelope } from "../utils/parse";
1
+ import { unwrapEnvelope } from "../utils/parse.js";
2
2
  function getResultCode(raw) {
3
3
  if (!raw || typeof raw !== "object") {
4
4
  return undefined;
@@ -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 { createUnsupportedSttClient } from "./stt";
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[];