Description
Specification
There are times when we need to transfer the secrets from a vault to either another vault or the user's file system. Sometimes, only one secret needs to be transferred. Other times, we need to transfer multiple file trees including their directory structure.
As all the vaults are stored on the same encrypted file system (efs
), to transfer file trees between vaults, we only need to use regular file copying/moving operations on file systems; something along the lines of fs.promises.copy()
should work well to transfer secrets between vaults.
However, doing this between the vaults and the user's file system is not as straightforward. To efficiently transmit the file tree, we will be using an archival format like tar
. The tar
archival format is inherently streamable, and can be used to zip the file tree into a single file, which can then be transmitted over a RPC call, then be unpacked on the client, effectively transferring the file structure to the user's file system. Of course, we can also compress the resulting file, but we won't get into that quite yet.
Additional context
- Pokykey#799 has seen discussion regarding streaming over file trees using RPC calls.
- gera2ld/tarjs can be used as a zero-dependency package to generate
tar
from a file system. - matrixai/js-virtualtar can be looked into, as this was also attempting to make streamable
tar
bindings for JavaScript.
Tasks
- Make an RPC handler responsible of copying/moving file tree.
- To move file tree between vaults, just use the
fs
operations. Multiple locks might be required if transferring between multiple vaults. - To move file tree between vaults and file systems, make a tarball and stream it over RPC instead.