@solongate/proxy 0.81.53 → 0.81.54

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/index.js CHANGED
@@ -10062,13 +10062,6 @@ import { Box as Box7, Text as Text7, useInput as useInput6 } from "ink";
10062
10062
  import TextInput5 from "ink-text-input";
10063
10063
  import { useEffect as useEffect6, useRef as useRef3, useState as useState7 } from "react";
10064
10064
  import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
10065
- function alertBodyFor(channel) {
10066
- const c2 = channel.trim();
10067
- const base = { name: "dataroom alert", threshold: 5, windowSeconds: 60, signal: "any" };
10068
- if (/^https?:\/\//i.test(c2)) return { ...base, slackUrl: c2 };
10069
- if (c2.includes("@")) return { ...base, emails: [c2] };
10070
- return { ...base, telegram: [c2] };
10071
- }
10072
10065
  function SettingsPanel({
10073
10066
  active: active2,
10074
10067
  focused,
@@ -10103,8 +10096,9 @@ function SettingsPanel({
10103
10096
  const whQ = useLoader(() => listAccounts().length ? api.settings.getWebhooks() : Promise.resolve(null));
10104
10097
  const alertQ = useLoader(() => listAccounts().length ? api.settings.getAlerts() : Promise.resolve(null));
10105
10098
  const local = localQ.data;
10106
- const webhooks = whQ.data?.webhooks ?? [];
10107
- const alerts = alertQ.data?.rules ?? [];
10099
+ const [hidden, setHidden] = useState7(/* @__PURE__ */ new Set());
10100
+ const webhooks = (whQ.data?.webhooks ?? []).filter((w) => !hidden.has("wh:" + w.id));
10101
+ const alerts = (alertQ.data?.rules ?? []).filter((r) => !hidden.has("alert:" + r.id));
10108
10102
  const rowsAll = [
10109
10103
  ...accounts.map((acc) => ({ kind: "acct", acc })),
10110
10104
  { kind: "acct-add" },
@@ -10115,7 +10109,8 @@ function SettingsPanel({
10115
10109
  ...webhooks.map((wh) => ({ kind: "wh", wh })),
10116
10110
  { kind: "wh-add" },
10117
10111
  ...alerts.map((rule) => ({ kind: "alert", rule })),
10118
- { kind: "alert-add" }
10112
+ { kind: "alert-add-email" },
10113
+ { kind: "alert-add-tg" }
10119
10114
  ]
10120
10115
  ];
10121
10116
  const selClamped = Math.min(sel, rowsAll.length - 1);
@@ -10200,9 +10195,12 @@ function SettingsPanel({
10200
10195
  setEditing("wh-url");
10201
10196
  } else if (r.kind === "alert") {
10202
10197
  run12(r.rule.enabled ? "alert disabled" : "alert enabled", () => api.settings.setAlertEnabled(r.rule.id, !r.rule.enabled), alertQ.reload);
10198
+ } else if (r.kind === "alert-add-email") {
10199
+ setInput("");
10200
+ setEditing("alert-email");
10203
10201
  } else {
10204
10202
  setInput("");
10205
- setEditing("alert-channel");
10203
+ setEditing("alert-tg");
10206
10204
  }
10207
10205
  };
10208
10206
  const submitInput = () => {
@@ -10215,9 +10213,20 @@ function SettingsPanel({
10215
10213
  } else if (which === "wh-url") {
10216
10214
  if (!v) return;
10217
10215
  run12("webhook added", () => api.settings.createWebhook({ url: v, events: "denials" }), whQ.reload);
10218
- } else if (which === "alert-channel") {
10216
+ } else if (which === "alert-email") {
10217
+ if (!v) return;
10218
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v)) {
10219
+ setMsg({ text: "\u2717 that does not look like an e-mail address", level: "bad" });
10220
+ return;
10221
+ }
10222
+ run12("email alert added", () => api.settings.createAlert({ ...ALERT_BASE, emails: [v] }), alertQ.reload);
10223
+ } else if (which === "alert-tg") {
10219
10224
  if (!v) return;
10220
- run12("alert rule added", () => api.settings.createAlert(alertBodyFor(v)), alertQ.reload);
10225
+ if (!/^-?\d{5,}$/.test(v)) {
10226
+ setMsg({ text: "\u2717 a telegram chat id is a number \u2014 get yours from @userinfobot", level: "bad" });
10227
+ return;
10228
+ }
10229
+ run12("telegram alert added", () => api.settings.createAlert({ ...ALERT_BASE, telegram: [v] }), alertQ.reload);
10221
10230
  }
10222
10231
  };
10223
10232
  useInput6(
@@ -10260,9 +10269,9 @@ function SettingsPanel({
10260
10269
  if (cur.kind === "wh" || cur.kind === "wh-add") {
10261
10270
  setInput("");
10262
10271
  setEditing("wh-url");
10263
- } else if (cur.kind === "alert" || cur.kind === "alert-add") {
10272
+ } else if (cur.kind === "alert" || cur.kind === "alert-add-email" || cur.kind === "alert-add-tg") {
10264
10273
  setInput("");
10265
- setEditing("alert-channel");
10274
+ setEditing("alert-email");
10266
10275
  }
10267
10276
  } else if (inp === "d" && (cur.kind === "wh" || cur.kind === "alert")) {
10268
10277
  const k = keyOf(cur);
@@ -10272,8 +10281,13 @@ function SettingsPanel({
10272
10281
  return;
10273
10282
  }
10274
10283
  setConfirmDel(null);
10275
- if (cur.kind === "wh") run12("webhook deleted", () => api.settings.deleteWebhook(cur.wh.id), whQ.reload);
10276
- else run12("alert deleted", () => api.settings.deleteAlert(cur.rule.id), alertQ.reload);
10284
+ if (cur.kind === "wh") {
10285
+ const id = cur.wh.id;
10286
+ run12("webhook deleted", () => api.settings.deleteWebhook(id).then(() => setHidden((h) => new Set(h).add("wh:" + id))), whQ.reload);
10287
+ } else {
10288
+ const id = cur.rule.id;
10289
+ run12("alert deleted", () => api.settings.deleteAlert(id).then(() => setHidden((h) => new Set(h).add("alert:" + id))), alertQ.reload);
10290
+ }
10277
10291
  } else if (inp === "r") reloadAll();
10278
10292
  },
10279
10293
  { isActive: focused && !editing }
@@ -10302,7 +10316,7 @@ function SettingsPanel({
10302
10316
  const error = locked ? null : localQ.error ?? whQ.error ?? alertQ.error;
10303
10317
  const mark = (r) => keyOf(r) === keyOf(cur) && focused ? "\u25B8 " : " ";
10304
10318
  const onOff = (on) => on ? /* @__PURE__ */ jsx7(Text7, { color: theme.ok, children: "on " }) : /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "off" });
10305
- const chanOf = (rule) => [...(rule.slackUrls ?? []).map((u) => "slack " + u), ...rule.emails ?? [], ...(rule.telegram ?? []).map((t) => "tg " + t)].join(", ") || "\u2014";
10319
+ const chanOf = (rule) => [...rule.emails ?? [], ...(rule.telegram ?? []).map((t) => "tg " + t)].join(", ") || "\u2014";
10306
10320
  const listBudget = Math.max(4, rows - 10);
10307
10321
  const start = Math.min(Math.max(0, selClamped - Math.floor(listBudget / 2)), Math.max(0, rowsAll.length - listBudget));
10308
10322
  const inWindow = (r) => {
@@ -10312,7 +10326,7 @@ function SettingsPanel({
10312
10326
  return /* @__PURE__ */ jsx7(DataView, { loading, error, children: /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
10313
10327
  /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: focused ? "\u2191\u2193 move \xB7 enter/m act \xB7 t test webhook \xB7 n add account \xB7 e events \xB7 d delete \xB7 r refresh" : "press \u2192 to configure" }),
10314
10328
  editing ? /* @__PURE__ */ jsxs7(Box7, { children: [
10315
- /* @__PURE__ */ jsx7(Text7, { color: theme.warn, children: editing === "path" ? "local log path: " : editing === "wh-url" ? "webhook url: " : "channel (slack url / email / telegram id): " }),
10329
+ /* @__PURE__ */ jsx7(Text7, { color: theme.warn, children: editing === "path" ? "local log path: " : editing === "wh-url" ? "webhook url: " : editing === "alert-email" ? "e-mail address: " : "telegram chat id (from @userinfobot): " }),
10316
10330
  /* @__PURE__ */ jsx7(TextInput5, { value: input, onChange: setInput, onSubmit: submitInput })
10317
10331
  ] }) : msg ? /* @__PURE__ */ jsx7(Text7, { color: msg.level === "bad" ? theme.bad : theme.ok, children: truncate2(msg.text, cols) }) : login?.msg ? /* @__PURE__ */ jsx7(Text7, { color: login.phase === "error" ? theme.bad : theme.ok, children: login.msg }) : /* @__PURE__ */ jsx7(Text7, { children: " " }),
10318
10332
  /* @__PURE__ */ jsxs7(Box7, { marginTop: 1, flexDirection: "column", children: [
@@ -10405,15 +10419,19 @@ function SettingsPanel({
10405
10419
  /* @__PURE__ */ jsx7(Text7, { children: `\u2265${rule.threshold}/${rule.windowSeconds}s ` }),
10406
10420
  /* @__PURE__ */ jsx7(Text7, { color: theme.accent, children: truncate2(chanOf(rule), cols - 26) })
10407
10421
  ] }, rule.id)),
10408
- inWindow({ kind: "alert-add" }) ? /* @__PURE__ */ jsxs7(Text7, { children: [
10409
- /* @__PURE__ */ jsx7(Text7, { color: cur.kind === "alert-add" && focused ? theme.accentBright : theme.dim, children: mark({ kind: "alert-add" }) }),
10410
- /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "+ add alert (enter \u2014 one channel: slack url, email or telegram chat id)" })
10422
+ inWindow({ kind: "alert-add-email" }) ? /* @__PURE__ */ jsxs7(Text7, { children: [
10423
+ /* @__PURE__ */ jsx7(Text7, { color: cur.kind === "alert-add-email" && focused ? theme.accentBright : theme.dim, children: mark({ kind: "alert-add-email" }) }),
10424
+ /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "+ add email alert (enter)" })
10425
+ ] }) : null,
10426
+ inWindow({ kind: "alert-add-tg" }) ? /* @__PURE__ */ jsxs7(Text7, { children: [
10427
+ /* @__PURE__ */ jsx7(Text7, { color: cur.kind === "alert-add-tg" && focused ? theme.accentBright : theme.dim, children: mark({ kind: "alert-add-tg" }) }),
10428
+ /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "+ add telegram alert (enter \u2014 numeric chat id, get it from @userinfobot)" })
10411
10429
  ] }) : null
10412
10430
  ] })
10413
10431
  ] })
10414
10432
  ] }) });
10415
10433
  }
10416
- var EVENTS, SPIN2, acctLabel;
10434
+ var EVENTS, SPIN2, ALERT_BASE, acctLabel;
10417
10435
  var init_Settings = __esm({
10418
10436
  "src/tui/panels/Settings.tsx"() {
10419
10437
  "use strict";
@@ -10426,6 +10444,7 @@ var init_Settings = __esm({
10426
10444
  init_theme();
10427
10445
  EVENTS = ["denials", "allowed", "all"];
10428
10446
  SPIN2 = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
10447
+ ALERT_BASE = { name: "dataroom alert", threshold: 5, windowSeconds: 60, signal: "any" };
10429
10448
  acctLabel = (a) => a.email || a.user || "account \u2026" + a.apiKey.slice(-4);
10430
10449
  }
10431
10450
  });
package/dist/tui/index.js CHANGED
@@ -3175,13 +3175,7 @@ function stopLogsServerDaemon() {
3175
3175
  import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
3176
3176
  var EVENTS = ["denials", "allowed", "all"];
3177
3177
  var SPIN2 = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
3178
- function alertBodyFor(channel) {
3179
- const c2 = channel.trim();
3180
- const base = { name: "dataroom alert", threshold: 5, windowSeconds: 60, signal: "any" };
3181
- if (/^https?:\/\//i.test(c2)) return { ...base, slackUrl: c2 };
3182
- if (c2.includes("@")) return { ...base, emails: [c2] };
3183
- return { ...base, telegram: [c2] };
3184
- }
3178
+ var ALERT_BASE = { name: "dataroom alert", threshold: 5, windowSeconds: 60, signal: "any" };
3185
3179
  var acctLabel = (a) => a.email || a.user || "account \u2026" + a.apiKey.slice(-4);
3186
3180
  function SettingsPanel({
3187
3181
  active: active2,
@@ -3217,8 +3211,9 @@ function SettingsPanel({
3217
3211
  const whQ = useLoader(() => listAccounts().length ? api.settings.getWebhooks() : Promise.resolve(null));
3218
3212
  const alertQ = useLoader(() => listAccounts().length ? api.settings.getAlerts() : Promise.resolve(null));
3219
3213
  const local = localQ.data;
3220
- const webhooks = whQ.data?.webhooks ?? [];
3221
- const alerts = alertQ.data?.rules ?? [];
3214
+ const [hidden, setHidden] = useState7(/* @__PURE__ */ new Set());
3215
+ const webhooks = (whQ.data?.webhooks ?? []).filter((w) => !hidden.has("wh:" + w.id));
3216
+ const alerts = (alertQ.data?.rules ?? []).filter((r) => !hidden.has("alert:" + r.id));
3222
3217
  const rowsAll = [
3223
3218
  ...accounts.map((acc) => ({ kind: "acct", acc })),
3224
3219
  { kind: "acct-add" },
@@ -3229,7 +3224,8 @@ function SettingsPanel({
3229
3224
  ...webhooks.map((wh) => ({ kind: "wh", wh })),
3230
3225
  { kind: "wh-add" },
3231
3226
  ...alerts.map((rule) => ({ kind: "alert", rule })),
3232
- { kind: "alert-add" }
3227
+ { kind: "alert-add-email" },
3228
+ { kind: "alert-add-tg" }
3233
3229
  ]
3234
3230
  ];
3235
3231
  const selClamped = Math.min(sel, rowsAll.length - 1);
@@ -3314,9 +3310,12 @@ function SettingsPanel({
3314
3310
  setEditing("wh-url");
3315
3311
  } else if (r.kind === "alert") {
3316
3312
  run(r.rule.enabled ? "alert disabled" : "alert enabled", () => api.settings.setAlertEnabled(r.rule.id, !r.rule.enabled), alertQ.reload);
3313
+ } else if (r.kind === "alert-add-email") {
3314
+ setInput("");
3315
+ setEditing("alert-email");
3317
3316
  } else {
3318
3317
  setInput("");
3319
- setEditing("alert-channel");
3318
+ setEditing("alert-tg");
3320
3319
  }
3321
3320
  };
3322
3321
  const submitInput = () => {
@@ -3329,9 +3328,20 @@ function SettingsPanel({
3329
3328
  } else if (which === "wh-url") {
3330
3329
  if (!v) return;
3331
3330
  run("webhook added", () => api.settings.createWebhook({ url: v, events: "denials" }), whQ.reload);
3332
- } else if (which === "alert-channel") {
3331
+ } else if (which === "alert-email") {
3332
+ if (!v) return;
3333
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v)) {
3334
+ setMsg({ text: "\u2717 that does not look like an e-mail address", level: "bad" });
3335
+ return;
3336
+ }
3337
+ run("email alert added", () => api.settings.createAlert({ ...ALERT_BASE, emails: [v] }), alertQ.reload);
3338
+ } else if (which === "alert-tg") {
3333
3339
  if (!v) return;
3334
- run("alert rule added", () => api.settings.createAlert(alertBodyFor(v)), alertQ.reload);
3340
+ if (!/^-?\d{5,}$/.test(v)) {
3341
+ setMsg({ text: "\u2717 a telegram chat id is a number \u2014 get yours from @userinfobot", level: "bad" });
3342
+ return;
3343
+ }
3344
+ run("telegram alert added", () => api.settings.createAlert({ ...ALERT_BASE, telegram: [v] }), alertQ.reload);
3335
3345
  }
3336
3346
  };
3337
3347
  useInput6(
@@ -3374,9 +3384,9 @@ function SettingsPanel({
3374
3384
  if (cur.kind === "wh" || cur.kind === "wh-add") {
3375
3385
  setInput("");
3376
3386
  setEditing("wh-url");
3377
- } else if (cur.kind === "alert" || cur.kind === "alert-add") {
3387
+ } else if (cur.kind === "alert" || cur.kind === "alert-add-email" || cur.kind === "alert-add-tg") {
3378
3388
  setInput("");
3379
- setEditing("alert-channel");
3389
+ setEditing("alert-email");
3380
3390
  }
3381
3391
  } else if (inp === "d" && (cur.kind === "wh" || cur.kind === "alert")) {
3382
3392
  const k = keyOf(cur);
@@ -3386,8 +3396,13 @@ function SettingsPanel({
3386
3396
  return;
3387
3397
  }
3388
3398
  setConfirmDel(null);
3389
- if (cur.kind === "wh") run("webhook deleted", () => api.settings.deleteWebhook(cur.wh.id), whQ.reload);
3390
- else run("alert deleted", () => api.settings.deleteAlert(cur.rule.id), alertQ.reload);
3399
+ if (cur.kind === "wh") {
3400
+ const id = cur.wh.id;
3401
+ run("webhook deleted", () => api.settings.deleteWebhook(id).then(() => setHidden((h) => new Set(h).add("wh:" + id))), whQ.reload);
3402
+ } else {
3403
+ const id = cur.rule.id;
3404
+ run("alert deleted", () => api.settings.deleteAlert(id).then(() => setHidden((h) => new Set(h).add("alert:" + id))), alertQ.reload);
3405
+ }
3391
3406
  } else if (inp === "r") reloadAll();
3392
3407
  },
3393
3408
  { isActive: focused && !editing }
@@ -3416,7 +3431,7 @@ function SettingsPanel({
3416
3431
  const error = locked ? null : localQ.error ?? whQ.error ?? alertQ.error;
3417
3432
  const mark = (r) => keyOf(r) === keyOf(cur) && focused ? "\u25B8 " : " ";
3418
3433
  const onOff = (on) => on ? /* @__PURE__ */ jsx7(Text7, { color: theme.ok, children: "on " }) : /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "off" });
3419
- const chanOf = (rule) => [...(rule.slackUrls ?? []).map((u) => "slack " + u), ...rule.emails ?? [], ...(rule.telegram ?? []).map((t) => "tg " + t)].join(", ") || "\u2014";
3434
+ const chanOf = (rule) => [...rule.emails ?? [], ...(rule.telegram ?? []).map((t) => "tg " + t)].join(", ") || "\u2014";
3420
3435
  const listBudget = Math.max(4, rows - 10);
3421
3436
  const start = Math.min(Math.max(0, selClamped - Math.floor(listBudget / 2)), Math.max(0, rowsAll.length - listBudget));
3422
3437
  const inWindow = (r) => {
@@ -3426,7 +3441,7 @@ function SettingsPanel({
3426
3441
  return /* @__PURE__ */ jsx7(DataView, { loading, error, children: /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", children: [
3427
3442
  /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: focused ? "\u2191\u2193 move \xB7 enter/m act \xB7 t test webhook \xB7 n add account \xB7 e events \xB7 d delete \xB7 r refresh" : "press \u2192 to configure" }),
3428
3443
  editing ? /* @__PURE__ */ jsxs7(Box7, { children: [
3429
- /* @__PURE__ */ jsx7(Text7, { color: theme.warn, children: editing === "path" ? "local log path: " : editing === "wh-url" ? "webhook url: " : "channel (slack url / email / telegram id): " }),
3444
+ /* @__PURE__ */ jsx7(Text7, { color: theme.warn, children: editing === "path" ? "local log path: " : editing === "wh-url" ? "webhook url: " : editing === "alert-email" ? "e-mail address: " : "telegram chat id (from @userinfobot): " }),
3430
3445
  /* @__PURE__ */ jsx7(TextInput5, { value: input, onChange: setInput, onSubmit: submitInput })
3431
3446
  ] }) : msg ? /* @__PURE__ */ jsx7(Text7, { color: msg.level === "bad" ? theme.bad : theme.ok, children: truncate(msg.text, cols) }) : login?.msg ? /* @__PURE__ */ jsx7(Text7, { color: login.phase === "error" ? theme.bad : theme.ok, children: login.msg }) : /* @__PURE__ */ jsx7(Text7, { children: " " }),
3432
3447
  /* @__PURE__ */ jsxs7(Box7, { marginTop: 1, flexDirection: "column", children: [
@@ -3519,9 +3534,13 @@ function SettingsPanel({
3519
3534
  /* @__PURE__ */ jsx7(Text7, { children: `\u2265${rule.threshold}/${rule.windowSeconds}s ` }),
3520
3535
  /* @__PURE__ */ jsx7(Text7, { color: theme.accent, children: truncate(chanOf(rule), cols - 26) })
3521
3536
  ] }, rule.id)),
3522
- inWindow({ kind: "alert-add" }) ? /* @__PURE__ */ jsxs7(Text7, { children: [
3523
- /* @__PURE__ */ jsx7(Text7, { color: cur.kind === "alert-add" && focused ? theme.accentBright : theme.dim, children: mark({ kind: "alert-add" }) }),
3524
- /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "+ add alert (enter \u2014 one channel: slack url, email or telegram chat id)" })
3537
+ inWindow({ kind: "alert-add-email" }) ? /* @__PURE__ */ jsxs7(Text7, { children: [
3538
+ /* @__PURE__ */ jsx7(Text7, { color: cur.kind === "alert-add-email" && focused ? theme.accentBright : theme.dim, children: mark({ kind: "alert-add-email" }) }),
3539
+ /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "+ add email alert (enter)" })
3540
+ ] }) : null,
3541
+ inWindow({ kind: "alert-add-tg" }) ? /* @__PURE__ */ jsxs7(Text7, { children: [
3542
+ /* @__PURE__ */ jsx7(Text7, { color: cur.kind === "alert-add-tg" && focused ? theme.accentBright : theme.dim, children: mark({ kind: "alert-add-tg" }) }),
3543
+ /* @__PURE__ */ jsx7(Text7, { color: theme.dim, children: "+ add telegram alert (enter \u2014 numeric chat id, get it from @userinfobot)" })
3525
3544
  ] }) : null
3526
3545
  ] })
3527
3546
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.81.53",
3
+ "version": "0.81.54",
4
4
  "description": "AI tool security proxy: protect any AI tool server with customizable policies, path/command constraints, rate limiting, and audit logging. No code changes required.",
5
5
  "type": "module",
6
6
  "bin": {