@@ -6,7 +6,7 @@ export interface ISymmetricEncryption {
66 /** Generate / initialise the local encryption key. Idempotent. */
77 init ( ) : Promise < void > ;
88 /** Encrypt a raw data buffer. Returns the ciphertext and the IV used. */
9- encryptData ( data : ArrayBuffer ) : Promise < { encryptedData : Uint8Array < ArrayBuffer > ; iv : Uint8Array < ArrayBuffer > } > ;
9+ encryptData ( data : ArrayBuffer ) : Promise < { encryptedData : Uint8Array ; iv : Uint8Array } > ;
1010 /** Decrypt a ciphertext buffer using the previously imported remote key. */
1111 decryptData ( data : BufferSource , iv : BufferSource ) : Promise < ArrayBuffer > ;
1212 /** Serialise the local key to a string for transmission (e.g. JWK JSON). */
@@ -53,12 +53,12 @@ export class AesGcmEncryption implements ISymmetricEncryption {
5353 ) ;
5454 }
5555
56- public async encryptData ( data : ArrayBuffer ) : Promise < { encryptedData : Uint8Array < ArrayBuffer > ; iv : Uint8Array < ArrayBuffer > } > {
56+ public async encryptData ( data : ArrayBuffer ) : Promise < { encryptedData : Uint8Array ; iv : Uint8Array } > {
5757 if ( ! this . aesKeyLocal ) {
5858 throw new Error ( 'Local AES key not generated.' ) ;
5959 }
60- const iv = crypto . getRandomValues ( new Uint8Array ( 12 ) ) ;
61- const encryptedData = await crypto . subtle . encrypt (
60+ const iv = window . crypto . getRandomValues ( new Uint8Array ( 12 ) ) ;
61+ const encryptedData = await window . crypto . subtle . encrypt (
6262 { name : "AES-GCM" , iv } ,
6363 this . aesKeyLocal ,
6464 data
@@ -70,7 +70,7 @@ export class AesGcmEncryption implements ISymmetricEncryption {
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 { name : "AES-GCM" , iv } ,
7575 this . aesKeyRemote ,
7676 data
0 commit comments