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.js
CHANGED
|
@@ -205,13 +205,13 @@ function createAuthClient(options = {}) {
|
|
|
205
205
|
const said = typeof options.locale === "function" ? options.locale() : options.locale;
|
|
206
206
|
return (said ?? (typeof document === "undefined" ? "" : document.documentElement?.lang) ?? "").trim();
|
|
207
207
|
};
|
|
208
|
-
async function post(path, form, bad) {
|
|
208
|
+
async function post(path, form, bad, captchaToken) {
|
|
209
209
|
if (bad) return { ok: false, error: { code: bad.code, message: bad.message, field: bad.field } };
|
|
210
210
|
try {
|
|
211
211
|
const res = await doFetch(`${base}${path}`, {
|
|
212
212
|
method: "POST",
|
|
213
213
|
credentials: "same-origin",
|
|
214
|
-
headers: { "content-type": "application/json", accept: "application/json", ...locale() ? { "x-cauthy-locale": locale() } : {} },
|
|
214
|
+
headers: { "content-type": "application/json", accept: "application/json", ...locale() ? { "x-cauthy-locale": locale() } : {}, ...captchaToken ? { "x-cauthy-captcha": captchaToken } : {} },
|
|
215
215
|
body: JSON.stringify(form)
|
|
216
216
|
});
|
|
217
217
|
const body = await res.json().catch(() => null);
|
|
@@ -263,9 +263,11 @@ function createAuthClient(options = {}) {
|
|
|
263
263
|
}
|
|
264
264
|
return {
|
|
265
265
|
signIn: {
|
|
266
|
-
email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password))),
|
|
266
|
+
email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
|
|
267
267
|
mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
|
|
268
|
-
|
|
268
|
+
mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
|
|
269
|
+
mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
|
|
270
|
+
magicLink: (f) => post("/sign-in/magic-link", { email: f.email }, checkEmail(f.email), f.captchaToken),
|
|
269
271
|
magicLinkVerify: (f) => post("/sign-in/magic-link/verify", { token: f.token }, null),
|
|
270
272
|
emailCode: (f) => post("/sign-in/email-code", { code: f.code }, checkCode(f.code)),
|
|
271
273
|
passkeyUrl,
|
|
@@ -346,9 +348,9 @@ function createAuthClient(options = {}) {
|
|
|
346
348
|
}
|
|
347
349
|
},
|
|
348
350
|
signUp: {
|
|
349
|
-
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)))
|
|
351
|
+
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)
|
|
350
352
|
},
|
|
351
|
-
forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email)),
|
|
353
|
+
forgotPassword: (f) => post("/forgot-password", { email: f.email }, checkEmail(f.email), f.captchaToken),
|
|
352
354
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
|
|
353
355
|
verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
|
|
354
356
|
signOut: () => post("/sign-out", {}, null),
|
|
@@ -366,7 +368,14 @@ function createAuthClient(options = {}) {
|
|
|
366
368
|
setup: (f) => post("/me/mfa/setup", { password: f.password }, null),
|
|
367
369
|
verify: (f) => post("/me/mfa/verify", { code: f.code }, checkCode(f.code)),
|
|
368
370
|
disable: (f) => post("/me/mfa/disable", { password: f.password }, null),
|
|
369
|
-
recoveryCodes: (f) => post("/me/mfa/recovery-codes", { password: f.password }, null)
|
|
371
|
+
recoveryCodes: (f) => post("/me/mfa/recovery-codes", { password: f.password }, null),
|
|
372
|
+
async factors() {
|
|
373
|
+
const body = await read("/me/mfa/factors");
|
|
374
|
+
return body && typeof body.totp === "boolean" ? body : null;
|
|
375
|
+
},
|
|
376
|
+
addPhone: (f) => post("/me/mfa/phone", { phone: f.phone, channel: f.channel, password: f.password }, null),
|
|
377
|
+
verifyPhone: (f) => post("/me/mfa/phone/verify", { code: f.code }, checkCode(f.code)),
|
|
378
|
+
removePhone: (f) => post("/me/mfa/phone/remove", { password: f.password }, null)
|
|
370
379
|
},
|
|
371
380
|
changeEmail: (f) => post("/me/email", { email: f.email, password: f.password }, checkEmail(f.email)),
|
|
372
381
|
async identities() {
|
|
@@ -383,6 +392,11 @@ function createAuthClient(options = {}) {
|
|
|
383
392
|
return body && Array.isArray(body.sessions) ? body.sessions : [];
|
|
384
393
|
},
|
|
385
394
|
signOutEverywhere: () => post("/me/sessions/end", {}, null),
|
|
395
|
+
async agents() {
|
|
396
|
+
const body = await read("/me/agents");
|
|
397
|
+
return body && Array.isArray(body.agents) ? body.agents : [];
|
|
398
|
+
},
|
|
399
|
+
disconnectAgent: (id) => post("/me/agents/disconnect", { id }, null),
|
|
386
400
|
async passkeys() {
|
|
387
401
|
const body = await read("/me/passkeys");
|
|
388
402
|
return body && Array.isArray(body.passkeys) ? body.passkeys : [];
|