Chapter 15 of 22 Part III: Trust, Cryptography & Security

The Invisible Journey of Money

5 Verified Book Snippets

Every .js file below is byte-identical (SHA-256 verified) to the printed code in Volume 1. Runnable blocks execute inside an isolated sandboxed iframe and Web Worker with a 2-second timeout and zero network access.

Download Chapter ZIP

block-01.js

Printed book snippet (byte-identical) · 316 bytes · SHA-256: d8e283f4d282…
Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Defines pure JavaScript functions/data; runs cleanly in the sandbox (add a console.log call in your own test to inspect return values).

function authorize(amount, available, frozen) {
  if (!Number.isSafeInteger(amount) || amount <= 0)
    return 'Invalid amount';
  if (!Number.isSafeInteger(available) || available < 0)
    return 'Invalid balance';
  if (frozen) return 'Declined';
  if (amount > available) return 'Declined';
  return 'Approved';
}
Download .js

block-02.js

Printed book snippet (byte-identical) · 279 bytes · SHA-256: 57770db8a161…
Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Defines pure JavaScript functions/data; runs cleanly in the sandbox (add a console.log call in your own test to inspect return values).

function recordPurchase(book, id, cents) {
  if (!Number.isSafeInteger(cents) || cents <= 0)
    return 'Invalid amount';
  if (book.has(id)) {
    return book.get(id) === cents ? 'Already recorded'
      : 'Conflicting request';
  }
  book.set(id, cents);
  return 'Recorded';
}
Download .js

block-03.js

Printed book snippet (byte-identical) · 203 bytes · SHA-256: f2ad1d65909e…
Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Runs directly in Node.js or the isolated browser sandbox and logs output.

const book = new Map();
console.log(recordPurchase(book, 'FAIR-01', 1200));
console.log(recordPurchase(book, 'FAIR-01', 1200));
console.log(recordPurchase(book, 'FAIR-01', 1500));
console.log(book.size);
Download .js

block-04.js

Printed book snippet (byte-identical) · 258 bytes · SHA-256: 23ee0c4c8855…
Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Defines pure JavaScript functions/data; runs cleanly in the sandbox (add a console.log call in your own test to inspect return values).

function review(event) {
  const clues = [];
  if (event.unusualAmount) clues.push('Amount');
  if (event.unusualPlace) clues.push('Place');
  if (event.duplicateAlert) clues.push('Duplicate');
  return {clues, result: clues.length ? 'Review' : 'No flag'};
}
Download .js

block-05.js

Printed book snippet (byte-identical) · 111 bytes · SHA-256: 37476324937e…
Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Runs directly in Node.js or the isolated browser sandbox and logs output.

const sample = {unusualAmount: true,
  unusualPlace: false, duplicateAlert: true};
console.log(review(sample));
Download .js