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 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. 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.
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. The proof also goes with the code exchange at the end of a sign-in through Cauthy's page, which a contract can require (`sign_in.require_system_proof`).
239
239
 
240
240
  ```ts
241
241
  const org = await auth.system.organizations.create({ name: 'Acme' })
package/dist/index.js CHANGED
@@ -1212,13 +1212,13 @@ function createCauthy(given = {}) {
1212
1212
  return proto === "https" || proto === "http" ? `${proto}://${url.host}` : url.origin;
1213
1213
  };
1214
1214
  const attrs = (request, maxAge) => ({ secure: originOf(request).startsWith("https://"), maxAge });
1215
- async function token(form) {
1215
+ async function token(form, proof = {}) {
1216
1216
  const body2 = new URLSearchParams({ client_id: clientId, ...form });
1217
1217
  if (clientSecret) body2.set("client_secret", clientSecret);
1218
1218
  try {
1219
1219
  const res = await doFetch(`${issuer}/v1/oauth/token`, {
1220
1220
  method: "POST",
1221
- headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
1221
+ headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json", ...proof },
1222
1222
  body: body2
1223
1223
  });
1224
1224
  if (res.ok) return { ok: true, body: await res.json() };
@@ -1458,7 +1458,7 @@ function createCauthy(given = {}) {
1458
1458
  code,
1459
1459
  redirect_uri: `${originOf(request)}${basePath}/callback`,
1460
1460
  code_verifier: flow.verifier
1461
- });
1461
+ }, await passedOn(request));
1462
1462
  const s = res.ok ? await stored(res.body) : null;
1463
1463
  if (s === null) return failed(request, "exchange_failed");
1464
1464
  return redirect(flow.returnTo, [...await write(request, s, had), writeCookie(flowCookie, "", attrs(request, 0)), writeCookie(againCookie, "", attrs(request, 0))]);
@@ -1570,7 +1570,7 @@ function createCauthy(given = {}) {
1570
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
- noProofUntil = Date.now() + 5 * 6e4;
1573
+ noProofUntil = Date.now() + 3e4;
1574
1574
  return {};
1575
1575
  }
1576
1576
  }