diff --git a/libs/common/src/auth/abstractions/devices-api.service.abstraction.ts b/libs/common/src/auth/abstractions/devices-api.service.abstraction.ts index 9d1576ccfc6..7ab929a2c28 100644 --- a/libs/common/src/auth/abstractions/devices-api.service.abstraction.ts +++ b/libs/common/src/auth/abstractions/devices-api.service.abstraction.ts @@ -18,7 +18,10 @@ export abstract class DevicesApiServiceAbstraction { deviceKeyEncryptedDevicePrivateKey: string, ) => Promise; - updateTrust: (updateDevicesTrustRequestModel: UpdateDevicesTrustRequest) => Promise; + updateTrust: ( + updateDevicesTrustRequestModel: UpdateDevicesTrustRequest, + deviceIdentifier: string, + ) => Promise; getDeviceKeys: ( deviceIdentifier: string, diff --git a/libs/common/src/auth/services/device-trust-crypto.service.implementation.ts b/libs/common/src/auth/services/device-trust-crypto.service.implementation.ts index 8e1a8fcfff5..d03e84c704e 100644 --- a/libs/common/src/auth/services/device-trust-crypto.service.implementation.ts +++ b/libs/common/src/auth/services/device-trust-crypto.service.implementation.ts @@ -150,7 +150,7 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac trustRequest.currentDevice = currentDeviceUpdateRequest; trustRequest.otherDevices = []; - await this.devicesApiService.updateTrust(trustRequest); + await this.devicesApiService.updateTrust(trustRequest, deviceIdentifier); } async getDeviceKey(): Promise { diff --git a/libs/common/src/auth/services/device-trust-crypto.service.spec.ts b/libs/common/src/auth/services/device-trust-crypto.service.spec.ts index 54917a934d6..1093b36184c 100644 --- a/libs/common/src/auth/services/device-trust-crypto.service.spec.ts +++ b/libs/common/src/auth/services/device-trust-crypto.service.spec.ts @@ -502,7 +502,7 @@ describe("deviceTrustCryptoService", () => { await deviceTrustCryptoService.rotateDevicesTrust(fakeNewUserKey, ""); - expect(devicesApiService.updateTrust).not.toBeCalled(); + expect(devicesApiService.updateTrust).not.toHaveBeenCalled(); }); describe("is on a trusted device", () => { @@ -579,7 +579,7 @@ describe("deviceTrustCryptoService", () => { await deviceTrustCryptoService.rotateDevicesTrust(fakeNewUserKey, "my_password_hash"); - expect(devicesApiService.updateTrust).toBeCalledWith( + expect(devicesApiService.updateTrust).toHaveBeenCalledWith( matches((updateTrustModel: UpdateDevicesTrustRequest) => { return ( updateTrustModel.currentDevice.encryptedPublicKey === @@ -587,6 +587,7 @@ describe("deviceTrustCryptoService", () => { updateTrustModel.currentDevice.encryptedUserKey === "4.ZW5jcnlwdGVkdXNlcg==" ); }), + expect.stringMatching("test_device_identifier"), ); }); }); diff --git a/libs/common/src/auth/services/devices-api.service.implementation.ts b/libs/common/src/auth/services/devices-api.service.implementation.ts index f196adc50a9..50e72dcef51 100644 --- a/libs/common/src/auth/services/devices-api.service.implementation.ts +++ b/libs/common/src/auth/services/devices-api.service.implementation.ts @@ -71,13 +71,20 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac return new DeviceResponse(result); } - async updateTrust(updateDevicesTrustRequestModel: UpdateDevicesTrustRequest): Promise { + async updateTrust( + updateDevicesTrustRequestModel: UpdateDevicesTrustRequest, + deviceIdentifier: string, + ): Promise { await this.apiService.send( "POST", "/devices/update-trust", updateDevicesTrustRequestModel, true, false, + null, + (headers) => { + headers.set("X-Device-Identifier", deviceIdentifier); + }, ); }