cauthy-auth 0.20.0 → 0.23.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/{cauthy-Bn3iv50y.d.ts → cauthy-DGAy45G2.d.ts} +1 -1
- package/dist/{cauthy-C29HCvag.d.mts → cauthy-XkIbG5gE.d.mts} +1 -1
- package/dist/client.d.mts +133 -3
- package/dist/client.d.ts +133 -3
- package/dist/client.js +54 -0
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +54 -0
- package/dist/client.mjs.map +1 -1
- package/dist/express.d.mts +2 -2
- package/dist/express.d.ts +2 -2
- package/dist/fastify.d.mts +2 -2
- package/dist/fastify.d.ts +2 -2
- package/dist/hono.d.mts +2 -2
- package/dist/hono.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +178 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -5
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/react.d.mts +171 -2
- package/dist/react.d.ts +171 -2
- package/dist/react.js +261 -3
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +260 -3
- package/dist/react.mjs.map +1 -1
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +54 -0
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +54 -0
- package/dist/svelte.mjs.map +1 -1
- package/dist/{system-ZD_Wa8Bm.d.mts → system-BxMsSIu1.d.mts} +2 -0
- package/dist/{system-DhRr_WxR.d.ts → system-DTIeDXDP.d.ts} +2 -0
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +54 -0
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +54 -0
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(react_exports, {
|
|
|
25
25
|
CauthyProvider: () => CauthyProvider,
|
|
26
26
|
ForgotPassword: () => ForgotPassword,
|
|
27
27
|
GoogleOneTap: () => GoogleOneTap,
|
|
28
|
+
OrganizationMembers: () => OrganizationMembers,
|
|
28
29
|
ResetPassword: () => ResetPassword,
|
|
29
30
|
SignIn: () => SignIn,
|
|
30
31
|
SignUp: () => SignUp,
|
|
@@ -266,6 +267,7 @@ function createAuthClient(options = {}) {
|
|
|
266
267
|
return null;
|
|
267
268
|
}
|
|
268
269
|
}
|
|
270
|
+
const upgradeUrl = (provider, o = {}) => `${base}/me/upgrade/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
269
271
|
const linkUrl = (provider, o = {}) => `${base}/me/identities/link/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
270
272
|
const socialUrl = (provider, o = {}) => `${base}/sign-in/social/${encodeURIComponent(provider)}${o.returnTo ? `?return_to=${encodeURIComponent(o.returnTo)}` : ""}`;
|
|
271
273
|
const ssoUrl = (target, o = {}) => {
|
|
@@ -303,10 +305,40 @@ function createAuthClient(options = {}) {
|
|
|
303
305
|
}
|
|
304
306
|
return {
|
|
305
307
|
signIn: {
|
|
308
|
+
anonymously: (f = {}) => post("/sign-in/anonymous", {}, null, f.captchaToken),
|
|
306
309
|
email: (f) => post("/sign-in/email", { email: f.email, password: f.password }, firstProblem(checkEmail(f.email), checkPassword(f.password)), f.captchaToken),
|
|
307
310
|
mfa: (f) => post("/sign-in/mfa", { code: f.code }, checkCode(f.code)),
|
|
308
311
|
mfaMethods: () => post("/sign-in/mfa/methods", {}, null),
|
|
309
312
|
mfaSendCode: () => post("/sign-in/mfa/send", {}, null),
|
|
313
|
+
mfaPush: () => post("/sign-in/mfa/push", {}, null),
|
|
314
|
+
async mfaPushWait(o = {}) {
|
|
315
|
+
const status = await new Promise((resolve) => {
|
|
316
|
+
if (typeof EventSource !== "function") return resolve("approved");
|
|
317
|
+
const source = new EventSource(`${base}/sign-in/mfa/push/events`, { withCredentials: true });
|
|
318
|
+
const stop = (st) => {
|
|
319
|
+
source.close();
|
|
320
|
+
resolve(st);
|
|
321
|
+
};
|
|
322
|
+
o.signal?.addEventListener("abort", () => stop("aborted"));
|
|
323
|
+
source.addEventListener("status", (e) => {
|
|
324
|
+
const st = (() => {
|
|
325
|
+
try {
|
|
326
|
+
return String(JSON.parse(e.data).status);
|
|
327
|
+
} catch {
|
|
328
|
+
return "";
|
|
329
|
+
}
|
|
330
|
+
})();
|
|
331
|
+
if (st && st !== "pending") stop(st);
|
|
332
|
+
});
|
|
333
|
+
source.onerror = () => {
|
|
334
|
+
if (source.readyState === EventSource.CLOSED) stop("expired");
|
|
335
|
+
};
|
|
336
|
+
});
|
|
337
|
+
if (status === "aborted") return { ok: false, error: { code: "aborted", message: "Stopped waiting." } };
|
|
338
|
+
if (status === "denied") return { ok: false, error: { code: "push_denied", message: "The sign-in was turned down on the phone." } };
|
|
339
|
+
if (status === "expired") return { ok: false, error: { code: "push_expired", message: "Nobody answered on the phone in time." } };
|
|
340
|
+
return post("/sign-in/mfa/push/finish", {}, null);
|
|
341
|
+
},
|
|
310
342
|
magicLink: (f) => post("/sign-in/magic-link", { email: f.email, ...f.create ? { create: true } : {}, ...f.returnTo ? { returnTo: f.returnTo } : {} }, checkEmail(f.email), f.captchaToken),
|
|
311
343
|
magicLinkVerify: (f) => post("/sign-in/magic-link/verify", { token: f.token }, null),
|
|
312
344
|
emailCode: (f) => post("/sign-in/email-code", { code: f.code }, checkCode(f.code)),
|
|
@@ -400,6 +432,24 @@ function createAuthClient(options = {}) {
|
|
|
400
432
|
resetPassword: (f) => post("/reset-password", { token: f.token, password: f.password }, checkNewPassword(f.password)),
|
|
401
433
|
verifyEmail: (f) => post("/verify-email", { token: f.token }, null),
|
|
402
434
|
signOut: () => post("/sign-out", {}, null),
|
|
435
|
+
organizations: {
|
|
436
|
+
async list(system) {
|
|
437
|
+
const body = await read(`/me/organizations${system ? `?system=${encodeURIComponent(system)}` : ""}`);
|
|
438
|
+
return body && Array.isArray(body.organizations) ? body.organizations : [];
|
|
439
|
+
},
|
|
440
|
+
async members(id) {
|
|
441
|
+
const body = await read(`/me/organizations/members?id=${encodeURIComponent(id)}`);
|
|
442
|
+
return body && Array.isArray(body.members) ? body.members : null;
|
|
443
|
+
},
|
|
444
|
+
async roles(id) {
|
|
445
|
+
const body = await read(`/me/organizations/roles?id=${encodeURIComponent(id)}`);
|
|
446
|
+
return body && Array.isArray(body.roles) ? body.roles : null;
|
|
447
|
+
},
|
|
448
|
+
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)),
|
|
449
|
+
setRole: (id, userId, role) => post("/me/organizations/members/role", { organizationId: id, userId, role }, null),
|
|
450
|
+
remove: (id, userId) => post("/me/organizations/members/remove", { organizationId: id, userId }, null),
|
|
451
|
+
inviteAgain: (id, userId, f = {}) => post("/me/organizations/members/invite", { organizationId: id, userId, locale: f.locale ?? "" }, null)
|
|
452
|
+
},
|
|
403
453
|
account: {
|
|
404
454
|
async get() {
|
|
405
455
|
const body = await read("/me");
|
|
@@ -438,6 +488,11 @@ function createAuthClient(options = {}) {
|
|
|
438
488
|
return body && Array.isArray(body.sessions) ? body.sessions : [];
|
|
439
489
|
},
|
|
440
490
|
signOutEverywhere: () => post("/me/sessions/end", {}, null),
|
|
491
|
+
upgrade: (f) => post("/me/upgrade", { email: f.email, password: f.password, name: f.name ?? "" }, firstProblem(checkName(f.name), checkEmail(f.email), checkNewPassword(f.password))),
|
|
492
|
+
upgradeUrl,
|
|
493
|
+
upgradeWith(provider, o) {
|
|
494
|
+
window.location.assign(upgradeUrl(provider, o));
|
|
495
|
+
},
|
|
441
496
|
async agents() {
|
|
442
497
|
const body = await read("/me/agents");
|
|
443
498
|
return body && Array.isArray(body.agents) ? body.agents : [];
|
|
@@ -548,6 +603,9 @@ var TEXTS = {
|
|
|
548
603
|
sendCodeSms: "Send a code by SMS to {to}",
|
|
549
604
|
sendCodeWhatsapp: "Send a code by WhatsApp to {to}",
|
|
550
605
|
codeSent: "We sent a code to {to}. Type it here.",
|
|
606
|
+
pushSend: "Approve on my phone",
|
|
607
|
+
pushPick: "On your phone, pick {n}",
|
|
608
|
+
pushWaiting: "We sent a notification to your phone. Open it and pick this number.",
|
|
551
609
|
phone: "Phone, with its country code",
|
|
552
610
|
phoneHelp: "Get your codes by SMS or WhatsApp instead of an app.",
|
|
553
611
|
phoneOn: "Codes go to {to}.",
|
|
@@ -612,7 +670,29 @@ var TEXTS = {
|
|
|
612
670
|
unlink: "Unlink",
|
|
613
671
|
linked: "The account was linked.",
|
|
614
672
|
ssoOnly: "Your company signs you in to this account.",
|
|
673
|
+
members: "Members",
|
|
674
|
+
membersHidden: "Your role here does not let you see the members.",
|
|
675
|
+
organizationMissing: "You do not belong to this organization.",
|
|
676
|
+
memberYou: "you",
|
|
677
|
+
memberInvited: "invited",
|
|
678
|
+
memberManager: "manages members",
|
|
679
|
+
memberRole: "Role",
|
|
680
|
+
memberAdd: "Add member",
|
|
681
|
+
memberAdded: "{email} is a member now.",
|
|
682
|
+
memberRemove: "Remove",
|
|
683
|
+
memberRemoveConfirm: "Remove {who}?",
|
|
684
|
+
memberLeave: "Leave",
|
|
685
|
+
memberLeaveConfirm: "Leave {org}? You will need an invitation to come back.",
|
|
686
|
+
memberInviteAgain: "Send the invitation again",
|
|
687
|
+
memberInvitationSent: "The invitation is on its way.",
|
|
688
|
+
yes: "Yes",
|
|
689
|
+
cancel: "Cancel",
|
|
615
690
|
errors: {
|
|
691
|
+
not_allowed: "Your role in this organization does not allow that.",
|
|
692
|
+
last_manager: "Somebody else must manage the members first: give that role to another member.",
|
|
693
|
+
already_member: "That person already belongs to the organization. Change their role instead.",
|
|
694
|
+
unknown_role: "Choose one of the roles offered.",
|
|
695
|
+
user_not_active: "That account is disabled.",
|
|
616
696
|
required: "This is required.",
|
|
617
697
|
invalid_email: "That does not look like an email address.",
|
|
618
698
|
too_short: "Use at least 8 characters.",
|
|
@@ -672,6 +752,9 @@ var TEXTS = {
|
|
|
672
752
|
sendCodeSms: "Enviar un c\xF3digo por SMS a {to}",
|
|
673
753
|
sendCodeWhatsapp: "Enviar un c\xF3digo por WhatsApp a {to}",
|
|
674
754
|
codeSent: "Te enviamos un c\xF3digo a {to}. Escr\xEDbelo aqu\xED.",
|
|
755
|
+
pushSend: "Aprobar en mi tel\xE9fono",
|
|
756
|
+
pushPick: "En tu tel\xE9fono, elige el {n}",
|
|
757
|
+
pushWaiting: "Enviamos una notificaci\xF3n a tu tel\xE9fono. \xC1brela y elige este n\xFAmero.",
|
|
675
758
|
phone: "Tel\xE9fono, con su c\xF3digo de pa\xEDs",
|
|
676
759
|
phoneHelp: "Recibe tus c\xF3digos por SMS o WhatsApp en vez de una app.",
|
|
677
760
|
phoneOn: "Los c\xF3digos van a {to}.",
|
|
@@ -736,7 +819,29 @@ var TEXTS = {
|
|
|
736
819
|
unlink: "Desvincular",
|
|
737
820
|
linked: "La cuenta qued\xF3 vinculada.",
|
|
738
821
|
ssoOnly: "A esta cuenta entras con el inicio de sesi\xF3n de tu empresa.",
|
|
822
|
+
members: "Miembros",
|
|
823
|
+
membersHidden: "Tu rol aqu\xED no te deja ver los miembros.",
|
|
824
|
+
organizationMissing: "No perteneces a esta organizaci\xF3n.",
|
|
825
|
+
memberYou: "t\xFA",
|
|
826
|
+
memberInvited: "invitado",
|
|
827
|
+
memberManager: "administra los miembros",
|
|
828
|
+
memberRole: "Rol",
|
|
829
|
+
memberAdd: "Agregar miembro",
|
|
830
|
+
memberAdded: "{email} ya es miembro.",
|
|
831
|
+
memberRemove: "Quitar",
|
|
832
|
+
memberRemoveConfirm: "\xBFQuitar a {who}?",
|
|
833
|
+
memberLeave: "Salir",
|
|
834
|
+
memberLeaveConfirm: "\xBFSalir de {org}? Necesitar\xE1s una invitaci\xF3n para volver.",
|
|
835
|
+
memberInviteAgain: "Enviar la invitaci\xF3n de nuevo",
|
|
836
|
+
memberInvitationSent: "La invitaci\xF3n va en camino.",
|
|
837
|
+
yes: "S\xED",
|
|
838
|
+
cancel: "Cancelar",
|
|
739
839
|
errors: {
|
|
840
|
+
not_allowed: "Tu rol en esta organizaci\xF3n no permite eso.",
|
|
841
|
+
last_manager: "Primero alguien m\xE1s debe administrar los miembros: dale ese rol a otro miembro.",
|
|
842
|
+
already_member: "Esa persona ya pertenece a la organizaci\xF3n. Cambia su rol.",
|
|
843
|
+
unknown_role: "Escoge uno de los roles ofrecidos.",
|
|
844
|
+
user_not_active: "Esa cuenta est\xE1 desactivada.",
|
|
740
845
|
required: "Este dato es obligatorio.",
|
|
741
846
|
invalid_email: "Eso no parece un correo.",
|
|
742
847
|
too_short: "Usa al menos 8 caracteres.",
|
|
@@ -952,9 +1057,28 @@ function SignIn(props) {
|
|
|
952
1057
|
(0, import_react.useEffect)(() => {
|
|
953
1058
|
if (step !== "code") return;
|
|
954
1059
|
void auth.signIn.mfaMethods().then((r) => {
|
|
955
|
-
if (r.ok) setPhoneWay({ totp: r.totp, phone: r.phone });
|
|
1060
|
+
if (r.ok) setPhoneWay({ totp: r.totp, phone: r.phone, push: r.push });
|
|
956
1061
|
});
|
|
957
1062
|
}, [step]);
|
|
1063
|
+
const [pushNumber, setPushNumber] = (0, import_react.useState)(0);
|
|
1064
|
+
const pushWait = (0, import_react.useRef)(null);
|
|
1065
|
+
(0, import_react.useEffect)(() => () => pushWait.current?.abort(), []);
|
|
1066
|
+
const sendPush = async () => {
|
|
1067
|
+
f.setBusy(true);
|
|
1068
|
+
f.setError(null);
|
|
1069
|
+
const r = await auth.signIn.mfaPush();
|
|
1070
|
+
f.setBusy(false);
|
|
1071
|
+
if (!r.ok) return f.setError(r.error);
|
|
1072
|
+
setPushNumber(r.number);
|
|
1073
|
+
pushWait.current?.abort();
|
|
1074
|
+
const ctl = new AbortController();
|
|
1075
|
+
pushWait.current = ctl;
|
|
1076
|
+
const done = await auth.signIn.mfaPushWait({ signal: ctl.signal });
|
|
1077
|
+
if (ctl.signal.aborted) return;
|
|
1078
|
+
setPushNumber(0);
|
|
1079
|
+
if (!done.ok) return f.setError(done.error);
|
|
1080
|
+
f.done();
|
|
1081
|
+
};
|
|
958
1082
|
const sendCode = async () => {
|
|
959
1083
|
f.setBusy(true);
|
|
960
1084
|
f.setError(null);
|
|
@@ -1066,6 +1190,11 @@ function SignIn(props) {
|
|
|
1066
1190
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: f.cx("form"), ...f.root, onSubmit: submit, noValidate: true, children: [
|
|
1067
1191
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: f.cx("notice"), children: phoneSent ? f.t.codeSent.replace("{to}", phoneSent) : phoneWay?.phone && !phoneWay.totp ? f.t.codeHelpPhone : f.t.codeHelp }),
|
|
1068
1192
|
general && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", className: f.cx("error"), children: f.say(general) }),
|
|
1193
|
+
pushNumber > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: f.cx("notice"), role: "status", "aria-live": "polite", children: [
|
|
1194
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: f.t.pushPick.replace("{n}", String(pushNumber)) }),
|
|
1195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { fontSize: 48, fontWeight: 700, margin: "4px 0", textAlign: "center" }, children: pushNumber }),
|
|
1196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: f.t.pushWaiting })
|
|
1197
|
+
] }) : phoneWay?.push && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("button"), onClick: () => void sendPush(), children: f.t.pushSend }),
|
|
1069
1198
|
phoneWay?.phone && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => void sendCode(), children: (phoneWay.phone.channel === "whatsapp" ? f.t.sendCodeWhatsapp : f.t.sendCodeSms).replace("{to}", to) }),
|
|
1070
1199
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { f, name: "code", type: "text", label: f.t.code, value: code, autoComplete: "one-time-code", required: true, onChange: setCode }),
|
|
1071
1200
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "submit", disabled: f.busy, className: f.cx("button"), children: f.t.verify })
|
|
@@ -1140,7 +1269,7 @@ function SignUp(props) {
|
|
|
1140
1269
|
e.preventDefault();
|
|
1141
1270
|
f.setBusy(true);
|
|
1142
1271
|
f.setError(null);
|
|
1143
|
-
const r = await auth.signUp.email({ name, email, password, captchaToken: challenge.token });
|
|
1272
|
+
const r = auth.session?.user.isAnonymous === true ? await auth.account.upgrade({ name, email, password }) : await auth.signUp.email({ name, email, password, captchaToken: challenge.token });
|
|
1144
1273
|
f.setBusy(false);
|
|
1145
1274
|
challenge.renew();
|
|
1146
1275
|
if (!r.ok) return f.setError(r.error);
|
|
@@ -1310,6 +1439,130 @@ function Account(props) {
|
|
|
1310
1439
|
] })
|
|
1311
1440
|
] });
|
|
1312
1441
|
}
|
|
1442
|
+
function OrganizationMembers(props) {
|
|
1443
|
+
const auth = useAuth();
|
|
1444
|
+
const { root } = useForm(props);
|
|
1445
|
+
const { f, done, setDone, run } = useSection(props);
|
|
1446
|
+
const problem = f.error && f.error.field !== "email" ? f.error : null;
|
|
1447
|
+
const [seat, setSeat] = (0, import_react.useState)(void 0);
|
|
1448
|
+
const [members, setMembers] = (0, import_react.useState)(null);
|
|
1449
|
+
const [roles, setRoles] = (0, import_react.useState)([]);
|
|
1450
|
+
const [email, setEmail] = (0, import_react.useState)("");
|
|
1451
|
+
const [role, setRole] = (0, import_react.useState)("");
|
|
1452
|
+
const [asking, setAsking] = (0, import_react.useState)(null);
|
|
1453
|
+
const id = props.organizationId;
|
|
1454
|
+
const when = props.formatDate ?? ((iso) => new Date(iso).toLocaleDateString());
|
|
1455
|
+
const load = async () => {
|
|
1456
|
+
const [list, people, choices] = await Promise.all([auth.organizations.list(), auth.organizations.members(id), auth.organizations.roles(id)]);
|
|
1457
|
+
setSeat(list.find((o) => o.id === id) ?? null);
|
|
1458
|
+
setMembers(people);
|
|
1459
|
+
setRoles(choices ?? []);
|
|
1460
|
+
if (choices && choices.length > 0 && !choices.some((c) => c.role === role)) setRole(choices[0].role);
|
|
1461
|
+
};
|
|
1462
|
+
(0, import_react.useEffect)(() => {
|
|
1463
|
+
void load();
|
|
1464
|
+
}, [id]);
|
|
1465
|
+
if (seat === void 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: f.cx("account"), ...root, "aria-busy": "true" });
|
|
1466
|
+
if (seat === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: f.cx("account"), ...root, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: f.cx("notice"), children: f.t.organizationMissing }) });
|
|
1467
|
+
const manage = seat.can.manageMembers;
|
|
1468
|
+
const label = (r) => roles.find((c) => c.role === r)?.name || r;
|
|
1469
|
+
const add = async (e) => {
|
|
1470
|
+
e.preventDefault();
|
|
1471
|
+
const r = await run(() => auth.organizations.add(id, { email, role, locale: props.locale }));
|
|
1472
|
+
if (!r.ok) return;
|
|
1473
|
+
setEmail("");
|
|
1474
|
+
setDone(f.t.memberAdded.replace("{email}", r.member.email));
|
|
1475
|
+
await load();
|
|
1476
|
+
};
|
|
1477
|
+
const change = async (m, next) => {
|
|
1478
|
+
const r = await run(() => auth.organizations.setRole(id, m.userId, next));
|
|
1479
|
+
if (r.ok) await load();
|
|
1480
|
+
};
|
|
1481
|
+
const remove = async (m) => {
|
|
1482
|
+
setAsking(null);
|
|
1483
|
+
const r = await run(() => auth.organizations.remove(id, m.userId));
|
|
1484
|
+
if (!r.ok) return;
|
|
1485
|
+
if (m.you) setSeat(null);
|
|
1486
|
+
else await load();
|
|
1487
|
+
};
|
|
1488
|
+
const inviteAgain = async (m) => {
|
|
1489
|
+
const r = await run(() => auth.organizations.inviteAgain(id, m.userId, { locale: props.locale }));
|
|
1490
|
+
if (r.ok) setDone(f.t.memberInvitationSent);
|
|
1491
|
+
};
|
|
1492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: f.cx("account"), ...root, children: [
|
|
1493
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: f.cx("section"), children: [
|
|
1494
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: f.cx("heading"), children: [
|
|
1495
|
+
f.t.members,
|
|
1496
|
+
" \xB7 ",
|
|
1497
|
+
seat.name
|
|
1498
|
+
] }),
|
|
1499
|
+
problem && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", className: f.cx("error"), children: f.say(problem) }),
|
|
1500
|
+
members === null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1501
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: f.cx("notice"), children: f.t.membersHidden }),
|
|
1502
|
+
auth.session && (asking === auth.session.user.id ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { role: "group", "aria-label": f.t.memberLeave, children: [
|
|
1503
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: f.t.memberLeaveConfirm.replace("{org}", seat.name) }),
|
|
1504
|
+
" ",
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1506
|
+
f.Button,
|
|
1507
|
+
{
|
|
1508
|
+
type: "button",
|
|
1509
|
+
disabled: f.busy,
|
|
1510
|
+
className: f.cx("providerButton"),
|
|
1511
|
+
onClick: () => void remove({ userId: auth.session.user.id, you: true }),
|
|
1512
|
+
children: f.t.yes
|
|
1513
|
+
}
|
|
1514
|
+
),
|
|
1515
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => setAsking(null), children: f.t.cancel })
|
|
1516
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => setAsking(auth.session.user.id), children: f.t.memberLeave }))
|
|
1517
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: f.cx("sessions"), children: members.map((m) => {
|
|
1518
|
+
const who = m.name || m.email;
|
|
1519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: f.cx("session"), children: [
|
|
1520
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1521
|
+
who,
|
|
1522
|
+
m.name ? ` \xB7 ${m.email}` : "",
|
|
1523
|
+
m.you ? ` (${f.t.memberYou})` : "",
|
|
1524
|
+
m.invited ? ` \xB7 ${f.t.memberInvited}` : "",
|
|
1525
|
+
m.manager ? ` \xB7 ${f.t.memberManager}` : "",
|
|
1526
|
+
" \xB7 ",
|
|
1527
|
+
when(m.since)
|
|
1528
|
+
] }),
|
|
1529
|
+
" ",
|
|
1530
|
+
manage && roles.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1531
|
+
"select",
|
|
1532
|
+
{
|
|
1533
|
+
"aria-label": `${f.t.memberRole}: ${who}`,
|
|
1534
|
+
className: f.cx("input"),
|
|
1535
|
+
value: m.role,
|
|
1536
|
+
disabled: f.busy,
|
|
1537
|
+
onChange: (e) => void change(m, e.target.value),
|
|
1538
|
+
children: roles.map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: c.role, children: c.name || c.role }, c.role))
|
|
1539
|
+
}
|
|
1540
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: label(m.role) }),
|
|
1541
|
+
" ",
|
|
1542
|
+
asking === m.userId ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { role: "group", "aria-label": m.you ? f.t.memberLeave : f.t.memberRemove, children: [
|
|
1543
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: m.you ? f.t.memberLeaveConfirm.replace("{org}", seat.name) : f.t.memberRemoveConfirm.replace("{who}", who) }),
|
|
1544
|
+
" ",
|
|
1545
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => void remove(m), children: f.t.yes }),
|
|
1546
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => setAsking(null), children: f.t.cancel })
|
|
1547
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1548
|
+
manage && m.invited && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => void inviteAgain(m), children: f.t.memberInviteAgain }),
|
|
1549
|
+
(manage || m.you) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => setAsking(m.userId), children: m.you ? f.t.memberLeave : f.t.memberRemove })
|
|
1550
|
+
] })
|
|
1551
|
+
] }, m.userId);
|
|
1552
|
+
}) }),
|
|
1553
|
+
done && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", className: f.cx("notice"), children: done })
|
|
1554
|
+
] }),
|
|
1555
|
+
manage && roles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: f.cx("section"), onSubmit: add, noValidate: true, children: [
|
|
1556
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: f.cx("heading"), children: f.t.memberAdd }),
|
|
1557
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { f, name: "email", type: "email", label: f.t.email, value: email, autoComplete: "off", required: true, onChange: setEmail }),
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: f.cx("field"), children: [
|
|
1559
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: f.cx("label"), children: f.t.memberRole }),
|
|
1560
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { name: "role", className: f.cx("input"), value: role, onChange: (e) => setRole(e.target.value), children: roles.map((c) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: c.role, children: c.name || c.role }, c.role)) })
|
|
1561
|
+
] }),
|
|
1562
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(f.Button, { type: "submit", disabled: f.busy, className: f.cx("button"), children: f.t.memberAdd })
|
|
1563
|
+
] })
|
|
1564
|
+
] });
|
|
1565
|
+
}
|
|
1313
1566
|
function PasskeysPart({ props, account, accountUrl, when }) {
|
|
1314
1567
|
const auth = useAuth();
|
|
1315
1568
|
const { f, done, setDone, run, general } = useSection(props);
|
|
@@ -1731,8 +1984,10 @@ function useAuth() {
|
|
|
1731
1984
|
...client,
|
|
1732
1985
|
signIn: {
|
|
1733
1986
|
...client.signIn,
|
|
1987
|
+
anonymously: (f) => then(client.signIn.anonymously(f)),
|
|
1734
1988
|
email: (f) => then(client.signIn.email(f)),
|
|
1735
1989
|
mfa: (f) => then(client.signIn.mfa(f)),
|
|
1990
|
+
mfaPushWait: (o) => then(client.signIn.mfaPushWait(o)),
|
|
1736
1991
|
magicLinkVerify: (f) => then(client.signIn.magicLinkVerify(f)),
|
|
1737
1992
|
emailCode: (f) => then(client.signIn.emailCode(f)),
|
|
1738
1993
|
passkey: (o) => then(client.signIn.passkey(o)),
|
|
@@ -1746,7 +2001,9 @@ function useAuth() {
|
|
|
1746
2001
|
// What is on screen says the new name, and knows when the session ended.
|
|
1747
2002
|
update: (f) => then(client.account.update(f)),
|
|
1748
2003
|
changePassword: (f) => then(client.account.changePassword(f)),
|
|
1749
|
-
signOutEverywhere: () => then(client.account.signOutEverywhere())
|
|
2004
|
+
signOutEverywhere: () => then(client.account.signOutEverywhere()),
|
|
2005
|
+
// The guest is now the account: what is on screen says so.
|
|
2006
|
+
upgrade: (f) => then(client.account.upgrade(f))
|
|
1750
2007
|
},
|
|
1751
2008
|
session,
|
|
1752
2009
|
status,
|
|
@@ -1760,6 +2017,7 @@ function useAuth() {
|
|
|
1760
2017
|
CauthyProvider,
|
|
1761
2018
|
ForgotPassword,
|
|
1762
2019
|
GoogleOneTap,
|
|
2020
|
+
OrganizationMembers,
|
|
1763
2021
|
ResetPassword,
|
|
1764
2022
|
SignIn,
|
|
1765
2023
|
SignUp,
|