@tinycloud/vfs mounts TinyCloud data as a Node.js virtual file system. In this first cut it is KV-only: files and directories are backed by TinyCloud KV in the underlying space or delegated subtree. It is meant for Node runtimes, not the browser.
Access Modes
TinyCloud VFS supports two entry points:
- Owner access uses an authenticated
TinyCloudNode instance and mounts your own space
- Delegated access uses a portable delegation and mounts the delegator’s scoped subtree
The delegated factory is async because it resolves the delegation before building the mounted VFS: await createTinyCloudDelegatedVfs(...).
Installation
Owner Usage
Use createTinyCloudVfsFromNode(node) when the process owns the TinyCloud session.
Delegated Usage
Use await createTinyCloudDelegatedVfs({ node, delegation }) when you want to mount a path that was granted through delegation.
Live-Tested Behavior
These examples were validated against the live Node coverage added in js-sdk PR #194.
- Owner mounts support read, write, stat, list, rename, unlink, and
rmdir
- Delegated mounts can read and write within the delegated subtree
- Read-only delegations reject writes with
EACCES
Cleanup
The current examples explicitly call vfs.unmount() and then provider.close(). Keep that order in your own code: unmount first, then close the provider.
If you are writing a long-lived service, treat the provider as a resource that should be closed on shutdown even after the VFS has been unmounted.