cauthy-auth 0.38.2 → 0.39.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 +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -235,7 +235,7 @@ npx cauthy-auth init
|
|
|
235
235
|
npx cauthy-auth init --system ledger --app-url https://app.example.com # production
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
The same client is your application's own identity: it manages its organizations with no person's token.
|
|
238
|
+
The same client is your application's own identity: it manages its organizations with no person's token. When people sign in with a public client (no secret) and the application's identity is a confidential client beside it, give the key that client's id: `systemKey: { privateKey, keyId, clientId }`. Its sign-ins then carry the proof that tells Cauthy which application signed the person in, and from what address.
|
|
239
239
|
|
|
240
240
|
```ts
|
|
241
241
|
const org = await auth.system.organizations.create({ name: 'Acme' })
|
package/dist/index.js
CHANGED
|
@@ -1561,13 +1561,13 @@ function createCauthy(given = {}) {
|
|
|
1561
1561
|
return null;
|
|
1562
1562
|
}
|
|
1563
1563
|
}
|
|
1564
|
-
const clientIp = given.clientIp ?? ((request) => request.headers.get("x-forwarded-for")?.split(",").
|
|
1564
|
+
const clientIp = given.clientIp ?? ((request) => request.headers.get("x-forwarded-for")?.split(",").map((a) => a.trim()).reverse().find((a) => a !== "" && !ownNetwork(a)));
|
|
1565
1565
|
let noProofUntil = 0;
|
|
1566
1566
|
async function passedOn(request) {
|
|
1567
1567
|
if (Date.now() < noProofUntil) return {};
|
|
1568
1568
|
const ip = clientIp(request);
|
|
1569
1569
|
try {
|
|
1570
|
-
const proof = { "x-cauthy-system-token": await ownSystem.token() };
|
|
1570
|
+
const proof = { "x-cauthy-system-token": await ownSystem.token(), "x-cauthy-app-origin": originOf(request) };
|
|
1571
1571
|
return ip ? { ...proof, "x-cauthy-client-ip": ip } : proof;
|
|
1572
1572
|
} catch {
|
|
1573
1573
|
noProofUntil = Date.now() + 5 * 6e4;
|
|
@@ -2472,6 +2472,10 @@ function legalOf(raw) {
|
|
|
2472
2472
|
consentPurposes: purposes.map((p) => ({ key: String(p.key ?? ""), label: String(p.label ?? ""), required: p.required === true }))
|
|
2473
2473
|
};
|
|
2474
2474
|
}
|
|
2475
|
+
function ownNetwork(address) {
|
|
2476
|
+
const a = address.toLowerCase();
|
|
2477
|
+
return /^(127\.|10\.|192\.168\.|169\.254\.|0\.)/.test(a) || /^172\.(1[6-9]|2\d|3[01])\./.test(a) || a === "::1" || /^f[cd]/.test(a) || /^fe[89ab]/.test(a) || a.startsWith("::ffff:127.") || a === "localhost";
|
|
2478
|
+
}
|
|
2475
2479
|
|
|
2476
2480
|
// src/connect.ts
|
|
2477
2481
|
function sessionSecret() {
|