aboutsummaryrefslogtreecommitdiffstats
path: root/db/normalized
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-02-09 21:03:04 +0000
committerAdam Soltys <[email protected]>2023-02-09 21:03:04 +0000
commit4c5d520b925c8be0c38a595b27704e790451fabd (patch)
tree3d61e46837397b7dccfc667f89e1c22fc4be45c3 /db/normalized
parentf054d689647836f98e3a3cc5ee4aebc7efba1ce7 (diff)
downloadcoinos-server-4c5d520b925c8be0c38a595b27704e790451fabd.tar.gz
coinos-server-4c5d520b925c8be0c38a595b27704e790451fabd.zip
ignore compose
Diffstat (limited to 'db/normalized')
0 files changed, 0 insertions, 0 deletions
t .mf { color: #00D; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #00D; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #00D; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #00D; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #D20; background-color: #FFF0F0 } /* Literal.String.Affix */ .highlight .sb { color: #D20; background-color: #FFF0F0 } /* Literal.String.Backtick */ .highlight .sc { color: #D20; background-color: #FFF0F0 } /* Literal.String.Char */ .highlight .dl { color: #D20; background-color: #FFF0F0 } /* Literal.String.Delimiter */ .highlight .sd { color: #D20; background-color: #FFF0F0 } /* Literal.String.Doc */ .highlight .s2 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Double */ .highlight .se { color: #04D; background-color: #FFF0F0 } /* Literal.String.Escape */ .highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
// The padlock is answerable from wherever it's tapped. Feature screens (your
// profile, a chat thread) are drawn ahead of the wallet screen, and the
// "Protect this device?" card is drawn BY the wallet screen — so the tap used
// to do nothing visible until you navigated home and the card finally
// appeared there. The ask outranks feature screens now, and declining still
// leaves you exactly where you tapped.
//
// Run: bun tools/padlock-ask-test.js
import puppeteer from './puppeteer.js';
import { generateMnemonic } from '@scure/bip39';
import { wordlist } from '@scure/bip39/wordlists/english';
import { buildHtml } from '../build.js';
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
let ok = true;
const check = (n, c, d = '') => { console.log(` ${c ? '✓' : '✗'} ${n}${d ? ' — ' + d : ''}`); if (!c) ok = false; };
const html = await buildHtml({ minify: true, pwa: false });
const server = Bun.serve({ port: 5231, fetch: () => new Response(html, { headers: { 'content-type': 'text/html' } }) });
const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] });
const page = await browser.newPage();
const click = (sel, t) => page.evaluate((s, x) => { const e = [...document.querySelectorAll(s)].find((n) => n.textContent.trim().toLowerCase().includes(x.toLowerCase())); if (e) { e.click(); return true; } return false; }, sel, t);
const bodyText = () => page.evaluate(() => document.body.innerText);
const waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await bodyText()).toLowerCase().includes(x.toLowerCase())) return true; await sleep(250); } return false; };
try {
  await page.setViewport({ width: 390, height: 844 });
  await page.goto('http://localhost:5231/', { waitUntil: 'domcontentloaded' });
  await page.evaluate(() => localStorage.setItem('btc-wallet-network', 'regtest'));
  await page.reload({ waitUntil: 'domcontentloaded' });
  await sleep(400);
  await click('button', 'create a new wallet');
  await sleep(500);
  await click('button', 'Have an existing seed');
  await sleep(400);
  await page.waitForSelector('textarea');
  await page.type('textarea', generateMnemonic(wordlist));
  await click('button', 'Open wallet');
  await waitText('receive', 20000);

  // open the balance card's settings (its gear) — the padlock lives there
  await page.evaluate(() => document.querySelector('.balance-gear')?.click());
  await sleep(900);
  check('the wallet settings page is open', /security/i.test(await bodyText()), (await bodyText()).slice(0, 60).replace(/\n/g, ' | '));

  // tap the padlock — the ask must appear without navigating anywhere
  const tapped = await page.evaluate(() => {
    const b = [...document.querySelectorAll('button')].find((e) => /lock/i.test(e.getAttribute('aria-label') || ''));
    if (!b) return false; b.click(); return true;
  });
  check('padlock is reachable from the wallet settings', tapped);
  await sleep(500);
  const text = await bodyText();
  check('the ask appears on the tap', /protect this device/i.test(text), text.split('\n').slice(0, 3).join(' | '));

  // declining lands back on the settings page, not somewhere else
  await click('button', 'not now');
  await sleep(600);
  check('declining lands back on the wallet settings', /security/i.test(await bodyText()), (await bodyText()).slice(0, 60).replace(/\n/g, ' | '));
} finally {
  await browser.close(); server.stop(true);
}
console.log(ok ? '\n✅ padlock ask is immediate' : '\n❌ failed');
process.exit(ok ? 0 : 1);