mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
Cleanup src folder for web and move ts code into src/app per angular convention (#3127)
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
import { StateService as BaseStateService } from "@bitwarden/common/abstractions/state.service";
|
|
||||||
import { StorageOptions } from "@bitwarden/common/models/domain/storageOptions";
|
|
||||||
|
|
||||||
import { Account } from "src/models/account";
|
|
||||||
|
|
||||||
export abstract class StateService extends BaseStateService<Account> {
|
|
||||||
getRememberEmail: (options?: StorageOptions) => Promise<boolean>;
|
|
||||||
setRememberEmail: (value: boolean, options?: StorageOptions) => Promise<void>;
|
|
||||||
}
|
|
||||||
@@ -19,8 +19,8 @@ import { Policy } from "@bitwarden/common/models/domain/policy";
|
|||||||
import { ListResponse } from "@bitwarden/common/models/response/listResponse";
|
import { ListResponse } from "@bitwarden/common/models/response/listResponse";
|
||||||
import { PolicyResponse } from "@bitwarden/common/models/response/policyResponse";
|
import { PolicyResponse } from "@bitwarden/common/models/response/policyResponse";
|
||||||
|
|
||||||
import { StateService } from "../../abstractions/state.service";
|
|
||||||
import { RouterService } from "../services/router.service";
|
import { RouterService } from "../services/router.service";
|
||||||
|
import { StateService } from "../services/state.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-login",
|
selector: "app-login",
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { ContainerService } from "@bitwarden/common/services/container.service";
|
|||||||
import { EventService as EventLoggingService } from "@bitwarden/common/services/event.service";
|
import { EventService as EventLoggingService } from "@bitwarden/common/services/event.service";
|
||||||
import { VaultTimeoutService as VaultTimeoutService } from "@bitwarden/common/services/vaultTimeout.service";
|
import { VaultTimeoutService as VaultTimeoutService } from "@bitwarden/common/services/vaultTimeout.service";
|
||||||
|
|
||||||
import { I18nService as I18nService } from "../../services/i18n.service";
|
import { I18nService } from "./i18n.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InitService {
|
export class InitService {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Injectable } from "@angular/core";
|
|||||||
|
|
||||||
import { PasswordRepromptService as BasePasswordRepromptService } from "@bitwarden/angular/services/passwordReprompt.service";
|
import { PasswordRepromptService as BasePasswordRepromptService } from "@bitwarden/angular/services/passwordReprompt.service";
|
||||||
|
|
||||||
import { PasswordRepromptComponent } from "../app/components/password-reprompt.component";
|
import { PasswordRepromptComponent } from "../components/password-reprompt.component";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PasswordRepromptService extends BasePasswordRepromptService {
|
export class PasswordRepromptService extends BasePasswordRepromptService {
|
||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
import { ModalService as ModalServiceAbstraction } from "@bitwarden/angular/services/modal.service";
|
import { ModalService as ModalServiceAbstraction } from "@bitwarden/angular/services/modal.service";
|
||||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
|
||||||
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/abstractions/messaging.service";
|
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/abstractions/messaging.service";
|
||||||
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "@bitwarden/common/abstractions/passwordReprompt.service";
|
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "@bitwarden/common/abstractions/passwordReprompt.service";
|
||||||
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
@@ -23,26 +22,25 @@ import { AbstractStorageService } from "@bitwarden/common/abstractions/storage.s
|
|||||||
import { StateFactory } from "@bitwarden/common/factories/stateFactory";
|
import { StateFactory } from "@bitwarden/common/factories/stateFactory";
|
||||||
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
|
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
|
||||||
|
|
||||||
import { StateService as StateServiceAbstraction } from "../../abstractions/state.service";
|
|
||||||
import { Account } from "../../models/account";
|
|
||||||
import { GlobalState } from "../../models/globalState";
|
|
||||||
import { BroadcasterMessagingService } from "../../services/broadcasterMessaging.service";
|
|
||||||
import { HtmlStorageService } from "../../services/htmlStorage.service";
|
|
||||||
import { I18nService } from "../../services/i18n.service";
|
|
||||||
import { PasswordRepromptService } from "../../services/passwordReprompt.service";
|
|
||||||
import { StateService } from "../../services/state.service";
|
|
||||||
import { StateMigrationService } from "../../services/stateMigration.service";
|
|
||||||
import { WebPlatformUtilsService } from "../../services/webPlatformUtils.service";
|
|
||||||
import { HomeGuard } from "../guards/home.guard";
|
import { HomeGuard } from "../guards/home.guard";
|
||||||
|
import { Account } from "../models/account";
|
||||||
|
import { GlobalState } from "../models/globalState";
|
||||||
import { PermissionsGuard as OrgPermissionsGuard } from "../organizations/guards/permissions.guard";
|
import { PermissionsGuard as OrgPermissionsGuard } from "../organizations/guards/permissions.guard";
|
||||||
import { NavigationPermissionsService as OrgPermissionsService } from "../organizations/services/navigation-permissions.service";
|
import { NavigationPermissionsService as OrgPermissionsService } from "../organizations/services/navigation-permissions.service";
|
||||||
|
|
||||||
|
import { BroadcasterMessagingService } from "./broadcasterMessaging.service";
|
||||||
import { EventService } from "./event.service";
|
import { EventService } from "./event.service";
|
||||||
|
import { HtmlStorageService } from "./htmlStorage.service";
|
||||||
|
import { I18nService } from "./i18n.service";
|
||||||
import { InitService } from "./init.service";
|
import { InitService } from "./init.service";
|
||||||
import { ModalService } from "./modal.service";
|
import { ModalService } from "./modal.service";
|
||||||
|
import { PasswordRepromptService } from "./passwordReprompt.service";
|
||||||
import { PolicyListService } from "./policy-list.service";
|
import { PolicyListService } from "./policy-list.service";
|
||||||
import { RouterService } from "./router.service";
|
import { RouterService } from "./router.service";
|
||||||
|
import { StateService } from "./state.service";
|
||||||
|
import { StateMigrationService } from "./stateMigration.service";
|
||||||
import { WebFileDownloadService } from "./webFileDownload.service";
|
import { WebFileDownloadService } from "./webFileDownload.service";
|
||||||
|
import { WebPlatformUtilsService } from "./webPlatformUtils.service";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [ToastrModule, JslibServicesModule],
|
imports: [ToastrModule, JslibServicesModule],
|
||||||
@@ -95,22 +93,10 @@ import { WebFileDownloadService } from "./webFileDownload.service";
|
|||||||
useClass: StateMigrationService,
|
useClass: StateMigrationService,
|
||||||
deps: [AbstractStorageService, SECURE_STORAGE, STATE_FACTORY],
|
deps: [AbstractStorageService, SECURE_STORAGE, STATE_FACTORY],
|
||||||
},
|
},
|
||||||
{
|
StateService,
|
||||||
provide: StateServiceAbstraction,
|
|
||||||
useClass: StateService,
|
|
||||||
deps: [
|
|
||||||
AbstractStorageService,
|
|
||||||
SECURE_STORAGE,
|
|
||||||
MEMORY_STORAGE,
|
|
||||||
LogService,
|
|
||||||
StateMigrationServiceAbstraction,
|
|
||||||
STATE_FACTORY,
|
|
||||||
STATE_SERVICE_USE_CACHE,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
provide: BaseStateServiceAbstraction,
|
provide: BaseStateServiceAbstraction,
|
||||||
useExisting: StateServiceAbstraction,
|
useExisting: StateService,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: PasswordRepromptServiceAbstraction,
|
provide: PasswordRepromptServiceAbstraction,
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
|
import { Inject, Injectable } from "@angular/core";
|
||||||
|
|
||||||
|
import {
|
||||||
|
MEMORY_STORAGE,
|
||||||
|
SECURE_STORAGE,
|
||||||
|
STATE_FACTORY,
|
||||||
|
STATE_SERVICE_USE_CACHE,
|
||||||
|
} from "@bitwarden/angular/services/jslib-services.module";
|
||||||
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
|
import { StateMigrationService } from "@bitwarden/common/abstractions/stateMigration.service";
|
||||||
|
import { AbstractStorageService } from "@bitwarden/common/abstractions/storage.service";
|
||||||
|
import { StateFactory } from "@bitwarden/common/factories/stateFactory";
|
||||||
import { CipherData } from "@bitwarden/common/models/data/cipherData";
|
import { CipherData } from "@bitwarden/common/models/data/cipherData";
|
||||||
import { CollectionData } from "@bitwarden/common/models/data/collectionData";
|
import { CollectionData } from "@bitwarden/common/models/data/collectionData";
|
||||||
import { FolderData } from "@bitwarden/common/models/data/folderData";
|
import { FolderData } from "@bitwarden/common/models/data/folderData";
|
||||||
@@ -5,14 +17,31 @@ import { SendData } from "@bitwarden/common/models/data/sendData";
|
|||||||
import { StorageOptions } from "@bitwarden/common/models/domain/storageOptions";
|
import { StorageOptions } from "@bitwarden/common/models/domain/storageOptions";
|
||||||
import { StateService as BaseStateService } from "@bitwarden/common/services/state.service";
|
import { StateService as BaseStateService } from "@bitwarden/common/services/state.service";
|
||||||
|
|
||||||
import { StateService as StateServiceAbstraction } from "../abstractions/state.service";
|
|
||||||
import { Account } from "../models/account";
|
import { Account } from "../models/account";
|
||||||
import { GlobalState } from "../models/globalState";
|
import { GlobalState } from "../models/globalState";
|
||||||
|
|
||||||
export class StateService
|
@Injectable()
|
||||||
extends BaseStateService<GlobalState, Account>
|
export class StateService extends BaseStateService<GlobalState, Account> {
|
||||||
implements StateServiceAbstraction
|
constructor(
|
||||||
{
|
storageService: AbstractStorageService,
|
||||||
|
@Inject(SECURE_STORAGE) secureStorageService: AbstractStorageService,
|
||||||
|
@Inject(MEMORY_STORAGE) memoryStorageService: AbstractStorageService,
|
||||||
|
logService: LogService,
|
||||||
|
stateMigrationService: StateMigrationService,
|
||||||
|
@Inject(STATE_FACTORY) stateFactory: StateFactory<GlobalState, Account>,
|
||||||
|
@Inject(STATE_SERVICE_USE_CACHE) useAccountCache = true
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
storageService,
|
||||||
|
secureStorageService,
|
||||||
|
memoryStorageService,
|
||||||
|
logService,
|
||||||
|
stateMigrationService,
|
||||||
|
stateFactory,
|
||||||
|
useAccountCache
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async addAccount(account: Account) {
|
async addAccount(account: Account) {
|
||||||
// Apply web overides to default account values
|
// Apply web overides to default account values
|
||||||
account = new Account(account);
|
account = new Account(account);
|
||||||
@@ -6,7 +6,7 @@ import { OrganizationService } from "@bitwarden/common/abstractions/organization
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { TokenService } from "@bitwarden/common/abstractions/token.service";
|
import { TokenService } from "@bitwarden/common/abstractions/token.service";
|
||||||
|
|
||||||
import { StateService } from "../../abstractions/state.service";
|
import { StateService } from "../services/state.service";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "SettingsComponent";
|
const BroadcasterSubscriptionId = "SettingsComponent";
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import "bootstrap";
|
|||||||
import "jquery";
|
import "jquery";
|
||||||
import "popper.js";
|
import "popper.js";
|
||||||
|
|
||||||
require("../scss/styles.scss");
|
require("./scss/styles.scss");
|
||||||
require("../scss/tailwind.css");
|
require("./scss/tailwind.css");
|
||||||
|
|
||||||
import { AppModule } from "./app.module";
|
import { AppModule } from "./app/app.module";
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
@@ -14,16 +14,6 @@
|
|||||||
"angularCompilerOptions": {
|
"angularCompilerOptions": {
|
||||||
"preserveWhitespaces": true
|
"preserveWhitespaces": true
|
||||||
},
|
},
|
||||||
"files": [
|
"files": ["src/polyfills.ts", "src/main.ts", "../../bitwarden_license/bit-web/src/main.ts"],
|
||||||
"src/app/polyfills.ts",
|
"include": ["src/connectors/*.ts", "src/**/*.stories.ts"]
|
||||||
"src/app/main.ts",
|
|
||||||
"../../bitwarden_license/bit-web/src/app/main.ts"
|
|
||||||
],
|
|
||||||
"include": [
|
|
||||||
"src/connectors/*.ts",
|
|
||||||
"src/models/*.ts",
|
|
||||||
"src/services/*.ts",
|
|
||||||
"src/abstractions/*.ts",
|
|
||||||
"src/**/*.stories.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,8 +282,8 @@ const webpackConfig = {
|
|||||||
devtool: "source-map",
|
devtool: "source-map",
|
||||||
devServer: devServer,
|
devServer: devServer,
|
||||||
entry: {
|
entry: {
|
||||||
"app/polyfills": "./src/app/polyfills.ts",
|
"app/polyfills": "./src/polyfills.ts",
|
||||||
"app/main": "./src/app/main.ts",
|
"app/main": "./src/main.ts",
|
||||||
"connectors/webauthn": "./src/connectors/webauthn.ts",
|
"connectors/webauthn": "./src/connectors/webauthn.ts",
|
||||||
"connectors/webauthn-fallback": "./src/connectors/webauthn-fallback.ts",
|
"connectors/webauthn-fallback": "./src/connectors/webauthn-fallback.ts",
|
||||||
"connectors/duo": "./src/connectors/duo.ts",
|
"connectors/duo": "./src/connectors/duo.ts",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import "popper.js";
|
|||||||
require("src/scss/styles.scss");
|
require("src/scss/styles.scss");
|
||||||
require("src/scss/tailwind.css");
|
require("src/scss/tailwind.css");
|
||||||
|
|
||||||
import { AppModule } from "./app.module";
|
import { AppModule } from "./app/app.module";
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
@@ -2,7 +2,7 @@ const { AngularWebpackPlugin } = require("@ngtools/webpack");
|
|||||||
|
|
||||||
const webpackConfig = require("../../apps/web/webpack.config");
|
const webpackConfig = require("../../apps/web/webpack.config");
|
||||||
|
|
||||||
webpackConfig.entry["app/main"] = "../../bitwarden_license/bit-web/src/app/main.ts";
|
webpackConfig.entry["app/main"] = "../../bitwarden_license/bit-web/src/main.ts";
|
||||||
webpackConfig.plugins[webpackConfig.plugins.length - 1] = new AngularWebpackPlugin({
|
webpackConfig.plugins[webpackConfig.plugins.length - 1] = new AngularWebpackPlugin({
|
||||||
tsConfigPath: "tsconfig.json",
|
tsConfigPath: "tsconfig.json",
|
||||||
entryModule: "bitwarden_license/src/app/app.module#AppModule",
|
entryModule: "bitwarden_license/src/app/app.module#AppModule",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
"homepage": "https://bitwarden.com",
|
"homepage": "https://bitwarden.com",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"lint": "eslint . || prettier --check .",
|
"lint": "eslint . && prettier --check .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"prettier": "prettier --write .",
|
"prettier": "prettier --write .",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
|
|||||||
Reference in New Issue
Block a user