litmus-cli 0.3.0__py3-none-any.whl
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.
- litmus/__init__.py +27 -0
- litmus/artifact.py +179 -0
- litmus/cli.py +342 -0
- litmus/detectors/__init__.py +3 -0
- litmus/detectors/base.py +56 -0
- litmus/exif.py +158 -0
- litmus/inspectors/__init__.py +32 -0
- litmus/inspectors/base.py +36 -0
- litmus/inspectors/c2pa.py +159 -0
- litmus/inspectors/file_metadata.py +210 -0
- litmus/inspectors/office_metadata.py +54 -0
- litmus/inspectors/text_markers.py +75 -0
- litmus/inspectors/unicode_scan.py +308 -0
- litmus/io.py +54 -0
- litmus/model.py +173 -0
- litmus/office.py +198 -0
- litmus/pipeline.py +464 -0
- litmus/providers/__init__.py +17 -0
- litmus/providers/registry.py +239 -0
- litmus/reporting.py +150 -0
- litmus/server.py +176 -0
- litmus/transform/__init__.py +12 -0
- litmus/transform/base.py +30 -0
- litmus/transform/code_structural.py +119 -0
- litmus/transform/file_strip.py +148 -0
- litmus/transform/text_normalize.py +257 -0
- litmus/validate/__init__.py +3 -0
- litmus/validate/binary.py +75 -0
- litmus/validate/code.py +165 -0
- litmus/validate/office.py +73 -0
- litmus/validate/structural.py +136 -0
- litmus/validate/text.py +158 -0
- litmus/validate/treesitter_code.py +129 -0
- litmus/web_ui.py +728 -0
- litmus_cli-0.3.0.dist-info/METADATA +108 -0
- litmus_cli-0.3.0.dist-info/RECORD +39 -0
- litmus_cli-0.3.0.dist-info/WHEEL +4 -0
- litmus_cli-0.3.0.dist-info/entry_points.txt +2 -0
- litmus_cli-0.3.0.dist-info/licenses/LICENSE +21 -0
litmus/web_ui.py
ADDED
|
@@ -0,0 +1,728 @@
|
|
|
1
|
+
"""The litmus web UI: a single self-contained HTML page.
|
|
2
|
+
|
|
3
|
+
Kept as its own module so ``server.py`` stays focused on HTTP concerns. The
|
|
4
|
+
page is deliberately self-contained (inline CSS/JS, no external fetches) to
|
|
5
|
+
satisfy its strict Content-Security-Policy and the project's local-only
|
|
6
|
+
stance: nothing the browser renders is loaded off the machine.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from .transform import PROFILES
|
|
12
|
+
|
|
13
|
+
__all__ = ["INDEX_HTML"]
|
|
14
|
+
|
|
15
|
+
# User-facing names for the cleaning levels. The wire value stays the profile
|
|
16
|
+
# id; only the label is friendly.
|
|
17
|
+
_PROFILE_LABELS = {
|
|
18
|
+
"minimal": "Minimal — invisible characters only",
|
|
19
|
+
"standard": "Standard (recommended)",
|
|
20
|
+
"tidy": "Tidy — also neaten spacing",
|
|
21
|
+
"code": "Code-aware — also remove unused Python imports",
|
|
22
|
+
}
|
|
23
|
+
_PROFILE_OPTIONS = "".join(
|
|
24
|
+
f'<option value="{p}"{" selected" if p == "standard" else ""}>'
|
|
25
|
+
f"{_PROFILE_LABELS.get(p, p.title())}</option>"
|
|
26
|
+
for p in PROFILES
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# The web UI. Deliberately self-contained (inline CSS/JS, no external fetches)
|
|
30
|
+
# so it satisfies the page's strict CSP and the project's local-only stance.
|
|
31
|
+
# Aesthetic: a warm "forensic lab" — dark, dimensional, friendly. All result
|
|
32
|
+
# copy is written for non-technical readers; raw identifiers stay available
|
|
33
|
+
# in small print so nothing is hidden, only translated.
|
|
34
|
+
INDEX_HTML = """<!doctype html>
|
|
35
|
+
<html lang="en" data-theme="dark">
|
|
36
|
+
<head>
|
|
37
|
+
<meta charset="utf-8">
|
|
38
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
39
|
+
<title>litmus</title>
|
|
40
|
+
<style>
|
|
41
|
+
:root{
|
|
42
|
+
--bg:#06070d; --bg2:#0a0d16; --panel:rgba(19,25,37,.66); --panel-2:rgba(24,31,46,.6);
|
|
43
|
+
--raise:#1a2233; --ink:#eef2f8; --dim:#9aa7bb; --faint:#5c6879;
|
|
44
|
+
--line:rgba(130,150,185,.12); --line-2:rgba(150,170,205,.2);
|
|
45
|
+
--signal:#ffb020; --signal-2:#ff863a; --signal-soft:rgba(255,176,32,.14); --signal-glow:rgba(255,150,40,.45);
|
|
46
|
+
--good:#3ddc97; --good-soft:rgba(61,220,151,.13);
|
|
47
|
+
--bad:#ff6b6b; --bad-soft:rgba(255,107,107,.12);
|
|
48
|
+
--mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;
|
|
49
|
+
--sans:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
|
|
50
|
+
--round:ui-rounded,"SF Pro Rounded","Hiragino Maru Gothic ProN","Trebuchet MS",var(--sans);
|
|
51
|
+
--radius:20px;
|
|
52
|
+
--glass:saturate(160%) blur(16px);
|
|
53
|
+
--card-shadow:0 1px 0 rgba(255,255,255,.06) inset, 0 -24px 50px rgba(0,0,0,.22) inset,
|
|
54
|
+
0 28px 64px -22px rgba(0,0,0,.75), 0 8px 24px -14px rgba(0,0,0,.6);
|
|
55
|
+
--card-shadow-hover:0 1px 0 rgba(255,255,255,.10) inset, 0 -24px 50px rgba(0,0,0,.24) inset,
|
|
56
|
+
0 46px 100px -28px rgba(0,0,0,.9), 0 14px 34px -16px rgba(0,0,0,.72);
|
|
57
|
+
}
|
|
58
|
+
*{box-sizing:border-box}
|
|
59
|
+
html{scroll-behavior:smooth}
|
|
60
|
+
html,body{height:100%}
|
|
61
|
+
body{
|
|
62
|
+
margin:0;background:var(--bg);color:var(--ink);font-family:var(--sans);
|
|
63
|
+
font-size:15px;line-height:1.55;-webkit-font-smoothing:antialiased;overflow-x:hidden;
|
|
64
|
+
}
|
|
65
|
+
/* layered atmosphere: drifting aurora + masked grid */
|
|
66
|
+
.bg{position:fixed;inset:0;z-index:0;pointer-events:none;overflow:hidden}
|
|
67
|
+
.bg::before{content:"";position:absolute;inset:-25%;
|
|
68
|
+
background:
|
|
69
|
+
radial-gradient(38% 30% at 18% 12%, rgba(255,150,40,.18), transparent 60%),
|
|
70
|
+
radial-gradient(34% 30% at 86% 8%, rgba(96,124,255,.14), transparent 60%),
|
|
71
|
+
radial-gradient(46% 42% at 74% 88%, rgba(61,220,151,.10), transparent 60%),
|
|
72
|
+
radial-gradient(40% 36% at 8% 92%, rgba(255,84,120,.08), transparent 60%);
|
|
73
|
+
filter:blur(38px);animation:aurora 26s ease-in-out infinite alternate}
|
|
74
|
+
.bg::after{content:"";position:absolute;inset:0;
|
|
75
|
+
background-image:linear-gradient(rgba(140,160,195,.05) 1px,transparent 1px),
|
|
76
|
+
linear-gradient(90deg,rgba(140,160,195,.05) 1px,transparent 1px);
|
|
77
|
+
background-size:50px 50px;
|
|
78
|
+
-webkit-mask:radial-gradient(120% 82% at 50% 0%,#000 38%,transparent 100%);
|
|
79
|
+
mask:radial-gradient(120% 82% at 50% 0%,#000 38%,transparent 100%)}
|
|
80
|
+
@keyframes aurora{0%{transform:translate3d(-2%,-1%,0) scale(1.05) rotate(0deg)}
|
|
81
|
+
100%{transform:translate3d(2%,3%,0) scale(1.18) rotate(5deg)}}
|
|
82
|
+
/* film grain */
|
|
83
|
+
body::before{content:"";position:fixed;inset:0;z-index:1;pointer-events:none;opacity:.4;mix-blend-mode:overlay;
|
|
84
|
+
background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
|
|
85
|
+
background-size:150px}
|
|
86
|
+
/* pointer-follow glow */
|
|
87
|
+
body::after{content:"";position:fixed;inset:0;z-index:0;pointer-events:none;
|
|
88
|
+
background:radial-gradient(300px circle at var(--mx,50%) var(--my,-20%), rgba(255,176,32,.10), transparent 72%)}
|
|
89
|
+
.wrap{position:relative;z-index:2;max-width:840px;margin:0 auto;padding:54px 22px 120px}
|
|
90
|
+
header{display:flex;align-items:center;gap:14px;margin-bottom:6px}
|
|
91
|
+
.brand{font-family:var(--mono);font-weight:600;font-size:16px;letter-spacing:.36em;text-transform:uppercase;
|
|
92
|
+
background:linear-gradient(90deg,#ffffff,#c4cfe0);-webkit-background-clip:text;background-clip:text;color:transparent}
|
|
93
|
+
.brand b{background:linear-gradient(90deg,var(--signal),var(--signal-2));-webkit-background-clip:text;background-clip:text;
|
|
94
|
+
color:transparent;text-shadow:0 0 18px var(--signal-glow)}
|
|
95
|
+
.ver{font-family:var(--mono);font-size:10.5px;color:var(--dim);letter-spacing:.12em;
|
|
96
|
+
padding:4px 11px;border:1px solid var(--line-2);border-radius:999px;
|
|
97
|
+
background:rgba(255,255,255,.03);-webkit-backdrop-filter:var(--glass);backdrop-filter:var(--glass)}
|
|
98
|
+
.tagline{color:var(--dim);margin:16px 0 34px;max-width:60ch;font-size:16.5px;line-height:1.6;
|
|
99
|
+
animation:fadeUp .8s .05s cubic-bezier(.2,.7,.2,1) both}
|
|
100
|
+
.tagline b{color:var(--ink);font-weight:700}
|
|
101
|
+
@keyframes fadeUp{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
|
|
102
|
+
|
|
103
|
+
/* ---- scanner (upload) ---- */
|
|
104
|
+
.scanner{position:relative;border:1px solid var(--line-2);border-radius:var(--radius);
|
|
105
|
+
background:linear-gradient(180deg,var(--panel),var(--panel-2));overflow:hidden;
|
|
106
|
+
box-shadow:var(--card-shadow);-webkit-backdrop-filter:var(--glass);backdrop-filter:var(--glass);
|
|
107
|
+
transform-style:preserve-3d;transition:transform .18s cubic-bezier(.2,.7,.2,1), box-shadow .3s;
|
|
108
|
+
animation:fadeUp .9s .1s cubic-bezier(.2,.7,.2,1) both}
|
|
109
|
+
.scanner::before{content:"";position:absolute;inset:0;border-radius:var(--radius);pointer-events:none;
|
|
110
|
+
background:linear-gradient(140deg,rgba(255,255,255,.06),transparent 30%,transparent 70%,rgba(255,255,255,.03));
|
|
111
|
+
-webkit-mask:linear-gradient(#000,#000) content-box,linear-gradient(#000,#000);mask-composite:exclude;padding:1px;opacity:.7}
|
|
112
|
+
.scanner:hover{box-shadow:var(--card-shadow-hover)}
|
|
113
|
+
#drop{position:relative;padding:50px 28px;text-align:center;cursor:pointer;
|
|
114
|
+
transition:background .18s ease, box-shadow .18s ease;outline:none}
|
|
115
|
+
#drop:focus-visible{box-shadow:inset 0 0 0 2px var(--signal)}
|
|
116
|
+
#drop .eye{display:block;margin:0 auto 16px;width:46px;height:46px;color:var(--faint);
|
|
117
|
+
transition:color .2s,transform .25s cubic-bezier(.2,.7,.2,1.4)}
|
|
118
|
+
#drop:hover .eye{color:var(--dim);transform:translateY(-2px)}
|
|
119
|
+
#drop .big{font-family:var(--round);font-size:16px;color:var(--ink)}
|
|
120
|
+
#drop .big u{text-decoration:none;color:var(--signal);border-bottom:1px dashed var(--signal)}
|
|
121
|
+
#drop .hint{display:block;margin-top:8px;font-size:12.5px;color:var(--faint);
|
|
122
|
+
font-family:var(--mono);letter-spacing:.04em}
|
|
123
|
+
.scanner.over #drop{background:var(--signal-soft)}
|
|
124
|
+
.scanner.over #drop .eye{color:var(--signal);transform:scale(1.1)}
|
|
125
|
+
.scanner.over::after,.scanner.busy::after{content:"";position:absolute;left:0;right:0;height:2px;top:0;
|
|
126
|
+
background:linear-gradient(90deg,transparent,var(--signal),transparent);
|
|
127
|
+
animation:scan 1.1s linear infinite;z-index:2}
|
|
128
|
+
@keyframes scan{0%{top:0;opacity:0}10%{opacity:1}90%{opacity:1}100%{top:100%;opacity:0}}
|
|
129
|
+
|
|
130
|
+
.controls{display:flex;flex-wrap:wrap;gap:10px 18px;align-items:center;
|
|
131
|
+
padding:16px 20px;border-top:1px solid var(--line);background:var(--panel)}
|
|
132
|
+
.seg{display:inline-flex;border:1px solid var(--line-2);border-radius:10px;overflow:hidden;
|
|
133
|
+
box-shadow:0 1px 0 rgba(255,255,255,.04) inset}
|
|
134
|
+
.seg label{padding:7px 16px;font-family:var(--round);font-size:13px;
|
|
135
|
+
color:var(--dim);cursor:pointer;transition:.15s;user-select:none}
|
|
136
|
+
.seg input{position:absolute;opacity:0;pointer-events:none}
|
|
137
|
+
.seg label:has(input:checked){background:var(--signal);color:#0a0c11;font-weight:700}
|
|
138
|
+
.opt{display:inline-flex;gap:7px;align-items:center;font-size:13px;color:var(--dim)}
|
|
139
|
+
.opt select{font-family:var(--sans);font-size:12.5px;padding:6px 8px;border-radius:8px;
|
|
140
|
+
border:1px solid var(--line-2);background:var(--panel-2);color:var(--ink)}
|
|
141
|
+
#run{margin-left:auto;font-family:var(--round);font-size:13.5px;letter-spacing:.02em;
|
|
142
|
+
background:linear-gradient(180deg,#ffc14d,var(--signal));color:#0a0c11;font-weight:700;
|
|
143
|
+
border:0;border-radius:10px;padding:10px 22px;cursor:pointer;
|
|
144
|
+
box-shadow:0 1px 0 rgba(255,255,255,.35) inset, 0 6px 16px rgba(255,176,32,.25);
|
|
145
|
+
transition:transform .12s ease, box-shadow .12s ease, filter .12s}
|
|
146
|
+
#run:hover:not(:disabled){filter:brightness(1.06);transform:translateY(-1px);
|
|
147
|
+
box-shadow:0 1px 0 rgba(255,255,255,.35) inset, 0 10px 22px rgba(255,176,32,.32)}
|
|
148
|
+
#run:active:not(:disabled){transform:translateY(1px);box-shadow:0 1px 0 rgba(255,255,255,.2) inset,0 3px 8px rgba(255,176,32,.2)}
|
|
149
|
+
#run:disabled{opacity:.35;cursor:not-allowed}
|
|
150
|
+
#chosen{font-family:var(--mono);font-size:12px;color:var(--faint);padding:0 20px 14px;background:var(--panel)}
|
|
151
|
+
#chosen:not(:empty){padding-top:2px}
|
|
152
|
+
|
|
153
|
+
/* ---- results ---- */
|
|
154
|
+
#out{margin-top:28px;display:grid;gap:18px}
|
|
155
|
+
.panel{border:1px solid var(--line-2);border-radius:var(--radius);background:var(--panel);
|
|
156
|
+
overflow:hidden;box-shadow:var(--card-shadow);
|
|
157
|
+
-webkit-backdrop-filter:var(--glass);backdrop-filter:var(--glass);
|
|
158
|
+
transition:transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s, opacity .6s;}
|
|
159
|
+
.panel:hover{transform:translateY(-3px);box-shadow:var(--card-shadow-hover)}
|
|
160
|
+
/* scroll-reveal: panels rise into view as you scroll */
|
|
161
|
+
.panel,.footnote,.resetrow{opacity:0;transform:translateY(28px) scale(.985);
|
|
162
|
+
transition:opacity .7s cubic-bezier(.2,.7,.2,1),transform .7s cubic-bezier(.2,.7,.2,1);
|
|
163
|
+
transition-delay:calc(var(--i,0)*70ms)}
|
|
164
|
+
.panel.in,.footnote.in,.resetrow.in{opacity:1;transform:none}
|
|
165
|
+
.panel.in:hover{transform:translateY(-3px)}
|
|
166
|
+
@keyframes rise{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
|
|
167
|
+
|
|
168
|
+
/* verdict hero */
|
|
169
|
+
.hero{display:flex;gap:20px;align-items:center;padding:26px 26px;position:relative;overflow:hidden}
|
|
170
|
+
.hero::after{content:"";position:absolute;top:0;left:-60%;width:40%;height:100%;
|
|
171
|
+
background:linear-gradient(105deg,transparent,rgba(255,255,255,.045),transparent);
|
|
172
|
+
animation:sheen 1.6s .35s cubic-bezier(.2,.7,.3,1) both}
|
|
173
|
+
@keyframes sheen{to{left:120%}}
|
|
174
|
+
.orb{flex:0 0 auto;width:62px;height:62px;border-radius:50%;display:grid;place-items:center;position:relative}
|
|
175
|
+
.orb svg{width:30px;height:30px;position:relative;z-index:1}
|
|
176
|
+
.orb::before{content:"";position:absolute;inset:0;border-radius:50%;
|
|
177
|
+
background:radial-gradient(circle at 32% 28%,rgba(255,255,255,.5),transparent 42%),var(--orb-c,#2b3648);
|
|
178
|
+
box-shadow:0 8px 20px var(--orb-glow,rgba(0,0,0,.4)), 0 2px 4px rgba(0,0,0,.4),
|
|
179
|
+
0 1px 1px rgba(255,255,255,.25) inset, 0 -6px 12px rgba(0,0,0,.28) inset}
|
|
180
|
+
.hero.ok .orb{--orb-c:linear-gradient(180deg,#3ddc97,#1fa76c);--orb-glow:rgba(61,220,151,.35)}
|
|
181
|
+
.hero.warn .orb{--orb-c:linear-gradient(180deg,#ffc14d,#e09612);--orb-glow:rgba(255,176,32,.35)}
|
|
182
|
+
.hero.no .orb{--orb-c:linear-gradient(180deg,#ff8a8a,#d84a4a);--orb-glow:rgba(255,107,107,.3)}
|
|
183
|
+
.hero.ok .orb::after{content:"";position:absolute;inset:-6px;border-radius:50%;
|
|
184
|
+
border:2px solid var(--good);opacity:0;animation:pulse 1s .3s ease-out 2}
|
|
185
|
+
@keyframes pulse{0%{transform:scale(.8);opacity:.8}100%{transform:scale(1.5);opacity:0}}
|
|
186
|
+
.hero h1{margin:0 0 4px;font-family:var(--round);font-size:22px;line-height:1.2;font-weight:700}
|
|
187
|
+
.hero p{margin:0;color:var(--dim);font-size:14px;max-width:52ch}
|
|
188
|
+
.hero .kicker{font-family:var(--mono);font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;
|
|
189
|
+
color:var(--faint);display:block;margin-bottom:6px}
|
|
190
|
+
.hero .num{color:var(--signal);font-variant-numeric:tabular-nums}
|
|
191
|
+
.checkdraw{stroke-dasharray:26;stroke-dashoffset:26;animation:draw .5s .25s ease-out forwards}
|
|
192
|
+
@keyframes draw{to{stroke-dashoffset:0}}
|
|
193
|
+
.heroCta{margin:0 26px 22px;display:flex;gap:12px;align-items:center;flex-wrap:wrap}
|
|
194
|
+
.dl{display:inline-block;text-decoration:none}
|
|
195
|
+
.dl button{font-family:var(--round);font-size:14px;font-weight:700;letter-spacing:.02em;
|
|
196
|
+
background:linear-gradient(180deg,#4ce8a6,#26bd7e);color:#07130d;border:0;border-radius:12px;
|
|
197
|
+
padding:12px 22px;cursor:pointer;display:flex;gap:9px;align-items:center;
|
|
198
|
+
box-shadow:0 1px 0 rgba(255,255,255,.4) inset, 0 8px 20px rgba(61,220,151,.28);
|
|
199
|
+
transition:transform .12s, box-shadow .12s, filter .12s}
|
|
200
|
+
.dl button:hover{filter:brightness(1.05);transform:translateY(-1px)}
|
|
201
|
+
.dl button:active{transform:translateY(1px);box-shadow:0 1px 0 rgba(255,255,255,.25) inset,0 3px 8px rgba(61,220,151,.2)}
|
|
202
|
+
.ctaNote{color:var(--faint);font-size:12.5px}
|
|
203
|
+
|
|
204
|
+
/* findings */
|
|
205
|
+
.panel h2{margin:0;padding:14px 20px;font-family:var(--mono);font-size:11.5px;letter-spacing:.16em;
|
|
206
|
+
text-transform:uppercase;color:var(--dim);border-bottom:1px solid var(--line);
|
|
207
|
+
display:flex;justify-content:space-between;align-items:center}
|
|
208
|
+
.panel h2 .count{color:var(--signal)}
|
|
209
|
+
.cards{padding:14px;display:grid;gap:10px}
|
|
210
|
+
.finding{border:1px solid var(--line);border-radius:13px;background:var(--panel-2);
|
|
211
|
+
padding:14px 16px;animation:rise .45s both;transition:border-color .15s, transform .15s}
|
|
212
|
+
.finding:hover{border-color:var(--line-2);transform:translateY(-1px)}
|
|
213
|
+
.finding .top{display:flex;align-items:center;gap:11px;flex-wrap:wrap}
|
|
214
|
+
.fico{flex:0 0 auto;width:34px;height:34px;border-radius:10px;display:grid;place-items:center;
|
|
215
|
+
background:var(--raise);color:var(--signal);border:1px solid var(--line-2);
|
|
216
|
+
box-shadow:0 1px 0 rgba(255,255,255,.05) inset, 0 3px 8px rgba(0,0,0,.3)}
|
|
217
|
+
.fico svg{width:17px;height:17px}
|
|
218
|
+
.ftitle{font-family:var(--round);font-size:15px;font-weight:700;color:var(--ink)}
|
|
219
|
+
.tag{margin-left:auto;font-family:var(--round);font-size:11px;font-weight:700;padding:3px 10px;
|
|
220
|
+
border-radius:999px}
|
|
221
|
+
.tag.warning{background:var(--signal-soft);color:var(--signal)}
|
|
222
|
+
.tag.notice{background:rgba(147,160,179,.14);color:var(--dim)}
|
|
223
|
+
.tag.info{background:rgba(147,160,179,.10);color:var(--faint)}
|
|
224
|
+
.fbody{color:var(--dim);margin:7px 0 0;font-size:13.5px;line-height:1.5}
|
|
225
|
+
.floc{font-family:var(--mono);font-size:11px;color:var(--faint);margin-top:7px}
|
|
226
|
+
.payload{margin-top:10px;font-family:var(--mono);font-size:13px;background:var(--bad-soft);
|
|
227
|
+
border:1px solid var(--bad);border-radius:9px;padding:9px 12px;color:var(--ink)}
|
|
228
|
+
.payload span{color:var(--bad);letter-spacing:.05em;text-transform:uppercase;font-size:10.5px;display:block;margin-bottom:3px}
|
|
229
|
+
.fix{display:flex;gap:7px;align-items:center;font-family:var(--round);font-size:12.5px;font-weight:600;
|
|
230
|
+
color:var(--good);margin-top:9px}
|
|
231
|
+
.fix svg{width:13px;height:13px}
|
|
232
|
+
.rawid{font-family:var(--mono);font-size:10px;color:var(--faint);opacity:.7}
|
|
233
|
+
|
|
234
|
+
.allclear{display:flex;gap:14px;align-items:center;padding:22px 20px;color:var(--dim);font-size:14px}
|
|
235
|
+
.allclear svg{color:var(--good);flex:0 0 auto}
|
|
236
|
+
|
|
237
|
+
/* file strip + fine print */
|
|
238
|
+
.meta{display:flex;flex-wrap:wrap;gap:6px 22px;font-size:13px;color:var(--dim);padding:14px 20px;align-items:baseline}
|
|
239
|
+
.meta b{color:var(--ink);font-weight:600;font-family:var(--round)}
|
|
240
|
+
.meta .fp{font-family:var(--mono);font-size:10.5px;color:var(--faint);margin-left:auto}
|
|
241
|
+
.notes{padding:14px 20px;color:var(--faint);font-size:12.5px;line-height:1.65}
|
|
242
|
+
.notes b{color:var(--dim)}
|
|
243
|
+
.footnote{max-width:60ch;margin:14px auto 2px;padding:0 20px;text-align:center;
|
|
244
|
+
color:var(--faint);font-size:12px;line-height:1.6}
|
|
245
|
+
details.tech{margin-top:8px}
|
|
246
|
+
details.tech summary{cursor:pointer;font-family:var(--mono);font-size:11px;color:var(--faint);letter-spacing:.06em}
|
|
247
|
+
details.tech div{margin-top:6px;font-family:var(--mono);font-size:11.5px;color:var(--faint);line-height:1.6}
|
|
248
|
+
.working{padding:28px 20px;color:var(--dim);font-family:var(--round);font-size:14px}
|
|
249
|
+
.working::after{content:"";animation:dots 1.2s steps(4,end) infinite}
|
|
250
|
+
@keyframes dots{0%{content:""}25%{content:"."}50%{content:".."}75%{content:"..."}}
|
|
251
|
+
|
|
252
|
+
/* input-source toggle + paste box */
|
|
253
|
+
.source{display:flex;gap:4px;padding:12px 12px 0}
|
|
254
|
+
.source button{flex:0 0 auto;font-family:var(--round);font-size:13px;font-weight:600;color:var(--dim);
|
|
255
|
+
background:transparent;border:0;border-radius:9px 9px 0 0;padding:9px 16px;cursor:pointer;transition:.15s}
|
|
256
|
+
.source button[aria-selected="true"]{color:var(--ink);background:var(--panel);box-shadow:inset 0 -2px 0 var(--signal)}
|
|
257
|
+
#paste{width:calc(100% - 24px);margin:12px;min-height:150px;resize:vertical;
|
|
258
|
+
font-family:var(--mono);font-size:13px;line-height:1.5;color:var(--ink);
|
|
259
|
+
background:var(--panel-2);border:1px solid var(--line-2);border-radius:12px;padding:14px;outline:none}
|
|
260
|
+
#paste:focus{box-shadow:inset 0 0 0 2px var(--signal-soft),0 0 0 1px var(--signal)}
|
|
261
|
+
#paste::placeholder{color:var(--faint)}
|
|
262
|
+
.hidden{display:none!important}
|
|
263
|
+
|
|
264
|
+
/* C2PA / verification verdict on a finding */
|
|
265
|
+
.verify{display:inline-flex;gap:6px;align-items:center;margin-top:9px;font-family:var(--round);
|
|
266
|
+
font-size:12px;font-weight:700;padding:3px 10px;border-radius:999px}
|
|
267
|
+
.verify.genuine{background:var(--good-soft);color:var(--good)}
|
|
268
|
+
.verify.unver{background:var(--signal-soft);color:var(--signal)}
|
|
269
|
+
.verify.invalid{background:var(--bad-soft);color:var(--bad)}
|
|
270
|
+
|
|
271
|
+
/* before/after reveal (diff) */
|
|
272
|
+
.reveal{padding:14px 18px 18px}
|
|
273
|
+
.reveal .lead{color:var(--dim);font-size:13px;margin:0 0 10px}
|
|
274
|
+
.reveal pre{margin:0;padding:14px;border-radius:12px;background:var(--panel-2);border:1px solid var(--line-2);
|
|
275
|
+
font-family:var(--mono);font-size:12.5px;line-height:1.7;white-space:pre-wrap;word-break:break-word;
|
|
276
|
+
max-height:260px;overflow:auto;color:var(--ink)}
|
|
277
|
+
.chip-hidden{display:inline-block;background:var(--bad);color:#180a0a;font-family:var(--mono);font-size:9.5px;
|
|
278
|
+
font-weight:700;letter-spacing:.03em;border-radius:5px;padding:1px 5px;margin:0 1px;vertical-align:middle;transform:translateY(-1px)}
|
|
279
|
+
|
|
280
|
+
/* copy-text output (paste mode) */
|
|
281
|
+
.copywrap{padding:0 18px 18px}
|
|
282
|
+
.copybtn{font-family:var(--round);font-size:13px;font-weight:700;background:var(--raise);color:var(--ink);
|
|
283
|
+
border:1px solid var(--line-2);border-radius:10px;padding:9px 16px;cursor:pointer;display:inline-flex;gap:8px;align-items:center;transition:.15s}
|
|
284
|
+
.copybtn:hover{border-color:var(--signal);color:var(--signal)}
|
|
285
|
+
.copybtn.done{background:var(--good-soft);color:var(--good);border-color:var(--good)}
|
|
286
|
+
|
|
287
|
+
/* start-over / reset */
|
|
288
|
+
.resetrow{text-align:center;margin-top:4px}
|
|
289
|
+
.resetbtn{font-family:var(--round);font-size:13.5px;font-weight:600;color:var(--dim);background:var(--panel);
|
|
290
|
+
border:1px solid var(--line-2);border-radius:11px;padding:10px 22px;cursor:pointer;display:inline-flex;gap:8px;align-items:center;
|
|
291
|
+
box-shadow:var(--card-shadow);transition:transform .12s,border-color .15s,color .15s}
|
|
292
|
+
.resetbtn:hover{color:var(--ink);border-color:var(--signal);transform:translateY(-1px)}
|
|
293
|
+
.resetbtn:active{transform:translateY(1px)}
|
|
294
|
+
.resetbtn svg{width:15px;height:15px}
|
|
295
|
+
|
|
296
|
+
/* batch (multi-file) summary + rows */
|
|
297
|
+
.batch{padding:8px 14px 14px;display:grid;gap:8px}
|
|
298
|
+
.brow{display:flex;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--line);
|
|
299
|
+
border-radius:12px;background:var(--panel-2);transition:border-color .15s}
|
|
300
|
+
.brow:hover{border-color:var(--line-2)}
|
|
301
|
+
.brow .dot{width:9px;height:9px;border-radius:50%;flex:0 0 auto}
|
|
302
|
+
.brow .dot.ok{background:var(--good)} .brow .dot.warn{background:var(--signal)} .brow .dot.no{background:var(--bad)}
|
|
303
|
+
.brow .bname{font-family:var(--round);font-weight:600;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
304
|
+
.brow .bstat{margin-left:auto;font-size:12.5px;color:var(--dim);flex:0 0 auto}
|
|
305
|
+
.brow a.mini{margin-left:10px;text-decoration:none}
|
|
306
|
+
.brow a.mini button{font-family:var(--round);font-size:12px;font-weight:700;background:var(--good);color:#07130d;
|
|
307
|
+
border:0;border-radius:8px;padding:6px 12px;cursor:pointer}
|
|
308
|
+
/* premium finishing details */
|
|
309
|
+
::selection{background:rgba(255,176,32,.28);color:#fff}
|
|
310
|
+
::-webkit-scrollbar{width:12px;height:12px}
|
|
311
|
+
::-webkit-scrollbar-track{background:transparent}
|
|
312
|
+
::-webkit-scrollbar-thumb{background:linear-gradient(var(--line-2),var(--raise));border-radius:99px;
|
|
313
|
+
border:3px solid transparent;background-clip:padding-box}
|
|
314
|
+
::-webkit-scrollbar-thumb:hover{background:linear-gradient(var(--signal-soft),var(--line-2));background-clip:padding-box}
|
|
315
|
+
html{scrollbar-color:var(--line-2) transparent}
|
|
316
|
+
.hero .orb{animation:float 5s ease-in-out infinite}
|
|
317
|
+
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}
|
|
318
|
+
@media (prefers-reduced-motion:reduce){
|
|
319
|
+
*{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}
|
|
320
|
+
.panel,.footnote,.resetrow{opacity:1!important;transform:none!important}
|
|
321
|
+
.bg::before{animation:none!important}
|
|
322
|
+
}
|
|
323
|
+
@media (max-width:560px){.hero{flex-direction:column;text-align:center;align-items:center}.tag{margin-left:0}}
|
|
324
|
+
</style>
|
|
325
|
+
</head>
|
|
326
|
+
<body>
|
|
327
|
+
<div class="bg" aria-hidden="true"></div>
|
|
328
|
+
<div class="wrap">
|
|
329
|
+
<header>
|
|
330
|
+
<span class="brand">lit<b>m</b>us</span>
|
|
331
|
+
<span class="ver">100% local · private</span>
|
|
332
|
+
</header>
|
|
333
|
+
<p class="tagline"><b>See what's hiding in your files.</b> Drop one in — litmus reveals
|
|
334
|
+
invisible characters, hidden file info and content credentials, and can strip them out without
|
|
335
|
+
changing anything you can see. Nothing ever leaves your computer.</p>
|
|
336
|
+
|
|
337
|
+
<div class="scanner" id="scanner">
|
|
338
|
+
<div class="source" role="tablist">
|
|
339
|
+
<button id="tab-file" role="tab" aria-selected="true">Files</button>
|
|
340
|
+
<button id="tab-text" role="tab" aria-selected="false">Paste text</button>
|
|
341
|
+
</div>
|
|
342
|
+
<div id="drop" role="button" tabindex="0" aria-label="Choose or drop files to analyse">
|
|
343
|
+
<svg class="eye" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4">
|
|
344
|
+
<path d="M1.5 12S5 5 12 5s10.5 7 10.5 7-3.5 7-10.5 7S1.5 12 1.5 12Z"/>
|
|
345
|
+
<circle cx="12" cy="12" r="3.2"/>
|
|
346
|
+
</svg>
|
|
347
|
+
<span class="big">Drop files or <u>browse</u></span>
|
|
348
|
+
<span class="hint">text · code · png · jpeg · svg · docx / xlsx / pptx · select several at once</span>
|
|
349
|
+
<input id="file" type="file" multiple hidden>
|
|
350
|
+
</div>
|
|
351
|
+
<textarea id="paste" class="hidden" placeholder="Paste text here — litmus will reveal and remove any hidden characters, without changing a single word you can see."></textarea>
|
|
352
|
+
<div class="controls">
|
|
353
|
+
<span class="seg">
|
|
354
|
+
<label><input type="radio" name="mode" value="inspect" checked> Check</label>
|
|
355
|
+
<label><input type="radio" name="mode" value="clean"> Clean</label>
|
|
356
|
+
</span>
|
|
357
|
+
<label class="opt">Cleaning level
|
|
358
|
+
<select id="profile">__PROFILE_OPTIONS__</select>
|
|
359
|
+
</label>
|
|
360
|
+
<label class="opt" title="For source code: apply the clean-up even when litmus cannot verify the program is unchanged. Unverified results are clearly marked.">
|
|
361
|
+
<input type="checkbox" id="force"> allow unverified <span style="color:var(--faint)">(code)</span>
|
|
362
|
+
</label>
|
|
363
|
+
<button id="run" disabled>Check file</button>
|
|
364
|
+
</div>
|
|
365
|
+
<div id="chosen"></div>
|
|
366
|
+
</div>
|
|
367
|
+
|
|
368
|
+
<div id="out"></div>
|
|
369
|
+
</div>
|
|
370
|
+
<script>
|
|
371
|
+
const $=(s)=>document.querySelector(s);
|
|
372
|
+
const drop=$("#drop"),fileInput=$("#file"),runBtn=$("#run"),out=$("#out"),scanner=$("#scanner");
|
|
373
|
+
const paste=$("#paste"),tabFile=$("#tab-file"),tabText=$("#tab-text");
|
|
374
|
+
const MAX_FILE=16*1024*1024, MAX_FILES=300;
|
|
375
|
+
let picked=[]; // File[] in file mode
|
|
376
|
+
let source="file"; // "file" | "text"
|
|
377
|
+
function fmtBytes(n){return n<1024?n+" B":n<1048576?(n/1024).toFixed(1)+" KB":(n/1048576).toFixed(1)+" MB"}
|
|
378
|
+
function modeVerb(){return document.querySelector('input[name=mode]:checked').value==="clean"?"Clean":"Check";}
|
|
379
|
+
function refreshRun(){
|
|
380
|
+
if(source==="text"){runBtn.disabled=paste.value.length===0;runBtn.textContent=modeVerb()+" text";}
|
|
381
|
+
else{runBtn.disabled=picked.length===0;runBtn.textContent=modeVerb()+(picked.length>1?` ${picked.length} files`:" file");}
|
|
382
|
+
}
|
|
383
|
+
function baseName(f){return (f.webkitRelativePath||f.name||"").split("/").pop();}
|
|
384
|
+
function isJunk(f){const b=baseName(f);return b===".DS_Store"||b==="Thumbs.db"||b.startsWith("._")||b==="";}
|
|
385
|
+
function choose(files){
|
|
386
|
+
const all=Array.from(files||[]).filter(f=>!isJunk(f));
|
|
387
|
+
const oversized=all.filter(f=>f.size>MAX_FILE).length;
|
|
388
|
+
const usable=all.filter(f=>f.size<=MAX_FILE); // empty files are allowed
|
|
389
|
+
picked=usable.slice(0,MAX_FILES);
|
|
390
|
+
const capped=usable.length-picked.length;
|
|
391
|
+
const el=$("#chosen");
|
|
392
|
+
if(!picked.length){
|
|
393
|
+
el.textContent=(files&&files.length)
|
|
394
|
+
? `> nothing to analyse (${files.length} item(s) selected; ${oversized} over ${fmtBytes(MAX_FILE)}, rest were system files)`
|
|
395
|
+
: "";
|
|
396
|
+
}else if(picked.length<=6){
|
|
397
|
+
el.textContent="> "+picked.map(f=>`${baseName(f)} (${fmtBytes(f.size)})`).join(" · ");
|
|
398
|
+
}else{
|
|
399
|
+
el.textContent=`> ${picked.length} files selected`
|
|
400
|
+
+(oversized?` · ${oversized} skipped (over ${fmtBytes(MAX_FILE)})`:"")
|
|
401
|
+
+(capped?` · ${capped} beyond the ${MAX_FILES}-file limit`:"");
|
|
402
|
+
}
|
|
403
|
+
refreshRun();
|
|
404
|
+
}
|
|
405
|
+
function setSource(s){source=s;
|
|
406
|
+
tabFile.setAttribute("aria-selected",s==="file");tabText.setAttribute("aria-selected",s==="text");
|
|
407
|
+
drop.classList.toggle("hidden",s!=="file");$("#chosen").classList.toggle("hidden",s!=="file");
|
|
408
|
+
paste.classList.toggle("hidden",s!=="text");refreshRun();}
|
|
409
|
+
tabFile.addEventListener("click",()=>setSource("file"));
|
|
410
|
+
tabText.addEventListener("click",()=>setSource("text"));
|
|
411
|
+
paste.addEventListener("input",refreshRun);
|
|
412
|
+
document.querySelectorAll('input[name=mode]').forEach(el=>el.addEventListener("change",refreshRun));
|
|
413
|
+
drop.addEventListener("click",()=>fileInput.click());
|
|
414
|
+
drop.addEventListener("keydown",(e)=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();fileInput.click();}});
|
|
415
|
+
fileInput.addEventListener("change",(e)=>choose(e.target.files));
|
|
416
|
+
["dragover","dragenter"].forEach(ev=>scanner.addEventListener(ev,(e)=>{e.preventDefault();scanner.classList.add("over");}));
|
|
417
|
+
["dragleave","drop"].forEach(ev=>scanner.addEventListener(ev,(e)=>{if(ev==="drop")e.preventDefault();scanner.classList.remove("over");}));
|
|
418
|
+
scanner.addEventListener("drop",(e)=>{e.preventDefault();scanner.classList.remove("over");if(e.dataTransfer.files.length)choose(e.dataTransfer.files);});
|
|
419
|
+
function toBase64(buf){const b=new Uint8Array(buf);let s="";const c=0x8000;for(let i=0;i<b.length;i+=c)s+=String.fromCharCode.apply(null,b.subarray(i,i+c));return btoa(s);}
|
|
420
|
+
function esc(s){return String(s).replace(/[&<>]/g,c=>({'&':'&','<':'<','>':'>'}[c]));}
|
|
421
|
+
|
|
422
|
+
/* clear all input + result state without a browser refresh */
|
|
423
|
+
function resetAll(){
|
|
424
|
+
picked=[];fileInput.value="";paste.value="";window.__cleaned=undefined;
|
|
425
|
+
$("#chosen").textContent="";out.innerHTML="";refreshRun();
|
|
426
|
+
(source==="text"?paste:drop).focus&&(source==="text"?paste.focus():drop.focus());
|
|
427
|
+
window.scrollTo({top:0,behavior:"smooth"});
|
|
428
|
+
}
|
|
429
|
+
const RESET_ROW='<div class="resetrow"><button class="resetbtn" id="resetbtn"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 3-6.7L3 8"/><path d="M3 3v5h5"/></svg> Start over — check another</button></div>';
|
|
430
|
+
const REDUCED=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
431
|
+
// reveal result panels as they scroll into view
|
|
432
|
+
function revealPanels(){
|
|
433
|
+
const els=out.querySelectorAll(".panel:not(.seen),.footnote:not(.seen),.resetrow:not(.seen)");
|
|
434
|
+
if(REDUCED||!("IntersectionObserver" in window)){els.forEach(el=>el.classList.add("seen","in"));return;}
|
|
435
|
+
const io=new IntersectionObserver((ents,obs)=>{ents.forEach(en=>{
|
|
436
|
+
if(en.isIntersecting){en.target.classList.add("in");obs.unobserve(en.target);}});},{rootMargin:"0px 0px -6% 0px"});
|
|
437
|
+
els.forEach((el,i)=>{el.classList.add("seen");el.style.setProperty("--i",Math.min(i,6));io.observe(el);});
|
|
438
|
+
}
|
|
439
|
+
// wire buttons that live inside freshly-rendered results
|
|
440
|
+
function wireResults(){
|
|
441
|
+
const rb=$("#resetbtn");if(rb)rb.addEventListener("click",resetAll);
|
|
442
|
+
const cb=$("#copybtn");
|
|
443
|
+
if(cb)cb.addEventListener("click",async()=>{
|
|
444
|
+
try{await navigator.clipboard.writeText(window.__cleaned||"");cb.classList.add("done");cb.textContent="Copied ✓";}
|
|
445
|
+
catch(e){cb.textContent="Copy failed — select the text above";}
|
|
446
|
+
});
|
|
447
|
+
revealPanels();
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/* reveal hidden characters in a string as labelled chips (before/after view) */
|
|
451
|
+
function hiddenLabel(cp){
|
|
452
|
+
if(cp===0x200B)return"ZWSP";if(cp===0x200C)return"ZWNJ";if(cp===0x200D)return"ZWJ";
|
|
453
|
+
if(cp===0x2060)return"WJ";if(cp===0xFEFF)return"BOM";
|
|
454
|
+
if(cp===0x200E)return"LRM";if(cp===0x200F)return"RLM";
|
|
455
|
+
if((cp>=0x202A&&cp<=0x202E)||(cp>=0x2066&&cp<=0x2069))return"BIDI";
|
|
456
|
+
if(cp===0x00AD)return"SHY";if(cp===0x034F)return"CGJ";if(cp===0x2800)return"BRAILLE";
|
|
457
|
+
if(cp>=0xE0000&&cp<=0xE007F)return"TAG";
|
|
458
|
+
if((cp>=0xFE00&&cp<=0xFE0F)||(cp>=0xE0100&&cp<=0xE01EF))return"VS";
|
|
459
|
+
if(cp===0x00A0)return"NBSP";
|
|
460
|
+
if((cp>=0x2000&&cp<=0x200A)||cp===0x202F||cp===0x205F||cp===0x3000)return"SPACE";
|
|
461
|
+
if((cp<0x20&&cp!==0x09&&cp!==0x0A&&cp!==0x0D)||(cp>=0x7F&&cp<=0x9F))return"CTRL";
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
function revealHidden(text){
|
|
465
|
+
let html="",count=0;
|
|
466
|
+
for(const ch of text){const cp=ch.codePointAt(0),label=hiddenLabel(cp);
|
|
467
|
+
if(label){count++;html+=`<span class="chip-hidden" title="U+${cp.toString(16).toUpperCase().padStart(4,"0")}">${label}</span>`;}
|
|
468
|
+
else html+=esc(ch);}
|
|
469
|
+
return {html,count};
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/* ---- plain-language translations (raw ids stay visible in small print) ---- */
|
|
473
|
+
const ICONS={
|
|
474
|
+
ghost:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 3l18 18M10.6 5.1A9.8 9.8 0 0 1 12 5c7 0 10.5 7 10.5 7a17 17 0 0 1-3 3.9M6.6 6.6A16.8 16.8 0 0 0 1.5 12S5 19 12 19a9.9 9.9 0 0 0 5.4-1.6"/></svg>',
|
|
475
|
+
text:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 7V5h16v2M9 20h6M12 5v15"/></svg>',
|
|
476
|
+
tag:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20.6 13.4 13.4 20.6a2 2 0 0 1-2.8 0L3 13V3h10l7.6 7.6a2 2 0 0 1 0 2.8Z"/><circle cx="7.5" cy="7.5" r="1.2"/></svg>',
|
|
477
|
+
badge:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="9" r="6"/><path d="m8.5 14.5-2 7 5.5-3 5.5 3-2-7"/></svg>'
|
|
478
|
+
};
|
|
479
|
+
const CATS={
|
|
480
|
+
zero_width:{t:"Invisible characters",icon:"ghost",b:"Characters hidden between the letters that you can't see. They're sometimes used to secretly mark or track text."},
|
|
481
|
+
unicode_tag_char:{t:"Hidden message characters",icon:"ghost",b:"Special invisible characters that can spell out a secret message inside ordinary-looking text."},
|
|
482
|
+
bidi_control:{t:"Text-direction controls",icon:"ghost",b:"Hidden marks that can silently change the order text is displayed in."},
|
|
483
|
+
exotic_space:{t:"Disguised spaces",icon:"ghost",b:"Spaces that look normal but are actually special characters — a common fingerprint of copy-pasted text."},
|
|
484
|
+
other_invisible:{t:"Hidden formatting marks",icon:"ghost",b:"Invisible characters that don't change what you see on screen."},
|
|
485
|
+
variation_selector:{t:"Invisible symbol modifiers",icon:"ghost",b:"Hidden marks that change how symbols display — and can also carry hidden data."},
|
|
486
|
+
control_char:{t:"Machine control characters",icon:"ghost",b:"Old machine-instruction characters that don't belong in normal text."},
|
|
487
|
+
byte_order_mark:{t:"Hidden file marker",icon:"ghost",b:"An invisible marker at the very start of the file."},
|
|
488
|
+
mixed_script_word:{t:"Look-alike letters",icon:"text",b:"Letters from a different alphabet disguised as normal ones — the word looks right but isn't."},
|
|
489
|
+
unicode_normalization:{t:"Non-standard letterforms",icon:"text",b:"Letters written in an unusual way that looks identical on screen."},
|
|
490
|
+
mixed_line_endings:{t:"Mixed line breaks",icon:"text",b:"The file mixes two styles of line breaks — often a sign it was assembled from different tools."},
|
|
491
|
+
markup_comment:{t:"Hidden comments",icon:"text",b:"Notes embedded in the file that don't show up when it's viewed normally."},
|
|
492
|
+
c2pa_manifest:{t:"Content credentials",icon:"badge",b:"An embedded record of where this file came from — often added by AI tools or cameras. Removing it removes that record, not the picture."},
|
|
493
|
+
png_metadata:{t:"Hidden image info",icon:"tag",b:"Extra information embedded in the image — software names, dates, descriptions — that isn't part of the picture itself."},
|
|
494
|
+
jpeg_metadata:{t:"Hidden image info",icon:"tag",b:"Extra information embedded in the image — software names, dates, descriptions — that isn't part of the picture itself."},
|
|
495
|
+
svg_metadata:{t:"Hidden image info",icon:"tag",b:"Extra information embedded in the graphic that isn't part of what it draws."},
|
|
496
|
+
file_metadata:{t:"Hidden file info",icon:"tag",b:"Extra information embedded in the file that isn't part of its visible content."}
|
|
497
|
+
};
|
|
498
|
+
const SEV={warning:"Worth removing",notice:"Unusual",info:"Good to know"};
|
|
499
|
+
const KINDS={text:"Text",source_code:"Code",binary:"Image / binary"};
|
|
500
|
+
|
|
501
|
+
async function analyzeOne(name,b64,mode){
|
|
502
|
+
const res=await fetch("/api/analyze",{method:"POST",headers:{"Content-Type":"application/json"},
|
|
503
|
+
body:JSON.stringify({name,data_base64:b64,mode,profile:$("#profile").value,force:$("#force").checked})});
|
|
504
|
+
const data=await res.json();
|
|
505
|
+
if(!res.ok)throw new Error(data.error||"Unknown error.");
|
|
506
|
+
return data;
|
|
507
|
+
}
|
|
508
|
+
runBtn.addEventListener("click",async()=>{
|
|
509
|
+
const mode=document.querySelector('input[name=mode]:checked').value;
|
|
510
|
+
runBtn.disabled=true;scanner.classList.add("busy");
|
|
511
|
+
const busyWord=mode==="clean"?"Cleaning":"Reading";
|
|
512
|
+
try{
|
|
513
|
+
if(source==="text"){
|
|
514
|
+
const txt=paste.value;
|
|
515
|
+
out.innerHTML=`<div class="panel"><div class="working">${busyWord} your text</div></div>`;
|
|
516
|
+
const bytes=new TextEncoder().encode(txt);
|
|
517
|
+
const data=await analyzeOne("pasted.txt",toBase64(bytes.buffer),mode);
|
|
518
|
+
renderSingle(data,mode,{name:"pasted text",originalText:txt});
|
|
519
|
+
}else{
|
|
520
|
+
const items=picked.slice();
|
|
521
|
+
out.innerHTML=`<div class="panel"><div class="working">${busyWord} ${items.length>1?items.length+" files":"your file"}</div></div>`;
|
|
522
|
+
const results=[];
|
|
523
|
+
for(const f of items){
|
|
524
|
+
const label=f.webkitRelativePath||f.name;
|
|
525
|
+
const buf=await f.arrayBuffer();
|
|
526
|
+
let originalText=null;
|
|
527
|
+
try{if(f.size<2_000_000)originalText=new TextDecoder("utf-8",{fatal:true}).decode(buf);}catch(e){}
|
|
528
|
+
const data=await analyzeOne(f.name,toBase64(buf),mode);
|
|
529
|
+
results.push({name:label,data,originalText});
|
|
530
|
+
}
|
|
531
|
+
if(results.length===1)renderSingle(results[0].data,mode,{name:results[0].name,originalText:results[0].originalText});
|
|
532
|
+
else renderBatch(results,mode);
|
|
533
|
+
}
|
|
534
|
+
}catch(err){out.innerHTML=heroCard("no","Something went wrong",esc(String(err&&err.message||err)),"");}
|
|
535
|
+
finally{runBtn.disabled=false;scanner.classList.remove("busy");}
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
const CHECK='<svg viewBox="0 0 24 24" fill="none" stroke="#07130d" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path class="checkdraw" d="M20 6 9 17l-5-5"/></svg>';
|
|
539
|
+
const SPARK='<svg viewBox="0 0 24 24" fill="none" stroke="#0a0c11" stroke-width="2.2" stroke-linecap="round"><path d="M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M18.4 5.6l-2.8 2.8M8.4 15.6l-2.8 2.8"/></svg>';
|
|
540
|
+
const STOP='<svg viewBox="0 0 24 24" fill="none" stroke="#140808" stroke-width="2.4" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5.5M12 16.4v.2"/></svg>';
|
|
541
|
+
|
|
542
|
+
function heroCard(kind,title,body,extra,kicker){
|
|
543
|
+
const icon=kind==="ok"?CHECK:kind==="warn"?SPARK:STOP;
|
|
544
|
+
return `<div class="panel"><div class="hero ${kind}"><div class="orb">${icon}</div><div>`+
|
|
545
|
+
(kicker?`<span class="kicker">${kicker}</span>`:"")+
|
|
546
|
+
`<h1>${title}</h1><p>${body}</p></div></div>${extra||""}</div>`;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function friendlyReason(raw){
|
|
550
|
+
const s=String(raw||"");
|
|
551
|
+
if(s.includes("could not be proven")||s.includes("No structural validator"))
|
|
552
|
+
return "This code is written in a language litmus can't double-check yet — and it never saves a change it can't verify. Your original is untouched.";
|
|
553
|
+
if(s.includes("provably changed"))
|
|
554
|
+
return "Removing the hidden characters would have changed how this code actually runs, so litmus stopped and kept your original exactly as it was.";
|
|
555
|
+
if(s.includes("no longer parses"))
|
|
556
|
+
return "The clean-up would have broken this file, so litmus refused and kept your original exactly as it was.";
|
|
557
|
+
return "The result couldn't be verified as safe, so litmus kept your original exactly as it was.";
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function findingCard(x,i){
|
|
561
|
+
const c=CATS[x.category]||{t:esc(String(x.category).replace(/_/g," ")),icon:"tag",b:esc(x.summary)};
|
|
562
|
+
let html=`<div class="finding" style="animation-delay:${80+i*60}ms"><div class="top">`+
|
|
563
|
+
`<span class="fico">${ICONS[c.icon]}</span><span class="ftitle">${c.t}</span>`+
|
|
564
|
+
`<span class="tag ${esc(x.severity)}">${SEV[x.severity]||esc(x.severity)}</span></div>`+
|
|
565
|
+
`<p class="fbody">${c.b}</p>`;
|
|
566
|
+
if(x.locations&&x.locations[0]&&x.locations[0].line)
|
|
567
|
+
html+=`<div class="floc">first seen at line ${x.locations[0].line}${x.count>1?" · "+x.count+" in total":""}</div>`;
|
|
568
|
+
if(x.details&&x.details.decoded_ascii_payload)
|
|
569
|
+
html+=`<div class="payload"><span>hidden message we decoded</span>${esc(x.details.decoded_ascii_payload)}</div>`;
|
|
570
|
+
// C2PA / content-credential verification verdict (feature 3)
|
|
571
|
+
if(x.category==="c2pa_manifest"){
|
|
572
|
+
const d=x.details||{},v=d.verification;
|
|
573
|
+
if(v==="performed"&&d.validity==="valid")
|
|
574
|
+
html+=`<div class="verify genuine">✓ signature verified — genuine credential</div>`;
|
|
575
|
+
else if(v==="performed"&&d.validity==="invalid")
|
|
576
|
+
html+=`<div class="verify invalid">⚠ signature invalid — this credential may be tampered</div>`;
|
|
577
|
+
else if(v==="performed")
|
|
578
|
+
html+=`<div class="verify genuine">✓ manifest read and verified</div>`;
|
|
579
|
+
else if(v==="failed")
|
|
580
|
+
html+=`<div class="verify unver">present, but its signature could not be verified</div>`;
|
|
581
|
+
else
|
|
582
|
+
html+=`<div class="verify unver">present, signature not verified <span style="opacity:.7">(install the c2pa extra to verify)</span></div>`;
|
|
583
|
+
}
|
|
584
|
+
// GPS location call-out (feature 2)
|
|
585
|
+
if(x.category==="photo_location"&&x.details&&x.details.gps_latitude!=null)
|
|
586
|
+
html+=`<div class="payload"><span>location this photo reveals</span>${esc(x.details.gps_latitude)}, ${esc(x.details.gps_longitude)}</div>`;
|
|
587
|
+
if(x.removable_by&&x.removable_by.length)
|
|
588
|
+
html+=`<div class="fix"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round"><path d="M20 6 9 17l-5-5"/></svg> litmus can remove this — use Clean</div>`;
|
|
589
|
+
html+=`<div class="floc rawid">${esc(x.category)} · ${esc(String(x.evidence_class).replace(/_/g," "))}</div></div>`;
|
|
590
|
+
return html;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function renderSingle(data,mode,ctx){
|
|
594
|
+
ctx=ctx||{};
|
|
595
|
+
const r=data.report,a=r.artifact,f=r.inspection.findings||[];
|
|
596
|
+
const t=r.transformation;
|
|
597
|
+
const isText=a.kind==="text"||a.kind==="source_code";
|
|
598
|
+
let html="";
|
|
599
|
+
|
|
600
|
+
/* 1 — verdict hero */
|
|
601
|
+
if(mode==="clean"&&t&&t.performed){
|
|
602
|
+
if(t.accepted&&data.output_base64){
|
|
603
|
+
const proven=r.validation&&r.validation.all_passed===true;
|
|
604
|
+
const cta=`<div class="heroCta"><a class="dl" href="data:application/octet-stream;base64,${data.output_base64}" download="${esc(data.output_name)}"><button>↓ Download your clean file</button></a><span class="ctaNote">Your original stays untouched on your computer.</span></div>`;
|
|
605
|
+
if(proven)
|
|
606
|
+
html+=heroCard("ok","Your file is clean","Litmus removed the hidden extras, then double-checked that everything you can see stayed exactly the same.",cta,"cleaned & verified");
|
|
607
|
+
else
|
|
608
|
+
html+=heroCard("warn","Cleaned — please review","The clean-up was applied at your request, but litmus couldn't verify the result is unchanged. Give it a look before using it.",cta,"cleaned, not verified");
|
|
609
|
+
}else if(t.accepted){
|
|
610
|
+
html+=heroCard("ok","Nothing to clean","This was already spotless — no hidden content to remove.","","all clear");
|
|
611
|
+
}else{
|
|
612
|
+
const details=`<div class="notes"><details class="tech"><summary>technical details</summary><div>${esc(t.rejected_reason||"")}</div></details></div>`;
|
|
613
|
+
html+=heroCard("no","Your file wasn't changed",friendlyReason(t.rejected_reason),details,"stopped for safety");
|
|
614
|
+
}
|
|
615
|
+
}else{
|
|
616
|
+
if(f.length===0)
|
|
617
|
+
html+=heroCard("ok","Nothing hidden here","Litmus checked for invisible characters, hidden info and content credentials, and found none it can detect.","","all clear");
|
|
618
|
+
else{
|
|
619
|
+
const worth=f.some(x=>x.severity==="warning");
|
|
620
|
+
html+=heroCard("warn",`Found <span class="num">${f.length}</span> hidden ${f.length===1?"thing":"things"}`,
|
|
621
|
+
(worth?"Some of it is worth removing. ":"Nothing alarming — just things you can't see. ")+
|
|
622
|
+
"Switch to <b>Clean</b> and litmus will strip out what it can without touching anything visible.","","check complete");
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/* 2 — reveal / before-after (feature 5): show WHERE the hidden characters are */
|
|
627
|
+
if(ctx.originalText){
|
|
628
|
+
const rev=revealHidden(ctx.originalText);
|
|
629
|
+
if(rev.count>0)
|
|
630
|
+
html+=`<div class="panel"><h2>Where the hidden characters are <span class="count">${rev.count}</span></h2>`+
|
|
631
|
+
`<div class="reveal"><p class="lead">Your text with every invisible character revealed as a red chip. The visible words are exactly as you'll keep them.</p>`+
|
|
632
|
+
`<pre>${rev.html}</pre></div></div>`;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/* 3 — findings */
|
|
636
|
+
if(f.length){
|
|
637
|
+
html+=`<div class="panel"><h2>What's hiding in there <span class="count">${f.length}</span></h2><div class="cards">`+
|
|
638
|
+
f.map(findingCard).join("")+`</div></div>`;
|
|
639
|
+
}else if(mode!=="clean"){
|
|
640
|
+
html+=`<div class="panel"><h2>What's hiding in there <span class="count">0</span></h2>`+
|
|
641
|
+
`<div class="allclear"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"><path d="M20 6 9 17l-5-5"/></svg>`+
|
|
642
|
+
`Nothing detectable — no invisible characters, no embedded info, no content credentials.</div></div>`;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/* 4 — cleaned text output with copy button (feature 6, paste mode) */
|
|
646
|
+
if(mode==="clean"&&isText&&t&&t.accepted&&data.output_base64){
|
|
647
|
+
const cleaned=new TextDecoder().decode(Uint8Array.from(atob(data.output_base64),c=>c.charCodeAt(0)));
|
|
648
|
+
window.__cleaned=cleaned;
|
|
649
|
+
html+=`<div class="panel"><h2>Your clean text</h2><div class="reveal"><pre id="cleanout">${esc(cleaned)}</pre></div>`+
|
|
650
|
+
`<div class="copywrap"><button class="copybtn" id="copybtn"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/></svg> Copy clean text</button></div></div>`;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/* 5 — at a glance */
|
|
654
|
+
html+=`<div class="panel" style="animation-delay:.12s"><div class="meta">`+
|
|
655
|
+
`<span><b>${esc(ctx.name||"file")}</b></span>`+
|
|
656
|
+
`<span>${KINDS[a.kind]||esc(a.kind)}${a.language?" · "+esc(a.language):""}</span>`+
|
|
657
|
+
`<span>${fmtBytes(a.size_bytes)}</span>`+
|
|
658
|
+
`<span class="fp" title="A unique fingerprint of this exact input's contents">fingerprint ${esc(a.sha256.slice(0,12))}…</span>`+
|
|
659
|
+
`</div></div>`;
|
|
660
|
+
|
|
661
|
+
/* 6 — fine print */
|
|
662
|
+
const p=r.inspection.provenance;
|
|
663
|
+
if(p&&p.notes&&p.notes.length)
|
|
664
|
+
html+=`<p class="footnote">litmus only checks what it can verify on your machine. A clean result means nothing hidden was found — not that a file is safe or that it proves who (or what) made it.</p>`;
|
|
665
|
+
|
|
666
|
+
html+=RESET_ROW;
|
|
667
|
+
out.innerHTML=html;
|
|
668
|
+
wireResults();
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/* multi-file batch view (feature 4) */
|
|
672
|
+
function renderBatch(results,mode){
|
|
673
|
+
let withFindings=0,cleaned=0;
|
|
674
|
+
const rows=results.map((it,i)=>{
|
|
675
|
+
const r=it.data.report,f=r.inspection.findings||[],t=r.transformation;
|
|
676
|
+
let dot="ok",stat="clean";
|
|
677
|
+
if(mode==="clean"&&t&&t.performed){
|
|
678
|
+
if(t.accepted&&it.data.output_base64){dot="ok";stat="cleaned";cleaned++;}
|
|
679
|
+
else if(t.accepted){dot="ok";stat="already clean";}
|
|
680
|
+
else{dot="no";stat="kept unchanged";}
|
|
681
|
+
}else{
|
|
682
|
+
if(f.length){dot=f.some(x=>x.severity==="warning")?"warn":"warn";stat=`${f.length} hidden`;withFindings++;}
|
|
683
|
+
else{dot="ok";stat="nothing hidden";}
|
|
684
|
+
}
|
|
685
|
+
if(f.length&&mode!=="clean")withFindings=withFindings; // counted above
|
|
686
|
+
const dl=(mode==="clean"&&it.data.output_base64)
|
|
687
|
+
? `<a class="mini" href="data:application/octet-stream;base64,${it.data.output_base64}" download="${esc(it.data.output_name||it.name)}"><button>↓ Download</button></a>`:"";
|
|
688
|
+
return `<div class="brow" style="animation-delay:${i*40}ms"><span class="dot ${dot}"></span>`+
|
|
689
|
+
`<span class="bname">${esc(it.name)}</span><span class="bstat">${esc(stat)}</span>${dl}</div>`;
|
|
690
|
+
}).join("");
|
|
691
|
+
|
|
692
|
+
const total=results.length;
|
|
693
|
+
const anyFindings=results.reduce((n,it)=>n+((it.data.report.inspection.findings||[]).length),0);
|
|
694
|
+
let html;
|
|
695
|
+
if(mode==="clean")
|
|
696
|
+
html=heroCard(cleaned?"ok":"ok",`Cleaned <span class="num">${cleaned}</span> of ${total} files`,
|
|
697
|
+
cleaned?"Download each cleaned file below. Every original stays untouched on your computer.":"None of these needed changes — they were already clean.","","batch complete");
|
|
698
|
+
else
|
|
699
|
+
html=heroCard(anyFindings?"warn":"ok",
|
|
700
|
+
anyFindings?`Found hidden content in <span class="num">${withFindings}</span> of ${total} files`:`All <span class="num">${total}</span> files look clean`,
|
|
701
|
+
anyFindings?"Here's the per-file breakdown. Switch to Clean to strip what litmus can.":"No invisible characters, embedded info or content credentials detected in any of them.","","batch complete");
|
|
702
|
+
html+=`<div class="panel"><h2>Per-file results <span class="count">${total}</span></h2><div class="batch">${rows}</div></div>`;
|
|
703
|
+
html+=RESET_ROW;
|
|
704
|
+
out.innerHTML=html;
|
|
705
|
+
wireResults();
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
setSource("file");
|
|
709
|
+
|
|
710
|
+
/* ambient depth: pointer-follow glow + subtle 3D tilt on the scanner card */
|
|
711
|
+
if(!REDUCED){
|
|
712
|
+
let raf=0,mx=innerWidth/2,my=-40;
|
|
713
|
+
addEventListener("pointermove",(e)=>{mx=e.clientX;my=e.clientY;
|
|
714
|
+
if(!raf)raf=requestAnimationFrame(()=>{raf=0;
|
|
715
|
+
document.body.style.setProperty("--mx",mx+"px");document.body.style.setProperty("--my",my+"px");});
|
|
716
|
+
},{passive:true});
|
|
717
|
+
const TILT=6;
|
|
718
|
+
scanner.addEventListener("pointermove",(e)=>{
|
|
719
|
+
const r=scanner.getBoundingClientRect();
|
|
720
|
+
const px=(e.clientX-r.left)/r.width-.5, py=(e.clientY-r.top)/r.height-.5;
|
|
721
|
+
scanner.style.transform=`perspective(1100px) rotateX(${(-py*TILT).toFixed(2)}deg) rotateY(${(px*TILT).toFixed(2)}deg)`;
|
|
722
|
+
});
|
|
723
|
+
scanner.addEventListener("pointerleave",()=>{scanner.style.transform="";});
|
|
724
|
+
}
|
|
725
|
+
</script>
|
|
726
|
+
</body>
|
|
727
|
+
</html>
|
|
728
|
+
""".replace("__PROFILE_OPTIONS__", _PROFILE_OPTIONS)
|