-
Notifications
You must be signed in to change notification settings - Fork 12
Conversation
WatermelonAI SummaryThe two commits in this Pull Request involve adding encryption and decryption utilities for GitHub tokens, with the specific goal of improving security and salting access tokens. This suggests that the business logic is focused on enhancing the protection of sensitive data related to user authentication and authorization. The PR aims to introduce a new feature that adds functionality to the system, in order to ensure the secure handling of OAuth tokens. GitHub PRsClick here to login to Jira |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
utils/encryption/encrypt.ts
Outdated
if(!process.env.ENCRYPTION_KEY) { | ||
throw new Error("Encryption key not found"); | ||
} | ||
const key = base64ToUint8Array(process.env.NEXT_PUBLIC_ENCRYPTION_KEY!); |
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.
Weird we have two things in the envelope
utils/encryption/decrypt.ts
Outdated
@@ -0,0 +1,16 @@ | |||
import base64ToUint8Array from "./base64ToUint8Array"; | |||
|
|||
export default function decrypt(ciphertext: string): string { |
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.
I think the two processes are so coupled they could go in the same file.
@@ -0,0 +1,8 @@ | |||
export default function base64ToUint8Array(base64String: string): Uint8Array { | |||
const binaryString = atob(base64String); | |||
const byteArray = new Uint8Array(binaryString.length); |
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.
Same file is worth it.
utils/db/github/getToken.ts
Outdated
|
||
export default async function getUser(user): Promise<any> { | ||
try { | ||
let data = await executeRequest( | ||
`EXEC dbo.get_github_token @watermelon_user = '${user}'` | ||
); | ||
return data; | ||
return decrypt(data); |
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.
Is all data encrypted?
}, | ||
}); | ||
let userJson = await user.json(); | ||
// save user correctly | ||
await saveUserInfo({ | ||
access_token: json.access_token, | ||
access_token: encrypt(json.access_token), |
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.
Perf.
Not a priority at this time |
Description
We want to improve security and salt access tokens.
Type of change
Notes
Acceptance