Skip to content

Commit

Permalink
Revert "feat(authenticate): Provide credentials for HTTP authenticati…
Browse files Browse the repository at this point in the history
…on (#125)" (#126)

This reverts commit 03ee82b.
  • Loading branch information
lino-levan authored Jan 7, 2025
1 parent 03ee82b commit 3a90da3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 57 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions examples/authenticate.ts

This file was deleted.

25 changes: 0 additions & 25 deletions src/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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`.
*
Expand Down

0 comments on commit 3a90da3

Please sign in to comment.