diff --git a/jslib/angular/src/components/callout.component.html b/jslib/angular/src/components/callout.component.html
deleted file mode 100644
index a049d5cb..00000000
--- a/jslib/angular/src/components/callout.component.html
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
- {{ title }}
-
-
- {{ enforcedPolicyMessage }}
-
- - 0">
- {{ "policyInEffectMinComplexity" | i18n: getPasswordScoreAlertDisplay() }}
-
- - 0">
- {{ "policyInEffectMinLength" | i18n: enforcedPolicyOptions?.minLength.toString() }}
-
- -
- {{ "policyInEffectUppercase" | i18n }}
-
- -
- {{ "policyInEffectLowercase" | i18n }}
-
- -
- {{ "policyInEffectNumbers" | i18n }}
-
- -
- {{ "policyInEffectSpecial" | i18n: "!@#$%^&*" }}
-
-
-
-
-
diff --git a/jslib/angular/src/components/callout.component.ts b/jslib/angular/src/components/callout.component.ts
deleted file mode 100644
index 9b7a7e0d..00000000
--- a/jslib/angular/src/components/callout.component.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import { Component, Input, OnInit } from "@angular/core";
-
-import { I18nService } from "@/jslib/common/src/abstractions/i18n.service";
-import { MasterPasswordPolicyOptions } from "@/jslib/common/src/models/domain/masterPasswordPolicyOptions";
-
-@Component({
- selector: "app-callout",
- templateUrl: "callout.component.html",
-})
-export class CalloutComponent implements OnInit {
- @Input() type = "info";
- @Input() icon: string;
- @Input() title: string;
- @Input() clickable: boolean;
- @Input() enforcedPolicyOptions: MasterPasswordPolicyOptions;
- @Input() enforcedPolicyMessage: string;
- @Input() useAlertRole = false;
-
- calloutStyle: string;
-
- constructor(private i18nService: I18nService) {}
-
- ngOnInit() {
- this.calloutStyle = this.type;
-
- if (this.enforcedPolicyMessage === undefined) {
- this.enforcedPolicyMessage = this.i18nService.t("masterPasswordPolicyInEffect");
- }
-
- if (this.type === "warning" || this.type === "danger") {
- if (this.type === "danger") {
- this.calloutStyle = "danger";
- }
- if (this.title === undefined) {
- this.title = this.i18nService.t("warning");
- }
- if (this.icon === undefined) {
- this.icon = "bwi-exclamation-triangle";
- }
- } else if (this.type === "error") {
- this.calloutStyle = "danger";
- if (this.title === undefined) {
- this.title = this.i18nService.t("error");
- }
- if (this.icon === undefined) {
- this.icon = "bwi-error";
- }
- } else if (this.type === "tip") {
- this.calloutStyle = "success";
- if (this.title === undefined) {
- this.title = this.i18nService.t("tip");
- }
- if (this.icon === undefined) {
- this.icon = "bwi-lightbulb";
- }
- }
- }
-
- getPasswordScoreAlertDisplay() {
- if (this.enforcedPolicyOptions == null) {
- return "";
- }
-
- let str: string;
- switch (this.enforcedPolicyOptions.minComplexity) {
- case 4:
- str = this.i18nService.t("strong");
- break;
- case 3:
- str = this.i18nService.t("good");
- break;
- default:
- str = this.i18nService.t("weak");
- break;
- }
- return str + " (" + this.enforcedPolicyOptions.minComplexity + ")";
- }
-}
diff --git a/jslib/angular/src/components/icon.component.html b/jslib/angular/src/components/icon.component.html
deleted file mode 100644
index 27182fbb..00000000
--- a/jslib/angular/src/components/icon.component.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
![]()
-
-
diff --git a/jslib/angular/src/components/icon.component.ts b/jslib/angular/src/components/icon.component.ts
deleted file mode 100644
index 1af48983..00000000
--- a/jslib/angular/src/components/icon.component.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-import { Component, Input, OnChanges } from "@angular/core";
-
-import { EnvironmentService } from "@/jslib/common/src/abstractions/environment.service";
-import { StateService } from "@/jslib/common/src/abstractions/state.service";
-import { CipherType } from "@/jslib/common/src/enums/cipherType";
-import { Utils } from "@/jslib/common/src/misc/utils";
-import { CipherView } from "@/jslib/common/src/models/view/cipherView";
-
-/**
- * Provides a mapping from supported card brands to
- * the filenames of icon that should be present in images/cards folder of clients.
- */
-const cardIcons: Record = {
- Visa: "card-visa",
- Mastercard: "card-mastercard",
- Amex: "card-amex",
- Discover: "card-discover",
- "Diners Club": "card-diners-club",
- JCB: "card-jcb",
- Maestro: "card-maestro",
- UnionPay: "card-union-pay",
-};
-
-@Component({
- selector: "app-vault-icon",
- templateUrl: "icon.component.html",
-})
-export class IconComponent implements OnChanges {
- @Input() cipher: CipherView;
- icon: string;
- image: string;
- fallbackImage: string;
- imageEnabled: boolean;
-
- private iconsUrl: string;
-
- constructor(
- environmentService: EnvironmentService,
- private stateService: StateService,
- ) {
- this.iconsUrl = environmentService.getIconsUrl();
- }
-
- async ngOnChanges() {
- // Components may be re-used when using cdk-virtual-scroll. Which puts the component in a weird state,
- // to avoid this we reset all state variables.
- this.image = null;
- this.fallbackImage = null;
- this.imageEnabled = !(await this.stateService.getDisableFavicon());
- this.load();
- }
-
- protected load() {
- switch (this.cipher.type) {
- case CipherType.Login:
- this.icon = "bwi-globe";
- this.setLoginIcon();
- break;
- case CipherType.SecureNote:
- this.icon = "bwi-sticky-note";
- break;
- case CipherType.Card:
- this.icon = "bwi-credit-card";
- this.setCardIcon();
- break;
- case CipherType.Identity:
- this.icon = "bwi-id-card";
- break;
- default:
- break;
- }
- }
-
- private setLoginIcon() {
- if (this.cipher.login.uri) {
- let hostnameUri = this.cipher.login.uri;
- let isWebsite = false;
-
- if (hostnameUri.indexOf("androidapp://") === 0) {
- this.icon = "bwi-android";
- this.image = null;
- } else if (hostnameUri.indexOf("iosapp://") === 0) {
- this.icon = "bwi-apple";
- this.image = null;
- } else if (
- this.imageEnabled &&
- hostnameUri.indexOf("://") === -1 &&
- hostnameUri.indexOf(".") > -1
- ) {
- hostnameUri = "http://" + hostnameUri;
- isWebsite = true;
- } else if (this.imageEnabled) {
- isWebsite = hostnameUri.indexOf("http") === 0 && hostnameUri.indexOf(".") > -1;
- }
-
- if (this.imageEnabled && isWebsite) {
- try {
- this.image = this.iconsUrl + "/" + Utils.getHostname(hostnameUri) + "/icon.png";
- this.fallbackImage = "images/bwi-globe.png";
- } catch (e) {
- // Ignore error since the fallback icon will be shown if image is null.
- }
- }
- } else {
- this.image = null;
- }
- }
-
- private setCardIcon() {
- const brand = this.cipher.card.brand;
- if (this.imageEnabled && brand in cardIcons) {
- this.icon = "credit-card-icon " + cardIcons[brand];
- }
- }
-}
diff --git a/jslib/angular/src/components/password-reprompt.component.ts b/jslib/angular/src/components/password-reprompt.component.ts
deleted file mode 100644
index 0ff6005b..00000000
--- a/jslib/angular/src/components/password-reprompt.component.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Directive } from "@angular/core";
-
-import { CryptoService } from "@/jslib/common/src/abstractions/crypto.service";
-import { I18nService } from "@/jslib/common/src/abstractions/i18n.service";
-import { PlatformUtilsService } from "@/jslib/common/src/abstractions/platformUtils.service";
-
-import { ModalRef } from "./modal/modal.ref";
-
-/**
- * Used to verify the user's Master Password for the "Master Password Re-prompt" feature only.
- * See UserVerificationComponent for any other situation where you need to verify the user's identity.
- */
-@Directive()
-export class PasswordRepromptComponent {
- showPassword = false;
- masterPassword = "";
-
- 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"),
- );
- return;
- }
-
- this.modalRef.close(true);
- }
-}
diff --git a/jslib/angular/src/pipes/search-ciphers.pipe.ts b/jslib/angular/src/pipes/search-ciphers.pipe.ts
deleted file mode 100644
index aae299af..00000000
--- a/jslib/angular/src/pipes/search-ciphers.pipe.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Pipe, PipeTransform } from "@angular/core";
-
-import { CipherView } from "@/jslib/common/src/models/view/cipherView";
-
-@Pipe({
- name: "searchCiphers",
-})
-export class SearchCiphersPipe implements PipeTransform {
- transform(ciphers: CipherView[], searchText: string, deleted = false): CipherView[] {
- if (ciphers == null || ciphers.length === 0) {
- return [];
- }
-
- if (searchText == null || searchText.length < 2) {
- return ciphers.filter((c) => {
- return deleted !== c.isDeleted;
- });
- }
-
- searchText = searchText.trim().toLowerCase();
- return ciphers.filter((c) => {
- if (deleted !== c.isDeleted) {
- return false;
- }
- if (c.name != null && c.name.toLowerCase().indexOf(searchText) > -1) {
- return true;
- }
- if (searchText.length >= 8 && c.id.startsWith(searchText)) {
- return true;
- }
- if (c.subTitle != null && c.subTitle.toLowerCase().indexOf(searchText) > -1) {
- return true;
- }
- if (c.login && c.login.uri != null && c.login.uri.toLowerCase().indexOf(searchText) > -1) {
- return true;
- }
-
- return false;
- });
- }
-}
diff --git a/jslib/common/spec/domain/attachment.spec.ts b/jslib/common/spec/domain/attachment.spec.ts
deleted file mode 100644
index 9c8bd29a..00000000
--- a/jslib/common/spec/domain/attachment.spec.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { Substitute, Arg } from "@fluffy-spoon/substitute";
-
-import { CryptoService } from "@/jslib/common/src/abstractions/crypto.service";
-import { AttachmentData } from "@/jslib/common/src/models/data/attachmentData";
-import { Attachment } from "@/jslib/common/src/models/domain/attachment";
-import { SymmetricCryptoKey } from "@/jslib/common/src/models/domain/symmetricCryptoKey";
-import { ContainerService } from "@/jslib/common/src/services/container.service";
-
-import { makeStaticByteArray, mockEnc } from "../utils";
-
-describe("Attachment", () => {
- let data: AttachmentData;
-
- beforeEach(() => {
- data = {
- id: "id",
- url: "url",
- fileName: "fileName",
- key: "key",
- size: "1100",
- sizeName: "1.1 KB",
- };
- });
-
- it("Convert from empty", () => {
- const data = new AttachmentData();
- const attachment = new Attachment(data);
-
- expect(attachment).toEqual({
- id: null,
- url: null,
- size: undefined,
- sizeName: null,
- key: null,
- fileName: null,
- });
- });
-
- it("Convert", () => {
- const attachment = new Attachment(data);
-
- expect(attachment).toEqual({
- size: "1100",
- id: "id",
- url: "url",
- sizeName: "1.1 KB",
- fileName: { encryptedString: "fileName", encryptionType: 0 },
- key: { encryptedString: "key", encryptionType: 0 },
- });
- });
-
- it("toAttachmentData", () => {
- const attachment = new Attachment(data);
- expect(attachment.toAttachmentData()).toEqual(data);
- });
-
- it("Decrypt", async () => {
- const attachment = new Attachment();
- attachment.id = "id";
- attachment.url = "url";
- attachment.size = "1100";
- attachment.sizeName = "1.1 KB";
- attachment.key = mockEnc("key");
- attachment.fileName = mockEnc("fileName");
-
- const cryptoService = Substitute.for();
- cryptoService.getOrgKey(null).resolves(null);
- cryptoService.decryptToBytes(Arg.any(), Arg.any()).resolves(makeStaticByteArray(32));
-
- (window as any).bitwardenContainerService = new ContainerService(cryptoService);
-
- const view = await attachment.decrypt(null);
-
- expect(view).toEqual({
- id: "id",
- url: "url",
- size: "1100",
- sizeName: "1.1 KB",
- fileName: "fileName",
- key: expect.any(SymmetricCryptoKey),
- });
- });
-});
diff --git a/jslib/common/spec/domain/card.spec.ts b/jslib/common/spec/domain/card.spec.ts
deleted file mode 100644
index ca41084b..00000000
--- a/jslib/common/spec/domain/card.spec.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import { CardData } from "@/jslib/common/src/models/data/cardData";
-import { Card } from "@/jslib/common/src/models/domain/card";
-
-import { mockEnc } from "../utils";
-
-describe("Card", () => {
- let data: CardData;
-
- beforeEach(() => {
- data = {
- cardholderName: "encHolder",
- brand: "encBrand",
- number: "encNumber",
- expMonth: "encMonth",
- expYear: "encYear",
- code: "encCode",
- };
- });
-
- it("Convert from empty", () => {
- const data = new CardData();
- const card = new Card(data);
-
- expect(card).toEqual({
- cardholderName: null,
- brand: null,
- number: null,
- expMonth: null,
- expYear: null,
- code: null,
- });
- });
-
- it("Convert", () => {
- const card = new Card(data);
-
- expect(card).toEqual({
- cardholderName: { encryptedString: "encHolder", encryptionType: 0 },
- brand: { encryptedString: "encBrand", encryptionType: 0 },
- number: { encryptedString: "encNumber", encryptionType: 0 },
- expMonth: { encryptedString: "encMonth", encryptionType: 0 },
- expYear: { encryptedString: "encYear", encryptionType: 0 },
- code: { encryptedString: "encCode", encryptionType: 0 },
- });
- });
-
- it("toCardData", () => {
- const card = new Card(data);
- expect(card.toCardData()).toEqual(data);
- });
-
- it("Decrypt", async () => {
- const card = new Card();
- card.cardholderName = mockEnc("cardHolder");
- card.brand = mockEnc("brand");
- card.number = mockEnc("number");
- card.expMonth = mockEnc("expMonth");
- card.expYear = mockEnc("expYear");
- card.code = mockEnc("code");
-
- const view = await card.decrypt(null);
-
- expect(view).toEqual({
- _brand: "brand",
- _number: "number",
- _subTitle: null,
- cardholderName: "cardHolder",
- code: "code",
- expMonth: "expMonth",
- expYear: "expYear",
- });
- });
-});
diff --git a/jslib/common/spec/domain/cipher.spec.ts b/jslib/common/spec/domain/cipher.spec.ts
deleted file mode 100644
index b0e79930..00000000
--- a/jslib/common/spec/domain/cipher.spec.ts
+++ /dev/null
@@ -1,599 +0,0 @@
-import { Substitute, Arg } from "@fluffy-spoon/substitute";
-
-import { CipherRepromptType } from "@/jslib/common/src/enums/cipherRepromptType";
-import { CipherType } from "@/jslib/common/src/enums/cipherType";
-import { FieldType } from "@/jslib/common/src/enums/fieldType";
-import { SecureNoteType } from "@/jslib/common/src/enums/secureNoteType";
-import { UriMatchType } from "@/jslib/common/src/enums/uriMatchType";
-import { CipherData } from "@/jslib/common/src/models/data/cipherData";
-import { Card } from "@/jslib/common/src/models/domain/card";
-import { Cipher } from "@/jslib/common/src/models/domain/cipher";
-import { Identity } from "@/jslib/common/src/models/domain/identity";
-import { Login } from "@/jslib/common/src/models/domain/login";
-import { SecureNote } from "@/jslib/common/src/models/domain/secureNote";
-import { CardView } from "@/jslib/common/src/models/view/cardView";
-import { IdentityView } from "@/jslib/common/src/models/view/identityView";
-import { LoginView } from "@/jslib/common/src/models/view/loginView";
-
-import { mockEnc } from "../utils";
-
-describe("Cipher DTO", () => {
- it("Convert from empty CipherData", () => {
- const data = new CipherData();
- const cipher = new Cipher(data);
-
- expect(cipher).toEqual({
- id: null,
- userId: null,
- organizationId: null,
- folderId: null,
- name: null,
- notes: null,
- type: undefined,
- favorite: undefined,
- organizationUseTotp: undefined,
- edit: undefined,
- viewPassword: true,
- revisionDate: null,
- collectionIds: undefined,
- localData: null,
- deletedDate: null,
- reprompt: undefined,
- attachments: null,
- fields: null,
- passwordHistory: null,
- });
- });
-
- describe("LoginCipher", () => {
- let cipherData: CipherData;
-
- beforeEach(() => {
- cipherData = {
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- userId: "userId",
- edit: true,
- viewPassword: true,
- organizationUseTotp: true,
- favorite: false,
- revisionDate: "2022-01-31T12:00:00.000Z",
- type: CipherType.Login,
- name: "EncryptedString",
- notes: "EncryptedString",
- deletedDate: null,
- reprompt: CipherRepromptType.None,
- login: {
- uris: [{ uri: "EncryptedString", match: UriMatchType.Domain }],
- username: "EncryptedString",
- password: "EncryptedString",
- passwordRevisionDate: "2022-01-31T12:00:00.000Z",
- totp: "EncryptedString",
- autofillOnPageLoad: false,
- },
- passwordHistory: [
- { password: "EncryptedString", lastUsedDate: "2022-01-31T12:00:00.000Z" },
- ],
- attachments: [
- {
- id: "a1",
- url: "url",
- size: "1100",
- sizeName: "1.1 KB",
- fileName: "file",
- key: "EncKey",
- },
- {
- id: "a2",
- url: "url",
- size: "1100",
- sizeName: "1.1 KB",
- fileName: "file",
- key: "EncKey",
- },
- ],
- fields: [
- {
- name: "EncryptedString",
- value: "EncryptedString",
- type: FieldType.Text,
- linkedId: null,
- },
- {
- name: "EncryptedString",
- value: "EncryptedString",
- type: FieldType.Hidden,
- linkedId: null,
- },
- ],
- };
- });
-
- it("Convert", () => {
- const cipher = new Cipher(cipherData);
-
- expect(cipher).toEqual({
- id: "id",
- userId: "userId",
- organizationId: "orgId",
- folderId: "folderId",
- name: { encryptedString: "EncryptedString", encryptionType: 0 },
- notes: { encryptedString: "EncryptedString", encryptionType: 0 },
- type: 1,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- collectionIds: undefined,
- localData: null,
- deletedDate: null,
- reprompt: 0,
- login: {
- passwordRevisionDate: new Date("2022-01-31T12:00:00.000Z"),
- autofillOnPageLoad: false,
- username: { encryptedString: "EncryptedString", encryptionType: 0 },
- password: { encryptedString: "EncryptedString", encryptionType: 0 },
- totp: { encryptedString: "EncryptedString", encryptionType: 0 },
- uris: [{ match: 0, uri: { encryptedString: "EncryptedString", encryptionType: 0 } }],
- },
- attachments: [
- {
- fileName: { encryptedString: "file", encryptionType: 0 },
- id: "a1",
- key: { encryptedString: "EncKey", encryptionType: 0 },
- size: "1100",
- sizeName: "1.1 KB",
- url: "url",
- },
- {
- fileName: { encryptedString: "file", encryptionType: 0 },
- id: "a2",
- key: { encryptedString: "EncKey", encryptionType: 0 },
- size: "1100",
- sizeName: "1.1 KB",
- url: "url",
- },
- ],
- fields: [
- {
- linkedId: null,
- name: { encryptedString: "EncryptedString", encryptionType: 0 },
- type: 0,
- value: { encryptedString: "EncryptedString", encryptionType: 0 },
- },
- {
- linkedId: null,
- name: { encryptedString: "EncryptedString", encryptionType: 0 },
- type: 1,
- value: { encryptedString: "EncryptedString", encryptionType: 0 },
- },
- ],
- passwordHistory: [
- {
- lastUsedDate: new Date("2022-01-31T12:00:00.000Z"),
- password: { encryptedString: "EncryptedString", encryptionType: 0 },
- },
- ],
- });
- });
-
- it("toCipherData", () => {
- const cipher = new Cipher(cipherData);
- expect(cipher.toCipherData("userId")).toEqual(cipherData);
- });
-
- it("Decrypt", async () => {
- const cipher = new Cipher();
- cipher.id = "id";
- cipher.organizationId = "orgId";
- cipher.folderId = "folderId";
- cipher.edit = true;
- cipher.viewPassword = true;
- cipher.organizationUseTotp = true;
- cipher.favorite = false;
- cipher.revisionDate = new Date("2022-01-31T12:00:00.000Z");
- cipher.type = CipherType.Login;
- cipher.name = mockEnc("EncryptedString");
- cipher.notes = mockEnc("EncryptedString");
- cipher.deletedDate = null;
- cipher.reprompt = CipherRepromptType.None;
-
- const loginView = new LoginView();
- loginView.username = "username";
- loginView.password = "password";
-
- const login = Substitute.for();
- login.decrypt(Arg.any(), Arg.any()).resolves(loginView);
- cipher.login = login;
-
- const cipherView = await cipher.decrypt();
-
- expect(cipherView).toMatchObject({
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- name: "EncryptedString",
- notes: "EncryptedString",
- type: 1,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- login: loginView,
- attachments: null,
- fields: null,
- passwordHistory: null,
- collectionIds: undefined,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- deletedDate: null,
- reprompt: 0,
- localData: undefined,
- });
- });
- });
-
- describe("SecureNoteCipher", () => {
- let cipherData: CipherData;
-
- beforeEach(() => {
- cipherData = {
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- userId: "userId",
- edit: true,
- viewPassword: true,
- organizationUseTotp: true,
- favorite: false,
- revisionDate: "2022-01-31T12:00:00.000Z",
- type: CipherType.SecureNote,
- name: "EncryptedString",
- notes: "EncryptedString",
- deletedDate: null,
- reprompt: CipherRepromptType.None,
- secureNote: {
- type: SecureNoteType.Generic,
- },
- };
- });
-
- it("Convert", () => {
- const cipher = new Cipher(cipherData);
-
- expect(cipher).toEqual({
- id: "id",
- userId: "userId",
- organizationId: "orgId",
- folderId: "folderId",
- name: { encryptedString: "EncryptedString", encryptionType: 0 },
- notes: { encryptedString: "EncryptedString", encryptionType: 0 },
- type: 2,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- collectionIds: undefined,
- localData: null,
- deletedDate: null,
- reprompt: 0,
- secureNote: { type: SecureNoteType.Generic },
- attachments: null,
- fields: null,
- passwordHistory: null,
- });
- });
-
- it("toCipherData", () => {
- const cipher = new Cipher(cipherData);
- expect(cipher.toCipherData("userId")).toEqual(cipherData);
- });
-
- it("Decrypt", async () => {
- const cipher = new Cipher();
- cipher.id = "id";
- cipher.organizationId = "orgId";
- cipher.folderId = "folderId";
- cipher.edit = true;
- cipher.viewPassword = true;
- cipher.organizationUseTotp = true;
- cipher.favorite = false;
- cipher.revisionDate = new Date("2022-01-31T12:00:00.000Z");
- cipher.type = CipherType.SecureNote;
- cipher.name = mockEnc("EncryptedString");
- cipher.notes = mockEnc("EncryptedString");
- cipher.deletedDate = null;
- cipher.reprompt = CipherRepromptType.None;
- cipher.secureNote = new SecureNote();
- cipher.secureNote.type = SecureNoteType.Generic;
-
- const cipherView = await cipher.decrypt();
-
- expect(cipherView).toMatchObject({
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- name: "EncryptedString",
- notes: "EncryptedString",
- type: 2,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- secureNote: { type: 0 },
- attachments: null,
- fields: null,
- passwordHistory: null,
- collectionIds: undefined,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- deletedDate: null,
- reprompt: 0,
- localData: undefined,
- });
- });
- });
-
- describe("CardCipher", () => {
- let cipherData: CipherData;
-
- beforeEach(() => {
- cipherData = {
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- userId: "userId",
- edit: true,
- viewPassword: true,
- organizationUseTotp: true,
- favorite: false,
- revisionDate: "2022-01-31T12:00:00.000Z",
- type: CipherType.Card,
- name: "EncryptedString",
- notes: "EncryptedString",
- deletedDate: null,
- reprompt: CipherRepromptType.None,
- card: {
- cardholderName: "EncryptedString",
- brand: "EncryptedString",
- number: "EncryptedString",
- expMonth: "EncryptedString",
- expYear: "EncryptedString",
- code: "EncryptedString",
- },
- };
- });
-
- it("Convert", () => {
- const cipher = new Cipher(cipherData);
-
- expect(cipher).toEqual({
- id: "id",
- userId: "userId",
- organizationId: "orgId",
- folderId: "folderId",
- name: { encryptedString: "EncryptedString", encryptionType: 0 },
- notes: { encryptedString: "EncryptedString", encryptionType: 0 },
- type: 3,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- collectionIds: undefined,
- localData: null,
- deletedDate: null,
- reprompt: 0,
- card: {
- cardholderName: { encryptedString: "EncryptedString", encryptionType: 0 },
- brand: { encryptedString: "EncryptedString", encryptionType: 0 },
- number: { encryptedString: "EncryptedString", encryptionType: 0 },
- expMonth: { encryptedString: "EncryptedString", encryptionType: 0 },
- expYear: { encryptedString: "EncryptedString", encryptionType: 0 },
- code: { encryptedString: "EncryptedString", encryptionType: 0 },
- },
- attachments: null,
- fields: null,
- passwordHistory: null,
- });
- });
-
- it("toCipherData", () => {
- const cipher = new Cipher(cipherData);
- expect(cipher.toCipherData("userId")).toEqual(cipherData);
- });
-
- it("Decrypt", async () => {
- const cipher = new Cipher();
- cipher.id = "id";
- cipher.organizationId = "orgId";
- cipher.folderId = "folderId";
- cipher.edit = true;
- cipher.viewPassword = true;
- cipher.organizationUseTotp = true;
- cipher.favorite = false;
- cipher.revisionDate = new Date("2022-01-31T12:00:00.000Z");
- cipher.type = CipherType.Card;
- cipher.name = mockEnc("EncryptedString");
- cipher.notes = mockEnc("EncryptedString");
- cipher.deletedDate = null;
- cipher.reprompt = CipherRepromptType.None;
-
- const cardView = new CardView();
- cardView.cardholderName = "cardholderName";
- cardView.number = "4111111111111111";
-
- const card = Substitute.for();
- card.decrypt(Arg.any(), Arg.any()).resolves(cardView);
- cipher.card = card;
-
- const cipherView = await cipher.decrypt();
-
- expect(cipherView).toMatchObject({
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- name: "EncryptedString",
- notes: "EncryptedString",
- type: 3,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- card: cardView,
- attachments: null,
- fields: null,
- passwordHistory: null,
- collectionIds: undefined,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- deletedDate: null,
- reprompt: 0,
- localData: undefined,
- });
- });
- });
-
- describe("IdentityCipher", () => {
- let cipherData: CipherData;
-
- beforeEach(() => {
- cipherData = {
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- userId: "userId",
- edit: true,
- viewPassword: true,
- organizationUseTotp: true,
- favorite: false,
- revisionDate: "2022-01-31T12:00:00.000Z",
- type: CipherType.Identity,
- name: "EncryptedString",
- notes: "EncryptedString",
- deletedDate: null,
- reprompt: CipherRepromptType.None,
- identity: {
- title: "EncryptedString",
- firstName: "EncryptedString",
- middleName: "EncryptedString",
- lastName: "EncryptedString",
- address1: "EncryptedString",
- address2: "EncryptedString",
- address3: "EncryptedString",
- city: "EncryptedString",
- state: "EncryptedString",
- postalCode: "EncryptedString",
- country: "EncryptedString",
- company: "EncryptedString",
- email: "EncryptedString",
- phone: "EncryptedString",
- ssn: "EncryptedString",
- username: "EncryptedString",
- passportNumber: "EncryptedString",
- licenseNumber: "EncryptedString",
- },
- };
- });
-
- it("Convert", () => {
- const cipher = new Cipher(cipherData);
-
- expect(cipher).toEqual({
- id: "id",
- userId: "userId",
- organizationId: "orgId",
- folderId: "folderId",
- name: { encryptedString: "EncryptedString", encryptionType: 0 },
- notes: { encryptedString: "EncryptedString", encryptionType: 0 },
- type: 4,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- collectionIds: undefined,
- localData: null,
- deletedDate: null,
- reprompt: 0,
- identity: {
- title: { encryptedString: "EncryptedString", encryptionType: 0 },
- firstName: { encryptedString: "EncryptedString", encryptionType: 0 },
- middleName: { encryptedString: "EncryptedString", encryptionType: 0 },
- lastName: { encryptedString: "EncryptedString", encryptionType: 0 },
- address1: { encryptedString: "EncryptedString", encryptionType: 0 },
- address2: { encryptedString: "EncryptedString", encryptionType: 0 },
- address3: { encryptedString: "EncryptedString", encryptionType: 0 },
- city: { encryptedString: "EncryptedString", encryptionType: 0 },
- state: { encryptedString: "EncryptedString", encryptionType: 0 },
- postalCode: { encryptedString: "EncryptedString", encryptionType: 0 },
- country: { encryptedString: "EncryptedString", encryptionType: 0 },
- company: { encryptedString: "EncryptedString", encryptionType: 0 },
- email: { encryptedString: "EncryptedString", encryptionType: 0 },
- phone: { encryptedString: "EncryptedString", encryptionType: 0 },
- ssn: { encryptedString: "EncryptedString", encryptionType: 0 },
- username: { encryptedString: "EncryptedString", encryptionType: 0 },
- passportNumber: { encryptedString: "EncryptedString", encryptionType: 0 },
- licenseNumber: { encryptedString: "EncryptedString", encryptionType: 0 },
- },
- attachments: null,
- fields: null,
- passwordHistory: null,
- });
- });
-
- it("toCipherData", () => {
- const cipher = new Cipher(cipherData);
- expect(cipher.toCipherData("userId")).toEqual(cipherData);
- });
-
- it("Decrypt", async () => {
- const cipher = new Cipher();
- cipher.id = "id";
- cipher.organizationId = "orgId";
- cipher.folderId = "folderId";
- cipher.edit = true;
- cipher.viewPassword = true;
- cipher.organizationUseTotp = true;
- cipher.favorite = false;
- cipher.revisionDate = new Date("2022-01-31T12:00:00.000Z");
- cipher.type = CipherType.Identity;
- cipher.name = mockEnc("EncryptedString");
- cipher.notes = mockEnc("EncryptedString");
- cipher.deletedDate = null;
- cipher.reprompt = CipherRepromptType.None;
-
- const identityView = new IdentityView();
- identityView.firstName = "firstName";
- identityView.lastName = "lastName";
-
- const identity = Substitute.for();
- identity.decrypt(Arg.any(), Arg.any()).resolves(identityView);
- cipher.identity = identity;
-
- const cipherView = await cipher.decrypt();
-
- expect(cipherView).toMatchObject({
- id: "id",
- organizationId: "orgId",
- folderId: "folderId",
- name: "EncryptedString",
- notes: "EncryptedString",
- type: 4,
- favorite: false,
- organizationUseTotp: true,
- edit: true,
- viewPassword: true,
- identity: identityView,
- attachments: null,
- fields: null,
- passwordHistory: null,
- collectionIds: undefined,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- deletedDate: null,
- reprompt: 0,
- localData: undefined,
- });
- });
- });
-});
diff --git a/jslib/common/spec/domain/collection.spec.ts b/jslib/common/spec/domain/collection.spec.ts
deleted file mode 100644
index e5cf1d66..00000000
--- a/jslib/common/spec/domain/collection.spec.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { CollectionData } from "@/jslib/common/src/models/data/collectionData";
-import { Collection } from "@/jslib/common/src/models/domain/collection";
-
-import { mockEnc } from "../utils";
-
-describe("Collection", () => {
- let data: CollectionData;
-
- beforeEach(() => {
- data = {
- id: "id",
- organizationId: "orgId",
- name: "encName",
- externalId: "extId",
- readOnly: true,
- };
- });
-
- it("Convert from empty", () => {
- const data = new CollectionData({} as any);
- const card = new Collection(data);
-
- expect(card).toEqual({
- externalId: null,
- hidePasswords: null,
- id: null,
- name: null,
- organizationId: null,
- readOnly: null,
- });
- });
-
- it("Convert", () => {
- const collection = new Collection(data);
-
- expect(collection).toEqual({
- id: "id",
- organizationId: "orgId",
- name: { encryptedString: "encName", encryptionType: 0 },
- externalId: "extId",
- readOnly: true,
- hidePasswords: null,
- });
- });
-
- it("Decrypt", async () => {
- const collection = new Collection();
- collection.id = "id";
- collection.organizationId = "orgId";
- collection.name = mockEnc("encName");
- collection.externalId = "extId";
- collection.readOnly = false;
- collection.hidePasswords = false;
-
- const view = await collection.decrypt();
-
- expect(view).toEqual({
- externalId: "extId",
- hidePasswords: false,
- id: "id",
- name: "encName",
- organizationId: "orgId",
- readOnly: false,
- });
- });
-});
diff --git a/jslib/common/spec/domain/field.spec.ts b/jslib/common/spec/domain/field.spec.ts
deleted file mode 100644
index 452b0cd9..00000000
--- a/jslib/common/spec/domain/field.spec.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import { FieldType } from "@/jslib/common/src/enums/fieldType";
-import { FieldData } from "@/jslib/common/src/models/data/fieldData";
-import { Field } from "@/jslib/common/src/models/domain/field";
-
-import { mockEnc } from "../utils";
-
-describe("Field", () => {
- let data: FieldData;
-
- beforeEach(() => {
- data = {
- type: FieldType.Text,
- name: "encName",
- value: "encValue",
- linkedId: null,
- };
- });
-
- it("Convert from empty", () => {
- const data = new FieldData();
- const field = new Field(data);
-
- expect(field).toEqual({
- type: undefined,
- name: null,
- value: null,
- linkedId: undefined,
- });
- });
-
- it("Convert", () => {
- const field = new Field(data);
-
- expect(field).toEqual({
- type: FieldType.Text,
- name: { encryptedString: "encName", encryptionType: 0 },
- value: { encryptedString: "encValue", encryptionType: 0 },
- linkedId: null,
- });
- });
-
- it("toFieldData", () => {
- const field = new Field(data);
- expect(field.toFieldData()).toEqual(data);
- });
-
- it("Decrypt", async () => {
- const field = new Field();
- field.type = FieldType.Text;
- field.name = mockEnc("encName");
- field.value = mockEnc("encValue");
-
- const view = await field.decrypt(null);
-
- expect(view).toEqual({
- type: 0,
- name: "encName",
- value: "encValue",
- newField: false,
- showCount: false,
- showValue: false,
- });
- });
-});
diff --git a/jslib/common/spec/domain/folder.spec.ts b/jslib/common/spec/domain/folder.spec.ts
deleted file mode 100644
index dc22f829..00000000
--- a/jslib/common/spec/domain/folder.spec.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { FolderData } from "@/jslib/common/src/models/data/folderData";
-import { Folder } from "@/jslib/common/src/models/domain/folder";
-
-import { mockEnc } from "../utils";
-
-describe("Folder", () => {
- let data: FolderData;
-
- beforeEach(() => {
- data = {
- id: "id",
- userId: "userId",
- name: "encName",
- revisionDate: "2022-01-31T12:00:00.000Z",
- };
- });
-
- it("Convert", () => {
- const field = new Folder(data);
-
- expect(field).toEqual({
- id: "id",
- name: { encryptedString: "encName", encryptionType: 0 },
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- });
- });
-
- it("Decrypt", async () => {
- const folder = new Folder();
- folder.id = "id";
- folder.name = mockEnc("encName");
- folder.revisionDate = new Date("2022-01-31T12:00:00.000Z");
-
- const view = await folder.decrypt();
-
- expect(view).toEqual({
- id: "id",
- name: "encName",
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- });
- });
-});
diff --git a/jslib/common/spec/domain/identity.spec.ts b/jslib/common/spec/domain/identity.spec.ts
deleted file mode 100644
index f77459aa..00000000
--- a/jslib/common/spec/domain/identity.spec.ts
+++ /dev/null
@@ -1,134 +0,0 @@
-import { IdentityData } from "@/jslib/common/src/models/data/identityData";
-import { Identity } from "@/jslib/common/src/models/domain/identity";
-
-import { mockEnc } from "../utils";
-
-describe("Identity", () => {
- let data: IdentityData;
-
- beforeEach(() => {
- data = {
- title: "enctitle",
- firstName: "encfirstName",
- middleName: "encmiddleName",
- lastName: "enclastName",
- address1: "encaddress1",
- address2: "encaddress2",
- address3: "encaddress3",
- city: "enccity",
- state: "encstate",
- postalCode: "encpostalCode",
- country: "enccountry",
- company: "enccompany",
- email: "encemail",
- phone: "encphone",
- ssn: "encssn",
- username: "encusername",
- passportNumber: "encpassportNumber",
- licenseNumber: "enclicenseNumber",
- };
- });
-
- it("Convert from empty", () => {
- const data = new IdentityData();
- const identity = new Identity(data);
-
- expect(identity).toEqual({
- address1: null,
- address2: null,
- address3: null,
- city: null,
- company: null,
- country: null,
- email: null,
- firstName: null,
- lastName: null,
- licenseNumber: null,
- middleName: null,
- passportNumber: null,
- phone: null,
- postalCode: null,
- ssn: null,
- state: null,
- title: null,
- username: null,
- });
- });
-
- it("Convert", () => {
- const identity = new Identity(data);
-
- expect(identity).toEqual({
- title: { encryptedString: "enctitle", encryptionType: 0 },
- firstName: { encryptedString: "encfirstName", encryptionType: 0 },
- middleName: { encryptedString: "encmiddleName", encryptionType: 0 },
- lastName: { encryptedString: "enclastName", encryptionType: 0 },
- address1: { encryptedString: "encaddress1", encryptionType: 0 },
- address2: { encryptedString: "encaddress2", encryptionType: 0 },
- address3: { encryptedString: "encaddress3", encryptionType: 0 },
- city: { encryptedString: "enccity", encryptionType: 0 },
- state: { encryptedString: "encstate", encryptionType: 0 },
- postalCode: { encryptedString: "encpostalCode", encryptionType: 0 },
- country: { encryptedString: "enccountry", encryptionType: 0 },
- company: { encryptedString: "enccompany", encryptionType: 0 },
- email: { encryptedString: "encemail", encryptionType: 0 },
- phone: { encryptedString: "encphone", encryptionType: 0 },
- ssn: { encryptedString: "encssn", encryptionType: 0 },
- username: { encryptedString: "encusername", encryptionType: 0 },
- passportNumber: { encryptedString: "encpassportNumber", encryptionType: 0 },
- licenseNumber: { encryptedString: "enclicenseNumber", encryptionType: 0 },
- });
- });
-
- it("toIdentityData", () => {
- const identity = new Identity(data);
- expect(identity.toIdentityData()).toEqual(data);
- });
-
- it("Decrypt", async () => {
- const identity = new Identity();
-
- identity.title = mockEnc("mockTitle");
- identity.firstName = mockEnc("mockFirstName");
- identity.middleName = mockEnc("mockMiddleName");
- identity.lastName = mockEnc("mockLastName");
- identity.address1 = mockEnc("mockAddress1");
- identity.address2 = mockEnc("mockAddress2");
- identity.address3 = mockEnc("mockAddress3");
- identity.city = mockEnc("mockCity");
- identity.state = mockEnc("mockState");
- identity.postalCode = mockEnc("mockPostalCode");
- identity.country = mockEnc("mockCountry");
- identity.company = mockEnc("mockCompany");
- identity.email = mockEnc("mockEmail");
- identity.phone = mockEnc("mockPhone");
- identity.ssn = mockEnc("mockSsn");
- identity.username = mockEnc("mockUsername");
- identity.passportNumber = mockEnc("mockPassportNumber");
- identity.licenseNumber = mockEnc("mockLicenseNumber");
-
- const view = await identity.decrypt(null);
-
- expect(view).toEqual({
- _firstName: "mockFirstName",
- _lastName: "mockLastName",
- _subTitle: null,
- address1: "mockAddress1",
- address2: "mockAddress2",
- address3: "mockAddress3",
- city: "mockCity",
- company: "mockCompany",
- country: "mockCountry",
- email: "mockEmail",
- licenseNumber: "mockLicenseNumber",
- middleName: "mockMiddleName",
- passportNumber: "mockPassportNumber",
- phone: "mockPhone",
- postalCode: "mockPostalCode",
- ssn: "mockSsn",
- state: "mockState",
- title: "mockTitle",
- username: "mockUsername",
- });
- });
-});
diff --git a/jslib/common/spec/domain/login.spec.ts b/jslib/common/spec/domain/login.spec.ts
deleted file mode 100644
index 51ad07f5..00000000
--- a/jslib/common/spec/domain/login.spec.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-import { Substitute, Arg } from "@fluffy-spoon/substitute";
-
-import { UriMatchType } from "@/jslib/common/src/enums/uriMatchType";
-import { LoginData } from "@/jslib/common/src/models/data/loginData";
-import { Login } from "@/jslib/common/src/models/domain/login";
-import { LoginUri } from "@/jslib/common/src/models/domain/loginUri";
-import { LoginUriView } from "@/jslib/common/src/models/view/loginUriView";
-
-import { mockEnc } from "../utils";
-
-describe("Login DTO", () => {
- it("Convert from empty LoginData", () => {
- const data = new LoginData();
- const login = new Login(data);
-
- expect(login).toEqual({
- passwordRevisionDate: null,
- autofillOnPageLoad: undefined,
- username: null,
- password: null,
- totp: null,
- });
- });
-
- it("Convert from full LoginData", () => {
- const data: LoginData = {
- uris: [{ uri: "uri", match: UriMatchType.Domain }],
- username: "username",
- password: "password",
- passwordRevisionDate: "2022-01-31T12:00:00.000Z",
- totp: "123",
- autofillOnPageLoad: false,
- };
- const login = new Login(data);
-
- expect(login).toEqual({
- passwordRevisionDate: new Date("2022-01-31T12:00:00.000Z"),
- autofillOnPageLoad: false,
- username: { encryptedString: "username", encryptionType: 0 },
- password: { encryptedString: "password", encryptionType: 0 },
- totp: { encryptedString: "123", encryptionType: 0 },
- uris: [{ match: 0, uri: { encryptedString: "uri", encryptionType: 0 } }],
- });
- });
-
- it("Initialize without LoginData", () => {
- const login = new Login();
-
- expect(login).toEqual({});
- });
-
- it("Decrypts correctly", async () => {
- const loginUri = Substitute.for();
- const loginUriView = new LoginUriView();
- loginUriView.uri = "decrypted uri";
- loginUri.decrypt(Arg.any()).resolves(loginUriView);
-
- const login = new Login();
- login.uris = [loginUri];
- login.username = mockEnc("encrypted username");
- login.password = mockEnc("encrypted password");
- login.passwordRevisionDate = new Date("2022-01-31T12:00:00.000Z");
- login.totp = mockEnc("encrypted totp");
- login.autofillOnPageLoad = true;
-
- const loginView = await login.decrypt(null);
- expect(loginView).toEqual({
- username: "encrypted username",
- password: "encrypted password",
- passwordRevisionDate: new Date("2022-01-31T12:00:00.000Z"),
- totp: "encrypted totp",
- uris: [
- {
- match: null,
- _uri: "decrypted uri",
- _domain: null,
- _hostname: null,
- _host: null,
- _canLaunch: null,
- },
- ],
- autofillOnPageLoad: true,
- });
- });
-
- it("Converts from LoginData and back", () => {
- const data: LoginData = {
- uris: [{ uri: "uri", match: UriMatchType.Domain }],
- username: "username",
- password: "password",
- passwordRevisionDate: "2022-01-31T12:00:00.000Z",
- totp: "123",
- autofillOnPageLoad: false,
- };
- const login = new Login(data);
-
- const loginData = login.toLoginData();
-
- expect(loginData).toEqual(data);
- });
-});
diff --git a/jslib/common/spec/domain/loginUri.spec.ts b/jslib/common/spec/domain/loginUri.spec.ts
deleted file mode 100644
index 1522d374..00000000
--- a/jslib/common/spec/domain/loginUri.spec.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { UriMatchType } from "@/jslib/common/src/enums/uriMatchType";
-import { LoginUriData } from "@/jslib/common/src/models/data/loginUriData";
-import { LoginUri } from "@/jslib/common/src/models/domain/loginUri";
-
-import { mockEnc } from "../utils";
-
-describe("LoginUri", () => {
- let data: LoginUriData;
-
- beforeEach(() => {
- data = {
- uri: "encUri",
- match: UriMatchType.Domain,
- };
- });
-
- it("Convert from empty", () => {
- const data = new LoginUriData();
- const loginUri = new LoginUri(data);
-
- expect(loginUri).toEqual({
- match: null,
- uri: null,
- });
- });
-
- it("Convert", () => {
- const loginUri = new LoginUri(data);
-
- expect(loginUri).toEqual({
- match: 0,
- uri: { encryptedString: "encUri", encryptionType: 0 },
- });
- });
-
- it("toLoginUriData", () => {
- const loginUri = new LoginUri(data);
- expect(loginUri.toLoginUriData()).toEqual(data);
- });
-
- it("Decrypt", async () => {
- const loginUri = new LoginUri();
- loginUri.match = UriMatchType.Exact;
- loginUri.uri = mockEnc("uri");
-
- const view = await loginUri.decrypt(null);
-
- expect(view).toEqual({
- _canLaunch: null,
- _domain: null,
- _host: null,
- _hostname: null,
- _uri: "uri",
- match: 3,
- });
- });
-});
diff --git a/jslib/common/spec/domain/password.spec.ts b/jslib/common/spec/domain/password.spec.ts
deleted file mode 100644
index 1ddbb46f..00000000
--- a/jslib/common/spec/domain/password.spec.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { PasswordHistoryData } from "@/jslib/common/src/models/data/passwordHistoryData";
-import { Password } from "@/jslib/common/src/models/domain/password";
-
-import { mockEnc } from "../utils";
-
-describe("Password", () => {
- let data: PasswordHistoryData;
-
- beforeEach(() => {
- data = {
- password: "encPassword",
- lastUsedDate: "2022-01-31T12:00:00.000Z",
- };
- });
-
- it("Convert from empty", () => {
- const data = new PasswordHistoryData();
- const password = new Password(data);
-
- expect(password).toMatchObject({
- password: null,
- });
- });
-
- it("Convert", () => {
- const password = new Password(data);
-
- expect(password).toEqual({
- password: { encryptedString: "encPassword", encryptionType: 0 },
- lastUsedDate: new Date("2022-01-31T12:00:00.000Z"),
- });
- });
-
- it("toPasswordHistoryData", () => {
- const password = new Password(data);
- expect(password.toPasswordHistoryData()).toEqual(data);
- });
-
- it("Decrypt", async () => {
- const password = new Password();
- password.password = mockEnc("password");
- password.lastUsedDate = new Date("2022-01-31T12:00:00.000Z");
-
- const view = await password.decrypt(null);
-
- expect(view).toEqual({
- password: "password",
- lastUsedDate: new Date("2022-01-31T12:00:00.000Z"),
- });
- });
-});
diff --git a/jslib/common/spec/domain/secureNote.spec.ts b/jslib/common/spec/domain/secureNote.spec.ts
deleted file mode 100644
index 710b96cc..00000000
--- a/jslib/common/spec/domain/secureNote.spec.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { SecureNoteType } from "@/jslib/common/src/enums/secureNoteType";
-import { SecureNoteData } from "@/jslib/common/src/models/data/secureNoteData";
-import { SecureNote } from "@/jslib/common/src/models/domain/secureNote";
-
-describe("SecureNote", () => {
- let data: SecureNoteData;
-
- beforeEach(() => {
- data = {
- type: SecureNoteType.Generic,
- };
- });
-
- it("Convert from empty", () => {
- const data = new SecureNoteData();
- const secureNote = new SecureNote(data);
-
- expect(secureNote).toEqual({
- type: undefined,
- });
- });
-
- it("Convert", () => {
- const secureNote = new SecureNote(data);
-
- expect(secureNote).toEqual({
- type: 0,
- });
- });
-
- it("toSecureNoteData", () => {
- const secureNote = new SecureNote(data);
- expect(secureNote.toSecureNoteData()).toEqual(data);
- });
-
- it("Decrypt", async () => {
- const secureNote = new SecureNote();
- secureNote.type = SecureNoteType.Generic;
-
- const view = await secureNote.decrypt(null);
-
- expect(view).toEqual({
- type: 0,
- });
- });
-});
diff --git a/jslib/common/spec/domain/send.spec.ts b/jslib/common/spec/domain/send.spec.ts
deleted file mode 100644
index ab34895f..00000000
--- a/jslib/common/spec/domain/send.spec.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-import { Substitute, Arg, SubstituteOf } from "@fluffy-spoon/substitute";
-
-import { CryptoService } from "@/jslib/common/src/abstractions/crypto.service";
-import { SendType } from "@/jslib/common/src/enums/sendType";
-import { SendData } from "@/jslib/common/src/models/data/sendData";
-import { EncString } from "@/jslib/common/src/models/domain/encString";
-import { Send } from "@/jslib/common/src/models/domain/send";
-import { SendText } from "@/jslib/common/src/models/domain/sendText";
-import { ContainerService } from "@/jslib/common/src/services/container.service";
-
-import { makeStaticByteArray, mockEnc } from "../utils";
-
-describe("Send", () => {
- let data: SendData;
-
- beforeEach(() => {
- data = {
- id: "id",
- accessId: "accessId",
- userId: "userId",
- type: SendType.Text,
- name: "encName",
- notes: "encNotes",
- text: {
- text: "encText",
- hidden: true,
- },
- file: null,
- key: "encKey",
- maxAccessCount: null,
- accessCount: 10,
- revisionDate: "2022-01-31T12:00:00.000Z",
- expirationDate: "2022-01-31T12:00:00.000Z",
- deletionDate: "2022-01-31T12:00:00.000Z",
- password: "password",
- disabled: false,
- hideEmail: true,
- };
- });
-
- it("Convert from empty", () => {
- const data = new SendData();
- const send = new Send(data);
-
- expect(send).toEqual({
- id: null,
- accessId: null,
- userId: null,
- type: undefined,
- name: null,
- notes: null,
- text: undefined,
- file: undefined,
- key: null,
- maxAccessCount: undefined,
- accessCount: undefined,
- revisionDate: null,
- expirationDate: null,
- deletionDate: null,
- password: undefined,
- disabled: undefined,
- hideEmail: undefined,
- });
- });
-
- it("Convert", () => {
- const send = new Send(data);
-
- expect(send).toEqual({
- id: "id",
- accessId: "accessId",
- userId: "userId",
- type: SendType.Text,
- name: { encryptedString: "encName", encryptionType: 0 },
- notes: { encryptedString: "encNotes", encryptionType: 0 },
- text: {
- text: { encryptedString: "encText", encryptionType: 0 },
- hidden: true,
- },
- key: { encryptedString: "encKey", encryptionType: 0 },
- maxAccessCount: null,
- accessCount: 10,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- expirationDate: new Date("2022-01-31T12:00:00.000Z"),
- deletionDate: new Date("2022-01-31T12:00:00.000Z"),
- password: "password",
- disabled: false,
- hideEmail: true,
- });
- });
-
- it("Decrypt", async () => {
- const text = Substitute.for();
- text.decrypt(Arg.any()).resolves("textView" as any);
-
- const send = new Send();
- send.id = "id";
- send.accessId = "accessId";
- send.userId = "userId";
- send.type = SendType.Text;
- send.name = mockEnc("name");
- send.notes = mockEnc("notes");
- send.text = text;
- send.key = mockEnc("key");
- send.accessCount = 10;
- send.revisionDate = new Date("2022-01-31T12:00:00.000Z");
- send.expirationDate = new Date("2022-01-31T12:00:00.000Z");
- send.deletionDate = new Date("2022-01-31T12:00:00.000Z");
- send.password = "password";
- send.disabled = false;
- send.hideEmail = true;
-
- const cryptoService = Substitute.for();
- cryptoService.decryptToBytes(send.key, null).resolves(makeStaticByteArray(32));
- cryptoService.makeSendKey(Arg.any()).resolves("cryptoKey" as any);
-
- (window as any).bitwardenContainerService = new ContainerService(cryptoService);
-
- const view = await send.decrypt();
-
- text.received(1).decrypt("cryptoKey" as any);
- (send.name as SubstituteOf).received(1).decrypt(null, "cryptoKey" as any);
-
- expect(view).toMatchObject({
- id: "id",
- accessId: "accessId",
- name: "name",
- notes: "notes",
- type: 0,
- key: expect.anything(),
- cryptoKey: "cryptoKey",
- file: expect.anything(),
- text: "textView",
- maxAccessCount: undefined,
- accessCount: 10,
- revisionDate: new Date("2022-01-31T12:00:00.000Z"),
- expirationDate: new Date("2022-01-31T12:00:00.000Z"),
- deletionDate: new Date("2022-01-31T12:00:00.000Z"),
- password: "password",
- disabled: false,
- hideEmail: true,
- });
- });
-});
diff --git a/jslib/common/spec/domain/sendAccess.spec.ts b/jslib/common/spec/domain/sendAccess.spec.ts
deleted file mode 100644
index 95373f06..00000000
--- a/jslib/common/spec/domain/sendAccess.spec.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { Substitute, Arg } from "@fluffy-spoon/substitute";
-
-import { SendType } from "@/jslib/common/src/enums/sendType";
-import { SendAccess } from "@/jslib/common/src/models/domain/sendAccess";
-import { SendText } from "@/jslib/common/src/models/domain/sendText";
-import { SendAccessResponse } from "@/jslib/common/src/models/response/sendAccessResponse";
-
-import { mockEnc } from "../utils";
-
-describe("SendAccess", () => {
- let request: SendAccessResponse;
-
- beforeEach(() => {
- request = {
- id: "id",
- type: SendType.Text,
- name: "encName",
- file: null,
- text: {
- text: "encText",
- hidden: true,
- },
- expirationDate: new Date("2022-01-31T12:00:00.000Z"),
- creatorIdentifier: "creatorIdentifier",
- } as SendAccessResponse;
- });
-
- it("Convert from empty", () => {
- const request = new SendAccessResponse({});
- const sendAccess = new SendAccess(request);
-
- expect(sendAccess).toEqual({
- id: null,
- type: undefined,
- name: null,
- creatorIdentifier: null,
- expirationDate: null,
- });
- });
-
- it("Convert", () => {
- const sendAccess = new SendAccess(request);
-
- expect(sendAccess).toEqual({
- id: "id",
- type: 0,
- name: { encryptedString: "encName", encryptionType: 0 },
- text: {
- hidden: true,
- text: { encryptedString: "encText", encryptionType: 0 },
- },
- expirationDate: new Date("2022-01-31T12:00:00.000Z"),
- creatorIdentifier: "creatorIdentifier",
- });
- });
-
- it("Decrypt", async () => {
- const sendAccess = new SendAccess();
- sendAccess.id = "id";
- sendAccess.type = SendType.Text;
- sendAccess.name = mockEnc("name");
-
- const text = Substitute.for();
- text.decrypt(Arg.any()).resolves({} as any);
- sendAccess.text = text;
-
- sendAccess.expirationDate = new Date("2022-01-31T12:00:00.000Z");
- sendAccess.creatorIdentifier = "creatorIdentifier";
-
- const view = await sendAccess.decrypt(null);
-
- text.received(1).decrypt(Arg.any());
-
- expect(view).toEqual({
- id: "id",
- type: 0,
- name: "name",
- text: {},
- file: expect.anything(),
- expirationDate: new Date("2022-01-31T12:00:00.000Z"),
- creatorIdentifier: "creatorIdentifier",
- });
- });
-});
diff --git a/jslib/common/spec/domain/sendFile.spec.ts b/jslib/common/spec/domain/sendFile.spec.ts
deleted file mode 100644
index 70da0b03..00000000
--- a/jslib/common/spec/domain/sendFile.spec.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { SendFileData } from "@/jslib/common/src/models/data/sendFileData";
-import { SendFile } from "@/jslib/common/src/models/domain/sendFile";
-
-import { mockEnc } from "../utils";
-
-describe("SendFile", () => {
- let data: SendFileData;
-
- beforeEach(() => {
- data = {
- id: "id",
- size: "1100",
- sizeName: "1.1 KB",
- fileName: "encFileName",
- };
- });
-
- it("Convert from empty", () => {
- const data = new SendFileData();
- const sendFile = new SendFile(data);
-
- expect(sendFile).toEqual({
- fileName: null,
- id: null,
- size: undefined,
- sizeName: null,
- });
- });
-
- it("Convert", () => {
- const sendFile = new SendFile(data);
-
- expect(sendFile).toEqual({
- id: "id",
- size: "1100",
- sizeName: "1.1 KB",
- fileName: { encryptedString: "encFileName", encryptionType: 0 },
- });
- });
-
- it("Decrypt", async () => {
- const sendFile = new SendFile();
- sendFile.id = "id";
- sendFile.size = "1100";
- sendFile.sizeName = "1.1 KB";
- sendFile.fileName = mockEnc("fileName");
-
- const view = await sendFile.decrypt(null);
-
- expect(view).toEqual({
- fileName: "fileName",
- id: "id",
- size: "1100",
- sizeName: "1.1 KB",
- });
- });
-});
diff --git a/jslib/common/spec/domain/sendText.spec.ts b/jslib/common/spec/domain/sendText.spec.ts
deleted file mode 100644
index eb82c93c..00000000
--- a/jslib/common/spec/domain/sendText.spec.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { SendTextData } from "@/jslib/common/src/models/data/sendTextData";
-import { SendText } from "@/jslib/common/src/models/domain/sendText";
-
-import { mockEnc } from "../utils";
-
-describe("SendText", () => {
- let data: SendTextData;
-
- beforeEach(() => {
- data = {
- text: "encText",
- hidden: false,
- };
- });
-
- it("Convert from empty", () => {
- const data = new SendTextData();
- const secureNote = new SendText(data);
-
- expect(secureNote).toEqual({
- hidden: undefined,
- text: null,
- });
- });
-
- it("Convert", () => {
- const secureNote = new SendText(data);
-
- expect(secureNote).toEqual({
- hidden: false,
- text: { encryptedString: "encText", encryptionType: 0 },
- });
- });
-
- it("Decrypt", async () => {
- const secureNote = new SendText();
- secureNote.text = mockEnc("text");
- secureNote.hidden = true;
-
- const view = await secureNote.decrypt(null);
-
- expect(view).toEqual({
- text: "text",
- hidden: true,
- });
- });
-});
diff --git a/jslib/common/src/abstractions/state.service.ts b/jslib/common/src/abstractions/state.service.ts
index cabe5836..df30f264 100644
--- a/jslib/common/src/abstractions/state.service.ts
+++ b/jslib/common/src/abstractions/state.service.ts
@@ -3,26 +3,14 @@ import { Observable } from "rxjs";
import { KdfType } from "../enums/kdfType";
import { ThemeType } from "../enums/themeType";
import { UriMatchType } from "../enums/uriMatchType";
-import { CipherData } from "../models/data/cipherData";
-import { CollectionData } from "../models/data/collectionData";
-import { EventData } from "../models/data/eventData";
-import { FolderData } from "../models/data/folderData";
import { OrganizationData } from "../models/data/organizationData";
-import { PolicyData } from "../models/data/policyData";
import { ProviderData } from "../models/data/providerData";
-import { SendData } from "../models/data/sendData";
import { Account } from "../models/domain/account";
import { EncString } from "../models/domain/encString";
import { EnvironmentUrls } from "../models/domain/environmentUrls";
-import { GeneratedPasswordHistory } from "../models/domain/generatedPasswordHistory";
-import { Policy } from "../models/domain/policy";
import { StorageOptions } from "../models/domain/storageOptions";
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
import { WindowState } from "../models/domain/windowState";
-import { CipherView } from "../models/view/cipherView";
-import { CollectionView } from "../models/view/collectionView";
-import { FolderView } from "../models/view/folderView";
-import { SendView } from "../models/view/sendView";
export abstract class StateService {
accounts$: Observable<{ [userId: string]: T }>;
@@ -45,8 +33,6 @@ export abstract class StateService {
setApiKeyClientSecret: (value: string, options?: StorageOptions) => Promise;
getAutoConfirmFingerPrints: (options?: StorageOptions) => Promise;
setAutoConfirmFingerprints: (value: boolean, options?: StorageOptions) => Promise;
- getAutoFillOnPageLoadDefault: (options?: StorageOptions) => Promise;
- setAutoFillOnPageLoadDefault: (value: boolean, options?: StorageOptions) => Promise;
getBiometricAwaitingAcceptance: (options?: StorageOptions) => Promise;
setBiometricAwaitingAcceptance: (value: boolean, options?: StorageOptions) => Promise;
getBiometricFingerprintValidated: (options?: StorageOptions) => Promise;
@@ -75,17 +61,11 @@ export abstract class StateService {
setCryptoMasterKeyBiometric: (value: string, options?: StorageOptions) => Promise;
getDecodedToken: (options?: StorageOptions) => Promise;
setDecodedToken: (value: any, options?: StorageOptions) => Promise;
- getDecryptedCiphers: (options?: StorageOptions) => Promise;
- setDecryptedCiphers: (value: CipherView[], options?: StorageOptions) => Promise;
- getDecryptedCollections: (options?: StorageOptions) => Promise;
- setDecryptedCollections: (value: CollectionView[], options?: StorageOptions) => Promise;
getDecryptedCryptoSymmetricKey: (options?: StorageOptions) => Promise;
setDecryptedCryptoSymmetricKey: (
value: SymmetricCryptoKey,
options?: StorageOptions,
) => Promise;
- getDecryptedFolders: (options?: StorageOptions) => Promise;
- setDecryptedFolders: (value: FolderView[], options?: StorageOptions) => Promise;
getDecryptedOrganizationKeys: (
options?: StorageOptions,
) => Promise