kryptheon 0.1.72 → 0.1.74

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/bin/kryptheon.js CHANGED
@@ -3471,6 +3471,23 @@ function openInBrowser(url) {
3471
3471
  }
3472
3472
  }
3473
3473
 
3474
+ /**
3475
+ * The dashboard's page, opened in the browser. Started at sign-in by Start with
3476
+ * Windows (KRYPTHEON_OPEN_DAILY), only at the first sign-in of the day; every
3477
+ * other start opens it as before.
3478
+ */
3479
+ function openDashboardPage(address) {
3480
+ if (process.env.KRYPTHEON_OPEN_DAILY && !process.env.KRYPTHEON_NO_OPEN) {
3481
+ try {
3482
+ const dir = require(path.join(PACKAGE_DIR, 'kryptheon-store.js')).pathsFor(USER_DIR).dir;
3483
+ if (!require(path.join(PACKAGE_DIR, 'kryptheon-autostart.js')).firstOpenToday(dir)) return false;
3484
+ } catch (err) {
3485
+ /* opened as any other start */
3486
+ }
3487
+ }
3488
+ return openInBrowser(address);
3489
+ }
3490
+
3474
3491
  /**
3475
3492
  * The person's own folder picker, on this computer: the one Windows or the
3476
3493
  * Mac shows everywhere else. Resolves to the folder, or null when it was
@@ -3810,7 +3827,7 @@ async function dashboardCommand() {
3810
3827
  }
3811
3828
  if (running && running.version === mine) {
3812
3829
  const address = 'http://127.0.0.1:' + DASHBOARD_PORT + '/';
3813
- const shown = openInBrowser(address);
3830
+ const shown = openDashboardPage(address);
3814
3831
  console.log('');
3815
3832
  console.log(' The Kryptheon dashboard for ' + path.basename(USER_DIR) + ' is already running:');
3816
3833
  console.log('');
@@ -3822,6 +3839,8 @@ async function dashboardCommand() {
3822
3839
  }
3823
3840
  const opened = openStore();
3824
3841
  if (!opened) return 1;
3842
+ // A Start with Windows file from an older version, which never opened the page, gets today's text.
3843
+ try { require(path.join(PACKAGE_DIR, 'kryptheon-autostart.js')).refresh(USER_DIR); } catch (err) { /* left as it was */ }
3825
3844
  const dash = require(path.join(PACKAGE_DIR, 'kryptheon-dashboard.js'));
3826
3845
  const app = dash.createServer(USER_DIR, {
3827
3846
  run: (id, say) => runFromDashboard(id, opened, say),
@@ -3844,7 +3863,7 @@ async function dashboardCommand() {
3844
3863
  port = await app.listen(0);
3845
3864
  }
3846
3865
  const address = 'http://127.0.0.1:' + port + '/';
3847
- const shown = openInBrowser(address);
3866
+ const shown = openDashboardPage(address);
3848
3867
  console.log('');
3849
3868
  console.log(' Kryptheon dashboard for ' + path.basename(USER_DIR) + ':');
3850
3869
  console.log('');
@@ -116,7 +116,9 @@ async function refresh(root, env) {
116
116
  return { ok: true, account: summary(read(root, env)) };
117
117
  }
118
118
  if (r.status !== 200) return { ok: false, why: (r.body && r.body.error) || 'kryptheon.tech did not answer', account: summary(a) };
119
- return { ok: true, account: summary(keep(root, env, a.code, r.body, a.unlocked)) };
119
+ const kept = keep(root, env, a.code, r.body, a.unlocked);
120
+ if (a.setupReported) write(root, env, Object.assign({}, kept, { setupReported: a.setupReported }));
121
+ return { ok: true, account: summary(read(root, env)) };
120
122
  }
121
123
 
122
124
  /** Opens one finding's fix prompt: free on Pro and Studio; on Starter, one of the five this month. */
@@ -141,6 +143,23 @@ async function unlock(root, env, findingId) {
141
143
  return { ok: true, account: summary(read(root, env)) };
142
144
  }
143
145
 
146
+ /**
147
+ * The set-up is finished - the guide on this dashboard reached its end. Said to kryptheon.tech once, so the account
148
+ * page there opens instead of the first-time journey. Kept as said only when kryptheon.tech answers that it recorded
149
+ * it (setupRecorded); an older kryptheon.tech that does not know the word is asked again next time.
150
+ */
151
+ async function setupDone(root, env) {
152
+ const a = read(root, env);
153
+ if (!a || !a.code) return { ok: false, status: 409, why: 'connect your Kryptheon account first' };
154
+ if (a.setupReported) return { ok: true, already: true, account: summary(a) };
155
+ const r = await ask(env, a.code, { setupDone: true });
156
+ if (r.status === 0) return { ok: false, status: 503, why: r.why };
157
+ if (r.status !== 200) return { ok: false, status: r.status, why: (r.body && r.body.error) || 'kryptheon.tech did not answer' };
158
+ if (!r.body.setupRecorded) return { ok: true, recorded: false, account: summary(a) };
159
+ write(root, env, Object.assign({}, a, { setupReported: new Date().toISOString() }));
160
+ return { ok: true, recorded: true, account: summary(read(root, env)) };
161
+ }
162
+
144
163
  function disconnect(root, env) {
145
164
  forget(root, env);
146
165
  return { ok: true, account: summary(null) };
@@ -153,7 +172,7 @@ function summary(a) {
153
172
  }
154
173
  return {
155
174
  connected: true, app: a.app, plan: a.plan, clientReport: !!a.clientReport, prompts: a.prompts, month: a.month,
156
- checkedAt: a.checkedAt, accountPage: ACCOUNT_PAGE, pricing: PRICING,
175
+ checkedAt: a.checkedAt, accountPage: ACCOUNT_PAGE, pricing: PRICING, setupReported: !!a.setupReported,
157
176
  };
158
177
  }
159
178
 
@@ -180,4 +199,4 @@ function lock(state, root, env) {
180
199
  return out;
181
200
  }
182
201
 
183
- module.exports = { connect, refresh, unlock, disconnect, lock, summary, fingerprintOf, read, ENTITLEMENT, CODE };
202
+ module.exports = { connect, refresh, unlock, setupDone, disconnect, lock, summary, fingerprintOf, read, ENTITLEMENT, CODE };
@@ -9,7 +9,9 @@
9
9
  * the folder itself. The file says what it is and runs one thing:
10
10
  * npx kryptheon@latest dashboard, in a minimized window on the taskbar. A
11
11
  * window, not a hidden process: something that starts by itself at sign-in
12
- * should be seen, and closing it stops it.
12
+ * should be seen, and closing it stops it. The page itself opens in the
13
+ * browser once a day, at the first sign-in of the day - asked for by the
14
+ * owner, so the dashboard is in front of the person daily without a command.
13
15
  *
14
16
  * Only the file this module wrote is ever removed: it is recognised by its
15
17
  * first lines, never by its name alone.
@@ -77,10 +79,12 @@ function script(root) {
77
79
  ':run',
78
80
  'title Kryptheon dashboard - ' + name,
79
81
  'rem npx starts the command "kryptheon": never look for it in the current folder,',
80
- 'rem where a Kryptheon.cmd launcher may sit, and the browser is not opened at sign-in.',
82
+ 'rem where a Kryptheon.cmd launcher may sit. The dashboard opens in the browser',
83
+ 'rem once a day - at the first sign-in of the day - and not again that day.',
81
84
  'set NoDefaultCurrentDirectoryInExePath=1',
82
85
  'set KRYPTHEON_LAUNCHER=1',
83
- 'set KRYPTHEON_NO_OPEN=1',
86
+ 'set KRYPTHEON_NO_OPEN=',
87
+ 'set KRYPTHEON_OPEN_DAILY=1',
84
88
  'cd /d ' + quoted + ' || goto gone',
85
89
  'echo.',
86
90
  'echo Kryptheon dashboard, started when you signed in, for:',
@@ -145,4 +149,43 @@ function setAutostart(root, on, env, platform) {
145
149
  return Object.assign({ ok: true }, status(root, env, platform));
146
150
  }
147
151
 
148
- module.exports = { startupDir, fileFor, script, status, setAutostart, MARK };
152
+ /**
153
+ * A file this module wrote with an older version's text - one that never
154
+ * opened the browser - is written again with today's. Only a file that carries
155
+ * the mark, and only when it is on; anything else is left as it is.
156
+ */
157
+ function refresh(root, env, platform) {
158
+ const s = status(root, env, platform);
159
+ if (!s.on) return { ok: true, changed: false };
160
+ try {
161
+ const now = fs.readFileSync(s.file, 'utf8');
162
+ const want = script(root);
163
+ if (now === want) return { ok: true, changed: false };
164
+ fs.writeFileSync(s.file, want, 'utf8');
165
+ return { ok: true, changed: true };
166
+ } catch (err) {
167
+ return { ok: false, changed: false, why: err.message };
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Whether the dashboard started at sign-in should open the browser now: yes
173
+ * the first time on a day, no after that. The day is kept in the project's own
174
+ * Kryptheon folder. Asked only when started with KRYPTHEON_OPEN_DAILY.
175
+ */
176
+ function firstOpenToday(dir, now) {
177
+ const day = (now || new Date()).toLocaleDateString('en-CA');
178
+ const file = path.join(dir, 'opened-on.txt');
179
+ let last = '';
180
+ try { last = fs.readFileSync(file, 'utf8').trim(); } catch (err) { last = ''; }
181
+ if (last === day) return false;
182
+ try {
183
+ fs.mkdirSync(dir, { recursive: true });
184
+ fs.writeFileSync(file, day + '\n', 'utf8');
185
+ } catch (err) {
186
+ /* opened anyway: a page shown twice is better than never */
187
+ }
188
+ return true;
189
+ }
190
+
191
+ module.exports = { startupDir, fileFor, script, status, setAutostart, refresh, firstOpenToday, MARK };
@@ -53,6 +53,7 @@
53
53
  terminal: 'M4 5h16v14H4zM7 9l3 3-3 3M13 15h4',
54
54
  folder: 'M3 6h6l2 2h10v11H3z',
55
55
  dot: 'M12 12h.01',
56
+ up: 'M12 19V5m-6 6l6-6 6 6',
56
57
  };
57
58
  function icon(name, size) {
58
59
  var s = svgEl('svg', {
@@ -104,6 +105,26 @@
104
105
  busy = on;
105
106
  Array.prototype.forEach.call(document.querySelectorAll('[data-action]'), function (b) { b.disabled = on; });
106
107
  if (state) renderLaunch();
108
+ tell();
109
+ }
110
+ // The set-up is finished (the guide's end): kryptheon.tech is told once, so its account page opens instead of the
111
+ // first-time journey. Asked again on a later load while it has not been recorded there.
112
+ var setupSaid = false;
113
+ function sayDone() {
114
+ if (setupSaid || !state || !state.account || !state.account.connected || state.account.setupReported) return;
115
+ setupSaid = true;
116
+ post('/api/account/setup-done', {}).then(function () { load(); }, function () { setupSaid = false; });
117
+ }
118
+ window.addEventListener('kryptheon:setup-done', sayDone);
119
+ function guideFinished() {
120
+ try { if (JSON.parse(window.localStorage.getItem('kryptheon.guide.v1') || '{}').done) return true; } catch (e) { /* read below */ }
121
+ // set up before the guide existed: the address saved and a flow recorded is a finished set-up too
122
+ var rec = (state && state.steps || []).filter(function (s) { return s.action && s.action.kind === 'record'; })[0];
123
+ return !!(state && state.app && state.app.address && rec && rec.count > 0);
124
+ }
125
+ // The guide (kryptheon-tour.js) follows the page: what the server last said, and whether something runs.
126
+ function tell() {
127
+ try { window.dispatchEvent(new CustomEvent('kryptheon:state', { detail: { state: state, busy: busy } })); } catch (e) { /* no guide then */ }
107
128
  }
108
129
  // The clipboard, and when a browser refuses it, the older way: the text
109
130
  // put in a box off the screen, selected and copied.
@@ -181,6 +202,14 @@
181
202
  connectInput.setAttribute('aria-label', 'Your connect code');
182
203
  connectInput.autocomplete = 'off';
183
204
  connectInput.spellcheck = false;
205
+ // Handed over by kryptheon.tech's "Open my dashboard" (#connect=kd_...): put in the box, never sent by itself -
206
+ // the person presses Connect, so a link from anywhere else cannot tie this dashboard to someone else's account.
207
+ // Taken out of the address at once; the guide then starts at Connect.
208
+ var handed = /^#connect=(kd_[A-Za-z0-9_-]{20,100})$/.exec(window.location.hash || '');
209
+ if (handed) {
210
+ connectInput.value = handed[1];
211
+ try { window.history.replaceState(null, '', '#tour-connect'); } catch (e) { window.location.hash = 'tour-connect'; }
212
+ }
184
213
 
185
214
  /* ------------------------------------ jobs ------------------------------------ */
186
215
 
@@ -329,6 +358,7 @@
329
358
  { id: 'fixes', title: 'Proven fixes', icon: 'wrench' },
330
359
  { id: 'checks', title: 'Checks', icon: 'toggle' },
331
360
  { id: 'runs', title: 'Runs', icon: 'play' },
361
+ { id: 'plan', title: 'Upgrade your plan', icon: 'up' },
332
362
  { id: 'storage', title: 'Where this lives', icon: 'box' },
333
363
  ];
334
364
 
@@ -869,7 +899,11 @@
869
899
  body.appendChild(allLocked);
870
900
  }
871
901
  if (!shown.length) {
872
- body.appendChild(el('p', 'empty', state.findings.length ? 'Nothing matches.' : 'Nothing found by the checks that are on and have run. That is not the same as nothing wrong - see which checks are not built yet.'));
902
+ // Nothing found while recordings wait for a password is not "nothing wrong": they never ran.
903
+ var waiting = (state.passwordsNeeded || []).reduce(function (n, p) { return n + p.files.length; }, 0);
904
+ body.appendChild(el('p', 'empty', state.findings.length ? 'Nothing matches.' : waiting
905
+ ? 'Nothing found yet - because your recordings did not run: ' + plural((state.passwordsNeeded || []).length, 'password is', 'passwords are') + ' missing. Give ' + ((state.passwordsNeeded || []).length === 1 ? 'it' : 'them') + ' in the box at the top, and they run.'
906
+ : 'Nothing found by the checks that are on and have run. That is not the same as nothing wrong - see which checks are not built yet.'));
873
907
  return;
874
908
  }
875
909
  var newlyBroken = (lastRecheck ? lastRecheck.newProblems : []).map(function (p) { return p.id; });
@@ -1180,6 +1214,57 @@
1180
1214
  byId('notCheckedBadge').textContent = String((state.notChecked || []).length);
1181
1215
  }
1182
1216
 
1217
+ // A recording that signed in keeps its password out of the file; until it is given, the recording replays
1218
+ // nothing and every check after it is empty. Asked for here, at the top, one box per account - saved to .env
1219
+ // by the accounts route, then the recordings are replayed. Typed values are kept across the page's redraws.
1220
+ var pwTyped = {};
1221
+ function renderPasswords() {
1222
+ var box = byId('pwBox');
1223
+ if (!box) return;
1224
+ var need = state.passwordsNeeded || [];
1225
+ var focused = document.activeElement && box.contains(document.activeElement) ? document.activeElement.getAttribute('data-env') : null;
1226
+ clear(box);
1227
+ box.hidden = !need.length;
1228
+ if (!need.length) { pwTyped = {}; return; }
1229
+ var files = [];
1230
+ need.forEach(function (p) { p.files.forEach(function (f) { if (files.indexOf(f) < 0) files.push(f); }); });
1231
+ box.appendChild(el('h3', null, need.length === 1 ? 'Your recording needs a password to run' : 'Your recordings need ' + need.length + ' passwords to run'));
1232
+ box.appendChild(el('p', null, 'You signed in while recording. Kryptheon never keeps a password in the recording, so ' +
1233
+ plural(files.length, 'recording') + ' cannot sign in, and ' + (files.length === 1 ? 'it has' : 'they have') +
1234
+ ' not been checked yet. Type ' + (need.length === 1 ? 'the password' : 'each password') + ' you used - a test account, never a real customer\'s.'));
1235
+ var inputs = [];
1236
+ need.forEach(function (p) {
1237
+ var row = el('div', 'pw-row');
1238
+ var who = el('span', 'pw-who', p.account || 'The account you signed in with');
1239
+ who.appendChild(el('small', null, p.files.join(', ')));
1240
+ row.appendChild(who);
1241
+ var pw = el('input');
1242
+ pw.type = 'password';
1243
+ pw.autocomplete = 'off';
1244
+ pw.placeholder = 'its password';
1245
+ pw.setAttribute('data-env', p.envName);
1246
+ pw.setAttribute('aria-label', 'Password of ' + (p.account || 'the recorded account'));
1247
+ pw.value = pwTyped[p.envName] || '';
1248
+ pw.addEventListener('input', function () { pwTyped[p.envName] = pw.value; });
1249
+ inputs.push({ envName: p.envName, input: pw });
1250
+ row.appendChild(pw);
1251
+ box.appendChild(row);
1252
+ if (focused === p.envName) setTimeout(function () { pw.focus(); }, 0);
1253
+ });
1254
+ var save = button('sun', 'check', 'Save and run my recordings', function () {
1255
+ var entries = inputs.filter(function (x) { return x.input.value.trim(); }).map(function (x) { return { envName: x.envName, value: x.input.value }; });
1256
+ if (!entries.length) { toast('Type the password first.'); return; }
1257
+ post('/api/setup/accounts', { entries: entries }).then(function () {
1258
+ pwTyped = {};
1259
+ toast('Saved. Running your recordings now - 2-3 minutes.');
1260
+ load().then(function () { runChecks(['regression']); });
1261
+ }, function (err) { toast(err.message); });
1262
+ });
1263
+ save.setAttribute('data-action', 'pw-save');
1264
+ box.appendChild(save);
1265
+ box.appendChild(el('div', 'fallback', 'Saved only on this computer, in the .env file of this folder. Nothing already in it is changed.'));
1266
+ }
1267
+
1183
1268
  function renderRuns() {
1184
1269
  var box = byId('runList');
1185
1270
  clear(box);
@@ -1293,8 +1378,8 @@
1293
1378
  if (a.available) title.appendChild(el('span', 'tag ' + (a.on ? 'leaf' : ''), a.on ? 'on' : 'off'));
1294
1379
  text.appendChild(title);
1295
1380
  text.appendChild(el('span', null, !a.available ? (a.why || 'Not on this computer.')
1296
- : a.on ? 'When you sign in to Windows, this dashboard starts by itself in a small window on the taskbar, with nothing opened. To see it, double-click Kryptheon.cmd as always - it opens the one already running. Closing that taskbar window stops it until you sign in again.'
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.'));
1381
+ : a.on ? 'When you sign in to Windows, this dashboard starts by itself in a small window on the taskbar, and opens in your browser the first time each day. Closing that taskbar window stops it until you sign in again.'
1382
+ : 'Switch it on and this dashboard starts by itself every time you sign in to Windows, in a small window on the taskbar - and opens in your browser once a day, at your first sign-in. Switch it off here any time.'));
1298
1383
  row.appendChild(text);
1299
1384
  box.appendChild(row);
1300
1385
  renderDaily(box);
@@ -1798,7 +1883,11 @@
1798
1883
  connectInput.value = '';
1799
1884
  toast('Connected.');
1800
1885
  load();
1801
- }, function (err) { toast(err.message); });
1886
+ }, function (err) {
1887
+ toast(err.message);
1888
+ // the guide says it too, beside the box, with where a working code comes from
1889
+ try { window.dispatchEvent(new CustomEvent('kryptheon:connect-failed', { detail: { why: err.message } })); } catch (e) { /* no guide */ }
1890
+ });
1802
1891
  }));
1803
1892
  box.appendChild(row2);
1804
1893
  var help = el('div', 'fallback');
@@ -1842,17 +1931,97 @@
1842
1931
  if (!small) wrap.appendChild(el('div', 'd-text', 'This month\'s 5 free fix prompts are used.'));
1843
1932
  wrap.appendChild(button('sm', 'arrow', 'Unlock with Pro - ₹499/month', function (e) {
1844
1933
  if (e) e.stopPropagation();
1845
- copy(a.pricing || 'https://kryptheon.tech/pricing/', 'Pricing page address copied - open it in your browser');
1934
+ go('plan');
1846
1935
  }));
1847
1936
  }
1848
1937
  return wrap;
1849
1938
  }
1850
1939
 
1940
+ /* ------------------------------- upgrade your plan ------------------------------- */
1941
+
1942
+ // The plans, and a way to move up any day. Payment is never taken here: the button opens the account page on
1943
+ // kryptheon.tech, where Razorpay is. When the person comes back to this tab, the plan is asked for again (and every
1944
+ // 20 seconds for half an hour), so the new plan shows here without a button - the entitlement function's word, never
1945
+ // this page's guess.
1946
+ var PLAN_CARDS = [
1947
+ { id: 'starter', name: 'Starter', price: 'Free', per: 'no card needed', lines: ['Every problem your checks find, with proof', '5 fix prompts an app, every month', '1 app checked every night, with counts'] },
1948
+ { id: 'pro', name: 'Pro', price: '₹499', per: '/ month', best: true, lines: ['Every fix prompt, for every problem', 'One prompt that fixes them all at once', 'Every night, a test break-in on a copy of your database', 'A morning email, and an alert when a new problem appears', 'Export your findings as a CSV file', 'Up to 3 apps, 90 days of history'] },
1949
+ { id: 'studio', name: 'Studio', price: '₹799', per: '/ month', lines: ['Everything in Pro', 'Every client app on one screen - up to 15', 'A report you can hand a client, under your own name', 'Every app\'s findings in one CSV file', 'Alerts to Slack or any webhook', 'A year of history'] },
1950
+ ];
1951
+ var PAY_PAGE = 'https://kryptheon.tech/dashboard/#plan';
1952
+ var upgradeSince = 0;
1953
+ var upgradeFrom = null;
1954
+ function planNow() { var a = state && state.account; return a && a.connected ? a.plan : null; }
1955
+ function askPlanAgain() {
1956
+ if (!upgradeSince || Date.now() - upgradeSince > 30 * 60 * 1000) { upgradeSince = 0; return; }
1957
+ post('/api/account/refresh', {}).then(function () { return load(); }).then(function () {
1958
+ var now = planNow();
1959
+ if (now && now !== upgradeFrom && now !== 'starter') {
1960
+ upgradeSince = 0;
1961
+ toast('You are on ' + (PLAN_WORD[now] || now) + ' now - every fix prompt is open.');
1962
+ }
1963
+ }, function () {});
1964
+ }
1965
+ window.addEventListener('focus', askPlanAgain);
1966
+ document.addEventListener('visibilitychange', function () { if (!document.hidden) askPlanAgain(); });
1967
+ setInterval(askPlanAgain, 20000);
1968
+ function renderPlan() {
1969
+ var box = byId('planBox');
1970
+ if (!box) return;
1971
+ clear(box);
1972
+ var now = planNow();
1973
+ var rank = { starter: 0, pro: 1, studio: 2 };
1974
+ box.appendChild(el('p', 'plan-now', now ? 'You are on ' + (PLAN_WORD[now] || now) + '.' : 'This dashboard is not connected to an account yet.'));
1975
+ if (!now) {
1976
+ var hint = el('div', 'plan-hint');
1977
+ hint.appendChild(el('span', null, 'Connect it first - Dashboard, Your account - so a plan you pick shows up here by itself.'));
1978
+ hint.appendChild(button('sm', 'arrow', 'Connect my account', function () {
1979
+ go('dashboard');
1980
+ setTimeout(function () { var c = byId('accountCard'); if (c) c.scrollIntoView({ behavior: 'smooth', block: 'center' }); connectInput.focus(); }, 60);
1981
+ }));
1982
+ box.appendChild(hint);
1983
+ }
1984
+ var grid = el('div', 'plan-grid');
1985
+ PLAN_CARDS.forEach(function (p) {
1986
+ var cardEl = el('div', 'plan-card' + (p.best ? ' best' : '') + (now === p.id ? ' mine' : ''));
1987
+ var head = el('div', 'plan-top');
1988
+ head.appendChild(el('b', null, p.name));
1989
+ if (now === p.id) head.appendChild(el('span', 'tag leaf', 'your plan'));
1990
+ else if (p.best) head.appendChild(el('span', 'tag sun', 'most picked'));
1991
+ cardEl.appendChild(head);
1992
+ var price = el('div', 'plan-price');
1993
+ price.appendChild(el('strong', null, p.price));
1994
+ price.appendChild(el('span', null, ' ' + p.per));
1995
+ cardEl.appendChild(price);
1996
+ var ul = el('ul');
1997
+ p.lines.forEach(function (t) { ul.appendChild(el('li', null, t)); });
1998
+ cardEl.appendChild(ul);
1999
+ if (p.id !== 'starter' && (!now || rank[p.id] > rank[now])) {
2000
+ var link = el('a', 'btn' + (p.best ? ' sun' : ''));
2001
+ link.href = PAY_PAGE;
2002
+ link.target = '_blank';
2003
+ link.rel = 'noopener noreferrer';
2004
+ link.appendChild(icon('up', 15));
2005
+ link.appendChild(el('span', null, 'Choose ' + p.name));
2006
+ link.addEventListener('click', function () {
2007
+ upgradeSince = Date.now();
2008
+ upgradeFrom = now;
2009
+ toast('Pay on kryptheon.tech - this page switches to ' + p.name + ' by itself when you come back.');
2010
+ });
2011
+ cardEl.appendChild(link);
2012
+ }
2013
+ grid.appendChild(cardEl);
2014
+ });
2015
+ box.appendChild(grid);
2016
+ box.appendChild(el('p', 'fallback', 'Paid on kryptheon.tech with Razorpay - UPI or card. Any offer running is shown there. Cancel any time; 7-day full refund on any charge.'));
2017
+ }
2018
+
1851
2019
  function render(next) {
1852
2020
  if (!next) return;
1853
2021
  state = next;
1854
2022
  renderSide();
1855
2023
  renderTop();
2024
+ renderPasswords();
1856
2025
  renderApp();
1857
2026
  renderAccount();
1858
2027
  setupStart();
@@ -1866,6 +2035,9 @@
1866
2035
  renderChecks();
1867
2036
  renderRuns();
1868
2037
  renderStorage();
2038
+ renderPlan();
2039
+ if (guideFinished()) sayDone();
2040
+ tell();
1869
2041
  }
1870
2042
 
1871
2043
  function load() {
@@ -114,6 +114,22 @@
114
114
  .view { margin-top: 28px; }
115
115
  .view[hidden] { display: none; }
116
116
  .card { min-width: 0; }
117
+ /* upgrade your plan: three plans side by side, hairlines like the rest; Pro on ink */
118
+ .plan-now { margin: 18px 0 6px; font-weight: 700; }
119
+ .plan-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0 4px; color: var(--muted); }
120
+ .plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 18px 0 14px; border: 1px solid var(--line); }
121
+ .plan-card { display: flex; flex-direction: column; gap: 12px; padding: 22px 20px; min-width: 0; }
122
+ .plan-card + .plan-card { border-left: 1px solid var(--line); }
123
+ .plan-card.best { color: var(--on-dark); background: var(--ink); }
124
+ .plan-card.best .plan-price span, .plan-card.best ul { color: rgba(233, 237, 242, 0.75); }
125
+ .plan-card.mine { box-shadow: inset 0 0 0 2px var(--orange); }
126
+ .plan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
127
+ .plan-top b { font-weight: 900; font-stretch: 63%; font-size: 1.6rem; text-transform: uppercase; }
128
+ .plan-price strong { font-weight: 900; font-stretch: 70%; font-size: 2.4rem; }
129
+ .plan-price span { color: var(--muted); }
130
+ .plan-card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--muted); }
131
+ .plan-card .btn { margin-top: auto; text-decoration: none; }
132
+ @media (max-width: 900px) { .plan-grid { grid-template-columns: minmax(0, 1fr); } .plan-card + .plan-card { border-left: 0; border-top: 1px solid var(--line); } }
117
133
  .card + .card, .view > .card.gap { margin-top: 44px; }
118
134
  .card-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
119
135
  .card-head h3 { font-size: clamp(1.6rem, 2.8vw, 2.2rem); }
@@ -316,6 +332,16 @@
316
332
  .consent pre.warn { color: var(--orange-deep); background: rgba(255, 77, 0, 0.06); border-left: 2px solid var(--orange); }
317
333
  .consent .tick { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
318
334
  .consent .tick input { margin-top: 3px; }
335
+ /* A recording waiting for a password: asked for at the top of every view, in a box, never as ".env". */
336
+ .pw-need { margin-top: 20px; padding: 20px 22px; background: #fff4ec; border: 2px solid var(--orange); }
337
+ .pw-need h3 { margin: 0 0 6px; font-size: 18px; }
338
+ .pw-need p { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--on-light); }
339
+ .pw-need .pw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 10px; }
340
+ .pw-need .pw-who { flex: 0 1 260px; min-width: 0; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
341
+ .pw-need .pw-who small { display: block; font-weight: 400; color: var(--muted); }
342
+ .pw-need input[type=password] { flex: 1 1 220px; min-width: 0; max-width: 360px; padding: 10px 12px; border: 1px solid var(--line); background: var(--white); font: inherit; font-size: 14px; }
343
+ .pw-need input[type=password]:focus { outline: 2px solid var(--orange); outline-offset: 1px; }
344
+ .pw-need .fallback { margin-top: 10px; }
319
345
  .every { margin-top: 20px; padding: 18px 20px; background: var(--white); border-left: 3px solid var(--orange); }
320
346
  .every-steps { margin: 0; padding-left: 22px; display: grid; gap: 4px; font-size: 14px; }
321
347
  .every-why, .every-out li { color: var(--muted); }
@@ -419,6 +445,8 @@
419
445
  <button class="btn sun" id="runAll" type="button" data-action="run"></button>
420
446
  </div>
421
447
 
448
+ <section class="pw-need" id="pwBox" hidden aria-live="polite"></section>
449
+
422
450
  <section class="every" id="everyBox" hidden></section>
423
451
 
424
452
  <section class="job" id="job" hidden aria-live="polite"></section>
@@ -512,6 +540,13 @@
512
540
  </div>
513
541
  </section>
514
542
 
543
+ <section class="view" id="view-plan" hidden>
544
+ <div class="card">
545
+ <div class="card-head"><div><div class="c-sub">Move up any day - you pay on kryptheon.tech, and this page follows</div></div></div>
546
+ <div id="planBox"></div>
547
+ </div>
548
+ </section>
549
+
515
550
  <section class="view" id="view-storage" hidden>
516
551
  <div class="card">
517
552
  <div class="card-head"><div><div class="c-sub">On this machine, outside your project</div></div></div>
@@ -524,5 +559,6 @@
524
559
  </div>
525
560
  <div class="toast" id="toast" role="status" aria-live="polite"></div>
526
561
  <script src="/dashboard.js"></script>
562
+ <script src="/tour.js"></script>
527
563
  </body>
528
564
  </html>
@@ -239,6 +239,44 @@ function flowPrompt(t, lastPass) {
239
239
  return lines.join('\n');
240
240
  }
241
241
 
242
+ /**
243
+ * The passwords the recordings need and nobody gave - not in the environment, not in .env - each once, with
244
+ * the account it signs in as (an email in the recording whose name it is) and the recordings that need it.
245
+ * Never a value. The page asks for each in a box at the top: a recording waiting for one replays nothing,
246
+ * and every check after it comes back empty, which reads as "no problems" when nothing was tried.
247
+ */
248
+ function passwordsNeeded(root, env) {
249
+ const secrets = require('./kryptheon-secrets.js');
250
+ const ownName = questionsModule().ENV_NAME;
251
+ const dir = path.join(root, 'tests');
252
+ const byName = new Map();
253
+ let names = [];
254
+ try {
255
+ names = require('./kryptheon-testfiles.js').recordingNames(dir);
256
+ } catch (err) {
257
+ return [];
258
+ }
259
+ for (const file of names) {
260
+ let source;
261
+ try {
262
+ source = fs.readFileSync(path.join(dir, file), 'utf8');
263
+ } catch (err) {
264
+ continue;
265
+ }
266
+ const absent = secrets.missingSecrets(secrets.requiredSecrets(source), { env: env || process.env, envFile: secrets.envFileFor(root) });
267
+ if (!absent.length) continue;
268
+ const emails = source.match(/[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g) || [];
269
+ for (const envName of absent) {
270
+ if (!ownName.test(envName)) continue; // only names the box may write
271
+ const item = byName.get(envName) || { envName: envName, account: null, files: [] };
272
+ if (!item.account) item.account = emails.find((e) => 'KRYPTHEON_PASSWORD_' + replay.accountPart(e) === envName) || null;
273
+ item.files.push(('tests/' + file).split('\\').join('/'));
274
+ byName.set(envName, item);
275
+ }
276
+ }
277
+ return Array.from(byName.values()).slice(0, 20);
278
+ }
279
+
242
280
  function countRecordings(root) {
243
281
  try {
244
282
  // Recordings only - not the project's own unit tests in tests/.
@@ -1037,6 +1075,8 @@ function buildState(root, env) {
1037
1075
  allFixPrompt: combinedPrompt(forAll),
1038
1076
  runs: history.slice().reverse().map((r) => ({ runAt: r.runAt, status: r.status, passed: r.passed, failed: r.failed, durationMs: r.durationMs, skipped: (r.skipped || []).slice(0, 20) })),
1039
1077
  recordings: recordings,
1078
+ // passwords the recordings wait for, asked for at the top of the page (names and accounts, never values)
1079
+ passwordsNeeded: passwordsNeeded(root, env),
1040
1080
  steps: steps,
1041
1081
  // Which app this dashboard is for: its web address, kept here, and whether
1042
1082
  // its code is on this computer at all. The dashboard started from the home
@@ -1356,6 +1396,10 @@ function createServer(root, options) {
1356
1396
  if (req.method === 'GET' && url.pathname === '/dashboard.js') {
1357
1397
  return send(res, 200, 'text/javascript; charset=utf-8', fs.readFileSync(path.join(__dirname, 'kryptheon-dashboard-page.js'), 'utf8'));
1358
1398
  }
1399
+ // The first-time guide: lights one part of the page at a time while the person does it.
1400
+ if (req.method === 'GET' && url.pathname === '/tour.js') {
1401
+ return send(res, 200, 'text/javascript; charset=utf-8', fs.readFileSync(path.join(__dirname, 'kryptheon-tour.js'), 'utf8'));
1402
+ }
1359
1403
  if (req.method === 'GET' && Object.prototype.hasOwnProperty.call(ASSETS, url.pathname)) {
1360
1404
  const [type, file] = ASSETS[url.pathname];
1361
1405
  let body;
@@ -1426,6 +1470,7 @@ function createServer(root, options) {
1426
1470
  .catch(() => json(res, 500, { ok: false, why: 'something went wrong' }));
1427
1471
  if (url.pathname === '/api/account/connect') return answer(account.connect(root, env, input.code));
1428
1472
  if (url.pathname === '/api/account/refresh') return answer(account.refresh(root, env));
1473
+ if (url.pathname === '/api/account/setup-done') return answer(account.setupDone(root, env));
1429
1474
  if (url.pathname === '/api/account/disconnect') return json(res, 200, account.disconnect(root, env));
1430
1475
  if (url.pathname === '/api/prompt/unlock') {
1431
1476
  const id = String(input.id || '');
@@ -18,7 +18,8 @@ const roles = require('./kryptheon-roles.js');
18
18
  const replay = require('./kryptheon-replay.js');
19
19
  const secrets = require('./kryptheon-secrets.js');
20
20
 
21
- const ENV_NAME = /^KRYPTHEON_(PASSWORD|TOKEN)_[A-Z0-9_]{1,80}$/;
21
+ // The plain KRYPTHEON_PASSWORD too: a recording with no email typed before its password box uses it.
22
+ const ENV_NAME = /^KRYPTHEON_(PASSWORD|TOKEN)(_[A-Z0-9_]{1,80})?$/;
22
23
  const ROLE_NAME = /^[A-Za-z][A-Za-z0-9_ -]{0,39}$/;
23
24
  const GRANT_WORDS = /(^|\/)(invite|invites|invitations?|members?|team|users?|roles?|staff)(\/|$)/i;
24
25