mirror of
https://github.com/bitwarden/browser
synced 2026-02-11 05:53:42 +00:00
Merge branch 'main' into billing/pm-29602/build-upgrade-dialogs
This commit is contained in:
@@ -1110,6 +1110,7 @@ export default class MainBackground {
|
||||
this.logService,
|
||||
this.platformUtilsService,
|
||||
this.configService,
|
||||
this.sdkService,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -928,6 +928,7 @@ export class ServiceContainer {
|
||||
this.logService,
|
||||
this.platformUtilsService,
|
||||
this.configService,
|
||||
this.sdkService,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { EncString } from "@bitwarden/sdk-internal";
|
||||
|
||||
export class OrganizationUserBulkRestoreRequest {
|
||||
userIds: string[];
|
||||
ids: string[];
|
||||
defaultUserCollectionName: EncString | undefined;
|
||||
|
||||
constructor(userIds: string[], defaultUserCollectionName?: EncString) {
|
||||
this.userIds = userIds;
|
||||
constructor(ids: string[], defaultUserCollectionName?: EncString) {
|
||||
this.ids = ids;
|
||||
this.defaultUserCollectionName = defaultUserCollectionName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ describe("DefaultOrganizationUserService", () => {
|
||||
).toHaveBeenCalledWith(
|
||||
mockOrganization.id,
|
||||
expect.objectContaining({
|
||||
userIds: mockUserIds,
|
||||
ids: mockUserIds,
|
||||
defaultUserCollectionName: mockEncryptedCollectionName.encryptedString,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CsprngArray } from "../../../types/csprng";
|
||||
|
||||
export abstract class CryptoFunctionService {
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract pbkdf2(
|
||||
@@ -17,7 +17,7 @@ export abstract class CryptoFunctionService {
|
||||
iterations: number,
|
||||
): Promise<Uint8Array>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract hkdf(
|
||||
@@ -28,7 +28,7 @@ export abstract class CryptoFunctionService {
|
||||
algorithm: "sha256" | "sha512",
|
||||
): Promise<Uint8Array>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract hkdfExpand(
|
||||
@@ -38,7 +38,7 @@ export abstract class CryptoFunctionService {
|
||||
algorithm: "sha256" | "sha512",
|
||||
): Promise<Uint8Array>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract hash(
|
||||
@@ -46,7 +46,7 @@ export abstract class CryptoFunctionService {
|
||||
algorithm: "sha1" | "sha256" | "sha512" | "md5",
|
||||
): Promise<Uint8Array>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract hmacFast(
|
||||
@@ -56,7 +56,7 @@ export abstract class CryptoFunctionService {
|
||||
): Promise<Uint8Array | string>;
|
||||
abstract compareFast(a: Uint8Array | string, b: Uint8Array | string): Promise<boolean>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract aesDecryptFastParameters(
|
||||
@@ -66,7 +66,7 @@ export abstract class CryptoFunctionService {
|
||||
key: SymmetricCryptoKey,
|
||||
): CbcDecryptParameters<Uint8Array | string>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract aesDecryptFast({
|
||||
@@ -76,7 +76,7 @@ export abstract class CryptoFunctionService {
|
||||
| { mode: "cbc"; parameters: CbcDecryptParameters<Uint8Array | string> }
|
||||
| { mode: "ecb"; parameters: EcbDecryptParameters<Uint8Array | string> }): Promise<string>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Only used by DDG integration until DDG uses PKCS#7 padding, and by lastpass importer.
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Only used by DDG integration until DDG uses PKCS#7 padding, and by lastpass importer.
|
||||
*/
|
||||
abstract aesDecrypt(
|
||||
data: Uint8Array,
|
||||
@@ -85,7 +85,7 @@ export abstract class CryptoFunctionService {
|
||||
mode: "cbc" | "ecb",
|
||||
): Promise<Uint8Array>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract rsaEncrypt(
|
||||
@@ -94,7 +94,7 @@ export abstract class CryptoFunctionService {
|
||||
algorithm: "sha1",
|
||||
): Promise<Uint8Array>;
|
||||
/**
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. Implement low-level crypto operations
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. Implement low-level crypto operations
|
||||
* in the SDK instead. Further, you should probably never find yourself using this low-level crypto function.
|
||||
*/
|
||||
abstract rsaDecrypt(
|
||||
|
||||
@@ -27,7 +27,7 @@ export abstract class KeyGenerationService {
|
||||
* Uses HKDF, see {@link https://datatracker.ietf.org/doc/html/rfc5869 RFC 5869}
|
||||
* for details.
|
||||
*
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. This is a low-level cryptographic function.
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. This is a low-level cryptographic function.
|
||||
* New functionality should not be built on top of it, and instead should be built in the sdk.
|
||||
*
|
||||
* @param bitLength Length of key material.
|
||||
@@ -44,7 +44,7 @@ export abstract class KeyGenerationService {
|
||||
/**
|
||||
* Derives a 64 byte key from key material.
|
||||
*
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. This is a low-level cryptographic function.
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. This is a low-level cryptographic function.
|
||||
* New functionality should not be built on top of it, and instead should be built in the sdk.
|
||||
*
|
||||
* @remark The key material should be generated from {@link createKey}, or {@link createKeyWithPurpose}.
|
||||
@@ -63,7 +63,7 @@ export abstract class KeyGenerationService {
|
||||
/**
|
||||
* Derives a 32 byte key from a password using a key derivation function.
|
||||
*
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. This is a low-level cryptographic function.
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. This is a low-level cryptographic function.
|
||||
* New functionality should not be built on top of it, and instead should be built in the sdk.
|
||||
*
|
||||
* @param password Password to derive the key from.
|
||||
@@ -80,7 +80,7 @@ export abstract class KeyGenerationService {
|
||||
/**
|
||||
* Derives a 64 byte key from a 32 byte key using a key derivation function.
|
||||
*
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. This is a low-level cryptographic function.
|
||||
* @deprecated HAZMAT WARNING: DO NOT USE THIS FOR NEW CODE. CONTACT KEY MANAGEMENT IF YOU THINK YOU NEED TO. This is a low-level cryptographic function.
|
||||
* New functionality should not be built on top of it, and instead should be built in the sdk.
|
||||
*
|
||||
* @param key 32 byte key.
|
||||
|
||||
@@ -4,6 +4,7 @@ import { PolicyService } from "../admin-console/abstractions/policy/policy.servi
|
||||
import { ConfigService } from "../platform/abstractions/config/config.service";
|
||||
import { LogService } from "../platform/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "../platform/abstractions/platform-utils.service";
|
||||
import { SdkService } from "../platform/abstractions/sdk/sdk.service";
|
||||
import { StateProvider } from "../platform/state";
|
||||
|
||||
import { LegacyEncryptorProvider } from "./cryptography/legacy-encryptor-provider";
|
||||
@@ -20,6 +21,7 @@ describe("SystemServiceProvider", () => {
|
||||
let mockLogger: LogService;
|
||||
let mockEnvironment: MockProxy<PlatformUtilsService>;
|
||||
let mockConfigService: ConfigService;
|
||||
let mockSdkService: SdkService;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
@@ -31,6 +33,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger = mock<LogService>();
|
||||
mockEnvironment = mock<PlatformUtilsService>();
|
||||
mockConfigService = mock<ConfigService>();
|
||||
mockSdkService = mock<SdkService>();
|
||||
});
|
||||
|
||||
describe("createSystemServiceProvider", () => {
|
||||
@@ -45,6 +48,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(result).toHaveProperty("policy", mockPolicy);
|
||||
@@ -66,6 +70,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(result.extension).toBeInstanceOf(ExtensionService);
|
||||
@@ -83,6 +88,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(mockEnvironment.isDev).toHaveBeenCalledTimes(1);
|
||||
@@ -102,6 +108,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(mockEnvironment.isDev).toHaveBeenCalledTimes(1);
|
||||
@@ -121,6 +128,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(result.extension).toBeInstanceOf(ExtensionService);
|
||||
@@ -138,6 +146,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(result.policy).toBe(mockPolicy);
|
||||
@@ -154,6 +163,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(result.configService).toBe(mockConfigService);
|
||||
@@ -170,6 +180,7 @@ describe("SystemServiceProvider", () => {
|
||||
mockLogger,
|
||||
mockEnvironment,
|
||||
mockConfigService,
|
||||
mockSdkService,
|
||||
);
|
||||
|
||||
expect(result.environment).toBe(mockEnvironment);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { LogService } from "@bitwarden/logging";
|
||||
import { BitwardenClient } from "@bitwarden/sdk-internal";
|
||||
import { StateProvider } from "@bitwarden/state";
|
||||
|
||||
import { PolicyService } from "../admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { ConfigService } from "../platform/abstractions/config/config.service";
|
||||
import { PlatformUtilsService } from "../platform/abstractions/platform-utils.service";
|
||||
import { SdkService } from "../platform/abstractions/sdk/sdk.service";
|
||||
|
||||
import { LegacyEncryptorProvider } from "./cryptography/legacy-encryptor-provider";
|
||||
import { ExtensionRegistry } from "./extension/extension-registry.abstraction";
|
||||
@@ -29,7 +29,7 @@ export type SystemServiceProvider = {
|
||||
readonly environment: PlatformUtilsService;
|
||||
|
||||
/** SDK Service */
|
||||
readonly sdk?: BitwardenClient;
|
||||
readonly sdk: SdkService;
|
||||
};
|
||||
|
||||
/** Constructs a system service provider. */
|
||||
@@ -41,6 +41,7 @@ export function createSystemServiceProvider(
|
||||
logger: LogService,
|
||||
environment: PlatformUtilsService,
|
||||
configService: ConfigService,
|
||||
sdk: SdkService,
|
||||
): SystemServiceProvider {
|
||||
let log: LogProvider;
|
||||
if (environment.isDev()) {
|
||||
@@ -62,5 +63,6 @@ export function createSystemServiceProvider(
|
||||
log,
|
||||
configService,
|
||||
environment,
|
||||
sdk,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { ConfigService } from "@bitwarden/common/platform/abstractions/config/co
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||
import { KeyServiceLegacyEncryptorProvider } from "@bitwarden/common/tools/cryptography/key-service-legacy-encryptor-provider";
|
||||
import { LegacyEncryptorProvider } from "@bitwarden/common/tools/cryptography/legacy-encryptor-provider";
|
||||
import { ExtensionRegistry } from "@bitwarden/common/tools/extension/extension-registry.abstraction";
|
||||
@@ -71,6 +72,7 @@ export const ImporterProviders: SafeProvider[] = [
|
||||
LogService,
|
||||
PlatformUtilsService,
|
||||
ConfigService,
|
||||
SdkService,
|
||||
],
|
||||
}),
|
||||
safeProvider({
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
import { from, take } from "rxjs";
|
||||
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { safeProvider } from "@bitwarden/angular/platform/utils/safe-provider";
|
||||
import { SafeInjectionToken } from "@bitwarden/angular/services/injection-tokens";
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { EncryptService } from "@bitwarden/common/key-management/crypto/abstractions/encrypt.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
@@ -126,7 +124,7 @@ export const SYSTEM_SERVICE_PROVIDER = new SafeInjectionToken<SystemServiceProvi
|
||||
}),
|
||||
safeProvider({
|
||||
provide: GENERATOR_SERVICE_PROVIDER,
|
||||
useFactory: (
|
||||
useFactory: async (
|
||||
system: SystemServiceProvider,
|
||||
random: Randomizer,
|
||||
encryptor: LegacyEncryptorProvider,
|
||||
@@ -141,25 +139,19 @@ export const SYSTEM_SERVICE_PROVIDER = new SafeInjectionToken<SystemServiceProvi
|
||||
now: Date.now,
|
||||
} satisfies UserStateSubjectDependencyProvider;
|
||||
|
||||
const featureFlagObs$ = from(
|
||||
system.configService.getFeatureFlag(FeatureFlag.UseSdkPasswordGenerators),
|
||||
);
|
||||
let featureFlag: boolean = false;
|
||||
featureFlagObs$.pipe(take(1)).subscribe((ff) => (featureFlag = ff));
|
||||
const metadata = new providers.GeneratorMetadataProvider(
|
||||
userStateDeps,
|
||||
system,
|
||||
Object.values(BuiltIn),
|
||||
);
|
||||
|
||||
const sdkService = featureFlag ? system.sdk : undefined;
|
||||
const profile = new providers.GeneratorProfileProvider(userStateDeps, system.policy);
|
||||
|
||||
const generator: providers.GeneratorDependencyProvider = {
|
||||
randomizer: random,
|
||||
client: new RestClient(api, i18n),
|
||||
i18nService: i18n,
|
||||
sdk: sdkService,
|
||||
sdk: system.sdk,
|
||||
now: Date.now,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||
import {
|
||||
BitwardenClient,
|
||||
PassphraseGeneratorRequest,
|
||||
@@ -20,11 +23,11 @@ export class SdkPasswordRandomizer
|
||||
CredentialGenerator<PasswordGenerationOptions>
|
||||
{
|
||||
/** Instantiates the password randomizer
|
||||
* @param client access to SDK client to call upon password/passphrase generation
|
||||
* @param service access to SDK client to call upon password/passphrase generation
|
||||
* @param currentTime gets the current datetime in epoch time
|
||||
*/
|
||||
constructor(
|
||||
private client: BitwardenClient,
|
||||
private service: SdkService,
|
||||
private currentTime: () => number,
|
||||
) {}
|
||||
|
||||
@@ -40,8 +43,9 @@ export class SdkPasswordRandomizer
|
||||
request: GenerateRequest,
|
||||
settings: PasswordGenerationOptions | PassphraseGenerationOptions,
|
||||
) {
|
||||
const sdk: BitwardenClient = await firstValueFrom(this.service.client$);
|
||||
if (isPasswordGenerationOptions(settings)) {
|
||||
const password = await this.client.generator().password(convertPasswordRequest(settings));
|
||||
const password = await sdk.generator().password(convertPasswordRequest(settings));
|
||||
|
||||
return new GeneratedCredential(
|
||||
password,
|
||||
@@ -51,9 +55,7 @@ export class SdkPasswordRandomizer
|
||||
request.website,
|
||||
);
|
||||
} else if (isPassphraseGenerationOptions(settings)) {
|
||||
const passphrase = await this.client
|
||||
.generator()
|
||||
.passphrase(convertPassphraseRequest(settings));
|
||||
const passphrase = await sdk.generator().passphrase(convertPassphraseRequest(settings));
|
||||
|
||||
return new GeneratedCredential(
|
||||
passphrase,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mock } from "jest-mock-extended";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||
|
||||
import { PasswordRandomizer, SdkPasswordRandomizer } from "../../engine";
|
||||
import { SdkPasswordRandomizer } from "../../engine";
|
||||
import { PassphrasePolicyConstraints } from "../../policies";
|
||||
import { GeneratorDependencyProvider } from "../../providers";
|
||||
import { PassphraseGenerationOptions } from "../../types";
|
||||
@@ -22,16 +22,6 @@ describe("password - eff words generator metadata", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("engine.create", () => {
|
||||
const nonSdkDependencyProvider = mock<GeneratorDependencyProvider>();
|
||||
nonSdkDependencyProvider.sdk = undefined;
|
||||
it("returns a password randomizer", () => {
|
||||
expect(effPassphrase.engine.create(nonSdkDependencyProvider)).toBeInstanceOf(
|
||||
PasswordRandomizer,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("profiles[account]", () => {
|
||||
let accountProfile: CoreProfileMetadata<PassphraseGenerationOptions> | null = null;
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { GENERATOR_DISK } from "@bitwarden/common/platform/state";
|
||||
import { PublicClassifier } from "@bitwarden/common/tools/public-classifier";
|
||||
import { ObjectKey } from "@bitwarden/common/tools/state/object-key";
|
||||
|
||||
import { PasswordRandomizer, SdkPasswordRandomizer } from "../../engine";
|
||||
import { SdkPasswordRandomizer } from "../../engine";
|
||||
import { passphraseLeastPrivilege, PassphrasePolicyConstraints } from "../../policies";
|
||||
import { GeneratorDependencyProvider } from "../../providers";
|
||||
import { CredentialGenerator, PassphraseGenerationOptions } from "../../types";
|
||||
@@ -30,9 +30,6 @@ const passphrase: GeneratorMetadata<PassphraseGenerationOptions> = {
|
||||
create(
|
||||
dependencies: GeneratorDependencyProvider,
|
||||
): CredentialGenerator<PassphraseGenerationOptions> {
|
||||
if (dependencies.sdk == undefined) {
|
||||
return new PasswordRandomizer(dependencies.randomizer, dependencies.now);
|
||||
}
|
||||
return new SdkPasswordRandomizer(dependencies.sdk, dependencies.now);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mock } from "jest-mock-extended";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||
|
||||
import { PasswordRandomizer, SdkPasswordRandomizer } from "../../engine";
|
||||
import { SdkPasswordRandomizer } from "../../engine";
|
||||
import { DynamicPasswordPolicyConstraints } from "../../policies";
|
||||
import { GeneratorDependencyProvider } from "../../providers";
|
||||
import { PasswordGenerationOptions } from "../../types";
|
||||
@@ -22,14 +22,6 @@ describe("password - characters generator metadata", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("engine.create", () => {
|
||||
const nonSdkDependencyProvider = mock<GeneratorDependencyProvider>();
|
||||
nonSdkDependencyProvider.sdk = undefined;
|
||||
it("returns a password randomizer", () => {
|
||||
expect(password.engine.create(nonSdkDependencyProvider)).toBeInstanceOf(PasswordRandomizer);
|
||||
});
|
||||
});
|
||||
|
||||
describe("profiles[account]", () => {
|
||||
let accountProfile: CoreProfileMetadata<PasswordGenerationOptions> = null!;
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { GENERATOR_DISK } from "@bitwarden/common/platform/state";
|
||||
import { PublicClassifier } from "@bitwarden/common/tools/public-classifier";
|
||||
import { deepFreeze } from "@bitwarden/common/tools/util";
|
||||
|
||||
import { PasswordRandomizer, SdkPasswordRandomizer } from "../../engine";
|
||||
import { SdkPasswordRandomizer } from "../../engine";
|
||||
import { DynamicPasswordPolicyConstraints, passwordLeastPrivilege } from "../../policies";
|
||||
import { GeneratorDependencyProvider } from "../../providers";
|
||||
import { CredentialGenerator, PasswordGeneratorSettings } from "../../types";
|
||||
@@ -30,9 +30,6 @@ const password: GeneratorMetadata<PasswordGeneratorSettings> = deepFreeze({
|
||||
create(
|
||||
dependencies: GeneratorDependencyProvider,
|
||||
): CredentialGenerator<PasswordGeneratorSettings> {
|
||||
if (dependencies.sdk == undefined) {
|
||||
return new PasswordRandomizer(dependencies.randomizer, dependencies.now);
|
||||
}
|
||||
return new SdkPasswordRandomizer(dependencies.sdk, dependencies.now);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||
import { RestClient } from "@bitwarden/common/tools/integration/rpc";
|
||||
import { BitwardenClient } from "@bitwarden/sdk-internal";
|
||||
|
||||
import { Randomizer } from "../abstractions";
|
||||
|
||||
@@ -10,6 +10,6 @@ export type GeneratorDependencyProvider = {
|
||||
// FIXME: introduce `I18nKeyOrLiteral` into forwarder
|
||||
// structures and remove this dependency
|
||||
i18nService: I18nService;
|
||||
sdk?: BitwardenClient;
|
||||
sdk: SdkService;
|
||||
now: () => number;
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { Policy } from "@bitwarden/common/admin-console/models/domain/policy";
|
||||
import { Account } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||
import { LegacyEncryptorProvider } from "@bitwarden/common/tools/cryptography/legacy-encryptor-provider";
|
||||
import { UserEncryptor } from "@bitwarden/common/tools/cryptography/user-encryptor.abstraction";
|
||||
import {
|
||||
@@ -96,8 +95,6 @@ const SomePolicyService = mock<PolicyService>();
|
||||
|
||||
const SomeExtensionService = mock<ExtensionService>();
|
||||
|
||||
const SomeConfigService = mock<ConfigService>;
|
||||
|
||||
const SomeSdkService = mock<BitwardenClient>;
|
||||
|
||||
const ApplicationProvider = {
|
||||
@@ -110,9 +107,6 @@ const ApplicationProvider = {
|
||||
/** Event monitoring and diagnostic interfaces */
|
||||
log: disabledSemanticLoggerProvider,
|
||||
|
||||
/** Feature flag retrieval */
|
||||
configService: SomeConfigService,
|
||||
|
||||
/** SDK access for password generation */
|
||||
sdk: SomeSdkService,
|
||||
} as unknown as SystemServiceProvider;
|
||||
|
||||
18
package-lock.json
generated
18
package-lock.json
generated
@@ -23,8 +23,8 @@
|
||||
"@angular/platform-browser": "20.3.16",
|
||||
"@angular/platform-browser-dynamic": "20.3.16",
|
||||
"@angular/router": "20.3.16",
|
||||
"@bitwarden/commercial-sdk-internal": "0.2.0-main.506",
|
||||
"@bitwarden/sdk-internal": "0.2.0-main.506",
|
||||
"@bitwarden/commercial-sdk-internal": "0.2.0-main.522",
|
||||
"@bitwarden/sdk-internal": "0.2.0-main.522",
|
||||
"@electron/fuses": "1.8.0",
|
||||
"@emotion/css": "11.13.5",
|
||||
"@koa/multer": "4.0.0",
|
||||
@@ -4981,9 +4981,10 @@
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/commercial-sdk-internal": {
|
||||
"version": "0.2.0-main.506",
|
||||
"resolved": "https://registry.npmjs.org/@bitwarden/commercial-sdk-internal/-/commercial-sdk-internal-0.2.0-main.506.tgz",
|
||||
"integrity": "sha512-aRzcxOcj8vXxz0jN3q2xxj26zxBfjg3oRm5QXbWE7zXJ2PGrgxTaePca9pQYYpwgr7iufYMnZcq5dH+qttNEmA==",
|
||||
"version": "0.2.0-main.522",
|
||||
"resolved": "https://registry.npmjs.org/@bitwarden/commercial-sdk-internal/-/commercial-sdk-internal-0.2.0-main.522.tgz",
|
||||
"integrity": "sha512-2wAbg30cGlDhSj14LaK2/ISuT91XPVeNgL/PU+eoxLhAehGKjAXdvZN3PSwFaAuaMbEFzlESvqC1pzzO4p/1zw==",
|
||||
"license": "BITWARDEN SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT",
|
||||
"dependencies": {
|
||||
"type-fest": "^4.41.0"
|
||||
}
|
||||
@@ -5085,9 +5086,10 @@
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@bitwarden/sdk-internal": {
|
||||
"version": "0.2.0-main.506",
|
||||
"resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.506.tgz",
|
||||
"integrity": "sha512-BbTSU5Acx74Hr32zDj2kV8sbdclyvdIti5t6kXnCvJmA5dZbu+5j5Xw1luS9mGL9Vfi4w3OjVug/TiSxyhwLzQ==",
|
||||
"version": "0.2.0-main.522",
|
||||
"resolved": "https://registry.npmjs.org/@bitwarden/sdk-internal/-/sdk-internal-0.2.0-main.522.tgz",
|
||||
"integrity": "sha512-E+YqqX/FvGF0vGx6sNJfYaMj88C+rVo51fQPMSHoOePdryFcKQSJX706Glv86OMLMXE7Ln5Lua8LJRftlF/EFQ==",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"type-fest": "^4.41.0"
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@
|
||||
"@angular/platform-browser": "20.3.16",
|
||||
"@angular/platform-browser-dynamic": "20.3.16",
|
||||
"@angular/router": "20.3.16",
|
||||
"@bitwarden/commercial-sdk-internal": "0.2.0-main.506",
|
||||
"@bitwarden/sdk-internal": "0.2.0-main.506",
|
||||
"@bitwarden/commercial-sdk-internal": "0.2.0-main.522",
|
||||
"@bitwarden/sdk-internal": "0.2.0-main.522",
|
||||
"@electron/fuses": "1.8.0",
|
||||
"@emotion/css": "11.13.5",
|
||||
"@koa/multer": "4.0.0",
|
||||
|
||||
Reference in New Issue
Block a user