mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 05:00:10 +00:00
tmp
This commit is contained in:
@@ -139,7 +139,7 @@ export class LocalBackedSessionStorageService
|
||||
}
|
||||
|
||||
const valueJson = JSON.stringify(value);
|
||||
const encValue = await this.encryptService.encrypt(valueJson, await this.sessionKey.get());
|
||||
const encValue = await this.encryptService.encryptString(valueJson, await this.sessionKey.get());
|
||||
await this.localStorage.save(this.sessionStorageKey(key), encValue.encryptedString);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ export class EditCommand {
|
||||
(u) => new SelectionReadOnlyRequest(u.id, u.readOnly, u.hidePasswords, u.manage),
|
||||
);
|
||||
const request = new CollectionRequest();
|
||||
request.name = (await this.encryptService.encrypt(req.name, orgKey)).encryptedString;
|
||||
request.name = (await this.encryptService.encryptString(req.name, orgKey)).encryptedString;
|
||||
request.externalId = req.externalId;
|
||||
request.groups = groups;
|
||||
request.users = users;
|
||||
|
||||
@@ -227,7 +227,7 @@ export class CreateCommand {
|
||||
(u) => new SelectionReadOnlyRequest(u.id, u.readOnly, u.hidePasswords, u.manage),
|
||||
);
|
||||
const request = new CollectionRequest();
|
||||
request.name = (await this.encryptService.encrypt(req.name, orgKey)).encryptedString;
|
||||
request.name = (await this.encryptService.encryptString(req.name, orgKey)).encryptedString;
|
||||
request.externalId = req.externalId;
|
||||
request.groups = groups;
|
||||
request.users = users;
|
||||
|
||||
@@ -220,7 +220,7 @@ export default class NativeMessageService {
|
||||
|
||||
const sharedKey = await this.getSharedKeyForKey(key);
|
||||
|
||||
return this.encryptService.encrypt(commandDataString, sharedKey);
|
||||
return this.encryptService.encryptString(commandDataString, sharedKey);
|
||||
}
|
||||
|
||||
private async decryptResponsePayload(
|
||||
|
||||
@@ -110,7 +110,7 @@ export class ElectronKeyService extends DefaultKeyService {
|
||||
// Set a key half if it doesn't exist
|
||||
const keyBytes = await this.cryptoFunctionService.randomBytes(32);
|
||||
clientKeyHalf = Utils.fromBufferToUtf8(keyBytes) as CsprngString;
|
||||
const encKey = await this.encryptService.encrypt(clientKeyHalf, userKey);
|
||||
const encKey = await this.encryptService.encryptString(clientKeyHalf, userKey);
|
||||
await this.biometricStateService.setEncryptedClientKeyHalf(encKey, userId);
|
||||
}
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ export class BiometricMessageHandlerService {
|
||||
throw new Error("Session secret is missing");
|
||||
}
|
||||
|
||||
const encrypted = await this.encryptService.encrypt(
|
||||
const encrypted = await this.encryptService.encryptString(
|
||||
JSON.stringify(message),
|
||||
SymmetricCryptoKey.fromString(sessionSecret),
|
||||
);
|
||||
|
||||
@@ -168,7 +168,7 @@ export class DuckDuckGoMessageHandlerService {
|
||||
payload: DecryptedCommandData,
|
||||
key: SymmetricCryptoKey,
|
||||
): Promise<EncString> {
|
||||
return await this.encryptService.encrypt(JSON.stringify(payload), key);
|
||||
return await this.encryptService.encryptString(JSON.stringify(payload), key);
|
||||
}
|
||||
|
||||
private async decryptPayload(message: EncryptedMessage): Promise<DecryptedCommandData> {
|
||||
|
||||
@@ -112,7 +112,7 @@ export class OrganizationUserResetPasswordService
|
||||
if (orgSymKey == null) {
|
||||
throw new Error("No org key found");
|
||||
}
|
||||
const decPrivateKey = await this.encryptService.decryptToBytes(
|
||||
const decPrivateKey = await this.encryptService.unwrapDecapsulationKey(
|
||||
new EncString(response.encryptedPrivateKey),
|
||||
orgSymKey,
|
||||
);
|
||||
|
||||
@@ -145,7 +145,7 @@ export class AcceptOrganizationInviteService {
|
||||
|
||||
const [encryptedOrgKey, orgKey] = await this.keyService.makeOrgKey<OrgKey>();
|
||||
const [orgPublicKey, encryptedOrgPrivateKey] = await this.keyService.makeKeyPair(orgKey);
|
||||
const collection = await this.encryptService.encrypt(
|
||||
const collection = await this.encryptService.encryptString(
|
||||
this.i18nService.t("defaultCollection"),
|
||||
orgKey,
|
||||
);
|
||||
|
||||
@@ -626,7 +626,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
||||
if (this.createOrganization) {
|
||||
const orgKey = await this.keyService.makeOrgKey<OrgKey>();
|
||||
const key = orgKey[0].encryptedString;
|
||||
const collection = await this.encryptService.encrypt(
|
||||
const collection = await this.encryptService.encryptString(
|
||||
this.i18nService.t("defaultCollection"),
|
||||
orgKey[1],
|
||||
);
|
||||
|
||||
@@ -51,7 +51,7 @@ export class OrganizationSelfHostingLicenseUploaderComponent extends AbstractSel
|
||||
|
||||
const orgKey = await this.keyService.makeOrgKey<OrgKey>();
|
||||
const key = orgKey[0].encryptedString;
|
||||
const collection = await this.encryptService.encrypt(
|
||||
const collection = await this.encryptService.encryptString(
|
||||
this.i18nService.t("defaultCollection"),
|
||||
orgKey[1],
|
||||
);
|
||||
|
||||
@@ -74,7 +74,7 @@ export class WebProviderService {
|
||||
|
||||
const [publicKey, encryptedPrivateKey] = await this.keyService.makeKeyPair(organizationKey);
|
||||
|
||||
const encryptedCollectionName = await this.encryptService.encrypt(
|
||||
const encryptedCollectionName = await this.encryptService.encryptString(
|
||||
this.i18nService.t("defaultCollection"),
|
||||
organizationKey,
|
||||
);
|
||||
|
||||
@@ -93,7 +93,7 @@ export class ProjectService {
|
||||
): Promise<ProjectRequest> {
|
||||
const orgKey = await this.getOrganizationKey(organizationId);
|
||||
const request = new ProjectRequest();
|
||||
request.name = await this.encryptService.encrypt(projectView.name, orgKey);
|
||||
request.name = await this.encryptService.encryptStringprojectView.name, orgKey);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
@@ -102,12 +102,12 @@ export class AccessService {
|
||||
const organizationKey = await this.getOrganizationKey(organizationId);
|
||||
const accessTokenRequest = new AccessTokenRequest();
|
||||
const [name, encryptedPayload, key] = await Promise.all([
|
||||
await this.encryptService.encrypt(accessTokenView.name, organizationKey),
|
||||
await this.encryptService.encrypt(
|
||||
await this.encryptService.encryptString(accessTokenView.name, organizationKey),
|
||||
await this.encryptService.encryptString(
|
||||
JSON.stringify({ encryptionKey: organizationKey.keyB64 }),
|
||||
encryptionKey,
|
||||
),
|
||||
await this.encryptService.encrypt(encryptionKey.keyB64, organizationKey),
|
||||
await this.encryptService.encryptString(encryptionKey.keyB64, organizationKey),
|
||||
]);
|
||||
|
||||
accessTokenRequest.name = name;
|
||||
|
||||
@@ -130,7 +130,7 @@ export class ServiceAccountService {
|
||||
serviceAccountView: ServiceAccountView,
|
||||
) {
|
||||
const request = new ServiceAccountRequest();
|
||||
request.name = await this.encryptService.encrypt(serviceAccountView.name, organizationKey);
|
||||
request.name = await this.encryptService.encryptStringserviceAccountView.name, organizationKey);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ export class SecretsManagerPortingApiService {
|
||||
importData.projects.map(async (p: any) => {
|
||||
const project = new SecretsManagerImportedProjectRequest();
|
||||
project.id = p.id;
|
||||
project.name = await this.encryptService.encrypt(p.name, orgKey);
|
||||
project.name = await this.encryptService.encryptString(p.name, orgKey);
|
||||
return project;
|
||||
}),
|
||||
);
|
||||
@@ -96,9 +96,9 @@ export class SecretsManagerPortingApiService {
|
||||
const secret = new SecretsManagerImportedSecretRequest();
|
||||
|
||||
[secret.key, secret.value, secret.note] = await Promise.all([
|
||||
this.encryptService.encrypt(s.key, orgKey),
|
||||
this.encryptService.encrypt(s.value, orgKey),
|
||||
this.encryptService.encrypt(s.note, orgKey),
|
||||
this.encryptService.encryptString(s.key, orgKey),
|
||||
this.encryptService.encryptString(s.value, orgKey),
|
||||
this.encryptService.encryptString(s.note, orgKey),
|
||||
]);
|
||||
|
||||
secret.id = s.id;
|
||||
|
||||
@@ -45,11 +45,11 @@ export abstract class EncryptService {
|
||||
* @deprecated
|
||||
* @returns The decrypted Uint8Array
|
||||
*/
|
||||
abstract decryptToBytes(
|
||||
encThing: Encrypted,
|
||||
key: SymmetricCryptoKey,
|
||||
decryptTrace?: string,
|
||||
): Promise<Uint8Array | null>;
|
||||
// abstract decryptToBytes(
|
||||
// encThing: Encrypted,
|
||||
// key: SymmetricCryptoKey,
|
||||
// decryptTrace?: string,
|
||||
// ): Promise<Uint8Array | null>;
|
||||
/**
|
||||
* @deprecated Replaced by BulkEncryptService, remove once the feature is tested and the featureflag PM-4154-multi-worker-encryption-service is removed
|
||||
* @param items The items to decrypt
|
||||
|
||||
@@ -552,9 +552,11 @@ describe("keyService", () => {
|
||||
}
|
||||
|
||||
encryptService.unwrapDecapsulationKey.mockImplementation((encryptedPrivateKey, userKey) => {
|
||||
// TOOD: Branch between provider and private key?
|
||||
return Promise.resolve(fakePrivateKeyDecryption(encryptedPrivateKey, userKey));
|
||||
});
|
||||
encryptService.unwrapSymmetricKey.mockImplementation((encryptedPrivateKey, userKey) => {
|
||||
return Promise.resolve(new SymmetricCryptoKey(new Uint8Array(64)));
|
||||
});
|
||||
|
||||
encryptService.decapsulateKeyUnsigned.mockImplementation((data, privateKey) => {
|
||||
return Promise.resolve(new SymmetricCryptoKey(fakeOrgKeyDecryption(data, privateKey)));
|
||||
@@ -646,7 +648,7 @@ describe("keyService", () => {
|
||||
|
||||
const org2Key = decryptionKeys!.orgKeys![org2Id];
|
||||
expect(org2Key).not.toBeNull();
|
||||
expect(org2Key.keyB64).toContain("provider1Key");
|
||||
expect(org2Key.toEncoded()).toHaveLength(64);
|
||||
});
|
||||
|
||||
it("returns a stream that pays attention to updates of all data", async () => {
|
||||
|
||||
Reference in New Issue
Block a user