-
Notifications
You must be signed in to change notification settings - Fork 8
chore: sign update messages before sending #135
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
723552d
chore: sign update messages before sending
pcarranzav 73d3752
chore: include accountId in signature and message
pcarranzav 1cc6775
chore: verify signatures when applying updates (wip)
pcarranzav 3eb3539
test: add test for sign and recover
pcarranzav 69f9010
chore: allow passing the request msg to recover signer
pcarranzav fd4a555
fix: use the existing SignatureWithRecovery type
pcarranzav 25b94a3
chore: verify updates on server and client
pcarranzav 5a99a8d
fix: lint
pcarranzav 565be56
fix: apply review feedback
pcarranzav 80ad482
fix: connect spaceId correctly
pcarranzav 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
30 changes: 30 additions & 0 deletions
30
apps/server/prisma/migrations/20250129220359_add_update_signature/migration.sql
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Warnings: | ||
|
||
- Added the required column `accountId` to the `Update` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `updateId` to the `Update` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `signatureHex` to the `Update` table without a default value. This is not possible if the table is not empty. | ||
- Added the required column `signatureRecovery` to the `Update` table without a default value. This is not possible if the table is not empty. | ||
|
||
*/ | ||
-- RedefineTables | ||
PRAGMA defer_foreign_keys=ON; | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_Update" ( | ||
"spaceId" TEXT NOT NULL, | ||
"clock" INTEGER NOT NULL, | ||
"content" BLOB NOT NULL, | ||
"accountId" TEXT NOT NULL, | ||
"signatureHex" TEXT NOT NULL, | ||
"signatureRecovery" INTEGER NOT NULL, | ||
"updateId" TEXT NOT NULL, | ||
|
||
PRIMARY KEY ("spaceId", "clock"), | ||
CONSTRAINT "Update_spaceId_fkey" FOREIGN KEY ("spaceId") REFERENCES "Space" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, | ||
CONSTRAINT "Update_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
INSERT INTO "new_Update" ("clock", "content", "spaceId") SELECT "clock", "content", "spaceId" FROM "Update"; | ||
DROP TABLE "Update"; | ||
ALTER TABLE "new_Update" RENAME TO "Update"; | ||
PRAGMA foreign_keys=ON; | ||
PRAGMA defer_foreign_keys=OFF; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
# It should be added in your version-control system (e.g., Git) | ||
provider = "sqlite" |
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './decrypt-message.js'; | ||
export * from './encrypt-message.js'; | ||
export * from './serialize.js'; | ||
export * from './signed-update-message.js'; | ||
export * from './types.js'; |
Oops, something went wrong.
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.
here we gather all the automergeUpdates and then apply them. I actually didn't do it properly in the other case, but this should be the way to go. Can you update the function to do it this way?
The reason is that afaik this is much more performant than applying ever update in a for loop
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.
Makes sense, will fix