Closed str4d closed 3 years ago
I started looking at this, age::keys::Identity::from_buffer()
requires std::io::BufRead
. Can we get that from web_sys::File
?
File.stream()
returns ReadableStream
, which we can wrap with StreamReader
to get something implementing AsyncRead
(as with the file being decrypted), but not the blocking BufRead
. I think what we eventually want is an equivalent Identity::from_async_buffer
in age
, but we could also manually read each identity into a secrecy::SecretVec
and then pass those through Identity::from_buffer
.
Not sure if this issue is the right place for it, but if you need a snippet for this TODO in the readme Expose a Rust stream to JavaScript as a user-downloadable file.
, this one works well:
function download(content, filename, contentType) {
contentType = contentType || 'application/octet-stream'
const anchor = document.createElement('a')
const blob = new Blob([content], {'type': contentType})
anchor.href = window.URL.createObjectURL(blob)
anchor.download = filename
anchor.click()
}
Implemented in #25.
This should take a decryptor and a list of identity files, and return the same value as
decrypt_with_passphrase
: