1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 18:23:31 +00:00

[PM-23386] Fix fix usages of encrypt service (#15476)

* Fix incorrect usages of encrypt service

* Add docs

* Fix types
This commit is contained in:
Bernd Schoolmann
2025-07-15 11:56:19 +02:00
committed by GitHub
parent 8250e40c6c
commit d1f0c40e2f
3 changed files with 26 additions and 6 deletions

View File

@@ -296,10 +296,18 @@ export class TokenService implements TokenServiceAbstraction {
return await this.encryptService.encryptString(accessToken, accessTokenKey);
}
/**
* Decrypts the access token using the provided access token key.
*
* @param accessTokenKey - the key used to decrypt the access token
* @param encryptedAccessToken - the encrypted access token to decrypt
* @returns the decrypted access token
* @throws Error if the access token key is not provided or the decryption fails
*/
private async decryptAccessToken(
accessTokenKey: AccessTokenKey,
encryptedAccessToken: EncString,
): Promise<string | null> {
): Promise<string> {
if (!accessTokenKey) {
throw new Error(
"decryptAccessToken: Access token key required. Cannot decrypt access token.",