···1919 "github.com/lestrrat-go/jwx/v2/jwk"
2020)
21212222+// This xrpc client is copied from the indigo xrpc client, with some tweaks:
2323+// - There is no `AuthInfo` on the client. Instead, you pass auth _with the request_ in the `Do()` function
2424+// - There is an `XrpcAuthedRequestArgs` struct that contains all the info you need to complete an authed request
2525+// - There is a `OnDpopPdsNonceChanged` callback that will run when the dpop nonce receives an update. You can
2626+// use this to update a database, for example.
2727+// - Requests are retried whenever the dpop nonce changes
2828+2229type XrpcClient struct {
2330 // Client is an HTTP client to use. If not set, defaults to http.RobustHTTPClient().
2424- Client *http.Client
2525- UserAgent *string
2626- Headers map[string]string
2727- OnDPoPNonceChanged func(did, newNonce string)
3131+ Client *http.Client
3232+ UserAgent *string
3333+ Headers map[string]string
3434+ OnDpopPdsNonceChanged func(did, newNonce string)
2835}
29363037type XrpcAuthedRequestArgs struct {
···212219 // if we get a new nonce, update the nonce and make the request again
213220 if (resp.StatusCode == 400 || resp.StatusCode == 401) && xe.ErrStr == "use_dpop_nonce" {
214221 authedArgs.DpopPdsNonce = resp.Header.Get("DPoP-Nonce")
215215- c.OnDPoPNonceChanged(authedArgs.Did, authedArgs.DpopPdsNonce)
222222+ c.OnDpopPdsNonceChanged(authedArgs.Did, authedArgs.DpopPdsNonce)
216223 continue
217224 }
218225