The wage::decryptor_for_file API takes a JavaScript File and returns a handle to an age::Decryptor that wraps File.stream(). It would be great if there were a way to similarly expose age::stream::StreamReader as a JavaScript ReadableStream that could be passed back out to the browser, giving it the option to stream-process the decrypted file instead of having the entire decrypted file read into memory.
One issue here is that the Rust handle stores a lifetime, and wasm-bindgen doesn't currently support returning objects with lifetimes (https://github.com/rustwasm/wasm-bindgen/issues/1187). So we may need to hack around that with unsafe, or alternatively have an API that takes a JavaScript TransformStream and writes the decrypted file to it (which would make for a somewhat wonky JavaScript API, but should still enable building JS pipelines).
The
wage::decryptor_for_file
API takes a JavaScriptFile
and returns a handle to anage::Decryptor
that wrapsFile.stream()
. It would be great if there were a way to similarly exposeage::stream::StreamReader
as a JavaScriptReadableStream
that could be passed back out to the browser, giving it the option to stream-process the decrypted file instead of having the entire decrypted file read into memory.One issue here is that the Rust handle stores a lifetime, and
wasm-bindgen
doesn't currently support returning objects with lifetimes (https://github.com/rustwasm/wasm-bindgen/issues/1187). So we may need to hack around that withunsafe
, or alternatively have an API that takes a JavaScriptTransformStream
and writes the decrypted file to it (which would make for a somewhat wonky JavaScript API, but should still enable building JS pipelines).