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/client.d.mts +47 -1
- package/dist/client.d.ts +47 -1
- package/dist/client.js +12 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +12 -2
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +49 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +48 -1
- package/dist/react.d.ts +48 -1
- package/dist/react.js +79 -21
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +79 -21
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +12 -2
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +12 -2
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +12 -2
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +12 -2
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client.d.mts
CHANGED
|
@@ -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),
|
|
@@ -412,6 +426,38 @@ interface AuthClient {
|
|
|
412
426
|
social(provider: string, options?: {
|
|
413
427
|
returnTo?: string;
|
|
414
428
|
}): void;
|
|
429
|
+
/**
|
|
430
|
+
* Which company's sign-in a work address uses, if any (`found`), or
|
|
431
|
+
* `none`. It says so of the address's domain, never whether the address
|
|
432
|
+
* has an account.
|
|
433
|
+
*/
|
|
434
|
+
ssoDiscover(form: {
|
|
435
|
+
email: string;
|
|
436
|
+
}): Promise<AuthResult<'found', {
|
|
437
|
+
connection: SSOConnection;
|
|
438
|
+
}> | AuthResult<'none'>>;
|
|
439
|
+
/**
|
|
440
|
+
* Sends the browser to the person's company (found by `email`, or named
|
|
441
|
+
* by `connection`); it comes back signed in, at `returnTo`. A sign-in the
|
|
442
|
+
* company refused comes back with `?auth_error=`. Any other way of
|
|
443
|
+
* signing in answers `sso_required` for an address its company holds to
|
|
444
|
+
* SSO: send it here then.
|
|
445
|
+
*/
|
|
446
|
+
sso(target: {
|
|
447
|
+
email: string;
|
|
448
|
+
} | {
|
|
449
|
+
connection: string;
|
|
450
|
+
}, options?: {
|
|
451
|
+
returnTo?: string;
|
|
452
|
+
}): void;
|
|
453
|
+
/** Where `sso` sends the browser, for a plain link. */
|
|
454
|
+
ssoUrl(target: {
|
|
455
|
+
email: string;
|
|
456
|
+
} | {
|
|
457
|
+
connection: string;
|
|
458
|
+
}, options?: {
|
|
459
|
+
returnTo?: string;
|
|
460
|
+
}): string;
|
|
415
461
|
/** Where `social` sends the browser, for a plain link. */
|
|
416
462
|
socialUrl(provider: string, options?: {
|
|
417
463
|
returnTo?: string;
|
|
@@ -470,4 +516,4 @@ interface AuthClientOptions {
|
|
|
470
516
|
}
|
|
471
517
|
declare function createAuthClient(options?: AuthClientOptions): AuthClient;
|
|
472
518
|
|
|
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 };
|
|
519
|
+
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 SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
|
package/dist/client.d.ts
CHANGED
|
@@ -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),
|
|
@@ -412,6 +426,38 @@ interface AuthClient {
|
|
|
412
426
|
social(provider: string, options?: {
|
|
413
427
|
returnTo?: string;
|
|
414
428
|
}): void;
|
|
429
|
+
/**
|
|
430
|
+
* Which company's sign-in a work address uses, if any (`found`), or
|
|
431
|
+
* `none`. It says so of the address's domain, never whether the address
|
|
432
|
+
* has an account.
|
|
433
|
+
*/
|
|
434
|
+
ssoDiscover(form: {
|
|
435
|
+
email: string;
|
|
436
|
+
}): Promise<AuthResult<'found', {
|
|
437
|
+
connection: SSOConnection;
|
|
438
|
+
}> | AuthResult<'none'>>;
|
|
439
|
+
/**
|
|
440
|
+
* Sends the browser to the person's company (found by `email`, or named
|
|
441
|
+
* by `connection`); it comes back signed in, at `returnTo`. A sign-in the
|
|
442
|
+
* company refused comes back with `?auth_error=`. Any other way of
|
|
443
|
+
* signing in answers `sso_required` for an address its company holds to
|
|
444
|
+
* SSO: send it here then.
|
|
445
|
+
*/
|
|
446
|
+
sso(target: {
|
|
447
|
+
email: string;
|
|
448
|
+
} | {
|
|
449
|
+
connection: string;
|
|
450
|
+
}, options?: {
|
|
451
|
+
returnTo?: string;
|
|
452
|
+
}): void;
|
|
453
|
+
/** Where `sso` sends the browser, for a plain link. */
|
|
454
|
+
ssoUrl(target: {
|
|
455
|
+
email: string;
|
|
456
|
+
} | {
|
|
457
|
+
connection: string;
|
|
458
|
+
}, options?: {
|
|
459
|
+
returnTo?: string;
|
|
460
|
+
}): string;
|
|
415
461
|
/** Where `social` sends the browser, for a plain link. */
|
|
416
462
|
socialUrl(provider: string, options?: {
|
|
417
463
|
returnTo?: string;
|
|
@@ -470,4 +516,4 @@ interface AuthClientOptions {
|
|
|
470
516
|
}
|
|
471
517
|
declare function createAuthClient(options?: AuthClientOptions): AuthClient;
|
|
472
518
|
|
|
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 };
|
|
519
|
+
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 SSOConnection, type SecondStep, type SessionState, type SessionStore, type SessionStoreOptions, canAutofillPasskeys, canUsePasskeys, createAuthClient, createSessionStore };
|
package/dist/client.js
CHANGED
|
@@ -345,6 +345,11 @@ function createAuthClient(options = {}) {
|
|
|
345
345
|
}
|
|
346
346
|
const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
347
347
|
const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
348
|
+
const ssoUrl = (target, o = {}) => {
|
|
349
|
+
const q = new URLSearchParams("connection" in target ? { connection: target.connection } : { email: target.email.trim() });
|
|
350
|
+
if (o.returnTo) q.set("return_to", o.returnTo);
|
|
351
|
+
return `${base}/sign-in/sso?${q}`;
|
|
352
|
+
};
|
|
348
353
|
const passkeyUrl = (o = {}) => {
|
|
349
354
|
const q = new URLSearchParams({ method: "passkey" });
|
|
350
355
|
if (o.returnTo) q.set("return_to", o.returnTo);
|
|
@@ -356,11 +361,11 @@ function createAuthClient(options = {}) {
|
|
|
356
361
|
const res = await doFetch(`${base}/methods`, { credentials: "same-origin", headers: { accept: "application/json" } });
|
|
357
362
|
if (res.ok) {
|
|
358
363
|
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 };
|
|
364
|
+
return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
|
|
360
365
|
}
|
|
361
366
|
} catch {
|
|
362
367
|
}
|
|
363
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false };
|
|
368
|
+
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
|
|
364
369
|
}
|
|
365
370
|
async function ceremony(begin, finish, form, run, more = {}) {
|
|
366
371
|
const begun = await post(begin, form, null);
|
|
@@ -458,6 +463,11 @@ function createAuthClient(options = {}) {
|
|
|
458
463
|
socialUrl,
|
|
459
464
|
social(provider, o) {
|
|
460
465
|
window.location.assign(socialUrl(provider, o));
|
|
466
|
+
},
|
|
467
|
+
ssoDiscover: (f) => post("/sign-in/sso/discover", { email: f.email.trim() }, checkEmail(f.email)),
|
|
468
|
+
ssoUrl,
|
|
469
|
+
sso(target, o) {
|
|
470
|
+
window.location.assign(ssoUrl(target, o));
|
|
461
471
|
}
|
|
462
472
|
},
|
|
463
473
|
signUp: {
|