MCPcopy
hub / github.com/slopus/happy / SecretBoxEncryption

Class SecretBoxEncryption

packages/happy-app/sources/sync/encryption/encryptor.ts:20–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20export 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
46export class BoxEncryption implements Encryptor, Decryptor {
47 private readonly privateKey: Uint8Array;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected