kryptheon 0.1.68 → 0.1.70
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/LICENSE +38 -38
- package/bin/kryptheon.js +67 -5
- package/kryptheon-api.js +144 -4
- package/kryptheon-authz.js +26 -4
- package/kryptheon-baselines.js +232 -232
- package/kryptheon-changes.js +222 -222
- package/kryptheon-daily.js +192 -0
- package/kryptheon-dashboard-page.js +273 -2
- package/kryptheon-dashboard.html +28 -0
- package/kryptheon-dashboard.js +65 -3
- package/kryptheon-fonts-OFL.txt +98 -98
- package/kryptheon-probe-reporter.js +29 -29
- package/kryptheon-probe.config.js +37 -37
- package/kryptheon-project.js +600 -600
- package/kryptheon-questions.js +217 -0
- package/kryptheon-roles.js +4 -3
- package/kryptheon-selectors.js +301 -301
- package/kryptheon-store.js +334 -334
- package/kryptheon-testfiles.js +98 -98
- package/package.json +8 -2
- package/playwright.config.js +73 -73
|
@@ -518,6 +518,15 @@
|
|
|
518
518
|
|
|
519
519
|
function connectControls() {
|
|
520
520
|
var wrap = el('div', 'controls');
|
|
521
|
+
// What it does with the database, said before anything is pasted - the
|
|
522
|
+
// full list is shown again, for a yes, before every run.
|
|
523
|
+
var safe = el('ul', 'db-safe');
|
|
524
|
+
['It never reads your data - only the shape of your tables: names, columns, and who may see what.',
|
|
525
|
+
'It rebuilds that shape as a temporary copy, puts two made-up people in it, and attacks only the copy.',
|
|
526
|
+
'The copy is deleted when it finishes, or if it crashes. Your real tables are never changed.'].forEach(function (t) {
|
|
527
|
+
safe.appendChild(el('li', null, t));
|
|
528
|
+
});
|
|
529
|
+
wrap.appendChild(safe);
|
|
521
530
|
wrap.appendChild(dbInput);
|
|
522
531
|
wrap.appendChild(el('div', 'field-note', 'Kept only in this box. It goes to this dashboard on your machine, and to kryptheon-night for one run - never saved, never shown again.'));
|
|
523
532
|
loadHelp();
|
|
@@ -878,7 +887,10 @@
|
|
|
878
887
|
// The latest re-check, on the finding itself: still open, or newly
|
|
879
888
|
// broken by a fix for something else.
|
|
880
889
|
var latest = (f.attempts || [])[f.attempts ? f.attempts.length - 1 : 0];
|
|
881
|
-
|
|
890
|
+
// A FIXED re-check older than the check that found it again is not the answer any more.
|
|
891
|
+
var foundAgain = latest && latest.verdict === 'fixed' && f.when && String(f.when) > String(latest.at);
|
|
892
|
+
if (foundAgain) meta.appendChild(el('span', 'tag ember', 'FOUND AGAIN ' + ago(f.when) + ' (after a fix ' + ago(latest.at) + ')'));
|
|
893
|
+
else if (latest) meta.appendChild(el('span', 'tag ' + (VERDICT_TONE[latest.verdict] || ''), (VERDICT_WORDS[latest.verdict] || latest.verdict) + ' ' + ago(latest.at)));
|
|
882
894
|
if (newlyBroken.indexOf(f.id) !== -1) meta.appendChild(el('span', 'tag ember', 'NEWLY BROKEN'));
|
|
883
895
|
meta.appendChild(el('span', 'f-where', f.where));
|
|
884
896
|
left.appendChild(meta);
|
|
@@ -1285,8 +1297,60 @@
|
|
|
1285
1297
|
: 'Switch it on and this dashboard starts by itself every time you sign in to Windows, in a small window on the taskbar. Nothing opens - it just watches for changes. Switch it off here any time.'));
|
|
1286
1298
|
row.appendChild(text);
|
|
1287
1299
|
box.appendChild(row);
|
|
1300
|
+
renderDaily(box);
|
|
1288
1301
|
box.appendChild(el('div', 'keep-off', 'With the laptop off, nothing on it can run. The nightly database check is different: once set up in Start here, it runs inside your database itself, and its result is waiting the next time you open this page.'));
|
|
1289
1302
|
}
|
|
1303
|
+
// The daily check's controls: made once, so the page's refresh never undoes a time being typed.
|
|
1304
|
+
var dailyTime = el('input');
|
|
1305
|
+
dailyTime.type = 'time';
|
|
1306
|
+
dailyTime.setAttribute('aria-label', 'Time of the daily check');
|
|
1307
|
+
var dailyData = el('input');
|
|
1308
|
+
dailyData.type = 'checkbox';
|
|
1309
|
+
dailyData.setAttribute('aria-label', 'Include the checks that add test data');
|
|
1310
|
+
var dailyDirty = false;
|
|
1311
|
+
dailyTime.addEventListener('input', function () { dailyDirty = true; });
|
|
1312
|
+
function saveDaily(on, input) {
|
|
1313
|
+
post('/api/daily', { on: on, at: dailyTime.value || '09:00', addsData: dailyData.checked }).then(function (r) {
|
|
1314
|
+
dailyDirty = false;
|
|
1315
|
+
toast(on ? 'On: Check my app runs by itself every day at ' + r.daily.at + ' while your laptop is on' : 'Off: no daily check');
|
|
1316
|
+
return load();
|
|
1317
|
+
}).catch(function (err) { if (input) input.checked = !on; toast('Not saved: ' + err.message); });
|
|
1318
|
+
}
|
|
1319
|
+
function renderDaily(box) {
|
|
1320
|
+
var d = state.daily || { on: false, at: '09:00', addsData: false };
|
|
1321
|
+
if (!dailyDirty && document.activeElement !== dailyTime) dailyTime.value = d.at;
|
|
1322
|
+
if (document.activeElement !== dailyData) dailyData.checked = !!d.addsData;
|
|
1323
|
+
var row = el('div', 'keep-row');
|
|
1324
|
+
var sw = el('label', 'switch');
|
|
1325
|
+
var input = el('input');
|
|
1326
|
+
input.type = 'checkbox';
|
|
1327
|
+
input.checked = !!d.on;
|
|
1328
|
+
input.setAttribute('aria-label', 'Check my app every day');
|
|
1329
|
+
input.addEventListener('change', function () { saveDaily(input.checked, input); });
|
|
1330
|
+
sw.appendChild(input);
|
|
1331
|
+
sw.appendChild(el('span', 'track'));
|
|
1332
|
+
row.appendChild(sw);
|
|
1333
|
+
var text = el('div', 'keep-text');
|
|
1334
|
+
var title = el('b', null, 'Check my app every day ');
|
|
1335
|
+
title.appendChild(el('span', 'tag ' + (d.on ? 'leaf' : ''), d.on ? 'on' : 'off'));
|
|
1336
|
+
text.appendChild(title);
|
|
1337
|
+
text.appendChild(el('span', null, 'At this time, while your laptop is on and this dashboard runs, the same checks as Check my app run by themselves, and a note in the corner of your screen says what is new and what got fixed. Your app has to be running too.'));
|
|
1338
|
+
var when = el('div', 'setup-row');
|
|
1339
|
+
when.appendChild(el('span', null, 'Every day at'));
|
|
1340
|
+
when.appendChild(dailyTime);
|
|
1341
|
+
when.appendChild(button('sm', 'check', 'Save the time', function () { saveDaily(true, null); }));
|
|
1342
|
+
text.appendChild(when);
|
|
1343
|
+
var dl = el('label', 'tick setup-row');
|
|
1344
|
+
dl.appendChild(dailyData);
|
|
1345
|
+
dl.appendChild(document.createTextNode(' Include the checks that add test data (API, edge, reliability, roles) - only if this app is a test copy'));
|
|
1346
|
+
dailyData.onchange = function () { if (d.on) saveDaily(true, null); };
|
|
1347
|
+
text.appendChild(dl);
|
|
1348
|
+
if (d.next) text.appendChild(el('div', 'fallback', 'Next: ' + new Date(d.next).toLocaleString()));
|
|
1349
|
+
if (d.last && d.last.note) text.appendChild(el('div', 'fallback', 'Last (' + new Date(d.last.at).toLocaleString() + '): ' + d.last.note.title + ' - ' + d.last.note.body));
|
|
1350
|
+
row.appendChild(text);
|
|
1351
|
+
box.appendChild(row);
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1290
1354
|
function setAutostart(on, input) {
|
|
1291
1355
|
post('/api/autostart', { on: on }).then(function () {
|
|
1292
1356
|
toast(on ? 'On: it starts by itself when you sign in to Windows' : 'Off: it no longer starts by itself');
|
|
@@ -1489,6 +1553,212 @@
|
|
|
1489
1553
|
}
|
|
1490
1554
|
}
|
|
1491
1555
|
|
|
1556
|
+
/* --------------------------- who may do what, who signs in --------------------------- */
|
|
1557
|
+
|
|
1558
|
+
// Drawn only when asked for, and redrawn only after a save: the page's own refresh every few seconds must never
|
|
1559
|
+
// undo a tick the person has just made.
|
|
1560
|
+
var setupAdd = [];
|
|
1561
|
+
function setupStart() {
|
|
1562
|
+
var who = byId('whoBox');
|
|
1563
|
+
var sign = byId('signBox');
|
|
1564
|
+
if (!who || !sign || who.firstChild) return;
|
|
1565
|
+
who.appendChild(el('p', 'setup-note', 'Kryptheon reads from your code everything your app does, and which roles your code lets do it. Tick who SHOULD be able to do each thing - the roles check then tries every one as each role and tells you where your app does something else.'));
|
|
1566
|
+
who.appendChild(button('sun', 'list', 'Answer the questions', function () { loadSetup(); }));
|
|
1567
|
+
sign.appendChild(el('p', 'setup-note', 'To check your app as each kind of user, Kryptheon signs in as test accounts of your app. Add them here once.'));
|
|
1568
|
+
sign.appendChild(button('', 'list', 'Add test accounts', function () { loadSetup(); }));
|
|
1569
|
+
}
|
|
1570
|
+
function loadSetup() {
|
|
1571
|
+
return fetch('/api/setup' + (setupAdd.length ? '?add=' + encodeURIComponent(setupAdd.join(',')) : ''), { cache: 'no-store' })
|
|
1572
|
+
.then(function (res) { return res.json(); })
|
|
1573
|
+
.then(function (q) { renderWho(q); renderSign(q); })
|
|
1574
|
+
.catch(function (err) { toast('Could not read your app: ' + err.message); });
|
|
1575
|
+
}
|
|
1576
|
+
function renderWho(q) {
|
|
1577
|
+
var box = byId('whoBox');
|
|
1578
|
+
clear(box);
|
|
1579
|
+
if (!q.ran) { box.appendChild(el('p', 'setup-note', 'Could not read your code: ' + q.why)); return; }
|
|
1580
|
+
var open = q.rows.filter(function (r) { return r.everyone; }).length;
|
|
1581
|
+
box.appendChild(el('p', 'setup-note', q.policy.exists
|
|
1582
|
+
? 'Your answers are already saved. Change any tick and save again.'
|
|
1583
|
+
: 'Ticked = what your code allows today. ' + (open ? open + ' things have no role check in your code at all (orange): every signed-in person can do them. Untick the roles that should not.' : '')));
|
|
1584
|
+
var table = el('table', 'who');
|
|
1585
|
+
var head = el('tr');
|
|
1586
|
+
head.appendChild(el('th', null, 'What your app does'));
|
|
1587
|
+
q.roles.forEach(function (r) { head.appendChild(el('th', null, r)); });
|
|
1588
|
+
table.appendChild(head);
|
|
1589
|
+
var boxes = {};
|
|
1590
|
+
q.rows.forEach(function (row) {
|
|
1591
|
+
var tr = el('tr', row.everyone ? 'open-to-all' : null);
|
|
1592
|
+
var what = el('td', 'what');
|
|
1593
|
+
what.appendChild(document.createTextNode(row.label));
|
|
1594
|
+
what.appendChild(el('small', null, row.routes.join(' · ')));
|
|
1595
|
+
if (row.everyone) what.appendChild(el('span', 'warn', 'No role check in your code - anyone signed in can do this'));
|
|
1596
|
+
tr.appendChild(what);
|
|
1597
|
+
boxes[row.permission] = {};
|
|
1598
|
+
q.roles.forEach(function (r) {
|
|
1599
|
+
var td = el('td');
|
|
1600
|
+
var c = el('input');
|
|
1601
|
+
c.type = 'checkbox';
|
|
1602
|
+
c.checked = row.allowed.indexOf(r) >= 0;
|
|
1603
|
+
c.setAttribute('aria-label', r + ' may ' + row.label);
|
|
1604
|
+
boxes[row.permission][r] = c;
|
|
1605
|
+
td.appendChild(c);
|
|
1606
|
+
tr.appendChild(td);
|
|
1607
|
+
});
|
|
1608
|
+
table.appendChild(tr);
|
|
1609
|
+
});
|
|
1610
|
+
var tableWrap = el('div', 'who-wrap');
|
|
1611
|
+
tableWrap.appendChild(table);
|
|
1612
|
+
box.appendChild(tableWrap);
|
|
1613
|
+
|
|
1614
|
+
var addRow = el('div', 'setup-row');
|
|
1615
|
+
var addInput = el('input');
|
|
1616
|
+
addInput.type = 'text';
|
|
1617
|
+
addInput.placeholder = 'Another role your app has, like viewer';
|
|
1618
|
+
addInput.setAttribute('aria-label', 'Another role');
|
|
1619
|
+
addRow.appendChild(addInput);
|
|
1620
|
+
addRow.appendChild(button('sm', 'arrow', 'Add this role', function () {
|
|
1621
|
+
var v = addInput.value.trim();
|
|
1622
|
+
if (!/^[A-Za-z][A-Za-z0-9_ -]{0,39}$/.test(v)) { toast('A role is a short name, like viewer'); return; }
|
|
1623
|
+
if (setupAdd.indexOf(v) < 0) setupAdd.push(v);
|
|
1624
|
+
loadSetup();
|
|
1625
|
+
}));
|
|
1626
|
+
box.appendChild(addRow);
|
|
1627
|
+
|
|
1628
|
+
var tenantLabel = el('label', 'tick setup-row');
|
|
1629
|
+
var tenant = el('input');
|
|
1630
|
+
tenant.type = 'checkbox';
|
|
1631
|
+
tenant.checked = q.tenants.now === null ? q.tenants.suggested : q.tenants.now;
|
|
1632
|
+
tenantLabel.appendChild(tenant);
|
|
1633
|
+
tenantLabel.appendChild(document.createTextNode(' My app has more than one company or team, and one must never see or change another\'s records'));
|
|
1634
|
+
box.appendChild(tenantLabel);
|
|
1635
|
+
|
|
1636
|
+
var grants = {};
|
|
1637
|
+
if (q.grants.routes.length) {
|
|
1638
|
+
box.appendChild(el('p', 'setup-note', 'Your app gives people roles (' + q.grants.routes.join(', ') + '). Which roles may each role give?'));
|
|
1639
|
+
// by default only the roles the code lets use the route that gives roles may give any, and only roles below them
|
|
1640
|
+
var granters = [];
|
|
1641
|
+
q.rows.forEach(function (row) {
|
|
1642
|
+
if (row.routes.some(function (rt) { return q.grants.routes.indexOf(rt) >= 0; })) row.allowed.forEach(function (r) { if (granters.indexOf(r) < 0) granters.push(r); });
|
|
1643
|
+
});
|
|
1644
|
+
var gt = el('table', 'who');
|
|
1645
|
+
var gh = el('tr');
|
|
1646
|
+
gh.appendChild(el('th', null, 'This role may give'));
|
|
1647
|
+
q.roles.forEach(function (r) { gh.appendChild(el('th', null, r)); });
|
|
1648
|
+
gt.appendChild(gh);
|
|
1649
|
+
q.roles.forEach(function (giver, gi) {
|
|
1650
|
+
var tr = el('tr');
|
|
1651
|
+
tr.appendChild(el('td', null, giver));
|
|
1652
|
+
grants[giver] = {};
|
|
1653
|
+
q.roles.forEach(function (r, ri) {
|
|
1654
|
+
var td = el('td');
|
|
1655
|
+
var c = el('input');
|
|
1656
|
+
c.type = 'checkbox';
|
|
1657
|
+
var saved = q.grants.rules && q.grants.rules[giver];
|
|
1658
|
+
c.checked = saved ? saved.indexOf(r) >= 0 : granters.indexOf(giver) >= 0 && ri > gi;
|
|
1659
|
+
c.setAttribute('aria-label', giver + ' may give ' + r);
|
|
1660
|
+
grants[giver][r] = c;
|
|
1661
|
+
td.appendChild(c);
|
|
1662
|
+
tr.appendChild(td);
|
|
1663
|
+
});
|
|
1664
|
+
gt.appendChild(tr);
|
|
1665
|
+
});
|
|
1666
|
+
var gtWrap = el('div', 'who-wrap');
|
|
1667
|
+
gtWrap.appendChild(gt);
|
|
1668
|
+
box.appendChild(gtWrap);
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
var saveRow = el('div', 'setup-row');
|
|
1672
|
+
var replace = null;
|
|
1673
|
+
if (q.policy.exists) {
|
|
1674
|
+
var rl = el('label', 'tick');
|
|
1675
|
+
replace = el('input');
|
|
1676
|
+
replace.type = 'checkbox';
|
|
1677
|
+
rl.appendChild(replace);
|
|
1678
|
+
rl.appendChild(document.createTextNode(' Replace my permissions-policy.json with these answers'));
|
|
1679
|
+
saveRow.appendChild(rl);
|
|
1680
|
+
}
|
|
1681
|
+
saveRow.appendChild(button('sun', 'check', 'Save who may do what', function () {
|
|
1682
|
+
var allow = {};
|
|
1683
|
+
Object.keys(boxes).forEach(function (p) { allow[p] = q.roles.filter(function (r) { return boxes[p][r].checked; }); });
|
|
1684
|
+
var g = {};
|
|
1685
|
+
Object.keys(grants).forEach(function (giver) { g[giver] = q.roles.filter(function (r) { return grants[giver][r].checked; }); });
|
|
1686
|
+
post('/api/setup/policy', { roles: q.roles, allow: allow, tenants: tenant.checked, grants: g, replace: replace ? replace.checked : false })
|
|
1687
|
+
.then(function () { toast('Saved as permissions-policy.json. The roles check now judges your app by it.'); load(); loadSetup(); },
|
|
1688
|
+
function (err) { toast(err.message); });
|
|
1689
|
+
}));
|
|
1690
|
+
box.appendChild(saveRow);
|
|
1691
|
+
}
|
|
1692
|
+
function renderSign(q) {
|
|
1693
|
+
var box = byId('signBox');
|
|
1694
|
+
clear(box);
|
|
1695
|
+
if (!q.ran) return;
|
|
1696
|
+
var a = q.accounts;
|
|
1697
|
+
var inputs = [];
|
|
1698
|
+
if (a.mode === 'password') {
|
|
1699
|
+
box.appendChild(el('p', 'setup-note', 'Your app signs people in at ' + a.signIn + '. These are the accounts your project names - give each one\'s password (a test account, never a real customer\'s).'));
|
|
1700
|
+
if (!a.list.length) box.appendChild(el('p', 'setup-note', 'Your project names no account yet. Write your test accounts\' emails in your README, then come back.'));
|
|
1701
|
+
a.list.forEach(function (acc) {
|
|
1702
|
+
var row = el('div', 'setup-row');
|
|
1703
|
+
row.appendChild(el('span', null, acc.name));
|
|
1704
|
+
if (acc.set) { row.appendChild(el('span', 'fallback', 'saved in .env')); box.appendChild(row); return; }
|
|
1705
|
+
var pw = el('input');
|
|
1706
|
+
pw.type = 'password';
|
|
1707
|
+
pw.autocomplete = 'off';
|
|
1708
|
+
pw.placeholder = 'its password';
|
|
1709
|
+
pw.setAttribute('aria-label', 'Password of ' + acc.name);
|
|
1710
|
+
inputs.push({ envName: acc.envName, input: pw });
|
|
1711
|
+
row.appendChild(pw);
|
|
1712
|
+
box.appendChild(row);
|
|
1713
|
+
});
|
|
1714
|
+
} else {
|
|
1715
|
+
box.appendChild(el('p', 'setup-note', a.why ? 'Your app has no email-and-password sign-in, so Kryptheon signs in with a token per account (sent as Authorization: Bearer). Add one for each kind of user - at least two, of two different companies if your app has them.' : 'Accounts that sign in with a token:'));
|
|
1716
|
+
a.list.forEach(function (acc) {
|
|
1717
|
+
var row = el('div', 'setup-row');
|
|
1718
|
+
row.appendChild(el('span', null, acc.name));
|
|
1719
|
+
row.appendChild(el('span', 'fallback', 'saved in .env'));
|
|
1720
|
+
box.appendChild(row);
|
|
1721
|
+
});
|
|
1722
|
+
var addOne = function () {
|
|
1723
|
+
var row = el('div', 'setup-row');
|
|
1724
|
+
var name = el('input');
|
|
1725
|
+
name.type = 'text';
|
|
1726
|
+
name.placeholder = 'a name, like Acme owner';
|
|
1727
|
+
name.setAttribute('aria-label', 'Account name');
|
|
1728
|
+
var tok = el('input');
|
|
1729
|
+
tok.type = 'password';
|
|
1730
|
+
tok.autocomplete = 'off';
|
|
1731
|
+
tok.placeholder = 'its token';
|
|
1732
|
+
tok.setAttribute('aria-label', 'Token');
|
|
1733
|
+
inputs.push({ name: name, input: tok });
|
|
1734
|
+
row.appendChild(name);
|
|
1735
|
+
row.appendChild(tok);
|
|
1736
|
+
box.insertBefore(row, saveRow);
|
|
1737
|
+
};
|
|
1738
|
+
var more = button('sm', 'arrow', 'Another account', addOne);
|
|
1739
|
+
box.appendChild(more);
|
|
1740
|
+
}
|
|
1741
|
+
var saveRow = el('div', 'setup-row');
|
|
1742
|
+
saveRow.appendChild(button('sun', 'check', 'Save to .env', function () {
|
|
1743
|
+
var entries = inputs.filter(function (x) { return x.input.value.trim(); }).map(function (x) {
|
|
1744
|
+
return x.envName ? { envName: x.envName, value: x.input.value } : { label: x.name.value.trim(), value: x.input.value };
|
|
1745
|
+
});
|
|
1746
|
+
if (!entries.length) { toast('Nothing to save yet.'); return; }
|
|
1747
|
+
post('/api/setup/accounts', { entries: entries }).then(function (r) {
|
|
1748
|
+
inputs.forEach(function (x) { x.input.value = ''; });
|
|
1749
|
+
toast((r.written.length ? 'Added ' + r.written.length + ' to .env.' : 'Nothing new.') + (r.kept.length ? ' Already there, left as it is: ' + r.kept.length + '.' : ''));
|
|
1750
|
+
load();
|
|
1751
|
+
loadSetup();
|
|
1752
|
+
}, function (err) { toast(err.message); });
|
|
1753
|
+
}));
|
|
1754
|
+
box.appendChild(saveRow);
|
|
1755
|
+
box.appendChild(el('div', 'fallback', 'Added at the end of .env in your app\'s folder; nothing already in it is changed, and .env is added to .gitignore.'));
|
|
1756
|
+
if (a.mode !== 'password' && !a.list.length) {
|
|
1757
|
+
var first = box.querySelector('.btn.sm');
|
|
1758
|
+
if (first) first.click();
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1492
1762
|
/* ---------------------------------- account ---------------------------------- */
|
|
1493
1763
|
|
|
1494
1764
|
// Your account: the kryptheon.tech plan this dashboard is connected to, by the connect code from the account page.
|
|
@@ -1585,6 +1855,7 @@
|
|
|
1585
1855
|
renderTop();
|
|
1586
1856
|
renderApp();
|
|
1587
1857
|
renderAccount();
|
|
1858
|
+
setupStart();
|
|
1588
1859
|
renderNow();
|
|
1589
1860
|
renderSteps();
|
|
1590
1861
|
renderKeep();
|
|
@@ -1629,7 +1900,7 @@
|
|
|
1629
1900
|
// Not while something runs, not while a finding is open being read, not
|
|
1630
1901
|
// while a yes is being asked for, and not while someone is typing.
|
|
1631
1902
|
setInterval(function () {
|
|
1632
|
-
var typing = document.activeElement === dbInput || document.activeElement === recordInput || document.activeElement === connectInput;
|
|
1903
|
+
var typing = document.activeElement === dbInput || document.activeElement === recordInput || document.activeElement === connectInput || document.activeElement === dailyTime;
|
|
1633
1904
|
if (!busy && !openRow && !pending && !probeAsking && !paymentsAsking && !typing) load();
|
|
1634
1905
|
}, 5000);
|
|
1635
1906
|
})();
|
package/kryptheon-dashboard.html
CHANGED
|
@@ -294,6 +294,9 @@
|
|
|
294
294
|
.field { flex: 1; min-width: 220px; width: 100%; padding: 10px 12px; font: 13px/1.4 var(--mono); color: var(--on-light); background: var(--white); border: 1px solid var(--on-light); border-radius: 0; }
|
|
295
295
|
.field-row .btn { margin-top: 0; }
|
|
296
296
|
.field-note { font-size: 13px; line-height: 1.55; color: var(--muted); }
|
|
297
|
+
.db-safe { list-style: none; margin: 0 0 12px; padding: 12px 14px; border-left: 3px solid var(--orange); background: rgba(255, 77, 0, 0.05); font-size: 13.5px; line-height: 1.55; }
|
|
298
|
+
.db-safe li + li { margin-top: 4px; }
|
|
299
|
+
.db-safe li::before { content: "\2713"; color: var(--orange); font-weight: 700; margin-right: 8px; }
|
|
297
300
|
/* --- your app: which app this dashboard checks ----------------------------- */
|
|
298
301
|
.app-card { margin-bottom: 26px; }
|
|
299
302
|
#appBox { display: grid; gap: 10px; max-width: 760px; margin-top: 16px; }
|
|
@@ -346,6 +349,23 @@
|
|
|
346
349
|
.act-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
|
|
347
350
|
.act-row .act { margin-top: 0; }
|
|
348
351
|
.fallback { font: 10.5px/1.4 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
|
|
352
|
+
.who { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 12px; }
|
|
353
|
+
.who th { text-align: center; font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line, rgba(0,0,0,.12)); }
|
|
354
|
+
.who th:first-child, .who td:first-child { text-align: left; }
|
|
355
|
+
.who td { padding: 7px 4px; border-bottom: 1px solid var(--line, rgba(0,0,0,.08)); text-align: center; vertical-align: top; }
|
|
356
|
+
.who tr.open-to-all td:first-child { box-shadow: inset 3px 0 0 #e8590c; padding-left: 10px; }
|
|
357
|
+
.who .what small { display: block; font: 10.5px/1.4 var(--mono); color: var(--muted); }
|
|
358
|
+
.who .warn { display: block; font-size: 12px; color: #c2410c; margin-top: 2px; }
|
|
359
|
+
.setup-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
|
|
360
|
+
.setup-row input[type=text], .setup-row input[type=password] { flex: 1 1 260px; min-width: 0; max-width: 420px; padding: 9px 12px; border: 1px solid var(--line); background: var(--white); font: inherit; font-size: 14px; }
|
|
361
|
+
.setup-row input[type=text]:focus, .setup-row input[type=password]:focus { outline: 2px solid var(--orange); outline-offset: 1px; }
|
|
362
|
+
.setup-note { font-size: 13.5px; line-height: 1.5; margin-top: 8px; }
|
|
363
|
+
.who-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
|
|
364
|
+
.who-wrap .who { min-width: 560px; }
|
|
365
|
+
input[type=checkbox] { accent-color: var(--orange); }
|
|
366
|
+
.who input[type=checkbox], #whoBox input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
|
|
367
|
+
.who tbody tr:hover td { background: rgba(255, 77, 0, 0.045); }
|
|
368
|
+
.who th { font: 600 11px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
|
|
349
369
|
.tag.when { color: var(--on-light); border-style: dotted; }
|
|
350
370
|
.f-quick { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 0 8px 16px 20px; margin-top: -6px; }
|
|
351
371
|
.keep-row { display: flex; align-items: flex-start; gap: 16px; padding: 18px 8px 18px 0; }
|
|
@@ -426,6 +446,14 @@
|
|
|
426
446
|
<div class="card-head"><div><h3>Start here</h3><div class="c-sub">Do these in order. A step is done only once it has actually run.</div></div></div>
|
|
427
447
|
<div class="steps" id="steps"></div>
|
|
428
448
|
</div>
|
|
449
|
+
<div class="card gap" id="whoCard">
|
|
450
|
+
<div class="card-head"><div><h3>Who may do what</h3><div class="c-sub">A few questions instead of a file - the roles check judges your app by your answers</div></div></div>
|
|
451
|
+
<div id="whoBox"></div>
|
|
452
|
+
</div>
|
|
453
|
+
<div class="card gap" id="signCard">
|
|
454
|
+
<div class="card-head"><div><h3>Who Kryptheon signs in as</h3><div class="c-sub">Test accounts of your app - kept in .env on this computer, never sent anywhere</div></div></div>
|
|
455
|
+
<div id="signBox"></div>
|
|
456
|
+
</div>
|
|
429
457
|
<div class="card gap" id="keepCard">
|
|
430
458
|
<div class="card-head"><div><h3>Keep it running</h3><div class="c-sub">So it is watching whenever your laptop is on - without opening anything</div></div></div>
|
|
431
459
|
<div class="keep" id="keep"></div>
|
package/kryptheon-dashboard.js
CHANGED
|
@@ -278,6 +278,8 @@ const PROBE_WORDS = { reliability: { marker: false }, get roles() { return Objec
|
|
|
278
278
|
const PROBE_CHECKS = ['edge', 'reliability', 'roles'];
|
|
279
279
|
// The roles check is loaded when it is first needed.
|
|
280
280
|
const rolesModule = () => require('./kryptheon-roles.js');
|
|
281
|
+
const questionsModule = () => require('./kryptheon-questions.js');
|
|
282
|
+
const dailyModule = () => require('./kryptheon-daily.js');
|
|
281
283
|
|
|
282
284
|
// "Check my app": one press on the page runs every check that can run from
|
|
283
285
|
// here, one after another - asked for by the owner: a person who builds with
|
|
@@ -320,8 +322,16 @@ function everythingPlan(checks, app, addresses) {
|
|
|
320
322
|
if ((id === 'frontend' || id === 'backend' || id === 'api') && app.webOnly) { skip(id, 'your app\'s code is not on this computer - open the dashboard from your app\'s folder'); continue; }
|
|
321
323
|
if (id === 'regression' && !c.runnable) { skip(id, 'no recordings yet - record one of your flows first'); continue; }
|
|
322
324
|
if (id === 'api') {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
+
// A saved address that is not this computer (a live app): the API step still runs, READ-ONLY - GET only, no
|
|
326
|
+
// value kept - and says so in its name. Everything that writes stays for an app on this computer.
|
|
327
|
+
const saved = !origin && /^https?:\/\//i.test(String(app.address || '')) ? String(app.address).replace(/\/+$/, '') : null;
|
|
328
|
+
if (!origin && !saved) { skip(id, 'it runs on your app on this computer - start it (for example npm run dev) and save its address, like http://localhost:3000, in Your app. A live address (https://...) saved there is only read, never written to'); continue; }
|
|
329
|
+
if (saved) {
|
|
330
|
+
step.origin = saved;
|
|
331
|
+
step.readOnly = true;
|
|
332
|
+
step.addsData = false;
|
|
333
|
+
step.label = 'API on your live app (read-only)';
|
|
334
|
+
} else step.origin = origin;
|
|
325
335
|
}
|
|
326
336
|
if (id === 'edge' || id === 'reliability' || id === 'roles') {
|
|
327
337
|
if (!c.asks) { skip(id, 'no recordings yet - record one of your flows first'); continue; }
|
|
@@ -742,7 +752,11 @@ function buildState(root, env) {
|
|
|
742
752
|
|
|
743
753
|
// The API run: what got through on the running app, each with its proof.
|
|
744
754
|
if (apiLast && config.enabled.api) {
|
|
755
|
+
// a re-check that said FIXED after this run: that finding is closed until a later run finds it again
|
|
756
|
+
const apiFixed = new Set(readHistory(paths.fixes, 500).filter((a) => a && a.check === 'api' && a.verdict === 'fixed' && a.at > (apiLast.checkedAt || ''))
|
|
757
|
+
.map((a) => a.where + '|' + a.headline));
|
|
745
758
|
for (const f of apiLast.findings || []) {
|
|
759
|
+
if (apiFixed.has(f.where + '|' + f.headline)) continue;
|
|
746
760
|
findings.push({
|
|
747
761
|
check: 'api',
|
|
748
762
|
severity: f.severity,
|
|
@@ -1043,6 +1057,8 @@ function buildState(root, env) {
|
|
|
1043
1057
|
verification: { state: 'not verified', why: 'Kryptheon Verified is not built yet. No version of this project has been verified.' },
|
|
1044
1058
|
// Whether this dashboard starts by itself when the person signs in.
|
|
1045
1059
|
autostart: (() => { const s = autostart.status(root, env); return { available: s.available, on: s.on, why: s.why || '' }; })(),
|
|
1060
|
+
// the daily check: its time, the next run and what the last one found
|
|
1061
|
+
daily: dailyModule().stateOf(paths),
|
|
1046
1062
|
};
|
|
1047
1063
|
}
|
|
1048
1064
|
|
|
@@ -1294,6 +1310,20 @@ function createServer(root, options) {
|
|
|
1294
1310
|
const page = fs.readFileSync(path.join(__dirname, 'kryptheon-dashboard.html'), 'utf8');
|
|
1295
1311
|
let port = 0;
|
|
1296
1312
|
const jobs = createJobs();
|
|
1313
|
+
// The daily check: "Check my app" by itself once a day while this dashboard runs (kryptheon-daily.js). Its clock
|
|
1314
|
+
// looks once a minute; one run at a time is the jobs' own rule, so it never starts beside a run the person began.
|
|
1315
|
+
let dailyTimer = null;
|
|
1316
|
+
if (typeof opts.everything === 'function' && opts.daily !== false) {
|
|
1317
|
+
const clock = dailyModule().createDaily({
|
|
1318
|
+
paths: store.pathsFor(root, env), jobs, now: opts.now,
|
|
1319
|
+
plan: () => buildState(root, env).everything,
|
|
1320
|
+
findings: () => buildState(root, env).findings || [],
|
|
1321
|
+
everything: (steps, say, control, info) => opts.everything(steps, say, control, info),
|
|
1322
|
+
notify: opts.notify || dailyModule().notifyDesktop,
|
|
1323
|
+
});
|
|
1324
|
+
dailyTimer = setInterval(() => { try { clock.tick(); } catch (err) { /* the next minute tries again */ } }, opts.dailyEveryMs || 60000);
|
|
1325
|
+
if (dailyTimer.unref) dailyTimer.unref();
|
|
1326
|
+
}
|
|
1297
1327
|
|
|
1298
1328
|
const allowedHosts = () => new Set(['127.0.0.1:' + port, 'localhost:' + port]);
|
|
1299
1329
|
const send = (res, code, type, body) => {
|
|
@@ -1340,6 +1370,16 @@ function createServer(root, options) {
|
|
|
1340
1370
|
// What the page is sent, for this computer's account: fix prompts past what the plan opens never leave here.
|
|
1341
1371
|
return json(res, 200, account.lock(buildState(root, env), root, env));
|
|
1342
1372
|
}
|
|
1373
|
+
// The plain questions that take the place of permissions-policy.json and the passwords in .env. Read from the
|
|
1374
|
+
// code each time it is asked; nothing in it is a secret (accounts say only whether theirs is set).
|
|
1375
|
+
if (req.method === 'GET' && url.pathname === '/api/setup') {
|
|
1376
|
+
const extra = String(url.searchParams.get('add') || '').split(',').map((x) => x.trim()).filter(Boolean).slice(0, 12);
|
|
1377
|
+
try {
|
|
1378
|
+
return json(res, 200, questionsModule().questionsOf(root, { env, extraRoles: extra }));
|
|
1379
|
+
} catch (err) {
|
|
1380
|
+
return json(res, 500, { ran: false, why: 'the code could not be read for the questions' });
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1343
1383
|
if (req.method === 'GET' && url.pathname === '/api/job') {
|
|
1344
1384
|
return json(res, 200, { job: jobs.get() });
|
|
1345
1385
|
}
|
|
@@ -1357,6 +1397,26 @@ function createServer(root, options) {
|
|
|
1357
1397
|
} catch (err) {
|
|
1358
1398
|
return json(res, 400, { ok: false, why: 'not JSON' });
|
|
1359
1399
|
}
|
|
1400
|
+
if (url.pathname === '/api/daily') {
|
|
1401
|
+
const r = dailyModule().set(store.pathsFor(root, env), input);
|
|
1402
|
+
return json(res, r.ok ? 200 : 400, r.ok ? { ok: true, daily: dailyModule().stateOf(store.pathsFor(root, env)) } : r);
|
|
1403
|
+
}
|
|
1404
|
+
if (url.pathname === '/api/setup/policy') {
|
|
1405
|
+
const q = questionsModule().questionsOf(root, { env, extraRoles: Array.isArray(input.roles) ? input.roles.slice(0, 20).map(String) : [] });
|
|
1406
|
+
if (!q.ran) return json(res, 400, { ok: false, why: q.why });
|
|
1407
|
+
const made = questionsModule().policyFrom(q, input);
|
|
1408
|
+
if (!made.ok) return json(res, 400, made);
|
|
1409
|
+
const r = questionsModule().savePolicy(root, made.policy, input.replace === true);
|
|
1410
|
+
return json(res, r.ok ? 200 : 409, { ok: r.ok, why: r.why, roles: Object.keys(made.policy.roles) });
|
|
1411
|
+
}
|
|
1412
|
+
if (url.pathname === '/api/setup/accounts') {
|
|
1413
|
+
const qm = questionsModule();
|
|
1414
|
+
const entries = (Array.isArray(input.entries) ? input.entries : []).slice(0, 40)
|
|
1415
|
+
.map((e) => ({ envName: e && e.envName ? String(e.envName) : qm.tokenEnvName(e && e.label), value: e && e.value }));
|
|
1416
|
+
if (entries.some((e) => !e.envName)) return json(res, 400, { ok: false, why: 'give each token a name, like Northstar owner' });
|
|
1417
|
+
const r = qm.saveAccounts(root, entries);
|
|
1418
|
+
return json(res, r.ok ? 200 : 400, r);
|
|
1419
|
+
}
|
|
1360
1420
|
if (url.pathname === '/api/check') {
|
|
1361
1421
|
const r = setCheck(store.pathsFor(root, env), String(input.id || ''), input.on);
|
|
1362
1422
|
return json(res, r.ok ? 200 : 400, r);
|
|
@@ -1445,7 +1505,9 @@ function createServer(root, options) {
|
|
|
1445
1505
|
.map((s) => ({ id: s.id, label: s.label, why: plan.live.join(', ') + ' is not this computer - tick that it is your own test copy to include this' }))
|
|
1446
1506
|
.concat(plan.skipped);
|
|
1447
1507
|
if (!steps.length) return json(res, 400, { ok: false, why: skipped[0].why });
|
|
1448
|
-
const command = steps.map((s) => (s.id === 'api' ? RUN_COMMAND.api.replace('http://localhost:3000', s.origin) : RUN_COMMAND[s.id])).join(', then ');
|
|
1508
|
+
const command = steps.map((s) => (s.id === 'api' ? (s.readOnly ? 'npx kryptheon api --live --origin ' + s.origin + ' --yes' : RUN_COMMAND.api.replace('http://localhost:3000', s.origin)) : RUN_COMMAND[s.id])).join(', then ');
|
|
1509
|
+
// the person's own full run: today's daily one is not needed after it
|
|
1510
|
+
if (!jobs.busy()) dailyModule().markFullRun(store.pathsFor(root, env));
|
|
1449
1511
|
return begin('everything', 'Checking your app', command,
|
|
1450
1512
|
(say, control) => opts.everything(steps, say, control, { origin: plan.origin, confirmed: ticked ? plan.live : [], skipped: skipped }));
|
|
1451
1513
|
}
|