1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-22 19:23:24 +00:00

Changes after npm run prettier

This commit is contained in:
Daniel James Smith
2021-12-16 15:13:39 +01:00
parent 3b15f451d6
commit b73fbf75e3
495 changed files with 28253 additions and 26714 deletions

View File

@@ -1,4 +1,5 @@
## Type of change
- [ ] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
@@ -6,22 +7,22 @@
- [ ] Other
## Objective
<!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding-->
## Code changes
<!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes-->
<!--Also refer to any related changes or PRs in other repositories-->
* **file.ext:** Description of what was changed and why
- **file.ext:** Description of what was changed and why
## Testing requirements
<!--What functionality requires testing by QA? This includes testing new behavior and regression testing-->
## Before you submit
- [ ] I have checked for **linting** errors (`npm run lint`) (required)
- [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required)
- [ ] This change requires a **documentation update** (notify the documentation team)

View File

@@ -20,7 +20,6 @@ jobs:
- name: Print lines of code
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
build:
name: Build jslib
runs-on: ${{ matrix.os }}
@@ -33,7 +32,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
with:
node-version: '16'
node-version: "16"
- name: Install node-gyp
run: |

4
.vscode/launch.json vendored
View File

@@ -10,9 +10,7 @@
"name": "Jasmine Individual Test",
"program": "${workspaceRoot}\\node_modules\\jasmine\\bin\\jasmine.js",
"preLaunchTask": "npm run build",
"args": [
"${workspaceFolder}/dist\\spec\\node\\services\\nodeCryptoFunction.service.spec.js"
]
"args": ["${workspaceFolder}/dist\\spec\\node\\services\\nodeCryptoFunction.service.spec.js"]
}
]
}

View File

@@ -6,15 +6,11 @@ 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
- **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
## Contributor Agreement
@@ -22,9 +18,9 @@ Please sign the [Contributor Agreement](https://cla-assistant.io/bitwarden/jslib
## 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
# Introduction to jslib and git submodules
@@ -33,36 +29,39 @@ jslib is a repository that contains shared code for all Bitwarden Typescript/Jav
If you haven't worked with submodules before, you should start by reading some basic guides (such as the [git scm chapter](https://git-scm.com/book/en/v2/Git-Tools-Submodules) or the [Atlassian tutorial](https://www.atlassian.com/git/tutorials/git-submodule)).
# Setting up your Local Dev environment for jslib
In order to easily develop local changes to jslib across each of the TypeScript/JavaScript clients, we recommend using symlinks for the submodule so that you only have to make the change once for it to be reflected across all your local repos.
## Prerequisites
1. git bash or other git command line
2. In order for this to work well, you need to use a consistent relative directory structure. Repos should be cloned in the following way:
* `./<your project(s) directory>`; we'll call this `/dev` ('cause why not)
* jslib - `git clone https://github.com/bitwarden/jslib.git` (/dev/jslib)
* web - `git clone --recurse-submodules https://github.com/bitwarden/web.git` (/dev/web)
* desktop - `git clone --recurse-submodules https://github.com/bitwarden/desktop.git` (/dev/desktop)
* browser - `git clone --recurse-submodules https://github.com/bitwarden/browser.git` (/dev/browser)
* cli - `git clone --recurse-submodules https://github.com/bitwarden/cli` (/dev/cli)
- `./<your project(s) directory>`; we'll call this `/dev` ('cause why not)
- jslib - `git clone https://github.com/bitwarden/jslib.git` (/dev/jslib)
- web - `git clone --recurse-submodules https://github.com/bitwarden/web.git` (/dev/web)
- desktop - `git clone --recurse-submodules https://github.com/bitwarden/desktop.git` (/dev/desktop)
- browser - `git clone --recurse-submodules https://github.com/bitwarden/browser.git` (/dev/browser)
- cli - `git clone --recurse-submodules https://github.com/bitwarden/cli` (/dev/cli)
You should notice web, desktop, browser and cli each reference jslib as a git submodule. If you've already cloned the repos but didn't use `--recurse-submodules` then you'll need to init the submodule with `npm run sub:init`.
## Configure Symlinks
Using `git clone` will make symlinks added to your repo be seen by git as plain text file paths. We need to prevent that. In the project root run, `git config core.symlinks true`.
For each project other than jslib, run the following:
* For macOS/Linux: `npm run symlink:mac`
* For Windows: `npm run symlink:win`
- For macOS/Linux: `npm run symlink:mac`
- For Windows: `npm run symlink:win`
Your client repos will now be pointing to your local jslib repo. You can now make changes in jslib and they will be immediately shared by the clients (just like they will be in production).
## Committing and pushing jslib changes
* You work on jslib like any other repo. Check out a new branch, make some commits, and push to remote when you're ready to submit a PR.
* Do not commit your jslib changes in the client repo. Your changes to the client and your changes to jslib should stay completely separate.
* When submitting a client PR that depends on a jslib PR, please include a link to the jslib PR so that the reviewer knows there are jslib changes.
- You work on jslib like any other repo. Check out a new branch, make some commits, and push to remote when you're ready to submit a PR.
- Do not commit your jslib changes in the client repo. Your changes to the client and your changes to jslib should stay completely separate.
- When submitting a client PR that depends on a jslib PR, please include a link to the jslib PR so that the reviewer knows there are jslib changes.
### Updating jslib on a feature branch
@@ -70,8 +69,8 @@ If you've submitted a client PR and a jslib PR, your jslib PR will be approved a
1. If you've symlinked the client's jslib directory following the steps above, you'll need to delete that symlink and then run `npm run sub:init`.
2. Update the jslib submodule:
* if you're working on your own fork, run `git submodule update --remote --reference upstream`.
* if you're working on a branch on the official repo, run `npm run sub:update`
- if you're working on your own fork, run `git submodule update --remote --reference upstream`.
- if you're working on a branch on the official repo, run `npm run sub:update`
3. To check you've done this correctly, you can `cd` into your jslib directory and run `git log`. You should see your recent changes in the log. This will also show you the most recent commit hash, which should match the most recent commit hash on [Github](https://github.com/bitwarden/jslib).
4. Add your changes: `git add jslib`
5. Commit your changes: `git commit -m "update jslib version"`
@@ -89,7 +88,8 @@ If you've made changes to jslib without needing to make any changes to the clien
4. Create a new PR to the client repo. Please include a link to your jslib PR so that reviewers know why you're updating jslib.
## Merge Conflicts
At times when you need to perform a `git merge master` into your feature or local branch, and there are conflicting version references to the *jslib* repo from your other clients, you will not be able to use the traditional merge or stage functions you would normally use for a file.
At times when you need to perform a `git merge master` into your feature or local branch, and there are conflicting version references to the _jslib_ repo from your other clients, you will not be able to use the traditional merge or stage functions you would normally use for a file.
To resolve you must use either `git reset` or update the index directly using `git update-index`. You can use (depending on whether you have symlink'd jslib) one of the following:

View File

@@ -1,26 +1,18 @@
import {
Directive,
Input,
OnChanges,
SimpleChanges,
} from '@angular/core';
import { Directive, Input, OnChanges, SimpleChanges } from "@angular/core";
import {
CdkDragDrop,
moveItemInArray,
} from '@angular/cdk/drag-drop';
import { CdkDragDrop, moveItemInArray } from "@angular/cdk/drag-drop";
import { EventService } from 'jslib-common/abstractions/event.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { EventService } from "jslib-common/abstractions/event.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { CipherView } from 'jslib-common/models/view/cipherView';
import { FieldView } from 'jslib-common/models/view/fieldView';
import { CipherView } from "jslib-common/models/view/cipherView";
import { FieldView } from "jslib-common/models/view/fieldView";
import { CipherType } from 'jslib-common/enums/cipherType';
import { EventType } from 'jslib-common/enums/eventType';
import { FieldType } from 'jslib-common/enums/fieldType';
import { CipherType } from "jslib-common/enums/cipherType";
import { EventType } from "jslib-common/enums/eventType";
import { FieldType } from "jslib-common/enums/fieldType";
import { Utils } from 'jslib-common/misc/utils';
import { Utils } from "jslib-common/misc/utils";
@Directive()
export class AddEditCustomFieldsComponent implements OnChanges {
@@ -39,11 +31,14 @@ export class AddEditCustomFieldsComponent implements OnChanges {
constructor(private i18nService: I18nService, private eventService: EventService) {
this.addFieldTypeOptions = [
{ name: i18nService.t('cfTypeText'), value: FieldType.Text },
{ name: i18nService.t('cfTypeHidden'), value: FieldType.Hidden },
{ name: i18nService.t('cfTypeBoolean'), value: FieldType.Boolean },
{ name: i18nService.t("cfTypeText"), value: FieldType.Text },
{ name: i18nService.t("cfTypeHidden"), value: FieldType.Hidden },
{ name: i18nService.t("cfTypeBoolean"), value: FieldType.Boolean },
];
this.addFieldLinkedTypeOption = { name: this.i18nService.t('cfTypeLinked'), value: FieldType.Linked };
this.addFieldLinkedTypeOption = {
name: this.i18nService.t("cfTypeLinked"),
value: FieldType.Linked,
};
}
ngOnChanges(changes: SimpleChanges) {
@@ -80,7 +75,7 @@ export class AddEditCustomFieldsComponent implements OnChanges {
}
toggleFieldValue(field: FieldView) {
const f = (field as any);
const f = field as any;
f.showValue = !f.showValue;
if (this.editMode && f.showValue) {
this.eventService.collect(EventType.Cipher_ClientToggledHiddenFieldVisible, this.cipher.id);
@@ -102,8 +97,9 @@ export class AddEditCustomFieldsComponent implements OnChanges {
const options: any = [];
this.cipher.linkedFieldOptions.forEach((linkedFieldOption, id) =>
options.push({ name: this.i18nService.t(linkedFieldOption.i18nKey), value: id }));
this.linkedFieldOptions = options.sort(Utils.getSortFunction(this.i18nService, 'name'));
options.push({ name: this.i18nService.t(linkedFieldOption.i18nKey), value: id })
);
this.linkedFieldOptions = options.sort(Utils.getSortFunction(this.i18nService, "name"));
}
private resetCipherLinkedFields() {
@@ -113,12 +109,12 @@ export class AddEditCustomFieldsComponent implements OnChanges {
// Delete any Linked custom fields if the item type does not support them
if (this.cipher.linkedFieldOptions == null) {
this.cipher.fields = this.cipher.fields.filter(f => f.type !== FieldType.Linked);
this.cipher.fields = this.cipher.fields.filter((f) => f.type !== FieldType.Linked);
return;
}
this.cipher.fields
.filter(f => f.type === FieldType.Linked)
.forEach(f => f.linkedId = this.linkedFieldOptions[0].value);
.filter((f) => f.type === FieldType.Linked)
.forEach((f) => (f.linkedId = this.linkedFieldOptions[0].value));
}
}

View File

@@ -1,26 +1,34 @@
<div #callout class="callout callout-{{calloutStyle}}" [ngClass]="{'clickable': clickable}"
[attr.role]="useAlertRole ? 'alert' : null">
<div
#callout
class="callout callout-{{ calloutStyle }}"
[ngClass]="{ clickable: clickable }"
[attr.role]="useAlertRole ? 'alert' : null"
>
<h3 class="callout-heading" *ngIf="title">
<i class="fa {{icon}}" *ngIf="icon" aria-hidden="true"></i>
{{title}}
<i class="fa {{ icon }}" *ngIf="icon" aria-hidden="true"></i>
{{ title }}
</h3>
<div class="enforced-policy-options" *ngIf="enforcedPolicyOptions">
{{enforcedPolicyMessage}}
{{ enforcedPolicyMessage }}
<ul>
<li *ngIf="enforcedPolicyOptions?.minComplexity > 0">
{{'policyInEffectMinComplexity' | i18n : getPasswordScoreAlertDisplay()}}
{{ "policyInEffectMinComplexity" | i18n: getPasswordScoreAlertDisplay() }}
</li>
<li *ngIf="enforcedPolicyOptions?.minLength > 0">
{{'policyInEffectMinLength' | i18n : enforcedPolicyOptions?.minLength.toString()}}
{{ "policyInEffectMinLength" | i18n: enforcedPolicyOptions?.minLength.toString() }}
</li>
<li *ngIf="enforcedPolicyOptions?.requireUpper">
{{'policyInEffectUppercase' | i18n}}</li>
{{ "policyInEffectUppercase" | i18n }}
</li>
<li *ngIf="enforcedPolicyOptions?.requireLower">
{{'policyInEffectLowercase' | i18n}}</li>
{{ "policyInEffectLowercase" | i18n }}
</li>
<li *ngIf="enforcedPolicyOptions?.requireNumbers">
{{'policyInEffectNumbers' | i18n}}</li>
{{ "policyInEffectNumbers" | i18n }}
</li>
<li *ngIf="enforcedPolicyOptions?.requireSpecial">
{{'policyInEffectSpecial' | i18n : '!@#$%^&*'}}</li>
{{ "policyInEffectSpecial" | i18n: "!@#$%^&*" }}
</li>
</ul>
</div>
<ng-content></ng-content>

View File

@@ -1,19 +1,15 @@
import {
Component,
Input,
OnInit,
} from '@angular/core';
import { Component, Input, OnInit } from "@angular/core";
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { MasterPasswordPolicyOptions } from 'jslib-common/models/domain/masterPasswordPolicyOptions';
import { MasterPasswordPolicyOptions } from "jslib-common/models/domain/masterPasswordPolicyOptions";
@Component({
selector: 'app-callout',
templateUrl: 'callout.component.html',
selector: "app-callout",
templateUrl: "callout.component.html",
})
export class CalloutComponent implements OnInit {
@Input() type = 'info';
@Input() type = "info";
@Input() icon: string;
@Input() title: string;
@Input() clickable: boolean;
@@ -23,61 +19,61 @@ export class CalloutComponent implements OnInit {
calloutStyle: string;
constructor(private i18nService: I18nService) { }
constructor(private i18nService: I18nService) {}
ngOnInit() {
this.calloutStyle = this.type;
if (this.enforcedPolicyMessage === undefined) {
this.enforcedPolicyMessage = this.i18nService.t('masterPasswordPolicyInEffect');
this.enforcedPolicyMessage = this.i18nService.t("masterPasswordPolicyInEffect");
}
if (this.type === 'warning' || this.type === 'danger') {
if (this.type === 'danger') {
this.calloutStyle = 'danger';
if (this.type === "warning" || this.type === "danger") {
if (this.type === "danger") {
this.calloutStyle = "danger";
}
if (this.title === undefined) {
this.title = this.i18nService.t('warning');
this.title = this.i18nService.t("warning");
}
if (this.icon === undefined) {
this.icon = 'fa-warning';
this.icon = "fa-warning";
}
} else if (this.type === 'error') {
this.calloutStyle = 'danger';
} else if (this.type === "error") {
this.calloutStyle = "danger";
if (this.title === undefined) {
this.title = this.i18nService.t('error');
this.title = this.i18nService.t("error");
}
if (this.icon === undefined) {
this.icon = 'fa-bolt';
this.icon = "fa-bolt";
}
} else if (this.type === 'tip') {
this.calloutStyle = 'success';
} else if (this.type === "tip") {
this.calloutStyle = "success";
if (this.title === undefined) {
this.title = this.i18nService.t('tip');
this.title = this.i18nService.t("tip");
}
if (this.icon === undefined) {
this.icon = 'fa-lightbulb-o';
this.icon = "fa-lightbulb-o";
}
}
}
getPasswordScoreAlertDisplay() {
if (this.enforcedPolicyOptions == null) {
return '';
return "";
}
let str: string;
switch (this.enforcedPolicyOptions.minComplexity) {
case 4:
str = this.i18nService.t('strong');
str = this.i18nService.t("strong");
break;
case 3:
str = this.i18nService.t('good');
str = this.i18nService.t("good");
break;
default:
str = this.i18nService.t('weak');
str = this.i18nService.t("weak");
break;
}
return str + ' (' + this.enforcedPolicyOptions.minComplexity + ')';
return str + " (" + this.enforcedPolicyOptions.minComplexity + ")";
}
}

View File

@@ -1,12 +1,12 @@
import { Directive, Input } from '@angular/core';
import { Directive, Input } from "@angular/core";
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { CaptchaIFrame } from 'jslib-common/misc/captcha_iframe';
import { CaptchaIFrame } from "jslib-common/misc/captcha_iframe";
import { Utils } from 'jslib-common/misc/utils';
import { Utils } from "jslib-common/misc/utils";
@Directive()
export abstract class CaptchaProtectedComponent {
@@ -14,19 +14,27 @@ export abstract class CaptchaProtectedComponent {
captchaToken: string = null;
captcha: CaptchaIFrame;
constructor(protected environmentService: EnvironmentService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService) { }
constructor(
protected environmentService: EnvironmentService,
protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService
) {}
async setupCaptcha() {
const webVaultUrl = this.environmentService.getWebVaultUrl();
this.captcha = new CaptchaIFrame(window, webVaultUrl,
this.i18nService, (token: string) => {
this.captcha = new CaptchaIFrame(
window,
webVaultUrl,
this.i18nService,
(token: string) => {
this.captchaToken = token;
}, (error: string) => {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), error);
}, (info: string) => {
this.platformUtilsService.showToast('info', this.i18nService.t('info'), info);
},
(error: string) => {
this.platformUtilsService.showToast("error", this.i18nService.t("errorOccurred"), error);
},
(info: string) => {
this.platformUtilsService.showToast("info", this.i18nService.t("info"), info);
}
);
}
@@ -35,7 +43,7 @@ export abstract class CaptchaProtectedComponent {
return !Utils.isNullOrWhitespace(this.captchaSiteKey);
}
protected handleCaptchaRequired(response: { captchaSiteKey: string; }): boolean {
protected handleCaptchaRequired(response: { captchaSiteKey: string }): boolean {
if (Utils.isNullOrWhitespace(response.captchaSiteKey)) {
return false;
}

View File

@@ -1,13 +1,8 @@
import {
Directive,
EventEmitter,
Input,
Output,
} from '@angular/core';
import { Directive, EventEmitter, Input, Output } from "@angular/core";
import { SearchService } from 'jslib-common/abstractions/search.service';
import { SearchService } from "jslib-common/abstractions/search.service";
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CipherView } from "jslib-common/models/view/cipherView";
@Directive()
export class CiphersComponent {
@@ -28,7 +23,7 @@ export class CiphersComponent {
private searchTimeout: any = null;
constructor(protected searchService: SearchService) { }
constructor(protected searchService: SearchService) {}
async load(filter: (cipher: CipherView) => boolean = null, deleted: boolean = false) {
this.deleted = deleted || false;
@@ -87,9 +82,13 @@ export class CiphersComponent {
return !this.searchPending && this.searchService.isSearchable(this.searchText);
}
protected deletedFilter: (cipher: CipherView) => boolean = c => c.isDeleted === this.deleted;
protected deletedFilter: (cipher: CipherView) => boolean = (c) => c.isDeleted === this.deleted;
protected async doSearch(indexedCiphers?: CipherView[]) {
this.ciphers = await this.searchService.searchCiphers(this.searchText, [this.filter, this.deletedFilter], indexedCiphers);
this.ciphers = await this.searchService.searchCiphers(
this.searchText,
[this.filter, this.deletedFilter],
indexedCiphers
);
}
}

View File

@@ -1,21 +1,15 @@
import {
Directive,
EventEmitter,
Input,
OnInit,
Output,
} from '@angular/core';
import { Directive, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { CollectionService } from 'jslib-common/abstractions/collection.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { CipherService } from "jslib-common/abstractions/cipher.service";
import { CollectionService } from "jslib-common/abstractions/collection.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CollectionView } from 'jslib-common/models/view/collectionView';
import { CipherView } from "jslib-common/models/view/cipherView";
import { CollectionView } from "jslib-common/models/view/collectionView";
import { Cipher } from 'jslib-common/models/domain/cipher';
import { Cipher } from "jslib-common/models/domain/cipher";
@Directive()
export class CollectionsComponent implements OnInit {
@@ -30,8 +24,13 @@ export class CollectionsComponent implements OnInit {
protected cipherDomain: Cipher;
constructor(protected collectionService: CollectionService, protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService, protected cipherService: CipherService, private logService: LogService) { }
constructor(
protected collectionService: CollectionService,
protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService,
protected cipherService: CipherService,
private logService: LogService
) {}
async ngOnInit() {
await this.load();
@@ -43,9 +42,9 @@ export class CollectionsComponent implements OnInit {
this.cipher = await this.cipherDomain.decrypt();
this.collections = await this.loadCollections();
this.collections.forEach(c => (c as any).checked = false);
this.collections.forEach((c) => ((c as any).checked = false));
if (this.collectionIds != null) {
this.collections.forEach(c => {
this.collections.forEach((c) => {
(c as any).checked = this.collectionIds != null && this.collectionIds.indexOf(c.id) > -1;
});
}
@@ -53,11 +52,14 @@ export class CollectionsComponent implements OnInit {
async submit() {
const selectedCollectionIds = this.collections
.filter(c => !!(c as any).checked)
.map(c => c.id);
.filter((c) => !!(c as any).checked)
.map((c) => c.id);
if (!this.allowSelectNone && selectedCollectionIds.length === 0) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('selectOneCollection'));
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("selectOneCollection")
);
return;
}
this.cipherDomain.collectionIds = selectedCollectionIds;
@@ -65,7 +67,7 @@ export class CollectionsComponent implements OnInit {
this.formPromise = this.saveCollections();
await this.formPromise;
this.onSavedCollections.emit();
this.platformUtilsService.showToast('success', null, this.i18nService.t('editedItem'));
this.platformUtilsService.showToast("success", null, this.i18nService.t("editedItem"));
} catch (e) {
this.logService.error(e);
}
@@ -81,7 +83,9 @@ export class CollectionsComponent implements OnInit {
protected async loadCollections() {
const allCollections = await this.collectionService.getAllDecrypted();
return allCollections.filter(c => !c.readOnly && c.organizationId === this.cipher.organizationId);
return allCollections.filter(
(c) => !c.readOnly && c.organizationId === this.cipher.organizationId
);
}
protected saveCollections() {

View File

@@ -1,12 +1,8 @@
import {
Directive,
EventEmitter,
Output,
} from '@angular/core';
import { Directive, EventEmitter, Output } from "@angular/core";
import { EnvironmentService } from 'jslib-common/abstractions/environment.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
@Directive()
export class EnvironmentComponent {
@@ -20,17 +16,19 @@ export class EnvironmentComponent {
baseUrl: string;
showCustom = false;
constructor(protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService,
protected i18nService: I18nService) {
constructor(
protected platformUtilsService: PlatformUtilsService,
protected environmentService: EnvironmentService,
protected i18nService: I18nService
) {
const urls = this.environmentService.getUrls();
this.baseUrl = urls.base || '';
this.webVaultUrl = urls.webVault || '';
this.apiUrl = urls.api || '';
this.identityUrl = urls.identity || '';
this.iconsUrl = urls.icons || '';
this.notificationsUrl = urls.notifications || '';
this.baseUrl = urls.base || "";
this.webVaultUrl = urls.webVault || "";
this.apiUrl = urls.api || "";
this.identityUrl = urls.identity || "";
this.iconsUrl = urls.icons || "";
this.notificationsUrl = urls.notifications || "";
}
async submit() {
@@ -51,7 +49,7 @@ export class EnvironmentComponent {
this.iconsUrl = resUrls.icons;
this.notificationsUrl = resUrls.notifications;
this.platformUtilsService.showToast('success', null, this.i18nService.t('environmentSaved'));
this.platformUtilsService.showToast("success", null, this.i18nService.t("environmentSaved"));
this.saved();
}

View File

@@ -1,22 +1,17 @@
import {
Directive,
EventEmitter,
OnInit,
Output,
} from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { Directive, EventEmitter, OnInit, Output } from "@angular/core";
import { FormBuilder } from "@angular/forms";
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { EventService } from 'jslib-common/abstractions/event.service';
import { ExportService } from 'jslib-common/abstractions/export.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { UserVerificationService } from 'jslib-common/abstractions/userVerification.service';
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { EventService } from "jslib-common/abstractions/event.service";
import { ExportService } from "jslib-common/abstractions/export.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PolicyService } from "jslib-common/abstractions/policy.service";
import { UserVerificationService } from "jslib-common/abstractions/userVerification.service";
import { EventType } from 'jslib-common/enums/eventType';
import { PolicyType } from 'jslib-common/enums/policyType';
import { EventType } from "jslib-common/enums/eventType";
import { PolicyType } from "jslib-common/enums/policyType";
@Directive()
export class ExportComponent implements OnInit {
@@ -26,40 +21,53 @@ export class ExportComponent implements OnInit {
disabledByPolicy: boolean = false;
exportForm = this.fb.group({
format: ['json'],
secret: [''],
format: ["json"],
secret: [""],
});
formatOptions = [
{ name: '.json', value: 'json' },
{ name: '.csv', value: 'csv' },
{ name: '.json (Encrypted)', value: 'encrypted_json' },
{ name: ".json", value: "json" },
{ name: ".csv", value: "csv" },
{ name: ".json (Encrypted)", value: "encrypted_json" },
];
constructor(protected cryptoService: CryptoService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected exportService: ExportService,
protected eventService: EventService, private policyService: PolicyService, protected win: Window,
private logService: LogService, private userVerificationService: UserVerificationService,
private fb: FormBuilder) { }
constructor(
protected cryptoService: CryptoService,
protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService,
protected exportService: ExportService,
protected eventService: EventService,
private policyService: PolicyService,
protected win: Window,
private logService: LogService,
private userVerificationService: UserVerificationService,
private fb: FormBuilder
) {}
async ngOnInit() {
await this.checkExportDisabled();
}
async checkExportDisabled() {
this.disabledByPolicy = await this.policyService.policyAppliesToUser(PolicyType.DisablePersonalVaultExport);
this.disabledByPolicy = await this.policyService.policyAppliesToUser(
PolicyType.DisablePersonalVaultExport
);
if (this.disabledByPolicy) {
this.exportForm.disable();
}
}
get encryptedFormat() {
return this.format === 'encrypted_json';
return this.format === "encrypted_json";
}
async submit() {
if (this.disabledByPolicy) {
this.platformUtilsService.showToast('error', null, this.i18nService.t('personalVaultExportPolicyInEffect'));
this.platformUtilsService.showToast(
"error",
null,
this.i18nService.t("personalVaultExportPolicyInEffect")
);
return;
}
@@ -68,11 +76,11 @@ export class ExportComponent implements OnInit {
return;
}
const secret = this.exportForm.get('secret').value;
const secret = this.exportForm.get("secret").value;
try {
await this.userVerificationService.verifyUser(secret);
} catch (e) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), e.message);
this.platformUtilsService.showToast("error", this.i18nService.t("errorOccurred"), e.message);
return;
}
@@ -82,7 +90,7 @@ export class ExportComponent implements OnInit {
this.downloadFile(data);
this.saved();
await this.collectEvent();
this.exportForm.get('secret').setValue('');
this.exportForm.get("secret").setValue("");
} catch (e) {
this.logService.error(e);
}
@@ -91,16 +99,24 @@ export class ExportComponent implements OnInit {
async warningDialog() {
if (this.encryptedFormat) {
return await this.platformUtilsService.showDialog(
'<p>' + this.i18nService.t('encExportKeyWarningDesc') +
'<p>' + this.i18nService.t('encExportAccountWarningDesc'),
this.i18nService.t('confirmVaultExport'), this.i18nService.t('exportVault'),
this.i18nService.t('cancel'), 'warning',
true);
"<p>" +
this.i18nService.t("encExportKeyWarningDesc") +
"<p>" +
this.i18nService.t("encExportAccountWarningDesc"),
this.i18nService.t("confirmVaultExport"),
this.i18nService.t("exportVault"),
this.i18nService.t("cancel"),
"warning",
true
);
} else {
return await this.platformUtilsService.showDialog(
this.i18nService.t('exportWarningDesc'),
this.i18nService.t('confirmVaultExport'), this.i18nService.t('exportVault'),
this.i18nService.t('cancel'), 'warning');
this.i18nService.t("exportWarningDesc"),
this.i18nService.t("confirmVaultExport"),
this.i18nService.t("exportVault"),
this.i18nService.t("cancel"),
"warning"
);
}
}
@@ -114,13 +130,13 @@ export class ExportComponent implements OnInit {
protected getFileName(prefix?: string) {
let extension = this.format;
if (this.format === 'encrypted_json') {
if (this.format === "encrypted_json") {
if (prefix == null) {
prefix = 'encrypted';
prefix = "encrypted";
} else {
prefix = 'encrypted_' + prefix;
prefix = "encrypted_" + prefix;
}
extension = 'json';
extension = "json";
}
return this.exportService.getFileName(prefix, extension);
}
@@ -130,11 +146,11 @@ export class ExportComponent implements OnInit {
}
get format() {
return this.exportForm.get('format').value;
return this.exportForm.get("format").value;
}
private downloadFile(csv: string): void {
const fileName = this.getFileName();
this.platformUtilsService.saveFile(this.win, csv, { type: 'text/plain' }, fileName);
this.platformUtilsService.saveFile(this.win, csv, { type: "text/plain" }, fileName);
}
}

View File

@@ -1,17 +1,11 @@
import {
Directive,
EventEmitter,
Input,
OnInit,
Output,
} from '@angular/core';
import { Directive, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { FolderService } from 'jslib-common/abstractions/folder.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { FolderService } from "jslib-common/abstractions/folder.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { FolderView } from 'jslib-common/models/view/folderView';
import { FolderView } from "jslib-common/models/view/folderView";
@Directive()
export class FolderAddEditComponent implements OnInit {
@@ -25,17 +19,24 @@ export class FolderAddEditComponent implements OnInit {
formPromise: Promise<any>;
deletePromise: Promise<any>;
constructor(protected folderService: FolderService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, private logService: LogService) { }
constructor(
protected folderService: FolderService,
protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService,
private logService: LogService
) {}
async ngOnInit() {
await this.init();
}
async submit(): Promise<boolean> {
if (this.folder.name == null || this.folder.name === '') {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('nameRequired'));
if (this.folder.name == null || this.folder.name === "") {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("nameRequired")
);
return false;
}
@@ -43,8 +44,11 @@ export class FolderAddEditComponent implements OnInit {
const folder = await this.folderService.encrypt(this.folder);
this.formPromise = this.folderService.saveWithServer(folder);
await this.formPromise;
this.platformUtilsService.showToast('success', null,
this.i18nService.t(this.editMode ? 'editedFolder' : 'addedFolder'));
this.platformUtilsService.showToast(
"success",
null,
this.i18nService.t(this.editMode ? "editedFolder" : "addedFolder")
);
this.onSavedFolder.emit(this.folder);
return true;
} catch (e) {
@@ -56,8 +60,12 @@ export class FolderAddEditComponent implements OnInit {
async delete(): Promise<boolean> {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('deleteFolderConfirmation'), this.i18nService.t('deleteFolder'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
this.i18nService.t("deleteFolderConfirmation"),
this.i18nService.t("deleteFolder"),
this.i18nService.t("yes"),
this.i18nService.t("no"),
"warning"
);
if (!confirmed) {
return false;
}
@@ -65,7 +73,7 @@ export class FolderAddEditComponent implements OnInit {
try {
this.deletePromise = this.folderService.deleteWithServer(this.folder.id);
await this.deletePromise;
this.platformUtilsService.showToast('success', null, this.i18nService.t('deletedFolder'));
this.platformUtilsService.showToast("success", null, this.i18nService.t("deletedFolder"));
this.onDeletedFolder.emit(this.folder);
} catch (e) {
this.logService.error(e);
@@ -79,11 +87,11 @@ export class FolderAddEditComponent implements OnInit {
if (this.editMode) {
this.editMode = true;
this.title = this.i18nService.t('editFolder');
this.title = this.i18nService.t("editFolder");
const folder = await this.folderService.get(this.folderId);
this.folder = await folder.decrypt();
} else {
this.title = this.i18nService.t('addFolder');
this.title = this.i18nService.t("addFolder");
}
}
}

View File

@@ -1,39 +1,49 @@
import { Router } from '@angular/router';
import { Router } from "@angular/router";
import { PasswordHintRequest } from 'jslib-common/models/request/passwordHintRequest';
import { PasswordHintRequest } from "jslib-common/models/request/passwordHintRequest";
import { ApiService } from 'jslib-common/abstractions/api.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { LogService } from 'jslib-common/abstractions/log.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 { LogService } from "jslib-common/abstractions/log.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
export class HintComponent {
email: string = '';
email: string = "";
formPromise: Promise<any>;
protected successRoute = 'login';
protected successRoute = "login";
protected onSuccessfulSubmit: () => void;
constructor(protected router: Router, protected i18nService: I18nService,
protected apiService: ApiService, protected platformUtilsService: PlatformUtilsService,
private logService: LogService) { }
constructor(
protected router: Router,
protected i18nService: I18nService,
protected apiService: ApiService,
protected platformUtilsService: PlatformUtilsService,
private logService: LogService
) {}
async submit() {
if (this.email == null || this.email === '') {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('emailRequired'));
if (this.email == null || this.email === "") {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("emailRequired")
);
return;
}
if (this.email.indexOf('@') === -1) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('invalidEmail'));
if (this.email.indexOf("@") === -1) {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("invalidEmail")
);
return;
}
try {
this.formPromise = this.apiService.postPasswordHint(new PasswordHintRequest(this.email));
await this.formPromise;
this.platformUtilsService.showToast('success', null, this.i18nService.t('masterPassSent'));
this.platformUtilsService.showToast("success", null, this.i18nService.t("masterPassSent"));
if (this.onSuccessfulSubmit != null) {
this.onSuccessfulSubmit();
} else if (this.router != null) {

View File

@@ -1,4 +1,4 @@
<div class="icon" aria-hidden="true">
<img [src]="image" appFallbackSrc="{{fallbackImage}}" *ngIf="imageEnabled && image" alt="" />
<i class="fa fa-fw fa-lg {{icon}}" *ngIf="!imageEnabled || !image"></i>
<img [src]="image" appFallbackSrc="{{ fallbackImage }}" *ngIf="imageEnabled && image" alt="" />
<i class="fa fa-fw fa-lg {{ icon }}" *ngIf="!imageEnabled || !image"></i>
</div>

View File

@@ -7,35 +7,37 @@ import {
OnDestroy,
Type,
ViewChild,
ViewContainerRef
} from '@angular/core';
ViewContainerRef,
} from "@angular/core";
import {
ConfigurableFocusTrap,
ConfigurableFocusTrapFactory,
} from '@angular/cdk/a11y';
import { ConfigurableFocusTrap, ConfigurableFocusTrapFactory } from "@angular/cdk/a11y";
import { ModalService } from '../../services/modal.service';
import { ModalService } from "../../services/modal.service";
import { ModalRef } from './modal.ref';
import { ModalRef } from "./modal.ref";
@Component({
selector: 'app-modal',
template: '<ng-template #modalContent></ng-template>',
selector: "app-modal",
template: "<ng-template #modalContent></ng-template>",
})
export class DynamicModalComponent implements AfterViewInit, OnDestroy {
componentRef: ComponentRef<any>;
@ViewChild('modalContent', { read: ViewContainerRef, static: true }) modalContentRef: ViewContainerRef;
@ViewChild("modalContent", { read: ViewContainerRef, static: true })
modalContentRef: ViewContainerRef;
childComponentType: Type<any>;
setComponentParameters: (component: any) => void;
private focusTrap: ConfigurableFocusTrap;
constructor(private modalService: ModalService, private cd: ChangeDetectorRef,
private el: ElementRef<HTMLElement>, private focusTrapFactory: ConfigurableFocusTrapFactory,
public modalRef: ModalRef) { }
constructor(
private modalService: ModalService,
private cd: ChangeDetectorRef,
private el: ElementRef<HTMLElement>,
private focusTrapFactory: ConfigurableFocusTrapFactory,
public modalRef: ModalRef
) {}
ngAfterViewInit() {
this.loadChildComponent(this.childComponentType);
@@ -45,8 +47,10 @@ export class DynamicModalComponent implements AfterViewInit, OnDestroy {
this.cd.detectChanges();
this.modalRef.created(this.el.nativeElement);
this.focusTrap = this.focusTrapFactory.create(this.el.nativeElement.querySelector('.modal-dialog'));
if (this.el.nativeElement.querySelector('[appAutoFocus]') == null) {
this.focusTrap = this.focusTrapFactory.create(
this.el.nativeElement.querySelector(".modal-dialog")
);
if (this.el.nativeElement.querySelector("[appAutoFocus]") == null) {
this.focusTrap.focusFirstTabbableElementWhenReady();
}
}
@@ -70,7 +74,7 @@ export class DynamicModalComponent implements AfterViewInit, OnDestroy {
}
getFocus() {
const autoFocusEl = this.el.nativeElement.querySelector('[appAutoFocus]') as HTMLElement;
const autoFocusEl = this.el.nativeElement.querySelector("[appAutoFocus]") as HTMLElement;
autoFocusEl?.focus();
}
}

View File

@@ -1,9 +1,4 @@
import {
InjectFlags,
InjectionToken,
Injector,
Type
} from '@angular/core';
import { InjectFlags, InjectionToken, Injector, Type } from "@angular/core";
export class ModalInjector implements Injector {
constructor(private _parentInjector: Injector, private _additionalTokens: WeakMap<any, any>) {}

View File

@@ -1,18 +1,21 @@
import { Directive, OnInit } from '@angular/core';
import { Directive, OnInit } from "@angular/core";
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { GeneratedPasswordHistory } from 'jslib-common/models/domain/generatedPasswordHistory';
import { GeneratedPasswordHistory } from "jslib-common/models/domain/generatedPasswordHistory";
@Directive()
export class PasswordGeneratorHistoryComponent implements OnInit {
history: GeneratedPasswordHistory[] = [];
constructor(protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
private win: Window) { }
constructor(
protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService,
private win: Window
) {}
async ngOnInit() {
this.history = await this.passwordGenerationService.getHistory();
@@ -26,7 +29,10 @@ export class PasswordGeneratorHistoryComponent implements OnInit {
copy(password: string) {
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast('info', null,
this.i18nService.t('valueCopied', this.i18nService.t('password')));
this.platformUtilsService.showToast(
"info",
null,
this.i18nService.t("valueCopied", this.i18nService.t("password"))
);
}
}

View File

@@ -1,16 +1,10 @@
import {
Directive,
EventEmitter,
Input,
OnInit,
Output,
} from '@angular/core';
import { Directive, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PasswordGeneratorPolicyOptions } from 'jslib-common/models/domain/passwordGeneratorPolicyOptions';
import { PasswordGeneratorPolicyOptions } from "jslib-common/models/domain/passwordGeneratorPolicyOptions";
@Directive()
export class PasswordGeneratorComponent implements OnInit {
@@ -19,17 +13,20 @@ export class PasswordGeneratorComponent implements OnInit {
passTypeOptions: any[];
options: any = {};
password: string = '-';
password: string = "-";
showOptions = false;
avoidAmbiguous = false;
enforcedPolicyOptions: PasswordGeneratorPolicyOptions;
constructor(protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService, protected i18nService: I18nService,
private win: Window) {
constructor(
protected passwordGenerationService: PasswordGenerationService,
protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService,
private win: Window
) {
this.passTypeOptions = [
{ name: i18nService.t('password'), value: 'password' },
{ name: i18nService.t('passphrase'), value: 'passphrase' },
{ name: i18nService.t("password"), value: "password" },
{ name: i18nService.t("passphrase"), value: "passphrase" },
];
}
@@ -38,7 +35,7 @@ export class PasswordGeneratorComponent implements OnInit {
this.options = optionsResponse[0];
this.enforcedPolicyOptions = optionsResponse[1];
this.avoidAmbiguous = !this.options.ambiguous;
this.options.type = this.options.type === 'passphrase' ? 'passphrase' : 'password';
this.options.type = this.options.type === "passphrase" ? "passphrase" : "password";
this.password = await this.passwordGenerationService.generatePassword(this.options);
await this.passwordGenerationService.addHistory(this.password);
}
@@ -70,8 +67,11 @@ export class PasswordGeneratorComponent implements OnInit {
copy() {
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(this.password, copyOptions);
this.platformUtilsService.showToast('info', null,
this.i18nService.t('valueCopied', this.i18nService.t('password')));
this.platformUtilsService.showToast(
"info",
null,
this.i18nService.t("valueCopied", this.i18nService.t("password"))
);
}
select() {
@@ -86,10 +86,15 @@ export class PasswordGeneratorComponent implements OnInit {
// Application level normalize options depedent on class variables
this.options.ambiguous = !this.avoidAmbiguous;
if (!this.options.uppercase && !this.options.lowercase && !this.options.number && !this.options.special) {
if (
!this.options.uppercase &&
!this.options.lowercase &&
!this.options.number &&
!this.options.special
) {
this.options.lowercase = true;
if (this.win != null) {
const lowercase = this.win.document.querySelector('#lowercase') as HTMLInputElement;
const lowercase = this.win.document.querySelector("#lowercase") as HTMLInputElement;
if (lowercase) {
lowercase.checked = true;
}

View File

@@ -1,18 +1,22 @@
import { Directive, OnInit } from '@angular/core';
import { Directive, OnInit } from "@angular/core";
import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { CipherService } from "jslib-common/abstractions/cipher.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { PasswordHistoryView } from 'jslib-common/models/view/passwordHistoryView';
import { PasswordHistoryView } from "jslib-common/models/view/passwordHistoryView";
@Directive()
export class PasswordHistoryComponent implements OnInit {
cipherId: string;
history: PasswordHistoryView[] = [];
constructor(protected cipherService: CipherService, protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService, private win: Window) { }
constructor(
protected cipherService: CipherService,
protected platformUtilsService: PlatformUtilsService,
protected i18nService: I18nService,
private win: Window
) {}
async ngOnInit() {
await this.init();
@@ -21,8 +25,11 @@ export class PasswordHistoryComponent implements OnInit {
copy(password: string) {
const copyOptions = this.win != null ? { window: this.win } : null;
this.platformUtilsService.copyToClipboard(password, copyOptions);
this.platformUtilsService.showToast('info', null,
this.i18nService.t('valueCopied', this.i18nService.t('password')));
this.platformUtilsService.showToast(
"info",
null,
this.i18nService.t("valueCopied", this.i18nService.t("password"))
);
}
protected async init() {

View File

@@ -1,27 +1,33 @@
import { Directive } from '@angular/core';
import { Directive } from "@angular/core";
import { CryptoService } from 'jslib-common/abstractions/crypto.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { ModalRef } from './modal/modal.ref';
import { CryptoService } from "jslib-common/abstractions/crypto.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { ModalRef } from "./modal/modal.ref";
@Directive()
export class PasswordRepromptComponent {
showPassword = false;
masterPassword = '';
masterPassword = "";
constructor(private modalRef: ModalRef, private cryptoService: CryptoService, private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService) {}
constructor(
private modalRef: ModalRef,
private cryptoService: CryptoService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService
) {}
togglePassword() {
this.showPassword = !this.showPassword;
}
async submit() {
if (!await this.cryptoService.compareAndUpdateKeyHash(this.masterPassword, null)) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('invalidMasterPassword'));
if (!(await this.cryptoService.compareAndUpdateKeyHash(this.masterPassword, null))) {
this.platformUtilsService.showToast(
"error",
this.i18nService.t("errorOccurred"),
this.i18nService.t("invalidMasterPassword")
);
return;
}

View File

@@ -1,34 +1,28 @@
import { DatePipe } from '@angular/common';
import {
Directive,
EventEmitter,
Input,
OnInit,
Output
} from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { DatePipe } from "@angular/common";
import { Directive, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { FormControl, FormGroup } from "@angular/forms";
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
// Different BrowserPath = different controls.
enum BrowserPath {
// Native datetime-locale.
// We are happy.
Default = 'default',
Default = "default",
// Native date and time inputs, but no datetime-locale.
// We use individual date and time inputs and create a datetime programatically on submit.
Firefox = 'firefox',
Firefox = "firefox",
// No native date, time, or datetime-locale inputs.
// We use a polyfill for dates and a dropdown for times.
Safari = 'safari',
Safari = "safari",
}
enum DateField {
DeletionDate = 'deletion',
ExpriationDate = 'expiration',
DeletionDate = "deletion",
ExpriationDate = "expiration",
}
// Value = hours
@@ -57,7 +51,7 @@ export class EffluxDatesComponent implements OnInit {
@Input() readonly editMode: boolean;
@Input() readonly disabled: boolean;
@Output() datesChanged = new EventEmitter<{deletionDate: string, expirationDate: string}>();
@Output() datesChanged = new EventEmitter<{ deletionDate: string; expirationDate: string }>();
get browserPath(): BrowserPath {
if (this.platformUtilsService.isFirefox()) {
@@ -80,49 +74,49 @@ export class EffluxDatesComponent implements OnInit {
});
deletionDatePresets: any[] = [
{ name: this.i18nService.t('oneHour'), value: DatePreset.OneHour },
{ name: this.i18nService.t('oneDay'), value: DatePreset.OneDay },
{ name: this.i18nService.t('days', '2'), value: DatePreset.TwoDays },
{ name: this.i18nService.t('days', '3'), value: DatePreset.ThreeDays },
{ name: this.i18nService.t('days', '7'), value: DatePreset.SevenDays },
{ name: this.i18nService.t('days', '30'), value: DatePreset.ThirtyDays },
{ name: this.i18nService.t('custom'), value: DatePreset.Custom },
{ name: this.i18nService.t("oneHour"), value: DatePreset.OneHour },
{ name: this.i18nService.t("oneDay"), value: DatePreset.OneDay },
{ name: this.i18nService.t("days", "2"), value: DatePreset.TwoDays },
{ name: this.i18nService.t("days", "3"), value: DatePreset.ThreeDays },
{ name: this.i18nService.t("days", "7"), value: DatePreset.SevenDays },
{ name: this.i18nService.t("days", "30"), value: DatePreset.ThirtyDays },
{ name: this.i18nService.t("custom"), value: DatePreset.Custom },
];
expirationDatePresets: any[] = [
{ name: this.i18nService.t('never'), value: DatePreset.Never },
{ name: this.i18nService.t("never"), value: DatePreset.Never },
].concat([...this.deletionDatePresets]);
get selectedDeletionDatePreset(): FormControl {
return this.datesForm.get('selectedDeletionDatePreset') as FormControl;
return this.datesForm.get("selectedDeletionDatePreset") as FormControl;
}
get selectedExpirationDatePreset(): FormControl {
return this.datesForm.get('selectedExpirationDatePreset') as FormControl;
return this.datesForm.get("selectedExpirationDatePreset") as FormControl;
}
get defaultDeletionDateTime(): FormControl {
return this.datesForm.get('defaultDeletionDateTime') as FormControl;
return this.datesForm.get("defaultDeletionDateTime") as FormControl;
}
get defaultExpirationDateTime(): FormControl {
return this.datesForm.get('defaultExpirationDateTime') as FormControl;
return this.datesForm.get("defaultExpirationDateTime") as FormControl;
}
get fallbackDeletionDate(): FormControl {
return this.datesForm.get('fallbackDeletionDate') as FormControl;
return this.datesForm.get("fallbackDeletionDate") as FormControl;
}
get fallbackDeletionTime(): FormControl {
return this.datesForm.get('fallbackDeletionTime') as FormControl;
return this.datesForm.get("fallbackDeletionTime") as FormControl;
}
get fallbackExpirationDate(): FormControl {
return this.datesForm.get('fallbackExpirationDate') as FormControl;
return this.datesForm.get("fallbackExpirationDate") as FormControl;
}
get fallbackExpirationTime(): FormControl {
return this.datesForm.get('fallbackExpirationTime') as FormControl;
return this.datesForm.get("fallbackExpirationTime") as FormControl;
}
// Should be able to call these at any time and compute a submitable value
@@ -135,14 +129,15 @@ export class EffluxDatesComponent implements OnInit {
switch (this.browserPath) {
case BrowserPath.Safari:
case BrowserPath.Firefox:
return this.fallbackDeletionDate.value + 'T' + this.fallbackDeletionTime.value;
return this.fallbackDeletionDate.value + "T" + this.fallbackDeletionTime.value;
default:
return this.defaultDeletionDateTime.value;
}
default:
const now = new Date();
const miliseconds = now.setTime(now.getTime() +
(this.selectedDeletionDatePreset.value as number * 60 * 60 * 1000)) ;
const miliseconds = now.setTime(
now.getTime() + (this.selectedDeletionDatePreset.value as number) * 60 * 60 * 1000
);
return new Date(miliseconds).toString();
}
}
@@ -155,11 +150,13 @@ export class EffluxDatesComponent implements OnInit {
switch (this.browserPath) {
case BrowserPath.Safari:
case BrowserPath.Firefox:
if ((!this.fallbackExpirationDate.value || !this.fallbackExpirationTime.value) &&
this.editMode) {
if (
(!this.fallbackExpirationDate.value || !this.fallbackExpirationTime.value) &&
this.editMode
) {
return null;
}
return this.fallbackExpirationDate.value + 'T' + this.fallbackExpirationTime.value;
return this.fallbackExpirationDate.value + "T" + this.fallbackExpirationTime.value;
default:
if (!this.defaultExpirationDateTime.value) {
return null;
@@ -168,8 +165,9 @@ export class EffluxDatesComponent implements OnInit {
}
default:
const now = new Date();
const miliseconds = now.setTime(now.getTime() +
(this.selectedExpirationDatePreset.value as number * 60 * 60 * 1000));
const miliseconds = now.setTime(
now.getTime() + (this.selectedExpirationDatePreset.value as number) * 60 * 60 * 1000
);
return new Date(miliseconds).toString();
}
}
@@ -189,9 +187,11 @@ export class EffluxDatesComponent implements OnInit {
return nextWeek;
}
constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected datePipe: DatePipe) {
}
constructor(
protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService,
protected datePipe: DatePipe
) {}
ngOnInit(): void {
this.setInitialFormValues();
@@ -235,16 +235,23 @@ export class EffluxDatesComponent implements OnInit {
this.fallbackDeletionDate.setValue(this.initialDeletionDate.toISOString().slice(0, 10));
this.fallbackDeletionTime.setValue(this.initialDeletionDate.toTimeString().slice(0, 5));
if (this.initialExpirationDate != null) {
this.fallbackExpirationDate.setValue(this.initialExpirationDate.toISOString().slice(0, 10));
this.fallbackExpirationTime.setValue(this.initialExpirationDate.toTimeString().slice(0, 5));
this.fallbackExpirationDate.setValue(
this.initialExpirationDate.toISOString().slice(0, 10)
);
this.fallbackExpirationTime.setValue(
this.initialExpirationDate.toTimeString().slice(0, 5)
);
}
break;
case BrowserPath.Default:
if (this.initialExpirationDate) {
this.defaultExpirationDateTime.setValue(
this.datePipe.transform(new Date(this.initialExpirationDate), 'yyyy-MM-ddTHH:mm'));
this.datePipe.transform(new Date(this.initialExpirationDate), "yyyy-MM-ddTHH:mm")
);
}
this.defaultDeletionDateTime.setValue(this.datePipe.transform(new Date(this.initialDeletionDate), 'yyyy-MM-ddTHH:mm'));
this.defaultDeletionDateTime.setValue(
this.datePipe.transform(new Date(this.initialDeletionDate), "yyyy-MM-ddTHH:mm")
);
break;
}
} else {
@@ -254,7 +261,9 @@ export class EffluxDatesComponent implements OnInit {
switch (this.browserPath) {
case BrowserPath.Safari:
this.fallbackDeletionDate.setValue(this.nextWeek.toISOString().slice(0, 10));
this.fallbackDeletionTime.setValue(this.safariTimePresetOptions(DateField.DeletionDate)[1].twentyFourHour);
this.fallbackDeletionTime.setValue(
this.safariTimePresetOptions(DateField.DeletionDate)[1].twentyFourHour
);
break;
default:
break;
@@ -282,10 +291,10 @@ export class EffluxDatesComponent implements OnInit {
// add prepending 0s to single digit hours/minutes
if (h < 10) {
hour = '0' + hour;
hour = "0" + hour;
}
if (m < 10) {
minutes = '0' + minutes;
minutes = "0" + minutes;
}
// build time strings and push to relevant sort groups
@@ -324,14 +333,18 @@ export class EffluxDatesComponent implements OnInit {
// example: if the Send was created with a different client
if (field === DateField.ExpriationDate && this.initialExpirationDate != null && this.editMode) {
const previousValue: TimeOption = {
twelveHour: this.datePipe.transform(this.initialExpirationDate, 'hh:mm a'),
twentyFourHour: this.datePipe.transform(this.initialExpirationDate, 'HH:mm'),
twelveHour: this.datePipe.transform(this.initialExpirationDate, "hh:mm a"),
twentyFourHour: this.datePipe.transform(this.initialExpirationDate, "HH:mm"),
};
return [previousValue, { twelveHour: null, twentyFourHour: null }, ...validTimes];
} else if (field === DateField.DeletionDate && this.initialDeletionDate != null && this.editMode) {
} else if (
field === DateField.DeletionDate &&
this.initialDeletionDate != null &&
this.editMode
) {
const previousValue: TimeOption = {
twelveHour: this.datePipe.transform(this.initialDeletionDate, 'hh:mm a'),
twentyFourHour: this.datePipe.transform(this.initialDeletionDate, 'HH:mm'),
twelveHour: this.datePipe.transform(this.initialDeletionDate, "hh:mm a"),
twentyFourHour: this.datePipe.transform(this.initialDeletionDate, "HH:mm"),
};
return [previousValue, ...validTimes];
} else {

View File

@@ -1,27 +1,22 @@
import {
Directive,
Input,
OnInit,
} from '@angular/core';
import { Directive, Input, OnInit } from "@angular/core";
import {
AbstractControl,
ControlValueAccessor,
FormBuilder,
ValidationErrors,
Validator
} from '@angular/forms';
Validator,
} from "@angular/forms";
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PolicyService } from 'jslib-common/abstractions/policy.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PolicyService } from "jslib-common/abstractions/policy.service";
import { PolicyType } from 'jslib-common/enums/policyType';
import { Policy } from 'jslib-common/models/domain/policy';
import { PolicyType } from "jslib-common/enums/policyType";
import { Policy } from "jslib-common/models/domain/policy";
@Directive()
export class VaultTimeoutInputComponent implements ControlValueAccessor, Validator, OnInit {
get showCustom() {
return this.form.get('vaultTimeout').value === VaultTimeoutInputComponent.CUSTOM_VALUE;
return this.form.get("vaultTimeout").value === VaultTimeoutInputComponent.CUSTOM_VALUE;
}
static CUSTOM_VALUE = -100;
@@ -34,7 +29,7 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
}),
});
@Input() vaultTimeouts: { name: string; value: number; }[];
@Input() vaultTimeouts: { name: string; value: number }[];
vaultTimeoutPolicy: Policy;
vaultTimeoutPolicyHours: number;
vaultTimeoutPolicyMinutes: number;
@@ -42,8 +37,11 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
private onChange: (vaultTimeout: number) => void;
private validatorChange: () => void;
constructor(private fb: FormBuilder, private policyService: PolicyService, private i18nService: I18nService) {
}
constructor(
private fb: FormBuilder,
private policyService: PolicyService,
private i18nService: I18nService
) {}
async ngOnInit() {
if (await this.policyService.policyAppliesToUser(PolicyType.MaximumVaultTimeout)) {
@@ -53,7 +51,8 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
this.vaultTimeoutPolicyHours = Math.floor(this.vaultTimeoutPolicy.data.minutes / 60);
this.vaultTimeoutPolicyMinutes = this.vaultTimeoutPolicy.data.minutes % 60;
this.vaultTimeouts = this.vaultTimeouts.filter(t =>
this.vaultTimeouts = this.vaultTimeouts.filter(
(t) =>
t.value <= this.vaultTimeoutPolicy.data.minutes &&
(t.value > 0 || t.value === VaultTimeoutInputComponent.CUSTOM_VALUE) &&
t.value != null
@@ -61,12 +60,12 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
this.validatorChange();
}
this.form.valueChanges.subscribe(async value => {
this.form.valueChanges.subscribe(async (value) => {
this.onChange(this.getVaultTimeout(value));
});
// Assign the previous value to the custom fields
this.form.get('vaultTimeout').valueChanges.subscribe(value => {
this.form.get("vaultTimeout").valueChanges.subscribe((value) => {
if (value !== VaultTimeoutInputComponent.CUSTOM_VALUE) {
return;
}
@@ -82,7 +81,10 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
}
ngOnChanges() {
this.vaultTimeouts.push({ name: this.i18nService.t('custom'), value: VaultTimeoutInputComponent.CUSTOM_VALUE });
this.vaultTimeouts.push({
name: this.i18nService.t("custom"),
value: VaultTimeoutInputComponent.CUSTOM_VALUE,
});
}
getVaultTimeout(value: any) {
@@ -98,7 +100,7 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
return;
}
if (this.vaultTimeouts.every(p => p.value !== value)) {
if (this.vaultTimeouts.every((p) => p.value !== value)) {
this.form.setValue({
vaultTimeout: VaultTimeoutInputComponent.CUSTOM_VALUE,
custom: {
@@ -122,7 +124,7 @@ export class VaultTimeoutInputComponent implements ControlValueAccessor, Validat
registerOnTouched(onTouched: any): void {}
// tslint:disable-next-line
setDisabledState?(isDisabled: boolean): void { }
setDisabledState?(isDisabled: boolean): void {}
validate(control: AbstractControl): ValidationErrors {
if (this.vaultTimeoutPolicy && this.vaultTimeoutPolicy?.data?.minutes < control.value) {

View File

@@ -1,16 +1,11 @@
import {
Directive,
EventEmitter,
OnInit,
Output,
} from '@angular/core';
import { Router } from '@angular/router';
import { Directive, EventEmitter, OnInit, Output } from "@angular/core";
import { Router } from "@angular/router";
import { TwoFactorProviderType } from 'jslib-common/enums/twoFactorProviderType';
import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType";
import { AuthService } from 'jslib-common/abstractions/auth.service';
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { AuthService } from "jslib-common/abstractions/auth.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
@Directive()
export class TwoFactorOptionsComponent implements OnInit {
@@ -19,9 +14,13 @@ export class TwoFactorOptionsComponent implements OnInit {
providers: any[] = [];
constructor(protected authService: AuthService, protected router: Router,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected win: Window) { }
constructor(
protected authService: AuthService,
protected router: Router,
protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService,
protected win: Window
) {}
ngOnInit() {
this.providers = this.authService.getSupportedTwoFactorProviders(this.win);
@@ -32,7 +31,7 @@ export class TwoFactorOptionsComponent implements OnInit {
}
recover() {
this.platformUtilsService.launchUri('https://help.bitwarden.com/article/lost-two-step-device/');
this.platformUtilsService.launchUri("https://help.bitwarden.com/article/lost-two-step-device/");
this.onRecoverSelected.emit();
}
}

View File

@@ -1,25 +1,46 @@
<ng-container *ngIf="!usesKeyConnector">
<label for="masterPassword">{{'masterPass' | i18n}}</label>
<input id="masterPassword" type="password" name="MasterPasswordHash" class="form-control"
[formControl]="secret" required appAutofocus appInputVerbatim>
<small class="form-text text-muted">{{'confirmIdentity' | i18n}}</small>
<label for="masterPassword">{{ "masterPass" | i18n }}</label>
<input
id="masterPassword"
type="password"
name="MasterPasswordHash"
class="form-control"
[formControl]="secret"
required
appAutofocus
appInputVerbatim
/>
<small class="form-text text-muted">{{ "confirmIdentity" | i18n }}</small>
</ng-container>
<ng-container *ngIf="usesKeyConnector">
<div class="form-group">
<label class="d-block">{{'sendVerificationCode' | i18n}}</label>
<button type="button" class="btn btn-outline-secondary" (click)="requestOTP()" [disabled]="disableRequestOTP">
{{'sendCode' | i18n}}
<label class="d-block">{{ "sendVerificationCode" | i18n }}</label>
<button
type="button"
class="btn btn-outline-secondary"
(click)="requestOTP()"
[disabled]="disableRequestOTP"
>
{{ "sendCode" | i18n }}
</button>
<span class="ml-2 text-success" role="alert" @sent *ngIf="sentCode">
<i class="fa fa-check-circle-o" aria-hidden="true"></i>
{{'codeSent' | i18n}}
{{ "codeSent" | i18n }}
</span>
</div>
<div class="form-group">
<label for="verificationCode">{{'verificationCode' | i18n}}</label>
<input id="verificationCode" type="input" name="verificationCode" class="form-control"
[formControl]="secret" required appAutofocus appInputVerbatim>
<small class="form-text text-muted">{{'confirmIdentity' | i18n}}</small>
<label for="verificationCode">{{ "verificationCode" | i18n }}</label>
<input
id="verificationCode"
type="input"
name="verificationCode"
class="form-control"
[formControl]="secret"
required
appAutofocus
appInputVerbatim
/>
<small class="form-text text-muted">{{ "confirmIdentity" | i18n }}</small>
</div>
</ng-container>

View File

@@ -1,29 +1,17 @@
import {
animate,
style,
transition,
trigger,
} from '@angular/animations';
import {
Component,
OnInit,
} from '@angular/core';
import {
ControlValueAccessor,
FormControl,
NG_VALUE_ACCESSOR,
} from '@angular/forms';
import { animate, style, transition, trigger } from "@angular/animations";
import { Component, OnInit } from "@angular/core";
import { ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR } from "@angular/forms";
import { KeyConnectorService } from 'jslib-common/abstractions/keyConnector.service';
import { UserVerificationService } from 'jslib-common/abstractions/userVerification.service';
import { KeyConnectorService } from "jslib-common/abstractions/keyConnector.service";
import { UserVerificationService } from "jslib-common/abstractions/userVerification.service";
import { VerificationType } from 'jslib-common/enums/verificationType';
import { VerificationType } from "jslib-common/enums/verificationType";
import { Verification } from 'jslib-common/types/verification';
import { Verification } from "jslib-common/types/verification";
@Component({
selector: 'app-verify-master-password',
templateUrl: 'verify-master-password.component.html',
selector: "app-verify-master-password",
templateUrl: "verify-master-password.component.html",
providers: [
{
provide: NG_VALUE_ACCESSOR,
@@ -32,11 +20,8 @@ import { Verification } from 'jslib-common/types/verification';
},
],
animations: [
trigger('sent', [
transition(':enter', [
style({ opacity: 0 }),
animate('100ms', style({ opacity: 1 })),
]),
trigger("sent", [
transition(":enter", [style({ opacity: 0 }), animate("100ms", style({ opacity: 1 }))]),
]),
],
})
@@ -45,18 +30,20 @@ export class VerifyMasterPasswordComponent implements ControlValueAccessor, OnIn
disableRequestOTP: boolean = false;
sentCode: boolean = false;
secret = new FormControl('');
secret = new FormControl("");
private onChange: (value: Verification) => void;
constructor(private keyConnectorService: KeyConnectorService,
private userVerificationService: UserVerificationService) { }
constructor(
private keyConnectorService: KeyConnectorService,
private userVerificationService: UserVerificationService
) {}
async ngOnInit() {
this.usesKeyConnector = await this.keyConnectorService.getUsesKeyConnector();
this.processChanges(this.secret.value);
this.secret.valueChanges.subscribe(secret => this.processChanges(secret));
this.secret.valueChanges.subscribe((secret) => this.processChanges(secret));
}
async requestOTP() {

View File

@@ -1,15 +1,12 @@
import {
Directive,
Input,
} from '@angular/core';
import { Directive, Input } from "@angular/core";
import { EventType } from 'jslib-common/enums/eventType';
import { FieldType } from 'jslib-common/enums/fieldType';
import { EventType } from "jslib-common/enums/eventType";
import { FieldType } from "jslib-common/enums/fieldType";
import { EventService } from 'jslib-common/abstractions/event.service';
import { EventService } from "jslib-common/abstractions/event.service";
import { CipherView } from 'jslib-common/models/view/cipherView';
import { FieldView } from 'jslib-common/models/view/fieldView';
import { CipherView } from "jslib-common/models/view/cipherView";
import { FieldView } from "jslib-common/models/view/fieldView";
@Directive()
export class ViewCustomFieldsComponent {
@@ -19,14 +16,14 @@ export class ViewCustomFieldsComponent {
fieldType = FieldType;
constructor(private eventService: EventService) { }
constructor(private eventService: EventService) {}
async toggleFieldValue(field: FieldView) {
if (!await this.promptPassword()) {
if (!(await this.promptPassword())) {
return;
}
const f = (field as any);
const f = field as any;
f.showValue = !f.showValue;
if (f.showValue) {
this.eventService.collect(EventType.Cipher_ClientToggledHiddenFieldVisible, this.cipher.id);

View File

@@ -1,12 +1,7 @@
import {
Directive,
ElementRef,
Input,
Renderer2,
} from '@angular/core';
import { Directive, ElementRef, Input, Renderer2 } from "@angular/core";
@Directive({
selector: '[appA11yTitle]',
selector: "[appA11yTitle]",
})
export class A11yTitleDirective {
@Input() set appA11yTitle(title: string) {
@@ -15,14 +10,14 @@ export class A11yTitleDirective {
private title: string;
constructor(private el: ElementRef, private renderer: Renderer2) { }
constructor(private el: ElementRef, private renderer: Renderer2) {}
ngOnInit() {
if (!this.el.nativeElement.hasAttribute('title')) {
this.renderer.setAttribute(this.el.nativeElement, 'title', this.title);
if (!this.el.nativeElement.hasAttribute("title")) {
this.renderer.setAttribute(this.el.nativeElement, "title", this.title);
}
if (!this.el.nativeElement.hasAttribute('aria-label')) {
this.renderer.setAttribute(this.el.nativeElement, 'aria-label', this.title);
if (!this.el.nativeElement.hasAttribute("aria-label")) {
this.renderer.setAttribute(this.el.nativeElement, "aria-label", this.title);
}
}
}

View File

@@ -1,23 +1,21 @@
import {
Directive,
ElementRef,
Input,
OnChanges,
} from '@angular/core';
import { LogService } from 'jslib-common/abstractions/log.service';
import { Directive, ElementRef, Input, OnChanges } from "@angular/core";
import { LogService } from "jslib-common/abstractions/log.service";
import { ErrorResponse } from 'jslib-common/models/response/errorResponse';
import { ErrorResponse } from "jslib-common/models/response/errorResponse";
import { ValidationService } from '../services/validation.service';
import { ValidationService } from "../services/validation.service";
@Directive({
selector: '[appApiAction]',
selector: "[appApiAction]",
})
export class ApiActionDirective implements OnChanges {
@Input() appApiAction: Promise<any>;
constructor(private el: ElementRef, private validationService: ValidationService,
private logService: LogService) { }
constructor(
private el: ElementRef,
private validationService: ValidationService,
private logService: LogService
) {}
ngOnChanges(changes: any) {
if (this.appApiAction == null || this.appApiAction.then == null) {
@@ -26,17 +24,23 @@ export class ApiActionDirective implements OnChanges {
this.el.nativeElement.loading = true;
this.appApiAction.then((response: any) => {
this.appApiAction.then(
(response: any) => {
this.el.nativeElement.loading = false;
}, (e: any) => {
},
(e: any) => {
this.el.nativeElement.loading = false;
if ((e instanceof ErrorResponse || e.constructor.name === 'ErrorResponse') && (e as ErrorResponse).captchaRequired) {
this.logService.error('Captcha required error response: ' + e.getSingleMessage());
if (
(e instanceof ErrorResponse || e.constructor.name === "ErrorResponse") &&
(e as ErrorResponse).captchaRequired
) {
this.logService.error("Captcha required error response: " + e.getSingleMessage());
return;
}
this.logService?.error(`Received API exception: ${e}`);
this.validationService.showError(e);
});
}
);
}
}

View File

@@ -1,25 +1,20 @@
import {
Directive,
ElementRef,
Input,
NgZone,
} from '@angular/core';
import { Directive, ElementRef, Input, NgZone } from "@angular/core";
import { take } from 'rxjs/operators';
import { take } from "rxjs/operators";
import { Utils } from 'jslib-common/misc/utils';
import { Utils } from "jslib-common/misc/utils";
@Directive({
selector: '[appAutofocus]',
selector: "[appAutofocus]",
})
export class AutofocusDirective {
@Input() set appAutofocus(condition: boolean | string) {
this.autofocus = condition === '' || condition === true;
this.autofocus = condition === "" || condition === true;
}
private autofocus: boolean;
constructor(private el: ElementRef, private ngZone: NgZone) { }
constructor(private el: ElementRef, private ngZone: NgZone) {}
ngOnInit() {
if (!Utils.isMobileBrowser && this.autofocus) {

View File

@@ -1,17 +1,12 @@
import {
Directive,
ElementRef,
HostListener,
} from '@angular/core';
import { Directive, ElementRef, HostListener } from "@angular/core";
@Directive({
selector: '[appBlurClick]',
selector: "[appBlurClick]",
})
export class BlurClickDirective {
constructor(private el: ElementRef) {
}
constructor(private el: ElementRef) {}
@HostListener('click') onClick() {
@HostListener("click") onClick() {
this.el.nativeElement.blur();
}
}

View File

@@ -1,12 +1,7 @@
import {
Directive,
ElementRef,
HostListener,
OnInit,
} from '@angular/core';
import { Directive, ElementRef, HostListener, OnInit } from "@angular/core";
@Directive({
selector: '[appBoxRow]',
selector: "[appBoxRow]",
})
export class BoxRowDirective implements OnInit {
el: HTMLElement = null;
@@ -17,30 +12,43 @@ export class BoxRowDirective implements OnInit {
}
ngOnInit(): void {
this.formEls = Array.from(this.el.querySelectorAll('input:not([type="hidden"]), select, textarea'));
this.formEls.forEach(formEl => {
formEl.addEventListener('focus', (event: Event) => {
this.el.classList.add('active');
}, false);
this.formEls = Array.from(
this.el.querySelectorAll('input:not([type="hidden"]), select, textarea')
);
this.formEls.forEach((formEl) => {
formEl.addEventListener(
"focus",
(event: Event) => {
this.el.classList.add("active");
},
false
);
formEl.addEventListener('blur', (event: Event) => {
this.el.classList.remove('active');
}, false);
formEl.addEventListener(
"blur",
(event: Event) => {
this.el.classList.remove("active");
},
false
);
});
}
@HostListener('click', ['$event']) onClick(event: Event) {
@HostListener("click", ["$event"]) onClick(event: Event) {
const target = event.target as HTMLElement;
if (target !== this.el && !target.classList.contains('progress') &&
!target.classList.contains('progress-bar')) {
if (
target !== this.el &&
!target.classList.contains("progress") &&
!target.classList.contains("progress-bar")
) {
return;
}
if (this.formEls.length > 0) {
const formEl = (this.formEls[0] as HTMLElement);
if (formEl.tagName.toLowerCase() === 'input') {
const inputEl = (formEl as HTMLInputElement);
if (inputEl.type != null && inputEl.type.toLowerCase() === 'checkbox') {
const formEl = this.formEls[0] as HTMLElement;
if (formEl.tagName.toLowerCase() === "input") {
const inputEl = formEl as HTMLInputElement;
if (inputEl.type != null && inputEl.type.toLowerCase() === "checkbox") {
inputEl.click();
return;
}

View File

@@ -2,11 +2,8 @@ import {
CdkFixedSizeVirtualScroll,
FixedSizeVirtualScrollStrategy,
VIRTUAL_SCROLL_STRATEGY,
} from '@angular/cdk/scrolling';
import {
Directive,
forwardRef,
} from '@angular/core';
} from "@angular/cdk/scrolling";
import { Directive, forwardRef } from "@angular/core";
// Custom virtual scroll strategy for cdk-virtual-scroll
// Uses a sample list item to set the itemSize for FixedSizeVirtualScrollStrategy
@@ -15,7 +12,12 @@ export class CipherListVirtualScrollStrategy extends FixedSizeVirtualScrollStrat
private checkItemSizeCallback: any;
private timeout: any;
constructor(itemSize: number, minBufferPx: number, maxBufferPx: number, checkItemSizeCallback: any) {
constructor(
itemSize: number,
minBufferPx: number,
maxBufferPx: number,
checkItemSizeCallback: any
) {
super(itemSize, minBufferPx, maxBufferPx);
this.checkItemSizeCallback = checkItemSizeCallback;
}
@@ -34,29 +36,41 @@ export function _cipherListVirtualScrollStrategyFactory(cipherListDir: CipherLis
}
@Directive({
selector: 'cdk-virtual-scroll-viewport[itemSize]',
providers: [{
selector: "cdk-virtual-scroll-viewport[itemSize]",
providers: [
{
provide: VIRTUAL_SCROLL_STRATEGY,
useFactory: _cipherListVirtualScrollStrategyFactory,
deps: [forwardRef(() => CipherListVirtualScroll)],
}],
},
],
})
export class CipherListVirtualScroll extends CdkFixedSizeVirtualScroll {
_scrollStrategy: CipherListVirtualScrollStrategy;
constructor() {
super();
this._scrollStrategy = new CipherListVirtualScrollStrategy(this.itemSize, this.minBufferPx, this.maxBufferPx,
this.checkAndUpdateItemSize);
this._scrollStrategy = new CipherListVirtualScrollStrategy(
this.itemSize,
this.minBufferPx,
this.maxBufferPx,
this.checkAndUpdateItemSize
);
}
checkAndUpdateItemSize = () => {
const sampleItem = document.querySelector('cdk-virtual-scroll-viewport .virtual-scroll-item') as HTMLElement;
const sampleItem = document.querySelector(
"cdk-virtual-scroll-viewport .virtual-scroll-item"
) as HTMLElement;
const newItemSize = sampleItem?.offsetHeight;
if (newItemSize != null && newItemSize !== this.itemSize) {
this.itemSize = newItemSize;
this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
}
this._scrollStrategy.updateItemAndBufferSize(
this.itemSize,
this.minBufferPx,
this.maxBufferPx
);
}
};
}

View File

@@ -1,20 +1,14 @@
import {
Directive,
ElementRef,
HostListener,
Input,
} from '@angular/core';
import { Directive, ElementRef, HostListener, Input } from "@angular/core";
@Directive({
selector: '[appFallbackSrc]',
selector: "[appFallbackSrc]",
})
export class FallbackSrcDirective {
@Input('appFallbackSrc') appFallbackSrc: string;
@Input("appFallbackSrc") appFallbackSrc: string;
constructor(private el: ElementRef) {
}
constructor(private el: ElementRef) {}
@HostListener('error') onError() {
@HostListener("error") onError() {
this.el.nativeElement.src = this.appFallbackSrc;
}
}

View File

@@ -1,37 +1,32 @@
import {
Directive,
ElementRef,
Input,
Renderer2,
} from '@angular/core';
import { Directive, ElementRef, Input, Renderer2 } from "@angular/core";
@Directive({
selector: '[appInputVerbatim]',
selector: "[appInputVerbatim]",
})
export class InputVerbatimDirective {
@Input() set appInputVerbatim(condition: boolean | string) {
this.disableComplete = condition === '' || condition === true;
this.disableComplete = condition === "" || condition === true;
}
private disableComplete: boolean;
constructor(private el: ElementRef, private renderer: Renderer2) { }
constructor(private el: ElementRef, private renderer: Renderer2) {}
ngOnInit() {
if (this.disableComplete && !this.el.nativeElement.hasAttribute('autocomplete')) {
this.renderer.setAttribute(this.el.nativeElement, 'autocomplete', 'off');
if (this.disableComplete && !this.el.nativeElement.hasAttribute("autocomplete")) {
this.renderer.setAttribute(this.el.nativeElement, "autocomplete", "off");
}
if (!this.el.nativeElement.hasAttribute('autocapitalize')) {
this.renderer.setAttribute(this.el.nativeElement, 'autocapitalize', 'none');
if (!this.el.nativeElement.hasAttribute("autocapitalize")) {
this.renderer.setAttribute(this.el.nativeElement, "autocapitalize", "none");
}
if (!this.el.nativeElement.hasAttribute('autocorrect')) {
this.renderer.setAttribute(this.el.nativeElement, 'autocorrect', 'none');
if (!this.el.nativeElement.hasAttribute("autocorrect")) {
this.renderer.setAttribute(this.el.nativeElement, "autocorrect", "none");
}
if (!this.el.nativeElement.hasAttribute('spellcheck')) {
this.renderer.setAttribute(this.el.nativeElement, 'spellcheck', 'false');
if (!this.el.nativeElement.hasAttribute("spellcheck")) {
this.renderer.setAttribute(this.el.nativeElement, "spellcheck", "false");
}
if (!this.el.nativeElement.hasAttribute('inputmode')) {
this.renderer.setAttribute(this.el.nativeElement, 'inputmode', 'verbatim');
if (!this.el.nativeElement.hasAttribute("inputmode")) {
this.renderer.setAttribute(this.el.nativeElement, "inputmode", "verbatim");
}
}
}

View File

@@ -1,22 +1,18 @@
import {
Directive,
ElementRef,
HostListener,
} from '@angular/core';
import { Directive, ElementRef, HostListener } from "@angular/core";
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
@Directive({
selector: '[appSelectCopy]',
selector: "[appSelectCopy]",
})
export class SelectCopyDirective {
constructor(private el: ElementRef, private platformUtilsService: PlatformUtilsService) { }
constructor(private el: ElementRef, private platformUtilsService: PlatformUtilsService) {}
@HostListener('copy') onCopy() {
@HostListener("copy") onCopy() {
if (window == null) {
return;
}
let copyText = '';
let copyText = "";
const selection = window.getSelection();
for (let i = 0; i < selection.rangeCount; i++) {
const range = selection.getRangeAt(i);
@@ -30,7 +26,7 @@ export class SelectCopyDirective {
const newLinePos = text.search(/(?:\r\n|\r|\n)/);
if (newLinePos > -1) {
const otherPart = text.substr(newLinePos).trim();
if (otherPart === '') {
if (otherPart === "") {
stringEndPos = newLinePos;
}
}

View File

@@ -1,13 +1,10 @@
import {
Directive,
HostListener,
} from '@angular/core';
import { Directive, HostListener } from "@angular/core";
@Directive({
selector: '[appStopClick]',
selector: "[appStopClick]",
})
export class StopClickDirective {
@HostListener('click', ['$event']) onClick($event: MouseEvent) {
@HostListener("click", ["$event"]) onClick($event: MouseEvent) {
$event.preventDefault();
}
}

View File

@@ -1,13 +1,10 @@
import {
Directive,
HostListener,
} from '@angular/core';
import { Directive, HostListener } from "@angular/core";
@Directive({
selector: '[appStopProp]',
selector: "[appStopProp]",
})
export class StopPropDirective {
@HostListener('click', ['$event']) onClick($event: MouseEvent) {
@HostListener("click", ["$event"]) onClick($event: MouseEvent) {
$event.stopPropagation();
}
}

View File

@@ -1,20 +1,9 @@
import {
Directive,
ElementRef,
forwardRef,
HostListener,
Input,
Renderer2,
} from '@angular/core';
import {
ControlValueAccessor,
NgControl,
NG_VALUE_ACCESSOR,
} from '@angular/forms';
import { Directive, ElementRef, forwardRef, HostListener, Input, Renderer2 } from "@angular/core";
import { ControlValueAccessor, NgControl, NG_VALUE_ACCESSOR } from "@angular/forms";
// ref: https://juristr.com/blog/2018/02/ng-true-value-directive/
@Directive({
selector: 'input[type=checkbox][appTrueFalseValue]',
selector: "input[type=checkbox][appTrueFalseValue]",
providers: [
{
provide: NG_VALUE_ACCESSOR,
@@ -27,18 +16,18 @@ export class TrueFalseValueDirective implements ControlValueAccessor {
@Input() trueValue = true;
@Input() falseValue = false;
constructor(private elementRef: ElementRef, private renderer: Renderer2) { }
constructor(private elementRef: ElementRef, private renderer: Renderer2) {}
@HostListener('change', ['$event'])
@HostListener("change", ["$event"])
onHostChange(ev: any) {
this.propagateChange(ev.target.checked ? this.trueValue : this.falseValue);
}
writeValue(obj: any): void {
if (obj === this.trueValue) {
this.renderer.setProperty(this.elementRef.nativeElement, 'checked', true);
this.renderer.setProperty(this.elementRef.nativeElement, "checked", true);
} else {
this.renderer.setProperty(this.elementRef.nativeElement, 'checked', false);
this.renderer.setProperty(this.elementRef.nativeElement, "checked", false);
}
}
@@ -46,9 +35,15 @@ export class TrueFalseValueDirective implements ControlValueAccessor {
this.propagateChange = fn;
}
registerOnTouched(fn: any): void { /* nothing */ }
registerOnTouched(fn: any): void {
/* nothing */
}
setDisabledState?(isDisabled: boolean): void { /* nothing */ }
setDisabledState?(isDisabled: boolean): void {
/* nothing */
}
private propagateChange = (_: any) => { /* nothing */ };
private propagateChange = (_: any) => {
/* nothing */
};
}

View File

@@ -1,52 +1,49 @@
import {
Pipe,
PipeTransform,
} from '@angular/core';
import { Utils } from 'jslib-common/misc/utils';
import { Pipe, PipeTransform } from "@angular/core";
import { Utils } from "jslib-common/misc/utils";
/*
An updated pipe that sanitizes HTML, highlights numbers and special characters (in different colors each)
and handles Unicode / Emoji characters correctly.
*/
@Pipe({ name: 'colorPassword' })
@Pipe({ name: "colorPassword" })
export class ColorPasswordPipe implements PipeTransform {
transform(password: string) {
// Convert to an array to handle cases that stings have special characters, ie: emoji.
const passwordArray = Array.from(password);
let colorizedPassword = '';
let colorizedPassword = "";
for (let i = 0; i < passwordArray.length; i++) {
let character = passwordArray[i];
let isSpecial = false;
// Sanitize HTML first.
switch (character) {
case '&':
character = '&amp;';
case "&":
character = "&amp;";
isSpecial = true;
break;
case '<':
character = '&lt;';
case "<":
character = "&lt;";
isSpecial = true;
break;
case '>':
character = '&gt;';
case ">":
character = "&gt;";
isSpecial = true;
break;
case ' ':
character = '&nbsp;';
case " ":
character = "&nbsp;";
isSpecial = true;
break;
default:
break;
}
let type = 'letter';
let type = "letter";
if (character.match(Utils.regexpEmojiPresentation)) {
type = 'emoji';
type = "emoji";
} else if (isSpecial || character.match(/[^\w ]/)) {
type = 'special';
type = "special";
} else if (character.match(/\d/)) {
type = 'number';
type = "number";
}
colorizedPassword += '<span class="password-' + type + '">' + character + '</span>';
colorizedPassword += '<span class="password-' + type + '">' + character + "</span>";
}
return colorizedPassword;
}

View File

@@ -1,15 +1,12 @@
import {
Pipe,
PipeTransform,
} from '@angular/core';
import { Pipe, PipeTransform } from "@angular/core";
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
@Pipe({
name: 'i18n',
name: "i18n",
})
export class I18nPipe implements PipeTransform {
constructor(private i18nService: I18nService) { }
constructor(private i18nService: I18nService) {}
transform(id: string, p1?: string, p2?: string, p3?: string): string {
return this.i18nService.t(id, p1, p2, p3);

View File

@@ -1,12 +1,9 @@
import {
Pipe,
PipeTransform,
} from '@angular/core';
import { Pipe, PipeTransform } from "@angular/core";
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CipherView } from "jslib-common/models/view/cipherView";
@Pipe({
name: 'searchCiphers',
name: "searchCiphers",
})
export class SearchCiphersPipe implements PipeTransform {
transform(ciphers: CipherView[], searchText: string, deleted: boolean = false): CipherView[] {
@@ -15,13 +12,13 @@ export class SearchCiphersPipe implements PipeTransform {
}
if (searchText == null || searchText.length < 2) {
return ciphers.filter(c => {
return ciphers.filter((c) => {
return deleted !== c.isDeleted;
});
}
searchText = searchText.trim().toLowerCase();
return ciphers.filter(c => {
return ciphers.filter((c) => {
if (deleted !== c.isDeleted) {
return false;
}

View File

@@ -1,13 +1,16 @@
import {
Pipe,
PipeTransform,
} from '@angular/core';
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({
name: 'search',
name: "search",
})
export class SearchPipe implements PipeTransform {
transform(items: any[], searchText: string, prop1?: string, prop2?: string, prop3?: string): any[] {
transform(
items: any[],
searchText: string,
prop1?: string,
prop2?: string,
prop3?: string
): any[] {
if (items == null || items.length === 0) {
return [];
}
@@ -17,14 +20,26 @@ export class SearchPipe implements PipeTransform {
}
searchText = searchText.trim().toLowerCase();
return items.filter(i => {
if (prop1 != null && i[prop1] != null && i[prop1].toString().toLowerCase().indexOf(searchText) > -1) {
return items.filter((i) => {
if (
prop1 != null &&
i[prop1] != null &&
i[prop1].toString().toLowerCase().indexOf(searchText) > -1
) {
return true;
}
if (prop2 != null && i[prop2] != null && i[prop2].toString().toLowerCase().indexOf(searchText) > -1) {
if (
prop2 != null &&
i[prop2] != null &&
i[prop2].toString().toLowerCase().indexOf(searchText) > -1
) {
return true;
}
if (prop3 != null && i[prop3] != null && i[prop3].toString().toLowerCase().indexOf(searchText) > -1) {
if (
prop3 != null &&
i[prop3] != null &&
i[prop3].toString().toLowerCase().indexOf(searchText) > -1
) {
return true;
}
return false;

View File

@@ -1,7 +1,4 @@
import {
Pipe,
PipeTransform,
} from '@angular/core';
import { Pipe, PipeTransform } from "@angular/core";
interface User {
name?: string;
@@ -9,7 +6,7 @@ interface User {
}
@Pipe({
name: 'userName',
name: "userName",
})
export class UserNamePipe implements PipeTransform {
transform(user?: User): string {
@@ -17,6 +14,6 @@ export class UserNamePipe implements PipeTransform {
return null;
}
return user.name == null || user.name.trim() === '' ? user.email : user.name;
return user.name == null || user.name.trim() === "" ? user.email : user.name;
}
}

View File

@@ -1,90 +1,89 @@
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: italic;
font-weight: 300;
font-display: auto;
src: url(webfonts/Open_Sans-italic-300.woff) format('woff');
src: url(webfonts/Open_Sans-italic-300.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: italic;
font-weight: 400;
font-display: auto;
src: url(webfonts/Open_Sans-italic-400.woff) format('woff');
src: url(webfonts/Open_Sans-italic-400.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: italic;
font-weight: 600;
font-display: auto;
src: url(webfonts/Open_Sans-italic-600.woff) format('woff');
src: url(webfonts/Open_Sans-italic-600.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: italic;
font-weight: 700;
font-display: auto;
src: url(webfonts/Open_Sans-italic-700.woff) format('woff');
src: url(webfonts/Open_Sans-italic-700.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: italic;
font-weight: 800;
font-display: auto;
src: url(webfonts/Open_Sans-italic-800.woff) format('woff');
src: url(webfonts/Open_Sans-italic-800.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: normal;
font-weight: 300;
font-display: auto;
src: url(webfonts/Open_Sans-normal-300.woff) format('woff');
src: url(webfonts/Open_Sans-normal-300.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: normal;
font-weight: 400;
font-display: auto;
src: url(webfonts/Open_Sans-normal-400.woff) format('woff');
src: url(webfonts/Open_Sans-normal-400.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: normal;
font-weight: 600;
font-display: auto;
src: url(webfonts/Open_Sans-normal-600.woff) format('woff');
src: url(webfonts/Open_Sans-normal-600.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: normal;
font-weight: 700;
font-display: auto;
src: url(webfonts/Open_Sans-normal-700.woff) format('woff');
src: url(webfonts/Open_Sans-normal-700.woff) format("woff");
unicode-range: U+0-10FFFF;
}
@font-face {
font-family: 'Open Sans';
font-family: "Open Sans";
font-style: normal;
font-weight: 800;
font-display: auto;
src: url(webfonts/Open_Sans-normal-800.woff) format('woff');
src: url(webfonts/Open_Sans-normal-800.woff) format("woff");
unicode-range: U+0-10FFFF;
}

View File

@@ -1,7 +1,6 @@
import { Injectable } from '@angular/core';
import { Injectable } from "@angular/core";
import { BroadcasterService as BaseBroadcasterService } from 'jslib-common/services/broadcaster.service';
import { BroadcasterService as BaseBroadcasterService } from "jslib-common/services/broadcaster.service";
@Injectable()
export class BroadcasterService extends BaseBroadcasterService {
}
export class BroadcasterService extends BaseBroadcasterService {}

View File

@@ -7,13 +7,13 @@ import {
Injectable,
Injector,
Type,
ViewContainerRef
} from '@angular/core';
import { first } from 'rxjs/operators';
ViewContainerRef,
} from "@angular/core";
import { first } from "rxjs/operators";
import { DynamicModalComponent } from '../components/modal/dynamic-modal.component';
import { ModalInjector } from '../components/modal/modal-injector';
import { ModalRef } from '../components/modal/modal.ref';
import { DynamicModalComponent } from "../components/modal/dynamic-modal.component";
import { ModalInjector } from "../components/modal/modal-injector";
import { ModalRef } from "../components/modal/modal.ref";
export class ModalConfig<D = any> {
data?: D;
@@ -28,10 +28,13 @@ export class ModalService {
// therefore modules needs to manually initialize their resolvers.
private factoryResolvers: Map<Type<any>, ComponentFactoryResolver> = new Map();
constructor(private componentFactoryResolver: ComponentFactoryResolver, private applicationRef: ApplicationRef,
private injector: Injector) {
document.addEventListener('keyup', event => {
if (event.key === 'Escape' && this.modalCount > 0) {
constructor(
private componentFactoryResolver: ComponentFactoryResolver,
private applicationRef: ApplicationRef,
private injector: Injector
) {
document.addEventListener("keyup", (event) => {
if (event.key === "Escape" && this.modalCount > 0) {
this.topModal.instance.close();
}
});
@@ -45,9 +48,11 @@ export class ModalService {
return this.modalList[this.modalCount - 1];
}
async openViewRef<T>(componentType: Type<T>, viewContainerRef: ViewContainerRef,
setComponentParameters: (component: T) => void = null): Promise<[ModalRef, T]> {
async openViewRef<T>(
componentType: Type<T>,
viewContainerRef: ViewContainerRef,
setComponentParameters: (component: T) => void = null
): Promise<[ModalRef, T]> {
const [modalRef, modalComponentRef] = this.openInternal(componentType, null, false);
modalComponentRef.instance.setComponentParameters = setComponentParameters;
@@ -68,7 +73,10 @@ export class ModalService {
return modalRef;
}
registerComponentFactoryResolver<T>(componentType: Type<T>, componentFactoryResolver: ComponentFactoryResolver): void {
registerComponentFactoryResolver<T>(
componentType: Type<T>,
componentFactoryResolver: ComponentFactoryResolver
): void {
this.factoryResolvers.set(componentType, componentFactoryResolver);
}
@@ -80,9 +88,11 @@ export class ModalService {
return this.componentFactoryResolver.resolveComponentFactory(componentType);
}
protected openInternal(componentType: Type<any>, config?: ModalConfig, attachToDom?: boolean):
[ModalRef, ComponentRef<DynamicModalComponent>] {
protected openInternal(
componentType: Type<any>,
config?: ModalConfig,
attachToDom?: boolean
): [ModalRef, ComponentRef<DynamicModalComponent>] {
const [modalRef, componentRef] = this.createModalComponent(config);
componentRef.instance.childComponentType = componentType;
@@ -115,25 +125,27 @@ export class ModalService {
let backdrop: HTMLElement = null;
// Add backdrop, setup [data-dismiss] handler.
modalRef.onCreated.pipe(first()).subscribe(el => {
document.body.classList.add('modal-open');
modalRef.onCreated.pipe(first()).subscribe((el) => {
document.body.classList.add("modal-open");
const modalEl: HTMLElement = el.querySelector('.modal');
const dialogEl = modalEl.querySelector('.modal-dialog') as HTMLElement;
const modalEl: HTMLElement = el.querySelector(".modal");
const dialogEl = modalEl.querySelector(".modal-dialog") as HTMLElement;
backdrop = document.createElement('div');
backdrop.className = 'modal-backdrop fade';
backdrop = document.createElement("div");
backdrop.className = "modal-backdrop fade";
backdrop.style.zIndex = `${this.modalCount}040`;
modalEl.prepend(backdrop);
dialogEl.addEventListener('click', (e: Event) => {
dialogEl.addEventListener("click", (e: Event) => {
e.stopPropagation();
});
dialogEl.style.zIndex = `${this.modalCount}050`;
const modals = Array.from(el.querySelectorAll('.modal-backdrop, .modal *[data-dismiss="modal"]'));
const modals = Array.from(
el.querySelectorAll('.modal-backdrop, .modal *[data-dismiss="modal"]')
);
for (const closeElement of modals) {
closeElement.addEventListener('click', event => {
closeElement.addEventListener("click", (event) => {
modalRef.close();
});
}
@@ -144,19 +156,22 @@ export class ModalService {
modalRef.closed();
if (this.modalCount === 0) {
document.body.classList.remove('modal-open');
document.body.classList.remove("modal-open");
}
});
}
protected createModalComponent(config: ModalConfig): [ModalRef, ComponentRef<DynamicModalComponent>] {
protected createModalComponent(
config: ModalConfig
): [ModalRef, ComponentRef<DynamicModalComponent>] {
const modalRef = new ModalRef();
const map = new WeakMap();
map.set(ModalConfig, config);
map.set(ModalRef, modalRef);
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(DynamicModalComponent);
const componentFactory =
this.componentFactoryResolver.resolveComponentFactory(DynamicModalComponent);
const componentRef = componentFactory.create(new ModalInjector(this.injector, map));
return [modalRef, componentRef];

View File

@@ -1,27 +1,30 @@
import { Injectable } from '@angular/core';
import { Injectable } from "@angular/core";
import { KeyConnectorService } from 'jslib-common/abstractions/keyConnector.service';
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from 'jslib-common/abstractions/passwordReprompt.service';
import { KeyConnectorService } from "jslib-common/abstractions/keyConnector.service";
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "jslib-common/abstractions/passwordReprompt.service";
import { PasswordRepromptComponent } from '../components/password-reprompt.component';
import { ModalService } from './modal.service';
import { PasswordRepromptComponent } from "../components/password-reprompt.component";
import { ModalService } from "./modal.service";
@Injectable()
export class PasswordRepromptService implements PasswordRepromptServiceAbstraction {
protected component = PasswordRepromptComponent;
constructor(private modalService: ModalService, private keyConnectorService: KeyConnectorService) { }
constructor(
private modalService: ModalService,
private keyConnectorService: KeyConnectorService
) {}
protectedFields() {
return ['TOTP', 'Password', 'H_Field', 'Card Number', 'Security Code'];
return ["TOTP", "Password", "H_Field", "Card Number", "Security Code"];
}
async showPasswordPrompt() {
if (!await this.enabled()) {
if (!(await this.enabled())) {
return true;
}
const ref = this.modalService.open(this.component, {allowMultipleModals: true});
const ref = this.modalService.open(this.component, { allowMultipleModals: true });
if (ref == null) {
return false;
@@ -32,6 +35,6 @@ export class PasswordRepromptService implements PasswordRepromptServiceAbstracti
}
async enabled() {
return !await this.keyConnectorService.getUsesKeyConnector();
return !(await this.keyConnectorService.getUsesKeyConnector());
}
}

View File

@@ -1,21 +1,24 @@
import { Injectable } from '@angular/core';
import { Injectable } from "@angular/core";
import { I18nService } from 'jslib-common/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service';
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { ErrorResponse } from 'jslib-common/models/response/errorResponse';
import { ErrorResponse } from "jslib-common/models/response/errorResponse";
@Injectable()
export class ValidationService {
constructor(private i18nService: I18nService, private platformUtilsService: PlatformUtilsService) { }
constructor(
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService
) {}
showError(data: any): string[] {
const defaultErrorMessage = this.i18nService.t('unexpectedError');
const defaultErrorMessage = this.i18nService.t("unexpectedError");
let errors: string[] = [];
if (data != null && typeof data === 'string') {
if (data != null && typeof data === "string") {
errors.push(data);
} else if (data == null || typeof data !== 'object') {
} else if (data == null || typeof data !== "object") {
errors.push(defaultErrorMessage);
} else if (data.validationErrors != null) {
errors = errors.concat((data as ErrorResponse).getAllMessages());
@@ -24,9 +27,9 @@ export class ValidationService {
}
if (errors.length === 1) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), errors[0]);
this.platformUtilsService.showToast("error", this.i18nService.t("errorOccurred"), errors[0]);
} else if (errors.length > 1) {
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'), errors, {
this.platformUtilsService.showToast("error", this.i18nService.t("errorOccurred"), errors, {
timeout: 5000 * errors.length,
});
}

View File

@@ -14,17 +14,9 @@
"declarationDir": "dist/types",
"outDir": "dist",
"paths": {
"jslib-common/*": [
"../common/src/*"
]
"jslib-common/*": ["../common/src/*"]
}
},
"include": [
"src",
"spec"
],
"exclude": [
"node_modules",
"dist"
]
"include": ["src", "spec"],
"exclude": ["node_modules", "dist"]
}

View File

@@ -1,170 +1,178 @@
import { PolicyType } from '../enums/policyType';
import { SetKeyConnectorKeyRequest } from '../models/request/account/setKeyConnectorKeyRequest';
import { VerifyOTPRequest } from '../models/request/account/verifyOTPRequest';
import { PolicyType } from "../enums/policyType";
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
import { VerifyOTPRequest } from "../models/request/account/verifyOTPRequest";
import { AttachmentRequest } from '../models/request/attachmentRequest';
import { AttachmentRequest } from "../models/request/attachmentRequest";
import { BitPayInvoiceRequest } from '../models/request/bitPayInvoiceRequest';
import { CipherBulkDeleteRequest } from '../models/request/cipherBulkDeleteRequest';
import { CipherBulkMoveRequest } from '../models/request/cipherBulkMoveRequest';
import { CipherBulkRestoreRequest } from '../models/request/cipherBulkRestoreRequest';
import { CipherBulkShareRequest } from '../models/request/cipherBulkShareRequest';
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
import { CipherCreateRequest } from '../models/request/cipherCreateRequest';
import { CipherRequest } from '../models/request/cipherRequest';
import { CipherShareRequest } from '../models/request/cipherShareRequest';
import { CollectionRequest } from '../models/request/collectionRequest';
import { DeleteRecoverRequest } from '../models/request/deleteRecoverRequest';
import { EmailRequest } from '../models/request/emailRequest';
import { EmailTokenRequest } from '../models/request/emailTokenRequest';
import { EmergencyAccessAcceptRequest } from '../models/request/emergencyAccessAcceptRequest';
import { EmergencyAccessConfirmRequest } from '../models/request/emergencyAccessConfirmRequest';
import { EmergencyAccessInviteRequest } from '../models/request/emergencyAccessInviteRequest';
import { EmergencyAccessPasswordRequest } from '../models/request/emergencyAccessPasswordRequest';
import { EmergencyAccessUpdateRequest } from '../models/request/emergencyAccessUpdateRequest';
import { EventRequest } from '../models/request/eventRequest';
import { FolderRequest } from '../models/request/folderRequest';
import { GroupRequest } from '../models/request/groupRequest';
import { IapCheckRequest } from '../models/request/iapCheckRequest';
import { ImportCiphersRequest } from '../models/request/importCiphersRequest';
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
import { ImportOrganizationCiphersRequest } from '../models/request/importOrganizationCiphersRequest';
import { KdfRequest } from '../models/request/kdfRequest';
import { KeyConnectorUserKeyRequest } from '../models/request/keyConnectorUserKeyRequest';
import { KeysRequest } from '../models/request/keysRequest';
import { OrganizationSponsorshipCreateRequest } from '../models/request/organization/organizationSponsorshipCreateRequest';
import { OrganizationSponsorshipRedeemRequest } from '../models/request/organization/organizationSponsorshipRedeemRequest';
import { OrganizationSsoRequest } from '../models/request/organization/organizationSsoRequest';
import { OrganizationCreateRequest } from '../models/request/organizationCreateRequest';
import { OrganizationImportRequest } from '../models/request/organizationImportRequest';
import { OrganizationKeysRequest } from '../models/request/organizationKeysRequest';
import { OrganizationSubscriptionUpdateRequest } from '../models/request/organizationSubscriptionUpdateRequest';
import { OrganizationTaxInfoUpdateRequest } from '../models/request/organizationTaxInfoUpdateRequest';
import { OrganizationUpdateRequest } from '../models/request/organizationUpdateRequest';
import { OrganizationUpgradeRequest } from '../models/request/organizationUpgradeRequest';
import { OrganizationUserAcceptRequest } from '../models/request/organizationUserAcceptRequest';
import { OrganizationUserBulkConfirmRequest } from '../models/request/organizationUserBulkConfirmRequest';
import { OrganizationUserBulkRequest } from '../models/request/organizationUserBulkRequest';
import { OrganizationUserConfirmRequest } from '../models/request/organizationUserConfirmRequest';
import { OrganizationUserInviteRequest } from '../models/request/organizationUserInviteRequest';
import { OrganizationUserResetPasswordEnrollmentRequest } from '../models/request/organizationUserResetPasswordEnrollmentRequest';
import { OrganizationUserResetPasswordRequest } from '../models/request/organizationUserResetPasswordRequest';
import { OrganizationUserUpdateGroupsRequest } from '../models/request/organizationUserUpdateGroupsRequest';
import { OrganizationUserUpdateRequest } from '../models/request/organizationUserUpdateRequest';
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
import { PasswordRequest } from '../models/request/passwordRequest';
import { PaymentRequest } from '../models/request/paymentRequest';
import { PolicyRequest } from '../models/request/policyRequest';
import { PreloginRequest } from '../models/request/preloginRequest';
import { ProviderAddOrganizationRequest } from '../models/request/provider/providerAddOrganizationRequest';
import { ProviderOrganizationCreateRequest } from '../models/request/provider/providerOrganizationCreateRequest';
import { ProviderSetupRequest } from '../models/request/provider/providerSetupRequest';
import { ProviderUpdateRequest } from '../models/request/provider/providerUpdateRequest';
import { ProviderUserAcceptRequest } from '../models/request/provider/providerUserAcceptRequest';
import { ProviderUserBulkConfirmRequest } from '../models/request/provider/providerUserBulkConfirmRequest';
import { ProviderUserBulkRequest } from '../models/request/provider/providerUserBulkRequest';
import { ProviderUserConfirmRequest } from '../models/request/provider/providerUserConfirmRequest';
import { ProviderUserInviteRequest } from '../models/request/provider/providerUserInviteRequest';
import { ProviderUserUpdateRequest } from '../models/request/provider/providerUserUpdateRequest';
import { RegisterRequest } from '../models/request/registerRequest';
import { SeatRequest } from '../models/request/seatRequest';
import { SecretVerificationRequest } from '../models/request/secretVerificationRequest';
import { SelectionReadOnlyRequest } from '../models/request/selectionReadOnlyRequest';
import { SendAccessRequest } from '../models/request/sendAccessRequest';
import { SendRequest } from '../models/request/sendRequest';
import { SetPasswordRequest } from '../models/request/setPasswordRequest';
import { StorageRequest } from '../models/request/storageRequest';
import { TaxInfoUpdateRequest } from '../models/request/taxInfoUpdateRequest';
import { TokenRequest } from '../models/request/tokenRequest';
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
import { TwoFactorProviderRequest } from '../models/request/twoFactorProviderRequest';
import { TwoFactorRecoveryRequest } from '../models/request/twoFactorRecoveryRequest';
import { UpdateDomainsRequest } from '../models/request/updateDomainsRequest';
import { UpdateKeyRequest } from '../models/request/updateKeyRequest';
import { UpdateProfileRequest } from '../models/request/updateProfileRequest';
import { UpdateTempPasswordRequest } from '../models/request/updateTempPasswordRequest';
import { UpdateTwoFactorAuthenticatorRequest } from '../models/request/updateTwoFactorAuthenticatorRequest';
import { UpdateTwoFactorDuoRequest } from '../models/request/updateTwoFactorDuoRequest';
import { UpdateTwoFactorEmailRequest } from '../models/request/updateTwoFactorEmailRequest';
import { UpdateTwoFactorWebAuthnDeleteRequest } from '../models/request/updateTwoFactorWebAuthnDeleteRequest';
import { UpdateTwoFactorWebAuthnRequest } from '../models/request/updateTwoFactorWebAuthnRequest';
import { UpdateTwoFactorYubioOtpRequest } from '../models/request/updateTwoFactorYubioOtpRequest';
import { VerifyBankRequest } from '../models/request/verifyBankRequest';
import { VerifyDeleteRecoverRequest } from '../models/request/verifyDeleteRecoverRequest';
import { VerifyEmailRequest } from '../models/request/verifyEmailRequest';
import { BitPayInvoiceRequest } from "../models/request/bitPayInvoiceRequest";
import { CipherBulkDeleteRequest } from "../models/request/cipherBulkDeleteRequest";
import { CipherBulkMoveRequest } from "../models/request/cipherBulkMoveRequest";
import { CipherBulkRestoreRequest } from "../models/request/cipherBulkRestoreRequest";
import { CipherBulkShareRequest } from "../models/request/cipherBulkShareRequest";
import { CipherCollectionsRequest } from "../models/request/cipherCollectionsRequest";
import { CipherCreateRequest } from "../models/request/cipherCreateRequest";
import { CipherRequest } from "../models/request/cipherRequest";
import { CipherShareRequest } from "../models/request/cipherShareRequest";
import { CollectionRequest } from "../models/request/collectionRequest";
import { DeleteRecoverRequest } from "../models/request/deleteRecoverRequest";
import { EmailRequest } from "../models/request/emailRequest";
import { EmailTokenRequest } from "../models/request/emailTokenRequest";
import { EmergencyAccessAcceptRequest } from "../models/request/emergencyAccessAcceptRequest";
import { EmergencyAccessConfirmRequest } from "../models/request/emergencyAccessConfirmRequest";
import { EmergencyAccessInviteRequest } from "../models/request/emergencyAccessInviteRequest";
import { EmergencyAccessPasswordRequest } from "../models/request/emergencyAccessPasswordRequest";
import { EmergencyAccessUpdateRequest } from "../models/request/emergencyAccessUpdateRequest";
import { EventRequest } from "../models/request/eventRequest";
import { FolderRequest } from "../models/request/folderRequest";
import { GroupRequest } from "../models/request/groupRequest";
import { IapCheckRequest } from "../models/request/iapCheckRequest";
import { ImportCiphersRequest } from "../models/request/importCiphersRequest";
import { ImportDirectoryRequest } from "../models/request/importDirectoryRequest";
import { ImportOrganizationCiphersRequest } from "../models/request/importOrganizationCiphersRequest";
import { KdfRequest } from "../models/request/kdfRequest";
import { KeyConnectorUserKeyRequest } from "../models/request/keyConnectorUserKeyRequest";
import { KeysRequest } from "../models/request/keysRequest";
import { OrganizationSponsorshipCreateRequest } from "../models/request/organization/organizationSponsorshipCreateRequest";
import { OrganizationSponsorshipRedeemRequest } from "../models/request/organization/organizationSponsorshipRedeemRequest";
import { OrganizationSsoRequest } from "../models/request/organization/organizationSsoRequest";
import { OrganizationCreateRequest } from "../models/request/organizationCreateRequest";
import { OrganizationImportRequest } from "../models/request/organizationImportRequest";
import { OrganizationKeysRequest } from "../models/request/organizationKeysRequest";
import { OrganizationSubscriptionUpdateRequest } from "../models/request/organizationSubscriptionUpdateRequest";
import { OrganizationTaxInfoUpdateRequest } from "../models/request/organizationTaxInfoUpdateRequest";
import { OrganizationUpdateRequest } from "../models/request/organizationUpdateRequest";
import { OrganizationUpgradeRequest } from "../models/request/organizationUpgradeRequest";
import { OrganizationUserAcceptRequest } from "../models/request/organizationUserAcceptRequest";
import { OrganizationUserBulkConfirmRequest } from "../models/request/organizationUserBulkConfirmRequest";
import { OrganizationUserBulkRequest } from "../models/request/organizationUserBulkRequest";
import { OrganizationUserConfirmRequest } from "../models/request/organizationUserConfirmRequest";
import { OrganizationUserInviteRequest } from "../models/request/organizationUserInviteRequest";
import { OrganizationUserResetPasswordEnrollmentRequest } from "../models/request/organizationUserResetPasswordEnrollmentRequest";
import { OrganizationUserResetPasswordRequest } from "../models/request/organizationUserResetPasswordRequest";
import { OrganizationUserUpdateGroupsRequest } from "../models/request/organizationUserUpdateGroupsRequest";
import { OrganizationUserUpdateRequest } from "../models/request/organizationUserUpdateRequest";
import { PasswordHintRequest } from "../models/request/passwordHintRequest";
import { PasswordRequest } from "../models/request/passwordRequest";
import { PaymentRequest } from "../models/request/paymentRequest";
import { PolicyRequest } from "../models/request/policyRequest";
import { PreloginRequest } from "../models/request/preloginRequest";
import { ProviderAddOrganizationRequest } from "../models/request/provider/providerAddOrganizationRequest";
import { ProviderOrganizationCreateRequest } from "../models/request/provider/providerOrganizationCreateRequest";
import { ProviderSetupRequest } from "../models/request/provider/providerSetupRequest";
import { ProviderUpdateRequest } from "../models/request/provider/providerUpdateRequest";
import { ProviderUserAcceptRequest } from "../models/request/provider/providerUserAcceptRequest";
import { ProviderUserBulkConfirmRequest } from "../models/request/provider/providerUserBulkConfirmRequest";
import { ProviderUserBulkRequest } from "../models/request/provider/providerUserBulkRequest";
import { ProviderUserConfirmRequest } from "../models/request/provider/providerUserConfirmRequest";
import { ProviderUserInviteRequest } from "../models/request/provider/providerUserInviteRequest";
import { ProviderUserUpdateRequest } from "../models/request/provider/providerUserUpdateRequest";
import { RegisterRequest } from "../models/request/registerRequest";
import { SeatRequest } from "../models/request/seatRequest";
import { SecretVerificationRequest } from "../models/request/secretVerificationRequest";
import { SelectionReadOnlyRequest } from "../models/request/selectionReadOnlyRequest";
import { SendAccessRequest } from "../models/request/sendAccessRequest";
import { SendRequest } from "../models/request/sendRequest";
import { SetPasswordRequest } from "../models/request/setPasswordRequest";
import { StorageRequest } from "../models/request/storageRequest";
import { TaxInfoUpdateRequest } from "../models/request/taxInfoUpdateRequest";
import { TokenRequest } from "../models/request/tokenRequest";
import { TwoFactorEmailRequest } from "../models/request/twoFactorEmailRequest";
import { TwoFactorProviderRequest } from "../models/request/twoFactorProviderRequest";
import { TwoFactorRecoveryRequest } from "../models/request/twoFactorRecoveryRequest";
import { UpdateDomainsRequest } from "../models/request/updateDomainsRequest";
import { UpdateKeyRequest } from "../models/request/updateKeyRequest";
import { UpdateProfileRequest } from "../models/request/updateProfileRequest";
import { UpdateTempPasswordRequest } from "../models/request/updateTempPasswordRequest";
import { UpdateTwoFactorAuthenticatorRequest } from "../models/request/updateTwoFactorAuthenticatorRequest";
import { UpdateTwoFactorDuoRequest } from "../models/request/updateTwoFactorDuoRequest";
import { UpdateTwoFactorEmailRequest } from "../models/request/updateTwoFactorEmailRequest";
import { UpdateTwoFactorWebAuthnDeleteRequest } from "../models/request/updateTwoFactorWebAuthnDeleteRequest";
import { UpdateTwoFactorWebAuthnRequest } from "../models/request/updateTwoFactorWebAuthnRequest";
import { UpdateTwoFactorYubioOtpRequest } from "../models/request/updateTwoFactorYubioOtpRequest";
import { VerifyBankRequest } from "../models/request/verifyBankRequest";
import { VerifyDeleteRecoverRequest } from "../models/request/verifyDeleteRecoverRequest";
import { VerifyEmailRequest } from "../models/request/verifyEmailRequest";
import { ApiKeyResponse } from '../models/response/apiKeyResponse';
import { AttachmentResponse } from '../models/response/attachmentResponse';
import { AttachmentUploadDataResponse } from '../models/response/attachmentUploadDataResponse';
import { BillingResponse } from '../models/response/billingResponse';
import { BreachAccountResponse } from '../models/response/breachAccountResponse';
import { CipherResponse } from '../models/response/cipherResponse';
import { ApiKeyResponse } from "../models/response/apiKeyResponse";
import { AttachmentResponse } from "../models/response/attachmentResponse";
import { AttachmentUploadDataResponse } from "../models/response/attachmentUploadDataResponse";
import { BillingResponse } from "../models/response/billingResponse";
import { BreachAccountResponse } from "../models/response/breachAccountResponse";
import { CipherResponse } from "../models/response/cipherResponse";
import {
CollectionGroupDetailsResponse,
CollectionResponse,
} from '../models/response/collectionResponse';
import { DomainsResponse } from '../models/response/domainsResponse';
} from "../models/response/collectionResponse";
import { DomainsResponse } from "../models/response/domainsResponse";
import {
EmergencyAccessGranteeDetailsResponse,
EmergencyAccessGrantorDetailsResponse,
EmergencyAccessTakeoverResponse,
EmergencyAccessViewResponse
} from '../models/response/emergencyAccessResponse';
import { EventResponse } from '../models/response/eventResponse';
import { FolderResponse } from '../models/response/folderResponse';
import {
GroupDetailsResponse,
GroupResponse,
} from '../models/response/groupResponse';
import { IdentityCaptchaResponse } from '../models/response/identityCaptchaResponse';
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
import { KeyConnectorUserKeyResponse } from '../models/response/keyConnectorUserKeyResponse';
import { ListResponse } from '../models/response/listResponse';
import { OrganizationSsoResponse } from '../models/response/organization/organizationSsoResponse';
import { OrganizationAutoEnrollStatusResponse } from '../models/response/organizationAutoEnrollStatusResponse';
import { OrganizationKeysResponse } from '../models/response/organizationKeysResponse';
import { OrganizationResponse } from '../models/response/organizationResponse';
import { OrganizationSubscriptionResponse } from '../models/response/organizationSubscriptionResponse';
import { OrganizationUserBulkPublicKeyResponse } from '../models/response/organizationUserBulkPublicKeyResponse';
import { OrganizationUserBulkResponse } from '../models/response/organizationUserBulkResponse';
EmergencyAccessViewResponse,
} from "../models/response/emergencyAccessResponse";
import { EventResponse } from "../models/response/eventResponse";
import { FolderResponse } from "../models/response/folderResponse";
import { GroupDetailsResponse, GroupResponse } from "../models/response/groupResponse";
import { IdentityCaptchaResponse } from "../models/response/identityCaptchaResponse";
import { IdentityTokenResponse } from "../models/response/identityTokenResponse";
import { IdentityTwoFactorResponse } from "../models/response/identityTwoFactorResponse";
import { KeyConnectorUserKeyResponse } from "../models/response/keyConnectorUserKeyResponse";
import { ListResponse } from "../models/response/listResponse";
import { OrganizationSsoResponse } from "../models/response/organization/organizationSsoResponse";
import { OrganizationAutoEnrollStatusResponse } from "../models/response/organizationAutoEnrollStatusResponse";
import { OrganizationKeysResponse } from "../models/response/organizationKeysResponse";
import { OrganizationResponse } from "../models/response/organizationResponse";
import { OrganizationSubscriptionResponse } from "../models/response/organizationSubscriptionResponse";
import { OrganizationUserBulkPublicKeyResponse } from "../models/response/organizationUserBulkPublicKeyResponse";
import { OrganizationUserBulkResponse } from "../models/response/organizationUserBulkResponse";
import {
OrganizationUserDetailsResponse,
OrganizationUserResetPasswordDetailsReponse,
OrganizationUserUserDetailsResponse,
} from '../models/response/organizationUserResponse';
import { PaymentResponse } from '../models/response/paymentResponse';
import { PlanResponse } from '../models/response/planResponse';
import { PolicyResponse } from '../models/response/policyResponse';
import { PreloginResponse } from '../models/response/preloginResponse';
import { ProfileResponse } from '../models/response/profileResponse';
import { ProviderOrganizationOrganizationDetailsResponse, ProviderOrganizationResponse } from '../models/response/provider/providerOrganizationResponse';
import { ProviderResponse } from '../models/response/provider/providerResponse';
import { ProviderUserBulkPublicKeyResponse } from '../models/response/provider/providerUserBulkPublicKeyResponse';
import { ProviderUserBulkResponse } from '../models/response/provider/providerUserBulkResponse';
import { ProviderUserResponse, ProviderUserUserDetailsResponse } from '../models/response/provider/providerUserResponse';
import { SelectionReadOnlyResponse } from '../models/response/selectionReadOnlyResponse';
import { SendAccessResponse } from '../models/response/sendAccessResponse';
import { SendFileDownloadDataResponse } from '../models/response/sendFileDownloadDataResponse';
import { SendFileUploadDataResponse } from '../models/response/sendFileUploadDataResponse';
import { SendResponse } from '../models/response/sendResponse';
import { SubscriptionResponse } from '../models/response/subscriptionResponse';
import { SyncResponse } from '../models/response/syncResponse';
import { TaxInfoResponse } from '../models/response/taxInfoResponse';
import { TaxRateResponse } from '../models/response/taxRateResponse';
import { TwoFactorAuthenticatorResponse } from '../models/response/twoFactorAuthenticatorResponse';
import { TwoFactorDuoResponse } from '../models/response/twoFactorDuoResponse';
import { TwoFactorEmailResponse } from '../models/response/twoFactorEmailResponse';
import { TwoFactorProviderResponse } from '../models/response/twoFactorProviderResponse';
import { TwoFactorRecoverResponse } from '../models/response/twoFactorRescoverResponse';
import { ChallengeResponse, TwoFactorWebAuthnResponse } from '../models/response/twoFactorWebAuthnResponse';
import { TwoFactorYubiKeyResponse } from '../models/response/twoFactorYubiKeyResponse';
import { UserKeyResponse } from '../models/response/userKeyResponse';
} from "../models/response/organizationUserResponse";
import { PaymentResponse } from "../models/response/paymentResponse";
import { PlanResponse } from "../models/response/planResponse";
import { PolicyResponse } from "../models/response/policyResponse";
import { PreloginResponse } from "../models/response/preloginResponse";
import { ProfileResponse } from "../models/response/profileResponse";
import {
ProviderOrganizationOrganizationDetailsResponse,
ProviderOrganizationResponse,
} from "../models/response/provider/providerOrganizationResponse";
import { ProviderResponse } from "../models/response/provider/providerResponse";
import { ProviderUserBulkPublicKeyResponse } from "../models/response/provider/providerUserBulkPublicKeyResponse";
import { ProviderUserBulkResponse } from "../models/response/provider/providerUserBulkResponse";
import {
ProviderUserResponse,
ProviderUserUserDetailsResponse,
} from "../models/response/provider/providerUserResponse";
import { SelectionReadOnlyResponse } from "../models/response/selectionReadOnlyResponse";
import { SendAccessResponse } from "../models/response/sendAccessResponse";
import { SendFileDownloadDataResponse } from "../models/response/sendFileDownloadDataResponse";
import { SendFileUploadDataResponse } from "../models/response/sendFileUploadDataResponse";
import { SendResponse } from "../models/response/sendResponse";
import { SubscriptionResponse } from "../models/response/subscriptionResponse";
import { SyncResponse } from "../models/response/syncResponse";
import { TaxInfoResponse } from "../models/response/taxInfoResponse";
import { TaxRateResponse } from "../models/response/taxRateResponse";
import { TwoFactorAuthenticatorResponse } from "../models/response/twoFactorAuthenticatorResponse";
import { TwoFactorDuoResponse } from "../models/response/twoFactorDuoResponse";
import { TwoFactorEmailResponse } from "../models/response/twoFactorEmailResponse";
import { TwoFactorProviderResponse } from "../models/response/twoFactorProviderResponse";
import { TwoFactorRecoverResponse } from "../models/response/twoFactorRescoverResponse";
import {
ChallengeResponse,
TwoFactorWebAuthnResponse,
} from "../models/response/twoFactorWebAuthnResponse";
import { TwoFactorYubiKeyResponse } from "../models/response/twoFactorYubiKeyResponse";
import { UserKeyResponse } from "../models/response/userKeyResponse";
import { SendAccessView } from '../models/view/sendAccessView';
import { SendAccessView } from "../models/view/sendAccessView";
export abstract class ApiService {
postIdentityToken: (request: TokenRequest) => Promise<IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse>;
postIdentityToken: (
request: TokenRequest
) => Promise<IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse>;
refreshIdentityToken: () => Promise<any>;
getProfile: () => Promise<ProfileResponse>;
@@ -212,7 +220,11 @@ export abstract class ApiService {
deleteFolder: (id: string) => Promise<any>;
getSend: (id: string) => Promise<SendResponse>;
postSendAccess: (id: string, request: SendAccessRequest, apiUrl?: string) => Promise<SendAccessResponse>;
postSendAccess: (
id: string,
request: SendAccessRequest,
apiUrl?: string
) => Promise<SendAccessResponse>;
getSends: () => Promise<ListResponse<SendResponse>>;
postSend: (request: SendRequest) => Promise<SendResponse>;
postFileTypeSend: (request: SendRequest) => Promise<SendFileUploadDataResponse>;
@@ -225,12 +237,20 @@ export abstract class ApiService {
putSend: (id: string, request: SendRequest) => Promise<SendResponse>;
putSendRemovePassword: (id: string) => Promise<SendResponse>;
deleteSend: (id: string) => Promise<any>;
getSendFileDownloadData: (send: SendAccessView, request: SendAccessRequest, apiUrl?: string) => Promise<SendFileDownloadDataResponse>;
getSendFileDownloadData: (
send: SendAccessView,
request: SendAccessRequest,
apiUrl?: string
) => Promise<SendFileDownloadDataResponse>;
renewSendFileUploadUrl: (sendId: string, fileId: string) => Promise<SendFileUploadDataResponse>;
getCipher: (id: string) => Promise<CipherResponse>;
getCipherAdmin: (id: string) => Promise<CipherResponse>;
getAttachmentData: (cipherId: string, attachmentId: string, emergencyAccessId?: string) => Promise<AttachmentResponse>;
getAttachmentData: (
cipherId: string,
attachmentId: string,
emergencyAccessId?: string
) => Promise<AttachmentResponse>;
getCiphersOrganization: (organizationId: string) => Promise<ListResponse<CipherResponse>>;
postCipher: (request: CipherRequest) => Promise<CipherResponse>;
postCipherCreate: (request: CipherCreateRequest) => Promise<CipherResponse>;
@@ -248,14 +268,19 @@ export abstract class ApiService {
putCipherCollectionsAdmin: (id: string, request: CipherCollectionsRequest) => Promise<any>;
postPurgeCiphers: (request: SecretVerificationRequest, organizationId?: string) => Promise<any>;
postImportCiphers: (request: ImportCiphersRequest) => Promise<any>;
postImportOrganizationCiphers: (organizationId: string, request: ImportOrganizationCiphersRequest) => Promise<any>;
postImportOrganizationCiphers: (
organizationId: string,
request: ImportOrganizationCiphersRequest
) => Promise<any>;
putDeleteCipher: (id: string) => Promise<any>;
putDeleteCipherAdmin: (id: string) => Promise<any>;
putDeleteManyCiphers: (request: CipherBulkDeleteRequest) => Promise<any>;
putDeleteManyCiphersAdmin: (request: CipherBulkDeleteRequest) => Promise<any>;
putRestoreCipher: (id: string) => Promise<CipherResponse>;
putRestoreCipherAdmin: (id: string) => Promise<CipherResponse>;
putRestoreManyCiphers: (request: CipherBulkRestoreRequest) => Promise<ListResponse<CipherResponse>>;
putRestoreManyCiphers: (
request: CipherBulkRestoreRequest
) => Promise<ListResponse<CipherResponse>>;
/**
* @deprecated Mar 25 2021: This method has been deprecated in favor of direct uploads.
@@ -267,23 +292,51 @@ export abstract class ApiService {
* This method still exists for backward compatibility with old server versions.
*/
postCipherAttachmentAdminLegacy: (id: string, data: FormData) => Promise<CipherResponse>;
postCipherAttachment: (id: string, request: AttachmentRequest) => Promise<AttachmentUploadDataResponse>;
postCipherAttachment: (
id: string,
request: AttachmentRequest
) => Promise<AttachmentUploadDataResponse>;
deleteCipherAttachment: (id: string, attachmentId: string) => Promise<any>;
deleteCipherAttachmentAdmin: (id: string, attachmentId: string) => Promise<any>;
postShareCipherAttachment: (id: string, attachmentId: string, data: FormData,
organizationId: string) => Promise<any>;
renewAttachmentUploadUrl: (id: string, attachmentId: string) => Promise<AttachmentUploadDataResponse>;
postShareCipherAttachment: (
id: string,
attachmentId: string,
data: FormData,
organizationId: string
) => Promise<any>;
renewAttachmentUploadUrl: (
id: string,
attachmentId: string
) => Promise<AttachmentUploadDataResponse>;
postAttachmentFile: (id: string, attachmentId: string, data: FormData) => Promise<any>;
getCollectionDetails: (organizationId: string, id: string) => Promise<CollectionGroupDetailsResponse>;
getCollectionDetails: (
organizationId: string,
id: string
) => Promise<CollectionGroupDetailsResponse>;
getUserCollections: () => Promise<ListResponse<CollectionResponse>>;
getCollections: (organizationId: string) => Promise<ListResponse<CollectionResponse>>;
getCollectionUsers: (organizationId: string, id: string) => Promise<SelectionReadOnlyResponse[]>;
postCollection: (organizationId: string, request: CollectionRequest) => Promise<CollectionResponse>;
putCollectionUsers: (organizationId: string, id: string, request: SelectionReadOnlyRequest[]) => Promise<any>;
putCollection: (organizationId: string, id: string, request: CollectionRequest) => Promise<CollectionResponse>;
postCollection: (
organizationId: string,
request: CollectionRequest
) => Promise<CollectionResponse>;
putCollectionUsers: (
organizationId: string,
id: string,
request: SelectionReadOnlyRequest[]
) => Promise<any>;
putCollection: (
organizationId: string,
id: string,
request: CollectionRequest
) => Promise<CollectionResponse>;
deleteCollection: (organizationId: string, id: string) => Promise<any>;
deleteCollectionUser: (organizationId: string, id: string, organizationUserId: string) => Promise<any>;
deleteCollectionUser: (
organizationId: string,
id: string,
organizationUserId: string
) => Promise<any>;
getGroupDetails: (organizationId: string, id: string) => Promise<GroupDetailsResponse>;
getGroups: (organizationId: string) => Promise<ListResponse<GroupResponse>>;
@@ -296,35 +349,83 @@ export abstract class ApiService {
getPolicy: (organizationId: string, type: PolicyType) => Promise<PolicyResponse>;
getPolicies: (organizationId: string) => Promise<ListResponse<PolicyResponse>>;
getPoliciesByToken: (organizationId: string, token: string, email: string, organizationUserId: string) =>
Promise<ListResponse<PolicyResponse>>;
putPolicy: (organizationId: string, type: PolicyType, request: PolicyRequest) => Promise<PolicyResponse>;
getPoliciesByToken: (
organizationId: string,
token: string,
email: string,
organizationUserId: string
) => Promise<ListResponse<PolicyResponse>>;
putPolicy: (
organizationId: string,
type: PolicyType,
request: PolicyRequest
) => Promise<PolicyResponse>;
getOrganizationUser: (organizationId: string, id: string) => Promise<OrganizationUserDetailsResponse>;
getOrganizationUser: (
organizationId: string,
id: string
) => Promise<OrganizationUserDetailsResponse>;
getOrganizationUserGroups: (organizationId: string, id: string) => Promise<string[]>;
getOrganizationUsers: (organizationId: string) => Promise<ListResponse<OrganizationUserUserDetailsResponse>>;
getOrganizationUserResetPasswordDetails: (organizationId: string, id: string)
=> Promise<OrganizationUserResetPasswordDetailsReponse>;
postOrganizationUserInvite: (organizationId: string, request: OrganizationUserInviteRequest) => Promise<any>;
getOrganizationUsers: (
organizationId: string
) => Promise<ListResponse<OrganizationUserUserDetailsResponse>>;
getOrganizationUserResetPasswordDetails: (
organizationId: string,
id: string
) => Promise<OrganizationUserResetPasswordDetailsReponse>;
postOrganizationUserInvite: (
organizationId: string,
request: OrganizationUserInviteRequest
) => Promise<any>;
postOrganizationUserReinvite: (organizationId: string, id: string) => Promise<any>;
postManyOrganizationUserReinvite: (organizationId: string, request: OrganizationUserBulkRequest) => Promise<ListResponse<OrganizationUserBulkResponse>>;
postOrganizationUserAccept: (organizationId: string, id: string,
request: OrganizationUserAcceptRequest) => Promise<any>;
postOrganizationUserConfirm: (organizationId: string, id: string,
request: OrganizationUserConfirmRequest) => Promise<any>;
postOrganizationUsersPublicKey: (organizationId: string, request: OrganizationUserBulkRequest) =>
Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>>;
postOrganizationUserBulkConfirm: (organizationId: string, request: OrganizationUserBulkConfirmRequest) => Promise<ListResponse<OrganizationUserBulkResponse>>;
postManyOrganizationUserReinvite: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
postOrganizationUserAccept: (
organizationId: string,
id: string,
request: OrganizationUserAcceptRequest
) => Promise<any>;
postOrganizationUserConfirm: (
organizationId: string,
id: string,
request: OrganizationUserConfirmRequest
) => Promise<any>;
postOrganizationUsersPublicKey: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>>;
postOrganizationUserBulkConfirm: (
organizationId: string,
request: OrganizationUserBulkConfirmRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
putOrganizationUser: (organizationId: string, id: string, request: OrganizationUserUpdateRequest) => Promise<any>;
putOrganizationUserGroups: (organizationId: string, id: string,
request: OrganizationUserUpdateGroupsRequest) => Promise<any>;
putOrganizationUserResetPasswordEnrollment: (organizationId: string, userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest) => Promise<any>;
putOrganizationUserResetPassword: (organizationId: string, id: string,
request: OrganizationUserResetPasswordRequest) => Promise<any>;
putOrganizationUser: (
organizationId: string,
id: string,
request: OrganizationUserUpdateRequest
) => Promise<any>;
putOrganizationUserGroups: (
organizationId: string,
id: string,
request: OrganizationUserUpdateGroupsRequest
) => Promise<any>;
putOrganizationUserResetPasswordEnrollment: (
organizationId: string,
userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest
) => Promise<any>;
putOrganizationUserResetPassword: (
organizationId: string,
id: string,
request: OrganizationUserResetPasswordRequest
) => Promise<any>;
deleteOrganizationUser: (organizationId: string, id: string) => Promise<any>;
deleteManyOrganizationUsers: (organizationId: string, request: OrganizationUserBulkRequest) => Promise<ListResponse<OrganizationUserBulkResponse>>;
deleteManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
getSync: () => Promise<SyncResponse>;
postImportDirectory: (organizationId: string, request: ImportDirectoryRequest) => Promise<any>;
@@ -334,28 +435,45 @@ export abstract class ApiService {
putSettingsDomains: (request: UpdateDomainsRequest) => Promise<DomainsResponse>;
getTwoFactorProviders: () => Promise<ListResponse<TwoFactorProviderResponse>>;
getTwoFactorOrganizationProviders: (organizationId: string) => Promise<ListResponse<TwoFactorProviderResponse>>;
getTwoFactorAuthenticator: (request: SecretVerificationRequest) => Promise<TwoFactorAuthenticatorResponse>;
getTwoFactorOrganizationProviders: (
organizationId: string
) => Promise<ListResponse<TwoFactorProviderResponse>>;
getTwoFactorAuthenticator: (
request: SecretVerificationRequest
) => Promise<TwoFactorAuthenticatorResponse>;
getTwoFactorEmail: (request: SecretVerificationRequest) => Promise<TwoFactorEmailResponse>;
getTwoFactorDuo: (request: SecretVerificationRequest) => Promise<TwoFactorDuoResponse>;
getTwoFactorOrganizationDuo: (organizationId: string,
request: SecretVerificationRequest) => Promise<TwoFactorDuoResponse>;
getTwoFactorOrganizationDuo: (
organizationId: string,
request: SecretVerificationRequest
) => Promise<TwoFactorDuoResponse>;
getTwoFactorYubiKey: (request: SecretVerificationRequest) => Promise<TwoFactorYubiKeyResponse>;
getTwoFactorWebAuthn: (request: SecretVerificationRequest) => Promise<TwoFactorWebAuthnResponse>;
getTwoFactorWebAuthnChallenge: (request: SecretVerificationRequest) => Promise<ChallengeResponse>;
getTwoFactorRecover: (request: SecretVerificationRequest) => Promise<TwoFactorRecoverResponse>;
putTwoFactorAuthenticator: (
request: UpdateTwoFactorAuthenticatorRequest) => Promise<TwoFactorAuthenticatorResponse>;
request: UpdateTwoFactorAuthenticatorRequest
) => Promise<TwoFactorAuthenticatorResponse>;
putTwoFactorEmail: (request: UpdateTwoFactorEmailRequest) => Promise<TwoFactorEmailResponse>;
putTwoFactorDuo: (request: UpdateTwoFactorDuoRequest) => Promise<TwoFactorDuoResponse>;
putTwoFactorOrganizationDuo: (organizationId: string,
request: UpdateTwoFactorDuoRequest) => Promise<TwoFactorDuoResponse>;
putTwoFactorYubiKey: (request: UpdateTwoFactorYubioOtpRequest) => Promise<TwoFactorYubiKeyResponse>;
putTwoFactorWebAuthn: (request: UpdateTwoFactorWebAuthnRequest) => Promise<TwoFactorWebAuthnResponse>;
deleteTwoFactorWebAuthn: (request: UpdateTwoFactorWebAuthnDeleteRequest) => Promise<TwoFactorWebAuthnResponse>;
putTwoFactorOrganizationDuo: (
organizationId: string,
request: UpdateTwoFactorDuoRequest
) => Promise<TwoFactorDuoResponse>;
putTwoFactorYubiKey: (
request: UpdateTwoFactorYubioOtpRequest
) => Promise<TwoFactorYubiKeyResponse>;
putTwoFactorWebAuthn: (
request: UpdateTwoFactorWebAuthnRequest
) => Promise<TwoFactorWebAuthnResponse>;
deleteTwoFactorWebAuthn: (
request: UpdateTwoFactorWebAuthnDeleteRequest
) => Promise<TwoFactorWebAuthnResponse>;
putTwoFactorDisable: (request: TwoFactorProviderRequest) => Promise<TwoFactorProviderResponse>;
putTwoFactorOrganizationDisable: (organizationId: string,
request: TwoFactorProviderRequest) => Promise<TwoFactorProviderResponse>;
putTwoFactorOrganizationDisable: (
organizationId: string,
request: TwoFactorProviderRequest
) => Promise<TwoFactorProviderResponse>;
postTwoFactorRecover: (request: TwoFactorRecoveryRequest) => Promise<any>;
postTwoFactorEmailSetup: (request: TwoFactorEmailRequest) => Promise<any>;
postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise<any>;
@@ -374,7 +492,10 @@ export abstract class ApiService {
postEmergencyAccessApprove: (id: string) => Promise<any>;
postEmergencyAccessReject: (id: string) => Promise<any>;
postEmergencyAccessTakeover: (id: string) => Promise<EmergencyAccessTakeoverResponse>;
postEmergencyAccessPassword: (id: string, request: EmergencyAccessPasswordRequest) => Promise<any>;
postEmergencyAccessPassword: (
id: string,
request: EmergencyAccessPasswordRequest
) => Promise<any>;
postEmergencyAccessView: (id: string) => Promise<EmergencyAccessViewResponse>;
getOrganization: (id: string) => Promise<OrganizationResponse>;
@@ -382,19 +503,39 @@ export abstract class ApiService {
getOrganizationSubscription: (id: string) => Promise<OrganizationSubscriptionResponse>;
getOrganizationLicense: (id: string, installationId: string) => Promise<any>;
getOrganizationTaxInfo: (id: string) => Promise<TaxInfoResponse>;
getOrganizationAutoEnrollStatus: (identifier: string) => Promise<OrganizationAutoEnrollStatusResponse>;
getOrganizationAutoEnrollStatus: (
identifier: string
) => Promise<OrganizationAutoEnrollStatusResponse>;
getOrganizationSso: (id: string) => Promise<OrganizationSsoResponse>;
postOrganization: (request: OrganizationCreateRequest) => Promise<OrganizationResponse>;
putOrganization: (id: string, request: OrganizationUpdateRequest) => Promise<OrganizationResponse>;
putOrganization: (
id: string,
request: OrganizationUpdateRequest
) => Promise<OrganizationResponse>;
putOrganizationTaxInfo: (id: string, request: OrganizationTaxInfoUpdateRequest) => Promise<any>;
postLeaveOrganization: (id: string) => Promise<any>;
postOrganizationLicense: (data: FormData) => Promise<OrganizationResponse>;
postOrganizationLicenseUpdate: (id: string, data: FormData) => Promise<any>;
postOrganizationApiKey: (id: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>;
postOrganizationRotateApiKey: (id: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>;
postOrganizationSso: (id: string, request: OrganizationSsoRequest) => Promise<OrganizationSsoResponse>;
postOrganizationUpgrade: (id: string, request: OrganizationUpgradeRequest) => Promise<PaymentResponse>;
postOrganizationUpdateSubscription: (id: string, request: OrganizationSubscriptionUpdateRequest) => Promise<void>;
postOrganizationApiKey: (
id: string,
request: SecretVerificationRequest
) => Promise<ApiKeyResponse>;
postOrganizationRotateApiKey: (
id: string,
request: SecretVerificationRequest
) => Promise<ApiKeyResponse>;
postOrganizationSso: (
id: string,
request: OrganizationSsoRequest
) => Promise<OrganizationSsoResponse>;
postOrganizationUpgrade: (
id: string,
request: OrganizationUpgradeRequest
) => Promise<PaymentResponse>;
postOrganizationUpdateSubscription: (
id: string,
request: OrganizationSubscriptionUpdateRequest
) => Promise<void>;
postOrganizationSeat: (id: string, request: SeatRequest) => Promise<PaymentResponse>;
postOrganizationStorage: (id: string, request: StorageRequest) => Promise<any>;
postOrganizationPayment: (id: string, request: PaymentRequest) => Promise<any>;
@@ -405,7 +546,10 @@ export abstract class ApiService {
getPlans: () => Promise<ListResponse<PlanResponse>>;
getTaxRates: () => Promise<ListResponse<TaxRateResponse>>;
getOrganizationKeys: (id: string) => Promise<OrganizationKeysResponse>;
postOrganizationKeys: (id: string, request: OrganizationKeysRequest) => Promise<OrganizationKeysResponse>;
postOrganizationKeys: (
id: string,
request: OrganizationKeysRequest
) => Promise<OrganizationKeysResponse>;
postProviderSetup: (id: string, request: ProviderSetupRequest) => Promise<ProviderResponse>;
getProvider: (id: string) => Promise<ProviderResponse>;
@@ -415,28 +559,84 @@ export abstract class ApiService {
getProviderUser: (providerId: string, id: string) => Promise<ProviderUserResponse>;
postProviderUserInvite: (providerId: string, request: ProviderUserInviteRequest) => Promise<any>;
postProviderUserReinvite: (providerId: string, id: string) => Promise<any>;
postManyProviderUserReinvite: (providerId: string, request: ProviderUserBulkRequest) => Promise<ListResponse<ProviderUserBulkResponse>>;
postProviderUserAccept: (providerId: string, id: string, request: ProviderUserAcceptRequest) => Promise<any>;
postProviderUserConfirm: (providerId: string, id: string, request: ProviderUserConfirmRequest) => Promise<any>;
postProviderUsersPublicKey: (providerId: string, request: ProviderUserBulkRequest) =>
Promise<ListResponse<ProviderUserBulkPublicKeyResponse>>;
postProviderUserBulkConfirm: (providerId: string, request: ProviderUserBulkConfirmRequest) => Promise<ListResponse<ProviderUserBulkResponse>>;
putProviderUser: (providerId: string, id: string, request: ProviderUserUpdateRequest) => Promise<any>;
postManyProviderUserReinvite: (
providerId: string,
request: ProviderUserBulkRequest
) => Promise<ListResponse<ProviderUserBulkResponse>>;
postProviderUserAccept: (
providerId: string,
id: string,
request: ProviderUserAcceptRequest
) => Promise<any>;
postProviderUserConfirm: (
providerId: string,
id: string,
request: ProviderUserConfirmRequest
) => Promise<any>;
postProviderUsersPublicKey: (
providerId: string,
request: ProviderUserBulkRequest
) => Promise<ListResponse<ProviderUserBulkPublicKeyResponse>>;
postProviderUserBulkConfirm: (
providerId: string,
request: ProviderUserBulkConfirmRequest
) => Promise<ListResponse<ProviderUserBulkResponse>>;
putProviderUser: (
providerId: string,
id: string,
request: ProviderUserUpdateRequest
) => Promise<any>;
deleteProviderUser: (organizationId: string, id: string) => Promise<any>;
deleteManyProviderUsers: (providerId: string, request: ProviderUserBulkRequest) => Promise<ListResponse<ProviderUserBulkResponse>>;
getProviderClients: (providerId: string) => Promise<ListResponse<ProviderOrganizationOrganizationDetailsResponse>>;
postProviderAddOrganization: (providerId: string, request: ProviderAddOrganizationRequest) => Promise<any>;
postProviderCreateOrganization: (providerId: string, request: ProviderOrganizationCreateRequest) => Promise<ProviderOrganizationResponse>;
deleteManyProviderUsers: (
providerId: string,
request: ProviderUserBulkRequest
) => Promise<ListResponse<ProviderUserBulkResponse>>;
getProviderClients: (
providerId: string
) => Promise<ListResponse<ProviderOrganizationOrganizationDetailsResponse>>;
postProviderAddOrganization: (
providerId: string,
request: ProviderAddOrganizationRequest
) => Promise<any>;
postProviderCreateOrganization: (
providerId: string,
request: ProviderOrganizationCreateRequest
) => Promise<ProviderOrganizationResponse>;
deleteProviderOrganization: (providerId: string, organizationId: string) => Promise<any>;
getEvents: (start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
getEventsCipher: (id: string, start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
getEventsOrganization: (id: string, start: string, end: string,
token: string) => Promise<ListResponse<EventResponse>>;
getEventsOrganizationUser: (organizationId: string, id: string,
start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
getEventsProvider: (id: string, start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
getEventsProviderUser: (providerId: string, id: string, start: string, end: string, token: string) => Promise<ListResponse<EventResponse>>;
getEventsCipher: (
id: string,
start: string,
end: string,
token: string
) => Promise<ListResponse<EventResponse>>;
getEventsOrganization: (
id: string,
start: string,
end: string,
token: string
) => Promise<ListResponse<EventResponse>>;
getEventsOrganizationUser: (
organizationId: string,
id: string,
start: string,
end: string,
token: string
) => Promise<ListResponse<EventResponse>>;
getEventsProvider: (
id: string,
start: string,
end: string,
token: string
) => Promise<ListResponse<EventResponse>>;
getEventsProviderUser: (
providerId: string,
id: string,
start: string,
end: string,
token: string
) => Promise<ListResponse<EventResponse>>;
postEventsCollect: (request: EventRequest[]) => Promise<any>;
deleteSsoUser: (organizationId: string) => Promise<any>;
@@ -455,14 +655,23 @@ export abstract class ApiService {
preValidateSso: (identifier: string) => Promise<boolean>;
postCreateSponsorship: (sponsorshipOrgId: string, request: OrganizationSponsorshipCreateRequest) => Promise<void>;
postCreateSponsorship: (
sponsorshipOrgId: string,
request: OrganizationSponsorshipCreateRequest
) => Promise<void>;
deleteRevokeSponsorship: (sponsoringOrganizationId: string) => Promise<void>;
deleteRemoveSponsorship: (sponsoringOrgId: string) => Promise<void>;
postPreValidateSponsorshipToken: (sponsorshipToken: string) => Promise<boolean>;
postRedeemSponsorship: (sponsorshipToken: string, request: OrganizationSponsorshipRedeemRequest) => Promise<void>;
postRedeemSponsorship: (
sponsorshipToken: string,
request: OrganizationSponsorshipRedeemRequest
) => Promise<void>;
postResendSponsorshipOffer: (sponsoringOrgId: string) => Promise<void>;
getUserKeyFromKeyConnector: (keyConnectorUrl: string) => Promise<KeyConnectorUserKeyResponse>;
postUserKeyToKeyConnector: (keyConnectorUrl: string, request: KeyConnectorUserKeyRequest) => Promise<void>;
postUserKeyToKeyConnector: (
keyConnectorUrl: string,
request: KeyConnectorUserKeyRequest
) => Promise<void>;
getKeyConnectorAlive: (keyConnectorUrl: string) => Promise<void>;
}

View File

@@ -1,4 +1,4 @@
import { BreachAccountResponse } from '../models/response/breachAccountResponse';
import { BreachAccountResponse } from "../models/response/breachAccountResponse";
export abstract class AuditService {
passwordLeaked: (password: string) => Promise<number>;

View File

@@ -1,7 +1,7 @@
import { TwoFactorProviderType } from '../enums/twoFactorProviderType';
import { TwoFactorProviderType } from "../enums/twoFactorProviderType";
import { AuthResult } from '../models/domain/authResult';
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
import { AuthResult } from "../models/domain/authResult";
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
export abstract class AuthService {
email: string;
@@ -11,20 +11,45 @@ export abstract class AuthService {
ssoRedirectUrl: string;
clientId: string;
clientSecret: string;
twoFactorProvidersData: Map<TwoFactorProviderType, { [key: string]: string; }>;
twoFactorProvidersData: Map<TwoFactorProviderType, { [key: string]: string }>;
selectedTwoFactorProviderType: TwoFactorProviderType;
logIn: (email: string, masterPassword: string, captchaToken?: string) => Promise<AuthResult>;
logInSso: (code: string, codeVerifier: string, redirectUrl: string, orgId: string) => Promise<AuthResult>;
logInSso: (
code: string,
codeVerifier: string,
redirectUrl: string,
orgId: string
) => Promise<AuthResult>;
logInApiKey: (clientId: string, clientSecret: string) => Promise<AuthResult>;
logInTwoFactor: (twoFactorProvider: TwoFactorProviderType, twoFactorToken: string,
remember?: boolean) => Promise<AuthResult>;
logInComplete: (email: string, masterPassword: string, twoFactorProvider: TwoFactorProviderType,
twoFactorToken: string, remember?: boolean, captchaToken?: string) => Promise<AuthResult>;
logInSsoComplete: (code: string, codeVerifier: string, redirectUrl: string,
twoFactorProvider: TwoFactorProviderType, twoFactorToken: string, remember?: boolean) => Promise<AuthResult>;
logInApiKeyComplete: (clientId: string, clientSecret: string, twoFactorProvider: TwoFactorProviderType,
twoFactorToken: string, remember?: boolean) => Promise<AuthResult>;
logInTwoFactor: (
twoFactorProvider: TwoFactorProviderType,
twoFactorToken: string,
remember?: boolean
) => Promise<AuthResult>;
logInComplete: (
email: string,
masterPassword: string,
twoFactorProvider: TwoFactorProviderType,
twoFactorToken: string,
remember?: boolean,
captchaToken?: string
) => Promise<AuthResult>;
logInSsoComplete: (
code: string,
codeVerifier: string,
redirectUrl: string,
twoFactorProvider: TwoFactorProviderType,
twoFactorToken: string,
remember?: boolean
) => Promise<AuthResult>;
logInApiKeyComplete: (
clientId: string,
clientSecret: string,
twoFactorProvider: TwoFactorProviderType,
twoFactorToken: string,
remember?: boolean
) => Promise<AuthResult>;
logOut: (callback: Function) => void;
getSupportedTwoFactorProviders: (win: Window) => any[];
getDefaultTwoFactorProvider: (webAuthnSupported: boolean) => TwoFactorProviderType;

View File

@@ -1,26 +1,61 @@
import { DecryptParameters } from '../models/domain/decryptParameters';
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
import { DecryptParameters } from "../models/domain/decryptParameters";
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
export abstract class CryptoFunctionService {
pbkdf2: (password: string | ArrayBuffer, salt: string | ArrayBuffer, algorithm: 'sha256' | 'sha512',
iterations: number) => Promise<ArrayBuffer>;
hkdf: (ikm: ArrayBuffer, salt: string | ArrayBuffer, info: string | ArrayBuffer,
outputByteSize: number, algorithm: 'sha256' | 'sha512') => Promise<ArrayBuffer>;
hkdfExpand: (prk: ArrayBuffer, info: string | ArrayBuffer, outputByteSize: number,
algorithm: 'sha256' | 'sha512') => Promise<ArrayBuffer>;
hash: (value: string | ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512' | 'md5') => Promise<ArrayBuffer>;
hmac: (value: ArrayBuffer, key: ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512') => Promise<ArrayBuffer>;
pbkdf2: (
password: string | ArrayBuffer,
salt: string | ArrayBuffer,
algorithm: "sha256" | "sha512",
iterations: number
) => Promise<ArrayBuffer>;
hkdf: (
ikm: ArrayBuffer,
salt: string | ArrayBuffer,
info: string | ArrayBuffer,
outputByteSize: number,
algorithm: "sha256" | "sha512"
) => Promise<ArrayBuffer>;
hkdfExpand: (
prk: ArrayBuffer,
info: string | ArrayBuffer,
outputByteSize: number,
algorithm: "sha256" | "sha512"
) => Promise<ArrayBuffer>;
hash: (
value: string | ArrayBuffer,
algorithm: "sha1" | "sha256" | "sha512" | "md5"
) => Promise<ArrayBuffer>;
hmac: (
value: ArrayBuffer,
key: ArrayBuffer,
algorithm: "sha1" | "sha256" | "sha512"
) => Promise<ArrayBuffer>;
compare: (a: ArrayBuffer, b: ArrayBuffer) => Promise<boolean>;
hmacFast: (value: ArrayBuffer | string, key: ArrayBuffer | string, algorithm: 'sha1' | 'sha256' | 'sha512') =>
Promise<ArrayBuffer | string>;
hmacFast: (
value: ArrayBuffer | string,
key: ArrayBuffer | string,
algorithm: "sha1" | "sha256" | "sha512"
) => Promise<ArrayBuffer | string>;
compareFast: (a: ArrayBuffer | string, b: ArrayBuffer | string) => Promise<boolean>;
aesEncrypt: (data: ArrayBuffer, iv: ArrayBuffer, key: ArrayBuffer) => Promise<ArrayBuffer>;
aesDecryptFastParameters: (data: string, iv: string, mac: string, key: SymmetricCryptoKey) =>
DecryptParameters<ArrayBuffer | string>;
aesDecryptFastParameters: (
data: string,
iv: string,
mac: string,
key: SymmetricCryptoKey
) => DecryptParameters<ArrayBuffer | string>;
aesDecryptFast: (parameters: DecryptParameters<ArrayBuffer | string>) => Promise<string>;
aesDecrypt: (data: ArrayBuffer, iv: ArrayBuffer, key: ArrayBuffer) => Promise<ArrayBuffer>;
rsaEncrypt: (data: ArrayBuffer, publicKey: ArrayBuffer, algorithm: 'sha1' | 'sha256') => Promise<ArrayBuffer>;
rsaDecrypt: (data: ArrayBuffer, privateKey: ArrayBuffer, algorithm: 'sha1' | 'sha256') => Promise<ArrayBuffer>;
rsaEncrypt: (
data: ArrayBuffer,
publicKey: ArrayBuffer,
algorithm: "sha1" | "sha256"
) => Promise<ArrayBuffer>;
rsaDecrypt: (
data: ArrayBuffer,
privateKey: ArrayBuffer,
algorithm: "sha1" | "sha256"
) => Promise<ArrayBuffer>;
rsaExtractPublicKey: (privateKey: ArrayBuffer) => Promise<ArrayBuffer>;
rsaGenerateKeyPair: (length: 1024 | 2048 | 4096) => Promise<[ArrayBuffer, ArrayBuffer]>;
randomBytes: (length: number) => Promise<ArrayBuffer>;

View File

@@ -1,4 +1,4 @@
import { Observable } from 'rxjs';
import { Observable } from "rxjs";
export type Urls = {
base?: string;

View File

@@ -1,8 +1,11 @@
import { EventView } from '../models/view/eventView';
import { EventView } from "../models/view/eventView";
export abstract class ExportService {
getExport: (format?: 'csv' | 'json' | 'encrypted_json') => Promise<string>;
getOrganizationExport: (organizationId: string, format?: 'csv' | 'json' | 'encrypted_json') => Promise<string>;
getExport: (format?: "csv" | "json" | "encrypted_json") => Promise<string>;
getOrganizationExport: (
organizationId: string,
format?: "csv" | "json" | "encrypted_json"
) => Promise<string>;
getEventExport: (events: EventView[]) => Promise<string>;
getFileName: (prefix?: string, extension?: string) => string;
}

View File

@@ -1,11 +1,18 @@
import { EncArrayBuffer } from '../models/domain/encArrayBuffer';
import { EncString } from '../models/domain/encString';
import { AttachmentUploadDataResponse } from '../models/response/attachmentUploadDataResponse';
import { SendFileUploadDataResponse } from '../models/response/sendFileUploadDataResponse';
import { EncArrayBuffer } from "../models/domain/encArrayBuffer";
import { EncString } from "../models/domain/encString";
import { AttachmentUploadDataResponse } from "../models/response/attachmentUploadDataResponse";
import { SendFileUploadDataResponse } from "../models/response/sendFileUploadDataResponse";
export abstract class FileUploadService {
uploadSendFile: (uploadData: SendFileUploadDataResponse, fileName: EncString,
encryptedFileData: EncArrayBuffer) => Promise<any>;
uploadCipherAttachment: (admin: boolean, uploadData: AttachmentUploadDataResponse, fileName: EncString,
encryptedFileData: EncArrayBuffer) => Promise<any>;
uploadSendFile: (
uploadData: SendFileUploadDataResponse,
fileName: EncString,
encryptedFileData: EncArrayBuffer
) => Promise<any>;
uploadCipherAttachment: (
admin: boolean,
uploadData: AttachmentUploadDataResponse,
fileName: EncString,
encryptedFileData: EncArrayBuffer
) => Promise<any>;
}

View File

@@ -1,4 +1,4 @@
import { Importer } from '../importers/importer';
import { Importer } from "../importers/importer";
export interface ImportOption {
id: string;

View File

@@ -1,4 +1,4 @@
import { Organization } from '../models/domain/organization';
import { Organization } from "../models/domain/organization";
export abstract class KeyConnectorService {
getAndSetKey: (url?: string) => Promise<void>;

View File

@@ -1,4 +1,4 @@
import { LogLevelType } from '../enums/logLevelType';
import { LogLevelType } from "../enums/logLevelType";
export abstract class LogService {
debug: (message: string) => void;

View File

@@ -1,14 +1,16 @@
import { CipherView } from '../models/view/cipherView';
import { SendView } from '../models/view/sendView';
import { CipherView } from "../models/view/cipherView";
import { SendView } from "../models/view/sendView";
export abstract class SearchService {
indexedEntityId?: string = null;
clearIndex: () => void;
isSearchable: (query: string) => boolean;
indexCiphers: (indexedEntityGuid?: string, ciphersToIndex?: CipherView[]) => Promise<void>;
searchCiphers: (query: string,
filter?: ((cipher: CipherView) => boolean) | (((cipher: CipherView) => boolean)[]),
ciphers?: CipherView[]) => Promise<CipherView[]>;
searchCiphers: (
query: string,
filter?: ((cipher: CipherView) => boolean) | ((cipher: CipherView) => boolean)[],
ciphers?: CipherView[]
) => Promise<CipherView[]>;
searchCiphersBasic: (ciphers: CipherView[], query: string, deleted?: boolean) => CipherView[];
searchSends: (sends: SendView[], query: string) => SendView[];
}

View File

@@ -1,10 +1,13 @@
import { SecretVerificationRequest } from '../models/request/secretVerificationRequest';
import { SecretVerificationRequest } from "../models/request/secretVerificationRequest";
import { Verification } from '../types/verification';
import { Verification } from "../types/verification";
export abstract class UserVerificationService {
buildRequest: <T extends SecretVerificationRequest> (verification: Verification,
requestClass?: new () => T, alreadyHashed?: boolean) => Promise<T>;
buildRequest: <T extends SecretVerificationRequest>(
verification: Verification,
requestClass?: new () => T,
alreadyHashed?: boolean
) => Promise<T>;
verifyUser: (verification: Verification) => Promise<boolean>;
requestOTP: () => Promise<void>;
}

View File

@@ -1,5 +1,4 @@
export enum EmergencyAccessType
{
export enum EmergencyAccessType {
View = 0,
Takeover = 1,
}

View File

@@ -13,7 +13,7 @@ export enum Permissions {
*/
ManageAssignedCollections,
ManageGroups,
ManageOrganization ,
ManageOrganization,
ManagePolicies,
ManageProvider,
ManageUsers,

View File

@@ -1,7 +1,7 @@
export enum ThemeType {
System = 'system',
Light = 'light',
Dark = 'dark',
Nord = 'nord',
SolarizedDark = 'solarizedDark',
System = "system",
Light = "light",
Dark = "dark",
Nord = "nord",
SolarizedDark = "solarizedDark",
}

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class AscendoCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,16 +12,16 @@ export class AscendoCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
if (value.length < 2) {
return;
}
const cipher = this.initLoginCipher();
cipher.notes = this.getValueOrDefault(value[value.length - 1]);
cipher.name = this.getValueOrDefault(value[0], '--');
cipher.name = this.getValueOrDefault(value[0], "--");
if (value.length > 2 && (value.length % 2) === 0) {
if (value.length > 2 && value.length % 2 === 0) {
for (let i = 0; i < value.length - 2; i += 2) {
const val: string = value[i + 2];
const field: string = value[i + 1];
@@ -32,11 +32,15 @@ export class AscendoCsvImporter extends BaseImporter implements Importer {
const fieldLower = field.toLowerCase();
if (cipher.login.password == null && this.passwordFieldNames.indexOf(fieldLower) > -1) {
cipher.login.password = this.getValueOrDefault(val);
} else if (cipher.login.username == null &&
this.usernameFieldNames.indexOf(fieldLower) > -1) {
} else if (
cipher.login.username == null &&
this.usernameFieldNames.indexOf(fieldLower) > -1
) {
cipher.login.username = this.getValueOrDefault(val);
} else if ((cipher.login.uris == null || cipher.login.uris.length === 0) &&
this.uriFieldNames.indexOf(fieldLower) > -1) {
} else if (
(cipher.login.uris == null || cipher.login.uris.length === 0) &&
this.uriFieldNames.indexOf(fieldLower) > -1
) {
cipher.login.uris = this.makeUriArray(val);
} else {
this.processKvp(cipher, field, val);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class AvastCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,7 +12,7 @@ export class AvastCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.name);
cipher.login.uris = this.makeUriArray(value.web);

View File

@@ -1,10 +1,10 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CipherType } from '../enums/cipherType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherType } from "../enums/cipherType";
import { SecureNoteType } from "../enums/secureNoteType";
export class AvastJsonImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -52,10 +52,10 @@ export class AvastJsonImporter extends BaseImporter implements Importer {
cipher.card.brand = this.getCardBrand(cipher.card.number);
if (value.expirationDate != null) {
if (value.expirationDate.month != null) {
cipher.card.expMonth = value.expirationDate.month + '';
cipher.card.expMonth = value.expirationDate.month + "";
}
if (value.expirationDate.year != null) {
cipher.card.expYear = value.expirationDate.year + '';
cipher.card.expYear = value.expirationDate.year + "";
}
}
this.cleanupCipher(cipher);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class AviraCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,14 +12,19 @@ export class AviraCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.name,
this.getValueOrDefault(this.nameFromUrl(value.website), '--'));
cipher.name = this.getValueOrDefault(
value.name,
this.getValueOrDefault(this.nameFromUrl(value.website), "--")
);
cipher.login.uris = this.makeUriArray(value.website);
cipher.login.password = this.getValueOrDefault(value.password);
if (this.isNullOrWhitespace(value.username) && !this.isNullOrWhitespace(value.secondary_username)) {
if (
this.isNullOrWhitespace(value.username) &&
!this.isNullOrWhitespace(value.secondary_username)
) {
cipher.login.username = value.secondary_username;
} else {
cipher.login.username = this.getValueOrDefault(value.username);

View File

@@ -1,19 +1,19 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CipherView } from '../models/view/cipherView';
import { CollectionView } from '../models/view/collectionView';
import { FieldView } from '../models/view/fieldView';
import { FolderView } from '../models/view/folderView';
import { LoginView } from '../models/view/loginView';
import { SecureNoteView } from '../models/view/secureNoteView';
import { CipherView } from "../models/view/cipherView";
import { CollectionView } from "../models/view/collectionView";
import { FieldView } from "../models/view/fieldView";
import { FolderView } from "../models/view/folderView";
import { LoginView } from "../models/view/loginView";
import { SecureNoteView } from "../models/view/secureNoteView";
import { CipherRepromptType } from '../enums/cipherRepromptType';
import { CipherType } from '../enums/cipherType';
import { FieldType } from '../enums/fieldType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherRepromptType } from "../enums/cipherRepromptType";
import { CipherType } from "../enums/cipherType";
import { FieldType } from "../enums/fieldType";
import { SecureNoteType } from "../enums/secureNoteType";
export class BitwardenCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -24,10 +24,10 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
if (this.organization && !this.isNullOrWhitespace(value.collections)) {
const collections = (value.collections as string).split(',');
collections.forEach(col => {
const collections = (value.collections as string).split(",");
collections.forEach((col) => {
let addCollection = true;
let collectionIndex = result.collections.length;
@@ -52,15 +52,19 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
}
const cipher = new CipherView();
cipher.favorite = !this.organization && this.getValueOrDefault(value.favorite, '0') !== '0' ? true : false;
cipher.favorite =
!this.organization && this.getValueOrDefault(value.favorite, "0") !== "0" ? true : false;
cipher.type = CipherType.Login;
cipher.notes = this.getValueOrDefault(value.notes);
cipher.name = this.getValueOrDefault(value.name, '--');
cipher.name = this.getValueOrDefault(value.name, "--");
try {
cipher.reprompt = parseInt(this.getValueOrDefault(value.reprompt, CipherRepromptType.None.toString()), 10);
cipher.reprompt = parseInt(
this.getValueOrDefault(value.reprompt, CipherRepromptType.None.toString()),
10
);
} catch (e) {
// tslint:disable-next-line
console.error('Unable to parse reprompt value', e);
console.error("Unable to parse reprompt value", e);
cipher.reprompt = CipherRepromptType.None;
}
@@ -71,7 +75,7 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
continue;
}
const delimPosition = fields[i].lastIndexOf(': ');
const delimPosition = fields[i].lastIndexOf(": ");
if (delimPosition === -1) {
continue;
}
@@ -84,7 +88,7 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
field.name = fields[i].substr(0, delimPosition);
field.value = null;
field.type = FieldType.Text;
if (fields[i].length > (delimPosition + 2)) {
if (fields[i].length > delimPosition + 2) {
field.value = fields[i].substr(delimPosition + 2);
}
cipher.fields.push(field);
@@ -93,7 +97,7 @@ export class BitwardenCsvImporter extends BaseImporter implements Importer {
const valueType = value.type != null ? value.type.toLowerCase() : null;
switch (valueType) {
case 'note':
case "note":
cipher.type = CipherType.SecureNote;
cipher.secureNote = new SecureNoteView();
cipher.secureNote.type = SecureNoteType.Generic;

View File

@@ -1,15 +1,15 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { EncString } from '../models/domain/encString';
import { ImportResult } from '../models/domain/importResult';
import { EncString } from "../models/domain/encString";
import { ImportResult } from "../models/domain/importResult";
import { CipherWithIds } from '../models/export/cipherWithIds';
import { CollectionWithId } from '../models/export/collectionWithId';
import { FolderWithId } from '../models/export/folderWithId';
import { CipherWithIds } from "../models/export/cipherWithIds";
import { CollectionWithId } from "../models/export/collectionWithId";
import { FolderWithId } from "../models/export/folderWithId";
import { CryptoService } from '../abstractions/crypto.service';
import { I18nService } from '../abstractions/i18n.service';
import { CryptoService } from "../abstractions/crypto.service";
import { I18nService } from "../abstractions/i18n.service";
export class BitwardenJsonImporter extends BaseImporter implements Importer {
private results: any;
@@ -40,10 +40,13 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
if (this.results.encKeyValidation_DO_NOT_EDIT != null) {
const orgKey = await this.cryptoService.getOrgKey(this.organizationId);
const encKeyValidation = new EncString(this.results.encKeyValidation_DO_NOT_EDIT);
const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(encKeyValidation, orgKey);
const encKeyValidationDecrypt = await this.cryptoService.decryptToUtf8(
encKeyValidation,
orgKey
);
if (encKeyValidationDecrypt === null) {
this.result.success = false;
this.result.errorMessage = this.i18nService.t('importEncKeyError');
this.result.errorMessage = this.i18nService.t("importEncKeyError");
return;
}
}
@@ -87,11 +90,17 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
}
if (!this.organization && c.folderId != null && groupingsMap.has(c.folderId)) {
this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]);
this.result.folderRelationships.push([
this.result.ciphers.length,
groupingsMap.get(c.folderId),
]);
} else if (this.organization && c.collectionIds != null) {
c.collectionIds.forEach(cId => {
c.collectionIds.forEach((cId) => {
if (groupingsMap.has(cId)) {
this.result.collectionRelationships.push([this.result.ciphers.length, groupingsMap.get(cId)]);
this.result.collectionRelationships.push([
this.result.ciphers.length,
groupingsMap.get(cId),
]);
}
});
}
@@ -141,11 +150,17 @@ export class BitwardenJsonImporter extends BaseImporter implements Importer {
}
if (!this.organization && c.folderId != null && groupingsMap.has(c.folderId)) {
this.result.folderRelationships.push([this.result.ciphers.length, groupingsMap.get(c.folderId)]);
this.result.folderRelationships.push([
this.result.ciphers.length,
groupingsMap.get(c.folderId),
]);
} else if (this.organization && c.collectionIds != null) {
c.collectionIds.forEach(cId => {
c.collectionIds.forEach((cId) => {
if (groupingsMap.has(cId)) {
this.result.collectionRelationships.push([this.result.ciphers.length, groupingsMap.get(cId)]);
this.result.collectionRelationships.push([
this.result.ciphers.length,
groupingsMap.get(cId),
]);
}
});
}

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class BlackBerryCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,15 +12,15 @@ export class BlackBerryCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
if (value.grouping === 'list') {
results.forEach((value) => {
if (value.grouping === "list") {
return;
}
const cipher = this.initLoginCipher();
cipher.favorite = value.fav === '1';
cipher.favorite = value.fav === "1";
cipher.name = this.getValueOrDefault(value.name);
cipher.notes = this.getValueOrDefault(value.extra);
if (value.grouping !== 'note') {
if (value.grouping !== "note") {
cipher.login.uris = this.makeUriArray(value.url);
cipher.login.password = this.getValueOrDefault(value.password);
cipher.login.username = this.getValueOrDefault(value.username);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class BlurCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,13 +12,15 @@ export class BlurCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
if (value.label === 'null') {
results.forEach((value) => {
if (value.label === "null") {
value.label = null;
}
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.label,
this.getValueOrDefault(this.nameFromUrl(value.domain), '--'));
cipher.name = this.getValueOrDefault(
value.label,
this.getValueOrDefault(this.nameFromUrl(value.domain), "--")
);
cipher.login.uris = this.makeUriArray(value.domain);
cipher.login.password = this.getValueOrDefault(value.password);

View File

@@ -1,11 +1,9 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
const OfficialProps = [
'!group_id', '!group_name', 'title', 'username', 'password', 'URL', 'id',
];
const OfficialProps = ["!group_id", "!group_name", "title", "username", "password", "URL", "id"];
export class ButtercupCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -16,11 +14,11 @@ export class ButtercupCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
this.processFolder(result, this.getValueOrDefault(value['!group_name']));
results.forEach((value) => {
this.processFolder(result, this.getValueOrDefault(value["!group_name"]));
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.title, '--');
cipher.name = this.getValueOrDefault(value.title, "--");
cipher.login.username = this.getValueOrDefault(value.username);
cipher.login.password = this.getValueOrDefault(value.password);
cipher.login.uris = this.makeUriArray(value.URL);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class ChromeCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,9 +12,9 @@ export class ChromeCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.name, '--');
cipher.name = this.getValueOrDefault(value.name, "--");
cipher.login.username = this.getValueOrDefault(value.username);
cipher.login.password = this.getValueOrDefault(value.password);
cipher.login.uris = this.makeUriArray(value.url);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class ClipperzHtmlImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,9 +12,9 @@ export class ClipperzHtmlImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
const textarea = doc.querySelector('textarea');
const textarea = doc.querySelector("textarea");
if (textarea == null || this.isNullOrWhitespace(textarea.textContent)) {
result.errorMessage = 'Missing textarea.';
result.errorMessage = "Missing textarea.";
result.success = false;
return Promise.resolve(result);
}
@@ -23,10 +23,10 @@ export class ClipperzHtmlImporter extends BaseImporter implements Importer {
entries.forEach((entry: any) => {
const cipher = this.initLoginCipher();
if (!this.isNullOrWhitespace(entry.label)) {
cipher.name = entry.label.split('')[0];
cipher.name = entry.label.split("")[0];
}
if (entry.data != null && !this.isNullOrWhitespace(entry.data.notes)) {
cipher.notes = entry.data.notes.split('\\n').join('\n');
cipher.notes = entry.data.notes.split("\\n").join("\n");
}
if (entry.currentVersion != null && entry.currentVersion.fields != null) {
@@ -38,27 +38,34 @@ export class ClipperzHtmlImporter extends BaseImporter implements Importer {
const field = entry.currentVersion.fields[property];
const actionType = field.actionType != null ? field.actionType.toLowerCase() : null;
switch (actionType) {
case 'password':
case "password":
cipher.login.password = this.getValueOrDefault(field.value);
break;
case 'email':
case 'username':
case 'user':
case 'name':
case "email":
case "username":
case "user":
case "name":
cipher.login.username = this.getValueOrDefault(field.value);
break;
case 'url':
case "url":
cipher.login.uris = this.makeUriArray(field.value);
break;
default:
const labelLower = field.label != null ? field.label.toLowerCase() : null;
if (cipher.login.password == null && this.passwordFieldNames.indexOf(labelLower) > -1) {
if (
cipher.login.password == null &&
this.passwordFieldNames.indexOf(labelLower) > -1
) {
cipher.login.password = this.getValueOrDefault(field.value);
} else if (cipher.login.username == null &&
this.usernameFieldNames.indexOf(labelLower) > -1) {
} else if (
cipher.login.username == null &&
this.usernameFieldNames.indexOf(labelLower) > -1
) {
cipher.login.username = this.getValueOrDefault(field.value);
} else if ((cipher.login.uris == null || cipher.login.uris.length === 0) &&
this.uriFieldNames.indexOf(labelLower) > -1) {
} else if (
(cipher.login.uris == null || cipher.login.uris.length === 0) &&
this.uriFieldNames.indexOf(labelLower) > -1
) {
cipher.login.uris = this.makeUriArray(field.value);
} else {
this.processKvp(cipher, field.label, field.value);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class CodebookCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,12 +12,12 @@ export class CodebookCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
this.processFolder(result, this.getValueOrDefault(value.Category));
const cipher = this.initLoginCipher();
cipher.favorite = this.getValueOrDefault(value.Favorite) === 'True';
cipher.name = this.getValueOrDefault(value.Entry, '--');
cipher.favorite = this.getValueOrDefault(value.Favorite) === "True";
cipher.name = this.getValueOrDefault(value.Entry, "--");
cipher.notes = this.getValueOrDefault(value.Note);
cipher.login.username = this.getValueOrDefault(value.Username, value.Email);
cipher.login.password = this.getValueOrDefault(value.Password);
@@ -25,12 +25,12 @@ export class CodebookCsvImporter extends BaseImporter implements Importer {
cipher.login.uris = this.makeUriArray(value.Website);
if (!this.isNullOrWhitespace(value.Username)) {
this.processKvp(cipher, 'Email', value.Email);
this.processKvp(cipher, "Email", value.Email);
}
this.processKvp(cipher, 'Phone', value.Phone);
this.processKvp(cipher, 'PIN', value.PIN);
this.processKvp(cipher, 'Account', value.Account);
this.processKvp(cipher, 'Date', value.Date);
this.processKvp(cipher, "Phone", value.Phone);
this.processKvp(cipher, "PIN", value.PIN);
this.processKvp(cipher, "Account", value.Account);
this.processKvp(cipher, "Date", value.Date);
this.convertToNoteIfNeeded(cipher);
this.cleanupCipher(cipher);

View File

@@ -1,18 +1,26 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CardView } from '../models/view/cardView';
import { CipherView } from '../models/view/cipherView';
import { IdentityView } from '../models/view/identityView';
import { SecureNoteView } from '../models/view/secureNoteView';
import { CardView } from "../models/view/cardView";
import { CipherView } from "../models/view/cipherView";
import { IdentityView } from "../models/view/identityView";
import { SecureNoteView } from "../models/view/secureNoteView";
import { CipherType } from '../enums/cipherType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherType } from "../enums/cipherType";
import { SecureNoteType } from "../enums/secureNoteType";
const HandledResults = new Set(['ADDRESS', 'AUTHENTIFIANT', 'BANKSTATEMENT', 'IDCARD', 'IDENTITY',
'PAYMENTMEANS_CREDITCARD', 'PAYMENTMEAN_PAYPAL', 'EMAIL']);
const HandledResults = new Set([
"ADDRESS",
"AUTHENTIFIANT",
"BANKSTATEMENT",
"IDCARD",
"IDENTITY",
"PAYMENTMEANS_CREDITCARD",
"PAYMENTMEAN_PAYPAL",
"EMAIL",
]);
export class DashlaneJsonImporter extends BaseImporter implements Importer {
private result: ImportResult;
@@ -32,10 +40,10 @@ export class DashlaneJsonImporter extends BaseImporter implements Importer {
this.processAuth(results.AUTHENTIFIANT);
}
if (results.BANKSTATEMENT != null) {
this.processNote(results.BANKSTATEMENT, 'BankAccountName');
this.processNote(results.BANKSTATEMENT, "BankAccountName");
}
if (results.IDCARD != null) {
this.processNote(results.IDCARD, 'Fullname');
this.processNote(results.IDCARD, "Fullname");
}
if (results.PAYMENTMEANS_CREDITCARD != null) {
this.processCard(results.PAYMENTMEANS_CREDITCARD);
@@ -46,7 +54,7 @@ export class DashlaneJsonImporter extends BaseImporter implements Importer {
for (const key in results) {
if (results.hasOwnProperty(key) && !HandledResults.has(key)) {
this.processNote(results[key], null, 'Generic Note');
this.processNote(results[key], null, "Generic Note");
}
}
@@ -59,17 +67,19 @@ export class DashlaneJsonImporter extends BaseImporter implements Importer {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(credential.title);
cipher.login.username = this.getValueOrDefault(credential.login,
this.getValueOrDefault(credential.secondaryLogin));
cipher.login.username = this.getValueOrDefault(
credential.login,
this.getValueOrDefault(credential.secondaryLogin)
);
if (this.isNullOrWhitespace(cipher.login.username)) {
cipher.login.username = this.getValueOrDefault(credential.email);
} else if (!this.isNullOrWhitespace(credential.email)) {
cipher.notes = ('Email: ' + credential.email + '\n');
cipher.notes = "Email: " + credential.email + "\n";
}
cipher.login.password = this.getValueOrDefault(credential.password);
cipher.login.uris = this.makeUriArray(credential.domain);
cipher.notes += this.getValueOrDefault(credential.note, '');
cipher.notes += this.getValueOrDefault(credential.note, "");
this.convertToNoteIfNeeded(cipher);
this.cleanupCipher(cipher);
@@ -82,8 +92,8 @@ export class DashlaneJsonImporter extends BaseImporter implements Importer {
const cipher = new CipherView();
cipher.identity = new IdentityView();
cipher.type = CipherType.Identity;
cipher.name = this.getValueOrDefault(obj.fullName, '');
const nameParts = cipher.name.split(' ');
cipher.name = this.getValueOrDefault(obj.fullName, "");
const nameParts = cipher.name.split(" ");
if (nameParts.length > 0) {
cipher.identity.firstName = this.getValueOrDefault(nameParts[0]);
}
@@ -131,7 +141,7 @@ export class DashlaneJsonImporter extends BaseImporter implements Importer {
if (this.isNullOrWhitespace(cipher.name)) {
cipher.name = cipher.card.brand;
} else {
cipher.name += (' - ' + cipher.card.brand);
cipher.name += " - " + cipher.card.brand;
}
}
this.cleanupCipher(cipher);

View File

@@ -1,11 +1,11 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CardView } from '../models/view/cardView';
import { CardView } from "../models/view/cardView";
import { CipherType } from '../enums/cipherType';
import { CipherType } from "../enums/cipherType";
export class EncryptrCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -16,34 +16,34 @@ export class EncryptrCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.Label, '--');
cipher.name = this.getValueOrDefault(value.Label, "--");
cipher.notes = this.getValueOrDefault(value.Notes);
const text = this.getValueOrDefault(value.Text);
if (!this.isNullOrWhitespace(text)) {
if (this.isNullOrWhitespace(cipher.notes)) {
cipher.notes = text;
} else {
cipher.notes += ('\n\n' + text);
cipher.notes += "\n\n" + text;
}
}
const type = value['Entry Type'];
if (type === 'Password') {
const type = value["Entry Type"];
if (type === "Password") {
cipher.login.username = this.getValueOrDefault(value.Username);
cipher.login.password = this.getValueOrDefault(value.Password);
cipher.login.uris = this.makeUriArray(value['Site URL']);
} else if (type === 'Credit Card') {
cipher.login.uris = this.makeUriArray(value["Site URL"]);
} else if (type === "Credit Card") {
cipher.type = CipherType.Card;
cipher.card = new CardView();
cipher.card.cardholderName = this.getValueOrDefault(value['Name on card']);
cipher.card.number = this.getValueOrDefault(value['Card Number']);
cipher.card.cardholderName = this.getValueOrDefault(value["Name on card"]);
cipher.card.number = this.getValueOrDefault(value["Card Number"]);
cipher.card.brand = this.getCardBrand(cipher.card.number);
cipher.card.code = this.getValueOrDefault(value.CVV);
const expiry = this.getValueOrDefault(value.Expiry);
if (!this.isNullOrWhitespace(expiry)) {
const expParts = expiry.split('/');
const expParts = expiry.split("/");
if (expParts.length > 1) {
cipher.card.expMonth = parseInt(expParts[0], null).toString();
cipher.card.expYear = (2000 + parseInt(expParts[1], null)).toString();

View File

@@ -1,13 +1,13 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CipherType } from '../enums/cipherType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherType } from "../enums/cipherType";
import { SecureNoteType } from "../enums/secureNoteType";
import { CardView } from '../models/view/cardView';
import { SecureNoteView } from '../models/view/secureNoteView';
import { CardView } from "../models/view/cardView";
import { SecureNoteView } from "../models/view/secureNoteView";
export class EnpassCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -19,31 +19,38 @@ export class EnpassCsvImporter extends BaseImporter implements Importer {
}
let firstRow = true;
results.forEach(value => {
if (value.length < 2 || (firstRow && (value[0] === 'Title' || value[0] === 'title'))) {
results.forEach((value) => {
if (value.length < 2 || (firstRow && (value[0] === "Title" || value[0] === "title"))) {
firstRow = false;
return;
}
const cipher = this.initLoginCipher();
cipher.notes = this.getValueOrDefault(value[value.length - 1]);
cipher.name = this.getValueOrDefault(value[0], '--');
cipher.name = this.getValueOrDefault(value[0], "--");
if (value.length === 2 || (!this.containsField(value, 'username') &&
!this.containsField(value, 'password') && !this.containsField(value, 'email') &&
!this.containsField(value, 'url'))) {
if (
value.length === 2 ||
(!this.containsField(value, "username") &&
!this.containsField(value, "password") &&
!this.containsField(value, "email") &&
!this.containsField(value, "url"))
) {
cipher.type = CipherType.SecureNote;
cipher.secureNote = new SecureNoteView();
cipher.secureNote.type = SecureNoteType.Generic;
}
if (this.containsField(value, 'cardholder') && this.containsField(value, 'number') &&
this.containsField(value, 'expiry date')) {
if (
this.containsField(value, "cardholder") &&
this.containsField(value, "number") &&
this.containsField(value, "expiry date")
) {
cipher.type = CipherType.Card;
cipher.card = new CardView();
}
if (value.length > 2 && (value.length % 2) === 0) {
if (value.length > 2 && value.length % 2 === 0) {
for (let i = 0; i < value.length - 2; i += 2) {
const fieldValue: string = value[i + 2];
if (this.isNullOrWhitespace(fieldValue)) {
@@ -54,37 +61,51 @@ export class EnpassCsvImporter extends BaseImporter implements Importer {
const fieldNameLower = fieldName.toLowerCase();
if (cipher.type === CipherType.Login) {
if (fieldNameLower === 'url' && (cipher.login.uris == null || cipher.login.uris.length === 0)) {
if (
fieldNameLower === "url" &&
(cipher.login.uris == null || cipher.login.uris.length === 0)
) {
cipher.login.uris = this.makeUriArray(fieldValue);
continue;
} else if ((fieldNameLower === 'username' || fieldNameLower === 'email') &&
this.isNullOrWhitespace(cipher.login.username)) {
} else if (
(fieldNameLower === "username" || fieldNameLower === "email") &&
this.isNullOrWhitespace(cipher.login.username)
) {
cipher.login.username = fieldValue;
continue;
} else if (fieldNameLower === 'password' && this.isNullOrWhitespace(cipher.login.password)) {
} else if (
fieldNameLower === "password" &&
this.isNullOrWhitespace(cipher.login.password)
) {
cipher.login.password = fieldValue;
continue;
} else if (fieldNameLower === 'totp' && this.isNullOrWhitespace(cipher.login.totp)) {
} else if (fieldNameLower === "totp" && this.isNullOrWhitespace(cipher.login.totp)) {
cipher.login.totp = fieldValue;
continue;
}
} else if (cipher.type === CipherType.Card) {
if (fieldNameLower === 'cardholder' && this.isNullOrWhitespace(cipher.card.cardholderName)) {
if (
fieldNameLower === "cardholder" &&
this.isNullOrWhitespace(cipher.card.cardholderName)
) {
cipher.card.cardholderName = fieldValue;
continue;
} else if (fieldNameLower === 'number' && this.isNullOrWhitespace(cipher.card.number)) {
} else if (fieldNameLower === "number" && this.isNullOrWhitespace(cipher.card.number)) {
cipher.card.number = fieldValue;
cipher.card.brand = this.getCardBrand(fieldValue);
continue;
} else if (fieldNameLower === 'cvc' && this.isNullOrWhitespace(cipher.card.code)) {
} else if (fieldNameLower === "cvc" && this.isNullOrWhitespace(cipher.card.code)) {
cipher.card.code = fieldValue;
continue;
} else if (fieldNameLower === 'expiry date' && this.isNullOrWhitespace(cipher.card.expMonth) &&
this.isNullOrWhitespace(cipher.card.expYear)) {
} else if (
fieldNameLower === "expiry date" &&
this.isNullOrWhitespace(cipher.card.expMonth) &&
this.isNullOrWhitespace(cipher.card.expYear)
) {
if (this.setCardExpiration(cipher, fieldValue)) {
continue;
}
} else if (fieldNameLower === 'type') {
} else if (fieldNameLower === "type") {
// Skip since brand was determined from number above
continue;
}
@@ -106,7 +127,9 @@ export class EnpassCsvImporter extends BaseImporter implements Importer {
if (fields == null || name == null) {
return false;
}
return fields.filter(f => !this.isNullOrWhitespace(f) &&
f.toLowerCase() === name.toLowerCase()).length > 0;
return (
fields.filter((f) => !this.isNullOrWhitespace(f) && f.toLowerCase() === name.toLowerCase())
.length > 0
);
}
}

View File

@@ -1,14 +1,14 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CardView } from '../models/view/cardView';
import { CipherView } from '../models/view/cipherView';
import { FolderView } from '../models/view/folderView';
import { CardView } from "../models/view/cardView";
import { CipherView } from "../models/view/cipherView";
import { FolderView } from "../models/view/folderView";
import { CipherType } from '../enums/cipherType';
import { FieldType } from '../enums/fieldType';
import { CipherType } from "../enums/cipherType";
import { FieldType } from "../enums/fieldType";
export class EnpassJsonImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -32,7 +32,10 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
results.items.forEach((item: any) => {
if (item.folders != null && item.folders.length > 0 && foldersIndexMap.has(item.folders[0])) {
result.folderRelationships.push([result.ciphers.length, foldersIndexMap.get(item.folders[0])]);
result.folderRelationships.push([
result.ciphers.length,
foldersIndexMap.get(item.folders[0]),
]);
}
const cipher = this.initLoginCipher();
@@ -40,19 +43,24 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
cipher.favorite = item.favorite > 0;
if (item.template_type != null && item.fields != null && item.fields.length > 0) {
if (item.template_type.indexOf('login.') === 0 || item.template_type.indexOf('password.') === 0) {
if (
item.template_type.indexOf("login.") === 0 ||
item.template_type.indexOf("password.") === 0
) {
this.processLogin(cipher, item.fields);
} else if (item.template_type.indexOf('creditcard.') === 0) {
} else if (item.template_type.indexOf("creditcard.") === 0) {
this.processCard(cipher, item.fields);
} else if (item.template_type.indexOf('identity.') < 0 &&
item.fields.some((f: any) => f.type === 'password' && !this.isNullOrWhitespace(f.value))) {
} else if (
item.template_type.indexOf("identity.") < 0 &&
item.fields.some((f: any) => f.type === "password" && !this.isNullOrWhitespace(f.value))
) {
this.processLogin(cipher, item.fields);
} else {
this.processNote(cipher, item.fields);
}
}
cipher.notes += ('\n' + this.getValueOrDefault(item.note, ''));
cipher.notes += "\n" + this.getValueOrDefault(item.note, "");
this.convertToNoteIfNeeded(cipher);
this.cleanupCipher(cipher);
result.ciphers.push(cipher);
@@ -65,22 +73,28 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
private processLogin(cipher: CipherView, fields: any[]) {
const urls: string[] = [];
fields.forEach((field: any) => {
if (this.isNullOrWhitespace(field.value) || field.type === 'section') {
if (this.isNullOrWhitespace(field.value) || field.type === "section") {
return;
}
if ((field.type === 'username' || field.type === 'email') &&
this.isNullOrWhitespace(cipher.login.username)) {
if (
(field.type === "username" || field.type === "email") &&
this.isNullOrWhitespace(cipher.login.username)
) {
cipher.login.username = field.value;
} else if (field.type === 'password' && this.isNullOrWhitespace(cipher.login.password)) {
} else if (field.type === "password" && this.isNullOrWhitespace(cipher.login.password)) {
cipher.login.password = field.value;
} else if (field.type === 'totp' && this.isNullOrWhitespace(cipher.login.totp)) {
} else if (field.type === "totp" && this.isNullOrWhitespace(cipher.login.totp)) {
cipher.login.totp = field.value;
} else if (field.type === 'url') {
} else if (field.type === "url") {
urls.push(field.value);
} else {
this.processKvp(cipher, field.label, field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
this.processKvp(
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
);
}
});
cipher.login.uris = this.makeUriArray(urls);
@@ -90,36 +104,52 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
cipher.card = new CardView();
cipher.type = CipherType.Card;
fields.forEach((field: any) => {
if (this.isNullOrWhitespace(field.value) || field.type === 'section' || field.type === 'ccType') {
if (
this.isNullOrWhitespace(field.value) ||
field.type === "section" ||
field.type === "ccType"
) {
return;
}
if (field.type === 'ccName' && this.isNullOrWhitespace(cipher.card.cardholderName)) {
if (field.type === "ccName" && this.isNullOrWhitespace(cipher.card.cardholderName)) {
cipher.card.cardholderName = field.value;
} else if (field.type === 'ccNumber' && this.isNullOrWhitespace(cipher.card.number)) {
} else if (field.type === "ccNumber" && this.isNullOrWhitespace(cipher.card.number)) {
cipher.card.number = field.value;
cipher.card.brand = this.getCardBrand(cipher.card.number);
} else if (field.type === 'ccCvc' && this.isNullOrWhitespace(cipher.card.code)) {
} else if (field.type === "ccCvc" && this.isNullOrWhitespace(cipher.card.code)) {
cipher.card.code = field.value;
} else if (field.type === 'ccExpiry' && this.isNullOrWhitespace(cipher.card.expYear)) {
} else if (field.type === "ccExpiry" && this.isNullOrWhitespace(cipher.card.expYear)) {
if (!this.setCardExpiration(cipher, field.value)) {
this.processKvp(cipher, field.label, field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
this.processKvp(
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
);
}
} else {
this.processKvp(cipher, field.label, field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
this.processKvp(
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
);
}
});
}
private processNote(cipher: CipherView, fields: any[]) {
fields.forEach((field: any) => {
if (this.isNullOrWhitespace(field.value) || field.type === 'section') {
if (this.isNullOrWhitespace(field.value) || field.type === "section") {
return;
}
this.processKvp(cipher, field.label, field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text);
this.processKvp(
cipher,
field.label,
field.value,
field.sensitive === 1 ? FieldType.Hidden : FieldType.Text
);
});
}
@@ -134,7 +164,7 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
obj.children = [];
});
folders.forEach((obj: any) => {
if (obj.parent_uuid != null && obj.parent_uuid !== '' && map.has(obj.parent_uuid)) {
if (obj.parent_uuid != null && obj.parent_uuid !== "" && map.has(obj.parent_uuid)) {
map.get(obj.parent_uuid).children.push(obj);
} else {
folderTree.push(obj);
@@ -148,10 +178,10 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
return;
}
tree.forEach((f: any) => {
if (f.title != null && f.title.trim() !== '') {
if (f.title != null && f.title.trim() !== "") {
let title = f.title.trim();
if (titlePrefix != null && titlePrefix.trim() !== '') {
title = titlePrefix + '/' + title;
if (titlePrefix != null && titlePrefix.trim() !== "") {
title = titlePrefix + "/" + title;
}
map.set(f.uuid, title);
if (f.children != null && f.children.length !== 0) {

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class FirefoxCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,12 +12,14 @@ export class FirefoxCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.filter(value => {
return value.url !== 'chrome://FirefoxAccounts';
}).forEach(value => {
results
.filter((value) => {
return value.url !== "chrome://FirefoxAccounts";
})
.forEach((value) => {
const cipher = this.initLoginCipher();
const url = this.getValueOrDefault(value.url, this.getValueOrDefault(value.hostname));
cipher.name = this.getValueOrDefault(this.nameFromUrl(url), '--');
cipher.name = this.getValueOrDefault(this.nameFromUrl(url), "--");
cipher.login.username = this.getValueOrDefault(value.username);
cipher.login.password = this.getValueOrDefault(value.password);
cipher.login.uris = this.makeUriArray(url);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class GnomeJsonImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -13,19 +13,25 @@ export class GnomeJsonImporter extends BaseImporter implements Importer {
}
for (const keyRing in results) {
if (!results.hasOwnProperty(keyRing) || this.isNullOrWhitespace(keyRing) ||
results[keyRing].length === 0) {
if (
!results.hasOwnProperty(keyRing) ||
this.isNullOrWhitespace(keyRing) ||
results[keyRing].length === 0
) {
continue;
}
results[keyRing].forEach((value: any) => {
if (this.isNullOrWhitespace(value.display_name) || value.display_name.indexOf('http') !== 0) {
if (
this.isNullOrWhitespace(value.display_name) ||
value.display_name.indexOf("http") !== 0
) {
return;
}
this.processFolder(result, keyRing);
const cipher = this.initLoginCipher();
cipher.name = value.display_name.replace('http://', '').replace('https://', '');
cipher.name = value.display_name.replace("http://", "").replace("https://", "");
if (cipher.name.length > 30) {
cipher.name = cipher.name.substring(0, 30);
}
@@ -33,11 +39,16 @@ export class GnomeJsonImporter extends BaseImporter implements Importer {
cipher.login.uris = this.makeUriArray(value.display_name);
if (value.attributes != null) {
cipher.login.username = value.attributes != null ?
this.getValueOrDefault(value.attributes.username_value) : null;
cipher.login.username =
value.attributes != null
? this.getValueOrDefault(value.attributes.username_value)
: null;
for (const attr in value.attributes) {
if (!value.attributes.hasOwnProperty(attr) || attr === 'username_value' ||
attr === 'xdg:schema') {
if (
!value.attributes.hasOwnProperty(attr) ||
attr === "username_value" ||
attr === "xdg:schema"
) {
continue;
}
this.processKvp(cipher, attr, value.attributes[attr]);

View File

@@ -1,4 +1,4 @@
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export interface Importer {
organizationId: string;

View File

@@ -1,12 +1,12 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
const NotesHeader = 'Notes\n\n';
const ApplicationsHeader = 'Applications\n\n';
const WebsitesHeader = 'Websites\n\n';
const Delimiter = '\n---\n';
const NotesHeader = "Notes\n\n";
const ApplicationsHeader = "Applications\n\n";
const WebsitesHeader = "Websites\n\n";
const Delimiter = "\n---\n";
export class KasperskyTxtImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -15,7 +15,7 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
let notesData: string;
let applicationsData: string;
let websitesData: string;
let workingData = this.splitNewLine(data).join('\n');
let workingData = this.splitNewLine(data).join("\n");
if (workingData.indexOf(NotesHeader) !== -1) {
const parts = workingData.split(NotesHeader);
@@ -43,30 +43,30 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
const applications = this.parseDataCategory(applicationsData);
const websites = this.parseDataCategory(websitesData);
notes.forEach(n => {
notes.forEach((n) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(n.get('Name'));
cipher.notes = this.getValueOrDefault(n.get('Text'));
cipher.name = this.getValueOrDefault(n.get("Name"));
cipher.notes = this.getValueOrDefault(n.get("Text"));
this.cleanupCipher(cipher);
result.ciphers.push(cipher);
});
websites.concat(applications).forEach(w => {
websites.concat(applications).forEach((w) => {
const cipher = this.initLoginCipher();
const nameKey = w.has('Website name') ? 'Website name' : 'Application';
cipher.name = this.getValueOrDefault(w.get(nameKey), '');
if (!this.isNullOrWhitespace(w.get('Login name'))) {
const nameKey = w.has("Website name") ? "Website name" : "Application";
cipher.name = this.getValueOrDefault(w.get(nameKey), "");
if (!this.isNullOrWhitespace(w.get("Login name"))) {
if (!this.isNullOrWhitespace(cipher.name)) {
cipher.name += ': ';
cipher.name += ": ";
}
cipher.name += w.get('Login name');
cipher.name += w.get("Login name");
}
cipher.notes = this.getValueOrDefault(w.get('Comment'));
if (w.has('Website URL')) {
cipher.login.uris = this.makeUriArray(w.get('Website URL'));
cipher.notes = this.getValueOrDefault(w.get("Comment"));
if (w.has("Website URL")) {
cipher.login.uris = this.makeUriArray(w.get("Website URL"));
}
cipher.login.username = this.getValueOrDefault(w.get('Login'));
cipher.login.password = this.getValueOrDefault(w.get('Password'));
cipher.login.username = this.getValueOrDefault(w.get("Login"));
cipher.login.password = this.getValueOrDefault(w.get("Password"));
this.cleanupCipher(cipher);
result.ciphers.push(cipher);
});
@@ -80,19 +80,19 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
return [];
}
const items: Map<string, string>[] = [];
data.split(Delimiter).forEach(p => {
if (p.indexOf('\n') === -1) {
data.split(Delimiter).forEach((p) => {
if (p.indexOf("\n") === -1) {
return;
}
const item = new Map<string, string>();
let itemComment: string;
let itemCommentKey: string;
p.split('\n').forEach(l => {
p.split("\n").forEach((l) => {
if (itemComment != null) {
itemComment += ('\n' + l);
itemComment += "\n" + l;
return;
}
const colonIndex = l.indexOf(':');
const colonIndex = l.indexOf(":");
let key: string;
let val: string;
if (colonIndex === -1) {
@@ -106,7 +106,7 @@ export class KasperskyTxtImporter extends BaseImporter implements Importer {
if (key != null) {
item.set(key, val);
}
if (key === 'Comment' || key === 'Text') {
if (key === "Comment" || key === "Text") {
itemComment = val;
itemCommentKey = key;
}

View File

@@ -1,11 +1,11 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { FieldType } from '../enums/fieldType';
import { FieldType } from "../enums/fieldType";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { FolderView } from '../models/view/folderView';
import { FolderView } from "../models/view/folderView";
export class KeePass2XmlImporter extends BaseImporter implements Importer {
result = new ImportResult();
@@ -17,14 +17,14 @@ export class KeePass2XmlImporter extends BaseImporter implements Importer {
return Promise.resolve(this.result);
}
const rootGroup = doc.querySelector('KeePassFile > Root > Group');
const rootGroup = doc.querySelector("KeePassFile > Root > Group");
if (rootGroup == null) {
this.result.errorMessage = 'Missing `KeePassFile > Root > Group` node.';
this.result.errorMessage = "Missing `KeePassFile > Root > Group` node.";
this.result.success = false;
return Promise.resolve(this.result);
}
this.traverse(rootGroup, true, '');
this.traverse(rootGroup, true, "");
if (this.organization) {
this.moveFoldersToCollections(this.result);
@@ -39,46 +39,49 @@ export class KeePass2XmlImporter extends BaseImporter implements Importer {
let groupName = groupPrefixName;
if (!isRootNode) {
if (groupName !== '') {
groupName += '/';
if (groupName !== "") {
groupName += "/";
}
const nameEl = this.querySelectorDirectChild(node, 'Name');
groupName += nameEl == null ? '-' : nameEl.textContent;
const nameEl = this.querySelectorDirectChild(node, "Name");
groupName += nameEl == null ? "-" : nameEl.textContent;
const folder = new FolderView();
folder.name = groupName;
this.result.folders.push(folder);
}
this.querySelectorAllDirectChild(node, 'Entry').forEach(entry => {
this.querySelectorAllDirectChild(node, "Entry").forEach((entry) => {
const cipherIndex = this.result.ciphers.length;
const cipher = this.initLoginCipher();
this.querySelectorAllDirectChild(entry, 'String').forEach(entryString => {
const valueEl = this.querySelectorDirectChild(entryString, 'Value');
this.querySelectorAllDirectChild(entry, "String").forEach((entryString) => {
const valueEl = this.querySelectorDirectChild(entryString, "Value");
const value = valueEl != null ? valueEl.textContent : null;
if (this.isNullOrWhitespace(value)) {
return;
}
const keyEl = this.querySelectorDirectChild(entryString, 'Key');
const keyEl = this.querySelectorDirectChild(entryString, "Key");
const key = keyEl != null ? keyEl.textContent : null;
if (key === 'URL') {
if (key === "URL") {
cipher.login.uris = this.makeUriArray(value);
} else if (key === 'UserName') {
} else if (key === "UserName") {
cipher.login.username = value;
} else if (key === 'Password') {
} else if (key === "Password") {
cipher.login.password = value;
} else if (key === 'otp') {
cipher.login.totp = value.replace('key=', '');
} else if (key === 'Title') {
} else if (key === "otp") {
cipher.login.totp = value.replace("key=", "");
} else if (key === "Title") {
cipher.name = value;
} else if (key === 'Notes') {
cipher.notes += (value + '\n');
} else if (key === "Notes") {
cipher.notes += value + "\n";
} else {
let type = FieldType.Text;
const attrs = (valueEl.attributes as any);
if (attrs.length > 0 && attrs.ProtectInMemory != null &&
attrs.ProtectInMemory.value === 'True') {
const attrs = valueEl.attributes as any;
if (
attrs.length > 0 &&
attrs.ProtectInMemory != null &&
attrs.ProtectInMemory.value === "True"
) {
type = FieldType.Hidden;
}
this.processKvp(cipher, key, value, type);
@@ -93,7 +96,7 @@ export class KeePass2XmlImporter extends BaseImporter implements Importer {
}
});
this.querySelectorAllDirectChild(node, 'Group').forEach(group => {
this.querySelectorAllDirectChild(node, "Group").forEach((group) => {
this.traverse(group, false, groupName);
});
}

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class KeePassXCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,19 +12,21 @@ export class KeePassXCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
if (this.isNullOrWhitespace(value.Title)) {
return;
}
value.Group = !this.isNullOrWhitespace(value.Group) && value.Group.startsWith('Root/') ?
value.Group.replace('Root/', '') : value.Group;
value.Group =
!this.isNullOrWhitespace(value.Group) && value.Group.startsWith("Root/")
? value.Group.replace("Root/", "")
: value.Group;
const groupName = !this.isNullOrWhitespace(value.Group) ? value.Group : null;
this.processFolder(result, groupName);
const cipher = this.initLoginCipher();
cipher.notes = this.getValueOrDefault(value.Notes);
cipher.name = this.getValueOrDefault(value.Title, '--');
cipher.name = this.getValueOrDefault(value.Title, "--");
cipher.login.username = this.getValueOrDefault(value.Username);
cipher.login.password = this.getValueOrDefault(value.Password);
cipher.login.uris = this.makeUriArray(value.URL);

View File

@@ -1,9 +1,9 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { FolderView } from '../models/view/folderView';
import { FolderView } from "../models/view/folderView";
export class KeeperCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -14,15 +14,15 @@ export class KeeperCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
if (value.length < 6) {
return;
}
this.processFolder(result, value[0]);
const cipher = this.initLoginCipher();
cipher.notes = this.getValueOrDefault(value[5]) + '\n';
cipher.name = this.getValueOrDefault(value[1], '--');
cipher.notes = this.getValueOrDefault(value[5]) + "\n";
cipher.name = this.getValueOrDefault(value[1], "--");
cipher.login.username = this.getValueOrDefault(value[2]);
cipher.login.password = this.getValueOrDefault(value[3]);
cipher.login.uris = this.makeUriArray(value[4]);

View File

@@ -1,17 +1,17 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CardView } from '../models/view/cardView';
import { CipherView } from '../models/view/cipherView';
import { FolderView } from '../models/view/folderView';
import { IdentityView } from '../models/view/identityView';
import { LoginView } from '../models/view/loginView';
import { SecureNoteView } from '../models/view/secureNoteView';
import { CardView } from "../models/view/cardView";
import { CipherView } from "../models/view/cipherView";
import { FolderView } from "../models/view/folderView";
import { IdentityView } from "../models/view/identityView";
import { LoginView } from "../models/view/loginView";
import { SecureNoteView } from "../models/view/secureNoteView";
import { CipherType } from '../enums/cipherType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherType } from "../enums/cipherType";
import { SecureNoteType } from "../enums/secureNoteType";
export class LastPassCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -27,9 +27,9 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
let folderIndex = result.folders.length;
let grouping = value.grouping;
if (grouping != null) {
grouping = grouping.replace(/\\/g, '/').replace(/[\x00-\x1F\x7F-\x9F]/g, '');
grouping = grouping.replace(/\\/g, "/").replace(/[\x00-\x1F\x7F-\x9F]/g, "");
}
const hasFolder = this.getValueOrDefault(grouping, '(none)') !== '(none)';
const hasFolder = this.getValueOrDefault(grouping, "(none)") !== "(none)";
let addFolder = hasFolder;
if (hasFolder) {
@@ -90,23 +90,28 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
private buildBaseCipher(value: any) {
const cipher = new CipherView();
if (value.hasOwnProperty('profilename') && value.hasOwnProperty('profilelanguage')) {
if (value.hasOwnProperty("profilename") && value.hasOwnProperty("profilelanguage")) {
// form fill
cipher.favorite = false;
cipher.name = this.getValueOrDefault(value.profilename, '--');
cipher.name = this.getValueOrDefault(value.profilename, "--");
cipher.type = CipherType.Card;
if (!this.isNullOrWhitespace(value.title) || !this.isNullOrWhitespace(value.firstname) ||
!this.isNullOrWhitespace(value.lastname) || !this.isNullOrWhitespace(value.address1) ||
!this.isNullOrWhitespace(value.phone) || !this.isNullOrWhitespace(value.username) ||
!this.isNullOrWhitespace(value.email)) {
if (
!this.isNullOrWhitespace(value.title) ||
!this.isNullOrWhitespace(value.firstname) ||
!this.isNullOrWhitespace(value.lastname) ||
!this.isNullOrWhitespace(value.address1) ||
!this.isNullOrWhitespace(value.phone) ||
!this.isNullOrWhitespace(value.username) ||
!this.isNullOrWhitespace(value.email)
) {
cipher.type = CipherType.Identity;
}
} else {
// site or secure note
cipher.favorite = !this.organization && this.getValueOrDefault(value.fav, '0') === '1';
cipher.name = this.getValueOrDefault(value.name, '--');
cipher.type = value.url === 'http://sn' ? CipherType.SecureNote : CipherType.Login;
cipher.favorite = !this.organization && this.getValueOrDefault(value.fav, "0") === "1";
cipher.name = this.getValueOrDefault(value.name, "--");
cipher.type = value.url === "http://sn" ? CipherType.SecureNote : CipherType.Login;
}
return cipher;
}
@@ -118,12 +123,12 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
card.code = this.getValueOrDefault(value.cccsc);
card.brand = this.getCardBrand(value.ccnum);
if (!this.isNullOrWhitespace(value.ccexp) && value.ccexp.indexOf('-') > -1) {
const ccexpParts = (value.ccexp as string).split('-');
if (!this.isNullOrWhitespace(value.ccexp) && value.ccexp.indexOf("-") > -1) {
const ccexpParts = (value.ccexp as string).split("-");
if (ccexpParts.length > 1) {
card.expYear = ccexpParts[0];
card.expMonth = ccexpParts[1];
if (card.expMonth.length === 2 && card.expMonth[0] === '0') {
if (card.expMonth.length === 2 && card.expMonth[0] === "0") {
card.expMonth = card.expMonth[1];
}
}
@@ -163,27 +168,30 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
let processedNote = false;
if (extraParts.length) {
const typeParts = extraParts[0].split(':');
if (typeParts.length > 1 && typeParts[0] === 'NoteType' &&
(typeParts[1] === 'Credit Card' || typeParts[1] === 'Address')) {
if (typeParts[1] === 'Credit Card') {
const typeParts = extraParts[0].split(":");
if (
typeParts.length > 1 &&
typeParts[0] === "NoteType" &&
(typeParts[1] === "Credit Card" || typeParts[1] === "Address")
) {
if (typeParts[1] === "Credit Card") {
const mappedData = this.parseSecureNoteMapping<CardView>(cipher, extraParts, {
'Number': 'number',
'Name on Card': 'cardholderName',
'Security Code': 'code',
Number: "number",
"Name on Card": "cardholderName",
"Security Code": "code",
// LP provides date in a format like 'June,2020'
// Store in expMonth, then parse and modify
'Expiration Date': 'expMonth',
"Expiration Date": "expMonth",
});
if (this.isNullOrWhitespace(mappedData.expMonth) || mappedData.expMonth === ',') {
if (this.isNullOrWhitespace(mappedData.expMonth) || mappedData.expMonth === ",") {
// No expiration data
mappedData.expMonth = undefined;
} else {
const [monthString, year] = mappedData.expMonth.split(',');
const [monthString, year] = mappedData.expMonth.split(",");
// Parse month name into number
if (!this.isNullOrWhitespace(monthString)) {
const month = new Date(Date.parse(monthString.trim() + ' 1, 2012')).getMonth() + 1;
const month = new Date(Date.parse(monthString.trim() + " 1, 2012")).getMonth() + 1;
if (isNaN(month)) {
mappedData.expMonth = undefined;
} else {
@@ -199,22 +207,22 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
cipher.type = CipherType.Card;
cipher.card = mappedData;
} else if (typeParts[1] === 'Address') {
} else if (typeParts[1] === "Address") {
const mappedData = this.parseSecureNoteMapping<IdentityView>(cipher, extraParts, {
'Title': 'title',
'First Name': 'firstName',
'Last Name': 'lastName',
'Middle Name': 'middleName',
'Company': 'company',
'Address 1': 'address1',
'Address 2': 'address2',
'Address 3': 'address3',
'City / Town': 'city',
'State': 'state',
'Zip / Postal Code': 'postalCode',
'Country': 'country',
'Email Address': 'email',
'Username': 'username',
Title: "title",
"First Name": "firstName",
"Last Name": "lastName",
"Middle Name": "middleName",
Company: "company",
"Address 1": "address1",
"Address 2": "address2",
"Address 3": "address3",
"City / Town": "city",
State: "state",
"Zip / Postal Code": "postalCode",
Country: "country",
"Email Address": "email",
Username: "username",
});
cipher.type = CipherType.Identity;
cipher.identity = mappedData;
@@ -234,14 +242,14 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
const dataObj: any = {};
let processingNotes = false;
extraParts.forEach(extraPart => {
extraParts.forEach((extraPart) => {
let key: string = null;
let val: string = null;
if (!processingNotes) {
if (this.isNullOrWhitespace(extraPart)) {
return;
}
const colonIndex = extraPart.indexOf(':');
const colonIndex = extraPart.indexOf(":");
if (colonIndex === -1) {
key = extraPart;
} else {
@@ -250,16 +258,16 @@ export class LastPassCsvImporter extends BaseImporter implements Importer {
val = extraPart.substring(colonIndex + 1);
}
}
if (this.isNullOrWhitespace(key) || this.isNullOrWhitespace(val) || key === 'NoteType') {
if (this.isNullOrWhitespace(key) || this.isNullOrWhitespace(val) || key === "NoteType") {
return;
}
}
if (processingNotes) {
cipher.notes += ('\n' + extraPart);
} else if (key === 'Notes') {
cipher.notes += "\n" + extraPart;
} else if (key === "Notes") {
if (!this.isNullOrWhitespace(cipher.notes)) {
cipher.notes += ('\n' + val);
cipher.notes += "\n" + val;
} else {
cipher.notes = val;
}

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class LogMeOnceCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,12 +12,12 @@ export class LogMeOnceCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
if (value.length < 4) {
return;
}
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value[0], '--');
cipher.name = this.getValueOrDefault(value[0], "--");
cipher.login.username = this.getValueOrDefault(value[2]);
cipher.login.password = this.getValueOrDefault(value[3]);
cipher.login.uris = this.makeUriArray(value[1]);

View File

@@ -1,7 +1,7 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class MeldiumCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -12,9 +12,9 @@ export class MeldiumCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.DisplayName, '--');
cipher.name = this.getValueOrDefault(value.DisplayName, "--");
cipher.notes = this.getValueOrDefault(value.Notes);
cipher.login.username = this.getValueOrDefault(value.UserName);
cipher.login.password = this.getValueOrDefault(value.Password);

View File

@@ -1,12 +1,12 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CipherType } from '../enums/cipherType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherType } from "../enums/cipherType";
import { SecureNoteType } from "../enums/secureNoteType";
import { SecureNoteView } from '../models/view/secureNoteView';
import { SecureNoteView } from "../models/view/secureNoteView";
export class MSecureCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -17,35 +17,36 @@ export class MSecureCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
if (value.length < 3) {
return;
}
const folderName = this.getValueOrDefault(value[0], 'Unassigned') !== 'Unassigned' ? value[0] : null;
const folderName =
this.getValueOrDefault(value[0], "Unassigned") !== "Unassigned" ? value[0] : null;
this.processFolder(result, folderName);
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value[2], '--');
cipher.name = this.getValueOrDefault(value[2], "--");
if (value[1] === 'Web Logins' || value[1] === 'Login') {
if (value[1] === "Web Logins" || value[1] === "Login") {
cipher.login.uris = this.makeUriArray(value[4]);
cipher.login.username = this.getValueOrDefault(value[5]);
cipher.login.password = this.getValueOrDefault(value[6]);
cipher.notes = !this.isNullOrWhitespace(value[3]) ? value[3].split('\\n').join('\n') : null;
cipher.notes = !this.isNullOrWhitespace(value[3]) ? value[3].split("\\n").join("\n") : null;
} else if (value.length > 3) {
cipher.type = CipherType.SecureNote;
cipher.secureNote = new SecureNoteView();
cipher.secureNote.type = SecureNoteType.Generic;
for (let i = 3; i < value.length; i++) {
if (!this.isNullOrWhitespace(value[i])) {
cipher.notes += (value[i] + '\n');
cipher.notes += value[i] + "\n";
}
}
}
if (!this.isNullOrWhitespace(value[1]) && cipher.type !== CipherType.Login) {
cipher.name = value[1] + ': ' + cipher.name;
cipher.name = value[1] + ": " + cipher.name;
}
this.cleanupCipher(cipher);

View File

@@ -1,14 +1,14 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { CipherType } from '../enums/cipherType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherType } from "../enums/cipherType";
import { SecureNoteType } from "../enums/secureNoteType";
import { CardView } from '../models/view/cardView';
import { IdentityView } from '../models/view/identityView';
import { SecureNoteView } from '../models/view/secureNoteView';
import { CardView } from "../models/view/cardView";
import { IdentityView } from "../models/view/identityView";
import { SecureNoteView } from "../models/view/secureNoteView";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
export class MykiCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -19,9 +19,9 @@ export class MykiCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(value => {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.nickname, '--');
cipher.name = this.getValueOrDefault(value.nickname, "--");
cipher.notes = this.getValueOrDefault(value.additionalInfo);
if (value.url !== undefined) {
@@ -60,7 +60,7 @@ export class MykiCsvImporter extends BaseImporter implements Importer {
cipher.secureNote = new SecureNoteView();
cipher.type = CipherType.SecureNote;
cipher.secureNote.type = SecureNoteType.Generic;
cipher.name = this.getValueOrDefault(value.title, '--');
cipher.name = this.getValueOrDefault(value.title, "--");
cipher.notes = this.getValueOrDefault(value.content);
} else {
return;

View File

@@ -1,13 +1,13 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CipherView } from '../models/view/cipherView';
import { LoginView } from '../models/view/loginView';
import { CipherView } from "../models/view/cipherView";
import { LoginView } from "../models/view/loginView";
import { CipherType } from '../enums/cipherType';
import { SecureNoteType } from '../enums/secureNoteType';
import { CipherType } from "../enums/cipherType";
import { SecureNoteType } from "../enums/secureNoteType";
type nodePassCsvParsed = {
name: string;
@@ -40,8 +40,7 @@ export class NordPassCsvImporter extends BaseImporter implements Importer {
return Promise.resolve(result);
}
results.forEach(record => {
results.forEach((record) => {
const recordType = this.evaluateType(record);
if (recordType === undefined) {
return;
@@ -52,7 +51,7 @@ export class NordPassCsvImporter extends BaseImporter implements Importer {
}
const cipher = new CipherView();
cipher.name = this.getValueOrDefault(record.name, '--');
cipher.name = this.getValueOrDefault(record.name, "--");
cipher.notes = this.getValueOrDefault(record.note);
switch (recordType) {
@@ -109,7 +108,6 @@ export class NordPassCsvImporter extends BaseImporter implements Importer {
}
private evaluateType(record: nodePassCsvParsed): CipherType {
if (!this.isNullOrWhitespace(record.username)) {
return CipherType.Login;
}
@@ -130,12 +128,11 @@ export class NordPassCsvImporter extends BaseImporter implements Importer {
}
private processName(cipher: CipherView, fullName: string) {
if (this.isNullOrWhitespace(fullName)) {
return;
}
const nameParts = fullName.split(' ');
const nameParts = fullName.split(" ");
if (nameParts.length > 0) {
cipher.identity.firstName = this.getValueOrDefault(nameParts[0]);
}
@@ -143,7 +140,7 @@ export class NordPassCsvImporter extends BaseImporter implements Importer {
cipher.identity.lastName = this.getValueOrDefault(nameParts[1]);
} else if (nameParts.length >= 3) {
cipher.identity.middleName = this.getValueOrDefault(nameParts[1]);
cipher.identity.lastName = nameParts.slice(2, nameParts.length).join(' ');
cipher.identity.lastName = nameParts.slice(2, nameParts.length).join(" ");
}
}
}

View File

@@ -1,4 +1,4 @@
import { CipherView } from '../../models/view/cipherView';
import { CipherView } from "../../models/view/cipherView";
export class CipherImportContext {
lowerProperty: string;

View File

@@ -1,24 +1,24 @@
import { BaseImporter } from '../baseImporter';
import { Importer } from '../importer';
import { BaseImporter } from "../baseImporter";
import { Importer } from "../importer";
import { ImportResult } from '../../models/domain/importResult';
import { ImportResult } from "../../models/domain/importResult";
import { CardView } from '../../models/view/cardView';
import { CipherView } from '../../models/view/cipherView';
import { IdentityView } from '../../models/view/identityView';
import { PasswordHistoryView } from '../../models/view/passwordHistoryView';
import { SecureNoteView } from '../../models/view/secureNoteView';
import { CardView } from "../../models/view/cardView";
import { CipherView } from "../../models/view/cipherView";
import { IdentityView } from "../../models/view/identityView";
import { PasswordHistoryView } from "../../models/view/passwordHistoryView";
import { SecureNoteView } from "../../models/view/secureNoteView";
import { CipherType } from '../../enums/cipherType';
import { FieldType } from '../../enums/fieldType';
import { SecureNoteType } from '../../enums/secureNoteType';
import { CipherType } from "../../enums/cipherType";
import { FieldType } from "../../enums/fieldType";
import { SecureNoteType } from "../../enums/secureNoteType";
export class OnePassword1PifImporter extends BaseImporter implements Importer {
result = new ImportResult();
parse(data: string): Promise<ImportResult> {
data.split(this.newLineRegex).forEach(line => {
if (this.isNullOrWhitespace(line) || line[0] !== '{') {
data.split(this.newLineRegex).forEach((line) => {
if (this.isNullOrWhitespace(line) || line[0] !== "{") {
return;
}
const item = JSON.parse(line);
@@ -60,11 +60,16 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
if (item.details.passwordHistory != null) {
this.parsePasswordHistory(item.details.passwordHistory, cipher);
}
if (!this.isNullOrWhitespace(item.details.ccnum) || !this.isNullOrWhitespace(item.details.cvv)) {
if (
!this.isNullOrWhitespace(item.details.ccnum) ||
!this.isNullOrWhitespace(item.details.cvv)
) {
cipher.type = CipherType.Card;
cipher.card = new CardView();
} else if (!this.isNullOrWhitespace(item.details.firstname) ||
!this.isNullOrWhitespace(item.details.address1)) {
} else if (
!this.isNullOrWhitespace(item.details.firstname) ||
!this.isNullOrWhitespace(item.details.address1)
) {
cipher.type = CipherType.Identity;
cipher.identity = new IdentityView();
}
@@ -72,15 +77,15 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
cipher.login.password = item.details.password;
}
if (!this.isNullOrWhitespace(item.details.notesPlain)) {
cipher.notes = item.details.notesPlain.split(this.newLineRegex).join('\n') + '\n';
cipher.notes = item.details.notesPlain.split(this.newLineRegex).join("\n") + "\n";
}
if (item.details.fields != null) {
this.parseFields(item.details.fields, cipher, 'designation', 'value', 'name');
this.parseFields(item.details.fields, cipher, "designation", "value", "name");
}
if (item.details.sections != null) {
item.details.sections.forEach((section: any) => {
if (section.fields != null) {
this.parseFields(section.fields, cipher, 'n', 'v', 't');
this.parseFields(section.fields, cipher, "n", "v", "t");
}
});
}
@@ -91,14 +96,14 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
cipher.favorite = item.openContents && item.openContents.faveIndex ? true : false;
cipher.name = this.getValueOrDefault(item.title);
if (item.typeName === 'securenotes.SecureNote') {
if (item.typeName === "securenotes.SecureNote") {
cipher.type = CipherType.SecureNote;
cipher.secureNote = new SecureNoteView();
cipher.secureNote.type = SecureNoteType.Generic;
} else if (item.typeName === 'wallet.financial.CreditCard') {
} else if (item.typeName === "wallet.financial.CreditCard") {
cipher.type = CipherType.Card;
cipher.card = new CardView();
} else if (item.typeName === 'identities.Identity') {
} else if (item.typeName === "identities.Identity") {
cipher.type = CipherType.Identity;
cipher.identity = new IdentityView();
} else {
@@ -110,7 +115,7 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
this.parsePasswordHistory(item.secureContents.passwordHistory, cipher);
}
if (!this.isNullOrWhitespace(item.secureContents.notesPlain)) {
cipher.notes = item.secureContents.notesPlain.split(this.newLineRegex).join('\n') + '\n';
cipher.notes = item.secureContents.notesPlain.split(this.newLineRegex).join("\n") + "\n";
}
if (cipher.type === CipherType.Login) {
if (!this.isNullOrWhitespace(item.secureContents.password)) {
@@ -129,12 +134,12 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
}
}
if (item.secureContents.fields != null) {
this.parseFields(item.secureContents.fields, cipher, 'designation', 'value', 'name');
this.parseFields(item.secureContents.fields, cipher, "designation", "value", "name");
}
if (item.secureContents.sections != null) {
item.secureContents.sections.forEach((section: any) => {
if (section.fields != null) {
this.parseFields(section.fields, cipher, 'n', 'v', 't');
this.parseFields(section.fields, cipher, "n", "v", "t");
}
});
}
@@ -150,79 +155,98 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
.map((h: any) => {
const ph = new PasswordHistoryView();
ph.password = h.value;
ph.lastUsedDate = new Date(('' + h.time).length >= 13 ? h.time : h.time * 1000);
ph.lastUsedDate = new Date(("" + h.time).length >= 13 ? h.time : h.time * 1000);
return ph;
});
}
private parseFields(fields: any[], cipher: CipherView, designationKey: string, valueKey: string, nameKey: string) {
private parseFields(
fields: any[],
cipher: CipherView,
designationKey: string,
valueKey: string,
nameKey: string
) {
fields.forEach((field: any) => {
if (field[valueKey] == null || field[valueKey].toString().trim() === '') {
if (field[valueKey] == null || field[valueKey].toString().trim() === "") {
return;
}
const fieldValue = field[valueKey].toString();
const fieldDesignation = field[designationKey] != null ? field[designationKey].toString() : null;
const fieldDesignation =
field[designationKey] != null ? field[designationKey].toString() : null;
if (cipher.type === CipherType.Login) {
if (this.isNullOrWhitespace(cipher.login.username) && fieldDesignation === 'username') {
if (this.isNullOrWhitespace(cipher.login.username) && fieldDesignation === "username") {
cipher.login.username = fieldValue;
return;
} else if (this.isNullOrWhitespace(cipher.login.password) && fieldDesignation === 'password') {
} else if (
this.isNullOrWhitespace(cipher.login.password) &&
fieldDesignation === "password"
) {
cipher.login.password = fieldValue;
return;
} else if (this.isNullOrWhitespace(cipher.login.totp) && fieldDesignation != null &&
fieldDesignation.startsWith('TOTP_')) {
} else if (
this.isNullOrWhitespace(cipher.login.totp) &&
fieldDesignation != null &&
fieldDesignation.startsWith("TOTP_")
) {
cipher.login.totp = fieldValue;
return;
}
} else if (cipher.type === CipherType.Card) {
if (this.isNullOrWhitespace(cipher.card.number) && fieldDesignation === 'ccnum') {
if (this.isNullOrWhitespace(cipher.card.number) && fieldDesignation === "ccnum") {
cipher.card.number = fieldValue;
cipher.card.brand = this.getCardBrand(fieldValue);
return;
} else if (this.isNullOrWhitespace(cipher.card.code) && fieldDesignation === 'cvv') {
} else if (this.isNullOrWhitespace(cipher.card.code) && fieldDesignation === "cvv") {
cipher.card.code = fieldValue;
return;
} else if (this.isNullOrWhitespace(cipher.card.cardholderName) && fieldDesignation === 'cardholder') {
} else if (
this.isNullOrWhitespace(cipher.card.cardholderName) &&
fieldDesignation === "cardholder"
) {
cipher.card.cardholderName = fieldValue;
return;
} else if (this.isNullOrWhitespace(cipher.card.expiration) && fieldDesignation === 'expiry' &&
fieldValue.length === 6) {
} else if (
this.isNullOrWhitespace(cipher.card.expiration) &&
fieldDesignation === "expiry" &&
fieldValue.length === 6
) {
cipher.card.expMonth = (fieldValue as string).substr(4, 2);
if (cipher.card.expMonth[0] === '0') {
if (cipher.card.expMonth[0] === "0") {
cipher.card.expMonth = cipher.card.expMonth.substr(1, 1);
}
cipher.card.expYear = (fieldValue as string).substr(0, 4);
return;
} else if (fieldDesignation === 'type') {
} else if (fieldDesignation === "type") {
// Skip since brand was determined from number above
return;
}
} else if (cipher.type === CipherType.Identity) {
const identity = cipher.identity;
if (this.isNullOrWhitespace(identity.firstName) && fieldDesignation === 'firstname') {
if (this.isNullOrWhitespace(identity.firstName) && fieldDesignation === "firstname") {
identity.firstName = fieldValue;
return;
} else if (this.isNullOrWhitespace(identity.lastName) && fieldDesignation === 'lastname') {
} else if (this.isNullOrWhitespace(identity.lastName) && fieldDesignation === "lastname") {
identity.lastName = fieldValue;
return;
} else if (this.isNullOrWhitespace(identity.middleName) && fieldDesignation === 'initial') {
} else if (this.isNullOrWhitespace(identity.middleName) && fieldDesignation === "initial") {
identity.middleName = fieldValue;
return;
} else if (this.isNullOrWhitespace(identity.phone) && fieldDesignation === 'defphone') {
} else if (this.isNullOrWhitespace(identity.phone) && fieldDesignation === "defphone") {
identity.phone = fieldValue;
return;
} else if (this.isNullOrWhitespace(identity.company) && fieldDesignation === 'company') {
} else if (this.isNullOrWhitespace(identity.company) && fieldDesignation === "company") {
identity.company = fieldValue;
return;
} else if (this.isNullOrWhitespace(identity.email) && fieldDesignation === 'email') {
} else if (this.isNullOrWhitespace(identity.email) && fieldDesignation === "email") {
identity.email = fieldValue;
return;
} else if (this.isNullOrWhitespace(identity.username) && fieldDesignation === 'username') {
} else if (this.isNullOrWhitespace(identity.username) && fieldDesignation === "username") {
identity.username = fieldValue;
return;
} else if (fieldDesignation === 'address') {
} else if (fieldDesignation === "address") {
// fieldValue is an object casted into a string, so access the plain value instead
const { street, city, country, zip } = field[valueKey];
identity.address1 = this.getValueOrDefault(street);
@@ -235,13 +259,16 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
}
}
const fieldName = this.isNullOrWhitespace(field[nameKey]) ? 'no_name' : field[nameKey];
if (fieldName === 'password' && cipher.passwordHistory != null &&
cipher.passwordHistory.some(h => h.password === fieldValue)) {
const fieldName = this.isNullOrWhitespace(field[nameKey]) ? "no_name" : field[nameKey];
if (
fieldName === "password" &&
cipher.passwordHistory != null &&
cipher.passwordHistory.some((h) => h.password === fieldValue)
) {
return;
}
const fieldType = field.k === 'concealed' ? FieldType.Hidden : FieldType.Text;
const fieldType = field.k === "concealed" ? FieldType.Hidden : FieldType.Text;
this.processKvp(cipher, fieldName, fieldValue, fieldType);
});
}

View File

@@ -1,18 +1,45 @@
import { ImportResult } from '../../models/domain/importResult';
import { BaseImporter } from '../baseImporter';
import { Importer } from '../importer';
import { ImportResult } from "../../models/domain/importResult";
import { BaseImporter } from "../baseImporter";
import { Importer } from "../importer";
import { CipherType } from '../../enums/cipherType';
import { FieldType } from '../../enums/fieldType';
import { CipherView } from '../../models/view/cipherView';
import { CipherImportContext } from './cipherImportContext';
import { CipherType } from "../../enums/cipherType";
import { FieldType } from "../../enums/fieldType";
import { CipherView } from "../../models/view/cipherView";
import { CipherImportContext } from "./cipherImportContext";
export const IgnoredProperties = ['ainfo', 'autosubmit', 'notesplain', 'ps', 'scope', 'tags', 'title', 'uuid', 'notes'];
export const IgnoredProperties = [
"ainfo",
"autosubmit",
"notesplain",
"ps",
"scope",
"tags",
"title",
"uuid",
"notes",
];
export abstract class OnePasswordCsvImporter extends BaseImporter implements Importer {
protected loginPropertyParsers = [this.setLoginUsername, this.setLoginPassword, this.setLoginUris];
protected creditCardPropertyParsers = [this.setCreditCardNumber, this.setCreditCardVerification, this.setCreditCardCardholderName, this.setCreditCardExpiry];
protected identityPropertyParsers = [this.setIdentityFirstName, this.setIdentityInitial, this.setIdentityLastName, this.setIdentityUserName, this.setIdentityEmail, this.setIdentityPhone, this.setIdentityCompany];
protected loginPropertyParsers = [
this.setLoginUsername,
this.setLoginPassword,
this.setLoginUris,
];
protected creditCardPropertyParsers = [
this.setCreditCardNumber,
this.setCreditCardVerification,
this.setCreditCardCardholderName,
this.setCreditCardExpiry,
];
protected identityPropertyParsers = [
this.setIdentityFirstName,
this.setIdentityInitial,
this.setIdentityLastName,
this.setIdentityUserName,
this.setIdentityEmail,
this.setIdentityPhone,
this.setIdentityCompany,
];
abstract setCipherType(value: any, cipher: CipherView): void;
@@ -20,20 +47,20 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
const result = new ImportResult();
const results = this.parseCsv(data, true, {
quoteChar: '"',
escapeChar: '\\',
escapeChar: "\\",
});
if (results == null) {
result.success = false;
return Promise.resolve(result);
}
results.forEach(value => {
if (this.isNullOrWhitespace(this.getProp(value, 'title'))) {
results.forEach((value) => {
if (this.isNullOrWhitespace(this.getProp(value, "title"))) {
return;
}
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(this.getProp(value, 'title'), '--');
cipher.name = this.getValueOrDefault(this.getProp(value, "title"), "--");
this.setNotes(value, cipher);
@@ -57,8 +84,12 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
altUsername = this.setUnknownValue(context, altUsername);
}
if (cipher.type === CipherType.Login && !this.isNullOrWhitespace(altUsername) &&
this.isNullOrWhitespace(cipher.login.username) && altUsername.indexOf('://') === -1) {
if (
cipher.type === CipherType.Login &&
!this.isNullOrWhitespace(altUsername) &&
this.isNullOrWhitespace(cipher.login.username) &&
altUsername.indexOf("://") === -1
) {
cipher.login.username = altUsername;
}
@@ -108,10 +139,12 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setNotes(importRecord: any, cipher: CipherView) {
cipher.notes = this.getValueOrDefault(this.getProp(importRecord, 'notesPlain'), '') + '\n' +
this.getValueOrDefault(this.getProp(importRecord, 'notes'), '') + '\n';
cipher.notes =
this.getValueOrDefault(this.getProp(importRecord, "notesPlain"), "") +
"\n" +
this.getValueOrDefault(this.getProp(importRecord, "notes"), "") +
"\n";
cipher.notes.trim();
}
protected setKnownLoginValue(context: CipherImportContext): boolean {
@@ -142,18 +175,34 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setUnknownValue(context: CipherImportContext, altUsername: string): string {
if (IgnoredProperties.indexOf(context.lowerProperty) === -1 && !context.lowerProperty.startsWith('section:') &&
!context.lowerProperty.startsWith('section ')) {
if (altUsername == null && context.lowerProperty === 'email') {
if (
IgnoredProperties.indexOf(context.lowerProperty) === -1 &&
!context.lowerProperty.startsWith("section:") &&
!context.lowerProperty.startsWith("section ")
) {
if (altUsername == null && context.lowerProperty === "email") {
return context.importRecord[context.property];
}
else if (context.lowerProperty === 'created date' || context.lowerProperty === 'modified date') {
const readableDate = new Date(parseInt(context.importRecord[context.property], 10) * 1000).toUTCString();
this.processKvp(context.cipher, '1Password ' + context.property, readableDate);
} else if (
context.lowerProperty === "created date" ||
context.lowerProperty === "modified date"
) {
const readableDate = new Date(
parseInt(context.importRecord[context.property], 10) * 1000
).toUTCString();
this.processKvp(context.cipher, "1Password " + context.property, readableDate);
return null;
}
if (context.lowerProperty.includes('password') || context.lowerProperty.includes('key') || context.lowerProperty.includes('secret')) {
this.processKvp(context.cipher, context.property, context.importRecord[context.property], FieldType.Hidden);
if (
context.lowerProperty.includes("password") ||
context.lowerProperty.includes("key") ||
context.lowerProperty.includes("secret")
) {
this.processKvp(
context.cipher,
context.property,
context.importRecord[context.property],
FieldType.Hidden
);
} else {
this.processKvp(context.cipher, context.property, context.importRecord[context.property]);
}
@@ -162,7 +211,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setIdentityFirstName(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.identity.firstName) && context.lowerProperty.includes('first name')) {
if (
this.isNullOrWhitespace(context.cipher.identity.firstName) &&
context.lowerProperty.includes("first name")
) {
context.cipher.identity.firstName = context.importRecord[context.property];
return true;
}
@@ -170,7 +222,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setIdentityInitial(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.identity.middleName) && context.lowerProperty.includes('initial')) {
if (
this.isNullOrWhitespace(context.cipher.identity.middleName) &&
context.lowerProperty.includes("initial")
) {
context.cipher.identity.middleName = context.importRecord[context.property];
return true;
}
@@ -178,7 +233,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setIdentityLastName(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.identity.lastName) && context.lowerProperty.includes('last name')) {
if (
this.isNullOrWhitespace(context.cipher.identity.lastName) &&
context.lowerProperty.includes("last name")
) {
context.cipher.identity.lastName = context.importRecord[context.property];
return true;
}
@@ -186,7 +244,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setIdentityUserName(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.identity.username) && context.lowerProperty.includes('username')) {
if (
this.isNullOrWhitespace(context.cipher.identity.username) &&
context.lowerProperty.includes("username")
) {
context.cipher.identity.username = context.importRecord[context.property];
return true;
}
@@ -194,7 +255,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setIdentityCompany(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.identity.company) && context.lowerProperty.includes('company')) {
if (
this.isNullOrWhitespace(context.cipher.identity.company) &&
context.lowerProperty.includes("company")
) {
context.cipher.identity.company = context.importRecord[context.property];
return true;
}
@@ -202,7 +266,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setIdentityPhone(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.identity.phone) && context.lowerProperty.includes('default phone')) {
if (
this.isNullOrWhitespace(context.cipher.identity.phone) &&
context.lowerProperty.includes("default phone")
) {
context.cipher.identity.phone = context.importRecord[context.property];
return true;
}
@@ -210,7 +277,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setIdentityEmail(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.identity.email) && context.lowerProperty.includes('email')) {
if (
this.isNullOrWhitespace(context.cipher.identity.email) &&
context.lowerProperty.includes("email")
) {
context.cipher.identity.email = context.importRecord[context.property];
return true;
}
@@ -218,7 +288,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setCreditCardNumber(context: CipherImportContext): boolean {
if (this.isNullOrWhitespace(context.cipher.card.number) && context.lowerProperty.includes('number')) {
if (
this.isNullOrWhitespace(context.cipher.card.number) &&
context.lowerProperty.includes("number")
) {
context.cipher.card.number = context.importRecord[context.property];
context.cipher.card.brand = this.getCardBrand(context.cipher.card.number);
return true;
@@ -227,7 +300,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setCreditCardVerification(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.card.code) && context.lowerProperty.includes('verification number')) {
if (
this.isNullOrWhitespace(context.cipher.card.code) &&
context.lowerProperty.includes("verification number")
) {
context.cipher.card.code = context.importRecord[context.property];
return true;
}
@@ -235,7 +311,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setCreditCardCardholderName(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.card.cardholderName) && context.lowerProperty.includes('cardholder name')) {
if (
this.isNullOrWhitespace(context.cipher.card.cardholderName) &&
context.lowerProperty.includes("cardholder name")
) {
context.cipher.card.cardholderName = context.importRecord[context.property];
return true;
}
@@ -243,10 +322,16 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setCreditCardExpiry(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.card.expiration) && context.lowerProperty.includes('expiry date') &&
context.importRecord[context.property].length === 7) {
context.cipher.card.expMonth = (context.importRecord[context.property] as string).substr(0, 2);
if (context.cipher.card.expMonth[0] === '0') {
if (
this.isNullOrWhitespace(context.cipher.card.expiration) &&
context.lowerProperty.includes("expiry date") &&
context.importRecord[context.property].length === 7
) {
context.cipher.card.expMonth = (context.importRecord[context.property] as string).substr(
0,
2
);
if (context.cipher.card.expMonth[0] === "0") {
context.cipher.card.expMonth = context.cipher.card.expMonth.substr(1, 1);
}
context.cipher.card.expYear = (context.importRecord[context.property] as string).substr(3, 4);
@@ -256,7 +341,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setLoginPassword(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.login.password) && context.lowerProperty === 'password') {
if (
this.isNullOrWhitespace(context.cipher.login.password) &&
context.lowerProperty === "password"
) {
context.cipher.login.password = context.importRecord[context.property];
return true;
}
@@ -264,7 +352,10 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setLoginUsername(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.login.username) && context.lowerProperty === 'username') {
if (
this.isNullOrWhitespace(context.cipher.login.username) &&
context.lowerProperty === "username"
) {
context.cipher.login.username = context.importRecord[context.property];
return true;
}
@@ -272,11 +363,14 @@ export abstract class OnePasswordCsvImporter extends BaseImporter implements Imp
}
protected setLoginUris(context: CipherImportContext) {
if ((context.cipher.login.uris == null || context.cipher.login.uris.length === 0) && context.lowerProperty === 'urls') {
if (
(context.cipher.login.uris == null || context.cipher.login.uris.length === 0) &&
context.lowerProperty === "urls"
) {
const urls = context.importRecord[context.property].split(this.newLineRegex);
context.cipher.login.uris = this.makeUriArray(urls);
return true;
} else if ((context.lowerProperty === 'url')) {
} else if (context.lowerProperty === "url") {
if (context.cipher.login.uris == null) {
context.cipher.login.uris = [];
}

View File

@@ -1,28 +1,28 @@
import { Importer } from '../importer';
import { IgnoredProperties, OnePasswordCsvImporter } from './onepasswordCsvImporter';
import { Importer } from "../importer";
import { IgnoredProperties, OnePasswordCsvImporter } from "./onepasswordCsvImporter";
import { CipherType } from '../../enums/cipherType';
import { CardView } from '../../models/view/cardView';
import { CipherView } from '../../models/view/cipherView';
import { IdentityView } from '../../models/view/identityView';
import { CipherType } from "../../enums/cipherType";
import { CardView } from "../../models/view/cardView";
import { CipherView } from "../../models/view/cipherView";
import { IdentityView } from "../../models/view/identityView";
export class OnePasswordMacCsvImporter extends OnePasswordCsvImporter implements Importer {
setCipherType(value: any, cipher: CipherView) {
const onePassType = this.getValueOrDefault(this.getProp(value, 'type'), 'Login');
const onePassType = this.getValueOrDefault(this.getProp(value, "type"), "Login");
switch (onePassType) {
case 'Credit Card':
case "Credit Card":
cipher.type = CipherType.Card;
cipher.card = new CardView();
IgnoredProperties.push('type');
IgnoredProperties.push("type");
break;
case 'Identity':
case "Identity":
cipher.type = CipherType.Identity;
cipher.identity = new IdentityView();
IgnoredProperties.push('type');
IgnoredProperties.push("type");
break;
case 'Login':
case 'Secure Note':
IgnoredProperties.push('type');
case "Login":
case "Secure Note":
IgnoredProperties.push("type");
default:
break;
}

View File

@@ -1,12 +1,12 @@
import { Importer } from '../importer';
import { CipherImportContext } from './cipherImportContext';
import { OnePasswordCsvImporter } from './onepasswordCsvImporter';
import { Importer } from "../importer";
import { CipherImportContext } from "./cipherImportContext";
import { OnePasswordCsvImporter } from "./onepasswordCsvImporter";
import { CipherType } from '../../enums/cipherType';
import { CardView } from '../../models/view/cardView';
import { CipherView } from '../../models/view/cipherView';
import { IdentityView } from '../../models/view/identityView';
import { LoginView } from '../../models/view/loginView';
import { CipherType } from "../../enums/cipherType";
import { CardView } from "../../models/view/cardView";
import { CipherView } from "../../models/view/cipherView";
import { IdentityView } from "../../models/view/identityView";
import { LoginView } from "../../models/view/loginView";
export class OnePasswordWinCsvImporter extends OnePasswordCsvImporter implements Importer {
constructor() {
@@ -18,16 +18,20 @@ export class OnePasswordWinCsvImporter extends OnePasswordCsvImporter implements
cipher.type = CipherType.Login;
cipher.login = new LoginView();
if (!this.isNullOrWhitespace(this.getPropByRegexp(value, /\d+: number/i)) &&
!this.isNullOrWhitespace(this.getPropByRegexp(value, /\d+: expiry date/i))) {
if (
!this.isNullOrWhitespace(this.getPropByRegexp(value, /\d+: number/i)) &&
!this.isNullOrWhitespace(this.getPropByRegexp(value, /\d+: expiry date/i))
) {
cipher.type = CipherType.Card;
cipher.card = new CardView();
}
if (!this.isNullOrWhitespace(this.getPropByRegexp(value, /name \d+: first name/i)) ||
if (
!this.isNullOrWhitespace(this.getPropByRegexp(value, /name \d+: first name/i)) ||
!this.isNullOrWhitespace(this.getPropByRegexp(value, /name \d+: initial/i)) ||
!this.isNullOrWhitespace(this.getPropByRegexp(value, /name \d+: last name/i)) ||
!this.isNullOrWhitespace(this.getPropByRegexp(value, /internet \d+: email/i))) {
!this.isNullOrWhitespace(this.getPropByRegexp(value, /internet \d+: email/i))
) {
cipher.type = CipherType.Identity;
cipher.identity = new IdentityView();
}
@@ -35,17 +39,20 @@ export class OnePasswordWinCsvImporter extends OnePasswordCsvImporter implements
setIdentityAddress(context: CipherImportContext) {
if (context.lowerProperty.match(/address \d+: address/i)) {
this.processKvp(context.cipher, 'address', context.importRecord[context.property]);
this.processKvp(context.cipher, "address", context.importRecord[context.property]);
return true;
}
return false;
}
setCreditCardExpiry(context: CipherImportContext) {
if (this.isNullOrWhitespace(context.cipher.card.expiration) && context.lowerProperty.includes('expiry date')) {
const expSplit = (context.importRecord[context.property] as string).split('/');
if (
this.isNullOrWhitespace(context.cipher.card.expiration) &&
context.lowerProperty.includes("expiry date")
) {
const expSplit = (context.importRecord[context.property] as string).split("/");
context.cipher.card.expMonth = expSplit[0];
if (context.cipher.card.expMonth[0] === '0' && context.cipher.card.expMonth.length === 2) {
if (context.cipher.card.expMonth[0] === "0" && context.cipher.card.expMonth.length === 2) {
context.cipher.card.expMonth = context.cipher.card.expMonth.substr(1, 1);
}
context.cipher.card.expYear = expSplit[2].length > 4 ? expSplit[2].substr(0, 4) : expSplit[2];

View File

@@ -1,10 +1,10 @@
import { BaseImporter } from './baseImporter';
import { Importer } from './importer';
import { BaseImporter } from "./baseImporter";
import { Importer } from "./importer";
import { ImportResult } from '../models/domain/importResult';
import { ImportResult } from "../models/domain/importResult";
import { CollectionView } from '../models/view/collectionView';
import { FolderView } from '../models/view/folderView';
import { CollectionView } from "../models/view/collectionView";
import { FolderView } from "../models/view/folderView";
export class PadlockCsvImporter extends BaseImporter implements Importer {
parse(data: string): Promise<ImportResult> {
@@ -16,7 +16,7 @@ export class PadlockCsvImporter extends BaseImporter implements Importer {
}
let headers: string[] = null;
results.forEach(value => {
results.forEach((value) => {
if (headers == null) {
headers = value.map((v: string) => v);
return;
@@ -28,8 +28,8 @@ export class PadlockCsvImporter extends BaseImporter implements Importer {
if (!this.isNullOrWhitespace(value[1])) {
if (this.organization) {
const tags = (value[1] as string).split(',');
tags.forEach(tag => {
const tags = (value[1] as string).split(",");
tags.forEach((tag) => {
tag = tag.trim();
let addCollection = true;
let collectionIndex = result.collections.length;
@@ -51,14 +51,14 @@ export class PadlockCsvImporter extends BaseImporter implements Importer {
result.collectionRelationships.push([result.ciphers.length, collectionIndex]);
});
} else {
const tags = (value[1] as string).split(',');
const tags = (value[1] as string).split(",");
const tag = tags.length > 0 ? tags[0].trim() : null;
this.processFolder(result, tag);
}
}
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value[0], '--');
cipher.name = this.getValueOrDefault(value[0], "--");
for (let i = 2; i < value.length; i++) {
const header = headers[i].trim().toLowerCase();

Some files were not shown because too many files have changed in this diff Show More