cauthy-auth 0.25.0 → 0.26.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/client.d.mts +24 -4
- package/dist/client.d.ts +24 -4
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +1 -0
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +27 -4
- package/dist/react.d.ts +27 -4
- package/dist/react.js +16 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +16 -2
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.js +1 -0
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +1 -0
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +1 -0
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +1 -0
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1243,6 +1243,7 @@ function createCauthy(given = {}) {
|
|
|
1243
1243
|
"/me/mfa/phone/remove",
|
|
1244
1244
|
"/sign-in/mfa/methods",
|
|
1245
1245
|
"/sign-in/mfa/send",
|
|
1246
|
+
"/sign-in/mfa/email",
|
|
1246
1247
|
"/sign-in/mfa/push",
|
|
1247
1248
|
"/sign-in/mfa/push/events",
|
|
1248
1249
|
"/sign-in/mfa/push/finish",
|
|
@@ -1536,7 +1537,8 @@ function createCauthy(given = {}) {
|
|
|
1536
1537
|
if (res.error) return problem(res.status, res.error.code, res.error.message);
|
|
1537
1538
|
if (res.data?.mfa_required === true) {
|
|
1538
1539
|
const step = { kind: "mfa", token: String(res.data.mfa_token ?? ""), returnTo: afterSignIn };
|
|
1539
|
-
|
|
1540
|
+
const how = res.data.mfa_method === "email" ? { method: "email" } : {};
|
|
1541
|
+
return json({ status: "mfa_required", ...how }, 200, new Headers({ "set-cookie": writeCookie(stepCookie, await seal(step, await key), attrs(request, STEP_SECONDS)) }));
|
|
1540
1542
|
}
|
|
1541
1543
|
return signedIn(request, res.data);
|
|
1542
1544
|
}
|
|
@@ -1563,7 +1565,7 @@ function createCauthy(given = {}) {
|
|
|
1563
1565
|
if (res.error) return problem(res.status, res.error.code, res.error.message);
|
|
1564
1566
|
return signedIn(request, res.data, [writeCookie(stepCookie, "", attrs(request, 0))]);
|
|
1565
1567
|
}
|
|
1566
|
-
if (route === "/sign-in/mfa/methods" || route === "/sign-in/mfa/send") {
|
|
1568
|
+
if (route === "/sign-in/mfa/methods" || route === "/sign-in/mfa/send" || route === "/sign-in/mfa/email") {
|
|
1567
1569
|
const sealed = readCookies(request.headers.get("cookie")).get(stepCookie);
|
|
1568
1570
|
const step = sealed ? await unseal(sealed, await key) : null;
|
|
1569
1571
|
if (step === null || step.kind !== "mfa") return problem(400, "step_expired", "Sign in again: the code was asked for too long ago.");
|
|
@@ -1572,13 +1574,20 @@ function createCauthy(given = {}) {
|
|
|
1572
1574
|
if (res2.error) return problem(res2.status, res2.error.code, res2.error.message);
|
|
1573
1575
|
const p = res2.data?.phone;
|
|
1574
1576
|
const push = res2.data?.push;
|
|
1577
|
+
const mail = res2.data?.email;
|
|
1575
1578
|
return json({
|
|
1576
1579
|
status: "ok",
|
|
1577
1580
|
totp: res2.data?.totp === true,
|
|
1578
1581
|
phone: p ? { number: String(p.number ?? ""), channel: String(p.channel ?? "sms") } : null,
|
|
1579
|
-
push: push ? { devices: Number(push.devices ?? 0) } : null
|
|
1582
|
+
push: push ? { devices: Number(push.devices ?? 0) } : null,
|
|
1583
|
+
email: mail ? { to: String(mail.to ?? "") } : null
|
|
1580
1584
|
});
|
|
1581
1585
|
}
|
|
1586
|
+
if (route === "/sign-in/mfa/email") {
|
|
1587
|
+
const res2 = await ask(request, "POST", "/v1/auth/mfa/email", { mfa_token: step.token });
|
|
1588
|
+
if (res2.error) return problem(res2.status, res2.error.code, res2.error.message);
|
|
1589
|
+
return json({ status: "sent", sentTo: String(res2.data?.sent_to ?? "") });
|
|
1590
|
+
}
|
|
1582
1591
|
const res = await ask(request, "POST", "/v1/auth/mfa/send", { mfa_token: step.token });
|
|
1583
1592
|
if (res.error) return problem(res.status, res.error.code, res.error.message);
|
|
1584
1593
|
return json({ status: "sent", sentTo: String(res.data?.sent_to ?? ""), channel: String(res.data?.channel ?? "sms") });
|