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 page.waitForURL('**/signin?sent=1'),
30 page.locator('form[action="/signin"] button[type="submit"]').click(),
31 ]);
32 process.stdout.write('mail\n');
33 const link = JSON.parse((await input.next()).value).link;
34 // Email opens a NEW browser tab, exactly as the reported failure did.
35 const email = await context.newPage();
36 await email.goto(link);
37 process.stdout.write("stage:email-opened\n");
38 // The link opens the confirm door, which spends nothing; its one Sign
39 // in button POSTs the link back, and that is what signs in.
40 await email.locator('form[action="/auth/verify"] button[type="submit"]').click();
41 await email.waitForURL('**/native/authorize?*');
42 if (!(await email.locator("body").innerText()).includes(config.code)) throw Error("confirmation code differs from app");
43 await email.getByRole('button', {name:'Sign in to Calls app', exact:true}).click();
44 await email.waitForURL('**/native/complete');
45 if (!(await email.locator('body').innerText()).includes('Return to the Calls app')) throw Error('missing completion');
46 process.stdout.write('approved\n');
47} finally {
48 await browser.close();
49 lines.close();
50 process.stdin.destroy();
51}
52