@@ -2,13 +2,13 @@ import crypto, { createCipheriv, createDecipheriv } from "node:crypto";
22
33const separator = "|" ;
44
5- const unwrapKey = ( masterKey : string , wrapped : string ) : Buffer => {
5+ const unwrapKey = ( masterKey : Buffer , wrapped : string ) : Buffer => {
66 const iv = Buffer . alloc ( 8 , 0xa6 ) ; // Recommended default initial value
77 const decipher = createDecipheriv ( "aes256-wrap" , masterKey , iv ) ;
88 return Buffer . concat ( [ decipher . update ( wrapped , "base64" ) , decipher . final ( ) ] ) ;
99} ;
1010
11- const wrapKey = ( masterKey : string , key : Buffer ) : string => {
11+ const wrapKey = ( masterKey : Buffer , key : Buffer ) : string => {
1212 const iv = Buffer . alloc ( 8 , 0xa6 ) ;
1313 const cipher = createCipheriv ( "aes256-wrap" , masterKey , iv ) ;
1414 return cipher . update ( key , undefined , "base64" ) + cipher . final ( "base64" ) ;
@@ -40,7 +40,7 @@ const genKey = (): Buffer => {
4040} ;
4141
4242export const encryptEnv = (
43- masterKey : string ,
43+ masterKey : Buffer ,
4444 plaintext : PrismaJson . EnvVar [ ] ,
4545 key : string ,
4646) => {
@@ -52,7 +52,7 @@ export const encryptEnv = (
5252} ;
5353
5454export const decryptEnv = (
55- masterKey : string ,
55+ masterKey : Buffer ,
5656 ciphertext : PrismaJson . EnvVar [ ] ,
5757 key : string ,
5858) => {
@@ -63,4 +63,4 @@ export const decryptEnv = (
6363 } ) ) ;
6464} ;
6565
66- export const generateKey = ( masterKey : string ) => wrapKey ( masterKey , genKey ( ) ) ;
66+ export const generateKey = ( masterKey : Buffer ) => wrapKey ( masterKey , genKey ( ) ) ;
0 commit comments