Meexa
Meexa2w ago

What is the recommended way to do encryption?

I’m trying to encrypt API keys into a document but I’m running into some issues. I wanted to use node:crypto but I need the node environment for that but that environment doesn’t allow mutations. So I tried using the web crypto module but that is not fully implemented so I can’t get that working either. My other options are third-party libraries but crypto-js is deprecated and the alternatives seem unreliable I need to decrypt the value again later, so I can’t encrypt on the client either. I tried using an action but: - feels clunky because I can’t access the DB directly - typescript breaks when I return a value from the action What do I do?
4 Replies
Convex Bot
Convex Bot2w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
lee
lee2w ago
Out of curiosity, what features of web crypto are you using that aren't supported? (i know there are unsupported features, but knowing which ones are needed helps prioritize) The convex-auth library uses web crypto in convex queries -- using the "jose" library -- so it's possible if you stick to the most common encryption methods
Meexa
MeexaOP2w ago
I tried using Crypto.subtle but that wasn’t supported I’ll look into jose, thanks
lee
lee2w ago
A lot of Crypto.subtle is supported. It depends on the method and encryption algorithm

Did you find this page helpful?