cauthy-auth 0.19.0 → 0.20.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/svelte.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SessionStore, SessionState, SessionStoreOptions } from './client.mjs';
2
- export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind } from './client.mjs';
2
+ export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.mjs';
3
3
  import { i as PublicSession } from './system-ZD_Wa8Bm.mjs';
4
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';
5
5
  import './theme.mjs';
package/dist/svelte.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SessionStore, SessionState, SessionStoreOptions } from './client.js';
2
- export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind } from './client.js';
2
+ export { Account, AccountSession, AuthClient, AuthError, AuthMethods, AuthResult, Passkey, PasskeyKind, SSOConnection } from './client.js';
3
3
  import { i as PublicSession } from './system-DhRr_WxR.js';
4
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';
5
5
  import './theme.js';
package/dist/svelte.js CHANGED
@@ -230,6 +230,11 @@ function createAuthClient(options = {}) {
230
230
  }
231
231
  const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
232
232
  const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
233
+ const ssoUrl = (target, o = {}) => {
234
+ const q = new URLSearchParams("connection" in target ? { connection: target.connection } : { email: target.email.trim() });
235
+ if (o.returnTo) q.set("return_to", o.returnTo);
236
+ return `${base}/sign-in/sso?${q}`;
237
+ };
233
238
  const passkeyUrl = (o = {}) => {
234
239
  const q = new URLSearchParams({ method: "passkey" });
235
240
  if (o.returnTo) q.set("return_to", o.returnTo);
@@ -241,11 +246,11 @@ function createAuthClient(options = {}) {
241
246
  const res = await doFetch(`${base}/methods`, { credentials: "same-origin", headers: { accept: "application/json" } });
242
247
  if (res.ok) {
243
248
  const m = await res.json();
244
- return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true };
249
+ return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
245
250
  }
246
251
  } catch {
247
252
  }
248
- return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false };
253
+ return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
249
254
  }
250
255
  async function ceremony(begin, finish, form, run, more = {}) {
251
256
  const begun = await post(begin, form, null);
@@ -343,6 +348,11 @@ function createAuthClient(options = {}) {
343
348
  socialUrl,
344
349
  social(provider, o) {
345
350
  window.location.assign(socialUrl(provider, o));
351
+ },
352
+ ssoDiscover: (f) => post("/sign-in/sso/discover", { email: f.email.trim() }, checkEmail(f.email)),
353
+ ssoUrl,
354
+ sso(target, o) {
355
+ window.location.assign(ssoUrl(target, o));
346
356
  }
347
357
  },
348
358
  signUp: {