-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssl.jsx
executable file
·52 lines (42 loc) · 1.43 KB
/
ssl.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Check ssl expiry date for ssl certificates for Übersicht
*
* Version: 1.0
* Last Updated: 09/22/2020
*
* Created by Victor Savostin
*/
export const command = './ssl-checker.widget/ssl.sh';
// Refresh every X miliseconds
export const refreshFrequency = 1000 * 60 * 60 * 24;
// Base layout
export const className = {
top: '5px',
left: '5px',
color: 'rgba(255,255,255,0.6)',
fontFamily: 'Fira Code Retina',
fontWeight: 100,
fontSize: '12px'
}
const threshold = 14; // Days
// Render the widget
export const render = ({output, error}) => {
if (error) { return <div>Oops: <strong>{String(error)}</strong></div> }
const now = new Date().getTime();
const options = { year: 'numeric', month: 'numeric', day: 'numeric' };
const items = output.split('\n').filter(Boolean)
.reduce((out, item) => {
const [ domain, timestamp ] = item.split(' ');
const date = new Date(timestamp);
const days = Math.floor((date.getTime() - now) / 1000 / 60 / 60 / 24);
return [...out, { domain, date, days, warning: days < threshold }];
}, [])
.sort((a, b) => a.date > b.date);
return (
<table>
<tbody>
{items.map(({ domain, date, days, warning }) => <tr><td>{domain}<span style={{color: warning ? 'rgba(255,0,0,0.4)' : 'rgba(255,255,255,0.4)'}}> -> <strong>{days}</strong> ({date.toLocaleDateString('EN', options)})</span></td></tr>)}
</tbody>
</table>
)
}