-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add file system hooks #428
Conversation
ccccc27
to
ca5be49
Compare
src/fs/types.ts
Outdated
// 💾 TOP LEVEL | ||
// ------------ | ||
|
||
export type API = Exchange & Persistence & Posix & Sharing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better name for this? Just FileSystem
? 🤷♂️
hooks: { | ||
afterLoadExisting: (fs: FileSystem.API, dataFlowComponents: DataFlowComponents) => Promise<void> | ||
afterLoadNew: (fs: FileSystem.API, dataFlowComponents: DataFlowComponents) => Promise<void> | ||
beforeLoadExisting: (cid: CID, dataFlowComponents: DataFlowComponents) => Promise<void> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requirement for walletauth, I need to load part of the public filesystem to extract the encrypted root read key. I can't pass in the reference as a dependency during the creation of the manners components. because the reference component itself depends on the manners component. And sadly the PublicTree
and PrivateTree
components of the file system depend on the reference component, because they need to do DNS lookups. Should we add these hooks elsewhere? 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Tested it out writing a custom manners component with logging in each hook, working great. 🎉
Left one comment about adding sample data by default.
* Refactor state management * Extend Repository class and add instance methods * FileSystem refactor, pt. 1 * FileSystem refactor, pt. 2 * FileSystem refactor, pt. 3 * FileSystem refactor, pt. 4 * Rewire private sharing * Only add soft links when accepting share * Load filesystem * Fix async Repo constructor issue * Retry data root when loading filesystem (from #424) * Update changelog * Edited the CHANGELOG * Refactor remaining UCAN & DID functions * Refactor appl platform code * Refactor linking * App → AppMetadata * Fix last compilation errors * Closes #131 * Remove ipfs-unixfs dependency * Clean up some TODOs * Update all dependencies and use NPM * Backwards compatibility * Initial attempt at testing components * Async setup for tests, start rewriting tests & fix circular dep * Fix circular dependencies * Custom store for testing crypto component * Adjust tests, pt. 1 * Adjust tests, pt. 2 * FileSystem tweaks * Improve backwards compat, ipfs options, test fixes, etc. * Add more component sets and improve documentation * Rename auth.webCrypto to auth.fissionWebCrypto * Adjust tests, pt. 3 * Fallback options object * CID log tests * Fix linking tests * Use debug flag for linking errors/warnings * Fix linting errors * Skip wasm tests for now * Fix initialisation of repositories * Remove MMPT warning * Ensure private filesystem backwards compat * Improve usability * Fix issues with loading filesystem * Fix issue with encrypted files * Usability improvements & some fixes * Remove dead code * More documentation * Improve API reference * Replace appInfo with id * Adjust tests to latest change * Note appPath change in the changelog * Define a base register function * Remove additionalData from session * Rewrite README * Fix README typos and some minor improvements * Make browser crypto impl easier to extend * Add AuthenticationStrategy type * Rename program.id to program.tag * More improvements to crypto * Stick with one auth strategy * Update README * Update README.md Co-authored-by: Andrew Vivash <av@andrewvivash.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Update README.md Co-authored-by: Andrew Vivash <av@andrewvivash.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Rename tag to namespace * Update README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Apply suggestions from code review Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Also change tag to namespace in tests * Update README.md Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Update README.md Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Remove confidences readme * Explain CID decoding better * Update README.md Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Improve wording * Update src/components/confidences/implementation.ts Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Apply suggestions from code review Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Update src/common/fission.ts Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Rename confidences to capabilities * In memory storage component * Improve API for predefined component configs * Add some comments to the auth implementation type * Forgot to call namespaceToString for fission depot * Documentation improvements * Apply suggestions from code review Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Document base register function * Fix typo, filesystem -> fileSystem * Apply suggestions from code review Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Replace remaining mentions of confidences * Remove globe typecasting * Update src/linking/consumer.test.ts Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Add file system hooks (#428) * Add file system hooks * Use FileSystem interface instead of type arg * Less changes * Add Properties interface * Pass CID to beforeLoadExisting hook * Re-export CID from common/cid * Provide the data flow components as arguments * Remove unnecessary cast to Uint8Array * Pass AssociatedIdentity to hooks * Remove Exchange interface * Don't add sample data by default * DataFlowComponents -> DataComponents * Replace BlockCodec with CodecIdentifier * Apply suggestions from code review Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Don't remove old indexedDB databases * appDataPath -> Path.appData * Update changelog * Window -> self * Forgot to change session type for capabilities * Dependents -> Dependencies * Export all implementations from components * Don't export capability types * Rename activate to session * Update src/common/type-checks.ts Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Update src/common/hex.node.test.ts Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com> Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> * Undo type check change & remove min/max thing * Update package.json metadata * Set engine to >= 16 Signed-off-by: Steven Vandevelde <icid.asset@gmail.com> Co-authored-by: Jess Martin <jessmartin@gmail.com> Co-authored-by: Andrew Vivash <av@andrewvivash.com> Co-authored-by: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
Adds file system hooks to the manners component.
This enables an easier flow for walletauth. Walletauth creates a read key, encrypts it and puts it in the public file system. After that, when loading a file system, it needs to decrypt that read key and inject it into the system, before loading the filesystem. So rather than "monkey patching" the functions that load the filesystem we use these hooks.
Other changes: