1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-12 14:34:02 +00:00

feat: create separate bit licensed browser

This commit is contained in:
Andreas Coroiu
2025-09-01 13:15:32 +02:00
parent 50849917b4
commit 157d527b5a
16 changed files with 196 additions and 28 deletions

View File

@@ -3,7 +3,9 @@
"version": "2025.8.2",
"scripts": {
"build": "npm run build:chrome",
"build:bit": "npm run build:bit:chrome",
"build:chrome": "cross-env BROWSER=chrome MANIFEST_VERSION=3 NODE_OPTIONS=\"--max-old-space-size=8192\" webpack",
"build:bit:chrome": "cross-env BROWSER=chrome MANIFEST_VERSION=3 NODE_OPTIONS=\"--max-old-space-size=8192\" webpack -c ../../bitwarden_license/bit-browser/webpack.config.js",
"build:edge": "cross-env BROWSER=edge MANIFEST_VERSION=3 NODE_OPTIONS=\"--max-old-space-size=8192\" webpack",
"build:firefox": "cross-env BROWSER=firefox NODE_OPTIONS=\"--max-old-space-size=8192\" webpack",
"build:opera": "cross-env BROWSER=opera MANIFEST_VERSION=3 NODE_OPTIONS=\"--max-old-space-size=8192\" webpack",

View File

@@ -0,0 +1,20 @@
@if (showSdkWarning | async) {
<div class="tw-h-screen tw-flex tw-justify-center tw-items-center tw-p-4">
<bit-callout type="danger">
{{ "wasmNotSupported" | i18n }}
<a
bitLink
href="https://bitwarden.com/help/wasm-not-supported/"
target="_blank"
rel="noreferrer"
>
{{ "learnMore" | i18n }}
</a>
</bit-callout>
</div>
} @else {
<div [@routerTransition]="getRouteElevation(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
</div>
<bit-toast-container></bit-toast-container>
}

View File

@@ -57,28 +57,7 @@ import { DesktopSyncVerificationDialogComponent } from "./components/desktop-syn
selector: "app-root",
styles: [],
animations: [routerTransition],
template: `
@if (showSdkWarning | async) {
<div class="tw-h-screen tw-flex tw-justify-center tw-items-center tw-p-4">
<bit-callout type="danger">
{{ "wasmNotSupported" | i18n }}
<a
bitLink
href="https://bitwarden.com/help/wasm-not-supported/"
target="_blank"
rel="noreferrer"
>
{{ "learnMore" | i18n }}
</a>
</bit-callout>
</div>
} @else {
<div [@routerTransition]="getRouteElevation(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
</div>
<bit-toast-container></bit-toast-container>
}
`,
templateUrl: "app.component.html",
standalone: false,
})
export class AppComponent implements OnInit, OnDestroy {

View File

@@ -151,11 +151,6 @@ const plugins = [
filename: "[name].css",
chunkFilename: "chunk-[id].css",
}),
new AngularWebpackPlugin({
tsConfigPath: "tsconfig.json",
entryModule: "src/popup/app.module#AppModule",
sourceMap: true,
}),
new webpack.ProvidePlugin({
process: "process/browser.js",
}),
@@ -164,6 +159,11 @@ const plugins = [
filename: "[file].map",
}),
...requiredPlugins,
new AngularWebpackPlugin({
tsConfigPath: "tsconfig.json",
entryModule: "src/popup/app.module#AppModule",
sourceMap: true,
}),
];
/**

View File

@@ -0,0 +1,22 @@
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("../../tsconfig.base");
const sharedConfig = require("../../libs/shared/jest.config.angular");
/** @type {import('jest').Config} */
module.exports = {
...sharedConfig,
setupFilesAfterEnv: ["../../apps/browser/test.setup.ts"],
moduleNameMapper: pathsToModuleNameMapper(
{
"@bitwarden/common/spec": ["libs/common/spec"],
"@bitwarden/common": ["libs/common/src/*"],
"@bitwarden/admin-console/common": ["libs/admin-console/src/common"],
...(compilerOptions?.paths ?? {}),
},
{
prefix: "<rootDir>/../../",
},
),
};

View File

@@ -0,0 +1,9 @@
import OssMainBackground from "@bitwarden/browser/background/main.background";
export default class MainBackground {
private ossMain = new OssMainBackground();
async bootstrap() {
await this.ossMain.bootstrap();
}
}

View File

@@ -0,0 +1,7 @@
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import MainBackground from "../background/main.background";
const logService = new ConsoleLogService(false);
const bitwardenMain = ((self as any).bitwardenMain = new MainBackground());
bitwardenMain.bootstrap().catch((error) => logService.error(error));

View File

@@ -0,0 +1,10 @@
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
const routes: Routes = [];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AppRoutingModule {}

View File

@@ -0,0 +1,14 @@
import { Component, OnInit } from "@angular/core";
import { AppComponent as BaseAppComponent } from "@bitwarden/browser/popup/app.component";
@Component({
selector: "app-root",
templateUrl: "../../../../apps/browser/src/popup/app.component.html",
standalone: false,
})
export class AppComponent extends BaseAppComponent implements OnInit {
ngOnInit() {
return super.ngOnInit();
}
}

View File

@@ -0,0 +1,39 @@
import { OverlayModule } from "@angular/cdk/overlay";
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { RouterModule } from "@angular/router";
import { JslibModule } from "@bitwarden/angular/jslib.module";
// import { AppRoutingAnimationsModule } from "@bitwarden/browser/popup/app-routing-animations";
import { AppRoutingModule as OssRoutingModule } from "@bitwarden/browser/popup/app-routing.module";
import { AppModule as OssModule } from "@bitwarden/browser/popup/app.module";
// import { WildcardRoutingModule } from "@bitwarden/browser/popup/wildcard-routing.module";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
/**
* This is the AppModule for the commercial version of Bitwarden.
* `apps/browser/app.module.ts` contains the OSS version.
*
* You probably do not want to modify this file. Consider editing `oss.module.ts` instead.
*/
@NgModule({
imports: [
CommonModule,
OverlayModule,
OssModule,
JslibModule,
// BrowserAnimationsModule,
// FormsModule,
// ReactiveFormsModule,
// CoreModule,
// DragDropModule,
AppRoutingModule,
OssRoutingModule,
RouterModule,
// WildcardRoutingModule, // Needs to be last to catch all non-existing routes
],
declarations: [AppComponent],
bootstrap: [AppComponent],
})
export class AppModule {}

View File

@@ -0,0 +1,29 @@
import { enableProdMode } from "@angular/core";
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { PopupSizeService } from "@bitwarden/browser/platform/popup/layout/popup-size.service";
import { BrowserPlatformUtilsService } from "@bitwarden/browser/platform/services/platform-utils/browser-platform-utils.service";
// // eslint-disable-next-line @typescript-eslint/no-require-imports
// require("./scss/popup.scss");
// // eslint-disable-next-line @typescript-eslint/no-require-imports
// require("./scss/tailwind.css");
import { AppModule } from "./app.module";
// We put these first to minimize the delay in window changing.
PopupSizeService.initBodyWidthFromLocalStorage();
// Should be removed once we deprecate support for Safari 16.0 and older. See Jira ticket [PM-1861]
if (BrowserPlatformUtilsService.shouldApplySafariHeightFix(window)) {
document.documentElement.classList.add("safari_height_fix");
}
if (process.env.ENV === "production") {
enableProdMode();
}
function init() {
void platformBrowserDynamic().bootstrapModule(AppModule);
}
init();

View File

@@ -0,0 +1,10 @@
{
"extends": "../../apps/browser/tsconfig",
"files": [],
"include": [
"src",
"../../apps/browser/src/**/*.d.ts",
"../../libs/common/src/autofill/constants",
"../../libs/common/custom-matchers.d.ts"
]
}

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"isolatedModules": true,
"emitDecoratorMetadata": false
},
"files": ["../../apps/browser/test.setup.ts"]
}

View File

@@ -0,0 +1,17 @@
const { AngularWebpackPlugin } = require("@ngtools/webpack");
const webpackConfig = require("../../apps/browser/webpack.config");
const mainConfig = webpackConfig[0];
const backgroundConfig = webpackConfig[1];
mainConfig.entry["app/main"] = "../../bitwarden_license/bit-browser/src/popup/main.ts";
mainConfig.plugins[mainConfig.plugins.length - 1] = new AngularWebpackPlugin({
tsconfig: "../../bitwarden_license/bit-browser/tsconfig.json",
entryModule: "bitwarden_license/bit-browser/src/popup/app.module#AppModule",
sourceMap: true,
});
backgroundConfig.entry = "./src/platform/background.ts";
module.exports = webpackConfig;

View File

@@ -20,9 +20,10 @@ module.exports = {
"<rootDir>/apps/cli/jest.config.js",
"<rootDir>/apps/desktop/jest.config.js",
"<rootDir>/apps/web/jest.config.js",
"<rootDir>/bitwarden_license/bit-web/jest.config.js",
"<rootDir>/bitwarden_license/bit-browser/jest.config.js",
"<rootDir>/bitwarden_license/bit-cli/jest.config.js",
"<rootDir>/bitwarden_license/bit-common/jest.config.js",
"<rootDir>/bitwarden_license/bit-web/jest.config.js",
"<rootDir>/libs/admin-console/jest.config.js",
"<rootDir>/libs/angular/jest.config.js",

View File

@@ -26,6 +26,7 @@
"@bitwarden/auth/common": ["./libs/auth/src/common"],
"@bitwarden/billing": ["./libs/billing/src"],
"@bitwarden/bit-common/*": ["./bitwarden_license/bit-common/src/*"],
"@bitwarden/browser/*": ["./apps/browser/src/*"],
"@bitwarden/cli/*": ["./apps/cli/src/*"],
"@bitwarden/client-type": ["libs/client-type/src/index.ts"],
"@bitwarden/common/*": ["./libs/common/src/*"],