diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1843a13..7518e15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,6 @@ jobs: with: deno-version: v2.x - - name: Disable AppArmor - if: ${{ matrix.os == 'ubuntu-latest' }} - run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns - - name: check format if: matrix.os == 'ubuntu-latest' run: deno fmt --check diff --git a/README.md b/README.md index 2e35dbb..5a55b8f 100644 --- a/README.md +++ b/README.md @@ -138,16 +138,6 @@ const browser = await launch(); const anotherBrowser = await launch({ wsEndpoint: browser.wsEndpoint() }); ``` -### Page authenticate - -[authenticate example code](https://github.com/lino-levan/astral/blob/main/examples/authenticate.ts): - - // Open a new page - const page = await browser.newPage("https://httpbin.org/basic-auth/user/passwd"); - - // Provide credentials for HTTP authentication. - await page.authenticate({ username: "user", password: "passwd" }); - ## BYOB - Bring Your Own Browser Essentially the process is as simple as running a chromium-like binary with the diff --git a/examples/authenticate.ts b/examples/authenticate.ts deleted file mode 100644 index e600f9f..0000000 --- a/examples/authenticate.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -// Import Astral -import { launch } from "../mod.ts"; - -// Launch the browser -const browser = await launch(); - -// Open a new page -const page = await browser.newPage( - "https://httpbin.org/basic-auth/user/passwd", -); - -// Provide credentials for HTTP authentication. -await page.authenticate({ username: "user", password: "passwd" }); - -// Close the browser -await browser.close(); diff --git a/src/page.ts b/src/page.ts index 11f1000..a052074 100644 --- a/src/page.ts +++ b/src/page.ts @@ -286,31 +286,6 @@ export class Page extends EventTarget { return this.#celestial; } - /** - * Provide credentials for HTTP authentication. - * - * @example - * ```ts - * await page.authenticate({ 'username': username, 'password': password }); - * ``` - */ - authenticate( - { username, password }: { username: string; password: string }, - ): Promise { - function base64encoded(s: string) { - const codeUnits = new Uint16Array(s.length); - for (let i = 0; i < codeUnits.length; i++) { - codeUnits[i] = s.charCodeAt(i); - } - return btoa(String.fromCharCode(...new Uint8Array(codeUnits.buffer))); - } - - const auth = base64encoded(`${username}:${password}`); - return this.#celestial.Network.setExtraHTTPHeaders({ - headers: { "Authorization": `Basic ${auth}` }, - }); - } - /** * Runs `document.querySelector` within the page. If no element matches the selector, the return value resolves to `null`. *