Skip to content

Commit 6c8ff89

Browse files
committed
Fix send rotation broken due to incorrect types
1 parent 0555d82 commit 6c8ff89

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

libs/common/src/tools/send/services/send.service.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,9 @@ describe("SendService", () => {
477477
let encryptedKey: EncString;
478478

479479
beforeEach(() => {
480-
encryptService.unwrapSymmetricKey.mockResolvedValue(
481-
new SymmetricCryptoKey(new Uint8Array(32)),
482-
);
480+
encryptService.decryptBytes.mockResolvedValue(new Uint8Array(16));
483481
encryptedKey = new EncString("Re-encrypted Send Key");
484-
encryptService.wrapSymmetricKey.mockResolvedValue(encryptedKey);
482+
encryptService.encryptBytes.mockResolvedValue(encryptedKey);
485483
});
486484

487485
it("returns re-encrypted user sends", async () => {

libs/common/src/tools/send/services/send.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,9 @@ export class SendService implements InternalSendServiceAbstraction {
292292
) {
293293
const requests = await Promise.all(
294294
sends.map(async (send) => {
295-
const sendKey = await this.encryptService.unwrapSymmetricKey(send.key, originalUserKey);
296-
send.key = await this.encryptService.wrapSymmetricKey(sendKey, rotateUserKey);
295+
// Send key is not a key but a 16 byte seed used to derive the key
296+
const sendKey = await this.encryptService.decryptBytes(send.key, originalUserKey);
297+
send.key = await this.encryptService.encryptBytes(sendKey, rotateUserKey);
297298
return new SendWithIdRequest(send);
298299
}),
299300
);

0 commit comments

Comments
 (0)