kryptheon 0.1.46 → 0.1.48

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.
@@ -80,17 +80,25 @@ function liveLooking(addresses) {
80
80
  * what it does, where, that it leaves data behind, and - for an address that
81
81
  * is not this computer - that real people may see it.
82
82
  */
83
- function consentLines(what, addresses) {
83
+ function consentLines(what, addresses, options) {
84
84
  const live = liveLooking(addresses);
85
+ // The input check types its own values, which can carry a marker; the
86
+ // reliability check replays what was recorded, which cannot.
87
+ const marked = !(options && options.marker === false);
85
88
  const lines = [
86
89
  what,
87
90
  '',
88
91
  'It runs against: ' + (addresses.length ? addresses.join(', ') : 'the addresses in your recordings'),
89
92
  'It ADDS TEST DATA to your app, and that data STAYS there - Kryptheon does not delete it.',
93
+ ].concat(marked ? [
90
94
  'Most of it contains the word "' + TEST_WORD + '", so you can find it. Empty, negative and date values cannot carry it;',
91
95
  'every write that was accepted is listed when it ends.',
96
+ ] : [
97
+ 'The data is what your recorded flows save, saved again each time they are replayed (and twice on a double-click);',
98
+ 'every write that was accepted is listed when it ends.',
99
+ ], [
92
100
  'It never creates an account, and uses only the sign-in you recorded.',
93
- ];
101
+ ]);
94
102
  if (live.length) {
95
103
  lines.push('');
96
104
  lines.push('WARNING: ' + live.join(', ') + (live.length === 1 ? ' is' : ' are') + ' not this computer. If that is your live app,');
@@ -252,6 +260,37 @@ function runProbes(root, probes, options) {
252
260
  };
253
261
  }
254
262
 
263
+ // Each probe check keeps its last press in the store under this name.
264
+ const REPORT_FILES = { edge: 'edge-last.json', reliability: 'reliability-last.json' };
265
+
266
+ function reportFile(root, check, env) {
267
+ return path.join(store.pathsFor(root, env).dir, REPORT_FILES[check]);
268
+ }
269
+
270
+ function loadReport(root, check, env) {
271
+ try {
272
+ return JSON.parse(fs.readFileSync(reportFile(root, check, env), 'utf8'));
273
+ } catch (err) {
274
+ return null;
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Every address a press would reach: the pages the recordings open, and the
280
+ * places any earlier plain replay - of either check - saw the app save to.
281
+ * This is what the person is asked about, so a database somewhere else is
282
+ * named before it is written to.
283
+ */
284
+ function knownAddresses(root, sources, env) {
285
+ const out = [];
286
+ for (const source of sources) for (const a of addressesOf(source)) if (!out.includes(a)) out.push(a);
287
+ for (const check of Object.keys(REPORT_FILES)) {
288
+ const last = loadReport(root, check, env);
289
+ for (const h of (last && last.writeHosts) || []) if (!out.includes(h)) out.push(h);
290
+ }
291
+ return out;
292
+ }
293
+
255
294
  /** The request a write went to, said the way a person reads it. */
256
295
  function writeWords(w) {
257
296
  return w.method + ' ' + (w.host ? w.host : '') + w.path + ' -> ' + w.status;
@@ -271,4 +310,8 @@ module.exports = {
271
310
  probeDirFor: probeDirFor,
272
311
  runProbes: runProbes,
273
312
  writeWords: writeWords,
313
+ REPORT_FILES: REPORT_FILES,
314
+ reportFile: reportFile,
315
+ loadReport: loadReport,
316
+ knownAddresses: knownAddresses,
274
317
  };