()
| 36 | // Since it involves awaiting to get the instance and then another await to call the method. |
| 37 | // Using this allows the user to do this "await driver.network.addAuthenticationHandler(callback)" |
| 38 | async #init() { |
| 39 | if (this.#network !== undefined) { |
| 40 | return |
| 41 | } |
| 42 | this.#network = await getNetwork(this.#driver) |
| 43 | |
| 44 | await this.#network.addIntercept(new AddInterceptParameters(InterceptPhase.AUTH_REQUIRED)) |
| 45 | |
| 46 | await this.#network.authRequired(async (event) => { |
| 47 | const requestId = event.request.request |
| 48 | const uri = event.request.url |
| 49 | const credentials = this.getAuthCredentials(uri) |
| 50 | if (credentials !== null) { |
| 51 | await this.#network.continueWithAuth(requestId, credentials.username, credentials.password) |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | await this.#network.continueWithAuthNoCredentials(requestId) |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | getAuthCredentials(uri) { |
| 60 | for (let [, value] of this.#authHandlers) { |
no test coverage detected