Packages

A browser-native atproto OAuth + XRPC client for Gleam: WebCrypto DPoP, PKCE, and async transport, for building a public-client SPA with no server-side session custody.

Current section

Files

Jump to
atproto_browser src atproto browser digest.gleam
Raw

src/atproto/browser/digest.gleam

//// WebCrypto SHA-256, shared by `atproto/browser/pkce` (the S256 code
//// challenge) and `atproto/browser/oauth/resource` (the DPoP `ath` claim —
//// a hash of the access token). `gleam/crypto.hash`'s JS FFI is
//// `node:crypto`-only (confirmed, no WebCrypto in it), so this is a small
//// from-scratch replacement rather than a reuse of the stdlib.
import gleam/javascript/promise.{type Promise}
@external(javascript, "./digest_ffi.mjs", "sha256")
pub fn sha256(bits: BitArray) -> Promise(BitArray)