Browse Source

e2e metadata json

Marino Faggiana 7 years ago
parent
commit
b5134c2bcc
1 changed files with 27 additions and 11 deletions
  1. 27 11
      iOSClient/Security/NCEntoToEndInterface.swift

+ 27 - 11
iOSClient/Security/NCEntoToEndInterface.swift

@@ -25,17 +25,32 @@ import Foundation
 
 class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
 
-    struct e2eMetadataElement: Codable {
-        
-        let initializationVector: String
-        let authenticationTag: String
-        let metadataKey: Int
-        let encrypted: String
-    }
+    
     
     struct e2eMetadata: Codable {
         
-        let files: [String:e2eMetadataElement]
+        struct metadataKey: Codable {
+            
+            let metadataKeys: [String: String]
+            let version: Int
+        }
+        
+        struct sharingKey: Codable {
+            
+            let recipient: [String: String]
+        }
+        
+        struct filesKey: Codable {
+            
+            let initializationVector: String
+            let authenticationTag: String
+            let metadataKey: Int
+            let encrypted: String
+        }
+        
+        let files: [String: filesKey]
+        let metadata: metadataKey;
+        //let sharing: sharingKey;
     }
 
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -409,11 +424,12 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
             
             let response = try decoder.decode(e2eMetadata.self, from: data!)
             let files = response.files
+            let metadata = response.metadata
             
-            for metadata in files {
+            for file in files {
                 
-                let fileNameID = metadata.key
-                let element = metadata.value as e2eMetadataElement
+                let fileNameID = file.key
+                let element = file.value as e2eMetadata.filesKey
                 
                 let iv = element.initializationVector
                 let tag = element.authenticationTag