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
@@ -1,4 +1,4 @@
1
- import { J as JsonValue, S as Session, l as SessionStatus, k as SessionOrganization, c as CauthySystem, i as PublicSession, b as CauthyOptions } from './system-DhRr_WxR.js';
1
+ import { J as JsonValue, S as Session, l as SessionStatus, k as SessionOrganization, c as CauthySystem, i as PublicSession, b as CauthyOptions } from './system-DTIeDXDP.js';
2
2
  import { JWTVerifyGetKey } from 'jose';
3
3
 
4
4
  /** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
@@ -1,4 +1,4 @@
1
- import { J as JsonValue, S as Session, l as SessionStatus, k as SessionOrganization, c as CauthySystem, i as PublicSession, b as CauthyOptions } from './system-ZD_Wa8Bm.mjs';
1
+ import { J as JsonValue, S as Session, l as SessionStatus, k as SessionOrganization, c as CauthySystem, i as PublicSession, b as CauthyOptions } from './system-BxMsSIu1.mjs';
2
2
  import { JWTVerifyGetKey } from 'jose';
3
3
 
4
4
  /** Something that happened in Cauthy, as a subscriber is told. Moments are UTC. */
package/dist/client.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CauthyTheme } from './theme.mjs';
2
- import { i as PublicSession } from './system-ZD_Wa8Bm.mjs';
2
+ import { i as PublicSession } from './system-BxMsSIu1.mjs';
3
3
  import { A as AuthField } from './validate-B_iC-4y8.mjs';
4
4
  export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-B_iC-4y8.mjs';
5
5
  import 'jose';
@@ -100,6 +100,20 @@ interface AuthMethods {
100
100
  * forms show it themselves.
101
101
  */
102
102
  captchaSiteKey?: string;
103
+ /**
104
+ * Whether the workspace signs some people in through their company's SSO,
105
+ * found by their work address (`signIn.ssoDiscover`, `signIn.sso`).
106
+ */
107
+ sso: boolean;
108
+ }
109
+ /** A company's sign-in (an SSO connection of the workspace). */
110
+ interface SSOConnection {
111
+ /** What `signIn.sso({ connection })` takes. */
112
+ id: string;
113
+ /** The company's name, for "Continue with …". */
114
+ name: string;
115
+ /** The address can sign in no other way: a password, link or provider answers `sso_required`. */
116
+ enforced: boolean;
103
117
  }
104
118
  /**
105
119
  * What holds a passkey, as its authenticator says: a security key (a YubiKey),
@@ -149,6 +163,82 @@ interface ConnectedAgent {
149
163
  connectedAt: string;
150
164
  lastUsedAt: string;
151
165
  }
166
+ /** An organization the person belongs to, with what their role lets them do with its people. */
167
+ interface OrganizationSeat {
168
+ id: string;
169
+ /** The client system it is of (`pondari`). */
170
+ system: string;
171
+ name: string;
172
+ kind: string;
173
+ /** The person's role in it. */
174
+ role: string;
175
+ /** Cauthy's member powers, from the system's catalog: cauthy:members read and manage. */
176
+ can: {
177
+ readMembers: boolean;
178
+ manageMembers: boolean;
179
+ };
180
+ }
181
+ /** A person of an organization, as a member who may see them reads it. */
182
+ interface OrganizationPerson {
183
+ userId: string;
184
+ email: string;
185
+ name: string;
186
+ role: string;
187
+ /** The account's: `active`, `suspended`… A disabled member is still listed. */
188
+ status: string;
189
+ /** Invited and not yet accepted. */
190
+ invited: boolean;
191
+ /** Manages the organization's members. */
192
+ manager: boolean;
193
+ /** The signed-in person. */
194
+ you: boolean;
195
+ /** UTC, ISO 8601. */
196
+ since: string;
197
+ }
198
+ /** A role of the organization's system, as the catalog names it. */
199
+ interface OrganizationRoleChoice {
200
+ role: string;
201
+ name: string;
202
+ description: string;
203
+ /** Holding it manages the organization's members. */
204
+ manager: boolean;
205
+ }
206
+ /**
207
+ * The signed-in person's organizations, and their people. Seeing them needs
208
+ * cauthy:members read in the person's role; changing them needs manage. Cauthy
209
+ * decides, with the person's own session: the application authorizes nothing.
210
+ */
211
+ interface OrganizationsClient {
212
+ /** The organizations the person belongs to; one system's only with `system`. */
213
+ list(system?: string): Promise<OrganizationSeat[]>;
214
+ /** The people of one, or null when the person may not see them. */
215
+ members(organizationId: string): Promise<OrganizationPerson[] | null>;
216
+ /** The roles a member may be given, or null when the person may not see them. */
217
+ roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
218
+ /** Adds a person by their address; an address with no account gets one and its invitation. */
219
+ add(organizationId: string, form: {
220
+ email: string;
221
+ role: string;
222
+ name?: string;
223
+ locale?: string;
224
+ }): Promise<AuthResult<'added', {
225
+ member: OrganizationPerson;
226
+ }>>;
227
+ setRole(organizationId: string, userId: string, role: string): Promise<AuthResult<'changed', {
228
+ userId: string;
229
+ role: string;
230
+ }>>;
231
+ /** Removes a member; the person themself may always leave. */
232
+ remove(organizationId: string, userId: string): Promise<AuthResult<'removed', {
233
+ userId: string;
234
+ }>>;
235
+ /** Sends a member's invitation again. */
236
+ inviteAgain(organizationId: string, userId: string, form?: {
237
+ locale?: string;
238
+ }): Promise<AuthResult<'sent', {
239
+ userId: string;
240
+ }>>;
241
+ }
152
242
  interface AccountSession {
153
243
  /** "Mac · Chrome", or "" when the browser did not say. */
154
244
  device: string;
@@ -271,6 +361,26 @@ interface AccountClient {
271
361
  unlink(provider: string): Promise<AuthResult<'unlinked', {
272
362
  provider: string;
273
363
  }>>;
364
+ /**
365
+ * A guest becomes an account of their own with an address and a password —
366
+ * the same id, so what they did stays theirs. `email_taken`: the address has
367
+ * an account already; offer to sign in with it.
368
+ */
369
+ upgrade(form: {
370
+ email: string;
371
+ password: string;
372
+ name?: string;
373
+ }): Promise<AuthResult<'signed_in', {
374
+ session: PublicSession;
375
+ }>>;
376
+ /** Where a guest goes to become the account of a provider's address (Google…). */
377
+ upgradeUrl(provider: string, options?: {
378
+ returnTo?: string;
379
+ }): string;
380
+ /** Sends a guest to `upgradeUrl`; they come back signed in as the account. */
381
+ upgradeWith(provider: string, options?: {
382
+ returnTo?: string;
383
+ }): void;
274
384
  /** Where the account is signed in. */
275
385
  sessions(): Promise<AccountSession[]>;
276
386
  /** Signs the account out everywhere, here too. */
@@ -304,6 +414,17 @@ interface AccountClient {
304
414
  }
305
415
  interface AuthClient {
306
416
  signIn: {
417
+ /**
418
+ * A guest session, before the visitor signs up: the application keeps what
419
+ * they do under `session.user.id`, and `account.upgrade` (or
420
+ * `account.upgradeWith`) makes it their account, same id. Only where the
421
+ * workspace allows guests (`anonymous_disabled` otherwise).
422
+ */
423
+ anonymously(form?: {
424
+ captchaToken?: string;
425
+ }): Promise<AuthResult<'signed_in', {
426
+ session: PublicSession;
427
+ }>>;
307
428
  /** With address and password. `mfa_required`: ask for the code and call `signIn.mfa`. */
308
429
  email(form: {
309
430
  email: string;
@@ -412,6 +533,38 @@ interface AuthClient {
412
533
  social(provider: string, options?: {
413
534
  returnTo?: string;
414
535
  }): void;
536
+ /**
537
+ * Which company's sign-in a work address uses, if any (`found`), or
538
+ * `none`. It says so of the address's domain, never whether the address
539
+ * has an account.
540
+ */
541
+ ssoDiscover(form: {
542
+ email: string;
543
+ }): Promise<AuthResult<'found', {
544
+ connection: SSOConnection;
545
+ }> | AuthResult<'none'>>;
546
+ /**
547
+ * Sends the browser to the person's company (found by `email`, or named
548
+ * by `connection`); it comes back signed in, at `returnTo`. A sign-in the
549
+ * company refused comes back with `?auth_error=`. Any other way of
550
+ * signing in answers `sso_required` for an address its company holds to
551
+ * SSO: send it here then.
552
+ */
553
+ sso(target: {
554
+ email: string;
555
+ } | {
556
+ connection: string;
557
+ }, options?: {
558
+ returnTo?: string;
559
+ }): void;
560
+ /** Where `sso` sends the browser, for a plain link. */
561
+ ssoUrl(target: {
562
+ email: string;
563
+ } | {
564
+ connection: string;
565
+ }, options?: {
566
+ returnTo?: string;
567
+ }): string;
415
568
  /** Where `social` sends the browser, for a plain link. */
416
569
  socialUrl(provider: string, options?: {
417
570
  returnTo?: string;
@@ -447,6 +600,8 @@ interface AuthClient {
447
600
  signOut(): Promise<AuthResult<'signed_out'>>;
448
601
  /** The signed-in person's own account. */
449
602
  account: AccountClient;
603
+ /** The signed-in person's organizations, and their people. */
604
+ organizations: OrganizationsClient;
450
605
  /** Who is signed in, or null. */
451
606
  getSession(): Promise<PublicSession | null>;
452
607
  methods(): Promise<AuthMethods>;
@@ -470,4 +625,4 @@ interface AuthClientOptions {
470
625
  }
471
626
  declare function createAuthClient(options?: AuthClientOptions): AuthClient;
472
627
 
473
- export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type Passkey, type PasskeyKind, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
628
+ export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CauthyTheme } from './theme.js';
2
- import { i as PublicSession } from './system-DhRr_WxR.js';
2
+ import { i as PublicSession } from './system-DTIeDXDP.js';
3
3
  import { A as AuthField } from './validate-B_iC-4y8.js';
4
4
  export { F as FieldProblem, M as MIN_PASSWORD, c as checkCode, a as checkEmail, b as checkName, d as checkNewPassword, e as checkPassword } from './validate-B_iC-4y8.js';
5
5
  import 'jose';
@@ -100,6 +100,20 @@ interface AuthMethods {
100
100
  * forms show it themselves.
101
101
  */
102
102
  captchaSiteKey?: string;
103
+ /**
104
+ * Whether the workspace signs some people in through their company's SSO,
105
+ * found by their work address (`signIn.ssoDiscover`, `signIn.sso`).
106
+ */
107
+ sso: boolean;
108
+ }
109
+ /** A company's sign-in (an SSO connection of the workspace). */
110
+ interface SSOConnection {
111
+ /** What `signIn.sso({ connection })` takes. */
112
+ id: string;
113
+ /** The company's name, for "Continue with …". */
114
+ name: string;
115
+ /** The address can sign in no other way: a password, link or provider answers `sso_required`. */
116
+ enforced: boolean;
103
117
  }
104
118
  /**
105
119
  * What holds a passkey, as its authenticator says: a security key (a YubiKey),
@@ -149,6 +163,82 @@ interface ConnectedAgent {
149
163
  connectedAt: string;
150
164
  lastUsedAt: string;
151
165
  }
166
+ /** An organization the person belongs to, with what their role lets them do with its people. */
167
+ interface OrganizationSeat {
168
+ id: string;
169
+ /** The client system it is of (`pondari`). */
170
+ system: string;
171
+ name: string;
172
+ kind: string;
173
+ /** The person's role in it. */
174
+ role: string;
175
+ /** Cauthy's member powers, from the system's catalog: cauthy:members read and manage. */
176
+ can: {
177
+ readMembers: boolean;
178
+ manageMembers: boolean;
179
+ };
180
+ }
181
+ /** A person of an organization, as a member who may see them reads it. */
182
+ interface OrganizationPerson {
183
+ userId: string;
184
+ email: string;
185
+ name: string;
186
+ role: string;
187
+ /** The account's: `active`, `suspended`… A disabled member is still listed. */
188
+ status: string;
189
+ /** Invited and not yet accepted. */
190
+ invited: boolean;
191
+ /** Manages the organization's members. */
192
+ manager: boolean;
193
+ /** The signed-in person. */
194
+ you: boolean;
195
+ /** UTC, ISO 8601. */
196
+ since: string;
197
+ }
198
+ /** A role of the organization's system, as the catalog names it. */
199
+ interface OrganizationRoleChoice {
200
+ role: string;
201
+ name: string;
202
+ description: string;
203
+ /** Holding it manages the organization's members. */
204
+ manager: boolean;
205
+ }
206
+ /**
207
+ * The signed-in person's organizations, and their people. Seeing them needs
208
+ * cauthy:members read in the person's role; changing them needs manage. Cauthy
209
+ * decides, with the person's own session: the application authorizes nothing.
210
+ */
211
+ interface OrganizationsClient {
212
+ /** The organizations the person belongs to; one system's only with `system`. */
213
+ list(system?: string): Promise<OrganizationSeat[]>;
214
+ /** The people of one, or null when the person may not see them. */
215
+ members(organizationId: string): Promise<OrganizationPerson[] | null>;
216
+ /** The roles a member may be given, or null when the person may not see them. */
217
+ roles(organizationId: string): Promise<OrganizationRoleChoice[] | null>;
218
+ /** Adds a person by their address; an address with no account gets one and its invitation. */
219
+ add(organizationId: string, form: {
220
+ email: string;
221
+ role: string;
222
+ name?: string;
223
+ locale?: string;
224
+ }): Promise<AuthResult<'added', {
225
+ member: OrganizationPerson;
226
+ }>>;
227
+ setRole(organizationId: string, userId: string, role: string): Promise<AuthResult<'changed', {
228
+ userId: string;
229
+ role: string;
230
+ }>>;
231
+ /** Removes a member; the person themself may always leave. */
232
+ remove(organizationId: string, userId: string): Promise<AuthResult<'removed', {
233
+ userId: string;
234
+ }>>;
235
+ /** Sends a member's invitation again. */
236
+ inviteAgain(organizationId: string, userId: string, form?: {
237
+ locale?: string;
238
+ }): Promise<AuthResult<'sent', {
239
+ userId: string;
240
+ }>>;
241
+ }
152
242
  interface AccountSession {
153
243
  /** "Mac · Chrome", or "" when the browser did not say. */
154
244
  device: string;
@@ -271,6 +361,26 @@ interface AccountClient {
271
361
  unlink(provider: string): Promise<AuthResult<'unlinked', {
272
362
  provider: string;
273
363
  }>>;
364
+ /**
365
+ * A guest becomes an account of their own with an address and a password —
366
+ * the same id, so what they did stays theirs. `email_taken`: the address has
367
+ * an account already; offer to sign in with it.
368
+ */
369
+ upgrade(form: {
370
+ email: string;
371
+ password: string;
372
+ name?: string;
373
+ }): Promise<AuthResult<'signed_in', {
374
+ session: PublicSession;
375
+ }>>;
376
+ /** Where a guest goes to become the account of a provider's address (Google…). */
377
+ upgradeUrl(provider: string, options?: {
378
+ returnTo?: string;
379
+ }): string;
380
+ /** Sends a guest to `upgradeUrl`; they come back signed in as the account. */
381
+ upgradeWith(provider: string, options?: {
382
+ returnTo?: string;
383
+ }): void;
274
384
  /** Where the account is signed in. */
275
385
  sessions(): Promise<AccountSession[]>;
276
386
  /** Signs the account out everywhere, here too. */
@@ -304,6 +414,17 @@ interface AccountClient {
304
414
  }
305
415
  interface AuthClient {
306
416
  signIn: {
417
+ /**
418
+ * A guest session, before the visitor signs up: the application keeps what
419
+ * they do under `session.user.id`, and `account.upgrade` (or
420
+ * `account.upgradeWith`) makes it their account, same id. Only where the
421
+ * workspace allows guests (`anonymous_disabled` otherwise).
422
+ */
423
+ anonymously(form?: {
424
+ captchaToken?: string;
425
+ }): Promise<AuthResult<'signed_in', {
426
+ session: PublicSession;
427
+ }>>;
307
428
  /** With address and password. `mfa_required`: ask for the code and call `signIn.mfa`. */
308
429
  email(form: {
309
430
  email: string;
@@ -412,6 +533,38 @@ interface AuthClient {
412
533
  social(provider: string, options?: {
413
534
  returnTo?: string;
414
535
  }): void;
536
+ /**
537
+ * Which company's sign-in a work address uses, if any (`found`), or
538
+ * `none`. It says so of the address's domain, never whether the address
539
+ * has an account.
540
+ */
541
+ ssoDiscover(form: {
542
+ email: string;
543
+ }): Promise<AuthResult<'found', {
544
+ connection: SSOConnection;
545
+ }> | AuthResult<'none'>>;
546
+ /**
547
+ * Sends the browser to the person's company (found by `email`, or named
548
+ * by `connection`); it comes back signed in, at `returnTo`. A sign-in the
549
+ * company refused comes back with `?auth_error=`. Any other way of
550
+ * signing in answers `sso_required` for an address its company holds to
551
+ * SSO: send it here then.
552
+ */
553
+ sso(target: {
554
+ email: string;
555
+ } | {
556
+ connection: string;
557
+ }, options?: {
558
+ returnTo?: string;
559
+ }): void;
560
+ /** Where `sso` sends the browser, for a plain link. */
561
+ ssoUrl(target: {
562
+ email: string;
563
+ } | {
564
+ connection: string;
565
+ }, options?: {
566
+ returnTo?: string;
567
+ }): string;
415
568
  /** Where `social` sends the browser, for a plain link. */
416
569
  socialUrl(provider: string, options?: {
417
570
  returnTo?: string;
@@ -447,6 +600,8 @@ interface AuthClient {
447
600
  signOut(): Promise<AuthResult<'signed_out'>>;
448
601
  /** The signed-in person's own account. */
449
602
  account: AccountClient;
603
+ /** The signed-in person's organizations, and their people. */
604
+ organizations: OrganizationsClient;
450
605
  /** Who is signed in, or null. */
451
606
  getSession(): Promise<PublicSession | null>;
452
607
  methods(): Promise<AuthMethods>;
@@ -470,4 +625,4 @@ interface AuthClientOptions {
470
625
  }
471
626
  declare function createAuthClient(options?: AuthClientOptions): AuthClient;
472
627
 
473
- export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type Passkey, type PasskeyKind, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
628
+ export { type Account, type AccountClient, type AccountSession, type AuthClient, type AuthClientOptions, type AuthError, AuthField, type AuthMethods, type AuthResult, type ConnectedAgent, type LinkedIdentity, type OrganizationPerson, type OrganizationRoleChoice, type OrganizationSeat, type OrganizationsClient, type Passkey, type PasskeyKind, type SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
package/dist/client.js CHANGED
@@ -343,8 +343,14 @@ function createAuthClient(options = {}) {
343
343
  return null;
344
344
  }
345
345
  }
346
+ const upgradeUrl = (provider, o = {}) => `${base}/me/upgrade/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
346
347
  const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
347
348
  const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
349
+ const ssoUrl = (target, o = {}) => {
350
+ const q = new URLSearchParams("connection" in target ? { connection: target.connection } : { email: target.email.trim() });
351
+ if (o.returnTo) q.set("return_to", o.returnTo);
352
+ return `${base}/sign-in/sso?${q}`;
353
+ };
348
354
  const passkeyUrl = (o = {}) => {
349
355
  const q = new URLSearchParams({ method: "passkey" });
350
356
  if (o.returnTo) q.set("return_to", o.returnTo);
@@ -356,11 +362,11 @@ function createAuthClient(options = {}) {
356
362
  const res = await doFetch(`${base}/methods`, { credentials: "same-origin", headers: { accept: "application/json" } });
357
363
  if (res.ok) {
358
364
  const m = await res.json();
359
- return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true };
365
+ return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
360
366
  }
361
367
  } catch {
362
368
  }
363
- return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false };
369
+ return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
364
370
  }
365
371
  async function ceremony(begin, finish, form, run, more = {}) {
366
372
  const begun = await post(begin, form, null);
@@ -375,6 +381,7 @@ function createAuthClient(options = {}) {
375
381
  }
376
382
  return {
377
383
  signIn: {
384
+ anonymously: (f = {}) => post("/sign-in/anonymous", {}, null, f.captchaToken),
378
385
  email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
379
386
  mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
380
387
  mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
@@ -458,6 +465,11 @@ function createAuthClient(options = {}) {
458
465
  socialUrl,
459
466
  social(provider, o) {
460
467
  window.location.assign(socialUrl(provider, o));
468
+ },
469
+ ssoDiscover: (f) => post("/sign-in/sso/discover", { email: f.email.trim() }, checkEmail(f.email)),
470
+ ssoUrl,
471
+ sso(target, o) {
472
+ window.location.assign(ssoUrl(target, o));
461
473
  }
462
474
  },
463
475
  signUp: {
@@ -467,6 +479,24 @@ function createAuthClient(options = {}) {
467
479
  resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
468
480
  verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
469
481
  signOut: () => post("/sign-out", {}, null),
482
+ organizations: {
483
+ async list(system) {
484
+ const body = await read(`/me/organizations${system ? `?system=${encodeURIComponent(system)}` : ""}`);
485
+ return body && Array.isArray(body.organizations) ? body.organizations : [];
486
+ },
487
+ async members(id) {
488
+ const body = await read(`/me/organizations/members?id=${encodeURIComponent(id)}`);
489
+ return body && Array.isArray(body.members) ? body.members : null;
490
+ },
491
+ async roles(id) {
492
+ const body = await read(`/me/organizations/roles?id=${encodeURIComponent(id)}`);
493
+ return body && Array.isArray(body.roles) ? body.roles : null;
494
+ },
495
+ 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)),
496
+ setRole: (id, userId, role) => post("/me/organizations/members/role", { organizationId: id, userId, role }, null),
497
+ remove: (id, userId) => post("/me/organizations/members/remove", { organizationId: id, userId }, null),
498
+ inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null)
499
+ },
470
500
  account: {
471
501
  async get() {
472
502
  const body = await read("/me");
@@ -505,6 +535,11 @@ function createAuthClient(options = {}) {
505
535
  return body && Array.isArray(body.sessions) ? body.sessions : [];
506
536
  },
507
537
  signOutEverywhere: () => post("/me/sessions/end", {}, null),
538
+ upgrade: (f) => post("/me/upgrade", { email: f.email, password: f.password, name: f.name ?? "" }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password))),
539
+ upgradeUrl,
540
+ upgradeWith(provider, o) {
541
+ window.location.assign(upgradeUrl(provider, o));
542
+ },
508
543
  async agents() {
509
544
  const body = await read("/me/agents");
510
545
  return body && Array.isArray(body.agents) ? body.agents : [];