|
46 | 46 | </template> |
47 | 47 | <script lang="ts"> |
48 | 48 | import Vue from "vue"; |
49 | | -import { mapState } from "vuex"; |
50 | | -import { Encryption } from "../../models/encryption"; |
51 | | -import { EntryStorage } from "../../models/storage"; |
52 | | -import * as CryptoJS from "crypto-js"; |
53 | 49 |
|
54 | 50 | export default Vue.extend({ |
55 | 51 | data: function () { |
@@ -152,10 +148,7 @@ function getBackupFile( |
152 | 148 | let json = JSON.stringify(entryData, null, 2); |
153 | 149 | // for windows notepad |
154 | 150 | json = json.replace(/\n/g, "\r\n"); |
155 | | - const base64Data = CryptoJS.enc.Base64.stringify( |
156 | | - CryptoJS.enc.Utf8.parse(json) |
157 | | - ); |
158 | | - return `data:application/octet-stream;base64,${base64Data}`; |
| 151 | + return downloadFileUrlBuilder(json); |
159 | 152 | } |
160 | 153 |
|
161 | 154 | function getOneLineOtpBackupFile(entryData: { [hash: string]: OTPStorage }) { |
@@ -198,10 +191,12 @@ function getOneLineOtpBackupFile(entryData: { [hash: string]: OTPStorage }) { |
198 | 191 | otpAuthLines.push(otpAuthLine); |
199 | 192 | } |
200 | 193 |
|
201 | | - const base64Data = CryptoJS.enc.Base64.stringify( |
202 | | - CryptoJS.enc.Utf8.parse(otpAuthLines.join("\r\n")) |
203 | | - ); |
204 | | - return `data:application/octet-stream;base64,${base64Data}`; |
| 194 | + return downloadFileUrlBuilder(otpAuthLines.join("\r\n")); |
| 195 | +} |
| 196 | +
|
| 197 | +function downloadFileUrlBuilder(content: string) { |
| 198 | + const blob = new Blob([content], { type: "application/octet-stream" }); |
| 199 | + return URL.createObjectURL(blob); |
205 | 200 | } |
206 | 201 |
|
207 | 202 | function removeUnsafeData(data: string) { |
|
0 commit comments