| 18 | } |
| 19 | |
| 20 | export class SecretBoxEncryption implements Encryptor, Decryptor { |
| 21 | private readonly secretKey: Uint8Array; |
| 22 | |
| 23 | constructor(secretKey: Uint8Array) { |
| 24 | this.secretKey = secretKey; |
| 25 | } |
| 26 | |
| 27 | async decrypt(data: Uint8Array[]): Promise<(any | null)[]> { |
| 28 | // Process as batch, not Promise.all - more efficient |
| 29 | const results: (any | null)[] = []; |
| 30 | for (const item of data) { |
| 31 | results.push(decryptSecretBox(item, this.secretKey)); |
| 32 | } |
| 33 | return results; |
| 34 | } |
| 35 | |
| 36 | async encrypt(data: any[]): Promise<Uint8Array[]> { |
| 37 | // Process as batch, not Promise.all - more efficient |
| 38 | const results: Uint8Array[] = []; |
| 39 | for (const item of data) { |
| 40 | results.push(encryptSecretBox(item, this.secretKey)); |
| 41 | } |
| 42 | return results; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export class BoxEncryption implements Encryptor, Decryptor { |
| 47 | private readonly privateKey: Uint8Array; |
nothing calls this directly
no outgoing calls
no test coverage detected