cauthy-auth 0.20.0 → 0.23.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/{cauthy-Bn3iv50y.d.ts → cauthy-DGAy45G2.d.ts} +1 -1
- package/dist/{cauthy-C29HCvag.d.mts → cauthy-XkIbG5gE.d.mts} +1 -1
- package/dist/client.d.mts +133 -3
- package/dist/client.d.ts +133 -3
- package/dist/client.js +54 -0
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +54 -0
- package/dist/client.mjs.map +1 -1
- package/dist/express.d.mts +2 -2
- package/dist/express.d.ts +2 -2
- package/dist/fastify.d.mts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/hono.d.mts +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +178 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -5
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/react.d.mts +171 -2
- package/dist/react.d.ts +171 -2
- package/dist/react.js +261 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +260 -3
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +54 -0
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +54 -0
- package/dist/svelte.mjs.map +1 -1
- package/dist/{system-ZD_Wa8Bm.d.mts → system-BxMsSIu1.d.mts} +2 -0
- package/dist/{system-DhRr_WxR.d.ts → system-DTIeDXDP.d.ts} +2 -0
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +54 -0
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +54 -0
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/svelte.mjs
CHANGED
|
@@ -200,6 +200,7 @@ function createAuthClient(options = {}) {
|
|
|
200
200
|
return null;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
+
const upgradeUrl = (provider, o = {}) => `${base}/me/upgrade/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
203
204
|
const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
204
205
|
const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
205
206
|
const ssoUrl = (target, o = {}) => {
|
|
@@ -237,10 +238,40 @@ function createAuthClient(options = {}) {
|
|
|
237
238
|
}
|
|
238
239
|
return {
|
|
239
240
|
signIn: {
|
|
241
|
+
anonymously: (f = {}) => post("/sign-in/anonymous", {}, null, f.captchaToken),
|
|
240
242
|
email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
|
|
241
243
|
mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
|
|
242
244
|
mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
|
|
243
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
|
+
},
|
|
244
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),
|
|
245
276
|
magicLinkVerify: (f) => post("/sign-in/magic-link/verify", { token: f.token }, null),
|
|
246
277
|
emailCode: (f) => post("/sign-in/email-code", { code: f.code }, checkCode(f.code)),
|
|
@@ -334,6 +365,24 @@ function createAuthClient(options = {}) {
|
|
|
334
365
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
|
|
335
366
|
verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
|
|
336
367
|
signOut: () => post("/sign-out", {}, null),
|
|
368
|
+
organizations: {
|
|
369
|
+
async list(system) {
|
|
370
|
+
const body = await read(`/me/organizations${system ? `?system=${encodeURIComponent(system)}` : ""}`);
|
|
371
|
+
return body && Array.isArray(body.organizations) ? body.organizations : [];
|
|
372
|
+
},
|
|
373
|
+
async members(id) {
|
|
374
|
+
const body = await read(`/me/organizations/members?id=${encodeURIComponent(id)}`);
|
|
375
|
+
return body && Array.isArray(body.members) ? body.members : null;
|
|
376
|
+
},
|
|
377
|
+
async roles(id) {
|
|
378
|
+
const body = await read(`/me/organizations/roles?id=${encodeURIComponent(id)}`);
|
|
379
|
+
return body && Array.isArray(body.roles) ? body.roles : null;
|
|
380
|
+
},
|
|
381
|
+
add: (id, f) => post("/me/organizations/members/add", { organizationId: id, email: f.email, role: f.role, name: f.name ?? "", locale: f.locale ?? "" }, checkEmail(f.email)),
|
|
382
|
+
setRole: (id, userId, role) => post("/me/organizations/members/role", { organizationId: id, userId, role }, null),
|
|
383
|
+
remove: (id, userId) => post("/me/organizations/members/remove", { organizationId: id, userId }, null),
|
|
384
|
+
inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null)
|
|
385
|
+
},
|
|
337
386
|
account: {
|
|
338
387
|
async get() {
|
|
339
388
|
const body = await read("/me");
|
|
@@ -372,6 +421,11 @@ function createAuthClient(options = {}) {
|
|
|
372
421
|
return body && Array.isArray(body.sessions) ? body.sessions : [];
|
|
373
422
|
},
|
|
374
423
|
signOutEverywhere: () => post("/me/sessions/end", {}, null),
|
|
424
|
+
upgrade: (f) => post("/me/upgrade", { email: f.email, password: f.password, name: f.name ?? "" }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password))),
|
|
425
|
+
upgradeUrl,
|
|
426
|
+
upgradeWith(provider, o) {
|
|
427
|
+
window.location.assign(upgradeUrl(provider, o));
|
|
428
|
+
},
|
|
375
429
|
async agents() {
|
|
376
430
|
const body = await read("/me/agents");
|
|
377
431
|
return body && Array.isArray(body.agents) ? body.agents : [];
|