cauthy-auth 0.17.0 → 0.19.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/dist/index.mjs CHANGED
@@ -994,6 +994,7 @@ function createCauthy(given = {}) {
994
994
  const passkeyOf = (d) => ({
995
995
  id: String(d?.id ?? ""),
996
996
  name: String(d?.nickname ?? ""),
997
+ kind: ["security_key", "synced", "device"].includes(d?.kind) ? d.kind : "unknown",
997
998
  createdAt: String(d?.created_at ?? ""),
998
999
  lastUsedAt: d?.last_used_at ? String(d.last_used_at) : null
999
1000
  });
@@ -1409,7 +1410,8 @@ function createCauthy(given = {}) {
1409
1410
  return json({ status: "unlinked", provider }, 200, mine.headers);
1410
1411
  }
1411
1412
  if (route === "/me/passkeys/add/begin") {
1412
- const res = await as("/v1/auth/webauthn/register/begin", { password });
1413
+ const kind = b.kind === "device" || b.kind === "security_key" ? b.kind : "";
1414
+ const res = await as("/v1/auth/webauthn/register/begin", { password, ...kind ? { kind } : {} });
1413
1415
  if (res.error) return refused(res, res.error.code === "step_up_required" ? "password" : void 0);
1414
1416
  const step = { kind: "enrol", token: String(res.data?.session_id ?? ""), returnTo: afterSignIn };
1415
1417
  const h = new Headers(mine.headers);
@@ -1469,7 +1471,8 @@ function createCauthy(given = {}) {
1469
1471
  return json({ status: "verified" });
1470
1472
  }
1471
1473
  if (route === "/sign-in/passkey/begin") {
1472
- const res = await ask(request, "POST", "/v1/auth/webauthn/login/begin", {});
1474
+ const email = typeof b.email === "string" && checkEmail(b.email) === null ? b.email.trim() : "";
1475
+ const res = await ask(request, "POST", "/v1/auth/webauthn/login/begin", email !== "" ? { email } : {});
1473
1476
  if (res.error) return problem(res.status, res.error.code, res.error.message);
1474
1477
  const step = { kind: "passkey", token: String(res.data?.session_id ?? ""), returnTo: afterSignIn };
1475
1478
  return json(