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/react.mjs
CHANGED
|
@@ -231,6 +231,11 @@ function createAuthClient(options = {}) {
|
|
|
231
231
|
}
|
|
232
232
|
const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
233
233
|
const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
234
|
+
const ssoUrl = (target, o = {}) => {
|
|
235
|
+
const q = new URLSearchParams("connection" in target ? { connection: target.connection } : { email: target.email.trim() });
|
|
236
|
+
if (o.returnTo) q.set("return_to", o.returnTo);
|
|
237
|
+
return `${base}/sign-in/sso?${q}`;
|
|
238
|
+
};
|
|
234
239
|
const passkeyUrl = (o = {}) => {
|
|
235
240
|
const q = new URLSearchParams({ method: "passkey" });
|
|
236
241
|
if (o.returnTo) q.set("return_to", o.returnTo);
|
|
@@ -242,11 +247,11 @@ function createAuthClient(options = {}) {
|
|
|
242
247
|
const res = await doFetch(`${base}/methods`, { credentials: "same-origin", headers: { accept: "application/json" } });
|
|
243
248
|
if (res.ok) {
|
|
244
249
|
const m = await res.json();
|
|
245
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true };
|
|
250
|
+
return { providers: [], signUp: true, magicLink: false, passkey: false, ...m, passkeyHere: m.passkeyHere === true, passkeyOnCauthy: m.passkeyOnCauthy ?? m.passkey === true, sso: m.sso === true };
|
|
246
251
|
}
|
|
247
252
|
} catch {
|
|
248
253
|
}
|
|
249
|
-
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false };
|
|
254
|
+
return { providers: [], signUp: true, magicLink: false, passkey: false, passkeyHere: false, passkeyOnCauthy: false, sso: false };
|
|
250
255
|
}
|
|
251
256
|
async function ceremony(begin, finish, form, run, more = {}) {
|
|
252
257
|
const begun = await post(begin, form, null);
|
|
@@ -344,6 +349,11 @@ function createAuthClient(options = {}) {
|
|
|
344
349
|
socialUrl,
|
|
345
350
|
social(provider, o) {
|
|
346
351
|
window.location.assign(socialUrl(provider, o));
|
|
352
|
+
},
|
|
353
|
+
ssoDiscover: (f) => post("/sign-in/sso/discover", { email: f.email.trim() }, checkEmail(f.email)),
|
|
354
|
+
ssoUrl,
|
|
355
|
+
sso(target, o) {
|
|
356
|
+
window.location.assign(ssoUrl(target, o));
|
|
347
357
|
}
|
|
348
358
|
},
|
|
349
359
|
signUp: {
|
|
@@ -564,6 +574,7 @@ var TEXTS = {
|
|
|
564
574
|
linkWith: "Link",
|
|
565
575
|
unlink: "Unlink",
|
|
566
576
|
linked: "The account was linked.",
|
|
577
|
+
ssoOnly: "Your company signs you in to this account.",
|
|
567
578
|
errors: {
|
|
568
579
|
required: "This is required.",
|
|
569
580
|
invalid_email: "That does not look like an email address.",
|
|
@@ -592,7 +603,15 @@ var TEXTS = {
|
|
|
592
603
|
captcha_failed: "The check that you are not a bot did not pass. Try it again.",
|
|
593
604
|
passkey_failed: "The passkey could not be used. Try again, or sign in another way.",
|
|
594
605
|
passkey_exists: "This device already has a passkey for your account.",
|
|
595
|
-
passkey_unavailable: "Passkeys cannot be used here."
|
|
606
|
+
passkey_unavailable: "Passkeys cannot be used here.",
|
|
607
|
+
sso_required: "This address signs in through its company.",
|
|
608
|
+
sso_not_found: "No company sign-in answers for this address.",
|
|
609
|
+
sso_failed: "The sign-in with your company could not be completed. Try again.",
|
|
610
|
+
sso_unavailable: "Your company's sign-in cannot be reached right now. Try again in a moment.",
|
|
611
|
+
invalid_assertion: "Your company's answer could not be checked. Try again.",
|
|
612
|
+
provisioning_disabled: "Your company's sign-in worked, but this workspace has no account for you. Ask its admin to add you.",
|
|
613
|
+
connection_inactive: "Your company's sign-in is turned off for this workspace.",
|
|
614
|
+
invalid_grant: "That sign-in expired. Try again."
|
|
596
615
|
}
|
|
597
616
|
},
|
|
598
617
|
es: {
|
|
@@ -679,6 +698,7 @@ var TEXTS = {
|
|
|
679
698
|
linkWith: "Vincular",
|
|
680
699
|
unlink: "Desvincular",
|
|
681
700
|
linked: "La cuenta qued\xF3 vinculada.",
|
|
701
|
+
ssoOnly: "A esta cuenta entras con el inicio de sesi\xF3n de tu empresa.",
|
|
682
702
|
errors: {
|
|
683
703
|
required: "Este dato es obligatorio.",
|
|
684
704
|
invalid_email: "Eso no parece un correo.",
|
|
@@ -707,7 +727,15 @@ var TEXTS = {
|
|
|
707
727
|
captcha_failed: "La verificaci\xF3n de que no eres un robot no pas\xF3. Int\xE9ntalo de nuevo.",
|
|
708
728
|
passkey_failed: "No se pudo usar la llave de acceso. Intenta de nuevo o entra de otra forma.",
|
|
709
729
|
passkey_exists: "Este dispositivo ya tiene una llave de acceso de tu cuenta.",
|
|
710
|
-
passkey_unavailable: "Aqu\xED no se pueden usar llaves de acceso."
|
|
730
|
+
passkey_unavailable: "Aqu\xED no se pueden usar llaves de acceso.",
|
|
731
|
+
sso_required: "Este correo entra con el inicio de sesi\xF3n de su empresa.",
|
|
732
|
+
sso_not_found: "Ninguna empresa usa inicio de sesi\xF3n propio con este correo.",
|
|
733
|
+
sso_failed: "No se pudo completar el ingreso con tu empresa. Intenta de nuevo.",
|
|
734
|
+
sso_unavailable: "Ahora no se puede llegar al inicio de sesi\xF3n de tu empresa. Intenta en un momento.",
|
|
735
|
+
invalid_assertion: "No se pudo verificar la respuesta de tu empresa. Intenta de nuevo.",
|
|
736
|
+
provisioning_disabled: "El ingreso con tu empresa funcion\xF3, pero este workspace no tiene una cuenta para ti. P\xEDdele a su admin que te agregue.",
|
|
737
|
+
connection_inactive: "El inicio de sesi\xF3n de tu empresa est\xE1 apagado en este workspace.",
|
|
738
|
+
invalid_grant: "Ese ingreso venci\xF3. Intenta de nuevo."
|
|
711
739
|
}
|
|
712
740
|
}
|
|
713
741
|
};
|
|
@@ -900,6 +928,25 @@ function SignIn(props) {
|
|
|
900
928
|
};
|
|
901
929
|
const autofill = useRef(null);
|
|
902
930
|
const [offer, setOffer] = useState(0);
|
|
931
|
+
const [company, setCompany] = useState(null);
|
|
932
|
+
useEffect(() => {
|
|
933
|
+
if (!methods?.sso || checkEmail(email) !== null) return setCompany(null);
|
|
934
|
+
let current = true;
|
|
935
|
+
const t = setTimeout(() => {
|
|
936
|
+
void auth.signIn.ssoDiscover({ email }).then((r) => {
|
|
937
|
+
if (current) setCompany(r.ok && r.status === "found" ? r.connection : null);
|
|
938
|
+
});
|
|
939
|
+
}, 350);
|
|
940
|
+
return () => {
|
|
941
|
+
current = false;
|
|
942
|
+
clearTimeout(t);
|
|
943
|
+
};
|
|
944
|
+
}, [email, methods]);
|
|
945
|
+
const toCompany = () => {
|
|
946
|
+
autofill.current?.abort();
|
|
947
|
+
f.setBusy(true);
|
|
948
|
+
auth.signIn.sso({ email }, { returnTo: props.returnTo });
|
|
949
|
+
};
|
|
903
950
|
useEffect(() => {
|
|
904
951
|
void auth.methods().then(setMethods);
|
|
905
952
|
const back = returnedError();
|
|
@@ -932,9 +979,11 @@ function SignIn(props) {
|
|
|
932
979
|
autofill.current?.abort();
|
|
933
980
|
f.setBusy(true);
|
|
934
981
|
f.setError(null);
|
|
982
|
+
if (step === "password" && company?.enforced) return toCompany();
|
|
935
983
|
const r = step === "code" ? await auth.signIn.mfa({ code }) : step === "sent" ? await auth.signIn.emailCode({ code }) : await auth.signIn.email({ email, password, captchaToken: challenge.token });
|
|
936
984
|
f.setBusy(false);
|
|
937
985
|
if (step === "password") challenge.renew();
|
|
986
|
+
if (!r.ok && r.error.code === "sso_required") return toCompany();
|
|
938
987
|
if (!r.ok) {
|
|
939
988
|
setOffer((n) => n + 1);
|
|
940
989
|
return f.setError(r.error);
|
|
@@ -960,6 +1009,7 @@ function SignIn(props) {
|
|
|
960
1009
|
const r = await auth.signIn.magicLink({ email, captchaToken: challenge.token, create: props.createAccounts, returnTo: props.returnTo });
|
|
961
1010
|
f.setBusy(false);
|
|
962
1011
|
challenge.renew();
|
|
1012
|
+
if (!r.ok && r.error.code === "sso_required") return toCompany();
|
|
963
1013
|
if (!r.ok) return f.setError(r.error);
|
|
964
1014
|
setStep("sent");
|
|
965
1015
|
};
|
|
@@ -994,23 +1044,31 @@ function SignIn(props) {
|
|
|
994
1044
|
methods?.passkey && /* @__PURE__ */ jsx(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => void usePasskey(), children: f.t.usePasskey }),
|
|
995
1045
|
((methods?.providers.length ?? 0) > 0 || methods?.passkey) && /* @__PURE__ */ jsx("p", { className: f.cx("separator"), children: f.t.orWithEmail }),
|
|
996
1046
|
/* @__PURE__ */ jsx(Field, { f, name: "email", type: "email", label: f.t.email, value: email, autoComplete: methods?.passkeyHere ? "username webauthn" : "username", required: true, onChange: setEmail }),
|
|
997
|
-
/* @__PURE__ */
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1047
|
+
company && /* @__PURE__ */ jsxs(f.Button, { type: "button", disabled: f.busy, className: f.cx(company.enforced ? "button" : "providerButton"), onClick: toCompany, children: [
|
|
1048
|
+
f.t.continueWith,
|
|
1049
|
+
" ",
|
|
1050
|
+
company.name
|
|
1051
|
+
] }),
|
|
1052
|
+
company?.enforced && /* @__PURE__ */ jsx("p", { className: f.cx("notice"), children: f.t.ssoOnly }),
|
|
1053
|
+
!company?.enforced && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1054
|
+
/* @__PURE__ */ jsx(
|
|
1055
|
+
Field,
|
|
1056
|
+
{
|
|
1057
|
+
f,
|
|
1058
|
+
name: "password",
|
|
1059
|
+
type: "password",
|
|
1060
|
+
label: f.t.password,
|
|
1061
|
+
value: password,
|
|
1062
|
+
autoComplete: "current-password",
|
|
1063
|
+
required: true,
|
|
1064
|
+
onChange: setPassword,
|
|
1065
|
+
aside: props.links?.forgotPassword ? /* @__PURE__ */ jsx("a", { className: f.cx("link"), href: props.links.forgotPassword, children: f.t.forgotPassword }) : void 0
|
|
1066
|
+
}
|
|
1067
|
+
),
|
|
1068
|
+
challenge.node,
|
|
1069
|
+
/* @__PURE__ */ jsx(f.Button, { type: "submit", disabled: f.busy, className: f.cx("button"), children: f.t.signIn })
|
|
1070
|
+
] }),
|
|
1071
|
+
methods?.magicLink && !company?.enforced && /* @__PURE__ */ jsx(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => void sendLink(), children: f.t.emailMeALink }),
|
|
1014
1072
|
methods?.signUp !== false && props.links?.signUp && /* @__PURE__ */ jsxs("p", { className: f.cx("footer"), children: [
|
|
1015
1073
|
f.t.noAccount,
|
|
1016
1074
|
" ",
|