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