mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 19:23:52 +00:00
Assign ownership to many of the remaining libs/common files. Criteria for ownership: * Files used by a single team, is now owned by that team. * Files related to a domain owned by a team is now owned by that team. * Where ownership is unclear the "lowest level" service takes ownership.
32 lines
963 B
TypeScript
32 lines
963 B
TypeScript
import { AppIdService as AppIdServiceAbstraction } from "../abstractions/app-id.service";
|
|
import { AbstractStorageService } from "../abstractions/storage.service";
|
|
import { HtmlStorageLocation } from "../enums";
|
|
import { Utils } from "../misc/utils";
|
|
|
|
export class AppIdService implements AppIdServiceAbstraction {
|
|
constructor(private storageService: AbstractStorageService) {}
|
|
|
|
getAppId(): Promise<string> {
|
|
return this.makeAndGetAppId("appId");
|
|
}
|
|
|
|
getAnonymousAppId(): Promise<string> {
|
|
return this.makeAndGetAppId("anonymousAppId");
|
|
}
|
|
|
|
private async makeAndGetAppId(key: string) {
|
|
const existingId = await this.storageService.get<string>(key, {
|
|
htmlStorageLocation: HtmlStorageLocation.Local,
|
|
});
|
|
if (existingId != null) {
|
|
return existingId;
|
|
}
|
|
|
|
const guid = Utils.newGuid();
|
|
await this.storageService.save(key, guid, {
|
|
htmlStorageLocation: HtmlStorageLocation.Local,
|
|
});
|
|
return guid;
|
|
}
|
|
}
|