-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ Store cryptographically strong random secret for each note
- Loading branch information
Showing
4 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
server/prisma/migrations/20221120192437_add_note_secret_token/migration.sql
This file contains 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,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "EncryptedNote" ADD COLUMN "secret_token" TEXT; |
This file contains 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 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 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,9 @@ | ||
import crypto from "crypto"; | ||
|
||
/** | ||
* Generates a 256 bit token using the nodeJS crypto module. | ||
* @returns base 64-encoded token. | ||
*/ | ||
export function generateToken(): string { | ||
return crypto.randomBytes(32).toString("base64"); | ||
} |