Skip to content

Commit 2b9669d

Browse files
committed
Return full Anisette headers
1 parent be55f6d commit 2b9669d

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/anisette/anisette.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from __future__ import annotations
44

55
import base64
6+
import locale
67
import logging
78
from contextlib import ExitStack
89
from ctypes import c_ulonglong
9-
from typing import TYPE_CHECKING, Any, BinaryIO
10+
from datetime import datetime
11+
from typing import TYPE_CHECKING, BinaryIO, TypedDict
1012

1113
from typing_extensions import Self
1214

@@ -24,6 +26,23 @@
2426
DEFAULT_LIBS_URL = "https://anisette.dl.mikealmel.ooo/libs?arch=arm64-v8a"
2527

2628

29+
AnisetteHeaders = TypedDict(
30+
"AnisetteHeaders",
31+
{
32+
"X-Apple-I-Client-Time": str,
33+
"X-Apple-I-MD": str,
34+
"X-Apple-I-MD-LU": str,
35+
"X-Apple-I-MD-M": str,
36+
"X-Apple-I-MD-RINFO": str,
37+
"X-Apple-I-SRL-NO": str,
38+
"X-Apple-I-TimeZone": str,
39+
"X-Apple-Locale": str,
40+
"X-MMe-Client-Info": str,
41+
"X-Mme-Device-Id": str,
42+
},
43+
)
44+
45+
2746
class Anisette:
2847
"""
2948
The main Anisette provider class.
@@ -158,17 +177,25 @@ def provision(self) -> None:
158177
logging.info("Provisioning...")
159178
self._ani_provider.provisioning_session.provision(self._ds_id)
160179

161-
def get_data(self) -> dict[str, Any]: # FIXME: make TypedDict
180+
def get_data(self) -> AnisetteHeaders:
162181
"""
163182
Obtain Anisette headers for this session.
164183
165184
:return: Anisette headers that may be used for authentication purposes.
166185
"""
167186
self.provision()
168187
otp = self._ani_provider.adi.request_otp(self._ds_id)
188+
device = self._ani_provider.device
169189

170-
# FIXME: return other fields as well
171190
return {
191+
"X-Apple-I-Client-Time": datetime.now().astimezone().replace(microsecond=0).isoformat() + "Z",
172192
"X-Apple-I-MD": base64.b64encode(bytes(otp.otp)).decode(),
193+
"X-Apple-I-MD-LU": base64.b64encode(str(device.local_user_uuid).encode()).decode(),
173194
"X-Apple-I-MD-M": base64.b64encode(bytes(otp.machine_id)).decode(),
195+
"X-Apple-I-MD-RINFO": "17106176",
196+
"X-Apple-I-SRL-NO": "0",
197+
"X-Apple-I-TimeZone": str(datetime.now().astimezone().tzinfo),
198+
"X-Apple-Locale": locale.getdefaultlocale()[0] or "en_US",
199+
"X-MMe-Client-Info": device.server_friendly_description,
200+
"X-Mme-Device-Id": device.unique_device_identifier,
174201
}

0 commit comments

Comments
 (0)