 
 internal enum DeserializationError: Swift.Error {
     case invalidURLScheme
+    case duplicateQueryItem(String)
     case missingFactor
     case invalidFactor(String)
     case invalidCounterValue(String)

        throw DeserializationError.missingFactor
    }

    let algorithm = try queryDictionary[kQueryAlgorithmKey].map(algorithmFromString) ?? defaultAlgorithm
    let digits = try queryDictionary[kQueryDigitsKey].map(parseDigits) ?? defaultDigits
    guard let secret = try externalSecret ?? queryDictionary[kQuerySecretKey].map(parseSecret) else {
        throw DeserializationError.missingSecret
    }
    guard let generator = Generator(factor: factor, secret: secret, algorithm: algorithm, digits: digits) else {

        throw DeserializationError.invalidURLScheme
    }

    let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems ?? []

    let factor: Generator.Factor
    switch url.host {
    case .some(kFactorCounterKey):
        let counterValue = try queryItems.value(for: kQueryCounterKey).map(parseCounterValue) ?? defaultCounter
        factor = .counter(counterValue)
    case .some(kFactorTimerKey):
        let period = try queryItems.value(for: kQueryPeriodKey).map(parseTimerPeriod) ?? defaultPeriod
        factor = .timer(period: period)
    case let .some(rawValue):
        throw DeserializationError.invalidFactor(rawValue)
