extract convenience intitializer for param parser
This commit is contained in:
parent
1eb05c1d01
commit
b11bd6ea46
|
@ -390,12 +390,10 @@ class CDSBatchOperation: OWSOperation {
|
|||
|
||||
func parseAndDecrypt(response: Any?, remoteAttestation: RemoteAttestation) throws -> Data {
|
||||
|
||||
guard let responseDict = response as? [String: AnyObject] else {
|
||||
guard let params = ParamParser(responseObject: response) else {
|
||||
throw ContactDiscoveryError.parseError(description: "missing response dict")
|
||||
}
|
||||
|
||||
let params = ParamParser(dictionary: responseDict)
|
||||
|
||||
let cipherText = try params.requiredBase64EncodedData(key: "data")
|
||||
let initializationVector = try params.requiredBase64EncodedData(key: "iv")
|
||||
let authTag = try params.requiredBase64EncodedData(key: "mac")
|
||||
|
|
|
@ -34,6 +34,14 @@ public class ParamParser {
|
|||
self.dictionary = dictionary
|
||||
}
|
||||
|
||||
public convenience init?(responseObject: Any?) {
|
||||
guard let responseDict = responseObject as? [String: AnyObject] else {
|
||||
return nil
|
||||
}
|
||||
|
||||
self.init(dictionary: responseDict)
|
||||
}
|
||||
|
||||
// MARK: Errors
|
||||
|
||||
public enum ParseError: Error {
|
||||
|
|
Loading…
Reference in New Issue