Add support for Identity-Token handling
Dadoum

Dadoum commited on 2026-09-28 03:54:36
Showing 4 changed files, with 48 additions and 8 deletions.

... ...
@@ -140,6 +140,20 @@ impl<'lt, 'adi> AccountHTTPSession<'lt, 'adi> {
140 140
             .header("X-Apple-I-Identity-Id", &self.alt_dsid.0))
141 141
     }
142 142
 
143
+    /// Adds Anisette and `X-Apple-Identity-Token` for secondary authentication actions.
144
+    /// The identity header encodes this account's alternate DSID and its IDMS token.
145
+    pub fn identity_request_builder(
146
+        &self,
147
+        method: Method,
148
+        url: &str,
149
+        idms_token: &IdmsToken,
150
+    ) -> ADIResult<RequestBuilder> {
151
+        Ok(self.anisette_request_builder(method, url)?.header(
152
+            "X-Apple-Identity-Token",
153
+            BASE64_STANDARD.encode(format!("{}:{}", self.alt_dsid.0, idms_token.0)),
154
+        ))
155
+    }
156
+
143 157
     pub async fn get_app_token<T: AppToken>(
144 158
         &self,
145 159
         idms_token: &IdmsToken,
... ...
@@ -292,11 +306,7 @@ impl<'lt, 'adi> AccountHTTPSession<'lt, 'adi> {
292 306
 
293 307
         // AuthKitWin uses POST only when attaching a piggyback verification body.
294 308
         let response = self
295
-            .anisette_request_builder(Method::GET, validate_code_url)?
296
-            .header(
297
-                "X-Apple-Identity-Token",
298
-                BASE64_STANDARD.encode(format!("{}:{}", self.alt_dsid.0, idms_token.0)),
299
-            )
309
+            .identity_request_builder(Method::GET, validate_code_url, idms_token)?
300 310
             .header("security-code", validation_code)
301 311
             .send()
302 312
             .await?
... ...
@@ -1,4 +1,4 @@
1
-use super::account::AccountHTTPSession;
1
+use super::account::{AccountHTTPSession, IdmsToken};
2 2
 use adi::proxy::ADIResult;
3 3
 use plist::Dictionary;
4 4
 use reqwest::{Method, RequestBuilder};
... ...
@@ -58,6 +58,16 @@ impl<'lt, 'adi, T: AppToken> AppHTTPSession<'lt, 'adi, T> {
58 58
         self.http_session.account_request_builder(method, url)
59 59
     }
60 60
 
61
+    pub fn identity_request_builder(
62
+        &self,
63
+        method: Method,
64
+        url: &str,
65
+        idms_token: &IdmsToken,
66
+    ) -> ADIResult<RequestBuilder> {
67
+        self.http_session
68
+            .identity_request_builder(method, url, idms_token)
69
+    }
70
+
61 71
     pub fn app_request_builder(&self, method: Method, url: &str) -> ADIResult<RequestBuilder> {
62 72
         Ok(self
63 73
             .account_request_builder(method, url)?
... ...
@@ -1,4 +1,4 @@
1
-use super::account::AccountHTTPSession;
1
+use super::account::{AccountHTTPSession, IdmsToken};
2 2
 use super::app::{AppToken, Token};
3 3
 use crate::http_session::{AppleError, parse_status};
4 4
 use crate::plist_request::plist_to_body;
... ...
@@ -145,6 +145,16 @@ impl<'lt, 'adi> HeartbeatHTTPSession<'lt, 'adi> {
145 145
         self.http_session.account_request_builder(method, url)
146 146
     }
147 147
 
148
+    pub fn identity_request_builder(
149
+        &self,
150
+        method: Method,
151
+        url: &str,
152
+        idms_token: &IdmsToken,
153
+    ) -> ADIResult<RequestBuilder> {
154
+        self.http_session
155
+            .identity_request_builder(method, url, idms_token)
156
+    }
157
+
148 158
     pub fn heartbeat_request_builder(
149 159
         &self,
150 160
         method: Method,
... ...
@@ -1,7 +1,7 @@
1 1
 use adi::proxy::{ADIError, ADIResult};
2 2
 use grandslam::bundle_information::BundleInformation;
3 3
 use grandslam::plist_request::plist_to_body;
4
-use grandslam::{AccountHTTPSession, AppHTTPSession, AppToken, Token};
4
+use grandslam::{AccountHTTPSession, AppHTTPSession, AppToken, IdmsToken, Token};
5 5
 use plist::{Dictionary, Value};
6 6
 use plist_macros::{array, dict};
7 7
 use reqwest::{Method, RequestBuilder};
... ...
@@ -235,6 +235,16 @@ impl<'a, 'b> XcodeSession<'a, 'b> {
235 235
         self.http_session.account_request_builder(method, url)
236 236
     }
237 237
 
238
+    pub fn identity_request_builder(
239
+        &self,
240
+        method: Method,
241
+        url: &str,
242
+        idms_token: &IdmsToken,
243
+    ) -> ADIResult<RequestBuilder> {
244
+        self.http_session
245
+            .identity_request_builder(method, url, idms_token)
246
+    }
247
+
238 248
     pub fn app_request_builder(&self, method: Method, url: &str) -> ADIResult<RequestBuilder> {
239 249
         self.http_session.app_request_builder(method, url)
240 250
     }
241 251