@@ -51,7 +51,7 @@ export async function exportPublicKey(keyPair: CryptoKeyPair): Promise<Uint8Arra
5151export async function importPublicKey ( bytes : Uint8Array ) : Promise < CryptoKey > {
5252 return crypto . subtle . importKey (
5353 'raw' ,
54- bytes ,
54+ bytes as BufferSource ,
5555 { name : 'ECDH' , namedCurve : 'P-256' } ,
5656 false ,
5757 [ ]
@@ -87,7 +87,7 @@ export async function deriveAESKey(
8787 // Import as HKDF key material
8888 const keyMaterial = await crypto . subtle . importKey (
8989 'raw' ,
90- sharedSecret ,
90+ sharedSecret as BufferSource ,
9191 'HKDF' ,
9292 false ,
9393 [ 'deriveKey' ]
@@ -122,9 +122,9 @@ export async function encryptAESGCM(
122122 const iv = crypto . getRandomValues ( new Uint8Array ( 12 ) ) ;
123123
124124 const ciphertext = await crypto . subtle . encrypt (
125- { name : 'AES-GCM' , iv } ,
125+ { name : 'AES-GCM' , iv : iv as BufferSource } ,
126126 key ,
127- data
127+ data as BufferSource
128128 ) ;
129129
130130 return {
@@ -142,9 +142,9 @@ export async function decryptAESGCM(
142142 key : CryptoKey
143143) : Promise < Uint8Array > {
144144 const plaintext = await crypto . subtle . decrypt (
145- { name : 'AES-GCM' , iv } ,
145+ { name : 'AES-GCM' , iv : iv as BufferSource } ,
146146 key ,
147- ciphertext
147+ ciphertext as BufferSource
148148 ) ;
149149
150150 return new Uint8Array ( plaintext ) ;
@@ -244,7 +244,7 @@ export function hexToBytes(hex: string): Uint8Array {
244244 * Compute SHA-256 hash
245245 */
246246export async function sha256 ( data : Uint8Array ) : Promise < Uint8Array > {
247- const hash = await crypto . subtle . digest ( 'SHA-256' , data ) ;
247+ const hash = await crypto . subtle . digest ( 'SHA-256' , data as BufferSource ) ;
248248 return new Uint8Array ( hash ) ;
249249}
250250
0 commit comments