Skip to content

Commit

Permalink
Merge branch 'main' into AC-2009/migrate-organization-state
Browse files Browse the repository at this point in the history
  • Loading branch information
addisonbeck committed Mar 15, 2024
2 parents d6eb3e1 + 65534a1 commit d1ce9f8
Show file tree
Hide file tree
Showing 171 changed files with 5,209 additions and 1,040 deletions.
28 changes: 14 additions & 14 deletions apps/browser/src/_locales/be/messages.json
Expand Up @@ -119,7 +119,7 @@
"message": "Дадаць лагін"
},
"addCardMenu": {
"message": "Add card"
"message": "Дадаць картку"
},
"addIdentityMenu": {
"message": "Add identity"
Expand Down Expand Up @@ -269,7 +269,7 @@
"message": "Даўжыня"
},
"passwordMinLength": {
"message": "Minimum password length"
"message": "Мінімальная даўжыня пароля"
},
"uppercase": {
"message": "Вялікія літары (A-Z)"
Expand Down Expand Up @@ -369,7 +369,7 @@
"message": "Iншае"
},
"unlockMethodNeededToChangeTimeoutActionDesc": {
"message": "Set up an unlock method to change your vault timeout action."
"message": "Наладзіць метад разблакіроўкі для змянення дзеяння часу чакання вашага сховішча."
},
"unlockMethodNeeded": {
"message": "Set up an unlock method in Settings"
Expand Down Expand Up @@ -415,7 +415,7 @@
"message": "Заблакіраваць зараз"
},
"lockAll": {
"message": "Lock all"
"message": "Заблакаваць усе"
},
"immediately": {
"message": "Адразу"
Expand Down Expand Up @@ -494,7 +494,7 @@
"message": "Ваш уліковы запіс створаны! Цяпер вы можаце ўвайсці ў яго."
},
"youSuccessfullyLoggedIn": {
"message": "You successfully logged in"
"message": "Вы паспяхова аўтарызаваны"
},
"youMayCloseThisWindow": {
"message": "You may close this window"
Expand Down Expand Up @@ -2005,7 +2005,7 @@
"message": "Выбраць папку..."
},
"noFoldersFound": {
"message": "No folders found",
"message": "Папкі не знойдзены",
"description": "Used as a message within the notification bar when no folders are found"
},
"orgPermissionsUpdatedMustSetPassword": {
Expand Down Expand Up @@ -2215,7 +2215,7 @@
"message": "Версія сервера"
},
"selfHostedServer": {
"message": "self-hosted"
"message": "уласнае размяшчэнне"
},
"thirdParty": {
"message": "Іншы пастаўшчык"
Expand Down Expand Up @@ -2356,25 +2356,25 @@
}
},
"loggingInOn": {
"message": "Logging in on"
"message": "Увайсці на"
},
"opensInANewWindow": {
"message": "Адкрываць у новым акне"
},
"deviceApprovalRequired": {
"message": "Device approval required. Select an approval option below:"
"message": "Патрабуецца ўхваленне прылады. Выберыце параметры ўхвалення ніжэй:"
},
"rememberThisDevice": {
"message": "Remember this device"
"message": "Запомніць гэту прыладу"
},
"uncheckIfPublicDevice": {
"message": "Uncheck if using a public device"
"message": "Здыміце пазнаку, калі выкарыстоўваеце агульнадаступную прыладу"
},
"approveFromYourOtherDevice": {
"message": "Approve from your other device"
"message": "Ухваліць з іншай вашай прылады"
},
"requestAdminApproval": {
"message": "Request admin approval"
"message": "Запытаць ухваленне адміністратара"
},
"approveWithMasterPassword": {
"message": "Approve with master password"
Expand Down Expand Up @@ -2402,7 +2402,7 @@
"message": "Адлюстраванне"
},
"accountSuccessfullyCreated": {
"message": "Account successfully created!"
"message": "Уліковы запіс паспяхова створаны!"
},
"adminApprovalRequested": {
"message": "Admin approval requested"
Expand Down
2 changes: 1 addition & 1 deletion apps/browser/src/_locales/hu/messages.json
Expand Up @@ -688,7 +688,7 @@
"message": "A bejelentkezési jelszó frissítésének kérése, ha változást lett érzékelve egy webhelyen. Minden bejelentkezett fiókra vonatkozik."
},
"enableUsePasskeys": {
"message": "Kérés a jhozzáférési kulcs mentésére és használatára"
"message": "Kérés a hozzáférési kulcs mentésére és használatára"
},
"usePasskeysDesc": {
"message": "Kérés az új hozzáféréi kulcsok mentésére vagy bejelentkezés a széfben tárolt hozzáférési kulcsokkal. Minden bejelentkezett fiókra vonatkozik."
Expand Down
Expand Up @@ -7,13 +7,29 @@ import {
factory,
} from "../../../platform/background/service-factories/factory-options";
import {
stateServiceFactory,
StateServiceInitOptions,
} from "../../../platform/background/service-factories/state-service.factory";
GlobalStateProviderInitOptions,
globalStateProviderFactory,
} from "../../../platform/background/service-factories/global-state-provider.factory";
import {
PlatformUtilsServiceInitOptions,
platformUtilsServiceFactory,
} from "../../../platform/background/service-factories/platform-utils-service.factory";
import {
SingleUserStateProviderInitOptions,
singleUserStateProviderFactory,
} from "../../../platform/background/service-factories/single-user-state-provider.factory";
import {
SecureStorageServiceInitOptions,
secureStorageServiceFactory,
} from "../../../platform/background/service-factories/storage-service.factory";

type TokenServiceFactoryOptions = FactoryOptions;

export type TokenServiceInitOptions = TokenServiceFactoryOptions & StateServiceInitOptions;
export type TokenServiceInitOptions = TokenServiceFactoryOptions &
SingleUserStateProviderInitOptions &
GlobalStateProviderInitOptions &
PlatformUtilsServiceInitOptions &
SecureStorageServiceInitOptions;

export function tokenServiceFactory(
cache: { tokenService?: AbstractTokenService } & CachedServices,
Expand All @@ -23,6 +39,12 @@ export function tokenServiceFactory(
cache,
"tokenService",
opts,
async () => new TokenService(await stateServiceFactory(cache, opts)),
async () =>
new TokenService(
await singleUserStateProviderFactory(cache, opts),
await globalStateProviderFactory(cache, opts),
(await platformUtilsServiceFactory(cache, opts)).supportsSecureStorage(),
await secureStorageServiceFactory(cache, opts),
),
);
}
2 changes: 2 additions & 0 deletions apps/browser/src/auth/popup/login.component.ts
Expand Up @@ -91,6 +91,8 @@ export class LoginComponent extends BaseLoginComponent {
}

async launchSsoBrowser() {
// Save off email for SSO
await this.ssoLoginService.setSsoEmail(this.formGroup.value.email);
await this.loginService.saveEmailSettings();
// Generate necessary sso params
const passwordOptions: any = {
Expand Down
Expand Up @@ -184,6 +184,11 @@ export class MainContextMenuHandler {
stateServiceOptions: {
stateFactory: stateFactory,
},
platformUtilsServiceOptions: {
clipboardWriteCallback: () => Promise.resolve(),
biometricCallback: () => Promise.resolve(false),
win: self,
},
};

return new MainContextMenuHandler(
Expand Down
Expand Up @@ -755,6 +755,9 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte

// Prioritize capturing text content from elements rather than nodes.
currentElement = currentElement.parentElement || currentElement.parentNode;
if (!currentElement) {
return textContentItems;
}

let siblingElement = nodeIsElement(currentElement)
? currentElement.previousElementSibling
Expand Down
31 changes: 19 additions & 12 deletions apps/browser/src/background/main.background.ts
Expand Up @@ -409,8 +409,7 @@ export default class MainBackground {
);
this.activeUserStateProvider = new DefaultActiveUserStateProvider(
this.accountService,
storageServiceProvider,
stateEventRegistrarService,
this.singleUserStateProvider,
);
this.derivedStateProvider = new BackgroundDerivedStateProvider(
this.memoryStorageForStateProviders,
Expand All @@ -428,6 +427,21 @@ export default class MainBackground {
);
this.biometricStateService = new DefaultBiometricStateService(this.stateProvider);

this.userNotificationSettingsService = new UserNotificationSettingsService(this.stateProvider);
this.platformUtilsService = new BackgroundPlatformUtilsService(
this.messagingService,
(clipboardValue, clearMs) => this.clearClipboard(clipboardValue, clearMs),
async () => this.biometricUnlock(),
self,
);

this.tokenService = new TokenService(
this.singleUserStateProvider,
this.globalStateProvider,
this.platformUtilsService.supportsSecureStorage(),
this.secureStorageService,
);

const migrationRunner = new MigrationRunner(
this.storageService,
this.logService,
Expand All @@ -442,15 +456,9 @@ export default class MainBackground {
new StateFactory(GlobalState, Account),
this.accountService,
this.environmentService,
this.tokenService,
migrationRunner,
);
this.userNotificationSettingsService = new UserNotificationSettingsService(this.stateProvider);
this.platformUtilsService = new BackgroundPlatformUtilsService(
this.messagingService,
(clipboardValue, clearMs) => this.clearClipboard(clipboardValue, clearMs),
async () => this.biometricUnlock(),
self,
);

const themeStateService = new DefaultThemeStateService(this.globalStateProvider);

Expand All @@ -466,13 +474,14 @@ export default class MainBackground {
this.stateProvider,
this.biometricStateService,
);
this.tokenService = new TokenService(this.stateService);

this.appIdService = new AppIdService(this.globalStateProvider);
this.apiService = new ApiService(
this.tokenService,
this.platformUtilsService,
this.environmentService,
this.appIdService,
this.stateService,
(expired: boolean) => this.logout(expired),
);
this.domainSettingsService = new DefaultDomainSettingsService(this.stateProvider);
Expand Down Expand Up @@ -789,7 +798,6 @@ export default class MainBackground {
this.fido2AuthenticatorService,
this.configService,
this.authService,
this.stateService,
this.vaultSettingsService,
this.domainSettingsService,
this.logService,
Expand Down Expand Up @@ -837,7 +845,6 @@ export default class MainBackground {
this.cryptoService,
this.cryptoFunctionService,
this.runtimeBackground,
this.i18nService,
this.messagingService,
this.appIdService,
this.platformUtilsService,
Expand Down
2 changes: 0 additions & 2 deletions apps/browser/src/background/nativeMessaging.background.ts
Expand Up @@ -5,7 +5,6 @@ import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authenticatio
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand Down Expand Up @@ -75,7 +74,6 @@ export class NativeMessagingBackground {
private cryptoService: CryptoService,
private cryptoFunctionService: CryptoFunctionService,
private runtimeBackground: RuntimeBackground,
private i18nService: I18nService,
private messagingService: MessagingService,
private appIdService: AppIdService,
private platformUtilsService: PlatformUtilsService,
Expand Down
Expand Up @@ -9,20 +9,15 @@ import {

import { CachedServices, FactoryOptions, factory } from "./factory-options";
import {
StateEventRegistrarServiceInitOptions,
stateEventRegistrarServiceFactory,
} from "./state-event-registrar-service.factory";
import {
StorageServiceProviderInitOptions,
storageServiceProviderFactory,
} from "./storage-service-provider.factory";
SingleUserStateProviderInitOptions,
singleUserStateProviderFactory,
} from "./single-user-state-provider.factory";

type ActiveUserStateProviderFactory = FactoryOptions;

export type ActiveUserStateProviderInitOptions = ActiveUserStateProviderFactory &
AccountServiceInitOptions &
StorageServiceProviderInitOptions &
StateEventRegistrarServiceInitOptions;
SingleUserStateProviderInitOptions;

export async function activeUserStateProviderFactory(
cache: { activeUserStateProvider?: ActiveUserStateProvider } & CachedServices,
Expand All @@ -35,8 +30,7 @@ export async function activeUserStateProviderFactory(
async () =>
new DefaultActiveUserStateProvider(
await accountServiceFactory(cache, opts),
await storageServiceProviderFactory(cache, opts),
await stateEventRegistrarServiceFactory(cache, opts),
await singleUserStateProviderFactory(cache, opts),
),
);
}
Expand Up @@ -20,6 +20,7 @@ import {
PlatformUtilsServiceInitOptions,
platformUtilsServiceFactory,
} from "./platform-utils-service.factory";
import { stateServiceFactory, StateServiceInitOptions } from "./state-service.factory";

type ApiServiceFactoryOptions = FactoryOptions & {
apiServiceOptions: {
Expand All @@ -32,7 +33,8 @@ export type ApiServiceInitOptions = ApiServiceFactoryOptions &
TokenServiceInitOptions &
PlatformUtilsServiceInitOptions &
EnvironmentServiceInitOptions &
AppIdServiceInitOptions;
AppIdServiceInitOptions &
StateServiceInitOptions;

export function apiServiceFactory(
cache: { apiService?: AbstractApiService } & CachedServices,
Expand All @@ -48,6 +50,7 @@ export function apiServiceFactory(
await platformUtilsServiceFactory(cache, opts),
await environmentServiceFactory(cache, opts),
await appIdServiceFactory(cache, opts),
await stateServiceFactory(cache, opts),
opts.apiServiceOptions.logoutCallback,
opts.apiServiceOptions.customUserAgent,
),
Expand Down
Expand Up @@ -5,6 +5,10 @@ import {
accountServiceFactory,
AccountServiceInitOptions,
} from "../../../auth/background/service-factories/account-service.factory";
import {
tokenServiceFactory,
TokenServiceInitOptions,
} from "../../../auth/background/service-factories/token-service.factory";
import { Account } from "../../../models/account";
import { BrowserStateService } from "../../services/browser-state.service";

Expand Down Expand Up @@ -38,6 +42,7 @@ export type StateServiceInitOptions = StateServiceFactoryOptions &
LogServiceInitOptions &
AccountServiceInitOptions &
EnvironmentServiceInitOptions &
TokenServiceInitOptions &
MigrationRunnerInitOptions;

export async function stateServiceFactory(
Expand All @@ -57,6 +62,7 @@ export async function stateServiceFactory(
opts.stateServiceOptions.stateFactory,
await accountServiceFactory(cache, opts),
await environmentServiceFactory(cache, opts),
await tokenServiceFactory(cache, opts),
await migrationRunnerFactory(cache, opts),
opts.stateServiceOptions.useAccountCache,
),
Expand Down

0 comments on commit d1ce9f8

Please sign in to comment.