1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-25911] Add commercial sdk internal as dependency (#16883)

* feat: add commercial sdk as optional dependency

* feat: add alias to CLI

* feat: add alias to browser

* feat: add alias to web

* fix: revert optional - we cant omit optional dependencies or the builds break

* feat: remove commercial package from browser build

* feat: remove commercial package from cli build

* feat: remove commercial package from web build

* chore: add commercial sdk to renovate

* fix: windows cli workflow

* fix: accidental change

* feat: add lint for version string

* undo weird merge changes
This commit is contained in:
Andreas Coroiu
2025-10-27 15:17:20 +01:00
committed by GitHub
parent abc6e54bb9
commit 64590cb3c8
16 changed files with 139 additions and 6 deletions

View File

@@ -139,6 +139,7 @@
"@babel/core", "@babel/core",
"@babel/preset-env", "@babel/preset-env",
"@bitwarden/sdk-internal", "@bitwarden/sdk-internal",
"@bitwarden/commercial-sdk-internal",
"@electron/fuses", "@electron/fuses",
"@electron/notarize", "@electron/notarize",
"@electron/rebuild", "@electron/rebuild",

View File

@@ -219,12 +219,14 @@ jobs:
archive_name_prefix: "" archive_name_prefix: ""
npm_command_prefix: "dist:" npm_command_prefix: "dist:"
readable: "open source license" readable: "open source license"
type: "oss"
- build_prefix: "bit-" - build_prefix: "bit-"
artifact_prefix: "bit-" artifact_prefix: "bit-"
source_archive_name_prefix: "bit-" source_archive_name_prefix: "bit-"
archive_name_prefix: "bit-" archive_name_prefix: "bit-"
npm_command_prefix: "dist:bit:" npm_command_prefix: "dist:bit:"
readable: "commercial license" readable: "commercial license"
type: "commercial"
browser: browser:
- name: "chrome" - name: "chrome"
npm_command_suffix: "chrome" npm_command_suffix: "chrome"
@@ -279,6 +281,11 @@ jobs:
run: npm ci run: npm ci
working-directory: browser-source/ working-directory: browser-source/
- name: Remove commercial packages
if: ${{ matrix.license_type.type == 'oss' }}
run: rm -rf node_modules/@bitwarden/commercial-sdk-internal
working-directory: browser-source/
- name: Download SDK artifacts - name: Download SDK artifacts
if: ${{ inputs.sdk_branch != '' }} if: ${{ inputs.sdk_branch != '' }}
uses: bitwarden/gh-actions/download-artifacts@main uses: bitwarden/gh-actions/download-artifacts@main
@@ -350,11 +357,13 @@ jobs:
archive_name_prefix: "" archive_name_prefix: ""
npm_command_prefix: "dist:" npm_command_prefix: "dist:"
readable: "open source license" readable: "open source license"
type: "oss"
- build_prefix: "bit-" - build_prefix: "bit-"
artifact_prefix: "bit-" artifact_prefix: "bit-"
archive_name_prefix: "bit-" archive_name_prefix: "bit-"
npm_command_prefix: "dist:bit:" npm_command_prefix: "dist:bit:"
readable: "commercial license" readable: "commercial license"
type: "commercial"
env: env:
_BUILD_NUMBER: ${{ needs.setup.outputs.adj_build_number }} _BUILD_NUMBER: ${{ needs.setup.outputs.adj_build_number }}
_NODE_VERSION: ${{ needs.setup.outputs.node_version }} _NODE_VERSION: ${{ needs.setup.outputs.node_version }}
@@ -461,6 +470,11 @@ jobs:
run: npm ci run: npm ci
working-directory: ./ working-directory: ./
- name: Remove commercial packages
if: ${{ matrix.license_type.type == 'oss' }}
run: rm -rf node_modules/@bitwarden/commercial-sdk-internal
working-directory: ./
- name: Download SDK Artifacts - name: Download SDK Artifacts
if: ${{ inputs.sdk_branch != '' }} if: ${{ inputs.sdk_branch != '' }}
uses: bitwarden/gh-actions/download-artifacts@main uses: bitwarden/gh-actions/download-artifacts@main

View File

@@ -98,8 +98,8 @@ jobs:
] ]
license_type: license_type:
[ [
{ build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" }, { type: "oss", build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" },
{ build_prefix: "bit", artifact_prefix: "", readable: "commercial license" } { type: "commercial", build_prefix: "bit", artifact_prefix: "", readable: "commercial license" }
] ]
runs-on: ${{ matrix.os.distro }} runs-on: ${{ matrix.os.distro }}
needs: setup needs: setup
@@ -140,6 +140,11 @@ jobs:
run: npm ci run: npm ci
working-directory: ./ working-directory: ./
- name: Remove commercial packages
if: ${{ matrix.license_type.type == 'oss' }}
run: rm -rf node_modules/@bitwarden/commercial-sdk-internal
working-directory: ./
- name: Download SDK Artifacts - name: Download SDK Artifacts
if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }} if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }}
uses: bitwarden/gh-actions/download-artifacts@main uses: bitwarden/gh-actions/download-artifacts@main
@@ -291,8 +296,8 @@ jobs:
matrix: matrix:
license_type: license_type:
[ [
{ build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" }, { type: "oss", build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" },
{ build_prefix: "bit", artifact_prefix: "", readable: "commercial license" } { type: "commercial", build_prefix: "bit", artifact_prefix: "", readable: "commercial license" }
] ]
runs-on: windows-2022 runs-on: windows-2022
permissions: permissions:
@@ -410,6 +415,11 @@ jobs:
run: npm ci run: npm ci
working-directory: ./ working-directory: ./
- name: Remove commercial packages
if: ${{ matrix.license_type.type == 'oss' }}
run: Remove-Item -Recurse -Force -ErrorAction SilentlyContinue "node_modules/@bitwarden/commercial-sdk-internal"
working-directory: ./
- name: Download SDK Artifacts - name: Download SDK Artifacts
if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }} if: ${{ inputs.sdk_branch != '' && needs.setup.outputs.has_secrets == 'true' }}
uses: bitwarden/gh-actions/download-artifacts@main uses: bitwarden/gh-actions/download-artifacts@main

View File

@@ -99,34 +99,43 @@ jobs:
matrix: matrix:
include: include:
- artifact_name: selfhosted-open-source - artifact_name: selfhosted-open-source
license_type: "oss"
image_name: web-oss image_name: web-oss
npm_command: dist:oss:selfhost npm_command: dist:oss:selfhost
- artifact_name: cloud-COMMERCIAL - artifact_name: cloud-COMMERCIAL
license_type: "commercial"
image_name: web-cloud image_name: web-cloud
npm_command: dist:bit:cloud npm_command: dist:bit:cloud
- artifact_name: selfhosted-COMMERCIAL - artifact_name: selfhosted-COMMERCIAL
license_type: "commercial"
image_name: web image_name: web
npm_command: dist:bit:selfhost npm_command: dist:bit:selfhost
- artifact_name: selfhosted-DEV - artifact_name: selfhosted-DEV
license_type: "commercial"
image_name: web image_name: web
npm_command: build:bit:selfhost:dev npm_command: build:bit:selfhost:dev
git_metadata: true git_metadata: true
- artifact_name: cloud-QA - artifact_name: cloud-QA
license_type: "commercial"
image_name: web-qa-cloud image_name: web-qa-cloud
npm_command: build:bit:qa npm_command: build:bit:qa
git_metadata: true git_metadata: true
- artifact_name: ee - artifact_name: ee
license_type: "commercial"
image_name: web-ee image_name: web-ee
npm_command: build:bit:ee npm_command: build:bit:ee
git_metadata: true git_metadata: true
- artifact_name: cloud-euprd - artifact_name: cloud-euprd
license_type: "commercial"
image_name: web-euprd image_name: web-euprd
npm_command: build:bit:euprd npm_command: build:bit:euprd
- artifact_name: cloud-euqa - artifact_name: cloud-euqa
license_type: "commercial"
image_name: web-euqa image_name: web-euqa
npm_command: build:bit:euqa npm_command: build:bit:euqa
git_metadata: true git_metadata: true
- artifact_name: cloud-usdev - artifact_name: cloud-usdev
license_type: "commercial"
image_name: web-usdev image_name: web-usdev
npm_command: build:bit:usdev npm_command: build:bit:usdev
git_metadata: true git_metadata: true
@@ -269,6 +278,7 @@ jobs:
build-args: | build-args: |
NODE_VERSION=${{ env._NODE_VERSION }} NODE_VERSION=${{ env._NODE_VERSION }}
NPM_COMMAND=${{ matrix.npm_command }} NPM_COMMAND=${{ matrix.npm_command }}
LICENSE_TYPE=${{ matrix.license_type }}
context: . context: .
file: apps/web/Dockerfile file: apps/web/Dockerfile
load: true load: true

View File

@@ -75,6 +75,9 @@ jobs:
- name: Lint unowned dependencies - name: Lint unowned dependencies
run: npm run lint:dep-ownership run: npm run lint:dep-ownership
- name: Lint sdk-internal versions
run: npm run lint:sdk-internal-versions
- name: Run linter - name: Run linter
run: npm run lint run: npm run lint

View File

@@ -36,7 +36,8 @@ const DEFAULT_PARAMS = {
* outputPath?: string; * outputPath?: string;
* mode?: string; * mode?: string;
* env?: string; * env?: string;
* additionalEntries?: { [outputPath: string]: string } * additionalEntries?: { [outputPath: string]: string };
* importAliases?: import("webpack").ResolveOptions["alias"];
* }} params - The input parameters for building the config. * }} params - The input parameters for building the config.
*/ */
module.exports.buildConfig = function buildConfig(params) { module.exports.buildConfig = function buildConfig(params) {
@@ -362,6 +363,7 @@ module.exports.buildConfig = function buildConfig(params) {
path: require.resolve("path-browserify"), path: require.resolve("path-browserify"),
}, },
cache: true, cache: true,
alias: params.importAliases,
}, },
output: { output: {
filename: "[name].js", filename: "[name].js",
@@ -482,6 +484,7 @@ module.exports.buildConfig = function buildConfig(params) {
path: require.resolve("path-browserify"), path: require.resolve("path-browserify"),
}, },
cache: true, cache: true,
alias: params.importAliases,
}, },
dependencies: ["main"], dependencies: ["main"],
plugins: [...requiredPlugins, new AngularCheckPlugin()], plugins: [...requiredPlugins, new AngularCheckPlugin()],

View File

@@ -31,6 +31,7 @@ const DEFAULT_PARAMS = {
* localesPath?: string; * localesPath?: string;
* externalsModulesDir?: string; * externalsModulesDir?: string;
* watch?: boolean; * watch?: boolean;
* importAliases?: import("webpack").ResolveOptions["alias"];
* }} params * }} params
*/ */
module.exports.buildConfig = function buildConfig(params) { module.exports.buildConfig = function buildConfig(params) {
@@ -95,6 +96,7 @@ module.exports.buildConfig = function buildConfig(params) {
symlinks: false, symlinks: false,
modules: params.modulesPath, modules: params.modulesPath,
plugins: [new TsconfigPathsPlugin({ configFile: params.tsConfig })], plugins: [new TsconfigPathsPlugin({ configFile: params.tsConfig })],
alias: params.importAliases,
}, },
output: { output: {
filename: "[name].js", filename: "[name].js",

View File

@@ -9,6 +9,12 @@ COPY package*.json ./
COPY . . COPY . .
RUN npm ci RUN npm ci
# Remove commercial packages if LICENSE_TYPE is not 'commercial'
ARG LICENSE_TYPE=oss
RUN if [ "${LICENSE_TYPE}" != "commercial" ] ; then \
rm -rf node_modules/@bitwarden/commercial-sdk-internal ; \
fi
WORKDIR /source/apps/web WORKDIR /source/apps/web
ARG NPM_COMMAND=dist:bit:selfhost ARG NPM_COMMAND=dist:bit:selfhost
RUN npm run ${NPM_COMMAND} RUN npm run ${NPM_COMMAND}

View File

@@ -36,6 +36,7 @@ const DEFAULT_PARAMS = {
* outputPath?: string; * outputPath?: string;
* mode?: string; * mode?: string;
* env?: string; * env?: string;
* importAliases?: import("webpack").ResolveOptions["alias"];
* }} params * }} params
*/ */
module.exports.buildConfig = function buildConfig(params) { module.exports.buildConfig = function buildConfig(params) {
@@ -460,6 +461,7 @@ module.exports.buildConfig = function buildConfig(params) {
process: false, process: false,
path: require.resolve("path-browserify"), path: require.resolve("path-browserify"),
}, },
alias: params.importAliases,
}, },
output: { output: {
filename: "[name].[contenthash].js", filename: "[name].[contenthash].js",

View File

@@ -36,6 +36,12 @@ module.exports = (webpackConfig, context) => {
: context.options.outputPath, : context.options.outputPath,
mode: mode, mode: mode,
env: ENV, env: ENV,
importAliases: [
{
name: "@bitwarden/sdk-internal",
alias: "@bitwarden/commercial-sdk-internal",
},
],
}); });
} else { } else {
// npm build configuration // npm build configuration
@@ -49,6 +55,12 @@ module.exports = (webpackConfig, context) => {
entry: path.resolve(__dirname, "src/platform/background.ts"), entry: path.resolve(__dirname, "src/platform/background.ts"),
}, },
tsConfig: path.resolve(__dirname, "tsconfig.json"), tsConfig: path.resolve(__dirname, "tsconfig.json"),
importAliases: [
{
name: "@bitwarden/sdk-internal",
alias: "@bitwarden/commercial-sdk-internal",
},
],
}); });
} }
}; };

View File

@@ -24,6 +24,12 @@ module.exports = (webpackConfig, context) => {
localesPath: "apps/cli/src/locales", localesPath: "apps/cli/src/locales",
externalsModulesDir: "node_modules", externalsModulesDir: "node_modules",
watch: context.options.watch || false, watch: context.options.watch || false,
importAliases: [
{
name: "@bitwarden/sdk-internal",
alias: "@bitwarden/commercial-sdk-internal",
},
],
}); });
} else { } else {
// npm build configuration // npm build configuration
@@ -43,6 +49,12 @@ module.exports = (webpackConfig, context) => {
modulesPath: [path.resolve("../../node_modules")], modulesPath: [path.resolve("../../node_modules")],
localesPath: "../../apps/cli/src/locales", localesPath: "../../apps/cli/src/locales",
externalsModulesDir: "../../node_modules", externalsModulesDir: "../../node_modules",
importAliases: [
{
name: "@bitwarden/sdk-internal",
alias: "@bitwarden/commercial-sdk-internal",
},
],
}); });
} }
}; };

View File

@@ -17,6 +17,12 @@ module.exports = (webpackConfig, context) => {
context.context && context.context.root context.context && context.context.root
? path.resolve(context.context.root, context.options.outputPath) ? path.resolve(context.context.root, context.options.outputPath)
: context.options.outputPath, : context.options.outputPath,
importAliases: [
{
name: "@bitwarden/sdk-internal",
alias: "@bitwarden/commercial-sdk-internal",
},
],
}); });
} else { } else {
return buildConfig({ return buildConfig({
@@ -26,6 +32,12 @@ module.exports = (webpackConfig, context) => {
entryModule: "bitwarden_license/bit-web/src/app/app.module#AppModule", entryModule: "bitwarden_license/bit-web/src/app/app.module#AppModule",
}, },
tsConfig: path.resolve(__dirname, "tsconfig.build.json"), tsConfig: path.resolve(__dirname, "tsconfig.build.json"),
importAliases: [
{
name: "@bitwarden/sdk-internal",
alias: "@bitwarden/commercial-sdk-internal",
},
],
}); });
} }
}; };

22
package-lock.json generated
View File

@@ -23,6 +23,7 @@
"@angular/platform-browser": "19.2.14", "@angular/platform-browser": "19.2.14",
"@angular/platform-browser-dynamic": "19.2.14", "@angular/platform-browser-dynamic": "19.2.14",
"@angular/router": "19.2.14", "@angular/router": "19.2.14",
"@bitwarden/commercial-sdk-internal": "0.2.0-main.357",
"@bitwarden/sdk-internal": "0.2.0-main.357", "@bitwarden/sdk-internal": "0.2.0-main.357",
"@electron/fuses": "1.8.0", "@electron/fuses": "1.8.0",
"@emotion/css": "11.13.5", "@emotion/css": "11.13.5",
@@ -4605,6 +4606,27 @@
"resolved": "libs/client-type", "resolved": "libs/client-type",
"link": true "link": true
}, },
"node_modules/@bitwarden/commercial-sdk-internal": {
"version": "0.2.0-main.357",
"resolved": "https://registry.npmjs.org/@bitwarden/commercial-sdk-internal/-/commercial-sdk-internal-0.2.0-main.357.tgz",
"integrity": "sha512-eIArJelJKwG+aEGbtdhc5dKRBFopmyGJl+ClUQGJUFHzfrPGDcaSI04a/sSUK0NtbaxQOsf8qSvk+iKvISkKmw==",
"license": "BITWARDEN SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT",
"dependencies": {
"type-fest": "^4.41.0"
}
},
"node_modules/@bitwarden/commercial-sdk-internal/node_modules/type-fest": {
"version": "4.41.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz",
"integrity": "sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==",
"license": "(MIT OR CC0-1.0)",
"engines": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@bitwarden/common": { "node_modules/@bitwarden/common": {
"resolved": "libs/common", "resolved": "libs/common",
"link": true "link": true

View File

@@ -24,6 +24,7 @@
"test:types": "node ./scripts/test-types.js", "test:types": "node ./scripts/test-types.js",
"test:locales": "tsc --project ./scripts/tsconfig.json && node ./scripts/dist/test-locales.js", "test:locales": "tsc --project ./scripts/tsconfig.json && node ./scripts/dist/test-locales.js",
"lint:dep-ownership": "tsc --project ./scripts/tsconfig.json && node ./scripts/dist/dep-ownership.js", "lint:dep-ownership": "tsc --project ./scripts/tsconfig.json && node ./scripts/dist/dep-ownership.js",
"lint:sdk-internal-versions": "tsc --project ./scripts/tsconfig.json && node ./scripts/dist/sdk-internal-versions.js",
"docs:json": "compodoc -p ./tsconfig.json -e json -d . --disableRoutesGraph", "docs:json": "compodoc -p ./tsconfig.json -e json -d . --disableRoutesGraph",
"storybook": "ng run components:storybook", "storybook": "ng run components:storybook",
"build-storybook": "ng run components:build-storybook", "build-storybook": "ng run components:build-storybook",
@@ -160,6 +161,7 @@
"@angular/platform-browser-dynamic": "19.2.14", "@angular/platform-browser-dynamic": "19.2.14",
"@angular/router": "19.2.14", "@angular/router": "19.2.14",
"@bitwarden/sdk-internal": "0.2.0-main.357", "@bitwarden/sdk-internal": "0.2.0-main.357",
"@bitwarden/commercial-sdk-internal": "0.2.0-main.357",
"@electron/fuses": "1.8.0", "@electron/fuses": "1.8.0",
"@emotion/css": "11.13.5", "@emotion/css": "11.13.5",
"@koa/multer": "4.0.0", "@koa/multer": "4.0.0",

View File

@@ -0,0 +1,22 @@
/* eslint-disable no-console */
/// Ensure that `sdk-internal` and `commercial-sdk-internal` dependencies have matching versions.
import fs from "fs";
import path from "path";
const packageJson = JSON.parse(
fs.readFileSync(path.join(__dirname, "..", "..", "package.json"), "utf8"),
);
const sdkInternal = packageJson.dependencies["@bitwarden/sdk-internal"];
const commercialSdkInternal = packageJson.dependencies["@bitwarden/commercial-sdk-internal"];
if (sdkInternal !== commercialSdkInternal) {
console.error(
`Version mismatch between @bitwarden/sdk-internal (${sdkInternal}) and @bitwarden/commercial-sdk-internal (${commercialSdkInternal}), must be an exact match.`,
);
process.exit(1);
}
console.log(`All dependencies have matching versions: ${sdkInternal}`);