1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-18 18:33:50 +00:00

feat(tokens): Allow Inactive user authenticated API calls

This commit is contained in:
Justin Baur
2025-09-03 10:09:02 -04:00
committed by GitHub
parent bcd7eb746a
commit 73e8532ecc
15 changed files with 406 additions and 362 deletions

View File

@@ -1,22 +1,21 @@
import { ApiService } from "../../../abstractions/api.service";
import { TokenService } from "../../../auth/abstractions/token.service";
import { UserId } from "../../../types/guid";
import { ConfigApiServiceAbstraction } from "../../abstractions/config/config-api.service.abstraction";
import { ServerConfigResponse } from "../../models/response/server-config.response";
export class ConfigApiService implements ConfigApiServiceAbstraction {
constructor(
private apiService: ApiService,
private tokenService: TokenService,
) {}
constructor(private apiService: ApiService) {}
async get(userId: UserId | null): Promise<ServerConfigResponse> {
// Authentication adds extra context to config responses, if the user has an access token, we want to use it
// We don't particularly care about ensuring the token is valid and not expired, just that it exists
const authed: boolean =
userId == null ? false : (await this.tokenService.getAccessToken(userId)) != null;
let r: any;
if (userId == null) {
r = await this.apiService.send("GET", "/config", null, false, true);
} else {
r = await this.apiService.send("GET", "/config", null, userId, true);
}
const r = await this.apiService.send("GET", "/config", null, authed, true);
return new ServerConfigResponse(r);
}
}