cauthy-auth 0.19.0 → 0.22.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 +157 -2
  4. package/dist/client.d.ts +157 -2
  5. package/dist/client.js +37 -2
  6. package/dist/client.js.map +1 -1
  7. package/dist/client.mjs +37 -2
  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 +181 -6
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +181 -6
  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 +192 -1
  24. package/dist/react.d.ts +192 -1
  25. package/dist/react.js +279 -23
  26. package/dist/react.js.map +1 -1
  27. package/dist/react.mjs +278 -23
  28. package/dist/react.mjs.map +1 -1
  29. package/dist/svelte.d.mts +3 -3
  30. package/dist/svelte.d.ts +3 -3
  31. package/dist/svelte.js +37 -2
  32. package/dist/svelte.js.map +1 -1
  33. package/dist/svelte.mjs +37 -2
  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 +3 -3
  38. package/dist/vue.d.ts +3 -3
  39. package/dist/vue.js +37 -2
  40. package/dist/vue.js.map +1 -1
  41. package/dist/vue.mjs +37 -2
  42. package/dist/vue.mjs.map +1 -1
  43. package/package.json +1 -1
package/dist/svelte.mjs CHANGED
@@ -200,8 +200,14 @@ 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)}` : ""}`;
206
+ const ssoUrl = (target, o = {}) => {
207
+ const q = new URLSearchParams("connection" in target ? { connection: target.connection } : { email: target.email.trim() });
208
+ if (o.returnTo) q.set("return_to", o.returnTo);
209
+ return `${base}/sign-in/sso?${q}`;
210
+ };
205
211
  const passkeyUrl = (o = {}) => {
206
212
  const q = new URLSearchParams({ method: "passkey" });
207
213
  if (o.returnTo) q.set("return_to", o.returnTo);
@@ -213,11 +219,11 @@ function createAuthClient(options = {}) {
213
219
  const res = await doFetch(`${base}/methods`, { credentials: "same-origin", headers: { accept: "application/json" } });
214
220
  if (res.ok) {
215
221
  const m = await res.json();
216
- return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true };
222
+ return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
217
223
  }
218
224
  } catch {
219
225
  }
220
- return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false };
226
+ return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
221
227
  }
222
228
  async function ceremony(begin, finish, form, run, more = {}) {
223
229
  const begun = await post(begin, form, null);
@@ -232,6 +238,7 @@ function createAuthClient(options = {}) {
232
238
  }
233
239
  return {
234
240
  signIn: {
241
+ anonymously: (f = {}) => post("/sign-in/anonymous", {}, null, f.captchaToken),
235
242
  email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
236
243
  mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
237
244
  mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
@@ -315,6 +322,11 @@ function createAuthClient(options = {}) {
315
322
  socialUrl,
316
323
  social(provider, o) {
317
324
  window.location.assign(socialUrl(provider, o));
325
+ },
326
+ ssoDiscover: (f) => post("/sign-in/sso/discover", { email: f.email.trim() }, checkEmail(f.email)),
327
+ ssoUrl,
328
+ sso(target, o) {
329
+ window.location.assign(ssoUrl(target, o));
318
330
  }
319
331
  },
320
332
  signUp: {
@@ -324,6 +336,24 @@ function createAuthClient(options = {}) {
324
336
  resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
325
337
  verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
326
338
  signOut: () => post("/sign-out", {}, null),
339
+ organizations: {
340
+ async list(system) {
341
+ const body = await read(`/me/organizations${system ? `?system=${encodeURIComponent(system)}` : ""}`);
342
+ return body && Array.isArray(body.organizations) ? body.organizations : [];
343
+ },
344
+ async members(id) {
345
+ const body = await read(`/me/organizations/members?id=${encodeURIComponent(id)}`);
346
+ return body && Array.isArray(body.members) ? body.members : null;
347
+ },
348
+ async roles(id) {
349
+ const body = await read(`/me/organizations/roles?id=${encodeURIComponent(id)}`);
350
+ return body && Array.isArray(body.roles) ? body.roles : null;
351
+ },
352
+ 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)),
353
+ setRole: (id, userId, role) => post("/me/organizations/members/role", { organizationId: id, userId, role }, null),
354
+ remove: (id, userId) => post("/me/organizations/members/remove", { organizationId: id, userId }, null),
355
+ inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null)
356
+ },
327
357
  account: {
328
358
  async get() {
329
359
  const body = await read("/me");
@@ -362,6 +392,11 @@ function createAuthClient(options = {}) {
362
392
  return body && Array.isArray(body.sessions) ? body.sessions : [];
363
393
  },
364
394
  signOutEverywhere: () => post("/me/sessions/end", {}, null),
395
+ upgrade: (f) => post("/me/upgrade", { email: f.email, password: f.password, name: f.name ?? "" }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password))),
396
+ upgradeUrl,
397
+ upgradeWith(provider, o) {
398
+ window.location.assign(upgradeUrl(provider, o));
399
+ },
365
400
  async agents() {
366
401
  const body = await read("/me/agents");
367
402
  return body && Array.isArray(body.agents) ? body.agents : [];