Remove key error enum
This commit is contained in:
parent
b2b3c74586
commit
ac22fcd4eb
@ -17,11 +17,6 @@ private let df: DateFormatter = {
|
||||
return df
|
||||
}()
|
||||
|
||||
enum ServerError: Error {
|
||||
case invalidAuthenticationFileContent
|
||||
case invalidAuthenticationToken
|
||||
}
|
||||
|
||||
// configures your application
|
||||
public func configure(_ app: Application) async throws {
|
||||
let storageFolder = URL(fileURLWithPath: app.directory.resourcesDirectory)
|
||||
@ -79,15 +74,15 @@ private func loadKeys(at url: URL) throws -> (deviceKey: Data, remoteKey: Data)
|
||||
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
.map {
|
||||
guard let key = Data(fromHexEncodedString: $0) else {
|
||||
throw ServerError.invalidAuthenticationToken
|
||||
fatalError("Invalid key data: Failed to convert hex to binary.")
|
||||
}
|
||||
guard key.count == SHA256.byteCount else {
|
||||
throw ServerError.invalidAuthenticationToken
|
||||
fatalError("Invalid key data: Length should be \(SHA256.byteCount), not \(key.count)")
|
||||
}
|
||||
return key
|
||||
}
|
||||
guard authContent.count == 2 else {
|
||||
throw ServerError.invalidAuthenticationFileContent
|
||||
fatalError("Invalid keys: Expected 2, found \(authContent.count)")
|
||||
}
|
||||
return (deviceKey: authContent[0], remoteKey: authContent[1])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user