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.
Files changed (43) hide show
  1. package/dist/{cauthy-Bn3iv50y.d.ts → cauthy-DGAy45G2.d.ts} +1 -1
  2. package/dist/{cauthy-C29HCvag.d.mts → cauthy-XkIbG5gE.d.mts} +1 -1
  3. package/dist/client.d.mts +133 -3
  4. package/dist/client.d.ts +133 -3
  5. package/dist/client.js +54 -0
  6. package/dist/client.js.map +1 -1
  7. package/dist/client.mjs +54 -0
  8. package/dist/client.mjs.map +1 -1
  9. package/dist/express.d.mts +2 -2
  10. package/dist/express.d.ts +2 -2
  11. package/dist/fastify.d.mts +2 -2
  12. package/dist/fastify.d.ts +2 -2
  13. package/dist/hono.d.mts +2 -2
  14. package/dist/hono.d.ts +2 -2
  15. package/dist/index.d.mts +2 -2
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.js +178 -5
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +178 -5
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/next.d.mts +2 -2
  22. package/dist/next.d.ts +2 -2
  23. package/dist/react.d.mts +171 -2
  24. package/dist/react.d.ts +171 -2
  25. package/dist/react.js +261 -3
  26. package/dist/react.js.map +1 -1
  27. package/dist/react.mjs +260 -3
  28. package/dist/react.mjs.map +1 -1
  29. package/dist/svelte.d.mts +2 -2
  30. package/dist/svelte.d.ts +2 -2
  31. package/dist/svelte.js +54 -0
  32. package/dist/svelte.js.map +1 -1
  33. package/dist/svelte.mjs +54 -0
  34. package/dist/svelte.mjs.map +1 -1
  35. package/dist/{system-ZD_Wa8Bm.d.mts → system-BxMsSIu1.d.mts} +2 -0
  36. package/dist/{system-DhRr_WxR.d.ts → system-DTIeDXDP.d.ts} +2 -0
  37. package/dist/vue.d.mts +2 -2
  38. package/dist/vue.d.ts +2 -2
  39. package/dist/vue.js +54 -0
  40. package/dist/vue.js.map +1 -1
  41. package/dist/vue.mjs +54 -0
  42. package/dist/vue.mjs.map +1 -1
  43. package/package.json +1 -1
package/dist/svelte.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SessionStore, SessionState, SessionStoreOptions } from './client.mjs';
2
2
  export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.mjs';
3
- import { i as PublicSession } from './system-ZD_Wa8Bm.mjs';
4
- export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-ZD_Wa8Bm.mjs';
3
+ import { i as PublicSession } from './system-BxMsSIu1.mjs';
4
+ export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-BxMsSIu1.mjs';
5
5
  import './theme.mjs';
6
6
  import './validate-B_iC-4y8.mjs';
7
7
  import 'jose';
package/dist/svelte.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SessionStore, SessionState, SessionStoreOptions } from './client.js';
2
2
  export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.js';
3
- import { i as PublicSession } from './system-DhRr_WxR.js';
4
- export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-DhRr_WxR.js';
3
+ import { i as PublicSession } from './system-DTIeDXDP.js';
4
+ export { P as PermissionOf, f as Policy, R as RoleOf, k as SessionOrganization, m as SessionUser, p as can, r as definePolicy } from './system-DTIeDXDP.js';
5
5
  import './theme.js';
6
6
  import './validate-B_iC-4y8.js';
7
7
  import 'jose';
package/dist/svelte.js CHANGED
@@ -228,6 +228,7 @@ function createAuthClient(options = {}) {
228
228
  return null;
229
229
  }
230
230
  }
231
+ const upgradeUrl = (provider, o = {}) => `${base}/me/upgrade/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
231
232
  const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
232
233
  const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
233
234
  const ssoUrl = (target, o = {}) => {
@@ -265,10 +266,40 @@ function createAuthClient(options = {}) {
265
266
  }
266
267
  return {
267
268
  signIn: {
269
+ anonymously: (f = {}) => post("/sign-in/anonymous", {}, null, f.captchaToken),
268
270
  email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
269
271
  mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
270
272
  mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
271
273
  mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
274
+ mfaPush: () => post("/sign-in/mfa/push", {}, null),
275
+ async mfaPushWait(o = {}) {
276
+ const status = await new Promise((resolve) => {
277
+ if (typeof EventSource !== "function") return resolve("approved");
278
+ const source = new EventSource(`${base}/sign-in/mfa/push/events`, { withCredentials: true });
279
+ const stop = (st) => {
280
+ source.close();
281
+ resolve(st);
282
+ };
283
+ o.signal?.addEventListener("abort", () => stop("aborted"));
284
+ source.addEventListener("status", (e) => {
285
+ const st = (() => {
286
+ try {
287
+ return String(JSON.parse(e.data).status);
288
+ } catch {
289
+ return "";
290
+ }
291
+ })();
292
+ if (st && st !== "pending") stop(st);
293
+ });
294
+ source.onerror = () => {
295
+ if (source.readyState === EventSource.CLOSED) stop("expired");
296
+ };
297
+ });
298
+ if (status === "aborted") return { ok: false, error: { code: "aborted", message: "Stopped waiting." } };
299
+ if (status === "denied") return { ok: false, error: { code: "push_denied", message: "The sign-in was turned down on the phone." } };
300
+ if (status === "expired") return { ok: false, error: { code: "push_expired", message: "Nobody answered on the phone in time." } };
301
+ return post("/sign-in/mfa/push/finish", {}, null);
302
+ },
272
303
  magicLink: (f) => post("/sign-in/magic-link", { email: f.email, ...f.create ? { create: true } : {}, ...f.returnTo ? { returnTo: f.returnTo } : {} }, checkEmail(f.email), f.captchaToken),
273
304
  magicLinkVerify: (f) => post("/sign-in/magic-link/verify", { token: f.token }, null),
274
305
  emailCode: (f) => post("/sign-in/email-code", { code: f.code }, checkCode(f.code)),
@@ -362,6 +393,24 @@ function createAuthClient(options = {}) {
362
393
  resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
363
394
  verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
364
395
  signOut: () => post("/sign-out", {}, null),
396
+ organizations: {
397
+ async list(system) {
398
+ const body = await read(`/me/organizations${system ? `?system=${encodeURIComponent(system)}` : ""}`);
399
+ return body && Array.isArray(body.organizations) ? body.organizations : [];
400
+ },
401
+ async members(id) {
402
+ const body = await read(`/me/organizations/members?id=${encodeURIComponent(id)}`);
403
+ return body && Array.isArray(body.members) ? body.members : null;
404
+ },
405
+ async roles(id) {
406
+ const body = await read(`/me/organizations/roles?id=${encodeURIComponent(id)}`);
407
+ return body && Array.isArray(body.roles) ? body.roles : null;
408
+ },
409
+ 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)),
410
+ setRole: (id, userId, role) => post("/me/organizations/members/role", { organizationId: id, userId, role }, null),
411
+ remove: (id, userId) => post("/me/organizations/members/remove", { organizationId: id, userId }, null),
412
+ inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null)
413
+ },
365
414
  account: {
366
415
  async get() {
367
416
  const body = await read("/me");
@@ -400,6 +449,11 @@ function createAuthClient(options = {}) {
400
449
  return body && Array.isArray(body.sessions) ? body.sessions : [];
401
450
  },
402
451
  signOutEverywhere: () => post("/me/sessions/end", {}, null),
452
+ upgrade: (f) => post("/me/upgrade", { email: f.email, password: f.password, name: f.name ?? "" }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password))),
453
+ upgradeUrl,
454
+ upgradeWith(provider, o) {
455
+ window.location.assign(upgradeUrl(provider, o));
456
+ },
403
457
  async agents() {
404
458
  const body = await read("/me/agents");
405
459
  return body && Array.isArray(body.agents) ? body.agents : [];