mirror of
https://github.com/bitwarden/browser
synced 2026-02-14 15:33:55 +00:00
PM-20532 - SendTokenSvc - wire up hash password
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { SendHashedPassword } from "../../../key-management/sends/send-password.service";
|
||||
import { SendAccessToken } from "../models/send-access-token";
|
||||
import { SendTokenRetrievalError } from "../services/send-token.service";
|
||||
|
||||
@@ -5,7 +6,7 @@ export type SendAccessCredentialsType = "password" | "email-otp";
|
||||
|
||||
export type SendPasswordCredentials = {
|
||||
type: "password";
|
||||
password: string;
|
||||
password: SendHashedPassword;
|
||||
};
|
||||
export type SendEmailOtpCredentials = {
|
||||
type: "email-otp";
|
||||
@@ -14,6 +15,7 @@ export type SendEmailOtpCredentials = {
|
||||
};
|
||||
export type SendAccessCredentials = SendPasswordCredentials | SendEmailOtpCredentials;
|
||||
|
||||
// TODO: add JSdocs
|
||||
export abstract class SendTokenService {
|
||||
// SendAccessTokens need to be stored in session storage once retrieved.
|
||||
// All SendAccessTokens are scoped to a specific send id so all getting and setting should accept a send id.
|
||||
@@ -37,4 +39,15 @@ export abstract class SendTokenService {
|
||||
sendId: string,
|
||||
sendAccessCredentials: SendAccessCredentials,
|
||||
) => Promise<void>;
|
||||
|
||||
/**
|
||||
* Hashes a password for send access.
|
||||
* @param password The raw password string to hash.
|
||||
* @param keyMaterialUrlB64 The base64 URL encoded key material string.
|
||||
* @returns A promise that resolves to the hashed password as a SendHashedPassword.
|
||||
*/
|
||||
abstract hashPassword: (
|
||||
password: string,
|
||||
keyMaterialUrlB64: string,
|
||||
) => Promise<SendHashedPassword>;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import { Jsonify } from "type-fest";
|
||||
|
||||
import {
|
||||
SendHashedPassword,
|
||||
SendPasswordService,
|
||||
} from "../../../key-management/sends/send-password.service";
|
||||
import {
|
||||
GlobalState,
|
||||
GlobalStateProvider,
|
||||
@@ -16,6 +20,9 @@ import { SendAccessToken } from "../models/send-access-token";
|
||||
|
||||
import { SendTokenApiRetrievalError, SendTokenApiService } from "./send-token-api.service";
|
||||
|
||||
// TODO: add JSDocs
|
||||
// TODO: add tests for this service.
|
||||
|
||||
export const SEND_ACCESS_TOKEN_DICT = KeyDefinition.record<SendAccessToken, string>(
|
||||
SEND_ACCESS_DISK,
|
||||
"accessTokenDict",
|
||||
@@ -34,6 +41,7 @@ export class SendTokenService implements SendTokenServiceAbstraction {
|
||||
constructor(
|
||||
private globalStateProvider: GlobalStateProvider,
|
||||
private sendTokenApiService: SendTokenApiService,
|
||||
private sendPasswordService: SendPasswordService,
|
||||
) {
|
||||
this.initializeState();
|
||||
}
|
||||
@@ -83,6 +91,10 @@ export class SendTokenService implements SendTokenServiceAbstraction {
|
||||
// const result = await this.sendTokenApiService.requestSendAccessToken(request);
|
||||
}
|
||||
|
||||
async hashPassword(password: string, keyMaterialUrlB64: string): Promise<SendHashedPassword> {
|
||||
return this.sendPasswordService.hashPassword(password, keyMaterialUrlB64);
|
||||
}
|
||||
|
||||
private async getSendAccessTokenFromStorage(
|
||||
sendId: string,
|
||||
): Promise<SendAccessToken | undefined> {
|
||||
|
||||
Reference in New Issue
Block a user