mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 05:43:41 +00:00
[PM-12989] Create process for qa to build client with particular sdk version (#11601)
* feat: update sdk service abstraction with documentation and new `userClient$` function * feat: add uninitialized user client with cache * feat: initialize user crypto * feat: initialize org keys * fix: org crypto not initializing properly * feat: avoid creating clients unnecessarily * chore: remove dev print/subscription * fix: clean up cache * chore: update sdk version * feat: implement clean-up logic (#11504) * chore: bump sdk version to fix build issues * chore: bump sdk version to fix build issues * fix: missing constructor parameters * refactor: simplify free() and delete() calls * refactor: use a named function for client creation * fix: client never freeing after refactor * fix: broken impl and race condition in tests * feat: add sdk override to desktop build * feat: add SDK version to browser about dialog * feat: add sdk override to browser build * fix: `npm ci` overriding the override * fix: artifacts not properly downloaded * fix: switch to new repository * feat: add debug version function to web * feat: add sdk-version to CLI * feat: add version to desktop * feat: add override to cli * feat: add override to web * fix: cli version acting as default command * fix: consistent workflow input name * feat: add error handling * feat: upgrade sdk-internal * fix: forgot to update package lock * fix: broken CI build move sdk version to a regular command * chore: revert version changes * refactor: move error handling code * chore: bump SDK to 0.2.0.main-1 * fix: clean up references to inputs.sdk_commit * refactor: rename `init` to `applyVersionToWindow`
This commit is contained in:
44
.github/workflows/build-browser.yml
vendored
44
.github/workflows/build-browser.yml
vendored
@@ -27,7 +27,11 @@ on:
|
|||||||
workflow_call:
|
workflow_call:
|
||||||
inputs: {}
|
inputs: {}
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs: {}
|
inputs:
|
||||||
|
sdk_branch:
|
||||||
|
description: "Custom SDK branch"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -168,6 +172,25 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: browser-source/
|
working-directory: browser-source/
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: browser-source/
|
||||||
|
run: |
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npm run dist
|
run: npm run dist
|
||||||
working-directory: browser-source/apps/browser
|
working-directory: browser-source/apps/browser
|
||||||
@@ -331,6 +354,25 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Build Safari extension
|
- name: Build Safari extension
|
||||||
run: npm run dist:safari
|
run: npm run dist:safari
|
||||||
working-directory: apps/browser
|
working-directory: apps/browser
|
||||||
|
|||||||
46
.github/workflows/build-cli.yml
vendored
46
.github/workflows/build-cli.yml
vendored
@@ -28,7 +28,11 @@ on:
|
|||||||
- '.github/workflows/build-cli.yml'
|
- '.github/workflows/build-cli.yml'
|
||||||
- 'bitwarden_license/bit-cli/**'
|
- 'bitwarden_license/bit-cli/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs: {}
|
inputs:
|
||||||
|
sdk_branch:
|
||||||
|
description: "Custom SDK branch"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -112,6 +116,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Build & Package Unix
|
- name: Build & Package Unix
|
||||||
run: npm run dist:${{ matrix.license_type.build_prefix }}:${{ env.SHORT_RUNNER_OS }} --quiet
|
run: npm run dist:${{ matrix.license_type.build_prefix }}:${{ env.SHORT_RUNNER_OS }} --quiet
|
||||||
|
|
||||||
@@ -247,6 +271,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Build & Package Windows
|
- name: Build & Package Windows
|
||||||
run: npm run dist:${{ matrix.license_type.build_prefix }}:win --quiet
|
run: npm run dist:${{ matrix.license_type.build_prefix }}:win --quiet
|
||||||
|
|
||||||
|
|||||||
126
.github/workflows/build-desktop.yml
vendored
126
.github/workflows/build-desktop.yml
vendored
@@ -26,7 +26,11 @@ on:
|
|||||||
- '!*.txt'
|
- '!*.txt'
|
||||||
- '.github/workflows/build-desktop.yml'
|
- '.github/workflows/build-desktop.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs: {}
|
inputs:
|
||||||
|
sdk_branch:
|
||||||
|
description: "Custom SDK branch"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
@@ -182,6 +186,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Cache Native Module
|
- name: Cache Native Module
|
||||||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
id: cache
|
id: cache
|
||||||
@@ -328,6 +352,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Cache Native Module
|
- name: Cache Native Module
|
||||||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
id: cache
|
id: cache
|
||||||
@@ -616,6 +660,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Cache Native Module
|
- name: Cache Native Module
|
||||||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
id: cache
|
id: cache
|
||||||
@@ -784,6 +848,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Cache Native Module
|
- name: Cache Native Module
|
||||||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
id: cache
|
id: cache
|
||||||
@@ -1012,6 +1096,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Cache Native Module
|
- name: Cache Native Module
|
||||||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
id: cache
|
id: cache
|
||||||
@@ -1247,6 +1351,26 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: ./
|
working-directory: ./
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Cache Native Module
|
- name: Cache Native Module
|
||||||
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
|
||||||
id: cache
|
id: cache
|
||||||
|
|||||||
24
.github/workflows/build-web.yml
vendored
24
.github/workflows/build-web.yml
vendored
@@ -32,6 +32,10 @@ on:
|
|||||||
custom_tag_extension:
|
custom_tag_extension:
|
||||||
description: "Custom image tag extension"
|
description: "Custom image tag extension"
|
||||||
required: false
|
required: false
|
||||||
|
sdk_branch:
|
||||||
|
description: "Custom SDK branch"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
env:
|
env:
|
||||||
_AZ_REGISTRY: bitwardenprod.azurecr.io
|
_AZ_REGISTRY: bitwardenprod.azurecr.io
|
||||||
@@ -124,6 +128,26 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Download SDK Artifacts
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
uses: bitwarden/gh-actions/download-artifacts@main
|
||||||
|
with:
|
||||||
|
github_token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
workflow: build-wasm-internal.yml
|
||||||
|
workflow_conclusion: success
|
||||||
|
branch: ${{ inputs.sdk_branch }}
|
||||||
|
artifacts: sdk-internal
|
||||||
|
repo: bitwarden/sdk-internal
|
||||||
|
path: ../sdk-internal
|
||||||
|
if_no_artifact_found: fail
|
||||||
|
|
||||||
|
- name: Override SDK
|
||||||
|
if: ${{ inputs.sdk_branch != '' }}
|
||||||
|
working-directory: ./
|
||||||
|
run: |
|
||||||
|
ls -l ../
|
||||||
|
npm link ../sdk-internal
|
||||||
|
|
||||||
- name: Add Git metadata to build version
|
- name: Add Git metadata to build version
|
||||||
working-directory: apps/web
|
working-directory: apps/web
|
||||||
if: matrix.git_metadata
|
if: matrix.git_metadata
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<div bitDialogContent>
|
<div bitDialogContent>
|
||||||
<p>© Bitwarden Inc. 2015-{{ year }}</p>
|
<p>© Bitwarden Inc. 2015-{{ year }}</p>
|
||||||
<p class="user-select">{{ "version" | i18n }}: {{ version$ | async }}</p>
|
<p class="user-select">{{ "version" | i18n }}: {{ version$ | async }}</p>
|
||||||
|
<p class="user-select">SDK: {{ sdkVersion$ | async }}</p>
|
||||||
<ng-container *ngIf="data$ | async as data">
|
<ng-container *ngIf="data$ | async as data">
|
||||||
<p *ngIf="data.isCloud">
|
<p *ngIf="data.isCloud">
|
||||||
{{ "serverVersion" | i18n }}: {{ data.serverConfig?.version }}
|
{{ "serverVersion" | i18n }}: {{ data.serverConfig?.version }}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
|
|||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
|
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||||
import { ButtonModule, DialogModule } from "@bitwarden/components";
|
import { ButtonModule, DialogModule } from "@bitwarden/components";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -22,10 +23,13 @@ export class AboutDialogComponent {
|
|||||||
this.environmentService.environment$.pipe(map((env) => env.isCloud())),
|
this.environmentService.environment$.pipe(map((env) => env.isCloud())),
|
||||||
]).pipe(map(([serverConfig, isCloud]) => ({ serverConfig, isCloud })));
|
]).pipe(map(([serverConfig, isCloud]) => ({ serverConfig, isCloud })));
|
||||||
|
|
||||||
|
protected sdkVersion$ = this.sdkService.version$;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private configService: ConfigService,
|
private configService: ConfigService,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
|
private sdkService: SdkService,
|
||||||
) {
|
) {
|
||||||
this.version$ = defer(() => this.platformUtilsService.getApplicationVersion());
|
this.version$ = defer(() => this.platformUtilsService.getApplicationVersion());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as chalk from "chalk";
|
import * as chalk from "chalk";
|
||||||
import { program, Command, OptionValues } from "commander";
|
import { program, Command, OptionValues } from "commander";
|
||||||
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
|
||||||
|
|
||||||
@@ -102,6 +103,14 @@ export class Program extends BaseProgram {
|
|||||||
writeLn("", true);
|
writeLn("", true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("sdk-version")
|
||||||
|
.description("Print the SDK version.")
|
||||||
|
.action(async () => {
|
||||||
|
const sdkVersion = await firstValueFrom(this.serviceContainer.sdkService.version$);
|
||||||
|
writeLn(sdkVersion, true);
|
||||||
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
.command("login [email] [password]")
|
.command("login [email] [password]")
|
||||||
.description("Log into a user account.")
|
.description("Log into a user account.")
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { KeyService as KeyServiceAbstraction } from "@bitwarden/key-management";
|
|||||||
|
|
||||||
import { I18nRendererService } from "../../platform/services/i18n.renderer.service";
|
import { I18nRendererService } from "../../platform/services/i18n.renderer.service";
|
||||||
import { SshAgentService } from "../../platform/services/ssh-agent.service";
|
import { SshAgentService } from "../../platform/services/ssh-agent.service";
|
||||||
|
import { VersionService } from "../../platform/services/version.service";
|
||||||
import { NativeMessagingService } from "../../services/native-messaging.service";
|
import { NativeMessagingService } from "../../services/native-messaging.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -42,6 +43,7 @@ export class InitService {
|
|||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private userAutoUnlockKeyService: UserAutoUnlockKeyService,
|
private userAutoUnlockKeyService: UserAutoUnlockKeyService,
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
|
private versionService: VersionService,
|
||||||
private sshAgentService: SshAgentService,
|
private sshAgentService: SshAgentService,
|
||||||
@Inject(DOCUMENT) private document: Document,
|
@Inject(DOCUMENT) private document: Document,
|
||||||
) {}
|
) {}
|
||||||
@@ -76,6 +78,8 @@ export class InitService {
|
|||||||
htmlEl.classList.add("os_" + this.platformUtilsService.getDeviceString());
|
htmlEl.classList.add("os_" + this.platformUtilsService.getDeviceString());
|
||||||
this.themingService.applyThemeChangesTo(this.document);
|
this.themingService.applyThemeChangesTo(this.document);
|
||||||
|
|
||||||
|
this.versionService.init();
|
||||||
|
|
||||||
const containerService = new ContainerService(this.keyService, this.encryptService);
|
const containerService = new ContainerService(this.keyService, this.encryptService);
|
||||||
containerService.attachToGlobal(this.win);
|
containerService.attachToGlobal(this.win);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import { ClipboardMain } from "./platform/main/clipboard.main";
|
|||||||
import { DesktopCredentialStorageListener } from "./platform/main/desktop-credential-storage-listener";
|
import { DesktopCredentialStorageListener } from "./platform/main/desktop-credential-storage-listener";
|
||||||
import { MainCryptoFunctionService } from "./platform/main/main-crypto-function.service";
|
import { MainCryptoFunctionService } from "./platform/main/main-crypto-function.service";
|
||||||
import { MainSshAgentService } from "./platform/main/main-ssh-agent.service";
|
import { MainSshAgentService } from "./platform/main/main-ssh-agent.service";
|
||||||
|
import { VersionMain } from "./platform/main/version.main";
|
||||||
import { DesktopSettingsService } from "./platform/services/desktop-settings.service";
|
import { DesktopSettingsService } from "./platform/services/desktop-settings.service";
|
||||||
import { ElectronLogMainService } from "./platform/services/electron-log.main.service";
|
import { ElectronLogMainService } from "./platform/services/electron-log.main.service";
|
||||||
import { ElectronStorageService } from "./platform/services/electron-storage.service";
|
import { ElectronStorageService } from "./platform/services/electron-storage.service";
|
||||||
@@ -72,6 +73,7 @@ export class Main {
|
|||||||
nativeMessagingMain: NativeMessagingMain;
|
nativeMessagingMain: NativeMessagingMain;
|
||||||
clipboardMain: ClipboardMain;
|
clipboardMain: ClipboardMain;
|
||||||
desktopAutofillSettingsService: DesktopAutofillSettingsService;
|
desktopAutofillSettingsService: DesktopAutofillSettingsService;
|
||||||
|
versionMain: VersionMain;
|
||||||
sshAgentService: MainSshAgentService;
|
sshAgentService: MainSshAgentService;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -199,6 +201,8 @@ export class Main {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.versionMain = new VersionMain(this.windowMain);
|
||||||
|
|
||||||
this.powerMonitorMain = new PowerMonitorMain(this.messagingService, this.logService);
|
this.powerMonitorMain = new PowerMonitorMain(this.messagingService, this.logService);
|
||||||
this.menuMain = new MenuMain(
|
this.menuMain = new MenuMain(
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
@@ -207,6 +211,7 @@ export class Main {
|
|||||||
this.windowMain,
|
this.windowMain,
|
||||||
this.updaterMain,
|
this.updaterMain,
|
||||||
this.desktopSettingsService,
|
this.desktopSettingsService,
|
||||||
|
this.versionMain,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.biometricsService = new BiometricsService(
|
this.biometricsService = new BiometricsService(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { BrowserWindow, clipboard, dialog, MenuItemConstructorOptions } from "el
|
|||||||
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
|
||||||
|
import { VersionMain } from "../../platform/main/version.main";
|
||||||
import { isMacAppStore, isSnapStore, isWindowsStore } from "../../utils";
|
import { isMacAppStore, isSnapStore, isWindowsStore } from "../../utils";
|
||||||
import { UpdaterMain } from "../updater.main";
|
import { UpdaterMain } from "../updater.main";
|
||||||
|
|
||||||
@@ -22,17 +23,20 @@ export class AboutMenu implements IMenubarMenu {
|
|||||||
private readonly _updater: UpdaterMain;
|
private readonly _updater: UpdaterMain;
|
||||||
private readonly _window: BrowserWindow;
|
private readonly _window: BrowserWindow;
|
||||||
private readonly _version: string;
|
private readonly _version: string;
|
||||||
|
private readonly _versionMain: VersionMain;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
i18nService: I18nService,
|
i18nService: I18nService,
|
||||||
version: string,
|
version: string,
|
||||||
window: BrowserWindow,
|
window: BrowserWindow,
|
||||||
updater: UpdaterMain,
|
updater: UpdaterMain,
|
||||||
|
versionMain: VersionMain,
|
||||||
) {
|
) {
|
||||||
this._i18nService = i18nService;
|
this._i18nService = i18nService;
|
||||||
this._updater = updater;
|
this._updater = updater;
|
||||||
this._version = version;
|
this._version = version;
|
||||||
this._window = window;
|
this._window = window;
|
||||||
|
this._versionMain = versionMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get separator(): MenuItemConstructorOptions {
|
private get separator(): MenuItemConstructorOptions {
|
||||||
@@ -53,8 +57,11 @@ export class AboutMenu implements IMenubarMenu {
|
|||||||
id: "aboutBitwarden",
|
id: "aboutBitwarden",
|
||||||
label: this.localize("aboutBitwarden"),
|
label: this.localize("aboutBitwarden"),
|
||||||
click: async () => {
|
click: async () => {
|
||||||
|
const sdkVersion = await this._versionMain.sdkVersion();
|
||||||
const aboutInformation =
|
const aboutInformation =
|
||||||
this.localize("version", this._version) +
|
this.localize("version", this._version) +
|
||||||
|
"\nSDK " +
|
||||||
|
sdkVersion +
|
||||||
"\nShell " +
|
"\nShell " +
|
||||||
process.versions.electron +
|
process.versions.electron +
|
||||||
"\nRenderer " +
|
"\nRenderer " +
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
|
|||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
|
|
||||||
|
import { VersionMain } from "../../platform/main/version.main";
|
||||||
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
||||||
import { UpdaterMain } from "../updater.main";
|
import { UpdaterMain } from "../updater.main";
|
||||||
import { WindowMain } from "../window.main";
|
import { WindowMain } from "../window.main";
|
||||||
@@ -22,6 +23,7 @@ export class MenuMain {
|
|||||||
private windowMain: WindowMain,
|
private windowMain: WindowMain,
|
||||||
private updaterMain: UpdaterMain,
|
private updaterMain: UpdaterMain,
|
||||||
private desktopSettingsService: DesktopSettingsService,
|
private desktopSettingsService: DesktopSettingsService,
|
||||||
|
private versionMain: VersionMain,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
@@ -44,6 +46,7 @@ export class MenuMain {
|
|||||||
await this.getWebVaultUrl(),
|
await this.getWebVaultUrl(),
|
||||||
app.getVersion(),
|
app.getVersion(),
|
||||||
await firstValueFrom(this.desktopSettingsService.hardwareAcceleration$),
|
await firstValueFrom(this.desktopSettingsService.hardwareAcceleration$),
|
||||||
|
this.versionMain,
|
||||||
updateRequest,
|
updateRequest,
|
||||||
).menu,
|
).menu,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Menu, MenuItemConstructorOptions } from "electron";
|
|||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
|
|
||||||
|
import { VersionMain } from "../../platform/main/version.main";
|
||||||
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
|
||||||
import { isMac } from "../../utils";
|
import { isMac } from "../../utils";
|
||||||
import { UpdaterMain } from "../updater.main";
|
import { UpdaterMain } from "../updater.main";
|
||||||
@@ -54,6 +55,7 @@ export class Menubar {
|
|||||||
webVaultUrl: string,
|
webVaultUrl: string,
|
||||||
appVersion: string,
|
appVersion: string,
|
||||||
hardwareAccelerationEnabled: boolean,
|
hardwareAccelerationEnabled: boolean,
|
||||||
|
versionMain: VersionMain,
|
||||||
updateRequest?: MenuUpdateRequest,
|
updateRequest?: MenuUpdateRequest,
|
||||||
) {
|
) {
|
||||||
let isLocked = true;
|
let isLocked = true;
|
||||||
@@ -96,7 +98,7 @@ export class Menubar {
|
|||||||
desktopSettingsService,
|
desktopSettingsService,
|
||||||
webVaultUrl,
|
webVaultUrl,
|
||||||
hardwareAccelerationEnabled,
|
hardwareAccelerationEnabled,
|
||||||
new AboutMenu(i18nService, appVersion, windowMain.win, updaterMain),
|
new AboutMenu(i18nService, appVersion, windowMain.win, updaterMain, versionMain),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
17
apps/desktop/src/platform/main/version.main.ts
Normal file
17
apps/desktop/src/platform/main/version.main.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { ipcMain } from "electron";
|
||||||
|
|
||||||
|
import { WindowMain } from "../../main/window.main";
|
||||||
|
|
||||||
|
export class VersionMain {
|
||||||
|
constructor(private windowMain: WindowMain) {}
|
||||||
|
|
||||||
|
sdkVersion() {
|
||||||
|
const timeout = new Promise((resolve) => setTimeout(() => resolve("Timeout error"), 1000));
|
||||||
|
const version = new Promise((resolve) => {
|
||||||
|
ipcMain.once("sdkVersion", (_, version) => resolve(version));
|
||||||
|
this.windowMain.win.webContents.send("sdkVersion");
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise.race([timeout, version]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -122,6 +122,13 @@ const localhostCallbackService = {
|
|||||||
export default {
|
export default {
|
||||||
versions: {
|
versions: {
|
||||||
app: (): Promise<string> => ipcRenderer.invoke("appVersion"),
|
app: (): Promise<string> => ipcRenderer.invoke("appVersion"),
|
||||||
|
registerSdkVersionProvider: (provide: (resolve: (version: string) => void) => void) => {
|
||||||
|
const resolve = (version: string) => ipcRenderer.send("sdkVersion", version);
|
||||||
|
|
||||||
|
ipcRenderer.on("sdkVersion", () => {
|
||||||
|
provide(resolve);
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
deviceType: deviceType(),
|
deviceType: deviceType(),
|
||||||
isDev: isDev(),
|
isDev: isDev(),
|
||||||
|
|||||||
18
apps/desktop/src/platform/services/version.service.ts
Normal file
18
apps/desktop/src/platform/services/version.service.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
|
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: "root",
|
||||||
|
})
|
||||||
|
export class VersionService {
|
||||||
|
constructor(private sdkService: SdkService) {}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
ipc.platform.versions.registerSdkVersionProvider(async (resolve) => {
|
||||||
|
const version = await firstValueFrom(this.sdkService.version$);
|
||||||
|
resolve(version);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,8 @@ import { EventUploadService } from "@bitwarden/common/services/event/event-uploa
|
|||||||
import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service";
|
import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service";
|
||||||
import { KeyService as KeyServiceAbstraction } from "@bitwarden/key-management";
|
import { KeyService as KeyServiceAbstraction } from "@bitwarden/key-management";
|
||||||
|
|
||||||
|
import { VersionService } from "../platform/version.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InitService {
|
export class InitService {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -32,6 +34,7 @@ export class InitService {
|
|||||||
private encryptService: EncryptService,
|
private encryptService: EncryptService,
|
||||||
private userAutoUnlockKeyService: UserAutoUnlockKeyService,
|
private userAutoUnlockKeyService: UserAutoUnlockKeyService,
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
|
private versionService: VersionService,
|
||||||
@Inject(DOCUMENT) private document: Document,
|
@Inject(DOCUMENT) private document: Document,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -54,6 +57,8 @@ export class InitService {
|
|||||||
const htmlEl = this.win.document.documentElement;
|
const htmlEl = this.win.document.documentElement;
|
||||||
htmlEl.classList.add("locale_" + this.i18nService.translationLocale);
|
htmlEl.classList.add("locale_" + this.i18nService.translationLocale);
|
||||||
this.themingService.applyThemeChangesTo(this.document);
|
this.themingService.applyThemeChangesTo(this.document);
|
||||||
|
this.versionService.applyVersionToWindow();
|
||||||
|
|
||||||
const containerService = new ContainerService(this.keyService, this.encryptService);
|
const containerService = new ContainerService(this.keyService, this.encryptService);
|
||||||
containerService.attachToGlobal(this.win);
|
containerService.attachToGlobal(this.win);
|
||||||
};
|
};
|
||||||
|
|||||||
34
apps/web/src/app/platform/version.service.ts
Normal file
34
apps/web/src/app/platform/version.service.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { catchError, firstValueFrom, map } from "rxjs";
|
||||||
|
|
||||||
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
|
import { SdkService } from "@bitwarden/common/platform/abstractions/sdk/sdk.service";
|
||||||
|
|
||||||
|
type Version = {
|
||||||
|
client: string;
|
||||||
|
sdk: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: "root",
|
||||||
|
})
|
||||||
|
export class VersionService {
|
||||||
|
constructor(
|
||||||
|
private platformUtilsService: PlatformUtilsService,
|
||||||
|
private sdkService: SdkService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
applyVersionToWindow() {
|
||||||
|
(window as any).__version = async (): Promise<Version> => {
|
||||||
|
return {
|
||||||
|
client: await this.platformUtilsService.getApplicationVersion(),
|
||||||
|
sdk: await firstValueFrom(
|
||||||
|
this.sdkService.client$.pipe(
|
||||||
|
map((client) => client.version()),
|
||||||
|
catchError(() => "Unsupported"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,11 @@ export abstract class SdkService {
|
|||||||
*/
|
*/
|
||||||
supported$: Observable<boolean>;
|
supported$: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the version of the SDK.
|
||||||
|
*/
|
||||||
|
version$: Observable<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a client initialized without a user.
|
* Retrieve a client initialized without a user.
|
||||||
* This client can only be used for operations that don't require a user context.
|
* This client can only be used for operations that don't require a user context.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
distinctUntilChanged,
|
distinctUntilChanged,
|
||||||
tap,
|
tap,
|
||||||
switchMap,
|
switchMap,
|
||||||
|
catchError,
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
|
|
||||||
import { KeyService } from "@bitwarden/key-management";
|
import { KeyService } from "@bitwarden/key-management";
|
||||||
@@ -51,6 +52,11 @@ export class DefaultSdkService implements SdkService {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
version$ = this.client$.pipe(
|
||||||
|
map((client) => client.version()),
|
||||||
|
catchError(() => "Unsupported"),
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private sdkClientFactory: SdkClientFactory,
|
private sdkClientFactory: SdkClientFactory,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
|
|||||||
Reference in New Issue
Block a user