Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
//
// AnisetteData.swift
// XKit
//
// Created by Kabir Oberai on 19/11/19.
// Copyright © 2019 Kabir Oberai. All rights reserved.
//
import Foundation
public struct AnisetteData {
private static let clientTimeFormat = Date.ISO8601FormatStyle(
dateSeparator: .dash,
dateTimeSeparator: .standard,
timeSeparator: .colon,
timeZoneSeparator: .omitted,
includingFractionalSeconds: false,
timeZone: .gmt
)
/// `X-Apple-I-Locale`
static let iLocaleKey = "X-Apple-I-Locale"
/// `X-Apple-Locale`
static let localeKey = "X-Apple-Locale"
public let locale: Locale = .current
/// `X-Apple-I-TimeZone`
static let timeZoneKey = "X-Apple-I-TimeZone"
public let timeZone: TimeZone = .current
/// `X-Apple-I-Client-Time`
static let clientTimeKey = "X-Apple-I-Client-Time"
public let clientTime: Date
/// `X-Apple-I-MD-RINFO`
static let routingInfoKey = "X-Apple-I-MD-RINFO"
public let routingInfo: UInt64
/// `X-Apple-I-MD-M`
static let machineIDKey = "X-Apple-I-MD-M"
public let machineID: String
/// `X-Apple-I-MD-LU`
static let localUserIDKey = "X-Apple-I-MD-LU"
public let localUserID: String
/// `X-Apple-I-MD`
static let oneTimePasswordKey = "X-Apple-I-MD"
public let oneTimePassword: String
public let deviceInfo: DeviceInfo
public var dictionary: [String: String] {
// GSA doesn't like "en_US@rg=..."; it has to be just "en_US".
let localeIdentifier = if let language = locale.language.languageCode?.identifier,
let region = locale.region?.identifier {
"\(language)_\(region)"
} else {
"en_US"
}
return [
Self.localeKey: localeIdentifier,
Self.timeZoneKey: timeZone.abbreviation() ?? "UTC",
Self.clientTimeKey: clientTime.formatted(Self.clientTimeFormat),
Self.routingInfoKey: "\(routingInfo)",
Self.machineIDKey: machineID,
Self.localUserIDKey: localUserID,
Self.oneTimePasswordKey: oneTimePassword,
]
.merging(deviceInfo.dictionary) { _, b in b }
}
}