Skip to content

Commit 027baf1

Browse files
authored
chore: Release 0.6.0
chore: Release 0.6.0
2 parents 4a77b91 + 6be1f51 commit 027baf1

File tree

5 files changed

+48
-21
lines changed

5 files changed

+48
-21
lines changed

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "app-store-server-library"
33
description = "The Rust server library for the App Store Server API and App Store Server Notifications"
4-
version = "0.5.1"
4+
version = "0.6.0"
55
repository = "https://github.com/namecare/app-store-server-library-rust"
66
homepage = "https://github.com/namecare/app-store-server-library-rust"
77
authors = ["tkhp", "namecare"]
@@ -15,20 +15,20 @@ edition = "2021"
1515

1616
# Cryptography
1717
x509-parser = { version = "0.15.1", features = ["verify", "validate"] }
18-
jsonwebtoken = { version = "8.3.0" }
19-
ring = "0.16.20"
20-
pem = "3.0.2"
18+
jsonwebtoken = { version = "9.2.0" }
19+
ring = "0.17.7"
20+
pem = "3.0.3"
2121

2222
# Serialization
23-
serde = { version = "1.0.188", features = ["derive"] }
24-
serde_json = { version = "1.0.105" }
25-
serde_with = { version = "3.3.0", features = ["chrono"] }
26-
uuid = { version = "1.4.1", features = ["serde", "v4"] }
27-
chrono = { version = "0.4.28", features = ["serde"] }
28-
base64 = "0.21.3"
23+
serde = { version = "1.0.195", features = ["derive"] }
24+
serde_json = { version = "1.0.111" }
25+
serde_with = { version = "3.5.0", features = ["chrono"] }
26+
uuid = { version = "1.7.0", features = ["serde", "v4"] }
27+
chrono = { version = "0.4.32", features = ["serde"] }
28+
base64 = "0.21.7"
2929

3030
# Utils
31-
thiserror = "1.0.47"
31+
thiserror = "1.0.56"
3232

3333
[dev-dependencies]
3434
dotenv = "0.15.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Specify `app-store-server-library` in your project's `Cargo.toml` file, under th
1111

1212
```rust
1313
[dependencies]
14-
app-store-server-library = "0.5.1"
14+
app-store-server-library = "0.6.0"
1515
```
1616
Check
1717
[crates.io](https://crates.io/crates/app-store-server-library) for the latest version number.

src/primitives/data.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::primitives::environment::Environment;
22
use serde::{Deserialize, Serialize};
3+
use crate::primitives::status::Status;
34

45
/// The app metadata and the signed renewal and transaction information.
56
///
@@ -40,4 +41,10 @@ pub struct Data {
4041
/// [JWSRenewalInfo](https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfo)
4142
#[serde(rename = "signedRenewalInfo")]
4243
pub signed_renewal_info: Option<String>,
44+
45+
/// The status of an auto-renewable subscription at the time the App Store signs the notification.
46+
///
47+
/// [JWSRenewalInfo](https://developer.apple.com/documentation/appstoreservernotifications/status)
48+
#[serde(rename = "status")]
49+
pub status: Option<Status>
4350
}

src/promotional_offer_signature_creator.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt::{Display, Formatter};
22
use base64::Engine;
33
use base64::prelude::BASE64_STANDARD;
44
use pem::{parse, PemError};
5-
use ring::{error};
5+
use ring::{error, rand};
66
use ring::signature::{ECDSA_P256_SHA256_ASN1_SIGNING, EcdsaKeyPair, KeyPair, Signature};
77
use thiserror::Error;
88

@@ -11,7 +11,7 @@ pub struct KeyRejectedWrapped(error::KeyRejected);
1111

1212
impl PartialEq for KeyRejectedWrapped {
1313
fn eq(&self, other: &Self) -> bool {
14-
self.0.description_() == other.0.description_()
14+
self.0.to_string() == other.0.to_string()
1515
}
1616
}
1717

@@ -56,8 +56,9 @@ impl PromotionalOfferSignatureCreator {
5656
let pem = parse(private_key)?;
5757
let private_key = pem.contents();
5858
let alg = &ECDSA_P256_SHA256_ASN1_SIGNING;
59+
let rng = rand::SystemRandom::new();
5960

60-
let ec_private_key = EcdsaKeyPair::from_pkcs8(alg, private_key)
61+
let ec_private_key = EcdsaKeyPair::from_pkcs8(alg, private_key, &rng)
6162
.map_err(KeyRejectedWrapped)?;
6263

6364
Ok(PromotionalOfferSignatureCreator {

src/signed_data_verifier.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use jsonwebtoken::{Algorithm, DecodingKey, Validation};
44
use serde::de::DeserializeOwned;
55
use crate::chain_verifier::{ChainVerifierError, verify_chain};
66
use crate::primitives::environment::Environment;
7+
use crate::primitives::jws_renewal_info_decoded_payload::JWSRenewalInfoDecodedPayload;
78
use crate::primitives::jws_transaction_decoded_payload::JWSTransactionDecodedPayload;
89
use crate::primitives::response_body_v2_decoded_payload::ResponseBodyV2DecodedPayload;
910
use crate::utils::StringExt;
@@ -67,6 +68,24 @@ impl SignedDataVerifier {
6768

6869

6970
impl 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

Comments
 (0)