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
@@ -1,18 +1,18 @@
1
1
  import { Request, RequestHandler, Router } from 'express';
2
2
  import { a as AuthzLogger, E as ErrorBody, b as AxiamIdentity, V as VerifiableSession, A as AuthzVerifiableSession, c as ResourceSpec, R as RequireAccessOptions } from '../authzCore-CqXzLNmT.cjs';
3
3
  export { d as AuthzChecker, C as CheckOutcome, e as ResourceParamRef, f as ResourceResolutionError, g as ResourceResolver, U as UmaChallenger, h as UmaTicketMinter, i as assertAuthzClient, j as authenticateRequest, k as evaluateAccess, l as fromParam, m as hasAnyRole, r as resolveResourceId } from '../authzCore-CqXzLNmT.cjs';
4
- import { P as OidcClient, W as OidcStateStore, X as OidcTokenSet, V as OidcStateEntry } from '../oidcState-BaJ-SM_R.cjs';
5
- export { a as AuthorizationRequest, c as CibaAwaitParams, d as CibaClock, e as CibaDelivery, f as CibaInitiateParams, g as CibaInitiateResponse, h as CibaPingHeaders, i as CibaPollParams, j as CibaRequestSigner, k as CibaSignerDescription, l as CibaSigningAlg, m as CibaSigningKey, n as CibaUserHint, r as DeviceAuthorization, s as DeviceAuthorizeParams, t as DeviceLoginParams, u as DevicePollParams, E as ExchangedToken, F as FederationProvider, v as FederationProviderList, H as HANDOFF_CODE_TTL_SECS, w as HANDOFF_QUERY_PARAM, I as IntrospectParams, x as IntrospectionResult, L as LoginClientCredentialsParams, y as LogoutUrlParams, z as MIN_DISCOVERY_TTL_MS, G as MemoryOidcStateStore, K as MtlsEndpointAliases, O as OIDC_STATE_TTL_MS, N as OidcBeginParams, Q as OidcClientOptions, R as OidcConfiguration, S as OidcExchangeParams, T as OidcParParams, U as OidcRefreshParams, Y as PROTOCOL_OAUTH2, Z as PROTOCOL_OIDC_CONNECT, _ as PROTOCOL_SAML, a0 as PushedAuthorizationRequest, a1 as RequestedPermission, a2 as RequestingPartyToken, a3 as ResourceSet, a4 as RevokeParams, ae as SsoCompleteHandoffParams, af as SsoCompleteOauth2Params, ag as SsoCompleteParams, ah as SsoCompleteResult, ai as SsoProvidersParams, aj as SsoStartOauth2Params, ak as SsoStartParams, al as SsoStartResult, an as TokenExchangeParams, as as UmaExchangeTicketParams, at as VerifiedLogoutToken, au as createOidcClient, av as isAccessDenied, aw as isExpiredToken } from '../oidcState-BaJ-SM_R.cjs';
4
+ import { R as OidcClient, Y as OidcStateStore, Z as OidcTokenSet, X as OidcStateEntry } from '../oidcState-EnEJmoF5.cjs';
5
+ export { a as AuthorizationRequest, c as CibaAwaitParams, d as CibaClock, e as CibaDelivery, f as CibaInitiateParams, g as CibaInitiateResponse, h as CibaPingHeaders, i as CibaPollParams, j as CibaRequestSigner, k as CibaSignerDescription, l as CibaSigningAlg, m as CibaSigningKey, n as CibaUserHint, r as DeviceAuthorization, s as DeviceAuthorizeParams, t as DeviceLoginParams, u as DevicePollParams, E as ExchangedToken, F as FederationProvider, v as FederationProviderList, H as HANDOFF_CODE_TTL_SECS, w as HANDOFF_QUERY_PARAM, I as IntrospectParams, x as IntrospectionResult, L as LoginClientCredentialsParams, y as LoginWithProviderIdTokenOptions, z as LogoutUrlParams, G as MIN_DISCOVERY_TTL_MS, K as MemoryOidcStateStore, N as MtlsEndpointAliases, O as OIDC_STATE_TTL_MS, Q as OidcBeginParams, S as OidcClientOptions, T as OidcConfiguration, U as OidcExchangeParams, V as OidcParParams, W as OidcRefreshParams, _ as PROTOCOL_OAUTH2, $ as PROTOCOL_OIDC_CONNECT, a0 as PROTOCOL_SAML, a3 as PushedAuthorizationRequest, a4 as RequestedPermission, a5 as RequestingPartyToken, a6 as ResourceSet, a7 as RevokeParams, ah as SsoCompleteHandoffParams, ai as SsoCompleteOauth2Params, aj as SsoCompleteParams, ak as SsoCompleteResult, al as SsoProvidersParams, am as SsoStartOauth2Params, an as SsoStartParams, ao as SsoStartResult, aq as TokenExchangeParams, av as UmaExchangeTicketParams, aw as VerifiedLogoutToken, ax as createOidcClient, ay as isAccessDenied, az as isExpiredToken } from '../oidcState-EnEJmoF5.cjs';
6
6
  import { FastifyRequest, FastifyReply, FastifyPluginAsync, FastifyInstance } from 'fastify';
7
- export { F as FieldError, V as ValidationError } from '../errors-RvGlTyUj.cjs';
7
+ export { F as FieldError, V as ValidationError } from '../errors-DHauOsqx.cjs';
8
8
  import { P as PresentedProofs } from '../jwks-CTVpOWzI.cjs';
9
9
  export { a as AccessTokenExpectations, A as AxiamClaims, b as CLOCK_SKEW_LEEWAY_SEC, C as CnfClaim, I as IdTokenClaims, V as Verifier, h as assertTenantClaim, i as certificateThumbprintS256, v as verifyCertificateBinding, k as verifyTokenBinding } from '../jwks-CTVpOWzI.cjs';
10
10
  export { D as DEFAULT_POLL_INTERVAL_MS, M as MAX_ENTRIES, a as MIN_POLL_INTERVAL_MS, R as RevocationFeed, b as RevocationFeedOptions } from '../revocationFeed-KQhvMMl8.cjs';
11
11
  import '../sensitive-BC_s7Rrd.cjs';
12
12
  import '../types-zXSpiQM-.cjs';
13
13
  import 'node:crypto';
14
- import '../errors-DZ3k8a8i.cjs';
15
- import '../session-plDr4lFu.cjs';
14
+ import '../errors-CWlh-wcm.cjs';
15
+ import '../session-CeIUXgpE.cjs';
16
16
  import 'axios';
17
17
  import '../telemetry-Du0-zS5f.cjs';
18
18
 
@@ -1,18 +1,18 @@
1
1
  import { Request, RequestHandler, Router } from 'express';
2
2
  import { a as AuthzLogger, E as ErrorBody, b as AxiamIdentity, V as VerifiableSession, A as AuthzVerifiableSession, c as ResourceSpec, R as RequireAccessOptions } from '../authzCore-D-hquWSI.js';
3
3
  export { d as AuthzChecker, C as CheckOutcome, e as ResourceParamRef, f as ResourceResolutionError, g as ResourceResolver, U as UmaChallenger, h as UmaTicketMinter, i as assertAuthzClient, j as authenticateRequest, k as evaluateAccess, l as fromParam, m as hasAnyRole, r as resolveResourceId } from '../authzCore-D-hquWSI.js';
4
- import { P as OidcClient, W as OidcStateStore, X as OidcTokenSet, V as OidcStateEntry } from '../oidcState-C3VLn3eD.js';
5
- export { a as AuthorizationRequest, c as CibaAwaitParams, d as CibaClock, e as CibaDelivery, f as CibaInitiateParams, g as CibaInitiateResponse, h as CibaPingHeaders, i as CibaPollParams, j as CibaRequestSigner, k as CibaSignerDescription, l as CibaSigningAlg, m as CibaSigningKey, n as CibaUserHint, r as DeviceAuthorization, s as DeviceAuthorizeParams, t as DeviceLoginParams, u as DevicePollParams, E as ExchangedToken, F as FederationProvider, v as FederationProviderList, H as HANDOFF_CODE_TTL_SECS, w as HANDOFF_QUERY_PARAM, I as IntrospectParams, x as IntrospectionResult, L as LoginClientCredentialsParams, y as LogoutUrlParams, z as MIN_DISCOVERY_TTL_MS, G as MemoryOidcStateStore, K as MtlsEndpointAliases, O as OIDC_STATE_TTL_MS, N as OidcBeginParams, Q as OidcClientOptions, R as OidcConfiguration, S as OidcExchangeParams, T as OidcParParams, U as OidcRefreshParams, Y as PROTOCOL_OAUTH2, Z as PROTOCOL_OIDC_CONNECT, _ as PROTOCOL_SAML, a0 as PushedAuthorizationRequest, a1 as RequestedPermission, a2 as RequestingPartyToken, a3 as ResourceSet, a4 as RevokeParams, ae as SsoCompleteHandoffParams, af as SsoCompleteOauth2Params, ag as SsoCompleteParams, ah as SsoCompleteResult, ai as SsoProvidersParams, aj as SsoStartOauth2Params, ak as SsoStartParams, al as SsoStartResult, an as TokenExchangeParams, as as UmaExchangeTicketParams, at as VerifiedLogoutToken, au as createOidcClient, av as isAccessDenied, aw as isExpiredToken } from '../oidcState-C3VLn3eD.js';
4
+ import { R as OidcClient, Y as OidcStateStore, Z as OidcTokenSet, X as OidcStateEntry } from '../oidcState-CZhj0MBP.js';
5
+ export { a as AuthorizationRequest, c as CibaAwaitParams, d as CibaClock, e as CibaDelivery, f as CibaInitiateParams, g as CibaInitiateResponse, h as CibaPingHeaders, i as CibaPollParams, j as CibaRequestSigner, k as CibaSignerDescription, l as CibaSigningAlg, m as CibaSigningKey, n as CibaUserHint, r as DeviceAuthorization, s as DeviceAuthorizeParams, t as DeviceLoginParams, u as DevicePollParams, E as ExchangedToken, F as FederationProvider, v as FederationProviderList, H as HANDOFF_CODE_TTL_SECS, w as HANDOFF_QUERY_PARAM, I as IntrospectParams, x as IntrospectionResult, L as LoginClientCredentialsParams, y as LoginWithProviderIdTokenOptions, z as LogoutUrlParams, G as MIN_DISCOVERY_TTL_MS, K as MemoryOidcStateStore, N as MtlsEndpointAliases, O as OIDC_STATE_TTL_MS, Q as OidcBeginParams, S as OidcClientOptions, T as OidcConfiguration, U as OidcExchangeParams, V as OidcParParams, W as OidcRefreshParams, _ as PROTOCOL_OAUTH2, $ as PROTOCOL_OIDC_CONNECT, a0 as PROTOCOL_SAML, a3 as PushedAuthorizationRequest, a4 as RequestedPermission, a5 as RequestingPartyToken, a6 as ResourceSet, a7 as RevokeParams, ah as SsoCompleteHandoffParams, ai as SsoCompleteOauth2Params, aj as SsoCompleteParams, ak as SsoCompleteResult, al as SsoProvidersParams, am as SsoStartOauth2Params, an as SsoStartParams, ao as SsoStartResult, aq as TokenExchangeParams, av as UmaExchangeTicketParams, aw as VerifiedLogoutToken, ax as createOidcClient, ay as isAccessDenied, az as isExpiredToken } from '../oidcState-CZhj0MBP.js';
6
6
  import { FastifyRequest, FastifyReply, FastifyPluginAsync, FastifyInstance } from 'fastify';
7
- export { F as FieldError, V as ValidationError } from '../errors-dlGXAsbh.js';
7
+ export { F as FieldError, V as ValidationError } from '../errors-DDo3oxcH.js';
8
8
  import { P as PresentedProofs } from '../jwks-CTVpOWzI.js';
9
9
  export { a as AccessTokenExpectations, A as AxiamClaims, b as CLOCK_SKEW_LEEWAY_SEC, C as CnfClaim, I as IdTokenClaims, V as Verifier, h as assertTenantClaim, i as certificateThumbprintS256, v as verifyCertificateBinding, k as verifyTokenBinding } from '../jwks-CTVpOWzI.js';
10
10
  export { D as DEFAULT_POLL_INTERVAL_MS, M as MAX_ENTRIES, a as MIN_POLL_INTERVAL_MS, R as RevocationFeed, b as RevocationFeedOptions } from '../revocationFeed-KQhvMMl8.js';
11
11
  import '../sensitive-BC_s7Rrd.js';
12
12
  import '../types-BOX-6Srv.js';
13
13
  import 'node:crypto';
14
- import '../errors-DZ3k8a8i.js';
15
- import '../session-B03NsqVs.js';
14
+ import '../errors-CWlh-wcm.js';
15
+ import '../session-Beo11VT_.js';
16
16
  import 'axios';
17
17
  import '../telemetry-Du0-zS5f.js';
18
18
 
@@ -37,11 +37,18 @@ var OAuthProtocolError = class _OAuthProtocolError extends AuthError {
37
37
  * OPTIONAL, and §2 (contract 1.53, §28.12.3) dispatches on `error` alone.
38
38
  */
39
39
  errorDescription;
40
- constructor(error, errorDescription = "") {
40
+ /**
41
+ * The server's `Retry-After` in milliseconds, when this error is a `429` that carried one in
42
+ * delta-seconds form (contract 1.65 §37.3, C165-17). Absent otherwise; an HTTP-date is not read.
43
+ * Additive: honour it before retrying a rate-limited native sign-in or CIBA call.
44
+ */
45
+ retryAfterMs;
46
+ constructor(error, errorDescription = "", retryAfterMs2) {
41
47
  super(errorDescription ? `${error}: ${errorDescription}` : error);
42
48
  this.name = "OAuthProtocolError";
43
49
  this.error = error;
44
50
  this.errorDescription = errorDescription;
51
+ if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
45
52
  Object.setPrototypeOf(this, _OAuthProtocolError.prototype);
46
53
  }
47
54
  };
@@ -102,7 +109,7 @@ function isOAuth2ErrorBody(body) {
102
109
  const record = body;
103
110
  return typeof record.error === "string" && typeof record.error_description === "string";
104
111
  }
105
- function oauth2ErrorFromBody(body) {
112
+ function oauth2ErrorFromBody(body, retryAfterMs2) {
106
113
  if (body === null || typeof body !== "object" || Array.isArray(body)) {
107
114
  return void 0;
108
115
  }
@@ -111,7 +118,7 @@ function oauth2ErrorFromBody(body) {
111
118
  return void 0;
112
119
  }
113
120
  const description = typeof record.error_description === "string" ? record.error_description : "";
114
- return new OAuthProtocolError(record.error, description);
121
+ return new OAuthProtocolError(record.error, description, retryAfterMs2);
115
122
  }
116
123
  var SAFE_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
117
124
  "content-type",
@@ -1555,9 +1562,9 @@ function pollRateLimit(err) {
1555
1562
  if (axiosStatus(err) !== 429) return void 0;
1556
1563
  const body = axiosBody(err);
1557
1564
  const description = body !== null && typeof body === "object" && typeof body.error_description === "string" ? body.error_description : "";
1558
- const limited = new OAuthProtocolError("rate_limit_exceeded", description);
1559
1565
  const response = err.response;
1560
1566
  const retryAfter = response ? retryAfterMs(response) : void 0;
1567
+ const limited = new OAuthProtocolError("rate_limit_exceeded", description, retryAfter);
1561
1568
  if (retryAfter !== void 0) POLL_RETRY_AFTER_MS.set(limited, retryAfter);
1562
1569
  return limited;
1563
1570
  }
@@ -1577,6 +1584,24 @@ var RESERVED_AUTHORIZE_PARAMS = /* @__PURE__ */ new Set([
1577
1584
  "code_challenge",
1578
1585
  "code_challenge_method"
1579
1586
  ]);
1587
+ var IDP_HINT_PARAM = "axiam_idp_hint";
1588
+ var IDP_HINT_MAX_BYTES = 256;
1589
+ var PROVIDER_ID_TOKEN_GRANT_TYPE = "urn:axiam:params:oauth:grant-type:provider-id-token";
1590
+ function checkIdpHint(operation, hint) {
1591
+ if (hint === "") {
1592
+ throw new ValidationError(operation, 400, `${operation}: idpHint must not be empty (CONTRACT.md \xA712.1)`, [
1593
+ { field: "idpHint", message: "must not be empty" }
1594
+ ]);
1595
+ }
1596
+ if (Buffer.byteLength(hint, "utf8") > IDP_HINT_MAX_BYTES) {
1597
+ throw new ValidationError(
1598
+ operation,
1599
+ 400,
1600
+ `${operation}: idpHint must be at most ${IDP_HINT_MAX_BYTES} bytes (CONTRACT.md \xA712.1)`,
1601
+ [{ field: "idpHint", message: `must be at most ${IDP_HINT_MAX_BYTES} bytes` }]
1602
+ );
1603
+ }
1604
+ }
1580
1605
  var UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1581
1606
  var DiscoveryCache = class {
1582
1607
  #documents = /* @__PURE__ */ new Map();
@@ -1639,11 +1664,25 @@ function bodyMessage(body, fallback) {
1639
1664
  }
1640
1665
  return fallback;
1641
1666
  }
1667
+ function beginUrlIdpHint(url) {
1668
+ try {
1669
+ const value = new URL(url).searchParams.get(IDP_HINT_PARAM);
1670
+ return value === null || value === "" ? void 0 : value;
1671
+ } catch {
1672
+ return void 0;
1673
+ }
1674
+ }
1675
+ function redirectRefused(operation, status) {
1676
+ return new NetworkError(`${operation}: the server answered HTTP ${status}; a redirect is never followed (CONTRACT.md \xA712.1 rule 3)`);
1677
+ }
1642
1678
  function mapOidcError(err, url, fallbackMessage) {
1643
1679
  if (err instanceof AxiamError) {
1644
1680
  return err;
1645
1681
  }
1646
1682
  const status = axiosStatus(err);
1683
+ if (status !== void 0 && status >= 300 && status < 400) {
1684
+ return redirectRefused(fallbackMessage, status);
1685
+ }
1647
1686
  if (status !== void 0) {
1648
1687
  const body = axiosBody(err);
1649
1688
  return mapHttpStatusToError(status, bodyMessage(body, fallbackMessage), { url, body, cause: err });
@@ -1813,7 +1852,8 @@ function jsonBody(data) {
1813
1852
  }
1814
1853
  }
1815
1854
  function cibaError(operation, response) {
1816
- return oauth2ErrorFromBody(jsonBody(response.data)) ?? mapHttpStatusToError(response.status, `${operation}: HTTP ${response.status}`);
1855
+ if (response.status >= 300 && response.status < 400) return redirectRefused(operation, response.status);
1856
+ return oauth2ErrorFromBody(jsonBody(response.data), response.status === 429 ? retryAfterMs(response) : void 0) ?? mapHttpStatusToError(response.status, `${operation}: HTTP ${response.status}`);
1817
1857
  }
1818
1858
  function authorizationValues(headers) {
1819
1859
  const out = [];
@@ -1882,15 +1922,19 @@ var OidcClient = class {
1882
1922
  * fresh PKCE verifier/challenge pair using **S256 only** — `plain` is not
1883
1923
  * implemented anywhere in this SDK. The URL is built from the discovery
1884
1924
  * document's `authorization_endpoint` with exactly the eight parameters
1885
- * §12.1 rule 5 mandates, plus any `extraParams` the caller adds.
1925
+ * §12.1 rule 5 mandates, plus any `extraParams` the caller adds and, when
1926
+ * `idpHint` is set, the one `axiam_idp_hint` (contract 1.65).
1886
1927
  *
1887
1928
  * Nothing is stored: persist the returned `state`, `nonce` and
1888
1929
  * `codeVerifier` yourself (§12.3 rule 1).
1889
1930
  *
1890
1931
  * @throws Error when `extraParams` tries to override one of the eight
1891
1932
  * SDK-owned parameters — a programming error, caught at call time.
1933
+ * @throws ValidationError when `idpHint` is empty or over 256 UTF-8 bytes;
1934
+ * no URL is built.
1892
1935
  */
1893
1936
  oidcBegin(params) {
1937
+ if (params.idpHint !== void 0) checkIdpHint("oidcBegin", params.idpHint);
1894
1938
  const state = randomUrlSafeToken();
1895
1939
  const nonce = randomUrlSafeToken();
1896
1940
  const codeVerifier = generateCodeVerifier();
@@ -1904,6 +1948,7 @@ var OidcClient = class {
1904
1948
  `oidcBegin: extraParams may not override the SDK-owned authorization parameter "${key}" (CONTRACT.md \xA712.1 rule 5).`
1905
1949
  );
1906
1950
  }
1951
+ if (key === IDP_HINT_PARAM && params.idpHint !== void 0) continue;
1907
1952
  query.set(key, value);
1908
1953
  }
1909
1954
  query.set("response_type", "code");
@@ -1914,6 +1959,7 @@ var OidcClient = class {
1914
1959
  query.set("nonce", nonce);
1915
1960
  query.set("code_challenge", codeChallenge);
1916
1961
  query.set("code_challenge_method", CODE_CHALLENGE_METHOD_S256);
1962
+ if (params.idpHint !== void 0) query.set(IDP_HINT_PARAM, params.idpHint);
1917
1963
  target.search = query.toString().replace(/\+/g, "%20");
1918
1964
  return { url: target.toString(), state, nonce, codeVerifier };
1919
1965
  }
@@ -2010,6 +2056,94 @@ var OidcClient = class {
2010
2056
  return tokenSet;
2011
2057
  }
2012
2058
  // -------------------------------------------------------------------------
2059
+ // §37 loginWithProviderIdToken
2060
+ // -------------------------------------------------------------------------
2061
+ /**
2062
+ * `POST /oauth2/token` with
2063
+ * `grant_type=urn:axiam:params:oauth:grant-type:provider-id-token`
2064
+ * (CONTRACT.md §37, contract 1.65) — sign a native-app user in with the ID
2065
+ * token a Google, Apple or Facebook Limited Login SDK produced.
2066
+ *
2067
+ * @param provider - The provider's UUID or its `provider_slug`, sent verbatim:
2068
+ * never trimmed, case-folded, resolved or looked up. A provider *kind* name
2069
+ * (`google`) is not accepted here unless the operator also chose it as the
2070
+ * slug (§37.2 rule 2).
2071
+ * @param idToken - The provider's ID token (a credential; wrapped or bare).
2072
+ * @param nonce - The **raw** nonce, byte for byte: the provider's SDK was
2073
+ * given `SHA-256(raw)` as hexadecimal (`nativeNonce()` produces the
2074
+ * pair). Never hashed, replaced or generated here (§37.2 rule 3).
2075
+ * @param options - `scopes`, `resource`, `tenantId`, `configuration`.
2076
+ *
2077
+ * @remarks
2078
+ * **Never retried** — not on a status, a `429` or a transport failure: the
2079
+ * provider's token is single-use across the deployment (§37.2 rule 10). An
2080
+ * `invalid_grant` is the server's one generic answer to every refusal of the
2081
+ * token and is neither retried nor refined; the recovery is a **fresh**
2082
+ * provider token with a **fresh** nonce. A transport failure after the
2083
+ * request left is indeterminate and surfaces as `NetworkError`.
2084
+ *
2085
+ * No `openid` or other scope is added: omit `scopes` and the response carries
2086
+ * no `id_token`. This is not token exchange (§15) and never falls back to it
2087
+ * or to a browser flow. A public client sends `client_id` alone; a client
2088
+ * configured with a `clientSecret` sends it in the body.
2089
+ *
2090
+ * The result is the ordinary {@link OidcTokenSet}; an `id_token`, when
2091
+ * present, is validated under §12.4 with the raw `nonce` as the expected
2092
+ * nonce. As with `deviceLogin`, the token set is **returned and not
2093
+ * adopted** as this client's credential (§37.2 rule 9).
2094
+ *
2095
+ * Neither the ID token nor the raw nonce is logged, put in an error, or kept
2096
+ * after the call returns; hold the raw nonce only for the length of the
2097
+ * attempt.
2098
+ *
2099
+ * @throws ValidationError (local, no request) for an empty `provider`,
2100
+ * `idToken` or `nonce`.
2101
+ * @throws AuthError (local, no request) for a slug-only client (§12.3 rule 4).
2102
+ * @throws OAuthProtocolError for a body carrying `error`, at any status.
2103
+ * @throws NetworkError for a transport failure or a body-less `5xx`.
2104
+ *
2105
+ * @example
2106
+ * ```ts
2107
+ * const { raw, hashed } = nativeNonce();
2108
+ * const idToken = await providerSdk.signIn({ nonce: hashed });
2109
+ * const tokens = await oidc.loginWithProviderIdToken('corp-google', idToken, raw, {
2110
+ * scopes: ['openid', 'profile'],
2111
+ * });
2112
+ * ```
2113
+ */
2114
+ async loginWithProviderIdToken(provider, idToken, nonce, options = {}) {
2115
+ const operation = "loginWithProviderIdToken";
2116
+ const refuse2 = (field) => new ValidationError(operation, 400, `${operation}: ${field} must not be empty (CONTRACT.md \xA737.2 rule 4)`, [
2117
+ { field, message: "must not be empty" }
2118
+ ]);
2119
+ const idTokenValue = typeof idToken === "string" ? idToken : idToken.expose();
2120
+ const nonceValue = typeof nonce === "string" ? nonce : nonce.expose();
2121
+ if (provider === "") throw refuse2("provider");
2122
+ if (idTokenValue === "") throw refuse2("idToken");
2123
+ if (nonceValue === "") throw refuse2("nonce");
2124
+ this.#resolveTenantId(options.tenantId);
2125
+ const configuration = options.configuration ?? await this.oidcDiscover();
2126
+ const form = new URLSearchParams();
2127
+ form.set("grant_type", PROVIDER_ID_TOKEN_GRANT_TYPE);
2128
+ form.set("client_id", this.#options.clientId);
2129
+ form.set("provider", provider);
2130
+ form.set("id_token", idTokenValue);
2131
+ form.set("nonce", nonceValue);
2132
+ if (options.scopes !== void 0 && options.scopes.length > 0) {
2133
+ form.set("scope", options.scopes.join(" "));
2134
+ }
2135
+ if (options.resource !== void 0) {
2136
+ form.set("resource", options.resource);
2137
+ }
2138
+ this.#appendClientSecret(form);
2139
+ const url = this.#endpointUrl(this.#requiredEndpoint(configuration, "token_endpoint"), options.tenantId);
2140
+ const response = await this.#postCibaForm(url, form, operation);
2141
+ if (response.status < 200 || response.status >= 300) {
2142
+ throw cibaError(operation, response);
2143
+ }
2144
+ return this.#toTokenSet(response.data, configuration, nonceValue);
2145
+ }
2146
+ // -------------------------------------------------------------------------
2013
2147
  // 6. introspect
2014
2148
  // -------------------------------------------------------------------------
2015
2149
  /**
@@ -2442,6 +2576,7 @@ var OidcClient = class {
2442
2576
  * ```
2443
2577
  */
2444
2578
  async oidcPar(params) {
2579
+ if (params.idpHint !== void 0) checkIdpHint("oidcPar", params.idpHint);
2445
2580
  const configuration = params.configuration ?? await this.oidcDiscover();
2446
2581
  const endpoint = this.#optionalEndpoint(configuration, "pushed_authorization_request_endpoint");
2447
2582
  if (!endpoint) {
@@ -2462,6 +2597,11 @@ var OidcClient = class {
2462
2597
  if (params.dpopJkt !== void 0) {
2463
2598
  form.set("dpop_jkt", params.dpopJkt);
2464
2599
  }
2600
+ const pushedHint = params.idpHint ?? beginUrlIdpHint(request.url);
2601
+ if (pushedHint !== void 0) {
2602
+ checkIdpHint("oidcPar", pushedHint);
2603
+ form.set(IDP_HINT_PARAM, pushedHint);
2604
+ }
2465
2605
  this.#appendClientSecret(form);
2466
2606
  const url = this.#endpointUrl(endpoint, params.tenantId);
2467
2607
  const { data } = await this.#postForm(
@@ -2808,7 +2948,8 @@ var OidcClient = class {
2808
2948
  let data;
2809
2949
  try {
2810
2950
  const config = {
2811
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
2951
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
2952
+ maxRedirects: 0
2812
2953
  };
2813
2954
  const response = await this.#session.axios.post(
2814
2955
  url,
@@ -3139,7 +3280,13 @@ var OidcClient = class {
3139
3280
  if (response.status >= 500) {
3140
3281
  throw transient(retryableNetworkError(`${operation}: HTTP ${response.status}`, response));
3141
3282
  }
3142
- const protocol = oauth2ErrorFromBody(jsonBody(response.data));
3283
+ if (response.status >= 300 && response.status < 400) {
3284
+ return { error: redirectRefused(operation, response.status) };
3285
+ }
3286
+ const protocol = oauth2ErrorFromBody(
3287
+ jsonBody(response.data),
3288
+ response.status === 429 ? retryAfterMs(response) : void 0
3289
+ );
3143
3290
  if (protocol) return { error: protocol };
3144
3291
  if (statusIsRetryable(response.status)) {
3145
3292
  throw transient(retryableNetworkError(`${operation}: HTTP ${response.status}`, response));
@@ -3297,7 +3444,8 @@ var OidcClient = class {
3297
3444
  try {
3298
3445
  return await this.#session.axios.post(url, form.toString(), {
3299
3446
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
3300
- validateStatus: () => true
3447
+ validateStatus: () => true,
3448
+ maxRedirects: 0
3301
3449
  });
3302
3450
  } catch (err) {
3303
3451
  const code = err && typeof err === "object" && typeof err.code === "string" ? ` (${err.code})` : "";
@@ -3317,7 +3465,8 @@ var OidcClient = class {
3317
3465
  async () => {
3318
3466
  try {
3319
3467
  const response = await this.#session.axios.post(url, form.toString(), {
3320
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
3468
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
3469
+ maxRedirects: 0
3321
3470
  });
3322
3471
  return { wire: response.data };
3323
3472
  } catch (err) {
@@ -3525,13 +3674,16 @@ var OidcClient = class {
3525
3674
  /** POST a form-encoded body (§12.1 note 1) through the session transport. */
3526
3675
  async #postForm(url, form, fallbackMessage) {
3527
3676
  const config = {
3528
- headers: { "Content-Type": "application/x-www-form-urlencoded" }
3677
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
3678
+ // §12.1 rule 3 (C165-14): never follow a redirect from an `/oauth2/*` POST.
3679
+ maxRedirects: 0
3529
3680
  };
3530
3681
  try {
3531
3682
  return await this.#session.axios.post(url, form.toString(), config);
3532
3683
  } catch (err) {
3533
3684
  if (axiosStatus(err) === 429) {
3534
- const protocol = oauth2ErrorFromBody(axiosBody(err));
3685
+ const raw = err.response;
3686
+ const protocol = oauth2ErrorFromBody(axiosBody(err), raw ? retryAfterMs(raw) : void 0);
3535
3687
  if (protocol) throw protocol;
3536
3688
  }
3537
3689
  throw mapOidcError(err, url, fallbackMessage);