fix: auth join via Teams v2 'Join a meeting' form with Meeting ID + Passcode fields
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
d0cbcbcb29
commit
1972f698b4
1 changed files with 123 additions and 71 deletions
|
|
@ -178,90 +178,142 @@ export class BotOrchestrator {
|
||||||
this._setState('navigating');
|
this._setState('navigating');
|
||||||
|
|
||||||
if (authenticate) {
|
if (authenticate) {
|
||||||
// AUTHENTICATED JOIN: Navigate directly to the meeting URL within the
|
// AUTHENTICATED JOIN: Use the Teams v2 "Join a meeting" form.
|
||||||
// Teams v2 web app context. The external launcher (/dl/launcher/) and its
|
// The Teams v2 app (already loaded after auth) has a "Join a meeting" page
|
||||||
// "Continue on this browser" button always redirect to the anonymous
|
// with Meeting ID and Passcode fields. This keeps the user authenticated
|
||||||
// light-meetings experience, even with an active auth session.
|
// and avoids the external launcher which always redirects to anonymous mode.
|
||||||
//
|
this._logger.info(`Authenticated: joining meeting via Teams v2 "Join a meeting" form...`);
|
||||||
// Strategy: Use the Teams v2 internal URL format that keeps the user
|
|
||||||
// within the authenticated Teams web app. The key is to NOT go through
|
|
||||||
// the launcher dialog at all.
|
|
||||||
this._logger.info(`Authenticated: navigating to meeting within Teams v2 app...`);
|
|
||||||
|
|
||||||
// Parse the meeting URL to extract meeting code and passcode
|
// Parse the meeting URL to extract meeting code and passcode
|
||||||
const { parseMeetingUrl } = await import('./meetingUrlParser');
|
const { parseMeetingUrl } = await import('./meetingUrlParser');
|
||||||
const parsed = parseMeetingUrl(this._meetingUrl);
|
const parsed = parseMeetingUrl(this._meetingUrl);
|
||||||
|
const meetingId = parsed.meetingId || '';
|
||||||
|
const passcode = parsed.passcode || '';
|
||||||
|
|
||||||
// Try multiple URL formats to find one that works within Teams v2
|
this._logger.info(`Meeting ID: ${meetingId}, Passcode: ${passcode ? '***' : '(none)'}`);
|
||||||
const meetingUrlFormats = [
|
|
||||||
// Format 1: Teams v2 internal pre-join (most likely to keep auth)
|
|
||||||
`https://teams.microsoft.com/v2/#/meeting-join/${parsed.meetingId || ''}${parsed.passcode ? '?p=' + parsed.passcode : ''}`,
|
|
||||||
// Format 2: Direct /meet/ URL (original meeting URL)
|
|
||||||
this._meetingUrl,
|
|
||||||
// Format 3: Teams v2 hash-based deep link
|
|
||||||
`https://teams.microsoft.com/_#/meet/${parsed.meetingId || ''}${parsed.passcode ? '?p=' + parsed.passcode : ''}`,
|
|
||||||
];
|
|
||||||
|
|
||||||
let joinedSuccessfully = false;
|
let joinedViaForm = false;
|
||||||
|
|
||||||
for (const url of meetingUrlFormats) {
|
try {
|
||||||
this._logger.info(`Trying auth join URL: ${url}`);
|
// Navigate to the Teams v2 "Join a meeting" page
|
||||||
|
// This page is available within the authenticated Teams v2 app
|
||||||
|
await this._page!.goto('https://teams.microsoft.com/v2/', {
|
||||||
|
waitUntil: 'domcontentloaded',
|
||||||
|
timeout: 20000,
|
||||||
|
});
|
||||||
|
await this._page!.waitForTimeout(3000);
|
||||||
|
|
||||||
try {
|
// Look for "Join a meeting" link/button in the Teams v2 sidebar or header
|
||||||
await this._page!.goto(url, {
|
const joinMeetingSelectors = [
|
||||||
waitUntil: 'domcontentloaded',
|
'button:has-text("Join a meeting")',
|
||||||
timeout: 20000,
|
'a:has-text("Join a meeting")',
|
||||||
});
|
'button:has-text("Join with an ID")',
|
||||||
await this._page!.waitForTimeout(3000);
|
'a:has-text("Join with an ID")',
|
||||||
|
'[data-tid="join-meeting-button"]',
|
||||||
|
'button:has-text("An Besprechung teilnehmen")',
|
||||||
|
];
|
||||||
|
|
||||||
// Check if we landed on the authenticated pre-join page
|
let foundJoinPage = false;
|
||||||
const currentUrl = this._page!.url();
|
for (const sel of joinMeetingSelectors) {
|
||||||
const pageText = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 500) || '');
|
try {
|
||||||
|
const btn = await this._page!.$(sel);
|
||||||
this._logger.info(`After navigation - URL: ${currentUrl.substring(0, 100)}`);
|
if (btn) {
|
||||||
|
await btn.click();
|
||||||
// If we see the launcher, DON'T click "Continue on this browser" -- that leads to anon
|
this._logger.info(`Clicked: ${sel}`);
|
||||||
if (pageText.includes('Continue on this browser') || pageText.includes('Join on the Teams app')) {
|
await this._page!.waitForTimeout(2000);
|
||||||
this._logger.info('Launcher dialog detected - skipping it (would redirect to anonymous mode)');
|
foundJoinPage = true;
|
||||||
// Instead, try to find a "Use the web app" or direct join link
|
break;
|
||||||
const useWebAppButton = await this._page!.$('a:has-text("Use the web app"), button:has-text("Use the web app")');
|
|
||||||
if (useWebAppButton) {
|
|
||||||
await useWebAppButton.click();
|
|
||||||
await this._page!.waitForTimeout(3000);
|
|
||||||
}
|
}
|
||||||
continue; // Try next URL format
|
} catch { /* continue */ }
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we're on the authenticated pre-join (no name input, has "Join now")
|
|
||||||
if (!pageText.includes('Enter the name') && !pageText.includes('Type your name') &&
|
|
||||||
(pageText.includes('Join now') || pageText.includes('Join'))) {
|
|
||||||
this._logger.info('On authenticated pre-join page (no name input required)');
|
|
||||||
joinedSuccessfully = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we ended up on anon page (light-meetings)
|
|
||||||
if (currentUrl.includes('anon=true') || currentUrl.includes('light-meetings')) {
|
|
||||||
this._logger.warn(`URL redirected to anonymous mode: ${currentUrl.substring(0, 80)}`);
|
|
||||||
continue; // Try next URL format
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we're already in the meeting (Teams v2 loaded meeting directly)
|
|
||||||
if (pageText.includes('Leave') && pageText.includes('Mute')) {
|
|
||||||
this._logger.info('Already in meeting after navigation (Teams v2 joined directly)');
|
|
||||||
joinedSuccessfully = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (navError) {
|
|
||||||
this._logger.warn(`Navigation failed for URL ${url.substring(0, 60)}: ${navError}`);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if we're on the "Join a meeting" form page
|
||||||
|
const pageText = await this._page!.evaluate(() => document.body?.innerText?.substring(0, 500) || '');
|
||||||
|
|
||||||
|
if (pageText.includes('Meeting ID') || pageText.includes('Join a meeting') || pageText.includes('Besprechungs-ID')) {
|
||||||
|
this._logger.info('On "Join a meeting" form page - filling in meeting details');
|
||||||
|
|
||||||
|
// Fill in the Meeting ID field
|
||||||
|
const meetingIdSelectors = [
|
||||||
|
'input[placeholder*="Meeting ID" i]',
|
||||||
|
'input[placeholder*="Besprechungs-ID" i]',
|
||||||
|
'input[aria-label*="Meeting ID" i]',
|
||||||
|
'input[aria-label*="Besprechungs-ID" i]',
|
||||||
|
'input[name*="meetingId" i]',
|
||||||
|
'input[type="text"]:first-of-type',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const sel of meetingIdSelectors) {
|
||||||
|
try {
|
||||||
|
const input = await this._page!.$(sel);
|
||||||
|
if (input) {
|
||||||
|
await input.click();
|
||||||
|
await input.fill(meetingId);
|
||||||
|
this._logger.info(`Filled Meeting ID: ${meetingId}`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch { /* continue */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill in the Passcode field (if we have one)
|
||||||
|
if (passcode) {
|
||||||
|
const passcodeSelectors = [
|
||||||
|
'input[placeholder*="passcode" i]',
|
||||||
|
'input[placeholder*="Passcode" i]',
|
||||||
|
'input[placeholder*="Kennung" i]',
|
||||||
|
'input[aria-label*="passcode" i]',
|
||||||
|
'input[aria-label*="Kennung" i]',
|
||||||
|
'input[name*="passcode" i]',
|
||||||
|
'input[type="text"]:nth-of-type(2)',
|
||||||
|
'input[type="password"]',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const sel of passcodeSelectors) {
|
||||||
|
try {
|
||||||
|
const input = await this._page!.$(sel);
|
||||||
|
if (input) {
|
||||||
|
await input.click();
|
||||||
|
await input.fill(passcode);
|
||||||
|
this._logger.info('Filled Passcode');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch { /* continue */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Click "Join meeting" button
|
||||||
|
await this._page!.waitForTimeout(500);
|
||||||
|
const joinBtnSelectors = [
|
||||||
|
'button:has-text("Join meeting")',
|
||||||
|
'button:has-text("An Besprechung teilnehmen")',
|
||||||
|
'button:has-text("Beitreten")',
|
||||||
|
'button[data-tid="join-meeting-submit"]',
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const sel of joinBtnSelectors) {
|
||||||
|
try {
|
||||||
|
const btn = await this._page!.$(sel);
|
||||||
|
if (btn) {
|
||||||
|
await btn.click();
|
||||||
|
this._logger.info(`Clicked: ${sel}`);
|
||||||
|
joinedViaForm = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch { /* continue */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (joinedViaForm) {
|
||||||
|
// Wait for the pre-join/meeting page to load
|
||||||
|
await this._page!.waitForTimeout(5000);
|
||||||
|
this._logger.info('Submitted meeting join form - waiting for pre-join page');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (formError) {
|
||||||
|
this._logger.warn(`Teams v2 form join failed: ${formError}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!joinedSuccessfully) {
|
if (!joinedViaForm) {
|
||||||
this._logger.warn('All authenticated URL formats failed - falling back to launcher flow');
|
this._logger.warn('Teams v2 form join did not work - falling back to launcher flow');
|
||||||
// Last resort: use the launcher flow (will end up anonymous, but at least in the meeting)
|
|
||||||
await this._joinProcedure.startMeetingLauncherFlow(this._meetingUrl);
|
await this._joinProcedure.startMeetingLauncherFlow(this._meetingUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue