Skip to content

Commit

Permalink
Compatibility with macOS 13.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn0wfreezeDev committed Apr 21, 2023
1 parent 4e0f37d commit fe1e286
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 166 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
{
"object": {
"pins": [
{
"package": "swift-crypto",
"repositoryURL": "https://github.com/apple/swift-crypto.git",
"state": {
"branch": null,
"revision": "3bea268b223651c4ab7b7b9ad62ef9b2d4143eb6",
"version": "1.1.6"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "6aa9347d9bc5bbfe6a84983aec955c17ffea96ef",
"version": "2.33.0"
}
},
{
"package": "swift-nio-ssl",
"repositoryURL": "https://github.com/apple/swift-nio-ssl",
"state": {
"branch": null,
"revision": "5e68c1ded15619bb281b273fa8c2d8fd7f7b2b7d",
"version": "2.16.1"
}
"pins" : [
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "ddb07e896a2a8af79512543b1c7eb9797f8898a5",
"version" : "1.1.7"
}
]
},
"version": 1
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "124119f0bb12384cef35aa041d7c3a686108722d",
"version" : "2.40.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl",
"state" : {
"revision" : "c30c680c78c99afdabf84805a83c8745387c4ac7",
"version" : "2.20.2"
}
}
],
"version" : 2
}
3 changes: 2 additions & 1 deletion OpenHaystack/OpenHaystack/AnisetteDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public class AnisetteDataManager: NSObject {
"X-Apple-I-MD-M": data.machineID,
"X-Apple-I-MD": data.oneTimePassword,
"X-Apple-I-TimeZone": String(data.timeZone.abbreviation() ?? "UTC"),
"X-Apple-I-Client-Time": ISO8601DateFormatter().string(from: data.date),
// "X-Apple-I-Client-Time": ISO8601DateFormatter().string(from: data.date),
"X-Apple-I-Client-Time": ISO8601DateFormatter().string(from: Date()),
"X-Apple-I-MD-RINFO": String(data.routingInfo),
] as [AnyHashable: Any])
}
Expand Down
40 changes: 20 additions & 20 deletions OpenHaystack/OpenHaystack/HaystackApp/AccessoryController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AccessoryController: ObservableObject {
var selfObserver: AnyCancellable?
var listElementsObserver = [AnyCancellable]()
let findMyController: FindMyController

weak var savePanel: NSSavePanel?

init(accessories: [Accessory], findMyController: FindMyController) {
Expand Down Expand Up @@ -99,13 +99,13 @@ class AccessoryController: ObservableObject {
func export(accessories: [Accessory]) throws -> URL {

let savePanel = NSSavePanel()
// savePanel.allowedFileTypes = ["plist", "json"]
// savePanel.allowedFileTypes = ["plist", "json"]
if #available(macOS 12.0, *) {
savePanel.allowedContentTypes = [.propertyList]
}else {
} else {
savePanel.allowedFileTypes = ["plist"]
}

savePanel.canCreateDirectories = true
savePanel.directoryURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
savePanel.message = "This export contains all private keys! Keep the file save to protect your location data"
Expand All @@ -114,31 +114,31 @@ class AccessoryController: ObservableObject {
savePanel.prompt = "Export"
savePanel.title = "Export accessories & keys"
savePanel.isExtensionHidden = false

let accessoryView = NSView()
let popUpButton = NSPopUpButton(title: "File type", target: self, action: #selector(exportFileTypeChanged(button:)))
popUpButton.addItems(withTitles: ["Property List", "JSON"])
popUpButton.selectItem(at: 0)
popUpButton.stringValue = "File type"
popUpButton.translatesAutoresizingMaskIntoConstraints = false
accessoryView.addSubview(popUpButton)

let popUpButtonLabel = NSTextField(labelWithString: "File type")
popUpButtonLabel.translatesAutoresizingMaskIntoConstraints = false
accessoryView.addSubview(popUpButtonLabel)
accessoryView.translatesAutoresizingMaskIntoConstraints = false
// popUpButtonLabel.leadingAnchor.constraint(greaterThanOrEqualTo: accessoryView.leadingAnchor, constant: 20.0).isActive = true

// popUpButtonLabel.leadingAnchor.constraint(greaterThanOrEqualTo: accessoryView.leadingAnchor, constant: 20.0).isActive = true
popUpButtonLabel.trailingAnchor.constraint(equalTo: popUpButton.leadingAnchor, constant: -8.0).isActive = true
popUpButtonLabel.trailingAnchor.constraint(lessThanOrEqualTo: accessoryView.centerXAnchor, constant: 0).isActive = true
popUpButtonLabel.centerYAnchor.constraint(equalTo: popUpButton.centerYAnchor, constant: 0).isActive = true
// popUpButton.trailingAnchor.constraint(lessThanOrEqualTo: accessoryView.trailingAnchor, constant: -20.0).isActive = true
// popUpButton.trailingAnchor.constraint(lessThanOrEqualTo: accessoryView.trailingAnchor, constant: -20.0).isActive = true
popUpButton.leadingAnchor.constraint(lessThanOrEqualTo: accessoryView.centerXAnchor, constant: 0).isActive = true
popUpButton.topAnchor.constraint(equalTo: accessoryView.topAnchor, constant: 8.0).isActive = true
popUpButton.bottomAnchor.constraint(equalTo: accessoryView.bottomAnchor, constant: -8.0).isActive = true
popUpButton.heightAnchor.constraint(greaterThanOrEqualToConstant: 20.0).isActive = true
popUpButton.widthAnchor.constraint(lessThanOrEqualToConstant: 200.0).isActive = true

savePanel.accessoryView = accessoryView
self.savePanel = savePanel

Expand All @@ -148,15 +148,15 @@ class AccessoryController: ObservableObject {
var url = savePanel.url
{
let selectedItemIndex = popUpButton.indexOfSelectedItem

// Store the accessory file
if selectedItemIndex == 0 {
if url.pathExtension != "plist" {
url = url.appendingPathExtension("plist")
}
let propertyList = try PropertyListEncoder().encode(accessories)
try propertyList.write(to: url)
}else if selectedItemIndex == 1 {
} else if selectedItemIndex == 1 {
if url.pathExtension != "json" {
url = url.appendingPathExtension("json")
}
Expand All @@ -168,18 +168,18 @@ class AccessoryController: ObservableObject {
}
throw ImportError.cancelled
}

@objc func exportFileTypeChanged(button: NSPopUpButton) {
if button.indexOfSelectedItem == 0 {
if #available(macOS 12.0, *) {
self.savePanel?.allowedContentTypes = [.propertyList]
}else {
} else {
self.savePanel?.allowedFileTypes = ["plist"]
}
}else {
} else {
if #available(macOS 12.0, *) {
self.savePanel?.allowedContentTypes = [.json]
}else {
} else {
self.savePanel?.allowedFileTypes = ["json"]
}
}
Expand All @@ -190,10 +190,10 @@ class AccessoryController: ObservableObject {
let openPanel = NSOpenPanel()
if #available(macOS 12.0, *) {
openPanel.allowedContentTypes = [.json, .propertyList]
}else {
} else {
openPanel.allowedFileTypes = ["json", "plist"]
}

openPanel.canCreateDirectories = true
openPanel.directoryURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
openPanel.message = "Import an accessories file that includes the private keys"
Expand All @@ -208,10 +208,10 @@ class AccessoryController: ObservableObject {
var importedAccessories: [Accessory]
if url.pathExtension == "plist" {
importedAccessories = try PropertyListDecoder().decode([Accessory].self, from: accessoryData)
}else {
} else {
importedAccessories = try JSONDecoder().decode([Accessory].self, from: accessoryData)
}

var updatedAccessories = self.accessories
// Filter out accessories with the same id (no duplicates)
importedAccessories = importedAccessories.filter({ acc in !self.accessories.contains(where: { acc.id == $0.id }) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import CoreLocation
import Foundation
import SwiftUI
import CoreLocation

// swiftlint:disable force_try
struct PreviewData {
Expand Down
Loading

0 comments on commit fe1e286

Please sign in to comment.