sign_in_with_apple_fixed/
data.rs1use serde::{Deserialize, Deserializer, Serialize};
2
3pub const APPLE_PUB_KEYS: &str =
4 "https://appleid.apple.com/auth/keys";
5pub const APPLE_ISSUER: &str = "https://appleid.apple.com";
6
7#[derive(Debug, Serialize, Deserialize)]
8pub struct KeyComponents {
9 pub kty: String, pub kid: String, pub r#use: String, pub alg: String, pub n: String, pub e: String, }
16
17#[derive(Debug, PartialEq, Serialize, Deserialize)]
18pub struct Claims {
19 pub iss: String,
20 pub aud: String,
21 pub exp: i32,
22 pub iat: i32,
23 pub sub: String,
24 pub email: Option<String>,
25 pub email_verified: Option<String>,
26 pub auth_time: i32,
27}
28
29#[derive(Debug, PartialEq, Serialize, Deserialize)]
31pub struct ClaimsServer2Server {
32 pub iss: String,
33 pub aud: String,
34 pub exp: i32,
35 pub iat: i32,
36 pub jti: String,
37 #[serde(deserialize_with = "deserialize_events")]
40 pub events: ClaimsServer2ServerEvent,
41}
42
43#[derive(Debug, PartialEq, Serialize, Deserialize)]
44pub struct ClaimsServer2ServerEvent {
45 #[serde(rename = "type")]
46 pub event_type: String,
47 pub sub: String,
48 pub event_time: i64,
49 pub email: Option<String>,
50 pub is_private_email: Option<String>,
51}
52
53pub fn deserialize_events<'de, D>(
61 deserializer: D,
62) -> Result<ClaimsServer2ServerEvent, D::Error>
63where
64 D: Deserializer<'de>,
65{
66 let s = String::deserialize(deserializer)?;
67 let events: ClaimsServer2ServerEvent =
68 serde_json::from_str(s.as_str())
69 .map_err(serde::de::Error::custom)?;
70 Ok(events)
71}