1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 21:50:15 +00:00

Added device on all requests and removed explicit headers

This commit is contained in:
Todd Martin
2025-02-01 18:11:36 -05:00
parent 1d712124bc
commit 69a21be347
5 changed files with 9 additions and 30 deletions

View File

@@ -20,10 +20,7 @@ export abstract class DevicesApiServiceAbstraction {
deviceKeyEncryptedDevicePrivateKey: string,
) => Promise<DeviceResponse>;
updateTrust: (
updateDevicesTrustRequestModel: UpdateDevicesTrustRequest,
deviceIdentifier: string,
) => Promise<void>;
updateTrust: (updateDevicesTrustRequestModel: UpdateDevicesTrustRequest) => Promise<void>;
getDeviceKeys: (
deviceIdentifier: string,
@@ -31,11 +28,10 @@ export abstract class DevicesApiServiceAbstraction {
) => Promise<ProtectedDeviceResponse>;
/**
* Notifies the server that the device has a device key, but didn't receive any associated decryption keys.
* Notifies the server that the current device has a device key, but didn't receive any associated decryption keys.
* Note: For debugging purposes only.
* @param deviceIdentifier - current device identifier
*/
postDeviceTrustLoss: (deviceIdentifier: string) => Promise<void>;
postDeviceTrustLoss: () => Promise<void>;
/**
* Deactivates a device

View File

@@ -5,7 +5,6 @@ import { DeviceView } from "./views/device.view";
export abstract class DevicesServiceAbstraction {
abstract getDevices$(): Observable<Array<DeviceView>>;
abstract getDeviceByIdentifier$(deviceIdentifier: string): Observable<DeviceView>;
abstract isDeviceKnownForUser$(email: string, deviceIdentifier: string): Observable<boolean>;
abstract updateTrustedDeviceKeys$(
deviceIdentifier: string,

View File

@@ -252,7 +252,7 @@ export class DeviceTrustService implements DeviceTrustServiceAbstraction {
"[Device trust rotation] Posting device trust update with current device:",
deviceIdentifier,
);
await this.devicesApiService.updateTrust(trustRequest, deviceIdentifier);
await this.devicesApiService.updateTrust(trustRequest);
this.logService.info("[Device trust rotation] Device trust update posted successfully.");
}
@@ -359,8 +359,7 @@ export class DeviceTrustService implements DeviceTrustServiceAbstraction {
}
async recordDeviceTrustLoss(): Promise<void> {
const deviceIdentifier = await this.appIdService.getAppId();
await this.devicesApiService.postDeviceTrustLoss(deviceIdentifier);
await this.devicesApiService.postDeviceTrustLoss();
}
private getSecureStorageOptions(userId: UserId): StorageOptions {

View File

@@ -73,10 +73,7 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
return new DeviceResponse(result);
}
async updateTrust(
updateDevicesTrustRequestModel: UpdateDevicesTrustRequest,
deviceIdentifier: string,
): Promise<void> {
async updateTrust(updateDevicesTrustRequestModel: UpdateDevicesTrustRequest): Promise<void> {
await this.apiService.send(
"POST",
"/devices/update-trust",
@@ -84,9 +81,6 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
true,
false,
null,
(headers) => {
headers.set("Device-Identifier", deviceIdentifier);
},
);
}
@@ -104,18 +98,8 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
return new ProtectedDeviceResponse(result);
}
async postDeviceTrustLoss(deviceIdentifier: string): Promise<void> {
await this.apiService.send(
"POST",
"/devices/lost-trust",
null,
true,
false,
null,
(headers) => {
headers.set("Device-Identifier", deviceIdentifier);
},
);
async postDeviceTrustLoss(): Promise<void> {
await this.apiService.send("POST", "/devices/lost-trust", null, true, false);
}
async deactivateDevice(deviceId: string): Promise<void> {

View File

@@ -1913,6 +1913,7 @@ export class ApiService implements ApiServiceAbstraction {
let requestBody: any = null;
const headers = new Headers({
"Device-Type": this.deviceType,
"Device-Identifier": await this.appIdService.getAppId(),
});
if (flagEnabled("prereleaseBuild")) {