mirror of
https://github.com/bitwarden/browser
synced 2026-02-22 04:14:04 +00:00
Replace uses of encstring with unsigned shared key
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { UnsignedSharedKey } from "@bitwarden/sdk-internal";
|
||||
|
||||
export type EncryptedOrganizationKeyData =
|
||||
| OrganizationEncryptedOrganizationKeyData
|
||||
| ProviderEncryptedOrganizationKeyData;
|
||||
|
||||
type OrganizationEncryptedOrganizationKeyData = {
|
||||
type: "organization";
|
||||
key: string;
|
||||
key: UnsignedSharedKey;
|
||||
};
|
||||
|
||||
type ProviderEncryptedOrganizationKeyData = {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { UnsignedSharedKey } from "@bitwarden/sdk-internal";
|
||||
|
||||
import { EncryptService } from "../../../key-management/crypto/abstractions/encrypt.service";
|
||||
import { EncString } from "../../../key-management/crypto/models/enc-string";
|
||||
import { SymmetricCryptoKey } from "../../../platform/models/domain/symmetric-crypto-key";
|
||||
@@ -5,15 +7,15 @@ import { OrgKey, UserPrivateKey } from "../../../types/key";
|
||||
import { EncryptedOrganizationKeyData } from "../data/encrypted-organization-key.data";
|
||||
|
||||
export abstract class BaseEncryptedOrganizationKey {
|
||||
abstract get encryptedOrganizationKey(): EncString;
|
||||
abstract get encryptedOrganizationKey(): UnsignedSharedKey;
|
||||
|
||||
static fromData(data: EncryptedOrganizationKeyData) {
|
||||
switch (data.type) {
|
||||
case "organization":
|
||||
return new EncryptedOrganizationKey(data.key);
|
||||
return new EncryptedOrganizationKey(data.key as UnsignedSharedKey);
|
||||
|
||||
case "provider":
|
||||
return new ProviderEncryptedOrganizationKey(data.key, data.providerId);
|
||||
return new ProviderEncryptedOrganizationKey(data.key as UnsignedSharedKey, data.providerId);
|
||||
|
||||
default:
|
||||
return null;
|
||||
@@ -28,7 +30,7 @@ export abstract class BaseEncryptedOrganizationKey {
|
||||
}
|
||||
|
||||
export class EncryptedOrganizationKey implements BaseEncryptedOrganizationKey {
|
||||
constructor(private key: string) {}
|
||||
constructor(private key: UnsignedSharedKey) {}
|
||||
|
||||
async decrypt(encryptService: EncryptService, privateKey: UserPrivateKey) {
|
||||
return (await encryptService.decapsulateKeyUnsigned(
|
||||
@@ -38,7 +40,7 @@ export class EncryptedOrganizationKey implements BaseEncryptedOrganizationKey {
|
||||
}
|
||||
|
||||
get encryptedOrganizationKey() {
|
||||
return new EncString(this.key);
|
||||
return this.key;
|
||||
}
|
||||
|
||||
toData(): EncryptedOrganizationKeyData {
|
||||
@@ -51,7 +53,7 @@ export class EncryptedOrganizationKey implements BaseEncryptedOrganizationKey {
|
||||
|
||||
export class ProviderEncryptedOrganizationKey implements BaseEncryptedOrganizationKey {
|
||||
constructor(
|
||||
private key: string,
|
||||
private key: UnsignedSharedKey,
|
||||
private providerId: string,
|
||||
) {}
|
||||
|
||||
@@ -67,7 +69,7 @@ export class ProviderEncryptedOrganizationKey implements BaseEncryptedOrganizati
|
||||
}
|
||||
|
||||
get encryptedOrganizationKey() {
|
||||
return new EncString(this.key);
|
||||
return this.key;
|
||||
}
|
||||
|
||||
toData(): EncryptedOrganizationKeyData {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
|
||||
import { UnsignedSharedKey } from "@bitwarden/sdk-internal";
|
||||
|
||||
// @ts-strict-ignore
|
||||
interface TokenizedPaymentMethod {
|
||||
type: "bankAccount" | "card" | "payPal";
|
||||
@@ -20,7 +23,7 @@ export class ProviderSetupRequest {
|
||||
businessName: string;
|
||||
billingEmail: string;
|
||||
token: string;
|
||||
key: string;
|
||||
key: UnsignedSharedKey;
|
||||
paymentMethod: TokenizedPaymentMethod;
|
||||
billingAddress: BillingAddress;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { UnsignedSharedKey } from "@bitwarden/sdk-internal";
|
||||
|
||||
import { MemberDecryptionType } from "../../../auth/enums/sso";
|
||||
import { ProductTierType } from "../../../billing/enums";
|
||||
import { BaseResponse } from "../../../models/response/base.response";
|
||||
@@ -29,7 +31,7 @@ export class ProfileOrganizationResponse extends BaseResponse {
|
||||
seats: number;
|
||||
maxCollections: number;
|
||||
maxStorageGb?: number;
|
||||
key: string;
|
||||
key: UnsignedSharedKey;
|
||||
hasPublicAndPrivateKeys: boolean;
|
||||
status: OrganizationUserStatusType;
|
||||
type: OrganizationUserType;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { UnsignedSharedKey } from "@bitwarden/sdk-internal";
|
||||
|
||||
import { BaseResponse } from "../../../models/response/base.response";
|
||||
import {
|
||||
ProviderStatusType,
|
||||
@@ -10,7 +12,7 @@ import { PermissionsApi } from "../api/permissions.api";
|
||||
export class ProfileProviderResponse extends BaseResponse {
|
||||
id: string;
|
||||
name: string;
|
||||
key: string;
|
||||
key: UnsignedSharedKey;
|
||||
status: ProviderUserStatusType;
|
||||
type: ProviderUserType;
|
||||
enabled: boolean;
|
||||
|
||||
Reference in New Issue
Block a user