dsh-cookie-cleaner 0.6.4 → 0.7.1
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/CHANGELOG.md +260 -242
- package/dsh.plugin.json +1 -1
- package/lib/client.js +123 -7
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
- package/src/api-routes.js +144 -138
- package/src/cli.js +281 -236
- package/src/client/card.tsx +310 -253
- package/src/client/locales.ts +91 -84
- package/src/client/routes.ts +138 -118
- package/src/core.js +669 -531
- package/src/index.js +426 -394
- package/src/legacy-injection.js +137 -0
- package/src/patch-guard.js +509 -416
- package/src/patch-read.js +251 -199
- package/src/runtime-guard.js +14 -4
package/lib/client.js
CHANGED
|
@@ -162,11 +162,18 @@ window.__ModuleLoader__.load({
|
|
|
162
162
|
"revert.none": t("没有可回滚的快照(修复一次才会留一份)", "no snapshot to roll back (a successful fix keeps one)", "回滚用スナップショット無し(修復成功時に 1 件保存)", "롤백 스냅샷 없음(복구 성공 시 1개 보관)", "aucun instantané à restaurer (une réparation réussie en garde un)", "kein Snapshot zum Zurückrollen (ein erfolgreicher Fix hinterlässt einen)", "nessuno snapshot da ripristinare (una correzione riuscita ne conserva uno)", "нет снимка для отката (успешное исправление сохраняет один)", "no hay instantánea a la que volver (una reparación correcta guarda una)"),
|
|
163
163
|
"lastCheck": t("最近体检:{at}", "last check: {at}", "最近の点検:{at}", "마지막 점검: {at}", "dernier contrôle : {at}", "letzte Prüfung: {at}", "ultimo controllo: {at}", "последняя проверка: {at}", "última revisión: {at}"),
|
|
164
164
|
"guard.title": t("运行期守护(Set-Cookie 退休旧 cookie)", "Runtime guard (retire stale cookies via Set-Cookie)", "ランタイム守護(Set-Cookie で古い cookie を引退)", "런타임 가드 (Set-Cookie 로 오래된 cookie 정리)", "Garde en direct (retirer les vieux cookies via Set-Cookie)", "Laufzeit-Wächter (alte Cookies via Set-Cookie entfernen)", "Guardia runtime (ritira i cookie vecchi via Set-Cookie)", "Страж (удаление старых cookie через Set-Cookie)", "Guardia en ejecución (retirar cookies viejas vía Set-Cookie)"),
|
|
165
|
-
"guard.enable": t("启用运行期守护", "Enable runtime guard", "ランタイム守護を有効化", "런타임 가드 켜기", "Activer la garde en direct", "Laufzeit-Wächter aktivieren", "Abilita la guardia runtime", "Включить стража", "Activar guardia en ejecución"),
|
|
166
165
|
"guard.retireAbove": t("触发阈值(条数 > 此值才退休,0=不设阈值)", "Trigger threshold (retire only when count > this; 0 = no threshold)", "発動しきい値(件数 > この値で引退、0=なし)", "발동 임계값(개수 > 이 값이면 정리, 0=없음)", "Seuil de déclenchement (retirer si nombre > cette valeur ; 0 = aucun)", "Auslöseschwelle (erst wenn Anzahl > dieser Wert; 0 = keine)", "Soglia di attivazione (ritira se conteggio > valore; 0 = nessuna)", "Порог срабатывания (удалять если число > значения; 0 = нет)", "Umbral de disparo (retirar si cantidad > valor; 0 = ninguno)"),
|
|
167
166
|
"guard.keep": t("保留尾部条数(keep)", "Keep tail count (keep)", "末尾保持件数(keep)", "꼬리 유지 개수(keep)", "Nombre conservé en queue (keep)", "Anzahl am Ende behalten (keep)", "Numero mantenuto in coda (keep)", "Держать в хвосте (keep)", "Cantidad retenida en cola (keep)"),
|
|
168
167
|
"guard.saved": t("已写入守护设置(HMR 热生效)", "guard settings written (applies via HMR)", "守護設定を書き込みました(HMR で反映)", "가드 설정 기록됨(HMR 적용)", "réglages de la garde écrits (appliqués par HMR)", "Wächter-Einstellungen geschrieben (via HMR)", "impostazioni della guardia scritte (via HMR)", "настройки стража записаны (через HMR)", "ajustes de la guardia escritos (vía HMR)"),
|
|
169
168
|
"guard.noop": t("无变化,未写入", "no change, nothing written", "変更なし、書き込みなし", "변경 없음, 기록 안 함", "aucun changement", "keine Änderung", "nessun cambiamento", "без изменений", "sin cambios"),
|
|
169
|
+
"guard.enableRetire": t("退休陈旧 cookie(推荐开启)", "Retire stale cookies (recommended)", "古い cookie を引退(推奨)", "오래된 cookie 정리 (권장)", "Retirer les vieux cookies (recommandé)", "Alte Cookies entfernen (empfohlen)", "Ritira i cookie vecchi (consigliato)", "Удалять старые cookie (рекомендуется)", "Retirar cookies viejos (recomendado)"),
|
|
170
|
+
"legacy.title": t("历史注入残留", "Legacy injection residue", "過去の注入残り", "과거 주입 잔여물", "Résidu d'injection historique", "Alt-Injektionsrest", "Residuo di iniezione storica", "Остаток старой инъекции", "Residuo de inyección histórica"),
|
|
171
|
+
"legacy.found": t("旧版「应用端口」写进 profile 的表达式:{expr}", "written into the profile by the old \"apply port\" action: {expr}", "旧版「ポート適用」が profile に書いた式:{expr}", "구버전 \"포트 적용\"이 profile 에 쓴 식: {expr}", "écrit dans le profil par l'ancienne action « appliquer le port » : {expr}", "vom alten \"Port anwenden\" ins Profil geschrieben: {expr}", "scritto nel profilo dalla vecchia azione \"applica porta\": {expr}", "записано в profile старым действием «применить порт»: {expr}", "escrito en el perfil por la antigua acción \"aplicar puerto\": {expr}"),
|
|
172
|
+
"legacy.clean": t("清理这一行", "Clean this row", "この行を整理", "이 행 정리", "Nettoyer cette ligne", "Diese Zeile bereinigen", "Pulisci questa riga", "Очистить эту строку", "Limpiar esta fila"),
|
|
173
|
+
"legacy.cleaned": t("已清理:该键回落到宿主默认", "cleaned: the key falls back to the host default", "整理しました:ホスト既定に戻ります", "정리됨: 호스트 기본값으로 복귀", "nettoyé : la clé revient à la valeur par défaut", "bereinigt: der Schlüssel fällt auf den Host-Standard zurück", "pulito: la chiave torna al valore predefinito", "очищено: ключ возвращается к значению хоста", "limpiado: la clave vuelve al valor del host"),
|
|
174
|
+
"legacy.noop": t("没有可清理的内容", "nothing to clean", "整理するものはありません", "정리할 항목 없음", "rien à nettoyer", "nichts zu bereinigen", "niente da pulire", "нечего очищать", "nada que limpiar"),
|
|
175
|
+
"legacy.unsupported": t("当前宿主(<0.2.2-rc.2)仍需要钉端口这条缓解,只报告不清理", "this host (<0.2.2-rc.2) still relies on the pinned port; reporting only", "このホスト(<0.2.2-rc.2)はポート固定が必要なため報告のみ", "이 호스트(<0.2.2-rc.2)는 포트 고정이 필요해 보고만 합니다", "cet hôte (<0.2.2-rc.2) dépend encore du port fixé ; rapport seulement", "dieser Host (<0.2.2-rc.2) braucht den festen Port noch; nur Bericht", "questo host (<0.2.2-rc.2) richiede ancora la porta fissata; solo segnalazione", "этот хост (<0.2.2-rc.2) ещё полагается на фиксированный порт; только отчёт", "este host (<0.2.2-rc.2) aún depende del puerto fijo; solo informe"),
|
|
176
|
+
"guard.enableBudget": t("抬高请求头预算(默认关,放宽 431 触发线)", "Raise the header budget (off by default; loosens the 431 threshold)", "ヘッダー予算を引き上げ(既定オフ。431 の閾値を緩める)", "헤더 예산 올리기 (기본 꺼짐, 431 임계값 완화)", "Relever le budget d'en-têtes (désactivé par défaut ; assouplit le seuil 431)", "Header-Budget anheben (standardmäßig aus; lockert die 431-Schwelle)", "Alza il budget header (disattivato; allenta la soglia 431)", "Поднять лимит заголовков (по умолчанию выкл.; ослабляет порог 431)", "Elevar el presupuesto de cabeceras (desactivado; relaja el umbral 431)"),
|
|
170
177
|
"guard.unavailable": t("当前宿主拿不到本插件配置行(无 config-editor),无法在面板改守护设置", "the host exposes no editable row for this plugin; cannot change guard settings here", "このホストでは本プラグインの設定行を取得できず、パネルでは変更不可", "이 호스트에서 플러그인 설정 행을 얻을 수 없어 패널에서 변경 불가", "cet hôte n'expose pas de ligne éditable pour ce plugin", "dieser Host hat keine editierbare Zeile für dieses Plugin", "questo host non espone una riga modificabile per il plugin", "этот хост не даёт редактируемую строку плагина", "este host no expone una fila editable para este plugin")
|
|
171
178
|
};
|
|
172
179
|
/** 把共享判定表压平成 `p.P5` 形态的键(宿主只回 code,语言由界面决定)。 */
|
|
@@ -198,7 +205,9 @@ window.__ModuleLoader__.load({
|
|
|
198
205
|
fix: "/api/dsh-cookie-cleaner/patch/fix",
|
|
199
206
|
revert: "/api/dsh-cookie-cleaner/patch/revert",
|
|
200
207
|
guardGet: "/api/dsh-cookie-cleaner/guard/get",
|
|
201
|
-
guardSet: "/api/dsh-cookie-cleaner/guard/set"
|
|
208
|
+
guardSet: "/api/dsh-cookie-cleaner/guard/set",
|
|
209
|
+
legacyGet: "/api/dsh-cookie-cleaner/legacy/get",
|
|
210
|
+
legacyClean: "/api/dsh-cookie-cleaner/legacy/clean"
|
|
202
211
|
};
|
|
203
212
|
/** POST 一跳;网络/解析失败都归成结构化错误,不让卡片白屏。 */
|
|
204
213
|
async function postJson(path, body = {}) {
|
|
@@ -313,9 +322,98 @@ window.__ModuleLoader__.load({
|
|
|
313
322
|
});
|
|
314
323
|
}
|
|
315
324
|
/**
|
|
316
|
-
*
|
|
325
|
+
* 运行期守护面板:两个独立开关(retireStale 清理 / raiseHeaderBudget 抬预算)+ 两个阈值(retireAbove / keep)。
|
|
326
|
+
* v0.7.0 之前是一个 runtimeGuard 全包——用户为了清 cookie 被迫放宽 431 阈值,故拆开。
|
|
317
327
|
* 读写都走后端桥(configEditor 写本插件自己那行),写后回显生效值——不凭手写 YAML。
|
|
318
328
|
*/
|
|
329
|
+
/**
|
|
330
|
+
* 历史注入残留面板(v0.7.1):旧版插件写进 profile 的 `port` 表达式还在不在。
|
|
331
|
+
*
|
|
332
|
+
* 为什么单独一块而不是塞进体检结果:这不是"配置对不对",是"插件自己留下的东西还在不在",
|
|
333
|
+
* 与 cookie 寿命无关。清理只在官方已接管 cookie 清理的宿主(0.2.2-rc.2+)上开放,
|
|
334
|
+
* 更早的宿主仍需要钉端口这条缓解,所以那里只显示不提供按钮。
|
|
335
|
+
*/
|
|
336
|
+
function LegacyPanel({ t }) {
|
|
337
|
+
const [v, setV] = react.useState(void 0);
|
|
338
|
+
const [busy, setBusy] = react.useState(false);
|
|
339
|
+
const [note, setNote] = react.useState("");
|
|
340
|
+
const mounted = react.useRef(true);
|
|
341
|
+
react.useEffect(() => {
|
|
342
|
+
mounted.current = true;
|
|
343
|
+
postJson(routes.legacyGet, {}).then((next) => {
|
|
344
|
+
if (mounted.current) setV(next);
|
|
345
|
+
}).catch(() => {});
|
|
346
|
+
return () => {
|
|
347
|
+
mounted.current = false;
|
|
348
|
+
};
|
|
349
|
+
}, []);
|
|
350
|
+
if (v === void 0) return null;
|
|
351
|
+
if (v.available === false || v.found !== true) return null;
|
|
352
|
+
const clean = async () => {
|
|
353
|
+
setBusy(true);
|
|
354
|
+
setNote("");
|
|
355
|
+
try {
|
|
356
|
+
const next = await postJson(routes.legacyClean, {});
|
|
357
|
+
if (!mounted.current) return;
|
|
358
|
+
setV(next.state ?? v);
|
|
359
|
+
setNote(next.kind === "cleaned" ? t("legacy.cleaned") : t("legacy.noop"));
|
|
360
|
+
} catch (error) {
|
|
361
|
+
if (mounted.current) setNote(render(t("state.failed"), { message: String(error.message ?? error) }));
|
|
362
|
+
} finally {
|
|
363
|
+
if (mounted.current) setBusy(false);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
367
|
+
style: {
|
|
368
|
+
display: "grid",
|
|
369
|
+
gap: 6,
|
|
370
|
+
marginTop: 8,
|
|
371
|
+
paddingTop: 8,
|
|
372
|
+
borderTop: "1px solid var(--dsw-color-border)"
|
|
373
|
+
},
|
|
374
|
+
children: [
|
|
375
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
376
|
+
style: { fontWeight: 600 },
|
|
377
|
+
children: t("legacy.title")
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
380
|
+
style: {
|
|
381
|
+
fontSize: "0.85em",
|
|
382
|
+
color: "var(--dsw-color-muted)"
|
|
383
|
+
},
|
|
384
|
+
children: render(t("legacy.found"), { expr: v.expression ?? "?" })
|
|
385
|
+
}),
|
|
386
|
+
v.cleanupSupported === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
387
|
+
type: "button",
|
|
388
|
+
disabled: busy,
|
|
389
|
+
onClick: () => void clean(),
|
|
390
|
+
style: {
|
|
391
|
+
justifySelf: "start",
|
|
392
|
+
padding: "3px 10px",
|
|
393
|
+
borderRadius: 6,
|
|
394
|
+
border: "1px solid var(--dsw-color-border)",
|
|
395
|
+
background: "var(--dsw-color-surface)",
|
|
396
|
+
color: "var(--dsw-color-text)",
|
|
397
|
+
cursor: busy ? "default" : "pointer"
|
|
398
|
+
},
|
|
399
|
+
children: t("legacy.clean")
|
|
400
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
401
|
+
style: {
|
|
402
|
+
fontSize: "0.85em",
|
|
403
|
+
color: "var(--dsw-color-muted)"
|
|
404
|
+
},
|
|
405
|
+
children: t("legacy.unsupported")
|
|
406
|
+
}),
|
|
407
|
+
note !== "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
408
|
+
style: {
|
|
409
|
+
fontSize: "0.85em",
|
|
410
|
+
color: "var(--dsw-color-text)"
|
|
411
|
+
},
|
|
412
|
+
children: note
|
|
413
|
+
}) : null
|
|
414
|
+
]
|
|
415
|
+
});
|
|
416
|
+
}
|
|
319
417
|
function GuardPanel({ t }) {
|
|
320
418
|
const [g, setG] = react.useState(void 0);
|
|
321
419
|
const [busy, setBusy] = react.useState(false);
|
|
@@ -349,7 +447,8 @@ window.__ModuleLoader__.load({
|
|
|
349
447
|
setNote("");
|
|
350
448
|
try {
|
|
351
449
|
const v = await postJson(routes.guardSet, {
|
|
352
|
-
|
|
450
|
+
retireStale: next.retireStale,
|
|
451
|
+
raiseHeaderBudget: next.raiseHeaderBudget,
|
|
353
452
|
maxHeaderBytes: next.maxHeaderBytes,
|
|
354
453
|
keep: next.keep,
|
|
355
454
|
retireAbove: next.retireAbove
|
|
@@ -395,13 +494,29 @@ window.__ModuleLoader__.load({
|
|
|
395
494
|
},
|
|
396
495
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
397
496
|
type: "checkbox",
|
|
398
|
-
checked: g.
|
|
497
|
+
checked: g.retireStale,
|
|
498
|
+
disabled: busy,
|
|
499
|
+
onChange: (e) => void commit({
|
|
500
|
+
...g,
|
|
501
|
+
retireStale: e.target.checked
|
|
502
|
+
})
|
|
503
|
+
}), t("guard.enableRetire")]
|
|
504
|
+
}),
|
|
505
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
506
|
+
style: {
|
|
507
|
+
display: "flex",
|
|
508
|
+
alignItems: "center",
|
|
509
|
+
gap: 6
|
|
510
|
+
},
|
|
511
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
512
|
+
type: "checkbox",
|
|
513
|
+
checked: g.raiseHeaderBudget,
|
|
399
514
|
disabled: busy,
|
|
400
515
|
onChange: (e) => void commit({
|
|
401
516
|
...g,
|
|
402
|
-
|
|
517
|
+
raiseHeaderBudget: e.target.checked
|
|
403
518
|
})
|
|
404
|
-
}), t("guard.
|
|
519
|
+
}), t("guard.enableBudget")]
|
|
405
520
|
}),
|
|
406
521
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
407
522
|
style: {
|
|
@@ -578,6 +693,7 @@ window.__ModuleLoader__.load({
|
|
|
578
693
|
t
|
|
579
694
|
}),
|
|
580
695
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(GuardPanel, { t }),
|
|
696
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(LegacyPanel, { t }),
|
|
581
697
|
state?.lastFix ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
582
698
|
style: {
|
|
583
699
|
fontSize: "0.85em",
|