cauthy-auth 0.24.1 → 0.24.3
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/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -918,6 +918,25 @@ function createCauthy(given = {}) {
|
|
|
918
918
|
orgCache.set(session.accessToken, { at: Date.now(), value });
|
|
919
919
|
return value;
|
|
920
920
|
}
|
|
921
|
+
const forgetting = (fn) => async (...args) => {
|
|
922
|
+
const out2 = await fn(...args);
|
|
923
|
+
orgCache.clear();
|
|
924
|
+
return out2;
|
|
925
|
+
};
|
|
926
|
+
const systemThatRefreshes = {
|
|
927
|
+
...ownSystem,
|
|
928
|
+
organizations: {
|
|
929
|
+
...ownSystem.organizations,
|
|
930
|
+
update: forgetting(ownSystem.organizations.update),
|
|
931
|
+
remove: forgetting(ownSystem.organizations.remove)
|
|
932
|
+
},
|
|
933
|
+
members: {
|
|
934
|
+
...ownSystem.members,
|
|
935
|
+
add: forgetting(ownSystem.members.add),
|
|
936
|
+
setRole: forgetting(ownSystem.members.setRole),
|
|
937
|
+
remove: forgetting(ownSystem.members.remove)
|
|
938
|
+
}
|
|
939
|
+
};
|
|
921
940
|
async function toPublic(session) {
|
|
922
941
|
let orgs = [];
|
|
923
942
|
try {
|
|
@@ -1078,10 +1097,11 @@ function createCauthy(given = {}) {
|
|
|
1078
1097
|
const clientIp = given.clientIp ?? ((request) => request.headers.get("x-forwarded-for")?.split(",").pop()?.trim() || void 0);
|
|
1079
1098
|
let noProofUntil = 0;
|
|
1080
1099
|
async function passedOn(request) {
|
|
1100
|
+
if (Date.now() < noProofUntil) return {};
|
|
1081
1101
|
const ip = clientIp(request);
|
|
1082
|
-
if (!ip || Date.now() < noProofUntil) return {};
|
|
1083
1102
|
try {
|
|
1084
|
-
|
|
1103
|
+
const proof = { "x-cauthy-system-token": await ownSystem.token() };
|
|
1104
|
+
return ip ? { ...proof, "x-cauthy-client-ip": ip } : proof;
|
|
1085
1105
|
} catch {
|
|
1086
1106
|
noProofUntil = Date.now() + 5 * 6e4;
|
|
1087
1107
|
return {};
|
|
@@ -1828,7 +1848,7 @@ function createCauthy(given = {}) {
|
|
|
1828
1848
|
return {
|
|
1829
1849
|
handler,
|
|
1830
1850
|
webhook,
|
|
1831
|
-
system:
|
|
1851
|
+
system: systemThatRefreshes,
|
|
1832
1852
|
getSession,
|
|
1833
1853
|
status,
|
|
1834
1854
|
resolve: resolve2,
|