Edge OAuth Client
ATProto OAuth on Cloudflare Workers — and why a dedicated package is needed.
What it is
The @atiproto/edge-oauth-client package extends @atproto/oauth-client to run in Cloudflare Workers. It handles the full ATProto OAuth 2.0 flow: generating authorization URLs, exchanging codes for sessions, refreshing tokens, and making DPoP-authenticated API requests on behalf of a user.
Why a separate package
The upstream @atproto/oauth-client is written for Node.js and relies on Node-specific APIs that are not available in the Cloudflare Workers runtime:
- Crypto — uses Node
cryptomodule; Workers only expose WebCrypto (globalThis.crypto). - Request cache property — the client sets
cache: "no-store"on fetch requests; Workers throw aTypeErrorif this property is present. - DID / handle resolution — the default resolvers use Node networking; Workers require standard
fetch. - Session / state storage — file and in-process stores don't persist across isolate instances; KV-backed stores are required.
This package wires up the WebCrypto EdgeRuntimeImplementation, the patchGlobalRequestObject fix, and edge-compatible resolver defaults so you don't have to.
Getting started
See the edge-oauth-client package docs for installation, Wrangler configuration, and a full example of the authorization flow.