-
Notifications
You must be signed in to change notification settings - Fork 41
feat: rclone-crypt folder vault PoC #2566
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
Draft
dschmidt
wants to merge
6
commits into
main
Choose a base branch
from
feat/e2ee
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
80fcc1d
feat: add rclone-crypt folder vault PoC
dschmidt cec7ee7
feat(rclone-crypt): add unlock-vault context action
dschmidt 41daaf3
test(rclone-crypt): rename readVault.feature to vault.feature
dschmidt 6ab39e9
refactor(rclone-crypt): consume engine streams via streamTo* helpers
dschmidt 4554374
fix(rclone-crypt): tighten unit-test compatibility around vault hooks
dschmidt 51b63cc
test(e2e): dispatch drop event through Playwright instead of syntheti…
dschmidt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| "activities", | ||
| "preview", | ||
| "mail", | ||
| "contacts" | ||
| "contacts", | ||
| "rclone-crypt" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,17 +6,22 @@ import { computed, Ref, unref } from 'vue' | |||||
| import { useGettext } from 'vue3-gettext' | ||||||
| import { | ||||||
| ApplicationFileExtension, | ||||||
| decryptResourceInPlace, | ||||||
| FileAction, | ||||||
| FileActionOptions, | ||||||
| resolveFileNameDuplicate, | ||||||
| resolveFolderVault, | ||||||
| streamToArrayBuffer, | ||||||
| useAppsStore, | ||||||
| useClientService, | ||||||
| useEmbedMode, | ||||||
| useExtensionRegistry, | ||||||
| useFileActions, | ||||||
| useIsResourceNameValid, | ||||||
| useMessages, | ||||||
| useModals, | ||||||
| useResourcesStore, | ||||||
| useRouter, | ||||||
| useUserStore | ||||||
| } from '@opencloud-eu/web-pkg' | ||||||
|
|
||||||
|
|
@@ -30,9 +35,11 @@ export const useFileActionsCreateNewFile = ({ space }: { space?: Ref<SpaceResour | |||||
|
|
||||||
| const { openEditor } = useFileActions() | ||||||
| const clientService = useClientService() | ||||||
| const router = useRouter() | ||||||
|
|
||||||
| const resourcesStore = useResourcesStore() | ||||||
| const { resources, currentFolder, areFileExtensionsShown } = storeToRefs(resourcesStore) | ||||||
| const extensionRegistry = useExtensionRegistry() | ||||||
|
|
||||||
| const { isFileNameValid } = useIsResourceNameValid() | ||||||
|
|
||||||
|
|
@@ -43,7 +50,26 @@ export const useFileActionsCreateNewFile = ({ space }: { space?: Ref<SpaceResour | |||||
| const openFile = (resource: Resource, appFileExtension: ApplicationFileExtension) => { | ||||||
| resourcesStore.upsertResource(resource) | ||||||
|
|
||||||
| return openEditor(appFileExtension, unref(space), resource) | ||||||
| // Folder-typed new-menu entries (e.g. vault from rclone-crypt, notebooks | ||||||
| // from notes) may not register an editor route — when there's nothing to | ||||||
| // open we navigate into the freshly-created folder instead so the user | ||||||
| // ends up inside it. Anything that *does* have a route (apps like notes) | ||||||
| // keeps using openEditor. | ||||||
| const targetSpace = unref(space) | ||||||
| const routeName = appFileExtension?.routeName || appFileExtension?.app | ||||||
| if (appFileExtension?.type === 'folder' && !router.hasRoute(routeName)) { | ||||||
| const driveAliasAndItem = targetSpace?.getDriveAliasAndItem(resource) | ||||||
| if (driveAliasAndItem) { | ||||||
| router.push({ | ||||||
| name: 'files-spaces-generic', | ||||||
| params: { driveAliasAndItem }, | ||||||
| query: resource.fileId ? { fileId: resource.fileId as string } : undefined | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| }) | ||||||
| return | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| return openEditor(appFileExtension, targetSpace, resource) | ||||||
| } | ||||||
|
|
||||||
| const handler = ( | ||||||
|
|
@@ -80,21 +106,45 @@ export const useFileActionsCreateNewFile = ({ space }: { space?: Ref<SpaceResour | |||||
|
|
||||||
| try { | ||||||
| let resource: Resource | ||||||
| // Vault-aware: the picker/modal works in cleartext (what the user | ||||||
| // sees in the listing), but webdav needs the encrypted segment | ||||||
| // names. Look up the engine for the parent and translate before | ||||||
| // calling out — then decrypt the response so the upserted resource | ||||||
| // matches the rest of the (cleartext) listing. | ||||||
| const cleartextParentPath = unref(currentFolder).path | ||||||
| const vaultEngine = resolveFolderVault( | ||||||
| extensionRegistry, | ||||||
| unref(space), | ||||||
| cleartextParentPath | ||||||
| ) | ||||||
| if (appFileExtension.createFileHandler) { | ||||||
| resource = await appFileExtension.createFileHandler({ | ||||||
| fileName, | ||||||
| space: unref(space), | ||||||
| currentFolder: unref(currentFolder) | ||||||
| }) | ||||||
| } else if (appFileExtension.type === 'folder') { | ||||||
| const path = join(unref(currentFolder).path, fileName) | ||||||
| const cleartextPath = join(cleartextParentPath, fileName) | ||||||
| const path = vaultEngine ? await vaultEngine.encryptPath(cleartextPath) : cleartextPath | ||||||
| resource = await (clientService.webdav as WebDAV).createFolder(unref(space), { path }) | ||||||
| } else { | ||||||
| const path = join(unref(currentFolder).path, fileName) | ||||||
| const cleartextPath = join(cleartextParentPath, fileName) | ||||||
| const path = vaultEngine ? await vaultEngine.encryptPath(cleartextPath) : cleartextPath | ||||||
| // In a vault, "create empty file" must still produce a valid | ||||||
| // rclone-crypt blob on the server — a 0-byte PUT would have no | ||||||
| // header and refuse to decrypt later. Pipe an empty plaintext | ||||||
| // stream through encryptContent to get the file-header bytes. | ||||||
| const content = vaultEngine | ||||||
| ? await streamToArrayBuffer(vaultEngine.encryptContent(new Blob([]).stream())) | ||||||
| : undefined | ||||||
| resource = await (clientService.webdav as WebDAV).putFileContents(unref(space), { | ||||||
| path | ||||||
| path, | ||||||
| ...(content ? { content } : {}) | ||||||
| }) | ||||||
| } | ||||||
| if (vaultEngine && resource) { | ||||||
| await decryptResourceInPlace(vaultEngine, resource) | ||||||
| } | ||||||
|
|
||||||
| resourcesStore.upsertResource(resource) | ||||||
|
|
||||||
|
|
||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can this happen in parallel? And I guess it should be done one the filtered
newResourcesarray below.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.
yeah, true! The api should handle a list, depending on the encryption implementation we can implement it much more efficiently that way