axiam-sdk 1.1.3 → 1.2.2

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 (50) hide show
  1. package/README.md +73 -3
  2. package/dist/amqp/index.js.map +1 -1
  3. package/dist/amqp/index.mjs.map +1 -1
  4. package/dist/browser/index.d.cts +1 -1
  5. package/dist/browser/index.d.ts +1 -1
  6. package/dist/{client-BGFn1VQh.d.cts → client-Bp7riC4k.d.cts} +147 -3
  7. package/dist/{client-DrQZZ1js.d.ts → client-CaurIxje.d.ts} +147 -3
  8. package/dist/{cookieJar-BTmpjXZe.d.ts → cookieJar-DC4GLKrJ.d.ts} +2 -2
  9. package/dist/{cookieJar-BqYOnNN-.d.cts → cookieJar-oKazfbN1.d.cts} +2 -2
  10. package/dist/{errors-DZ3k8a8i.d.cts → errors-CWlh-wcm.d.cts} +7 -1
  11. package/dist/{errors-DZ3k8a8i.d.ts → errors-CWlh-wcm.d.ts} +7 -1
  12. package/dist/{errors-dlGXAsbh.d.ts → errors-DDo3oxcH.d.ts} +1 -1
  13. package/dist/{errors-RvGlTyUj.d.cts → errors-DHauOsqx.d.cts} +1 -1
  14. package/dist/grpc/index.d.cts +4 -4
  15. package/dist/grpc/index.d.ts +4 -4
  16. package/dist/grpc/index.js +26 -5
  17. package/dist/grpc/index.js.map +1 -1
  18. package/dist/grpc/index.mjs +26 -5
  19. package/dist/grpc/index.mjs.map +1 -1
  20. package/dist/index.d.cts +4 -4
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.js +26 -5
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +26 -5
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/middleware/index.d.cts +5 -5
  27. package/dist/middleware/index.d.ts +5 -5
  28. package/dist/middleware/index.js +164 -12
  29. package/dist/middleware/index.js.map +1 -1
  30. package/dist/middleware/index.mjs +164 -12
  31. package/dist/middleware/index.mjs.map +1 -1
  32. package/dist/nestjs/index.js.map +1 -1
  33. package/dist/nestjs/index.mjs.map +1 -1
  34. package/dist/node/index.d.cts +15 -4
  35. package/dist/node/index.d.ts +15 -4
  36. package/dist/node/index.js +186 -14
  37. package/dist/node/index.js.map +1 -1
  38. package/dist/node/index.mjs +185 -15
  39. package/dist/node/index.mjs.map +1 -1
  40. package/dist/{oidcState-C3VLn3eD.d.ts → oidcState-CZhj0MBP.d.ts} +123 -5
  41. package/dist/{oidcState-BaJ-SM_R.d.cts → oidcState-EnEJmoF5.d.cts} +123 -5
  42. package/dist/rest/index.d.cts +6 -6
  43. package/dist/rest/index.d.ts +6 -6
  44. package/dist/rest/index.js +26 -5
  45. package/dist/rest/index.js.map +1 -1
  46. package/dist/rest/index.mjs +26 -5
  47. package/dist/rest/index.mjs.map +1 -1
  48. package/dist/{session-B03NsqVs.d.ts → session-Beo11VT_.d.ts} +9 -0
  49. package/dist/{session-plDr4lFu.d.cts → session-CeIUXgpE.d.cts} +9 -0
  50. package/package.json +1 -1
@@ -51,11 +51,18 @@ var OAuthProtocolError = class _OAuthProtocolError extends AuthError {
51
51
  * OPTIONAL, and §2 (contract 1.53, §28.12.3) dispatches on `error` alone.
52
52
  */
53
53
  errorDescription;
54
- constructor(error, errorDescription = "") {
54
+ /**
55
+ * The server's `Retry-After` in milliseconds, when this error is a `429` that carried one in
56
+ * delta-seconds form (contract 1.65 §37.3, C165-17). Absent otherwise; an HTTP-date is not read.
57
+ * Additive: honour it before retrying a rate-limited native sign-in or CIBA call.
58
+ */
59
+ retryAfterMs;
60
+ constructor(error, errorDescription = "", retryAfterMs2) {
55
61
  super(errorDescription ? `${error}: ${errorDescription}` : error);
56
62
  this.name = "OAuthProtocolError";
57
63
  this.error = error;
58
64
  this.errorDescription = errorDescription;
65
+ if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
59
66
  Object.setPrototypeOf(this, _OAuthProtocolError.prototype);
60
67
  }
61
68
  };
@@ -116,7 +123,7 @@ function isOAuth2ErrorBody(body) {
116
123
  const record = body;
117
124
  return typeof record.error === "string" && typeof record.error_description === "string";
118
125
  }
119
- function oauth2ErrorFromBody(body) {
126
+ function oauth2ErrorFromBody(body, retryAfterMs2) {
120
127
  if (body === null || typeof body !== "object" || Array.isArray(body)) {
121
128
  return void 0;
122
129
  }
@@ -125,7 +132,7 @@ function oauth2ErrorFromBody(body) {
125
132
  return void 0;
126
133
  }
127
134
  const description = typeof record.error_description === "string" ? record.error_description : "";
128
- return new OAuthProtocolError(record.error, description);
135
+ return new OAuthProtocolError(record.error, description, retryAfterMs2);
129
136
  }
130
137
  var SAFE_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
131
138
  "content-type",
@@ -692,12 +699,21 @@ var SharedSession = class {
692
699
  * The fetch adapter derives its `credentials` from `withCredentials: false`
693
700
  * (`'omit'`); `fetchOptions.credentials` is set as well for adapters that
694
701
  * read it.
702
+ *
703
+ * `fetchOptions.redirect: 'error'` is the browser persona's half of CONTRACT.md §12.1
704
+ * rule 3 ("No redirect is followed", C165-26). On the main client's `/oauth2/*` requests
705
+ * it makes `fetch` reject, which every caller maps to a `NetworkError` that carries
706
+ * neither the `Location` nor the request. Where `maxRedirects: 0` is set (the bare
707
+ * transport, `bareRequest`), axios's fetch adapter substitutes `redirect: 'manual'`
708
+ * (`lib/adapters/fetch.js`), so `'error'` is overridden there: the browser hands back an
709
+ * opaque-redirect (status 0), and `bareRequest` maps status 0 or any `3xx` to a
710
+ * `NetworkError` without the `Location` (`bareTransport.ts`).
695
711
  * `NodeSession` overrides this to {@link noCredentialsConfig}: its jar-free
696
712
  * agent pair is what keeps the cookies off there, and the fetch adapter
697
713
  * would bypass that pair.
698
714
  */
699
715
  oauth2RequestConfig() {
700
- return { ...this.noCredentialsConfig(), adapter: "fetch", fetchOptions: { credentials: "omit" } };
716
+ return { ...this.noCredentialsConfig(), adapter: "fetch", fetchOptions: { credentials: "omit", redirect: "error" } };
701
717
  }
702
718
  };
703
719
  function resolveTenantHeaderValue(options) {
@@ -1931,12 +1947,17 @@ async function bareRequest(session, operation, config) {
1931
1947
  maxRedirects: 0,
1932
1948
  validateStatus: () => true
1933
1949
  });
1950
+ let response;
1934
1951
  try {
1935
- return await instance.request(config);
1952
+ response = await instance.request(config);
1936
1953
  } catch (err) {
1937
1954
  const code = err && typeof err === "object" && "code" in err && typeof err.code === "string" ? ` (${err.code})` : "";
1938
1955
  throw new NetworkError(`${operation}: the request failed before any response arrived${code}`);
1939
1956
  }
1957
+ if (response.status === 0 || response.status >= 300 && response.status < 400) {
1958
+ throw new NetworkError(`${operation}: the server answered with a redirect, which is not followed`);
1959
+ }
1960
+ return response;
1940
1961
  }
1941
1962
  function retryAfterMs(response) {
1942
1963
  const raw = response.headers?.["retry-after"];
@@ -8923,6 +8944,10 @@ function generateCodeVerifier() {
8923
8944
  function computeCodeChallenge(codeVerifier) {
8924
8945
  return crypto.createHash("sha256").update(codeVerifier, "ascii").digest("base64url");
8925
8946
  }
8947
+ function nativeNonce() {
8948
+ const raw = randomUrlSafeToken(CSPRNG_BYTES);
8949
+ return { raw: new Sensitive(raw), hashed: crypto.createHash("sha256").update(raw, "utf8").digest("hex") };
8950
+ }
8926
8951
 
8927
8952
  // src/node/oidc.ts
8928
8953
  var DISCOVERY_PATH = "/.well-known/openid-configuration";
@@ -9036,9 +9061,9 @@ function pollRateLimit(err) {
9036
9061
  if (axiosStatus3(err) !== 429) return void 0;
9037
9062
  const body = axiosBody(err);
9038
9063
  const description = body !== null && typeof body === "object" && typeof body.error_description === "string" ? body.error_description : "";
9039
- const limited = new OAuthProtocolError("rate_limit_exceeded", description);
9040
9064
  const response = err.response;
9041
9065
  const retryAfter = response ? retryAfterMs(response) : void 0;
9066
+ const limited = new OAuthProtocolError("rate_limit_exceeded", description, retryAfter);
9042
9067
  if (retryAfter !== void 0) POLL_RETRY_AFTER_MS.set(limited, retryAfter);
9043
9068
  return limited;
9044
9069
  }
@@ -9058,6 +9083,24 @@ var RESERVED_AUTHORIZE_PARAMS = /* @__PURE__ */ new Set([
9058
9083
  "code_challenge",
9059
9084
  "code_challenge_method"
9060
9085
  ]);
9086
+ var IDP_HINT_PARAM = "axiam_idp_hint";
9087
+ var IDP_HINT_MAX_BYTES = 256;
9088
+ var PROVIDER_ID_TOKEN_GRANT_TYPE = "urn:axiam:params:oauth:grant-type:provider-id-token";
9089
+ function checkIdpHint(operation, hint) {
9090
+ if (hint === "") {
9091
+ throw new ValidationError(operation, 400, `${operation}: idpHint must not be empty (CONTRACT.md \xA712.1)`, [
9092
+ { field: "idpHint", message: "must not be empty" }
9093
+ ]);
9094
+ }
9095
+ if (Buffer.byteLength(hint, "utf8") > IDP_HINT_MAX_BYTES) {
9096
+ throw new ValidationError(
9097
+ operation,
9098
+ 400,
9099
+ `${operation}: idpHint must be at most ${IDP_HINT_MAX_BYTES} bytes (CONTRACT.md \xA712.1)`,
9100
+ [{ field: "idpHint", message: `must be at most ${IDP_HINT_MAX_BYTES} bytes` }]
9101
+ );
9102
+ }
9103
+ }
9061
9104
  var UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
9062
9105
  var DiscoveryCache = class {
9063
9106
  #documents = /* @__PURE__ */ new Map();
@@ -9120,11 +9163,25 @@ function bodyMessage(body, fallback) {
9120
9163
  }
9121
9164
  return fallback;
9122
9165
  }
9166
+ function beginUrlIdpHint(url) {
9167
+ try {
9168
+ const value = new URL(url).searchParams.get(IDP_HINT_PARAM);
9169
+ return value === null || value === "" ? void 0 : value;
9170
+ } catch {
9171
+ return void 0;
9172
+ }
9173
+ }
9174
+ function redirectRefused(operation, status) {
9175
+ return new NetworkError(`${operation}: the server answered HTTP ${status}; a redirect is never followed (CONTRACT.md \xA712.1 rule 3)`);
9176
+ }
9123
9177
  function mapOidcError(err, url, fallbackMessage) {
9124
9178
  if (err instanceof AxiamError) {
9125
9179
  return err;
9126
9180
  }
9127
9181
  const status = axiosStatus3(err);
9182
+ if (status !== void 0 && status >= 300 && status < 400) {
9183
+ return redirectRefused(fallbackMessage, status);
9184
+ }
9128
9185
  if (status !== void 0) {
9129
9186
  const body = axiosBody(err);
9130
9187
  return mapHttpStatusToError(status, bodyMessage(body, fallbackMessage), { url, body, cause: err });
@@ -9294,7 +9351,8 @@ function jsonBody(data) {
9294
9351
  }
9295
9352
  }
9296
9353
  function cibaError(operation, response) {
9297
- return oauth2ErrorFromBody(jsonBody(response.data)) ?? mapHttpStatusToError(response.status, `${operation}: HTTP ${response.status}`);
9354
+ if (response.status >= 300 && response.status < 400) return redirectRefused(operation, response.status);
9355
+ return oauth2ErrorFromBody(jsonBody(response.data), response.status === 429 ? retryAfterMs(response) : void 0) ?? mapHttpStatusToError(response.status, `${operation}: HTTP ${response.status}`);
9298
9356
  }
9299
9357
  function authorizationValues(headers) {
9300
9358
  const out = [];
@@ -9363,15 +9421,19 @@ var OidcClient = class {
9363
9421
  * fresh PKCE verifier/challenge pair using **S256 only** — `plain` is not
9364
9422
  * implemented anywhere in this SDK. The URL is built from the discovery
9365
9423
  * document's `authorization_endpoint` with exactly the eight parameters
9366
- * §12.1 rule 5 mandates, plus any `extraParams` the caller adds.
9424
+ * §12.1 rule 5 mandates, plus any `extraParams` the caller adds and, when
9425
+ * `idpHint` is set, the one `axiam_idp_hint` (contract 1.65).
9367
9426
  *
9368
9427
  * Nothing is stored: persist the returned `state`, `nonce` and
9369
9428
  * `codeVerifier` yourself (§12.3 rule 1).
9370
9429
  *
9371
9430
  * @throws Error when `extraParams` tries to override one of the eight
9372
9431
  * SDK-owned parameters — a programming error, caught at call time.
9432
+ * @throws ValidationError when `idpHint` is empty or over 256 UTF-8 bytes;
9433
+ * no URL is built.
9373
9434
  */
9374
9435
  oidcBegin(params) {
9436
+ if (params.idpHint !== void 0) checkIdpHint("oidcBegin", params.idpHint);
9375
9437
  const state = randomUrlSafeToken();
9376
9438
  const nonce = randomUrlSafeToken();
9377
9439
  const codeVerifier = generateCodeVerifier();
@@ -9385,6 +9447,7 @@ var OidcClient = class {
9385
9447
  `oidcBegin: extraParams may not override the SDK-owned authorization parameter "${key}" (CONTRACT.md \xA712.1 rule 5).`
9386
9448
  );
9387
9449
  }
9450
+ if (key === IDP_HINT_PARAM && params.idpHint !== void 0) continue;
9388
9451
  query.set(key, value);
9389
9452
  }
9390
9453
  query.set("response_type", "code");
@@ -9395,6 +9458,7 @@ var OidcClient = class {
9395
9458
  query.set("nonce", nonce);
9396
9459
  query.set("code_challenge", codeChallenge);
9397
9460
  query.set("code_challenge_method", CODE_CHALLENGE_METHOD_S256);
9461
+ if (params.idpHint !== void 0) query.set(IDP_HINT_PARAM, params.idpHint);
9398
9462
  target.search = query.toString().replace(/\+/g, "%20");
9399
9463
  return { url: target.toString(), state, nonce, codeVerifier };
9400
9464
  }
@@ -9491,6 +9555,94 @@ var OidcClient = class {
9491
9555
  return tokenSet;
9492
9556
  }
9493
9557
  // -------------------------------------------------------------------------
9558
+ // §37 loginWithProviderIdToken
9559
+ // -------------------------------------------------------------------------
9560
+ /**
9561
+ * `POST /oauth2/token` with
9562
+ * `grant_type=urn:axiam:params:oauth:grant-type:provider-id-token`
9563
+ * (CONTRACT.md §37, contract 1.65) — sign a native-app user in with the ID
9564
+ * token a Google, Apple or Facebook Limited Login SDK produced.
9565
+ *
9566
+ * @param provider - The provider's UUID or its `provider_slug`, sent verbatim:
9567
+ * never trimmed, case-folded, resolved or looked up. A provider *kind* name
9568
+ * (`google`) is not accepted here unless the operator also chose it as the
9569
+ * slug (§37.2 rule 2).
9570
+ * @param idToken - The provider's ID token (a credential; wrapped or bare).
9571
+ * @param nonce - The **raw** nonce, byte for byte: the provider's SDK was
9572
+ * given `SHA-256(raw)` as hexadecimal (`nativeNonce()` produces the
9573
+ * pair). Never hashed, replaced or generated here (§37.2 rule 3).
9574
+ * @param options - `scopes`, `resource`, `tenantId`, `configuration`.
9575
+ *
9576
+ * @remarks
9577
+ * **Never retried** — not on a status, a `429` or a transport failure: the
9578
+ * provider's token is single-use across the deployment (§37.2 rule 10). An
9579
+ * `invalid_grant` is the server's one generic answer to every refusal of the
9580
+ * token and is neither retried nor refined; the recovery is a **fresh**
9581
+ * provider token with a **fresh** nonce. A transport failure after the
9582
+ * request left is indeterminate and surfaces as `NetworkError`.
9583
+ *
9584
+ * No `openid` or other scope is added: omit `scopes` and the response carries
9585
+ * no `id_token`. This is not token exchange (§15) and never falls back to it
9586
+ * or to a browser flow. A public client sends `client_id` alone; a client
9587
+ * configured with a `clientSecret` sends it in the body.
9588
+ *
9589
+ * The result is the ordinary {@link OidcTokenSet}; an `id_token`, when
9590
+ * present, is validated under §12.4 with the raw `nonce` as the expected
9591
+ * nonce. As with `deviceLogin`, the token set is **returned and not
9592
+ * adopted** as this client's credential (§37.2 rule 9).
9593
+ *
9594
+ * Neither the ID token nor the raw nonce is logged, put in an error, or kept
9595
+ * after the call returns; hold the raw nonce only for the length of the
9596
+ * attempt.
9597
+ *
9598
+ * @throws ValidationError (local, no request) for an empty `provider`,
9599
+ * `idToken` or `nonce`.
9600
+ * @throws AuthError (local, no request) for a slug-only client (§12.3 rule 4).
9601
+ * @throws OAuthProtocolError for a body carrying `error`, at any status.
9602
+ * @throws NetworkError for a transport failure or a body-less `5xx`.
9603
+ *
9604
+ * @example
9605
+ * ```ts
9606
+ * const { raw, hashed } = nativeNonce();
9607
+ * const idToken = await providerSdk.signIn({ nonce: hashed });
9608
+ * const tokens = await oidc.loginWithProviderIdToken('corp-google', idToken, raw, {
9609
+ * scopes: ['openid', 'profile'],
9610
+ * });
9611
+ * ```
9612
+ */
9613
+ async loginWithProviderIdToken(provider, idToken, nonce, options = {}) {
9614
+ const operation = "loginWithProviderIdToken";
9615
+ const refuse = (field) => new ValidationError(operation, 400, `${operation}: ${field} must not be empty (CONTRACT.md \xA737.2 rule 4)`, [
9616
+ { field, message: "must not be empty" }
9617
+ ]);
9618
+ const idTokenValue = typeof idToken === "string" ? idToken : idToken.expose();
9619
+ const nonceValue = typeof nonce === "string" ? nonce : nonce.expose();
9620
+ if (provider === "") throw refuse("provider");
9621
+ if (idTokenValue === "") throw refuse("idToken");
9622
+ if (nonceValue === "") throw refuse("nonce");
9623
+ this.#resolveTenantId(options.tenantId);
9624
+ const configuration = options.configuration ?? await this.oidcDiscover();
9625
+ const form = new URLSearchParams();
9626
+ form.set("grant_type", PROVIDER_ID_TOKEN_GRANT_TYPE);
9627
+ form.set("client_id", this.#options.clientId);
9628
+ form.set("provider", provider);
9629
+ form.set("id_token", idTokenValue);
9630
+ form.set("nonce", nonceValue);
9631
+ if (options.scopes !== void 0 && options.scopes.length > 0) {
9632
+ form.set("scope", options.scopes.join(" "));
9633
+ }
9634
+ if (options.resource !== void 0) {
9635
+ form.set("resource", options.resource);
9636
+ }
9637
+ this.#appendClientSecret(form);
9638
+ const url = this.#endpointUrl(this.#requiredEndpoint(configuration, "token_endpoint"), options.tenantId);
9639
+ const response = await this.#postCibaForm(url, form, operation);
9640
+ if (response.status < 200 || response.status >= 300) {
9641
+ throw cibaError(operation, response);
9642
+ }
9643
+ return this.#toTokenSet(response.data, configuration, nonceValue);
9644
+ }
9645
+ // -------------------------------------------------------------------------
9494
9646
  // 6. introspect
9495
9647
  // -------------------------------------------------------------------------
9496
9648
  /**
@@ -9923,6 +10075,7 @@ var OidcClient = class {
9923
10075
  * ```
9924
10076
  */
9925
10077
  async oidcPar(params) {
10078
+ if (params.idpHint !== void 0) checkIdpHint("oidcPar", params.idpHint);
9926
10079
  const configuration = params.configuration ?? await this.oidcDiscover();
9927
10080
  const endpoint = this.#optionalEndpoint(configuration, "pushed_authorization_request_endpoint");
9928
10081
  if (!endpoint) {
@@ -9943,6 +10096,11 @@ var OidcClient = class {
9943
10096
  if (params.dpopJkt !== void 0) {
9944
10097
  form.set("dpop_jkt", params.dpopJkt);
9945
10098
  }
10099
+ const pushedHint = params.idpHint ?? beginUrlIdpHint(request.url);
10100
+ if (pushedHint !== void 0) {
10101
+ checkIdpHint("oidcPar", pushedHint);
10102
+ form.set(IDP_HINT_PARAM, pushedHint);
10103
+ }
9946
10104
  this.#appendClientSecret(form);
9947
10105
  const url = this.#endpointUrl(endpoint, params.tenantId);
9948
10106
  const { data } = await this.#postForm(
@@ -10289,7 +10447,8 @@ var OidcClient = class {
10289
10447
  let data;
10290
10448
  try {
10291
10449
  const config = {
10292
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
10450
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
10451
+ maxRedirects: 0
10293
10452
  };
10294
10453
  const response = await this.#session.axios.post(
10295
10454
  url,
@@ -10620,7 +10779,13 @@ var OidcClient = class {
10620
10779
  if (response.status >= 500) {
10621
10780
  throw transient(retryableNetworkError(`${operation}: HTTP ${response.status}`, response));
10622
10781
  }
10623
- const protocol = oauth2ErrorFromBody(jsonBody(response.data));
10782
+ if (response.status >= 300 && response.status < 400) {
10783
+ return { error: redirectRefused(operation, response.status) };
10784
+ }
10785
+ const protocol = oauth2ErrorFromBody(
10786
+ jsonBody(response.data),
10787
+ response.status === 429 ? retryAfterMs(response) : void 0
10788
+ );
10624
10789
  if (protocol) return { error: protocol };
10625
10790
  if (statusIsRetryable(response.status)) {
10626
10791
  throw transient(retryableNetworkError(`${operation}: HTTP ${response.status}`, response));
@@ -10778,7 +10943,8 @@ var OidcClient = class {
10778
10943
  try {
10779
10944
  return await this.#session.axios.post(url, form.toString(), {
10780
10945
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
10781
- validateStatus: () => true
10946
+ validateStatus: () => true,
10947
+ maxRedirects: 0
10782
10948
  });
10783
10949
  } catch (err) {
10784
10950
  const code = err && typeof err === "object" && typeof err.code === "string" ? ` (${err.code})` : "";
@@ -10798,7 +10964,8 @@ var OidcClient = class {
10798
10964
  async () => {
10799
10965
  try {
10800
10966
  const response = await this.#session.axios.post(url, form.toString(), {
10801
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
10967
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
10968
+ maxRedirects: 0
10802
10969
  });
10803
10970
  return { wire: response.data };
10804
10971
  } catch (err) {
@@ -11006,13 +11173,16 @@ var OidcClient = class {
11006
11173
  /** POST a form-encoded body (§12.1 note 1) through the session transport. */
11007
11174
  async #postForm(url, form, fallbackMessage) {
11008
11175
  const config = {
11009
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
11176
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
11177
+ // §12.1 rule 3 (C165-14): never follow a redirect from an `/oauth2/*` POST.
11178
+ maxRedirects: 0
11010
11179
  };
11011
11180
  try {
11012
11181
  return await this.#session.axios.post(url, form.toString(), config);
11013
11182
  } catch (err) {
11014
11183
  if (axiosStatus3(err) === 429) {
11015
- const protocol = oauth2ErrorFromBody(axiosBody(err));
11184
+ const raw = err.response;
11185
+ const protocol = oauth2ErrorFromBody(axiosBody(err), raw ? retryAfterMs(raw) : void 0);
11016
11186
  if (protocol) throw protocol;
11017
11187
  }
11018
11188
  throw mapOidcError(err, url, fallbackMessage);
@@ -11788,6 +11958,7 @@ exports.OidcClient = OidcClient;
11788
11958
  exports.PROTOCOL_OAUTH2 = PROTOCOL_OAUTH2;
11789
11959
  exports.PROTOCOL_OIDC_CONNECT = PROTOCOL_OIDC_CONNECT;
11790
11960
  exports.PROTOCOL_SAML = PROTOCOL_SAML;
11961
+ exports.PROVIDER_ID_TOKEN_GRANT_TYPE = PROVIDER_ID_TOKEN_GRANT_TYPE;
11791
11962
  exports.PollSchedule = PollSchedule;
11792
11963
  exports.REFRESH_COOKIE = REFRESH_COOKIE;
11793
11964
  exports.RevocationFeed = RevocationFeed;
@@ -11825,6 +11996,7 @@ exports.generateCodeVerifier = generateCodeVerifier;
11825
11996
  exports.isAccessDenied = isAccessDenied;
11826
11997
  exports.isExpiredToken = isExpiredToken;
11827
11998
  exports.jwkThumbprintS256 = jwkThumbprintS256;
11999
+ exports.nativeNonce = nativeNonce;
11828
12000
  exports.normalizeOrigin = normalizeOrigin;
11829
12001
  exports.pushErrorCode = pushErrorCode;
11830
12002
  exports.randomUrlSafeToken = randomUrlSafeToken;