diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index 426c0bd..5772004 100755 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -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]) }