@@ -30,13 +30,13 @@ export class AesGcmEncryption {
3030 if ( ! this . aesKeyLocal ) {
3131 throw new Error ( 'AES key not generated' ) ;
3232 }
33- const jsonWebKey = await crypto . subtle . exportKey ( "jwk" , this . aesKeyLocal ) ;
33+ const jsonWebKey = await window . crypto . subtle . exportKey ( "jwk" , this . aesKeyLocal ) ;
3434 return JSON . stringify ( jsonWebKey ) ;
3535 }
3636
3737 public async setRemoteAesKey ( key : string ) : Promise < void > {
3838 const jsonWebKey = JSON . parse ( key ) ;
39- this . aesKeyRemote = await crypto . subtle . importKey (
39+ this . aesKeyRemote = await window . crypto . subtle . importKey (
4040 "jwk" ,
4141 jsonWebKey ,
4242 { name : "AES-GCM" } ,
@@ -47,13 +47,13 @@ export class AesGcmEncryption {
4747 }
4848
4949 public async encryptData ( data : ArrayBuffer ) {
50- if ( ! this . aesKeyLocal ) {
50+ if ( ! this . aesKeyLocal ) {
5151 throw new Error ( 'Local AES key not generated.' )
5252 } ;
5353 // Generate an Initialization Vector (IV) for AES-GCM (12 bytes)
54- const iv = crypto . getRandomValues ( new Uint8Array ( 12 ) ) ;
54+ const iv = window . crypto . getRandomValues ( new Uint8Array ( 12 ) ) ;
5555 // Encrypt the frame data using AES-GCM
56- const encryptedData = await crypto . subtle . encrypt (
56+ const encryptedData = await window . crypto . subtle . encrypt (
5757 {
5858 name : "AES-GCM" ,
5959 iv : iv
@@ -70,7 +70,7 @@ export class AesGcmEncryption {
7070 if ( ! this . aesKeyRemote ) {
7171 throw new Error ( 'Remote AES key not set.' )
7272 }
73- return crypto . subtle . decrypt (
73+ return window . crypto . subtle . decrypt (
7474 {
7575 name : "AES-GCM" ,
7676 iv
0 commit comments