@sdk-it/typescript 0.46.5 → 0.46.6

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/README.md CHANGED
@@ -61,6 +61,21 @@ Generated types enforce the value required by each scheme:
61
61
  - Mutual TLS uses `true`; the configured `fetch` implementation owns the
62
62
  client certificate.
63
63
 
64
+ Any scheme also accepts `true` to declare a transport-owned credential: the
65
+ requirement counts as satisfied and the client sets nothing, because something
66
+ outside it supplies the credential. That is the configuration for a browser
67
+ session cookie (`apiKey` with `in: cookie`; the browser sends it when the
68
+ configured `fetch` passes `credentials: 'include'`) and for a host proxy that
69
+ injects `Authorization` on the client's behalf:
70
+
71
+ ```typescript
72
+ const client = new ExampleClient({
73
+ baseUrl: '/api',
74
+ fetch: (request) => fetch(request, { credentials: 'include' }),
75
+ credentials: { session: true },
76
+ });
77
+ ```
78
+
64
79
  Each value may instead be a sync or async provider. Providers receive the
65
80
  scheme name plus the current operation's OpenAPI scopes or roles:
66
81
 
package/dist/index.js CHANGED
@@ -1760,7 +1760,8 @@ const providerSchema = <T extends SecurityCredentialValue>() =>
1760
1760
  z.custom<SecurityCredentialProvider<T>>((value) => typeof value === 'function');
1761
1761
  const stringCredentialSchema = z.union([
1762
1762
  z.string(),
1763
- providerSchema<string>(),
1763
+ z.literal(true),
1764
+ providerSchema<string | true>(),
1764
1765
  ]);
1765
1766
  const basicCredentialValueSchema = z.object({
1766
1767
  username: z.string(),
@@ -1768,7 +1769,8 @@ const basicCredentialValueSchema = z.object({
1768
1769
  });
1769
1770
  const basicCredentialSchema = z.union([
1770
1771
  basicCredentialValueSchema,
1771
- providerSchema<{ username: string; password: string }>(),
1772
+ z.literal(true),
1773
+ providerSchema<{ username: string; password: string } | true>(),
1772
1774
  ]);
1773
1775
  const mutualTlsCredentialSchema = z.union([
1774
1776
  z.literal(true),
@@ -1840,6 +1842,9 @@ function applyCredential(
1840
1842
  if (credential === undefined) {
1841
1843
  throw new Error('Security credential provider returned no credential');
1842
1844
  }
1845
+ // true declares a transport-owned credential: the configured fetch, a host
1846
+ // proxy, or the browser's cookie jar supplies it, so nothing is set here.
1847
+ if (credential === true) return;
1843
1848
  if (scheme.type === 'apiKey') {
1844
1849
  if (typeof credential !== 'string') {
1845
1850
  throw new TypeError('API key credentials must be strings');
@@ -1869,10 +1874,7 @@ function applyCredential(
1869
1874
  return;
1870
1875
  }
1871
1876
  if (scheme.type === 'mutualTLS') {
1872
- if (credential !== true) {
1873
- throw new TypeError('mutualTLS credentials must be true when the custom fetch owns the client certificate');
1874
- }
1875
- return;
1877
+ throw new TypeError('mutualTLS credentials must be true when the custom fetch owns the client certificate');
1876
1878
  }
1877
1879
  if (scheme.type === 'http' && scheme.scheme.toLowerCase() === 'basic') {
1878
1880
  if (