@@ -4,6 +4,7 @@ use jsonwebtoken::{Algorithm, DecodingKey, Validation};
44use serde:: de:: DeserializeOwned ;
55use crate :: chain_verifier:: { ChainVerifierError , verify_chain} ;
66use crate :: primitives:: environment:: Environment ;
7+ use crate :: primitives:: jws_renewal_info_decoded_payload:: JWSRenewalInfoDecodedPayload ;
78use crate :: primitives:: jws_transaction_decoded_payload:: JWSTransactionDecodedPayload ;
89use crate :: primitives:: response_body_v2_decoded_payload:: ResponseBodyV2DecodedPayload ;
910use crate :: utils:: StringExt ;
@@ -67,6 +68,24 @@ impl SignedDataVerifier {
6768
6869
6970impl SignedDataVerifier {
71+ /// Verifies and decodes a signed renewal info.
72+ ///
73+ /// This method takes a signed renewal info string, verifies its authenticity and
74+ /// integrity, and returns the decoded payload as a `JWSRenewalInfoDecodedPayload`
75+ /// if the verification is successful.
76+ ///
77+ /// # Arguments
78+ ///
79+ /// * `signed_renewal_info` - The signed renewal info string to verify and decode.
80+ ///
81+ /// # Returns
82+ ///
83+ /// - `Ok(JWSRenewalInfoDecodedPayload)` if verification and decoding are successful.
84+ /// - `Err(SignedDataVerifierError)` if verification or decoding fails, with error details.
85+ pub fn verify_and_decode_renewal_info ( & self , signed_renewal_info : & str ) -> Result < JWSRenewalInfoDecodedPayload , SignedDataVerifierError > {
86+ Ok ( self . decode_signed_object ( signed_renewal_info) ?)
87+ }
88+
7089 /// Verifies and decodes a signed transaction.
7190 ///
7291 /// This method takes a signed transaction string, verifies its authenticity and
@@ -219,12 +238,12 @@ mod tests {
219238 assert_eq ! ( result. err( ) . unwrap( ) , SignedDataVerifierError :: InvalidAppIdentifier ) ;
220239 }
221240
222- // #[test]
223- // fn test_renewal_info_decoding() {
224- // let verifier = get_payload_verifier();
225- // let notification = verifier.verify_and_decode_renewal_info(RENEWAL_INFO);
226- // assert_eq!(notification .environment, Environment::Sandbox);
227- // }
241+ #[ test]
242+ fn test_renewal_info_decoding ( ) {
243+ let verifier = get_payload_verifier ( ) ;
244+ let renewal_info = verifier. verify_and_decode_renewal_info ( RENEWAL_INFO ) . unwrap ( ) ;
245+ assert_eq ! ( renewal_info . environment, Some ( Environment :: Sandbox ) ) ;
246+ }
228247
229248 #[ test]
230249 fn test_transaction_info_decoding ( ) {
0 commit comments