cauthy-auth 0.26.0 → 0.27.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 +43 -2
- package/dist/client.d.ts +43 -2
- package/dist/client.js +7 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +7 -1
- package/dist/client.mjs.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +48 -2
- package/dist/react.d.ts +48 -2
- package/dist/react.js +45 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +45 -2
- package/dist/react.mjs.map +1 -1
- package/dist/styles.css +14 -0
- package/dist/svelte.js +7 -1
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +7 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.js +7 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +7 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -405,7 +405,7 @@ function createAuthClient(options = {}) {
|
|
|
405
405
|
signUp: {
|
|
406
406
|
email: (f) => post(
|
|
407
407
|
"/sign-up/email",
|
|
408
|
-
{ email: f.email, password: f.password, name: f.name, organization: f.organization },
|
|
408
|
+
{ email: f.email, password: f.password, name: f.name, organization: f.organization, acceptLegal: f.acceptLegal, consents: f.consents },
|
|
409
409
|
firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password), checkOrganization(f.organization)),
|
|
410
410
|
f.captchaToken
|
|
411
411
|
)
|
|
@@ -438,6 +438,12 @@ function createAuthClient(options = {}) {
|
|
|
438
438
|
return body && typeof body.account === "object" ? body.account : null;
|
|
439
439
|
},
|
|
440
440
|
update: (f) => post("/me", { name: f.name }, checkName(f.name)),
|
|
441
|
+
async legal() {
|
|
442
|
+
const body = await read("/me/legal");
|
|
443
|
+
if (!body) return { ok: false, error: { code: "not_signed_in", message: "Nobody is signed in." } };
|
|
444
|
+
return { ok: true, status: "ok", pending: Array.isArray(body.pending) ? body.pending : [] };
|
|
445
|
+
},
|
|
446
|
+
acceptLegal: (f = {}) => post("/me/legal/accept", { kinds: f.kinds ?? [] }, null),
|
|
441
447
|
changePassword: (f) => {
|
|
442
448
|
const bad = checkNewPassword(f.newPassword);
|
|
443
449
|
return post("/me/password", { password: f.password, newPassword: f.newPassword }, bad ? { ...bad, field: "newPassword" } : null);
|
|
@@ -578,6 +584,10 @@ var TEXTS = {
|
|
|
578
584
|
noAccount: "No account yet?",
|
|
579
585
|
createAccount: "Create one",
|
|
580
586
|
haveAccount: "Already have an account?",
|
|
587
|
+
iAccept: "I have read and accept",
|
|
588
|
+
and: "and",
|
|
589
|
+
termsOfService: "the Terms of Service",
|
|
590
|
+
privacyPolicy: "the Privacy Policy",
|
|
581
591
|
sendLink: "Send the link",
|
|
582
592
|
linkSent: "If that address has an account, a link to choose a new password is on its way.",
|
|
583
593
|
codeHelp: "Enter the code from your authenticator app, or a recovery code.",
|
|
@@ -730,6 +740,10 @@ var TEXTS = {
|
|
|
730
740
|
noAccount: "\xBFNo tienes cuenta?",
|
|
731
741
|
createAccount: "Crear una",
|
|
732
742
|
haveAccount: "\xBFYa tienes cuenta?",
|
|
743
|
+
iAccept: "He le\xEDdo y acepto",
|
|
744
|
+
and: "y",
|
|
745
|
+
termsOfService: "los T\xE9rminos del servicio",
|
|
746
|
+
privacyPolicy: "la Pol\xEDtica de privacidad",
|
|
733
747
|
sendLink: "Enviar el enlace",
|
|
734
748
|
linkSent: "Si ese correo tiene una cuenta, ya va en camino un enlace para elegir una contrase\xF1a nueva.",
|
|
735
749
|
codeHelp: "Escribe el c\xF3digo de tu aplicaci\xF3n de autenticaci\xF3n, o un c\xF3digo de recuperaci\xF3n.",
|
|
@@ -1277,11 +1291,21 @@ function SignUp(props) {
|
|
|
1277
1291
|
const [sent, setSent] = useState(false);
|
|
1278
1292
|
const methods = useMethods(auth);
|
|
1279
1293
|
const challenge = useChallenge(methods?.captchaSiteKey, props.locale);
|
|
1294
|
+
const [acceptLegal, setAcceptLegal] = useState(false);
|
|
1295
|
+
const [consents, setConsents] = useState({});
|
|
1296
|
+
const legal = methods?.legal;
|
|
1280
1297
|
const submit = async (e) => {
|
|
1281
1298
|
e.preventDefault();
|
|
1282
1299
|
f.setBusy(true);
|
|
1283
1300
|
f.setError(null);
|
|
1284
|
-
const r = auth.session?.user.isAnonymous === true ? await auth.account.upgrade({ name, email, password }) : await auth.signUp.email({
|
|
1301
|
+
const r = auth.session?.user.isAnonymous === true ? await auth.account.upgrade({ name, email, password }) : await auth.signUp.email({
|
|
1302
|
+
name,
|
|
1303
|
+
email,
|
|
1304
|
+
password,
|
|
1305
|
+
...methods?.organization?.ask ? { organization } : {},
|
|
1306
|
+
...legal ? { acceptLegal, consents } : {},
|
|
1307
|
+
captchaToken: challenge.token
|
|
1308
|
+
});
|
|
1285
1309
|
f.setBusy(false);
|
|
1286
1310
|
challenge.renew();
|
|
1287
1311
|
if (!r.ok) return f.setError(r.error);
|
|
@@ -1301,6 +1325,25 @@ function SignUp(props) {
|
|
|
1301
1325
|
/* @__PURE__ */ jsx(Field, { f, name: "name", type: "text", label: f.t.name, value: name, autoComplete: "name", onChange: setName }),
|
|
1302
1326
|
/* @__PURE__ */ jsx(Field, { f, name: "email", type: "email", label: f.t.email, value: email, autoComplete: "username", required: true, onChange: setEmail }),
|
|
1303
1327
|
/* @__PURE__ */ jsx(Field, { f, name: "password", type: "password", label: f.t.password, value: password, autoComplete: "new-password", required: true, onChange: setPassword }),
|
|
1328
|
+
legal && legal.documents.length > 0 && /* @__PURE__ */ jsxs("label", { className: f.cx("check"), children: [
|
|
1329
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", name: "acceptLegal", checked: acceptLegal, required: true, onChange: (e) => setAcceptLegal(e.target.checked) }),
|
|
1330
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1331
|
+
f.t.iAccept,
|
|
1332
|
+
" ",
|
|
1333
|
+
legal.documents.map((d, i) => /* @__PURE__ */ jsxs("span", { children: [
|
|
1334
|
+
i > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1335
|
+
f.t.and,
|
|
1336
|
+
" "
|
|
1337
|
+
] }),
|
|
1338
|
+
/* @__PURE__ */ jsx("a", { className: f.cx("link"), href: d.url, target: "_blank", rel: "noopener", children: d.kind === "terms" ? f.t.termsOfService : f.t.privacyPolicy }),
|
|
1339
|
+
" "
|
|
1340
|
+
] }, d.kind))
|
|
1341
|
+
] })
|
|
1342
|
+
] }),
|
|
1343
|
+
legal?.consentPurposes.map((p) => /* @__PURE__ */ jsxs("label", { className: f.cx("check"), children: [
|
|
1344
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", name: `consent_${p.key}`, checked: consents[p.key] === true, required: p.required, onChange: (e) => setConsents({ ...consents, [p.key]: e.target.checked }) }),
|
|
1345
|
+
/* @__PURE__ */ jsx("span", { children: p.label })
|
|
1346
|
+
] }, p.key)),
|
|
1304
1347
|
challenge.node,
|
|
1305
1348
|
/* @__PURE__ */ jsx(f.Button, { type: "submit", disabled: f.busy, className: f.cx("button"), children: f.t.signUp }),
|
|
1306
1349
|
props.links?.signIn && /* @__PURE__ */ jsxs("p", { className: f.cx("footer"), children: [
|