···3838await navigator.serviceWorker.ready;
3939```
40404141-Load your configuration from `client-metadata.json`:
4242-4343-```js
4444-import { configure } from "./atsw.js";
4545-4646-const config = await configure("./client-metadata.json");
4747-```
4848-4941### Logging in
50425143Pass the configuration and handle to `logIn`. It'll automatically redirect the user to their PDS:
···5345```js
5446import { logIn } from "./atsw.js";
55474848+const config = {
4949+ clientId: "https://example.com/client-metadata.json",
5050+ redirectUri: "https://example.com",
5151+ scope: "atproto repo?collection=com.atproto.server.getSession"
5252+};
5653await logIn(config, "you.bsky.social");
5754```
5555+5656+The configuration must match the corresponding fields from `client-metadata.json`.
58575958### Resuming sessions
6059
-10
atsw.js
···231231}
232232233233/**
234234- * Fetch client metadata and return an OAuth config.
235235- * @param {string} metadataUrl
236236- * @returns {Promise<OAuthConfig>}
237237- */
238238-export async function configure(metadataUrl) {
239239- const m = await (await fetch(metadataUrl)).json();
240240- return { clientId: m.client_id, redirectUri: m.redirect_uris[0], scope: m.scope };
241241-}
242242-243243-/**
244234 * Start the OAuth login flow. Stores an authing session in IndexedDB and
245235 * redirects the browser to the authorization server. When the auth server
246236 * redirects back, the service worker will intercept the callback and complete
-10
example/atsw.js
···231231}
232232233233/**
234234- * Fetch client metadata and return an OAuth config.
235235- * @param {string} metadataUrl
236236- * @returns {Promise<OAuthConfig>}
237237- */
238238-export async function configure(metadataUrl) {
239239- const m = await (await fetch(metadataUrl)).json();
240240- return { clientId: m.client_id, redirectUri: m.redirect_uris[0], scope: m.scope };
241241-}
242242-243243-/**
244234 * Start the OAuth login flow. Stores an authing session in IndexedDB and
245235 * redirects the browser to the authorization server. When the auth server
246236 * redirects back, the service worker will intercept the callback and complete