[PM-6012] Added device identifier header when updating trust on key rotation (#7807)
This commit is contained in:
parent
25711afaf6
commit
250e7c87e8
|
@ -18,7 +18,10 @@ export abstract class DevicesApiServiceAbstraction {
|
|||
deviceKeyEncryptedDevicePrivateKey: string,
|
||||
) => Promise<DeviceResponse>;
|
||||
|
||||
updateTrust: (updateDevicesTrustRequestModel: UpdateDevicesTrustRequest) => Promise<void>;
|
||||
updateTrust: (
|
||||
updateDevicesTrustRequestModel: UpdateDevicesTrustRequest,
|
||||
deviceIdentifier: string,
|
||||
) => Promise<void>;
|
||||
|
||||
getDeviceKeys: (
|
||||
deviceIdentifier: string,
|
||||
|
|
|
@ -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<DeviceKey> {
|
||||
|
|
|
@ -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"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -71,13 +71,20 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
|||
return new DeviceResponse(result);
|
||||
}
|
||||
|
||||
async updateTrust(updateDevicesTrustRequestModel: UpdateDevicesTrustRequest): Promise<void> {
|
||||
async updateTrust(
|
||||
updateDevicesTrustRequestModel: UpdateDevicesTrustRequest,
|
||||
deviceIdentifier: string,
|
||||
): Promise<void> {
|
||||
await this.apiService.send(
|
||||
"POST",
|
||||
"/devices/update-trust",
|
||||
updateDevicesTrustRequestModel,
|
||||
true,
|
||||
false,
|
||||
null,
|
||||
(headers) => {
|
||||
headers.set("X-Device-Identifier", deviceIdentifier);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue