cauthy-auth 0.22.0 → 0.24.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 +22 -1
- package/dist/client.d.ts +22 -1
- package/dist/client.js +29 -0
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +29 -0
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +48 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +26 -1
- package/dist/react.d.ts +26 -1
- package/dist/react.js +61 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +61 -1
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.js +29 -0
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +29 -0
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +29 -0
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +29 -0
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/svelte.mjs
CHANGED
|
@@ -243,6 +243,35 @@ function createAuthClient(options = {}) {
|
|
|
243
243
|
mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
|
|
244
244
|
mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
|
|
245
245
|
mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
|
|
246
|
+
mfaPush: () => post("/sign-in/mfa/push", {}, null),
|
|
247
|
+
async mfaPushWait(o = {}) {
|
|
248
|
+
const status = await new Promise((resolve) => {
|
|
249
|
+
if (typeof EventSource !== "function") return resolve("approved");
|
|
250
|
+
const source = new EventSource(`${base}/sign-in/mfa/push/events`, { withCredentials: true });
|
|
251
|
+
const stop = (st) => {
|
|
252
|
+
source.close();
|
|
253
|
+
resolve(st);
|
|
254
|
+
};
|
|
255
|
+
o.signal?.addEventListener("abort", () => stop("aborted"));
|
|
256
|
+
source.addEventListener("status", (e) => {
|
|
257
|
+
const st = (() => {
|
|
258
|
+
try {
|
|
259
|
+
return String(JSON.parse(e.data).status);
|
|
260
|
+
} catch {
|
|
261
|
+
return "";
|
|
262
|
+
}
|
|
263
|
+
})();
|
|
264
|
+
if (st && st !== "pending") stop(st);
|
|
265
|
+
});
|
|
266
|
+
source.onerror = () => {
|
|
267
|
+
if (source.readyState === EventSource.CLOSED) stop("expired");
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
if (status === "aborted") return { ok: false, error: { code: "aborted", message: "Stopped waiting." } };
|
|
271
|
+
if (status === "denied") return { ok: false, error: { code: "push_denied", message: "The sign-in was turned down on the phone." } };
|
|
272
|
+
if (status === "expired") return { ok: false, error: { code: "push_expired", message: "Nobody answered on the phone in time." } };
|
|
273
|
+
return post("/sign-in/mfa/push/finish", {}, null);
|
|
274
|
+
},
|
|
246
275
|
magicLink: (f) => post("/sign-in/magic-link", { email: f.email, ...f.create ? { create: true } : {}, ...f.returnTo ? { returnTo: f.returnTo } : {} }, checkEmail(f.email), f.captchaToken),
|
|
247
276
|
magicLinkVerify: (f) => post("/sign-in/magic-link/verify", { token: f.token }, null),
|
|
248
277
|
emailCode: (f) => post("/sign-in/email-code", { code: f.code }, checkCode(f.code)),
|