cauthy-auth 0.13.0 → 0.14.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/react.mjs CHANGED
@@ -390,6 +390,11 @@ function createAuthClient(options = {}) {
390
390
  return body && Array.isArray(body.sessions) ? body.sessions : [];
391
391
  },
392
392
  signOutEverywhere: () => post("/me/sessions/end", {}, null),
393
+ async agents() {
394
+ const body = await read("/me/agents");
395
+ return body && Array.isArray(body.agents) ? body.agents : [];
396
+ },
397
+ disconnectAgent: (id) => post("/me/agents/disconnect", { id }, null),
393
398
  async passkeys() {
394
399
  const body = await read("/me/passkeys");
395
400
  return body && Array.isArray(body.passkeys) ? body.passkeys : [];
@@ -541,6 +546,10 @@ var TEXTS = {
541
546
  passkeyUnnamed: "Passkey",
542
547
  sessions: "Where you are signed in",
543
548
  signOutEverywhere: "Sign out everywhere",
549
+ agents: "AI agents",
550
+ agentsHelp: "Agents you allowed to act for you. Disconnect one and it loses its access within minutes.",
551
+ disconnect: "Disconnect",
552
+ anAgent: "An AI agent",
544
553
  unknownDevice: "Unknown device",
545
554
  emailAddress: "Email address",
546
555
  newEmail: "New email address",
@@ -649,6 +658,10 @@ var TEXTS = {
649
658
  passkeyUnnamed: "Llave de acceso",
650
659
  sessions: "D\xF3nde tienes la sesi\xF3n abierta",
651
660
  signOutEverywhere: "Cerrar sesi\xF3n en todas partes",
661
+ agents: "Agentes de IA",
662
+ agentsHelp: "Los agentes a los que permitiste actuar por ti. Si desconectas uno, pierde el acceso en pocos minutos.",
663
+ disconnect: "Desconectar",
664
+ anAgent: "Un agente de IA",
652
665
  unknownDevice: "Dispositivo desconocido",
653
666
  emailAddress: "Correo",
654
667
  newEmail: "Correo nuevo",
@@ -1178,6 +1191,7 @@ function Account(props) {
1178
1191
  /* @__PURE__ */ jsx(SecondStepPart, { props, account, onChanged: (mfaEnabled) => setAccount({ ...account, mfaEnabled }) }),
1179
1192
  /* @__PURE__ */ jsx(PhonePart, { props, account, onChanged: (mfaEnabled) => setAccount({ ...account, mfaEnabled }) }),
1180
1193
  /* @__PURE__ */ jsx(PasskeysPart, { props, account, accountUrl: accountUrl(), when }),
1194
+ /* @__PURE__ */ jsx(AgentsPart, { props, when }),
1181
1195
  /* @__PURE__ */ jsxs("section", { className: cx("section"), children: [
1182
1196
  /* @__PURE__ */ jsx("h2", { className: cx("heading"), children: t.sessions }),
1183
1197
  /* @__PURE__ */ jsx("ul", { className: cx("sessions"), children: sessions.map((s, i) => /* @__PURE__ */ jsxs("li", { className: cx("session"), children: [
@@ -1477,6 +1491,35 @@ function PhonePart({ props, account, onChanged }) {
1477
1491
  /* @__PURE__ */ jsx(f.Button, { type: "submit", disabled: f.busy, className: f.cx("button"), children: ways.phone ? f.t.removePhone : f.t.addPhone })
1478
1492
  ] });
1479
1493
  }
1494
+ function AgentsPart({ props, when }) {
1495
+ const auth = useAuth();
1496
+ const { f, run, general } = useSection(props);
1497
+ const [list, setList] = useState([]);
1498
+ useEffect(() => {
1499
+ void auth.account.agents().then(setList);
1500
+ }, []);
1501
+ if (list.length === 0) return null;
1502
+ const disconnect = async (id) => {
1503
+ const r = await run(() => auth.account.disconnectAgent(id));
1504
+ if (r.ok) setList(list.filter((a) => a.id !== id));
1505
+ };
1506
+ return /* @__PURE__ */ jsxs("section", { className: f.cx("section"), children: [
1507
+ /* @__PURE__ */ jsx("h2", { className: f.cx("heading"), children: f.t.agents }),
1508
+ /* @__PURE__ */ jsx("p", { className: f.cx("notice"), children: f.t.agentsHelp }),
1509
+ general && /* @__PURE__ */ jsx("p", { role: "alert", className: f.cx("error"), children: f.say(general) }),
1510
+ /* @__PURE__ */ jsx("ul", { className: f.cx("sessions"), children: list.map((a) => /* @__PURE__ */ jsxs("li", { className: f.cx("session"), children: [
1511
+ a.name || f.t.anAgent,
1512
+ a.redirectHost ? ` (${a.redirectHost})` : "",
1513
+ " \u2192 ",
1514
+ a.resource.name,
1515
+ a.scopes.length > 0 ? ` \xB7 ${a.scopes.map((s) => s.description || s.name).join(", ")}` : "",
1516
+ " \xB7 ",
1517
+ when(a.lastUsedAt),
1518
+ " ",
1519
+ /* @__PURE__ */ jsx(f.Button, { type: "button", disabled: f.busy, className: f.cx("providerButton"), onClick: () => void disconnect(a.id), children: f.t.disconnect })
1520
+ ] }, a.id)) })
1521
+ ] });
1522
+ }
1480
1523
  function SignOutEverywhere({ props }) {
1481
1524
  const auth = useAuth();
1482
1525
  const { f, run, general } = useSection(props);