From ac22fcd4ebb883dbde85e74f0af955a56e88bef0 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Wed, 6 Dec 2023 09:53:24 +0100 Subject: [PATCH] Remove key error enum --- Sources/App/configure.swift | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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]) }