axiam-sdk 1.1.2 → 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.
- package/README.md +73 -3
- package/dist/amqp/index.js.map +1 -1
- package/dist/amqp/index.mjs.map +1 -1
- package/dist/browser/index.d.cts +1 -1
- package/dist/browser/index.d.ts +1 -1
- package/dist/{client-BGFn1VQh.d.cts → client-Bp7riC4k.d.cts} +147 -3
- package/dist/{client-DrQZZ1js.d.ts → client-CaurIxje.d.ts} +147 -3
- package/dist/{cookieJar-BTmpjXZe.d.ts → cookieJar-DC4GLKrJ.d.ts} +2 -2
- package/dist/{cookieJar-BqYOnNN-.d.cts → cookieJar-oKazfbN1.d.cts} +2 -2
- package/dist/{errors-DZ3k8a8i.d.cts → errors-CWlh-wcm.d.cts} +7 -1
- package/dist/{errors-DZ3k8a8i.d.ts → errors-CWlh-wcm.d.ts} +7 -1
- package/dist/{errors-dlGXAsbh.d.ts → errors-DDo3oxcH.d.ts} +1 -1
- package/dist/{errors-RvGlTyUj.d.cts → errors-DHauOsqx.d.cts} +1 -1
- package/dist/grpc/index.d.cts +4 -4
- package/dist/grpc/index.d.ts +4 -4
- package/dist/grpc/index.js +26 -5
- package/dist/grpc/index.js.map +1 -1
- package/dist/grpc/index.mjs +26 -5
- package/dist/grpc/index.mjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -5
- package/dist/index.mjs.map +1 -1
- package/dist/middleware/index.d.cts +5 -5
- package/dist/middleware/index.d.ts +5 -5
- package/dist/middleware/index.js +164 -12
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +164 -12
- package/dist/middleware/index.mjs.map +1 -1
- package/dist/nestjs/index.js.map +1 -1
- package/dist/nestjs/index.mjs.map +1 -1
- package/dist/node/index.d.cts +15 -4
- package/dist/node/index.d.ts +15 -4
- package/dist/node/index.js +186 -14
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +185 -15
- package/dist/node/index.mjs.map +1 -1
- package/dist/{oidcState-C3VLn3eD.d.ts → oidcState-CZhj0MBP.d.ts} +123 -5
- package/dist/{oidcState-BaJ-SM_R.d.cts → oidcState-EnEJmoF5.d.cts} +123 -5
- package/dist/rest/index.d.cts +6 -6
- package/dist/rest/index.d.ts +6 -6
- package/dist/rest/index.js +26 -5
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/index.mjs +26 -5
- package/dist/rest/index.mjs.map +1 -1
- package/dist/{session-B03NsqVs.d.ts → session-Beo11VT_.d.ts} +9 -0
- package/dist/{session-plDr4lFu.d.cts → session-CeIUXgpE.d.cts} +9 -0
- package/package.json +18 -18
package/dist/node/index.mjs
CHANGED
|
@@ -45,11 +45,18 @@ var OAuthProtocolError = class _OAuthProtocolError extends AuthError {
|
|
|
45
45
|
* OPTIONAL, and §2 (contract 1.53, §28.12.3) dispatches on `error` alone.
|
|
46
46
|
*/
|
|
47
47
|
errorDescription;
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The server's `Retry-After` in milliseconds, when this error is a `429` that carried one in
|
|
50
|
+
* delta-seconds form (contract 1.65 §37.3, C165-17). Absent otherwise; an HTTP-date is not read.
|
|
51
|
+
* Additive: honour it before retrying a rate-limited native sign-in or CIBA call.
|
|
52
|
+
*/
|
|
53
|
+
retryAfterMs;
|
|
54
|
+
constructor(error, errorDescription = "", retryAfterMs2) {
|
|
49
55
|
super(errorDescription ? `${error}: ${errorDescription}` : error);
|
|
50
56
|
this.name = "OAuthProtocolError";
|
|
51
57
|
this.error = error;
|
|
52
58
|
this.errorDescription = errorDescription;
|
|
59
|
+
if (retryAfterMs2 !== void 0) this.retryAfterMs = retryAfterMs2;
|
|
53
60
|
Object.setPrototypeOf(this, _OAuthProtocolError.prototype);
|
|
54
61
|
}
|
|
55
62
|
};
|
|
@@ -110,7 +117,7 @@ function isOAuth2ErrorBody(body) {
|
|
|
110
117
|
const record = body;
|
|
111
118
|
return typeof record.error === "string" && typeof record.error_description === "string";
|
|
112
119
|
}
|
|
113
|
-
function oauth2ErrorFromBody(body) {
|
|
120
|
+
function oauth2ErrorFromBody(body, retryAfterMs2) {
|
|
114
121
|
if (body === null || typeof body !== "object" || Array.isArray(body)) {
|
|
115
122
|
return void 0;
|
|
116
123
|
}
|
|
@@ -119,7 +126,7 @@ function oauth2ErrorFromBody(body) {
|
|
|
119
126
|
return void 0;
|
|
120
127
|
}
|
|
121
128
|
const description = typeof record.error_description === "string" ? record.error_description : "";
|
|
122
|
-
return new OAuthProtocolError(record.error, description);
|
|
129
|
+
return new OAuthProtocolError(record.error, description, retryAfterMs2);
|
|
123
130
|
}
|
|
124
131
|
var SAFE_RESPONSE_HEADERS = /* @__PURE__ */ new Set([
|
|
125
132
|
"content-type",
|
|
@@ -686,12 +693,21 @@ var SharedSession = class {
|
|
|
686
693
|
* The fetch adapter derives its `credentials` from `withCredentials: false`
|
|
687
694
|
* (`'omit'`); `fetchOptions.credentials` is set as well for adapters that
|
|
688
695
|
* read it.
|
|
696
|
+
*
|
|
697
|
+
* `fetchOptions.redirect: 'error'` is the browser persona's half of CONTRACT.md §12.1
|
|
698
|
+
* rule 3 ("No redirect is followed", C165-26). On the main client's `/oauth2/*` requests
|
|
699
|
+
* it makes `fetch` reject, which every caller maps to a `NetworkError` that carries
|
|
700
|
+
* neither the `Location` nor the request. Where `maxRedirects: 0` is set (the bare
|
|
701
|
+
* transport, `bareRequest`), axios's fetch adapter substitutes `redirect: 'manual'`
|
|
702
|
+
* (`lib/adapters/fetch.js`), so `'error'` is overridden there: the browser hands back an
|
|
703
|
+
* opaque-redirect (status 0), and `bareRequest` maps status 0 or any `3xx` to a
|
|
704
|
+
* `NetworkError` without the `Location` (`bareTransport.ts`).
|
|
689
705
|
* `NodeSession` overrides this to {@link noCredentialsConfig}: its jar-free
|
|
690
706
|
* agent pair is what keeps the cookies off there, and the fetch adapter
|
|
691
707
|
* would bypass that pair.
|
|
692
708
|
*/
|
|
693
709
|
oauth2RequestConfig() {
|
|
694
|
-
return { ...this.noCredentialsConfig(), adapter: "fetch", fetchOptions: { credentials: "omit" } };
|
|
710
|
+
return { ...this.noCredentialsConfig(), adapter: "fetch", fetchOptions: { credentials: "omit", redirect: "error" } };
|
|
695
711
|
}
|
|
696
712
|
};
|
|
697
713
|
function resolveTenantHeaderValue(options) {
|
|
@@ -1925,12 +1941,17 @@ async function bareRequest(session, operation, config) {
|
|
|
1925
1941
|
maxRedirects: 0,
|
|
1926
1942
|
validateStatus: () => true
|
|
1927
1943
|
});
|
|
1944
|
+
let response;
|
|
1928
1945
|
try {
|
|
1929
|
-
|
|
1946
|
+
response = await instance.request(config);
|
|
1930
1947
|
} catch (err) {
|
|
1931
1948
|
const code = err && typeof err === "object" && "code" in err && typeof err.code === "string" ? ` (${err.code})` : "";
|
|
1932
1949
|
throw new NetworkError(`${operation}: the request failed before any response arrived${code}`);
|
|
1933
1950
|
}
|
|
1951
|
+
if (response.status === 0 || response.status >= 300 && response.status < 400) {
|
|
1952
|
+
throw new NetworkError(`${operation}: the server answered with a redirect, which is not followed`);
|
|
1953
|
+
}
|
|
1954
|
+
return response;
|
|
1934
1955
|
}
|
|
1935
1956
|
function retryAfterMs(response) {
|
|
1936
1957
|
const raw = response.headers?.["retry-after"];
|
|
@@ -8917,6 +8938,10 @@ function generateCodeVerifier() {
|
|
|
8917
8938
|
function computeCodeChallenge(codeVerifier) {
|
|
8918
8939
|
return createHash("sha256").update(codeVerifier, "ascii").digest("base64url");
|
|
8919
8940
|
}
|
|
8941
|
+
function nativeNonce() {
|
|
8942
|
+
const raw = randomUrlSafeToken(CSPRNG_BYTES);
|
|
8943
|
+
return { raw: new Sensitive(raw), hashed: createHash("sha256").update(raw, "utf8").digest("hex") };
|
|
8944
|
+
}
|
|
8920
8945
|
|
|
8921
8946
|
// src/node/oidc.ts
|
|
8922
8947
|
var DISCOVERY_PATH = "/.well-known/openid-configuration";
|
|
@@ -9030,9 +9055,9 @@ function pollRateLimit(err) {
|
|
|
9030
9055
|
if (axiosStatus3(err) !== 429) return void 0;
|
|
9031
9056
|
const body = axiosBody(err);
|
|
9032
9057
|
const description = body !== null && typeof body === "object" && typeof body.error_description === "string" ? body.error_description : "";
|
|
9033
|
-
const limited = new OAuthProtocolError("rate_limit_exceeded", description);
|
|
9034
9058
|
const response = err.response;
|
|
9035
9059
|
const retryAfter = response ? retryAfterMs(response) : void 0;
|
|
9060
|
+
const limited = new OAuthProtocolError("rate_limit_exceeded", description, retryAfter);
|
|
9036
9061
|
if (retryAfter !== void 0) POLL_RETRY_AFTER_MS.set(limited, retryAfter);
|
|
9037
9062
|
return limited;
|
|
9038
9063
|
}
|
|
@@ -9052,6 +9077,24 @@ var RESERVED_AUTHORIZE_PARAMS = /* @__PURE__ */ new Set([
|
|
|
9052
9077
|
"code_challenge",
|
|
9053
9078
|
"code_challenge_method"
|
|
9054
9079
|
]);
|
|
9080
|
+
var IDP_HINT_PARAM = "axiam_idp_hint";
|
|
9081
|
+
var IDP_HINT_MAX_BYTES = 256;
|
|
9082
|
+
var PROVIDER_ID_TOKEN_GRANT_TYPE = "urn:axiam:params:oauth:grant-type:provider-id-token";
|
|
9083
|
+
function checkIdpHint(operation, hint) {
|
|
9084
|
+
if (hint === "") {
|
|
9085
|
+
throw new ValidationError(operation, 400, `${operation}: idpHint must not be empty (CONTRACT.md \xA712.1)`, [
|
|
9086
|
+
{ field: "idpHint", message: "must not be empty" }
|
|
9087
|
+
]);
|
|
9088
|
+
}
|
|
9089
|
+
if (Buffer.byteLength(hint, "utf8") > IDP_HINT_MAX_BYTES) {
|
|
9090
|
+
throw new ValidationError(
|
|
9091
|
+
operation,
|
|
9092
|
+
400,
|
|
9093
|
+
`${operation}: idpHint must be at most ${IDP_HINT_MAX_BYTES} bytes (CONTRACT.md \xA712.1)`,
|
|
9094
|
+
[{ field: "idpHint", message: `must be at most ${IDP_HINT_MAX_BYTES} bytes` }]
|
|
9095
|
+
);
|
|
9096
|
+
}
|
|
9097
|
+
}
|
|
9055
9098
|
var UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
9056
9099
|
var DiscoveryCache = class {
|
|
9057
9100
|
#documents = /* @__PURE__ */ new Map();
|
|
@@ -9114,11 +9157,25 @@ function bodyMessage(body, fallback) {
|
|
|
9114
9157
|
}
|
|
9115
9158
|
return fallback;
|
|
9116
9159
|
}
|
|
9160
|
+
function beginUrlIdpHint(url) {
|
|
9161
|
+
try {
|
|
9162
|
+
const value = new URL(url).searchParams.get(IDP_HINT_PARAM);
|
|
9163
|
+
return value === null || value === "" ? void 0 : value;
|
|
9164
|
+
} catch {
|
|
9165
|
+
return void 0;
|
|
9166
|
+
}
|
|
9167
|
+
}
|
|
9168
|
+
function redirectRefused(operation, status) {
|
|
9169
|
+
return new NetworkError(`${operation}: the server answered HTTP ${status}; a redirect is never followed (CONTRACT.md \xA712.1 rule 3)`);
|
|
9170
|
+
}
|
|
9117
9171
|
function mapOidcError(err, url, fallbackMessage) {
|
|
9118
9172
|
if (err instanceof AxiamError) {
|
|
9119
9173
|
return err;
|
|
9120
9174
|
}
|
|
9121
9175
|
const status = axiosStatus3(err);
|
|
9176
|
+
if (status !== void 0 && status >= 300 && status < 400) {
|
|
9177
|
+
return redirectRefused(fallbackMessage, status);
|
|
9178
|
+
}
|
|
9122
9179
|
if (status !== void 0) {
|
|
9123
9180
|
const body = axiosBody(err);
|
|
9124
9181
|
return mapHttpStatusToError(status, bodyMessage(body, fallbackMessage), { url, body, cause: err });
|
|
@@ -9288,7 +9345,8 @@ function jsonBody(data) {
|
|
|
9288
9345
|
}
|
|
9289
9346
|
}
|
|
9290
9347
|
function cibaError(operation, response) {
|
|
9291
|
-
|
|
9348
|
+
if (response.status >= 300 && response.status < 400) return redirectRefused(operation, response.status);
|
|
9349
|
+
return oauth2ErrorFromBody(jsonBody(response.data), response.status === 429 ? retryAfterMs(response) : void 0) ?? mapHttpStatusToError(response.status, `${operation}: HTTP ${response.status}`);
|
|
9292
9350
|
}
|
|
9293
9351
|
function authorizationValues(headers) {
|
|
9294
9352
|
const out = [];
|
|
@@ -9357,15 +9415,19 @@ var OidcClient = class {
|
|
|
9357
9415
|
* fresh PKCE verifier/challenge pair using **S256 only** — `plain` is not
|
|
9358
9416
|
* implemented anywhere in this SDK. The URL is built from the discovery
|
|
9359
9417
|
* document's `authorization_endpoint` with exactly the eight parameters
|
|
9360
|
-
* §12.1 rule 5 mandates, plus any `extraParams` the caller adds
|
|
9418
|
+
* §12.1 rule 5 mandates, plus any `extraParams` the caller adds and, when
|
|
9419
|
+
* `idpHint` is set, the one `axiam_idp_hint` (contract 1.65).
|
|
9361
9420
|
*
|
|
9362
9421
|
* Nothing is stored: persist the returned `state`, `nonce` and
|
|
9363
9422
|
* `codeVerifier` yourself (§12.3 rule 1).
|
|
9364
9423
|
*
|
|
9365
9424
|
* @throws Error when `extraParams` tries to override one of the eight
|
|
9366
9425
|
* SDK-owned parameters — a programming error, caught at call time.
|
|
9426
|
+
* @throws ValidationError when `idpHint` is empty or over 256 UTF-8 bytes;
|
|
9427
|
+
* no URL is built.
|
|
9367
9428
|
*/
|
|
9368
9429
|
oidcBegin(params) {
|
|
9430
|
+
if (params.idpHint !== void 0) checkIdpHint("oidcBegin", params.idpHint);
|
|
9369
9431
|
const state = randomUrlSafeToken();
|
|
9370
9432
|
const nonce = randomUrlSafeToken();
|
|
9371
9433
|
const codeVerifier = generateCodeVerifier();
|
|
@@ -9379,6 +9441,7 @@ var OidcClient = class {
|
|
|
9379
9441
|
`oidcBegin: extraParams may not override the SDK-owned authorization parameter "${key}" (CONTRACT.md \xA712.1 rule 5).`
|
|
9380
9442
|
);
|
|
9381
9443
|
}
|
|
9444
|
+
if (key === IDP_HINT_PARAM && params.idpHint !== void 0) continue;
|
|
9382
9445
|
query.set(key, value);
|
|
9383
9446
|
}
|
|
9384
9447
|
query.set("response_type", "code");
|
|
@@ -9389,6 +9452,7 @@ var OidcClient = class {
|
|
|
9389
9452
|
query.set("nonce", nonce);
|
|
9390
9453
|
query.set("code_challenge", codeChallenge);
|
|
9391
9454
|
query.set("code_challenge_method", CODE_CHALLENGE_METHOD_S256);
|
|
9455
|
+
if (params.idpHint !== void 0) query.set(IDP_HINT_PARAM, params.idpHint);
|
|
9392
9456
|
target.search = query.toString().replace(/\+/g, "%20");
|
|
9393
9457
|
return { url: target.toString(), state, nonce, codeVerifier };
|
|
9394
9458
|
}
|
|
@@ -9485,6 +9549,94 @@ var OidcClient = class {
|
|
|
9485
9549
|
return tokenSet;
|
|
9486
9550
|
}
|
|
9487
9551
|
// -------------------------------------------------------------------------
|
|
9552
|
+
// §37 loginWithProviderIdToken
|
|
9553
|
+
// -------------------------------------------------------------------------
|
|
9554
|
+
/**
|
|
9555
|
+
* `POST /oauth2/token` with
|
|
9556
|
+
* `grant_type=urn:axiam:params:oauth:grant-type:provider-id-token`
|
|
9557
|
+
* (CONTRACT.md §37, contract 1.65) — sign a native-app user in with the ID
|
|
9558
|
+
* token a Google, Apple or Facebook Limited Login SDK produced.
|
|
9559
|
+
*
|
|
9560
|
+
* @param provider - The provider's UUID or its `provider_slug`, sent verbatim:
|
|
9561
|
+
* never trimmed, case-folded, resolved or looked up. A provider *kind* name
|
|
9562
|
+
* (`google`) is not accepted here unless the operator also chose it as the
|
|
9563
|
+
* slug (§37.2 rule 2).
|
|
9564
|
+
* @param idToken - The provider's ID token (a credential; wrapped or bare).
|
|
9565
|
+
* @param nonce - The **raw** nonce, byte for byte: the provider's SDK was
|
|
9566
|
+
* given `SHA-256(raw)` as hexadecimal (`nativeNonce()` produces the
|
|
9567
|
+
* pair). Never hashed, replaced or generated here (§37.2 rule 3).
|
|
9568
|
+
* @param options - `scopes`, `resource`, `tenantId`, `configuration`.
|
|
9569
|
+
*
|
|
9570
|
+
* @remarks
|
|
9571
|
+
* **Never retried** — not on a status, a `429` or a transport failure: the
|
|
9572
|
+
* provider's token is single-use across the deployment (§37.2 rule 10). An
|
|
9573
|
+
* `invalid_grant` is the server's one generic answer to every refusal of the
|
|
9574
|
+
* token and is neither retried nor refined; the recovery is a **fresh**
|
|
9575
|
+
* provider token with a **fresh** nonce. A transport failure after the
|
|
9576
|
+
* request left is indeterminate and surfaces as `NetworkError`.
|
|
9577
|
+
*
|
|
9578
|
+
* No `openid` or other scope is added: omit `scopes` and the response carries
|
|
9579
|
+
* no `id_token`. This is not token exchange (§15) and never falls back to it
|
|
9580
|
+
* or to a browser flow. A public client sends `client_id` alone; a client
|
|
9581
|
+
* configured with a `clientSecret` sends it in the body.
|
|
9582
|
+
*
|
|
9583
|
+
* The result is the ordinary {@link OidcTokenSet}; an `id_token`, when
|
|
9584
|
+
* present, is validated under §12.4 with the raw `nonce` as the expected
|
|
9585
|
+
* nonce. As with `deviceLogin`, the token set is **returned and not
|
|
9586
|
+
* adopted** as this client's credential (§37.2 rule 9).
|
|
9587
|
+
*
|
|
9588
|
+
* Neither the ID token nor the raw nonce is logged, put in an error, or kept
|
|
9589
|
+
* after the call returns; hold the raw nonce only for the length of the
|
|
9590
|
+
* attempt.
|
|
9591
|
+
*
|
|
9592
|
+
* @throws ValidationError (local, no request) for an empty `provider`,
|
|
9593
|
+
* `idToken` or `nonce`.
|
|
9594
|
+
* @throws AuthError (local, no request) for a slug-only client (§12.3 rule 4).
|
|
9595
|
+
* @throws OAuthProtocolError for a body carrying `error`, at any status.
|
|
9596
|
+
* @throws NetworkError for a transport failure or a body-less `5xx`.
|
|
9597
|
+
*
|
|
9598
|
+
* @example
|
|
9599
|
+
* ```ts
|
|
9600
|
+
* const { raw, hashed } = nativeNonce();
|
|
9601
|
+
* const idToken = await providerSdk.signIn({ nonce: hashed });
|
|
9602
|
+
* const tokens = await oidc.loginWithProviderIdToken('corp-google', idToken, raw, {
|
|
9603
|
+
* scopes: ['openid', 'profile'],
|
|
9604
|
+
* });
|
|
9605
|
+
* ```
|
|
9606
|
+
*/
|
|
9607
|
+
async loginWithProviderIdToken(provider, idToken, nonce, options = {}) {
|
|
9608
|
+
const operation = "loginWithProviderIdToken";
|
|
9609
|
+
const refuse = (field) => new ValidationError(operation, 400, `${operation}: ${field} must not be empty (CONTRACT.md \xA737.2 rule 4)`, [
|
|
9610
|
+
{ field, message: "must not be empty" }
|
|
9611
|
+
]);
|
|
9612
|
+
const idTokenValue = typeof idToken === "string" ? idToken : idToken.expose();
|
|
9613
|
+
const nonceValue = typeof nonce === "string" ? nonce : nonce.expose();
|
|
9614
|
+
if (provider === "") throw refuse("provider");
|
|
9615
|
+
if (idTokenValue === "") throw refuse("idToken");
|
|
9616
|
+
if (nonceValue === "") throw refuse("nonce");
|
|
9617
|
+
this.#resolveTenantId(options.tenantId);
|
|
9618
|
+
const configuration = options.configuration ?? await this.oidcDiscover();
|
|
9619
|
+
const form = new URLSearchParams();
|
|
9620
|
+
form.set("grant_type", PROVIDER_ID_TOKEN_GRANT_TYPE);
|
|
9621
|
+
form.set("client_id", this.#options.clientId);
|
|
9622
|
+
form.set("provider", provider);
|
|
9623
|
+
form.set("id_token", idTokenValue);
|
|
9624
|
+
form.set("nonce", nonceValue);
|
|
9625
|
+
if (options.scopes !== void 0 && options.scopes.length > 0) {
|
|
9626
|
+
form.set("scope", options.scopes.join(" "));
|
|
9627
|
+
}
|
|
9628
|
+
if (options.resource !== void 0) {
|
|
9629
|
+
form.set("resource", options.resource);
|
|
9630
|
+
}
|
|
9631
|
+
this.#appendClientSecret(form);
|
|
9632
|
+
const url = this.#endpointUrl(this.#requiredEndpoint(configuration, "token_endpoint"), options.tenantId);
|
|
9633
|
+
const response = await this.#postCibaForm(url, form, operation);
|
|
9634
|
+
if (response.status < 200 || response.status >= 300) {
|
|
9635
|
+
throw cibaError(operation, response);
|
|
9636
|
+
}
|
|
9637
|
+
return this.#toTokenSet(response.data, configuration, nonceValue);
|
|
9638
|
+
}
|
|
9639
|
+
// -------------------------------------------------------------------------
|
|
9488
9640
|
// 6. introspect
|
|
9489
9641
|
// -------------------------------------------------------------------------
|
|
9490
9642
|
/**
|
|
@@ -9917,6 +10069,7 @@ var OidcClient = class {
|
|
|
9917
10069
|
* ```
|
|
9918
10070
|
*/
|
|
9919
10071
|
async oidcPar(params) {
|
|
10072
|
+
if (params.idpHint !== void 0) checkIdpHint("oidcPar", params.idpHint);
|
|
9920
10073
|
const configuration = params.configuration ?? await this.oidcDiscover();
|
|
9921
10074
|
const endpoint = this.#optionalEndpoint(configuration, "pushed_authorization_request_endpoint");
|
|
9922
10075
|
if (!endpoint) {
|
|
@@ -9937,6 +10090,11 @@ var OidcClient = class {
|
|
|
9937
10090
|
if (params.dpopJkt !== void 0) {
|
|
9938
10091
|
form.set("dpop_jkt", params.dpopJkt);
|
|
9939
10092
|
}
|
|
10093
|
+
const pushedHint = params.idpHint ?? beginUrlIdpHint(request.url);
|
|
10094
|
+
if (pushedHint !== void 0) {
|
|
10095
|
+
checkIdpHint("oidcPar", pushedHint);
|
|
10096
|
+
form.set(IDP_HINT_PARAM, pushedHint);
|
|
10097
|
+
}
|
|
9940
10098
|
this.#appendClientSecret(form);
|
|
9941
10099
|
const url = this.#endpointUrl(endpoint, params.tenantId);
|
|
9942
10100
|
const { data } = await this.#postForm(
|
|
@@ -10283,7 +10441,8 @@ var OidcClient = class {
|
|
|
10283
10441
|
let data;
|
|
10284
10442
|
try {
|
|
10285
10443
|
const config = {
|
|
10286
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
10444
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
10445
|
+
maxRedirects: 0
|
|
10287
10446
|
};
|
|
10288
10447
|
const response = await this.#session.axios.post(
|
|
10289
10448
|
url,
|
|
@@ -10614,7 +10773,13 @@ var OidcClient = class {
|
|
|
10614
10773
|
if (response.status >= 500) {
|
|
10615
10774
|
throw transient(retryableNetworkError(`${operation}: HTTP ${response.status}`, response));
|
|
10616
10775
|
}
|
|
10617
|
-
|
|
10776
|
+
if (response.status >= 300 && response.status < 400) {
|
|
10777
|
+
return { error: redirectRefused(operation, response.status) };
|
|
10778
|
+
}
|
|
10779
|
+
const protocol = oauth2ErrorFromBody(
|
|
10780
|
+
jsonBody(response.data),
|
|
10781
|
+
response.status === 429 ? retryAfterMs(response) : void 0
|
|
10782
|
+
);
|
|
10618
10783
|
if (protocol) return { error: protocol };
|
|
10619
10784
|
if (statusIsRetryable(response.status)) {
|
|
10620
10785
|
throw transient(retryableNetworkError(`${operation}: HTTP ${response.status}`, response));
|
|
@@ -10772,7 +10937,8 @@ var OidcClient = class {
|
|
|
10772
10937
|
try {
|
|
10773
10938
|
return await this.#session.axios.post(url, form.toString(), {
|
|
10774
10939
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
10775
|
-
validateStatus: () => true
|
|
10940
|
+
validateStatus: () => true,
|
|
10941
|
+
maxRedirects: 0
|
|
10776
10942
|
});
|
|
10777
10943
|
} catch (err) {
|
|
10778
10944
|
const code = err && typeof err === "object" && typeof err.code === "string" ? ` (${err.code})` : "";
|
|
@@ -10792,7 +10958,8 @@ var OidcClient = class {
|
|
|
10792
10958
|
async () => {
|
|
10793
10959
|
try {
|
|
10794
10960
|
const response = await this.#session.axios.post(url, form.toString(), {
|
|
10795
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
10961
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
10962
|
+
maxRedirects: 0
|
|
10796
10963
|
});
|
|
10797
10964
|
return { wire: response.data };
|
|
10798
10965
|
} catch (err) {
|
|
@@ -11000,13 +11167,16 @@ var OidcClient = class {
|
|
|
11000
11167
|
/** POST a form-encoded body (§12.1 note 1) through the session transport. */
|
|
11001
11168
|
async #postForm(url, form, fallbackMessage) {
|
|
11002
11169
|
const config = {
|
|
11003
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
11170
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
11171
|
+
// §12.1 rule 3 (C165-14): never follow a redirect from an `/oauth2/*` POST.
|
|
11172
|
+
maxRedirects: 0
|
|
11004
11173
|
};
|
|
11005
11174
|
try {
|
|
11006
11175
|
return await this.#session.axios.post(url, form.toString(), config);
|
|
11007
11176
|
} catch (err) {
|
|
11008
11177
|
if (axiosStatus3(err) === 429) {
|
|
11009
|
-
const
|
|
11178
|
+
const raw = err.response;
|
|
11179
|
+
const protocol = oauth2ErrorFromBody(axiosBody(err), raw ? retryAfterMs(raw) : void 0);
|
|
11010
11180
|
if (protocol) throw protocol;
|
|
11011
11181
|
}
|
|
11012
11182
|
throw mapOidcError(err, url, fallbackMessage);
|
|
@@ -11744,6 +11914,6 @@ function parseJsonQuiet(data) {
|
|
|
11744
11914
|
}
|
|
11745
11915
|
}
|
|
11746
11916
|
|
|
11747
|
-
export { ACCESS_COOKIE, ACCESS_TOKEN_TYPE, BACKCHANNEL_LOGOUT_EVENT, CIBA_GRANT_TYPE, CIBA_SLOW_DOWN_INCREMENT_SECS, CLOCK_SKEW_LEEWAY_SEC, CODE_CHALLENGE_METHOD_S256, CSPRNG_BYTES, CSRF_COOKIE, CibaRequestSigner, DEFAULT_CIBA_INTERVAL_SECS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_INTERVAL_SECS, DEFAULT_WEBHOOK_TOLERANCE_SEC, DEVICE_CODE_GRANT_TYPE, DISCOVERY_PATH, DPOP_IAT_LEEWAY_SEC, HANDOFF_CODE_TTL_SECS, HANDOFF_QUERY_PARAM, ID_TOKEN_ALG, InMemoryJtiStore, JWKS_PATH, JWKS_REFETCH_INTERVAL_MS, JWT_TOKEN_TYPE, MAX_CLOCK_SKEW_SEC, MAX_ENTRIES2 as MAX_ENTRIES, MAX_LOGOUT_TOKEN_AGE_SECS, MIN_DISCOVERY_TTL_MS, MIN_POLL_INTERVAL_MS, MIN_REPLAY_WINDOW_MS, MemoryOidcStateStore, MemoryReplayStore, NodeSession, OIDC_STATE_TTL_MS, OidcClient, PROTOCOL_OAUTH2, PROTOCOL_OIDC_CONNECT, PROTOCOL_SAML, PollSchedule, REFRESH_COOKIE, RevocationFeed, SIGNED_REQUEST_LIFETIME_SECS, SLOW_DOWN_INCREMENT_SECS, SSF_EVENT_TYPES, SSO_CALLBACK_PATH, SSO_HANDOFF_PATH, SSO_OAUTH2_CALLBACK_PATH, SSO_OAUTH2_START_PATH, SSO_PROVIDERS_PATH, SSO_START_PATH, Sensitive, SetRefusedError, SsfReceiver, TOKEN_EXCHANGE_GRANT_TYPE, TokenManager, UMA_CLAIM_TOKEN_FORMAT, UMA_PROTECTION_SCOPE, UMA_TICKET_GRANT_TYPE, WebhookVerifyError, accessTokenHash, assertTenantClaim, canonicalHtu, certificateThumbprintS256, computeCodeChallenge, createJar, createJwksVerifier, createNodeClient, createNodeSession, createOidcClient, createVerifier, extractCookieValue, generateCodeVerifier, isAccessDenied, isExpiredToken, jwkThumbprintS256, normalizeOrigin, pushErrorCode, randomUrlSafeToken, setErrFromReason, umaChallengeHeader, umaParseChallenge, verifyCertificateBinding, verifyDpopProof, verifyTokenBinding, verifyWebhook, wrapAxios };
|
|
11917
|
+
export { ACCESS_COOKIE, ACCESS_TOKEN_TYPE, BACKCHANNEL_LOGOUT_EVENT, CIBA_GRANT_TYPE, CIBA_SLOW_DOWN_INCREMENT_SECS, CLOCK_SKEW_LEEWAY_SEC, CODE_CHALLENGE_METHOD_S256, CSPRNG_BYTES, CSRF_COOKIE, CibaRequestSigner, DEFAULT_CIBA_INTERVAL_SECS, DEFAULT_POLL_INTERVAL_MS, DEFAULT_POLL_INTERVAL_SECS, DEFAULT_WEBHOOK_TOLERANCE_SEC, DEVICE_CODE_GRANT_TYPE, DISCOVERY_PATH, DPOP_IAT_LEEWAY_SEC, HANDOFF_CODE_TTL_SECS, HANDOFF_QUERY_PARAM, ID_TOKEN_ALG, InMemoryJtiStore, JWKS_PATH, JWKS_REFETCH_INTERVAL_MS, JWT_TOKEN_TYPE, MAX_CLOCK_SKEW_SEC, MAX_ENTRIES2 as MAX_ENTRIES, MAX_LOGOUT_TOKEN_AGE_SECS, MIN_DISCOVERY_TTL_MS, MIN_POLL_INTERVAL_MS, MIN_REPLAY_WINDOW_MS, MemoryOidcStateStore, MemoryReplayStore, NodeSession, OIDC_STATE_TTL_MS, OidcClient, PROTOCOL_OAUTH2, PROTOCOL_OIDC_CONNECT, PROTOCOL_SAML, PROVIDER_ID_TOKEN_GRANT_TYPE, PollSchedule, REFRESH_COOKIE, RevocationFeed, SIGNED_REQUEST_LIFETIME_SECS, SLOW_DOWN_INCREMENT_SECS, SSF_EVENT_TYPES, SSO_CALLBACK_PATH, SSO_HANDOFF_PATH, SSO_OAUTH2_CALLBACK_PATH, SSO_OAUTH2_START_PATH, SSO_PROVIDERS_PATH, SSO_START_PATH, Sensitive, SetRefusedError, SsfReceiver, TOKEN_EXCHANGE_GRANT_TYPE, TokenManager, UMA_CLAIM_TOKEN_FORMAT, UMA_PROTECTION_SCOPE, UMA_TICKET_GRANT_TYPE, WebhookVerifyError, accessTokenHash, assertTenantClaim, canonicalHtu, certificateThumbprintS256, computeCodeChallenge, createJar, createJwksVerifier, createNodeClient, createNodeSession, createOidcClient, createVerifier, extractCookieValue, generateCodeVerifier, isAccessDenied, isExpiredToken, jwkThumbprintS256, nativeNonce, normalizeOrigin, pushErrorCode, randomUrlSafeToken, setErrFromReason, umaChallengeHeader, umaParseChallenge, verifyCertificateBinding, verifyDpopProof, verifyTokenBinding, verifyWebhook, wrapAxios };
|
|
11748
11918
|
//# sourceMappingURL=index.mjs.map
|
|
11749
11919
|
//# sourceMappingURL=index.mjs.map
|