@thetypefounders/continue-with-google 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
- package/src/index.ts +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { type ElementHandle, Page } from 'puppeteer';
|
|
1
|
+
import { type ElementHandle, Page, WaitForSelectorOptions } from 'puppeteer';
|
|
2
2
|
export interface Logger {
|
|
3
3
|
info(message: string): void;
|
|
4
|
+
warn(message: string): void;
|
|
4
5
|
}
|
|
5
6
|
export type Options = {
|
|
6
7
|
challengeCount?: number;
|
|
7
8
|
challengeTimeoutSeconds?: number;
|
|
8
9
|
trialCount?: number;
|
|
9
10
|
trialTimeoutSeconds?: number;
|
|
11
|
+
waitForSelector?: WaitForSelectorOptions;
|
|
10
12
|
};
|
|
11
13
|
export declare function authenticate(page: Page, email: string, password: string, secret: string, selector: string, options?: Options, logger?: Logger): Promise<ElementHandle | null>;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export async function authenticate(page, email, password, secret, selector, opti
|
|
|
35
35
|
await waitForTrial(page, options.trialCount || DEFAULTS.trialCount, options.trialTimeoutSeconds || DEFAULTS.trialTimeoutSeconds, logger);
|
|
36
36
|
}
|
|
37
37
|
found = await Promise.any([
|
|
38
|
-
page.waitForSelector(selector).then(() => true),
|
|
38
|
+
page.waitForSelector(selector, options.waitForSelector).then(() => true),
|
|
39
39
|
page
|
|
40
40
|
.waitForSelector('input[type=tel]', { visible: true })
|
|
41
41
|
.then(() => false),
|
|
@@ -56,6 +56,9 @@ async function waitForTrial(page, attemptCount, attemptTimeoutSeconds, logger) {
|
|
|
56
56
|
previous = current;
|
|
57
57
|
current = future;
|
|
58
58
|
}
|
|
59
|
+
else {
|
|
60
|
+
logger.warn(`Failed to take a screenshot.`);
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
async function screenshot(page) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { generateToken } from 'authenticator';
|
|
2
2
|
import { setTimeout } from 'node:timers/promises';
|
|
3
|
-
import { type ElementHandle, Page } from 'puppeteer';
|
|
3
|
+
import { type ElementHandle, Page, WaitForSelectorOptions } from 'puppeteer';
|
|
4
4
|
|
|
5
5
|
export interface Logger {
|
|
6
6
|
info(message: string): void;
|
|
7
|
+
warn(message: string): void;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export type Options = {
|
|
@@ -11,6 +12,7 @@ export type Options = {
|
|
|
11
12
|
challengeTimeoutSeconds?: number;
|
|
12
13
|
trialCount?: number;
|
|
13
14
|
trialTimeoutSeconds?: number;
|
|
15
|
+
waitForSelector?: WaitForSelectorOptions;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
const DEFAULTS: Options = {
|
|
@@ -70,7 +72,7 @@ export async function authenticate(
|
|
|
70
72
|
);
|
|
71
73
|
}
|
|
72
74
|
found = await Promise.any([
|
|
73
|
-
page.waitForSelector(selector).then(() => true),
|
|
75
|
+
page.waitForSelector(selector, options.waitForSelector).then(() => true),
|
|
74
76
|
page
|
|
75
77
|
.waitForSelector('input[type=tel]', { visible: true })
|
|
76
78
|
.then(() => false),
|
|
@@ -101,6 +103,8 @@ async function waitForTrial(
|
|
|
101
103
|
if (future) {
|
|
102
104
|
previous = current;
|
|
103
105
|
current = future;
|
|
106
|
+
} else {
|
|
107
|
+
logger.warn(`Failed to take a screenshot.`);
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
110
|
}
|