cauthy-auth 0.39.0 → 0.40.0
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 +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1157,13 +1157,13 @@ function createCauthy(given = {}) {
|
|
|
1157
1157
|
return proto === "https" || proto === "http" ? `${proto}://${url.host}` : url.origin;
|
|
1158
1158
|
};
|
|
1159
1159
|
const attrs = (request, maxAge) => ({ secure: originOf(request).startsWith("https://"), maxAge });
|
|
1160
|
-
async function token(form) {
|
|
1160
|
+
async function token(form, proof = {}) {
|
|
1161
1161
|
const body2 = new URLSearchParams({ client_id: clientId, ...form });
|
|
1162
1162
|
if (clientSecret) body2.set("client_secret", clientSecret);
|
|
1163
1163
|
try {
|
|
1164
1164
|
const res = await doFetch(`${issuer}/v1/oauth/token`, {
|
|
1165
1165
|
method: "POST",
|
|
1166
|
-
headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
|
|
1166
|
+
headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json", ...proof },
|
|
1167
1167
|
body: body2
|
|
1168
1168
|
});
|
|
1169
1169
|
if (res.ok) return { ok: true, body: await res.json() };
|
|
@@ -1403,7 +1403,7 @@ function createCauthy(given = {}) {
|
|
|
1403
1403
|
code,
|
|
1404
1404
|
redirect_uri: `${originOf(request)}${basePath}/callback`,
|
|
1405
1405
|
code_verifier: flow.verifier
|
|
1406
|
-
});
|
|
1406
|
+
}, await passedOn(request));
|
|
1407
1407
|
const s = res.ok ? await stored(res.body) : null;
|
|
1408
1408
|
if (s === null) return failed(request, "exchange_failed");
|
|
1409
1409
|
return redirect(flow.returnTo, [...await write(request, s, had), writeCookie(flowCookie, "", attrs(request, 0)), writeCookie(againCookie, "", attrs(request, 0))]);
|
|
@@ -1515,7 +1515,7 @@ function createCauthy(given = {}) {
|
|
|
1515
1515
|
const proof = { "x-cauthy-system-token": await ownSystem.token(), "x-cauthy-app-origin": originOf(request) };
|
|
1516
1516
|
return ip ? { ...proof, "x-cauthy-client-ip": ip } : proof;
|
|
1517
1517
|
} catch {
|
|
1518
|
-
noProofUntil = Date.now() +
|
|
1518
|
+
noProofUntil = Date.now() + 3e4;
|
|
1519
1519
|
return {};
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|