Skip to content

Commit

Permalink
chore: Release 0.6.0
Browse files Browse the repository at this point in the history
chore: Release 0.6.0
  • Loading branch information
tikhop committed Jan 22, 2024
2 parents 4a77b91 + 6be1f51 commit 027baf1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "app-store-server-library"
description = "The Rust server library for the App Store Server API and App Store Server Notifications"
version = "0.5.1"
version = "0.6.0"
repository = "https://github.com/namecare/app-store-server-library-rust"
homepage = "https://github.com/namecare/app-store-server-library-rust"
authors = ["tkhp", "namecare"]
Expand All @@ -15,20 +15,20 @@ edition = "2021"

# Cryptography
x509-parser = { version = "0.15.1", features = ["verify", "validate"] }
jsonwebtoken = { version = "8.3.0" }
ring = "0.16.20"
pem = "3.0.2"
jsonwebtoken = { version = "9.2.0" }
ring = "0.17.7"
pem = "3.0.3"

# Serialization
serde = { version = "1.0.188", features = ["derive"] }
serde_json = { version = "1.0.105" }
serde_with = { version = "3.3.0", features = ["chrono"] }
uuid = { version = "1.4.1", features = ["serde", "v4"] }
chrono = { version = "0.4.28", features = ["serde"] }
base64 = "0.21.3"
serde = { version = "1.0.195", features = ["derive"] }
serde_json = { version = "1.0.111" }
serde_with = { version = "3.5.0", features = ["chrono"] }
uuid = { version = "1.7.0", features = ["serde", "v4"] }
chrono = { version = "0.4.32", features = ["serde"] }
base64 = "0.21.7"

# Utils
thiserror = "1.0.47"
thiserror = "1.0.56"

[dev-dependencies]
dotenv = "0.15.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Specify `app-store-server-library` in your project's `Cargo.toml` file, under th

```rust
[dependencies]
app-store-server-library = "0.5.1"
app-store-server-library = "0.6.0"
```
Check
[crates.io](https://crates.io/crates/app-store-server-library) for the latest version number.
Expand Down
7 changes: 7 additions & 0 deletions src/primitives/data.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::primitives::environment::Environment;
use serde::{Deserialize, Serialize};
use crate::primitives::status::Status;

/// The app metadata and the signed renewal and transaction information.
///
Expand Down Expand Up @@ -40,4 +41,10 @@ pub struct Data {
/// [JWSRenewalInfo](https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfo)
#[serde(rename = "signedRenewalInfo")]
pub signed_renewal_info: Option<String>,

/// The status of an auto-renewable subscription at the time the App Store signs the notification.
///
/// [JWSRenewalInfo](https://developer.apple.com/documentation/appstoreservernotifications/status)
#[serde(rename = "status")]
pub status: Option<Status>
}
7 changes: 4 additions & 3 deletions src/promotional_offer_signature_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt::{Display, Formatter};
use base64::Engine;
use base64::prelude::BASE64_STANDARD;
use pem::{parse, PemError};
use ring::{error};
use ring::{error, rand};
use ring::signature::{ECDSA_P256_SHA256_ASN1_SIGNING, EcdsaKeyPair, KeyPair, Signature};
use thiserror::Error;

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

impl PartialEq for KeyRejectedWrapped {
fn eq(&self, other: &Self) -> bool {
self.0.description_() == other.0.description_()
self.0.to_string() == other.0.to_string()
}
}

Expand Down Expand Up @@ -56,8 +56,9 @@ impl PromotionalOfferSignatureCreator {
let pem = parse(private_key)?;
let private_key = pem.contents();
let alg = &ECDSA_P256_SHA256_ASN1_SIGNING;
let rng = rand::SystemRandom::new();

let ec_private_key = EcdsaKeyPair::from_pkcs8(alg, private_key)
let ec_private_key = EcdsaKeyPair::from_pkcs8(alg, private_key, &rng)
.map_err(KeyRejectedWrapped)?;

Ok(PromotionalOfferSignatureCreator {
Expand Down
31 changes: 25 additions & 6 deletions src/signed_data_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use jsonwebtoken::{Algorithm, DecodingKey, Validation};
use serde::de::DeserializeOwned;
use crate::chain_verifier::{ChainVerifierError, verify_chain};
use crate::primitives::environment::Environment;
use crate::primitives::jws_renewal_info_decoded_payload::JWSRenewalInfoDecodedPayload;
use crate::primitives::jws_transaction_decoded_payload::JWSTransactionDecodedPayload;
use crate::primitives::response_body_v2_decoded_payload::ResponseBodyV2DecodedPayload;
use crate::utils::StringExt;
Expand Down Expand Up @@ -67,6 +68,24 @@ impl SignedDataVerifier {


impl SignedDataVerifier {
/// Verifies and decodes a signed renewal info.
///
/// This method takes a signed renewal info string, verifies its authenticity and
/// integrity, and returns the decoded payload as a `JWSRenewalInfoDecodedPayload`
/// if the verification is successful.
///
/// # Arguments
///
/// * `signed_renewal_info` - The signed renewal info string to verify and decode.
///
/// # Returns
///
/// - `Ok(JWSRenewalInfoDecodedPayload)` if verification and decoding are successful.
/// - `Err(SignedDataVerifierError)` if verification or decoding fails, with error details.
pub fn verify_and_decode_renewal_info(&self, signed_renewal_info: &str) -> Result<JWSRenewalInfoDecodedPayload, SignedDataVerifierError> {
Ok(self.decode_signed_object(signed_renewal_info)?)
}

/// Verifies and decodes a signed transaction.
///
/// This method takes a signed transaction string, verifies its authenticity and
Expand Down Expand Up @@ -219,12 +238,12 @@ mod tests {
assert_eq!(result.err().unwrap(), SignedDataVerifierError::InvalidAppIdentifier);
}

// #[test]
// fn test_renewal_info_decoding() {
// let verifier = get_payload_verifier();
// let notification = verifier.verify_and_decode_renewal_info(RENEWAL_INFO);
// assert_eq!(notification.environment, Environment::Sandbox);
// }
#[test]
fn test_renewal_info_decoding() {
let verifier = get_payload_verifier();
let renewal_info = verifier.verify_and_decode_renewal_info(RENEWAL_INFO).unwrap();
assert_eq!(renewal_info.environment, Some(Environment::Sandbox));
}

#[test]
fn test_transaction_info_decoding() {
Expand Down

0 comments on commit 027baf1

Please sign in to comment.