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.js
CHANGED
|
@@ -966,6 +966,25 @@ function createCauthy(given = {}) {
|
|
|
966
966
|
orgCache.set(session.accessToken, { at: Date.now(), value });
|
|
967
967
|
return value;
|
|
968
968
|
}
|
|
969
|
+
const forgetting = (fn) => async (...args) => {
|
|
970
|
+
const out2 = await fn(...args);
|
|
971
|
+
orgCache.clear();
|
|
972
|
+
return out2;
|
|
973
|
+
};
|
|
974
|
+
const systemThatRefreshes = {
|
|
975
|
+
...ownSystem,
|
|
976
|
+
organizations: {
|
|
977
|
+
...ownSystem.organizations,
|
|
978
|
+
update: forgetting(ownSystem.organizations.update),
|
|
979
|
+
remove: forgetting(ownSystem.organizations.remove)
|
|
980
|
+
},
|
|
981
|
+
members: {
|
|
982
|
+
...ownSystem.members,
|
|
983
|
+
add: forgetting(ownSystem.members.add),
|
|
984
|
+
setRole: forgetting(ownSystem.members.setRole),
|
|
985
|
+
remove: forgetting(ownSystem.members.remove)
|
|
986
|
+
}
|
|
987
|
+
};
|
|
969
988
|
async function toPublic(session) {
|
|
970
989
|
let orgs = [];
|
|
971
990
|
try {
|
|
@@ -1126,10 +1145,11 @@ function createCauthy(given = {}) {
|
|
|
1126
1145
|
const clientIp = given.clientIp ?? ((request) => request.headers.get("x-forwarded-for")?.split(",").pop()?.trim() || void 0);
|
|
1127
1146
|
let noProofUntil = 0;
|
|
1128
1147
|
async function passedOn(request) {
|
|
1148
|
+
if (Date.now() < noProofUntil) return {};
|
|
1129
1149
|
const ip = clientIp(request);
|
|
1130
|
-
if (!ip || Date.now() < noProofUntil) return {};
|
|
1131
1150
|
try {
|
|
1132
|
-
|
|
1151
|
+
const proof = { "x-cauthy-system-token": await ownSystem.token() };
|
|
1152
|
+
return ip ? { ...proof, "x-cauthy-client-ip": ip } : proof;
|
|
1133
1153
|
} catch {
|
|
1134
1154
|
noProofUntil = Date.now() + 5 * 6e4;
|
|
1135
1155
|
return {};
|
|
@@ -1876,7 +1896,7 @@ function createCauthy(given = {}) {
|
|
|
1876
1896
|
return {
|
|
1877
1897
|
handler,
|
|
1878
1898
|
webhook,
|
|
1879
|
-
system:
|
|
1899
|
+
system: systemThatRefreshes,
|
|
1880
1900
|
getSession,
|
|
1881
1901
|
status,
|
|
1882
1902
|
resolve: resolve2,
|