oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1import { chromium } from 'playwright';
2import { createInterface } from 'node:readline';
3const lines = createInterface({ input: process.stdin });
4const input = lines[Symbol.asyncIterator]();
5const config = JSON.parse((await input.next()).value);
6const browser = await chromium.launch({headless:true});
7try {
8 // A fresh default-browser profile; no cookie is copied out to the app.
9 // JavaScript is disabled to verify the entire sign-in/consent flow is HTML.
10 const context = await browser.newContext({javaScriptEnabled:false});
11 const page = await context.newPage();
12 await page.goto(config.url);
13 process.stdout.write("stage:signin\n");
14 // A member's target lands on the sign-in page. An invitation now lands on
15 // the guest screen instead (guest.html, added with guest joining): join in
16 // the app, a name form to continue in the browser, and the bar's Sign in.
17 // Only the sign-in page carries the address field, so follow the link when
18 // that is what this target produced.
19 const address = page.locator('input[name="address"]');
20 if ((await address.count()) === 0) {
21 await Promise.all([
22 page.waitForURL('**/signin*'),
23 // Since the shared chrome (f86d4da) the link is the bar's "Sign in".
24 page.getByRole('link', { name: 'Sign in', exact: true }).first().click(),
25 ]);
26 }
27 await address.fill(config.address);
28 await Promise.all([
29 // Sent is /signin?sent=1&attempt=<id> since the smart door.
30 page.waitForURL((u) => u.pathname === '/signin' && u.searchParams.get('sent') === '1'),
31 page.locator('form[action="/signin"] button[type="submit"]').click(),
32 ]);
33 process.stdout.write('mail\n');
34 const link = JSON.parse((await input.next()).value).link;
35 // Email opens a NEW browser tab, exactly as the reported failure did.
36 const email = await context.newPage();
37 await email.goto(link);
38 process.stdout.write("stage:email-opened\n");
39 // The link opens the confirm door, which spends nothing; its one Sign
40 // in button POSTs the link back, and that is what signs in.
41 await email.locator('form[action="/auth/verify"] button[type="submit"]').click();
42 await email.waitForURL('**/native/authorize?*');
43 if (!(await email.locator("body").innerText()).includes(config.code)) throw Error("confirmation code differs from app");
44 await email.getByRole('button', {name:'Sign in to Calls app', exact:true}).click();
45 await email.waitForURL('**/native/complete');
46 if (!(await email.locator('body').innerText()).includes('Return to the Calls app')) throw Error('missing completion');
47 process.stdout.write('approved\n');
48} finally {
49 await browser.close();
50 lines.close();
51 process.stdin.destroy();
52}
53