1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

Merge branch 'master' into feature/org-admin-refresh

This commit is contained in:
Shane Melton
2022-11-17 15:02:50 -08:00
34 changed files with 353 additions and 86 deletions

View File

@@ -6,6 +6,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { AngularWebpackPlugin } = require("@ngtools/webpack");
const TerserPlugin = require("terser-webpack-plugin");
const { TsconfigPathsPlugin } = require("tsconfig-paths-webpack-plugin");
const configurator = require("./config/config");
if (process.env.NODE_ENV == null) {
@@ -67,17 +68,24 @@ const moduleRules = [
},
];
const requiredPlugins = [
new webpack.DefinePlugin({
"process.env": {
ENV: JSON.stringify(ENV),
},
}),
new webpack.EnvironmentPlugin({
FLAGS: envConfig.flags,
DEV_FLAGS: ENV === "development" ? envConfig.devFlags : {},
}),
];
const plugins = [
new HtmlWebpackPlugin({
template: "./src/popup/index.html",
filename: "popup/index.html",
chunks: ["popup/polyfills", "popup/vendor-angular", "popup/vendor", "popup/main"],
}),
new HtmlWebpackPlugin({
template: "./src/background.html",
filename: "background.html",
chunks: ["vendor", "background"],
}),
new HtmlWebpackPlugin({
template: "./src/notification/bar.html",
filename: "notification/bar.html",
@@ -99,11 +107,6 @@ const plugins = [
filename: "[name].css",
chunkFilename: "chunk-[id].css",
}),
new webpack.DefinePlugin({
"process.env": {
ENV: JSON.stringify(ENV),
},
}),
new AngularWebpackPlugin({
tsConfigPath: "tsconfig.json",
entryModule: "src/popup/app.module#AppModule",
@@ -119,19 +122,20 @@ const plugins = [
exclude: [/content\/.*/, /notification\/.*/],
filename: "[file].map",
}),
new webpack.EnvironmentPlugin({
FLAGS: envConfig.flags,
DEV_FLAGS: ENV === "development" ? envConfig.devFlags : {},
}),
...requiredPlugins,
];
const config = {
/**
* @type {import("webpack").Configuration}
* This config compiles everything but the background
*/
const mainConfig = {
name: "main",
mode: ENV,
devtool: false,
entry: {
"popup/polyfills": "./src/popup/polyfills.ts",
"popup/main": "./src/popup/main.ts",
background: "./src/background.ts",
"content/autofill": "./src/content/autofill.js",
"content/autofiller": "./src/content/autofiller.ts",
"content/notificationBar": "./src/content/notificationBar.ts",
@@ -209,18 +213,72 @@ const config = {
plugins: plugins,
};
/**
* @type {import("webpack").Configuration[]}
*/
const configs = [];
if (manifestVersion == 2) {
// We can't use this in manifest v3
// Ideally we understand why this breaks it and we don't have to do this
config.optimization.splitChunks.cacheGroups.commons2 = {
mainConfig.optimization.splitChunks.cacheGroups.commons2 = {
test: /[\\/]node_modules[\\/]/,
name: "vendor",
chunks: (chunk) => {
return chunk.name === "background";
},
};
// Manifest V2 uses Background Pages which requires a html page.
mainConfig.plugins.push(
new HtmlWebpackPlugin({
template: "./src/background.html",
filename: "background.html",
chunks: ["vendor", "background"],
})
);
// Manifest V2 background pages can be run through the regular build pipeline.
// Since it's a standard webpage.
mainConfig.entry.background = "./src/background.ts";
configs.push(mainConfig);
} else {
config.entry["content/misc-utils"] = "./src/content/misc-utils.ts";
// Manifest v3 needs an extra helper for utilities in the content script.
// The javascript output of this should be added to manifest.v3.json
mainConfig.entry["content/misc-utils"] = "./src/content/misc-utils.ts";
/**
* @type {import("webpack").Configuration}
*/
const backgroundConfig = {
name: "background",
mode: ENV,
devtool: false,
entry: "./src/background.ts",
target: "webworker",
output: {
filename: "background.js",
path: path.resolve(__dirname, "build"),
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
},
],
},
resolve: {
extensions: [".ts", ".js"],
symlinks: false,
modules: [path.resolve("../../node_modules")],
plugins: [new TsconfigPathsPlugin()],
},
dependencies: ["main"],
plugins: [...requiredPlugins],
};
configs.push(mainConfig);
configs.push(backgroundConfig);
}
module.exports = config;
module.exports = configs;

View File

@@ -51,8 +51,8 @@ import { VaultTimeoutService } from "@bitwarden/common/services/vaultTimeout/vau
import { VaultTimeoutSettingsService } from "@bitwarden/common/services/vaultTimeout/vaultTimeoutSettings.service";
import { CliPlatformUtilsService } from "@bitwarden/node/cli/services/cliPlatformUtils.service";
import { ConsoleLogService } from "@bitwarden/node/cli/services/consoleLog.service";
import { NodeCryptoFunctionService } from "@bitwarden/node/services/node-crypto-function.service";
import { NodeApiService } from "@bitwarden/node/services/nodeApi.service";
import { NodeCryptoFunctionService } from "@bitwarden/node/services/nodeCryptoFunction.service";
import { Program } from "./program";
import { SendProgram } from "./send.program";

View File

@@ -88,7 +88,7 @@ export class DeleteCommand {
}
private async deleteFolder(id: string) {
const folder = await this.folderService.get(id);
const folder = await this.folderService.getFromState(id);
if (folder == null) {
return Response.notFound();
}

View File

@@ -118,7 +118,7 @@ export class EditCommand {
}
private async editFolder(id: string, req: FolderExport) {
const folder = await this.folderService.get(id);
const folder = await this.folderService.getFromState(id);
if (folder == null) {
return Response.notFound();
}

View File

@@ -353,7 +353,7 @@ export class GetCommand extends DownloadCommand {
private async getFolder(id: string) {
let decFolder: FolderView = null;
if (Utils.isGuid(id)) {
const folder = await this.folderService.get(id);
const folder = await this.folderService.getFromState(id);
if (folder != null) {
decFolder = await folder.decrypt();
}

View File

@@ -30,6 +30,6 @@
},
"_moduleAliases": {
"@bitwarden/common": "dist/libs/common/src",
"@bitwarden/node/services/nodeCryptoFunction.service": "dist/libs/node/src/services/nodeCryptoFunction.service"
"@bitwarden/node/services/node-crypto-function.service": "dist/libs/node/src/services/node-crypto-function.service"
}
}

View File

@@ -7,7 +7,7 @@ import { EncString } from "@bitwarden/common/models/domain/enc-string";
import { SymmetricCryptoKey } from "@bitwarden/common/models/domain/symmetric-crypto-key";
import { ConsoleLogService } from "@bitwarden/common/services/consoleLog.service";
import { EncryptServiceImplementation } from "@bitwarden/common/services/cryptography/encrypt.service.implementation";
import { NodeCryptoFunctionService } from "@bitwarden/node/services/nodeCryptoFunction.service";
import { NodeCryptoFunctionService } from "@bitwarden/node/services/node-crypto-function.service";
import { DecryptedCommandData } from "../../src/models/nativeMessaging/decryptedCommandData";
import { EncryptedMessage } from "../../src/models/nativeMessaging/encryptedMessage";