@@ -26,6 +26,8 @@ const SIG_QUERY_PARAM: &str = "sig";
2626const KEY_QUERY_PARAM : & str = "key" ;
2727// The authorization header name.
2828const AUTHORIZATION : & str = "Authorization" ;
29+ // The maximum body size we allow for requests.
30+ const MAX_RESPONSE_BODY_SIZE : usize = 16 * 1024 * 1024 ; // 16 KB
2931
3032#[ derive( Debug , Clone ) ]
3133struct JwtToken {
@@ -87,7 +89,8 @@ impl LnurlAuthToJwtProvider {
8789 // Fetch the LNURL.
8890 let lnurl_request = bitreq:: get ( & self . url )
8991 . with_headers ( self . default_headers . clone ( ) )
90- . with_timeout ( DEFAULT_TIMEOUT_SECS ) ;
92+ . with_timeout ( DEFAULT_TIMEOUT_SECS )
93+ . with_max_body_size ( Some ( MAX_RESPONSE_BODY_SIZE ) ) ;
9194 let lnurl_response =
9295 lnurl_request. send_async ( ) . await . map_err ( VssHeaderProviderError :: from) ?;
9396 let lnurl_str = String :: from_utf8 ( lnurl_response. into_bytes ( ) ) . map_err ( |e| {
@@ -100,7 +103,8 @@ impl LnurlAuthToJwtProvider {
100103 let signed_lnurl = sign_lnurl ( & self . engine , & self . parent_key , & lnurl_str) ?;
101104 let auth_request = bitreq:: get ( & signed_lnurl)
102105 . with_headers ( self . default_headers . clone ( ) )
103- . with_timeout ( DEFAULT_TIMEOUT_SECS ) ;
106+ . with_timeout ( DEFAULT_TIMEOUT_SECS )
107+ . with_max_body_size ( Some ( MAX_RESPONSE_BODY_SIZE ) ) ;
104108 let auth_response =
105109 auth_request. send_async ( ) . await . map_err ( VssHeaderProviderError :: from) ?;
106110 let lnurl_auth_response: LnurlAuthResponse =
0 commit comments