Something went wrong. Try again.
A CLI for publishing standard.site documents to ATProto sequoia.pub
standard site lexicon cli publishing
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import { JoseKey } from "@atproto/jwk-jose";import { OAuthClient } from "@atproto/oauth-client";import { AtprotoDohHandleResolver } from "@atproto-labs/handle-resolver";import type { Database } from "bun:sqlite";import { createStateStore, createSessionStore } from "./stores";
export const OAUTH_SCOPE = "atproto repo:site.standard.graph.subscription?action=create&action=delete";
export function createOAuthClient( db: Database, clientUrl: string, clientName = "Sequoia",) { const clientId = `${clientUrl}/oauth/client-metadata.json`; const redirectUri = `${clientUrl}/oauth/callback`;
const dohEndpoint = process.env.DOH_ENDPOINT || "https://cloudflare-dns.com/dns-query";
return new OAuthClient({ responseMode: "query", handleResolver: new AtprotoDohHandleResolver({ dohEndpoint }), clientMetadata: { client_id: clientId, client_name: clientName, client_uri: clientUrl, redirect_uris: [redirectUri], grant_types: ["authorization_code", "refresh_token"], response_types: ["code"], scope: OAUTH_SCOPE, token_endpoint_auth_method: "none", application_type: "web", dpop_bound_access_tokens: true, }, runtimeImplementation: { // biome-ignore lint/suspicious/noExplicitAny: key class mismatch across packages createKey: (algs: string[]) => JoseKey.generate(algs) as any, getRandomValues: (length: number) => crypto.getRandomValues(new Uint8Array(length)), digest: async (data: Uint8Array, { name }: { name: string }) => { const buf = await crypto.subtle.digest( name.replace("sha", "SHA-"), new Uint8Array(data), ); return new Uint8Array(buf); }, requestLock: <T>(_name: string, fn: () => T | PromiseLike<T>) => fn(), }, stateStore: createStateStore(db), sessionStore: createSessionStore(db), });}