(encryptedData, encodedKey, encodedIv, mimeType, fileName)
| 126 | } |
| 127 | |
| 128 | const decryptFile = async (encryptedData, encodedKey, encodedIv, mimeType, fileName) => { |
| 129 | const rawKey = base64UrlToArrayBuffer(encodedKey); |
| 130 | const iv = base64UrlToArrayBuffer(encodedIv); |
| 131 | |
| 132 | const key = await crypto.subtle.importKey( |
| 133 | 'raw', |
| 134 | rawKey, |
| 135 | { |
| 136 | name: 'AES-GCM', |
| 137 | length: 256 |
| 138 | }, |
| 139 | false, |
| 140 | [ |
| 141 | "decrypt" |
| 142 | ] |
| 143 | ); |
| 144 | |
| 145 | const decryptedData = await crypto.subtle.decrypt( |
| 146 | { |
| 147 | name: 'AES-GCM', |
| 148 | iv |
| 149 | }, |
| 150 | key, |
| 151 | encryptedData |
| 152 | ); |
| 153 | |
| 154 | return new File( |
| 155 | [ |
| 156 | decryptedData |
| 157 | ], |
| 158 | fileName, |
| 159 | { |
| 160 | type: mimeType |
| 161 | } |
| 162 | ); |
| 163 | } |
no test coverage detected