mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
* Adding the key definitions and tests and initial send state service * Adding the abstraction and implementing * Planning comments * Everything but fixing the send tests * Moving send tests over to the state provider * jslib needed name refactor * removing get/set encrypted sends from web vault state service * browser send state service factory * Fixing conflicts * Removing send service from services module and fixing send service observable * Commenting the migrator to be clear on why only encrypted * No need for service factories in browser * browser send service is no longer needed * Key def test cases to use toStrictEqual * Running prettier * Creating send test data to avoid code duplication * Adding state provider and account service to send in cli * Fixing the send service test cases * Fixing state definition keys * Moving to observables and implementing encryption service * Fixing key def tests * The cli was using the deprecated get method * The observables init doesn't need to happen in constructor * Missed commented out code * If enc key is null get user key * Service factory fix
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { Observable } from "rxjs";
|
|
|
|
import { EncArrayBuffer } from "../../../platform/models/domain/enc-array-buffer";
|
|
import { SymmetricCryptoKey } from "../../../platform/models/domain/symmetric-crypto-key";
|
|
import { UserKey } from "../../../types/key";
|
|
import { SendData } from "../models/data/send.data";
|
|
import { Send } from "../models/domain/send";
|
|
import { SendWithIdRequest } from "../models/request/send-with-id.request";
|
|
import { SendView } from "../models/view/send.view";
|
|
|
|
export abstract class SendService {
|
|
sends$: Observable<Send[]>;
|
|
sendViews$: Observable<SendView[]>;
|
|
|
|
encrypt: (
|
|
model: SendView,
|
|
file: File | ArrayBuffer,
|
|
password: string,
|
|
key?: SymmetricCryptoKey,
|
|
) => Promise<[Send, EncArrayBuffer]>;
|
|
/**
|
|
* Provides a send for a determined id
|
|
* updates after a change occurs to the send that matches the id
|
|
* @param id The id of the desired send
|
|
* @returns An observable that listens to the value of the desired send
|
|
*/
|
|
get$: (id: string) => Observable<Send | undefined>;
|
|
/**
|
|
* Provides re-encrypted user sends for the key rotation process
|
|
* @param newUserKey The new user key to use for re-encryption
|
|
* @throws Error if the new user key is null or undefined
|
|
* @returns A list of user sends that have been re-encrypted with the new user key
|
|
*/
|
|
getRotatedKeys: (newUserKey: UserKey) => Promise<SendWithIdRequest[]>;
|
|
/**
|
|
* @deprecated Do not call this, use the sends$ observable collection
|
|
*/
|
|
getAll: () => Promise<Send[]>;
|
|
/**
|
|
* @deprecated Only use in CLI
|
|
*/
|
|
getFromState: (id: string) => Promise<Send>;
|
|
/**
|
|
* @deprecated Only use in CLI
|
|
*/
|
|
getAllDecryptedFromState: () => Promise<SendView[]>;
|
|
}
|
|
|
|
export abstract class InternalSendService extends SendService {
|
|
upsert: (send: SendData | SendData[]) => Promise<any>;
|
|
replace: (sends: { [id: string]: SendData }) => Promise<void>;
|
|
delete: (id: string | string[]) => Promise<any>;
|
|
}
|