cauthy-auth 0.12.0 → 0.14.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 +8 -0
- package/dist/client.d.mts +86 -1
- package/dist/client.d.ts +86 -1
- package/dist/client.js +21 -7
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +21 -7
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +81 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -2
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts +103 -0
- package/dist/mcp.d.ts +103 -0
- package/dist/mcp.js +218 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mcp.mjs +191 -0
- package/dist/mcp.mjs.map +1 -0
- package/dist/react.d.mts +104 -1
- package/dist/react.d.ts +104 -1
- package/dist/react.js +259 -12
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +259 -12
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +5 -0
- package/dist/svelte.js +21 -7
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +21 -7
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +21 -7
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +21 -7
- package/dist/vue.mjs.map +1 -1
- package/package.json +6 -1
package/dist/vue.mjs
CHANGED
|
@@ -177,13 +177,13 @@ function createAuthClient(options = {}) {
|
|
|
177
177
|
const said = typeof options.locale === "function" ? options.locale() : options.locale;
|
|
178
178
|
return (said ?? (typeof document === "undefined" ? "" : document.documentElement?.lang) ?? "").trim();
|
|
179
179
|
};
|
|
180
|
-
async function post(path, form, bad) {
|
|
180
|
+
async function post(path, form, bad, captchaToken) {
|
|
181
181
|
if (bad) return { ok: false, error: { code: bad.code, message: bad.message, field: bad.field } };
|
|
182
182
|
try {
|
|
183
183
|
const res = await doFetch(`${base}${path}`, {
|
|
184
184
|
method: "POST",
|
|
185
185
|
credentials: "same-origin",
|
|
186
|
-
headers: { "content-type": "application/json", accept: "application/json", ...locale() ? { "x-cauthy-locale": locale() } : {} },
|
|
186
|
+
headers: { "content-type": "application/json", accept: "application/json", ...locale() ? { "x-cauthy-locale": locale() } : {}, ...captchaToken ? { "x-cauthy-captcha": captchaToken } : {} },
|
|
187
187
|
body: JSON.stringify(form)
|
|
188
188
|
});
|
|
189
189
|
const body = await res.json().catch(() => null);
|
|
@@ -235,9 +235,11 @@ function createAuthClient(options = {}) {
|
|
|
235
235
|
}
|
|
236
236
|
return {
|
|
237
237
|
signIn: {
|
|
238
|
-
email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password))),
|
|
238
|
+
email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
|
|
239
239
|
mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
|
|
240
|
-
|
|
240
|
+
mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
|
|
241
|
+
mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
|
|
242
|
+
magicLink: (f) => post("/sign-in/magic-link", { email: f.email }, checkEmail(f.email), f.captchaToken),
|
|
241
243
|
magicLinkVerify: (f) => post("/sign-in/magic-link/verify", { token: f.token }, null),
|
|
242
244
|
emailCode: (f) => post("/sign-in/email-code", { code: f.code }, checkCode(f.code)),
|
|
243
245
|
passkeyUrl,
|
|
@@ -318,9 +320,9 @@ function createAuthClient(options = {}) {
|
|
|
318
320
|
}
|
|
319
321
|
},
|
|
320
322
|
signUp: {
|
|
321
|
-
email: (f) => post("/sign-up/email", { email: f.email, password: f.password, name: f.name }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password)))
|
|
323
|
+
email: (f) => post("/sign-up/email", { email: f.email, password: f.password, name: f.name }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password)), f.captchaToken)
|
|
322
324
|
},
|
|
323
|
-
forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email)),
|
|
325
|
+
forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
|
|
324
326
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
|
|
325
327
|
verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
|
|
326
328
|
signOut: () => post("/sign-out", {}, null),
|
|
@@ -338,7 +340,14 @@ function createAuthClient(options = {}) {
|
|
|
338
340
|
setup: (f) => post("/me/mfa/setup", { password: f.password }, null),
|
|
339
341
|
verify: (f) => post("/me/mfa/verify", { code: f.code }, checkCode(f.code)),
|
|
340
342
|
disable: (f) => post("/me/mfa/disable", { password: f.password }, null),
|
|
341
|
-
recoveryCodes: (f) => post("/me/mfa/recovery-codes", { password: f.password }, null)
|
|
343
|
+
recoveryCodes: (f) => post("/me/mfa/recovery-codes", { password: f.password }, null),
|
|
344
|
+
async factors() {
|
|
345
|
+
const body = await read("/me/mfa/factors");
|
|
346
|
+
return body && typeof body.totp === "boolean" ? body : null;
|
|
347
|
+
},
|
|
348
|
+
addPhone: (f) => post("/me/mfa/phone", { phone: f.phone, channel: f.channel, password: f.password }, null),
|
|
349
|
+
verifyPhone: (f) => post("/me/mfa/phone/verify", { code: f.code }, checkCode(f.code)),
|
|
350
|
+
removePhone: (f) => post("/me/mfa/phone/remove", { password: f.password }, null)
|
|
342
351
|
},
|
|
343
352
|
changeEmail: (f) => post("/me/email", { email: f.email, password: f.password }, checkEmail(f.email)),
|
|
344
353
|
async identities() {
|
|
@@ -355,6 +364,11 @@ function createAuthClient(options = {}) {
|
|
|
355
364
|
return body && Array.isArray(body.sessions) ? body.sessions : [];
|
|
356
365
|
},
|
|
357
366
|
signOutEverywhere: () => post("/me/sessions/end", {}, null),
|
|
367
|
+
async agents() {
|
|
368
|
+
const body = await read("/me/agents");
|
|
369
|
+
return body && Array.isArray(body.agents) ? body.agents : [];
|
|
370
|
+
},
|
|
371
|
+
disconnectAgent: (id) => post("/me/agents/disconnect", { id }, null),
|
|
358
372
|
async passkeys() {
|
|
359
373
|
const body = await read("/me/passkeys");
|
|
360
374
|
return body && Array.isArray(body.passkeys) ? body.passkeys : [];
|