diff --git a/.gitattributes b/.gitattributes index 1d012697dcd..6313b56c578 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1 @@ -*.sh eol=lf -.dockerignore eol=lf -dockerfile eol=lf \ No newline at end of file +* text=auto eol=lf diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 5cc2da8788e..143797b9831 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -6,7 +6,7 @@ body: attributes: value: | Thanks for taking the time to fill out this bug report! - + Please do not submit feature requests. The [Community Forums](https://community.bitwarden.com) has a section for submitting, voting for, and discussing product feature requests. - type: textarea id: reproduce diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ab2b5754506..a4441bfaff4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,5 @@ ## Type of change + - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) @@ -6,27 +7,26 @@ - [ ] Other ## Objective + - - ## Code changes + -* **file.ext:** Description of what was changed and why +- **file.ext:** Description of what was changed and why ## Screenshots + - - ## Testing requirements + - - ## Before you submit + - [ ] I have checked for **linting** errors (`npm run lint`) (required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50666d6ddc9..f12d041cc58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,8 +9,8 @@ on: required: false push: branches-ignore: - - 'l10n_master' - - 'gh-pages' + - "l10n_master" + - "gh-pages" jobs: cloc: @@ -28,7 +28,6 @@ jobs: - name: Print lines of code run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git - setup: name: Setup runs-on: ubuntu-20.04 @@ -42,7 +41,6 @@ jobs: id: version run: echo "::set-output name=value::${GITHUB_SHA:0:7}" - build-oss-selfhost: name: Build OSS zip runs-on: ubuntu-20.04 @@ -53,13 +51,13 @@ jobs: - name: Set up Node uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea with: - node-version: '16' + node-version: "16" - name: Cache npm id: npm-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '~/.npm' + path: "~/.npm" key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Print environment @@ -84,13 +82,12 @@ jobs: zip -r web-$_VERSION-selfhosted-open-source.zip build - name: Upload build artifact - uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3 + uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3 with: name: web-${{ env._VERSION }}-selfhosted-open-source.zip path: ./web-${{ env._VERSION }}-selfhosted-open-source.zip if-no-files-found: error - build-cloud: name: Build Cloud zip runs-on: ubuntu-20.04 @@ -101,13 +98,13 @@ jobs: - name: Set up Node uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea with: - node-version: '16' + node-version: "16" - name: Cache npm id: npm-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '~/.npm' + path: "~/.npm" key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Print environment @@ -132,13 +129,12 @@ jobs: zip -r web-$_VERSION-cloud-COMMERCIAL.zip build - name: Upload build artifact - uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3 + uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3 with: name: web-${{ env._VERSION }}-cloud-COMMERCIAL.zip path: ./web-${{ env._VERSION }}-cloud-COMMERCIAL.zip if-no-files-found: error - build-commercial-selfhost: name: Build SelfHost Docker image runs-on: ubuntu-20.04 @@ -149,13 +145,13 @@ jobs: - name: Set up Node uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea with: - node-version: '16' + node-version: "16" - name: Cache npm id: npm-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '~/.npm' + path: "~/.npm" key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Print environment @@ -195,7 +191,7 @@ jobs: zip -r web-$_VERSION-selfhosted-COMMERCIAL.zip build - name: Upload build artifact - uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3 + uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700 # v2.2.3 with: name: web-${{ env._VERSION }}-selfhosted-COMMERCIAL.zip path: ./web-${{ env._VERSION }}-selfhosted-COMMERCIAL.zip @@ -248,7 +244,6 @@ jobs: if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix' run: docker logout - build-qa: name: Build Docker images for QA environment runs-on: ubuntu-20.04 @@ -256,13 +251,13 @@ jobs: - name: Set up Node uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea with: - node-version: '16' + node-version: "16" - name: Cache npm id: npm-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '~/.npm' + path: "~/.npm" key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Print environment @@ -344,7 +339,6 @@ jobs: - name: Log out of Docker run: docker logout - windows: name: Test code on Windows runs-on: windows-2019 @@ -352,22 +346,22 @@ jobs: - name: Set up NuGet uses: nuget/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1 with: - nuget-version: 'latest' + nuget-version: "latest" - name: Set up MSBuild uses: microsoft/setup-msbuild@c26a08ba26249b81327e26f6ef381897b6a8754d - name: Cache npm id: npm-cache - uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 + uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6 with: - path: '~/.npm' + path: "~/.npm" key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} - name: Set up Node uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea with: - node-version: '16' + node-version: "16" - name: Print environment run: | @@ -388,13 +382,12 @@ jobs: - name: Install dependencies run: npm ci - # - name: Run linter - # run: npm run lint + - name: Run linter + run: npm run lint - name: NPM build run: npm run build:bit:cloud - crowdin-push: name: Crowdin Push if: github.ref == 'refs/heads/master' @@ -408,7 +401,7 @@ jobs: _CROWDIN_PROJECT_ID: "308189" steps: - name: Checkout repo - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Login to Azure uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a @@ -423,7 +416,7 @@ jobs: secrets: "crowdin-api-token" - name: Upload Sources - uses: crowdin/github-action@e39093fd75daae7859c68eded4b43d42ec78d8ea # v1.3.2 + uses: crowdin/github-action@e39093fd75daae7859c68eded4b43d42ec78d8ea # v1.3.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }} @@ -433,7 +426,6 @@ jobs: upload_sources: true upload_translations: false - check-failures: name: Check for failures if: always() @@ -493,7 +485,7 @@ jobs: secrets: "devops-alerts-slack-webhook-url" - name: Notify Slack on failure - uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2 + uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2 if: failure() env: SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }} diff --git a/.github/workflows/crowdin-pull.yml b/.github/workflows/crowdin-pull.yml index 1b31d969cb1..95c62307cf6 100644 --- a/.github/workflows/crowdin-pull.yml +++ b/.github/workflows/crowdin-pull.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: inputs: {} schedule: - - cron: '0 0 * * 5' + - cron: "0 0 * * 5" jobs: crowdin-pull: @@ -15,7 +15,7 @@ jobs: _CROWDIN_PROJECT_ID: "308189" steps: - name: Checkout repo - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Login to Azure uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a @@ -30,7 +30,7 @@ jobs: secrets: "crowdin-api-token" - name: Download translations - uses: crowdin/github-action@e39093fd75daae7859c68eded4b43d42ec78d8ea # v1.3.2 + uses: crowdin/github-action@e39093fd75daae7859c68eded4b43d42ec78d8ea # v1.3.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CROWDIN_API_TOKEN: ${{ steps.retrieve-secrets.outputs.crowdin-api-token }} diff --git a/.github/workflows/qa-deploy.yml b/.github/workflows/qa-deploy.yml index b009a803df3..ecc363fd40e 100644 --- a/.github/workflows/qa-deploy.yml +++ b/.github/workflows/qa-deploy.yml @@ -20,11 +20,10 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repo - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Setup - run: - export PATH=$PATH:~/work/web/web + run: export PATH=$PATH:~/work/web/web - name: Login to Azure uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 91843d2577c..c4e4426f6c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: fi - name: Checkout repo - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # 2.3.4 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # 2.3.4 - name: Check Release Version id: version @@ -48,7 +48,6 @@ jobs: BRANCH_NAME=$(basename ${{ github.ref }}) echo "::set-output name=branch-name::$BRANCH_NAME" - self-host: name: Release self-host docker runs-on: ubuntu-20.04 @@ -96,7 +95,6 @@ jobs: - name: Log out of Docker run: docker logout - ghpages-deploy: name: Deploy Web Vault runs-on: ubuntu-20.04 @@ -108,7 +106,7 @@ jobs: _TAG_VERSION: ${{ needs.setup.outputs.tag_version }} steps: - name: Checkout Repo - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: ref: gh-pages @@ -118,7 +116,7 @@ jobs: git push -u origin deploy-$_TAG_VERSION - name: Checkout Repo - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - name: Setup git config run: | @@ -140,7 +138,7 @@ jobs: run: unzip web-*-cloud-COMMERCIAL.zip - name: Deploy GitHub Pages - uses: crazy-max/ghaction-github-pages@db4476a01402e1a7ce05f41832040eef16d14925 # v2.5.0 + uses: crazy-max/ghaction-github-pages@db4476a01402e1a7ce05f41832040eef16d14925 # v2.5.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -159,7 +157,6 @@ jobs: --base gh-pages \ --head "$PR_BRANCH" - release: name: Create GitHub Release runs-on: ubuntu-20.04 @@ -175,7 +172,7 @@ jobs: workflow_conclusion: success branch: ${{ needs.setup.outputs.branch-name }} artifacts: "web-*-selfhosted-COMMERCIAL.zip, - web-*-selfhosted-open-source.zip" + web-*-selfhosted-open-source.zip" - name: Rename assets run: | @@ -190,6 +187,6 @@ jobs: tag: "${{ needs.setup.outputs.tag_version }}" body: "" artifacts: "web-${{ needs.setup.outputs.release_version }}-selfhosted-COMMERCIAL.zip, - web-${{ needs.setup.outputs.release_version }}-selfhosted-open-source.zip" + web-${{ needs.setup.outputs.release_version }}-selfhosted-open-source.zip" token: ${{ secrets.GITHUB_TOKEN }} draft: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7373eef9e5c..21e158bc00a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,17 +6,12 @@ Please visit our [Community Forums](https://community.bitwarden.com/) for genera Here is how you can get involved: -* **Request a new feature:** Go to the [Feature Requests category](https://community.bitwarden.com/c/feature-requests/) of the Community Forums. Please search existing feature requests before making a new one - -* **Write code for a new feature:** Make a new post in the [Github Contributions category](https://community.bitwarden.com/c/github-contributions/) of the Community Forums. Include a description of your proposed contribution, screeshots, and links to any relevant feature requests. This helps get feedback from the community and Bitwarden team members before you start writing code - -* **Report a bug or submit a bugfix:** Use Github issues and pull requests - -* **Write documentation:** Submit a pull request to the [Bitwarden help repository](https://github.com/bitwarden/help) - -* **Help other users:** Go to the [User-to-User Support category](https://community.bitwarden.com/c/support/) on the Community Forums - -* **Translate:** See the localization (l10n) section below +- **Request a new feature:** Go to the [Feature Requests category](https://community.bitwarden.com/c/feature-requests/) of the Community Forums. Please search existing feature requests before making a new one +- **Write code for a new feature:** Make a new post in the [Github Contributions category](https://community.bitwarden.com/c/github-contributions/) of the Community Forums. Include a description of your proposed contribution, screeshots, and links to any relevant feature requests. This helps get feedback from the community and Bitwarden team members before you start writing code +- **Report a bug or submit a bugfix:** Use Github issues and pull requests +- **Write documentation:** Submit a pull request to the [Bitwarden help repository](https://github.com/bitwarden/help) +- **Help other users:** Go to the [User-to-User Support category](https://community.bitwarden.com/c/support/) on the Community Forums +- **Translate:** See the localization (l10n) section below ## Contributor Agreement @@ -24,9 +19,9 @@ Please sign the [Contributor Agreement](https://cla-assistant.io/bitwarden/web) ## Pull Request Guidelines -* use `npm run lint` and fix any linting suggestions before submitting a pull request -* commit any pull requests against the `master` branch -* include a link to your Community Forums post +- use `npm run lint` and fix any linting suggestions before submitting a pull request +- commit any pull requests against the `master` branch +- include a link to your Community Forums post # Localization (l10n) diff --git a/README.md b/README.md index 9c81aa2e2eb..034e624ddfa 100644 --- a/README.md +++ b/README.md @@ -48,16 +48,14 @@ You can also manually adjusting your API endpoint settings by adding `config/loc ```json { - "dev": { - "proxyApi": "http://your-api-url", - "proxyIdentity": "http://your-identity-url", - "proxyEvents": "http://your-events-url", - "proxyNotifications": "http://your-notifications-url", - "allowedHosts": ["hostnames-to-allow-in-webpack"], - }, - "urls": { - - } + "dev": { + "proxyApi": "http://your-api-url", + "proxyIdentity": "http://your-identity-url", + "proxyEvents": "http://your-events-url", + "proxyNotifications": "http://your-notifications-url", + "allowedHosts": ["hostnames-to-allow-in-webpack"] + }, + "urls": {} } ``` diff --git a/SECURITY.md b/SECURITY.md index ef94f0b494f..7a055501ad9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -7,7 +7,7 @@ notify us. We welcome working with you to resolve the issue promptly. Thanks in - Let us know as soon as possible upon discovery of a potential security issue, and we'll make every effort to quickly resolve the issue. - Provide us a reasonable amount of time to resolve the issue before any disclosure to the public or a - third-party. We may publicly disclose the issue before resolving it, if appropriate. + third-party. We may publicly disclose the issue before resolving it, if appropriate. - Make a good faith effort to avoid privacy violations, destruction of data, and interruption or degradation of our service. Only interact with accounts you own or with explicit permission of the account holder. diff --git a/bitwarden_license/src/app/app-routing.module.ts b/bitwarden_license/src/app/app-routing.module.ts index 3d03f7e3485..f9d434ed68a 100644 --- a/bitwarden_license/src/app/app-routing.module.ts +++ b/bitwarden_license/src/app/app-routing.module.ts @@ -1,15 +1,15 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; +import { NgModule } from "@angular/core"; +import { RouterModule, Routes } from "@angular/router"; const routes: Routes = [ - { - path: 'providers', - loadChildren: async () => (await import('./providers/providers.module')).ProvidersModule, - }, + { + path: "providers", + loadChildren: async () => (await import("./providers/providers.module")).ProvidersModule, + }, ]; @NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], }) -export class AppRoutingModule { } +export class AppRoutingModule {} diff --git a/bitwarden_license/src/app/app.component.ts b/bitwarden_license/src/app/app.component.ts index 224afce70c6..fb5560f1f80 100644 --- a/bitwarden_license/src/app/app.component.ts +++ b/bitwarden_license/src/app/app.component.ts @@ -1,22 +1,20 @@ -import { Component } from '@angular/core'; +import { Component } from "@angular/core"; -import { AppComponent as BaseAppComponent } from 'src/app/app.component'; -import { DisablePersonalVaultExportPolicy } from './policies/disable-personal-vault-export.component'; -import { MaximumVaultTimeoutPolicy } from './policies/maximum-vault-timeout.component'; +import { AppComponent as BaseAppComponent } from "src/app/app.component"; +import { DisablePersonalVaultExportPolicy } from "./policies/disable-personal-vault-export.component"; +import { MaximumVaultTimeoutPolicy } from "./policies/maximum-vault-timeout.component"; @Component({ - selector: 'app-root', - templateUrl: '../../../src/app/app.component.html', + selector: "app-root", + templateUrl: "../../../src/app/app.component.html", }) export class AppComponent extends BaseAppComponent { + ngOnInit() { + super.ngOnInit(); - ngOnInit() { - super.ngOnInit(); - - this.policyListService.addPolicies([ - new MaximumVaultTimeoutPolicy(), - new DisablePersonalVaultExportPolicy(), - ]); - } - + this.policyListService.addPolicies([ + new MaximumVaultTimeoutPolicy(), + new DisablePersonalVaultExportPolicy(), + ]); + } } diff --git a/bitwarden_license/src/app/app.module.ts b/bitwarden_license/src/app/app.module.ts index 204c6d5dee3..4d7fa790ba1 100644 --- a/bitwarden_license/src/app/app.module.ts +++ b/bitwarden_license/src/app/app.module.ts @@ -1,48 +1,48 @@ -import { DragDropModule } from '@angular/cdk/drag-drop'; -import { NgModule } from '@angular/core'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { RouterModule } from '@angular/router'; -import { InfiniteScrollModule } from 'ngx-infinite-scroll'; +import { DragDropModule } from "@angular/cdk/drag-drop"; +import { NgModule } from "@angular/core"; +import { FormsModule, ReactiveFormsModule } from "@angular/forms"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import { RouterModule } from "@angular/router"; +import { InfiniteScrollModule } from "ngx-infinite-scroll"; -import { BitwardenToastModule } from 'jslib-angular/components/toastr.component'; +import { BitwardenToastModule } from "jslib-angular/components/toastr.component"; -import { AppRoutingModule } from './app-routing.module'; -import { AppComponent } from './app.component'; -import { OrganizationsModule } from './organizations/organizations.module'; -import { DisablePersonalVaultExportPolicyComponent } from './policies/disable-personal-vault-export.component'; -import { MaximumVaultTimeoutPolicyComponent } from './policies/maximum-vault-timeout.component'; +import { AppRoutingModule } from "./app-routing.module"; +import { AppComponent } from "./app.component"; +import { OrganizationsModule } from "./organizations/organizations.module"; +import { DisablePersonalVaultExportPolicyComponent } from "./policies/disable-personal-vault-export.component"; +import { MaximumVaultTimeoutPolicyComponent } from "./policies/maximum-vault-timeout.component"; -import { OssRoutingModule } from 'src/app/oss-routing.module'; -import { OssModule } from 'src/app/oss.module'; -import { ServicesModule } from 'src/app/services/services.module'; -import { WildcardRoutingModule } from 'src/app/wildcard-routing.module'; +import { OssRoutingModule } from "src/app/oss-routing.module"; +import { OssModule } from "src/app/oss.module"; +import { ServicesModule } from "src/app/services/services.module"; +import { WildcardRoutingModule } from "src/app/wildcard-routing.module"; @NgModule({ - imports: [ - OssModule, - BrowserAnimationsModule, - FormsModule, - ReactiveFormsModule, - ServicesModule, - BitwardenToastModule.forRoot({ - maxOpened: 5, - autoDismiss: true, - closeButton: true, - }), - InfiniteScrollModule, - DragDropModule, - AppRoutingModule, - OssRoutingModule, - OrganizationsModule, - RouterModule, - WildcardRoutingModule, // Needs to be last to catch all non-existing routes - ], - declarations: [ - AppComponent, - MaximumVaultTimeoutPolicyComponent, - DisablePersonalVaultExportPolicyComponent, - ], - bootstrap: [AppComponent], + imports: [ + OssModule, + BrowserAnimationsModule, + FormsModule, + ReactiveFormsModule, + ServicesModule, + BitwardenToastModule.forRoot({ + maxOpened: 5, + autoDismiss: true, + closeButton: true, + }), + InfiniteScrollModule, + DragDropModule, + AppRoutingModule, + OssRoutingModule, + OrganizationsModule, + RouterModule, + WildcardRoutingModule, // Needs to be last to catch all non-existing routes + ], + declarations: [ + AppComponent, + MaximumVaultTimeoutPolicyComponent, + DisablePersonalVaultExportPolicyComponent, + ], + bootstrap: [AppComponent], }) -export class AppModule { } +export class AppModule {} diff --git a/bitwarden_license/src/app/main.ts b/bitwarden_license/src/app/main.ts index 075236e1eb4..c1050a94d4a 100644 --- a/bitwarden_license/src/app/main.ts +++ b/bitwarden_license/src/app/main.ts @@ -1,17 +1,17 @@ -import { enableProdMode } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { enableProdMode } from "@angular/core"; +import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; -import 'bootstrap'; -import 'jquery'; -import 'popper.js'; +import "bootstrap"; +import "jquery"; +import "popper.js"; // tslint:disable-next-line -require('src/scss/styles.scss'); +require("src/scss/styles.scss"); -import { AppModule } from './app.module'; +import { AppModule } from "./app.module"; -if (process.env.NODE_ENV === 'production') { - enableProdMode(); +if (process.env.NODE_ENV === "production") { + enableProdMode(); } platformBrowserDynamic().bootstrapModule(AppModule, { preserveWhitespaces: true }); diff --git a/bitwarden_license/src/app/organizations/manage/sso.component.html b/bitwarden_license/src/app/organizations/manage/sso.component.html index 2af5e09fe80..ceaabc97164 100644 --- a/bitwarden_license/src/app/organizations/manage/sso.component.html +++ b/bitwarden_license/src/app/organizations/manage/sso.component.html @@ -1,363 +1,488 @@ - - {{'loading' | i18n}} + + {{ "loading" | i18n }} -
-

- {{'ssoPolicyHelpStart' | i18n}} - {{'ssoPolicyHelpLink' | i18n}} - {{'ssoPolicyHelpEnd' | i18n}} -
- {{'ssoPolicyHelpKeyConnector' | i18n}} -

- -
-
- - -
- {{'allowSsoDesc' | i18n}} + +

+ {{ "ssoPolicyHelpStart" | i18n }} + {{ "ssoPolicyHelpLink" | i18n }} + {{ "ssoPolicyHelpEnd" | i18n }} +
+ {{ "ssoPolicyHelpKeyConnector" | i18n }} +

+ +
+
+ +
+ {{ "allowSsoDesc" | i18n }} +
-
- -
- - -
-
- - -
+
+ +
+ +
+
+ + +
+
- - - {{'keyConnectorWarning' | i18n}} - - -
- -
- -
- -
-
- - - - -
-
+ + + {{ "keyConnectorWarning" | i18n }} +
- - +
+ +
+
+ + + + +
+ + +
+ + +
+ + +
+
+

{{ "openIdConnectConfig" | i18n }}

+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+ +
+

{{ "samlSpConfig" | i18n }}

+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ + +
+
+
+
+ +
+ +
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+
+ + +
+
- -
-
-

{{'openIdConnectConfig' | i18n}}

-
- -
- -
- -
-
-
-
- -
- -
- -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+ +
+

{{ "samlIdpConfig" | i18n }}

+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
-
- -
-

{{'samlSpConfig' | i18n}}

-
- -
- -
- -
-
-
-
- -
- -
- - -
-
-
-
- -
- -
- -
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-
-
- - -
-
-
- - -
-

{{'samlIdpConfig' | i18n}}

- -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - + diff --git a/bitwarden_license/src/app/organizations/manage/sso.component.ts b/bitwarden_license/src/app/organizations/manage/sso.component.ts index d5d8be0eaac..7c2aed98daf 100644 --- a/bitwarden_license/src/app/organizations/manage/sso.component.ts +++ b/bitwarden_license/src/app/organizations/manage/sso.component.ts @@ -1,180 +1,183 @@ -import { - Component, - OnInit, -} from '@angular/core'; -import { FormBuilder } from '@angular/forms'; -import { ActivatedRoute } from '@angular/router'; +import { Component, OnInit } from "@angular/core"; +import { FormBuilder } from "@angular/forms"; +import { ActivatedRoute } from "@angular/router"; -import { ApiService } from 'jslib-common/abstractions/api.service'; -import { I18nService } from 'jslib-common/abstractions/i18n.service'; -import { OrganizationService } from 'jslib-common/abstractions/organization.service'; -import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; +import { ApiService } from "jslib-common/abstractions/api.service"; +import { I18nService } from "jslib-common/abstractions/i18n.service"; +import { OrganizationService } from "jslib-common/abstractions/organization.service"; +import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service"; -import { Organization } from 'jslib-common/models/domain/organization'; +import { Organization } from "jslib-common/models/domain/organization"; -import { OrganizationSsoRequest } from 'jslib-common/models/request/organization/organizationSsoRequest'; +import { OrganizationSsoRequest } from "jslib-common/models/request/organization/organizationSsoRequest"; @Component({ - selector: 'app-org-manage-sso', - templateUrl: 'sso.component.html', + selector: "app-org-manage-sso", + templateUrl: "sso.component.html", }) export class SsoComponent implements OnInit { + samlSigningAlgorithms = [ + "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", + "http://www.w3.org/2000/09/xmldsig#rsa-sha384", + "http://www.w3.org/2000/09/xmldsig#rsa-sha512", + "http://www.w3.org/2000/09/xmldsig#rsa-sha1", + ]; - samlSigningAlgorithms = [ - 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', - 'http://www.w3.org/2000/09/xmldsig#rsa-sha384', - 'http://www.w3.org/2000/09/xmldsig#rsa-sha512', - 'http://www.w3.org/2000/09/xmldsig#rsa-sha1', - ]; + loading = true; + organizationId: string; + organization: Organization; + formPromise: Promise; - loading = true; - organizationId: string; - organization: Organization; - formPromise: Promise; + callbackPath: string; + signedOutCallbackPath: string; + spEntityId: string; + spMetadataUrl: string; + spAcsUrl: string; - callbackPath: string; - signedOutCallbackPath: string; - spEntityId: string; - spMetadataUrl: string; - spAcsUrl: string; + enabled = this.fb.control(false); + data = this.fb.group({ + configType: [], - enabled = this.fb.control(false); - data = this.fb.group({ - configType: [], + keyConnectorEnabled: [], + keyConnectorUrl: [], - keyConnectorEnabled: [], - keyConnectorUrl: [], + // OpenId + authority: [], + clientId: [], + clientSecret: [], + metadataAddress: [], + redirectBehavior: [], + getClaimsFromUserInfoEndpoint: [], + additionalScopes: [], + additionalUserIdClaimTypes: [], + additionalEmailClaimTypes: [], + additionalNameClaimTypes: [], + acrValues: [], + expectedReturnAcrValue: [], - // OpenId - authority: [], - clientId: [], - clientSecret: [], - metadataAddress: [], - redirectBehavior: [], - getClaimsFromUserInfoEndpoint: [], - additionalScopes: [], - additionalUserIdClaimTypes: [], - additionalEmailClaimTypes: [], - additionalNameClaimTypes: [], - acrValues: [], - expectedReturnAcrValue: [], + // SAML + spNameIdFormat: [], + spOutboundSigningAlgorithm: [], + spSigningBehavior: [], + spMinIncomingSigningAlgorithm: [], + spWantAssertionsSigned: [], + spValidateCertificates: [], - // SAML - spNameIdFormat: [], - spOutboundSigningAlgorithm: [], - spSigningBehavior: [], - spMinIncomingSigningAlgorithm: [], - spWantAssertionsSigned: [], - spValidateCertificates: [], + idpEntityId: [], + idpBindingType: [], + idpSingleSignOnServiceUrl: [], + idpSingleLogoutServiceUrl: [], + idpArtifactResolutionServiceUrl: [], + idpX509PublicCert: [], + idpOutboundSigningAlgorithm: [], + idpAllowUnsolicitedAuthnResponse: [], + idpDisableOutboundLogoutRequests: [], + idpWantAuthnRequestsSigned: [], + }); - idpEntityId: [], - idpBindingType: [], - idpSingleSignOnServiceUrl: [], - idpSingleLogoutServiceUrl: [], - idpArtifactResolutionServiceUrl: [], - idpX509PublicCert: [], - idpOutboundSigningAlgorithm: [], - idpAllowUnsolicitedAuthnResponse: [], - idpDisableOutboundLogoutRequests: [], - idpWantAuthnRequestsSigned: [], + constructor( + private fb: FormBuilder, + private route: ActivatedRoute, + private apiService: ApiService, + private platformUtilsService: PlatformUtilsService, + private i18nService: I18nService, + private organizationService: OrganizationService + ) {} + + async ngOnInit() { + this.route.parent.parent.params.subscribe(async (params) => { + this.organizationId = params.organizationId; + await this.load(); }); + } - constructor(private fb: FormBuilder, private route: ActivatedRoute, private apiService: ApiService, - private platformUtilsService: PlatformUtilsService, private i18nService: I18nService, - private organizationService: OrganizationService) { } + async load() { + this.organization = await this.organizationService.get(this.organizationId); + const ssoSettings = await this.apiService.getOrganizationSso(this.organizationId); - async ngOnInit() { - this.route.parent.parent.params.subscribe(async params => { - this.organizationId = params.organizationId; - await this.load(); - }); + this.data.patchValue(ssoSettings.data); + this.enabled.setValue(ssoSettings.enabled); + + this.callbackPath = ssoSettings.urls.callbackPath; + this.signedOutCallbackPath = ssoSettings.urls.signedOutCallbackPath; + this.spEntityId = ssoSettings.urls.spEntityId; + this.spMetadataUrl = ssoSettings.urls.spMetadataUrl; + this.spAcsUrl = ssoSettings.urls.spAcsUrl; + + this.keyConnectorUrl.markAsDirty(); + + this.loading = false; + } + + copy(value: string) { + this.platformUtilsService.copyToClipboard(value); + } + + launchUri(url: string) { + this.platformUtilsService.launchUri(url); + } + + async submit() { + this.formPromise = this.postData(); + + try { + const response = await this.formPromise; + + this.data.patchValue(response.data); + this.enabled.setValue(response.enabled); + + this.platformUtilsService.showToast("success", null, this.i18nService.t("ssoSettingsSaved")); + } catch { + // Logged by appApiAction, do nothing } - async load() { - this.organization = await this.organizationService.get(this.organizationId); - const ssoSettings = await this.apiService.getOrganizationSso(this.organizationId); + this.formPromise = null; + } - this.data.patchValue(ssoSettings.data); - this.enabled.setValue(ssoSettings.enabled); + async postData() { + if (this.data.get("keyConnectorEnabled").value) { + await this.validateKeyConnectorUrl(); - this.callbackPath = ssoSettings.urls.callbackPath; - this.signedOutCallbackPath = ssoSettings.urls.signedOutCallbackPath; - this.spEntityId = ssoSettings.urls.spEntityId; - this.spMetadataUrl = ssoSettings.urls.spMetadataUrl; - this.spAcsUrl = ssoSettings.urls.spAcsUrl; - - this.keyConnectorUrl.markAsDirty(); - - this.loading = false; + if (this.keyConnectorUrl.hasError("invalidUrl")) { + throw new Error(this.i18nService.t("keyConnectorTestFail")); + } } - copy(value: string) { - this.platformUtilsService.copyToClipboard(value); + const request = new OrganizationSsoRequest(); + request.enabled = this.enabled.value; + request.data = this.data.value; + + return this.apiService.postOrganizationSso(this.organizationId, request); + } + + async validateKeyConnectorUrl() { + if (this.keyConnectorUrl.pristine) { + return; } - launchUri(url: string) { - this.platformUtilsService.launchUri(url); + this.keyConnectorUrl.markAsPending(); + + try { + await this.apiService.getKeyConnectorAlive(this.keyConnectorUrl.value); + this.keyConnectorUrl.updateValueAndValidity(); + } catch { + this.keyConnectorUrl.setErrors({ + invalidUrl: true, + }); } - async submit() { - this.formPromise = this.postData(); + this.keyConnectorUrl.markAsPristine(); + } - try { - const response = await this.formPromise; + get enableTestKeyConnector() { + return ( + this.data.get("keyConnectorEnabled").value && + this.keyConnectorUrl != null && + this.keyConnectorUrl.value !== "" + ); + } - this.data.patchValue(response.data); - this.enabled.setValue(response.enabled); - - this.platformUtilsService.showToast('success', null, this.i18nService.t('ssoSettingsSaved')); - } catch { - // Logged by appApiAction, do nothing - } - - this.formPromise = null; - } - - async postData() { - if (this.data.get('keyConnectorEnabled').value) { - await this.validateKeyConnectorUrl(); - - if (this.keyConnectorUrl.hasError('invalidUrl')) { - throw new Error(this.i18nService.t('keyConnectorTestFail')); - } - } - - const request = new OrganizationSsoRequest(); - request.enabled = this.enabled.value; - request.data = this.data.value; - - return this.apiService.postOrganizationSso(this.organizationId, request); - } - - async validateKeyConnectorUrl() { - if (this.keyConnectorUrl.pristine) { - return; - } - - this.keyConnectorUrl.markAsPending(); - - try { - await this.apiService.getKeyConnectorAlive(this.keyConnectorUrl.value); - this.keyConnectorUrl.updateValueAndValidity(); - } catch { - this.keyConnectorUrl.setErrors({ - invalidUrl: true, - }); - } - - this.keyConnectorUrl.markAsPristine(); - } - - get enableTestKeyConnector() { - return this.data.get('keyConnectorEnabled').value && - this.keyConnectorUrl != null && - this.keyConnectorUrl.value !== ''; - } - - get keyConnectorUrl() { - return this.data.get('keyConnectorUrl'); - } + get keyConnectorUrl() { + return this.data.get("keyConnectorUrl"); + } } diff --git a/bitwarden_license/src/app/organizations/organizations-routing.module.ts b/bitwarden_license/src/app/organizations/organizations-routing.module.ts index 5ad731eb54c..50b4dc8d61e 100644 --- a/bitwarden_license/src/app/organizations/organizations-routing.module.ts +++ b/bitwarden_license/src/app/organizations/organizations-routing.module.ts @@ -1,54 +1,54 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; +import { NgModule } from "@angular/core"; +import { RouterModule, Routes } from "@angular/router"; -import { AuthGuardService } from 'jslib-angular/services/auth-guard.service'; +import { AuthGuardService } from "jslib-angular/services/auth-guard.service"; -import { Permissions } from 'jslib-common/enums/permissions'; +import { Permissions } from "jslib-common/enums/permissions"; -import { OrganizationLayoutComponent } from 'src/app/layouts/organization-layout.component'; -import { ManageComponent } from 'src/app/organizations/manage/manage.component'; -import { OrganizationGuardService } from 'src/app/services/organization-guard.service'; -import { OrganizationTypeGuardService } from 'src/app/services/organization-type-guard.service'; +import { OrganizationLayoutComponent } from "src/app/layouts/organization-layout.component"; +import { ManageComponent } from "src/app/organizations/manage/manage.component"; +import { OrganizationGuardService } from "src/app/services/organization-guard.service"; +import { OrganizationTypeGuardService } from "src/app/services/organization-type-guard.service"; -import { SsoComponent } from './manage/sso.component'; +import { SsoComponent } from "./manage/sso.component"; const routes: Routes = [ - { - path: 'organizations/:organizationId', - component: OrganizationLayoutComponent, - canActivate: [AuthGuardService, OrganizationGuardService], + { + path: "organizations/:organizationId", + component: OrganizationLayoutComponent, + canActivate: [AuthGuardService, OrganizationGuardService], + children: [ + { + path: "manage", + component: ManageComponent, + canActivate: [OrganizationTypeGuardService], + data: { + permissions: [ + Permissions.CreateNewCollections, + Permissions.EditAnyCollection, + Permissions.DeleteAnyCollection, + Permissions.EditAssignedCollections, + Permissions.DeleteAssignedCollections, + Permissions.AccessEventLogs, + Permissions.ManageGroups, + Permissions.ManageUsers, + Permissions.ManagePolicies, + Permissions.ManageSso, + ], + }, children: [ - { - path: 'manage', - component: ManageComponent, - canActivate: [OrganizationTypeGuardService], - data: { - permissions: [ - Permissions.CreateNewCollections, - Permissions.EditAnyCollection, - Permissions.DeleteAnyCollection, - Permissions.EditAssignedCollections, - Permissions.DeleteAssignedCollections, - Permissions.AccessEventLogs, - Permissions.ManageGroups, - Permissions.ManageUsers, - Permissions.ManagePolicies, - Permissions.ManageSso, - ], - }, - children: [ - { - path: 'sso', - component: SsoComponent, - }, - ], - }, + { + path: "sso", + component: SsoComponent, + }, ], - }, + }, + ], + }, ]; @NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], }) -export class OrganizationsRoutingModule { } +export class OrganizationsRoutingModule {} diff --git a/bitwarden_license/src/app/organizations/organizations.module.ts b/bitwarden_license/src/app/organizations/organizations.module.ts index 812681262df..e81c270faba 100644 --- a/bitwarden_license/src/app/organizations/organizations.module.ts +++ b/bitwarden_license/src/app/organizations/organizations.module.ts @@ -1,22 +1,14 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { CommonModule } from "@angular/common"; +import { NgModule } from "@angular/core"; +import { FormsModule, ReactiveFormsModule } from "@angular/forms"; -import { OssModule } from 'src/app/oss.module'; +import { OssModule } from "src/app/oss.module"; -import { SsoComponent } from './manage/sso.component'; -import { OrganizationsRoutingModule } from './organizations-routing.module'; +import { SsoComponent } from "./manage/sso.component"; +import { OrganizationsRoutingModule } from "./organizations-routing.module"; @NgModule({ - imports: [ - CommonModule, - FormsModule, - ReactiveFormsModule, - OssModule, - OrganizationsRoutingModule, - ], - declarations: [ - SsoComponent, - ], + imports: [CommonModule, FormsModule, ReactiveFormsModule, OssModule, OrganizationsRoutingModule], + declarations: [SsoComponent], }) export class OrganizationsModule {} diff --git a/bitwarden_license/src/app/policies/disable-personal-vault-export.component.html b/bitwarden_license/src/app/policies/disable-personal-vault-export.component.html index f08f74c3230..317a9c8f1d4 100644 --- a/bitwarden_license/src/app/policies/disable-personal-vault-export.component.html +++ b/bitwarden_license/src/app/policies/disable-personal-vault-export.component.html @@ -1,6 +1,12 @@
-
- - -
+
+ + +
diff --git a/bitwarden_license/src/app/policies/disable-personal-vault-export.component.ts b/bitwarden_license/src/app/policies/disable-personal-vault-export.component.ts index b79bdfdb772..5723149058f 100644 --- a/bitwarden_license/src/app/policies/disable-personal-vault-export.component.ts +++ b/bitwarden_license/src/app/policies/disable-personal-vault-export.component.ts @@ -1,24 +1,26 @@ -import { Component } from '@angular/core'; -import { FormBuilder } from '@angular/forms'; +import { Component } from "@angular/core"; +import { FormBuilder } from "@angular/forms"; -import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { I18nService } from "jslib-common/abstractions/i18n.service"; -import { PolicyType } from 'jslib-common/enums/policyType'; +import { PolicyType } from "jslib-common/enums/policyType"; -import { PolicyRequest } from 'jslib-common/models/request/policyRequest'; +import { PolicyRequest } from "jslib-common/models/request/policyRequest"; -import { BasePolicy, BasePolicyComponent } from 'src/app/organizations/policies/base-policy.component'; +import { + BasePolicy, + BasePolicyComponent, +} from "src/app/organizations/policies/base-policy.component"; export class DisablePersonalVaultExportPolicy extends BasePolicy { - name = 'disablePersonalVaultExport'; - description = 'disablePersonalVaultExportDesc'; - type = PolicyType.DisablePersonalVaultExport; - component = DisablePersonalVaultExportPolicyComponent; + name = "disablePersonalVaultExport"; + description = "disablePersonalVaultExportDesc"; + type = PolicyType.DisablePersonalVaultExport; + component = DisablePersonalVaultExportPolicyComponent; } @Component({ - selector: 'policy-disable-personal-vault-export', - templateUrl: 'disable-personal-vault-export.component.html', + selector: "policy-disable-personal-vault-export", + templateUrl: "disable-personal-vault-export.component.html", }) -export class DisablePersonalVaultExportPolicyComponent extends BasePolicyComponent { -} +export class DisablePersonalVaultExportPolicyComponent extends BasePolicyComponent {} diff --git a/bitwarden_license/src/app/policies/maximum-vault-timeout.component.html b/bitwarden_license/src/app/policies/maximum-vault-timeout.component.html index ac43f2d1207..344cf009ec0 100644 --- a/bitwarden_license/src/app/policies/maximum-vault-timeout.component.html +++ b/bitwarden_license/src/app/policies/maximum-vault-timeout.component.html @@ -1,27 +1,47 @@ - - {{'requireSsoPolicyReq' | i18n}} + + {{ "requireSsoPolicyReq" | i18n }}
-
- - -
+
+ + +
-
- -
-
- - {{'hours' | i18n }} -
-
- - {{'minutes' | i18n }} -
-
+
+ +
+
+ + {{ "hours" | i18n }} +
+
+ + {{ "minutes" | i18n }} +
+
diff --git a/bitwarden_license/src/app/policies/maximum-vault-timeout.component.ts b/bitwarden_license/src/app/policies/maximum-vault-timeout.component.ts index 8d95a530b4c..9c1b44539df 100644 --- a/bitwarden_license/src/app/policies/maximum-vault-timeout.component.ts +++ b/bitwarden_license/src/app/policies/maximum-vault-timeout.component.ts @@ -1,70 +1,72 @@ -import { Component } from '@angular/core'; -import { FormBuilder } from '@angular/forms'; +import { Component } from "@angular/core"; +import { FormBuilder } from "@angular/forms"; -import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { I18nService } from "jslib-common/abstractions/i18n.service"; -import { PolicyType } from 'jslib-common/enums/policyType'; +import { PolicyType } from "jslib-common/enums/policyType"; -import { PolicyRequest } from 'jslib-common/models/request/policyRequest'; +import { PolicyRequest } from "jslib-common/models/request/policyRequest"; -import { BasePolicy, BasePolicyComponent } from 'src/app/organizations/policies/base-policy.component'; +import { + BasePolicy, + BasePolicyComponent, +} from "src/app/organizations/policies/base-policy.component"; export class MaximumVaultTimeoutPolicy extends BasePolicy { - name = 'maximumVaultTimeout'; - description = 'maximumVaultTimeoutDesc'; - type = PolicyType.MaximumVaultTimeout; - component = MaximumVaultTimeoutPolicyComponent; + name = "maximumVaultTimeout"; + description = "maximumVaultTimeoutDesc"; + type = PolicyType.MaximumVaultTimeout; + component = MaximumVaultTimeoutPolicyComponent; } @Component({ - selector: 'policy-maximum-timeout', - templateUrl: 'maximum-vault-timeout.component.html', + selector: "policy-maximum-timeout", + templateUrl: "maximum-vault-timeout.component.html", }) export class MaximumVaultTimeoutPolicyComponent extends BasePolicyComponent { + data = this.fb.group({ + hours: [null], + minutes: [null], + }); - data = this.fb.group({ - hours: [null], - minutes: [null], + constructor(private fb: FormBuilder, private i18nService: I18nService) { + super(); + } + + loadData() { + const minutes = this.policyResponse.data?.minutes; + + if (minutes == null) { + return; + } + + this.data.patchValue({ + hours: Math.floor(minutes / 60), + minutes: minutes % 60, }); + } - constructor(private fb: FormBuilder, private i18nService: I18nService) { - super(); + buildRequestData() { + if (this.data.value.hours == null && this.data.value.minutes == null) { + return null; } - loadData() { - const minutes = this.policyResponse.data?.minutes; + return { + minutes: this.data.value.hours * 60 + this.data.value.minutes, + }; + } - if (minutes == null) { - return; - } - - this.data.patchValue({ - hours: Math.floor(minutes / 60), - minutes: minutes % 60, - }); + buildRequest(policiesEnabledMap: Map): Promise { + const singleOrgEnabled = policiesEnabledMap.get(PolicyType.SingleOrg) ?? false; + if (this.enabled.value && !singleOrgEnabled) { + throw new Error(this.i18nService.t("requireSsoPolicyReqError")); } - buildRequestData() { - if (this.data.value.hours == null && this.data.value.minutes == null) { - return null; - } - - return { - minutes: this.data.value.hours * 60 + this.data.value.minutes, - }; + const data = this.buildRequestData(); + if (data?.minutes == null || data?.minutes <= 0) { + throw new Error(this.i18nService.t("invalidMaximumVaultTimeout")); } - buildRequest(policiesEnabledMap: Map): Promise { - const singleOrgEnabled = policiesEnabledMap.get(PolicyType.SingleOrg) ?? false; - if (this.enabled.value && !singleOrgEnabled) { - throw new Error(this.i18nService.t('requireSsoPolicyReqError')); - } - - const data = this.buildRequestData(); - if (data?.minutes == null || data?.minutes <= 0) { - throw new Error(this.i18nService.t('invalidMaximumVaultTimeout')); - } - - return super.buildRequest(policiesEnabledMap); - } + return super.buildRequest(policiesEnabledMap); + } } diff --git a/bitwarden_license/src/app/providers/clients/add-organization.component.html b/bitwarden_license/src/app/providers/clients/add-organization.component.html index d1271cf625f..56602e01a08 100644 --- a/bitwarden_license/src/app/providers/clients/add-organization.component.html +++ b/bitwarden_license/src/app/providers/clients/add-organization.component.html @@ -1,35 +1,46 @@