this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Initial commit

Jake Lazaroff 90af46e4

+110
+22
app.js
··· 1 + import { createAuthorizationUrl } from "@atcute/oauth-browser-client"; 2 + 3 + import { configure, scope } from "./oauth.js"; 4 + 5 + configure(); 6 + 7 + document.querySelector("form").onsubmit = async (e) => { 8 + e.preventDefault(); 9 + const data = new FormData(e.currentTarget); 10 + const identifier = data.get("handle"); 11 + if (typeof identifier !== "string") throw new Error("invalid handle"); 12 + 13 + const authUrl = await createAuthorizationUrl({ 14 + target: { type: "account", identifier }, 15 + scope, 16 + }); 17 + 18 + // localStorage.setItem("did", identity.id); 19 + await new Promise((r) => setTimeout(r, 100)); 20 + 21 + window.location.assign(authUrl); 22 + };
+22
callback.html
··· 1 + <!doctype html> 2 + <script type="importmap"> 3 + { 4 + "imports": { 5 + "@atcute/client": "https://esm.sh/@atcute/client", 6 + "@atcute/identity-resolver": "https://esm.sh/@atcute/identity-resolver", 7 + "@atcute/oauth-browser-client": "https://esm.sh/@atcute/oauth-browser-client@3.0.0" 8 + } 9 + } 10 + </script> 11 + <script type="module"> 12 + import { finalizeAuthorization } from "@atcute/oauth-browser-client"; 13 + 14 + import { configure } from "./oauth.js"; 15 + configure(); 16 + 17 + const params = new URLSearchParams(location.hash.slice(1)); 18 + 19 + finalizeAuthorization(params) 20 + .then(() => window.location.assign("/")) 21 + .catch((err) => console.error(err)); 22 + </script>
+12
client-metadata.json
··· 1 + { 2 + "client_id": "https://8a49-66-108-106-210.ngrok-free.app/client-metadata.json", 3 + "client_uri": "https://8a49-66-108-106-210.ngrok-free.app", 4 + "redirect_uris": ["https://8a49-66-108-106-210.ngrok-free.app/callback.html"], 5 + "application_type": "native", 6 + "client_name": "atrtc demo", 7 + "dpop_bound_access_tokens": true, 8 + "grant_types": ["authorization_code", "refresh_token"], 9 + "response_types": ["code"], 10 + "scope": "atproto repo?collection=com.jakelazaroff.webrtc.session", 11 + "token_endpoint_auth_method": "none" 12 + }
+23
index.html
··· 1 + <!doctype html> 2 + <html lang="en"> 3 + <head> 4 + <title>webrtc over atproto</title> 5 + <meta charset="utf8" /> 6 + <script type="importmap"> 7 + { 8 + "imports": { 9 + "@atcute/client": "https://esm.sh/@atcute/client", 10 + "@atcute/identity-resolver": "https://esm.sh/@atcute/identity-resolver", 11 + "@atcute/oauth-browser-client": "https://esm.sh/@atcute/oauth-browser-client@3.0.0" 12 + } 13 + } 14 + </script> 15 + <script type="module" src="./app.js"></script> 16 + </head> 17 + <body> 18 + <form> 19 + <input name="handle" /> 20 + <button>log in</button> 21 + </form> 22 + </body> 23 + </html>
+31
oauth.js
··· 1 + import metadata from "./client-metadata.json" with { type: "json" }; 2 + 3 + export const scope = metadata.scope; 4 + 5 + import { Client } from "@atcute/client"; 6 + import { configureOAuth, OAuthUserAgent } from "@atcute/oauth-browser-client"; 7 + import { 8 + CompositeDidDocumentResolver, 9 + LocalActorResolver, 10 + PlcDidDocumentResolver, 11 + WebDidDocumentResolver, 12 + XrpcHandleResolver, 13 + } from "@atcute/identity-resolver"; 14 + 15 + export function configure() { 16 + configureOAuth({ 17 + metadata: { client_id: metadata.client_id, redirect_uri: metadata.redirect_uris[0] }, 18 + identityResolver: new LocalActorResolver({ 19 + handleResolver: new XrpcHandleResolver({ serviceUrl: "https://public.api.bsky.app" }), 20 + didDocumentResolver: new CompositeDidDocumentResolver({ 21 + methods: { plc: new PlcDidDocumentResolver(), web: new WebDidDocumentResolver() }, 22 + }), 23 + }), 24 + }); 25 + } 26 + 27 + /** @param {import("@atcute/oauth-browser-client").Session} */ 28 + export function client(session) { 29 + const handler = new OAuthUserAgent(session); 30 + const client = new Client({ handler }); 31 + }