aboutsummaryrefslogtreecommitdiffstats
path: root/tools/amber-login-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/amber-login-test.js')
-rw-r--r--tools/amber-login-test.js26
1 files changed, 18 insertions, 8 deletions
diff --git a/tools/amber-login-test.js b/tools/amber-login-test.js
index 7439f0d..0b4c3c9 100644
--- a/tools/amber-login-test.js
+++ b/tools/amber-login-test.js
@@ -73,15 +73,25 @@ try {
// walked through
const signedKinds = [];
let signedUrls = 1;
+ // answer the next sign_event intent, if one is waiting
+ const signNext = async () => {
+ const pend = (await urls()).filter((u) => /type=sign_event/.test(u));
+ if (pend.length <= signedUrls) return false;
+ const u = pend[signedUrls]; signedUrls++;
+ const ev = JSON.parse(decodeURIComponent(u.slice('nostrsigner:'.length).split('?')[0]));
+ signedKinds.push(ev.kind);
+ await deliver(JSON.stringify(finalizeEvent({ kind: ev.kind, created_at: ev.created_at, tags: ev.tags, content: ev.content }, SK)));
+ return true;
+ };
for (let i = 0; i < 80 && !(await page.evaluate(() => document.body.innerText.toLowerCase().includes('receive'))); i++) {
- const us = await urls();
- const pend = us.filter((u) => /type=sign_event/.test(u));
- if (pend.length > signedUrls) {
- const u = pend[signedUrls]; signedUrls++;
- const ev = JSON.parse(decodeURIComponent(u.slice('nostrsigner:'.length).split('?')[0]));
- signedKinds.push(ev.kind);
- await deliver(JSON.stringify(finalizeEvent({ kind: ev.kind, created_at: ev.created_at, tags: ev.tags, content: ev.content }, SK)));
- } else { await click('later') || await click('skip verification') || await click("i've written it down") || await click('continue'); }
+ if (!(await signNext())) { await click('later') || await click('skip verification') || await click("i've written it down") || await click('continue'); }
+ await sleep(500);
+ }
+ // The starter follows wait on a deep look for a list this key may already
+ // have (2026-10-02 follows-overwrite fix), so their signature can arrive
+ // after the wallet is open: keep answering until things go quiet.
+ for (let i = 0, idle = 0; i < 60 && idle < 8; i++) {
+ if (await signNext()) idle = 0; else if (signedKinds.length) idle++;
await sleep(500);
}
if (!(await page.evaluate(() => document.body.innerText.toLowerCase().includes('receive')))) console.log(' DEBUG loop end:', JSON.stringify(await page.evaluate(() => ({ btns: [...document.querySelectorAll('button')].map((b) => b.textContent.trim()).filter(Boolean).slice(0, 12), text: document.body.innerText.slice(0, 160).replace(/\n+/g, ' | ') }))));