github-actions[bot] commited on
Commit
0b827be
·
1 Parent(s): b8a045d

Update from GitHub Actions

Browse files
Files changed (2) hide show
  1. functions/utils/authService.ts +60 -4
  2. package.json +1 -1
functions/utils/authService.ts CHANGED
@@ -48,6 +48,7 @@ export class AuthService {
48
  const authUrl = this.buildAuthUrl(clientId, redirectUri, account.email);
49
  await this.handleLoginProcess(page, account, authUrl);
50
  await this.handleMultiFactorAuth(page, account);
 
51
  await this.handleConsent(page, redirectUri);
52
  } finally {
53
  if (context) await context.close();
@@ -133,7 +134,7 @@ export class AuthService {
133
 
134
  //可能需要修改密码..这里就不处理了
135
  } catch (error) {
136
- console.log(account.email, `没有帮助我们保护帐户确认,继续执行: ${error}`);
137
  }
138
 
139
  }
@@ -196,10 +197,65 @@ export class AuthService {
196
  }
197
  }
198
 
199
- private async handleConsent(page: Page, redirectUri: string) {
200
- await page.waitForURL((url: any) => url.href.startsWith("https://login.live.com"));
201
- await page.click('button[type="submit"]#acceptButton');
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  try {
204
  await page.waitForURL("https://account.live.com/Consent/**", { timeout: 10000 });
205
  await page.click('button[type="submit"][data-testid="appConsentPrimaryButton"]');
 
48
  const authUrl = this.buildAuthUrl(clientId, redirectUri, account.email);
49
  await this.handleLoginProcess(page, account, authUrl);
50
  await this.handleMultiFactorAuth(page, account);
51
+ await this.confirmLogin(page, account);
52
  await this.handleConsent(page, redirectUri);
53
  } finally {
54
  if (context) await context.close();
 
134
 
135
  //可能需要修改密码..这里就不处理了
136
  } catch (error) {
137
+ console.log(account.email, `没有帮助我们保护帐户确认,继续执行: ${error}`);
138
  }
139
 
140
  }
 
197
  }
198
  }
199
 
 
 
 
200
 
201
+
202
+ async confirmLogin(page: Page, account: Account) {
203
+ try {
204
+ await page.waitForURL('https://account.live.com/interrupt/**', { timeout: 3000 });
205
+
206
+ // 尝试查找"暂时跳过"按钮
207
+ const skipButtonExists = await page.isVisible('button[data-testid="secondaryButton"]', { timeout: 5000 });
208
+ if (skipButtonExists) {
209
+ console.log(account.email, "找到新版'暂时跳过'按钮,正在点击...");
210
+ await page.click('button[data-testid="secondaryButton"]');
211
+ }
212
+
213
+ // 最后尝试你提到的另一个按钮
214
+ const otherButtonExists = await page.isVisible('div[data-testid="textButtonContainer"] > div:first-child > button[type="button"]', { timeout: 5000 });
215
+ if (otherButtonExists) {
216
+ console.log(account.email, "找到旧版'暂时跳过'按钮,正在点击...");
217
+ await page.click('div[data-testid="textButtonContainer"] > div:first-child > button[type="button"]');
218
+ }
219
+
220
+ } catch (error) {
221
+ //暂时跳过.下一个.获取微软的通行密钥软件
222
+ console.log(account.email, `无获取通行密钥提示,继续执行: ${error}`);
223
+ }
224
+
225
+ try {
226
+ //和下面一样.随机出现
227
+ await page.waitForURL('https://login.live.com/ppsecure/**', { timeout: 3000 });
228
+ //新版可能有问题.换成如下.
229
+ //await page.click('#acceptButton', { timeout: 10000 });
230
+ //await page.locator('button[type="submit"]').nth(0).click({ timeout: 10000 });
231
+ await page.locator('button[type="submit"]').first().click({ timeout: 10000 });
232
+ } catch (error) {
233
+ console.log(account.email, `无ppsecure登录确认,继续执行: ${error}`);
234
+ }
235
+
236
+ try {
237
+ //和上面一样.随机出现
238
+ await page.waitForURL((url) => {
239
+ return url.href.startsWith('https://login.live.com/oauth20_authorize.srf');
240
+ }, { timeout: 3000 });
241
+ await page.click('button[type="submit"]', { timeout: 10000 });
242
+ } catch (error) {
243
+ console.log(account.email, `无oauth20_authorize登录确认,继续执行: ${error}`);
244
+ }
245
+
246
+
247
+ try {
248
+ //旧版的登录确认
249
+ await page.waitForURL((url) => {
250
+ return url.href.startsWith('https://login.live.com');
251
+ }, { timeout: 3000 });
252
+ await page.click('button[type="submit"]#acceptButton',{timeout: 3000});
253
+ } catch (error) {
254
+ console.log(account.email, `无其他登录确认,继续执行: ${error}`);
255
+ }
256
+ }
257
+
258
+ private async handleConsent(page: Page, redirectUri: string) {
259
  try {
260
  await page.waitForURL("https://account.live.com/Consent/**", { timeout: 10000 });
261
  await page.click('button[type="submit"][data-testid="appConsentPrimaryButton"]');
package.json CHANGED
@@ -4,7 +4,7 @@
4
  "private": true,
5
  "type": "module",
6
  "scripts": {
7
- "dev": "vite --host --port 5009",
8
  "dev:server": "cross-env NODE_ENV=development tsx watch --no-cache index.ts",
9
  "dev:pages": "wrangler pages dev dist",
10
  "build": "vue-tsc -b && vite build",
 
4
  "private": true,
5
  "type": "module",
6
  "scripts": {
7
+ "dev": "vite --host --port 5010",
8
  "dev:server": "cross-env NODE_ENV=development tsx watch --no-cache index.ts",
9
  "dev:pages": "wrangler pages dev dist",
10
  "build": "vue-tsc -b && vite build",