siwa-async 0.5.1

Sign In With Apple Validation in Async Rust
Documentation
use serde::{Deserialize, Serialize};

/// Apple's Server to Server Notification Endpoint Request structure
/// This will be given as a JWT.
///
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct AppleS2SNERequest {
	/// Always https://appleid.apple.com
	pub iss: String,
	/// App bundle id which you register
	pub aud: String,
	/// Issued at since unix epoch (seconds)
	pub iat: u64,
	/// JSON Token ID
	pub jti: String,
	pub events: Vec<AppleS2SNEEvent>,
}

/// Apple's S2SNE Events Body
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct AppleS2SNEEvent {
	#[serde(rename = "type")]
	pub event_type: AppleS2SNEEventType,
	/// User ID
	pub sub: String,
	/// User email
	pub email: Option<String>,
	/// If a user set his mail as a private
	pub is_private_email: Option<bool>,
	pub event_time: u64,
}

/// Apple's S2SNE Events Type
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub enum AppleS2SNEEventType {
	#[serde(rename = "email-enabled")]
	EmailEnabled,
	#[serde(rename = "email-disabled")]
	EmailDisabled,
	#[serde(rename = "consent-revoked")]
	ConsentRevoked,
	#[serde(rename = "account-delete")]
	AccountDelete,
}