├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .git-blame-ignore-revs ├── .gitattributes ├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build.yml │ ├── chromatic.yml │ └── enforce-labels.yml ├── .gitignore ├── .husky ├── .gitignore └── pre-commit ├── .prettierignore ├── .prettierrc.json ├── .vscode ├── launch.json └── tasks.json ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── angular ├── jest.config.js ├── package-lock.json ├── package.json ├── spec │ └── test.ts ├── src │ ├── components │ │ ├── add-edit-custom-fields.component.ts │ │ ├── add-edit.component.ts │ │ ├── attachments.component.ts │ │ ├── avatar.component.ts │ │ ├── callout.component.html │ │ ├── callout.component.ts │ │ ├── captchaProtected.component.ts │ │ ├── change-password.component.ts │ │ ├── ciphers.component.ts │ │ ├── collections.component.ts │ │ ├── environment.component.ts │ │ ├── export-scope-callout.component.html │ │ ├── export-scope-callout.component.ts │ │ ├── export.component.ts │ │ ├── folder-add-edit.component.ts │ │ ├── generator.component.ts │ │ ├── hint.component.ts │ │ ├── icon.component.html │ │ ├── icon.component.ts │ │ ├── lock.component.ts │ │ ├── login.component.ts │ │ ├── modal │ │ │ ├── dynamic-modal.component.ts │ │ │ ├── modal-injector.ts │ │ │ └── modal.ref.ts │ │ ├── password-generator-history.component.ts │ │ ├── password-history.component.ts │ │ ├── password-reprompt.component.ts │ │ ├── premium.component.ts │ │ ├── register.component.ts │ │ ├── remove-password.component.ts │ │ ├── send │ │ │ ├── add-edit.component.ts │ │ │ ├── efflux-dates.component.ts │ │ │ └── send.component.ts │ │ ├── set-password.component.ts │ │ ├── set-pin.component.ts │ │ ├── settings │ │ │ └── vault-timeout-input.component.ts │ │ ├── share.component.ts │ │ ├── sso.component.ts │ │ ├── toastr.component.ts │ │ ├── two-factor-options.component.ts │ │ ├── two-factor.component.ts │ │ ├── update-password.component.ts │ │ ├── update-temp-password.component.ts │ │ ├── user-verification.component.html │ │ ├── user-verification.component.ts │ │ ├── view-custom-fields.component.ts │ │ └── view.component.ts │ ├── directives │ │ ├── a11y-invalid.directive.ts │ │ ├── a11y-title.directive.ts │ │ ├── api-action.directive.ts │ │ ├── autofocus.directive.ts │ │ ├── blur-click.directive.ts │ │ ├── box-row.directive.ts │ │ ├── cipherListVirtualScroll.directive.ts │ │ ├── fallback-src.directive.ts │ │ ├── input-strip-spaces.directive.ts │ │ ├── input-verbatim.directive.ts │ │ ├── not-premium.directive.ts │ │ ├── premium.directive.ts │ │ ├── select-copy.directive.ts │ │ ├── stop-click.directive.ts │ │ ├── stop-prop.directive.ts │ │ └── true-false-value.directive.ts │ ├── guards │ │ ├── auth.guard.ts │ │ ├── lock.guard.ts │ │ └── unauth.guard.ts │ ├── images │ │ └── cards │ │ │ ├── amex-dark.png │ │ │ ├── amex-light.png │ │ │ ├── diners_club-dark.png │ │ │ ├── diners_club-light.png │ │ │ ├── discover-dark.png │ │ │ ├── discover-light.png │ │ │ ├── jcb-dark.png │ │ │ ├── jcb-light.png │ │ │ ├── maestro-dark.png │ │ │ ├── maestro-light.png │ │ │ ├── mastercard-dark.png │ │ │ ├── mastercard-light.png │ │ │ ├── ru_pay-dark.png │ │ │ ├── ru_pay-light.png │ │ │ ├── union_pay-dark.png │ │ │ ├── union_pay-light.png │ │ │ ├── visa-dark.png │ │ │ └── visa-light.png │ ├── interfaces │ │ └── selectOptions.ts │ ├── jslib.module.ts │ ├── modules │ │ └── vault-filter │ │ │ ├── components │ │ │ ├── collection-filter.component.ts │ │ │ ├── folder-filter.component.ts │ │ │ ├── organization-filter.component.ts │ │ │ ├── status-filter.component.ts │ │ │ └── type-filter.component.ts │ │ │ ├── models │ │ │ ├── cipher-status.model.ts │ │ │ ├── display-mode.ts │ │ │ ├── dynamic-tree-node.model.ts │ │ │ ├── top-level-tree-node.model.ts │ │ │ └── vault-filter.model.ts │ │ │ ├── vault-filter.component.ts │ │ │ └── vault-filter.service.ts │ ├── pipes │ │ ├── color-password-count.pipe.ts │ │ ├── color-password.pipe.ts │ │ ├── credit-card-number.pipe.ts │ │ ├── ellipsis.pipe.ts │ │ ├── i18n.pipe.ts │ │ ├── search-ciphers.pipe.ts │ │ ├── search.pipe.ts │ │ └── user-name.pipe.ts │ ├── scss │ │ ├── bwicons │ │ │ ├── fonts │ │ │ │ ├── bwi-font.svg │ │ │ │ ├── bwi-font.ttf │ │ │ │ ├── bwi-font.woff │ │ │ │ └── bwi-font.woff2 │ │ │ └── styles │ │ │ │ └── style.scss │ │ ├── icons.scss │ │ ├── webfonts.css │ │ └── webfonts │ │ │ ├── Open_Sans-italic-300.woff │ │ │ ├── Open_Sans-italic-400.woff │ │ │ ├── Open_Sans-italic-600.woff │ │ │ ├── Open_Sans-italic-700.woff │ │ │ ├── Open_Sans-italic-800.woff │ │ │ ├── Open_Sans-normal-300.woff │ │ │ ├── Open_Sans-normal-400.woff │ │ │ ├── Open_Sans-normal-600.woff │ │ │ ├── Open_Sans-normal-700.woff │ │ │ └── Open_Sans-normal-800.woff │ ├── services │ │ ├── broadcaster.service.ts │ │ ├── jslib-services.module.ts │ │ ├── modal.service.ts │ │ ├── passwordReprompt.service.ts │ │ └── validation.service.ts │ └── validators │ │ ├── dirty.validator.ts │ │ └── notAllowedValueAsync.validator.ts ├── tsconfig.json └── tsconfig.spec.json ├── common ├── jest.config.js ├── package-lock.json ├── package.json ├── spec │ ├── domain │ │ ├── attachment.spec.ts │ │ ├── card.spec.ts │ │ ├── cipher.spec.ts │ │ ├── collection.spec.ts │ │ ├── encString.spec.ts │ │ ├── field.spec.ts │ │ ├── folder.spec.ts │ │ ├── identity.spec.ts │ │ ├── login.spec.ts │ │ ├── loginUri.spec.ts │ │ ├── password.spec.ts │ │ ├── secureNote.spec.ts │ │ ├── send.spec.ts │ │ ├── sendAccess.spec.ts │ │ ├── sendFile.spec.ts │ │ ├── sendText.spec.ts │ │ └── symmetricCryptoKey.spec.ts │ ├── importers │ │ ├── bitwardenJsonImporter.spec.ts │ │ ├── bitwardenPasswordProtectedImporter.spec.ts │ │ ├── dashlaneCsvImporter.spec.ts │ │ ├── firefoxCsvImporter.spec.ts │ │ ├── fsecureFskImporter.spec.ts │ │ ├── keepass2XmlImporter.spec.ts │ │ ├── keeperJsonImporter.spec.ts │ │ ├── lastpassCsvImporter.spec.ts │ │ ├── mykiCsvImporter.spec.ts │ │ ├── nordpassCsvImporter.spec.ts │ │ ├── onepassword1PifImporter.spec.ts │ │ ├── onepassword1PuxImporter.spec.ts │ │ ├── onepasswordMacCsvImporter.spec.ts │ │ ├── onepasswordWinCsvImporter.spec.ts │ │ ├── safariCsvImporter.spec.ts │ │ └── testData │ │ │ ├── bitwardenJson │ │ │ ├── empty.json.ts │ │ │ └── passwordProtected.json.ts │ │ │ ├── dashlaneCsv │ │ │ ├── credentials.csv.ts │ │ │ ├── id.csv.ts │ │ │ ├── multiplePersonalInfo.csv.ts │ │ │ ├── payments.csv.ts │ │ │ ├── personalInfo.csv.ts │ │ │ └── securenotes.csv.ts │ │ │ ├── firefoxCsv │ │ │ ├── firefoxAccountsData.csv.ts │ │ │ └── simplePasswordData.csv.ts │ │ │ ├── keeperJson │ │ │ └── testData.ts │ │ │ ├── mykiCsv │ │ │ ├── UserAccount.csv.ts │ │ │ ├── UserCreditCard.csv.ts │ │ │ ├── UserIdCard.csv.ts │ │ │ ├── UserIdentity.csv.ts │ │ │ ├── UserNote.csv.ts │ │ │ └── UserTwofa.csv.ts │ │ │ ├── nordpassCsv │ │ │ ├── nordpass.card.csv.ts │ │ │ ├── nordpass.identity.csv.ts │ │ │ ├── nordpass.login.csv.ts │ │ │ └── nordpass.secureNote.csv.ts │ │ │ ├── onePassword1Pux │ │ │ ├── APICredentials.ts │ │ │ ├── BankAccount.ts │ │ │ ├── CreditCard.ts │ │ │ ├── Database.ts │ │ │ ├── DriversLicense.ts │ │ │ ├── EmailAccount.ts │ │ │ ├── Emailfield.ts │ │ │ ├── EmailfieldOnIdentity.ts │ │ │ ├── EmailfieldOnIdentity_Prefilled.ts │ │ │ ├── IdentityData.ts │ │ │ ├── LoginData.ts │ │ │ ├── MedicalRecord.ts │ │ │ ├── Membership.ts │ │ │ ├── Onepux_example.ts │ │ │ ├── OutdoorLicense.ts │ │ │ ├── Passport.ts │ │ │ ├── Password.ts │ │ │ ├── RewardsProgram.ts │ │ │ ├── SSN.ts │ │ │ ├── SanitizedExport.ts │ │ │ ├── SecureNote.ts │ │ │ ├── Server.ts │ │ │ ├── SoftwareLicense.ts │ │ │ └── WirelessRouter.ts │ │ │ ├── onePasswordCsv │ │ │ ├── creditCard.mac.csv.ts │ │ │ ├── creditCard.windows.csv.ts │ │ │ ├── identity.mac.csv.ts │ │ │ ├── identity.windows.csv.ts │ │ │ ├── multipleItems.mac.csv.ts │ │ │ └── multipleItems.windows.csv.ts │ │ │ ├── safariCsv │ │ │ ├── oldSimplePasswordData.csv.ts │ │ │ └── simplePasswordData.csv.ts │ │ │ └── safeInCloud │ │ │ └── testData.xml.ts │ ├── misc │ │ ├── logInStrategies │ │ │ ├── apiLogIn.strategy.spec.ts │ │ │ ├── logIn.strategy.spec.ts │ │ │ ├── passwordLogIn.strategy.spec.ts │ │ │ └── ssoLogIn.strategy.spec.ts │ │ ├── sequentialize.spec.ts │ │ ├── throttle.spec.ts │ │ └── utils.spec.ts │ ├── services │ │ ├── cipher.service.spec.ts │ │ ├── consoleLog.service.spec.ts │ │ ├── export.service.spec.ts │ │ ├── import.service.spec.ts │ │ └── stateMigration.service.ts │ ├── test.ts │ ├── utils.ts │ └── web │ │ └── services │ │ └── webCryptoFunction.service.spec.ts ├── src │ ├── abstractions │ │ ├── api.service.ts │ │ ├── appId.service.ts │ │ ├── audit.service.ts │ │ ├── auth.service.ts │ │ ├── broadcaster.service.ts │ │ ├── cipher.service.ts │ │ ├── collection.service.ts │ │ ├── crypto.service.ts │ │ ├── cryptoFunction.service.ts │ │ ├── environment.service.ts │ │ ├── event.service.ts │ │ ├── export.service.ts │ │ ├── fileUpload.service.ts │ │ ├── folder.service.ts │ │ ├── i18n.service.ts │ │ ├── import.service.ts │ │ ├── keyConnector.service.ts │ │ ├── log.service.ts │ │ ├── messaging.service.ts │ │ ├── notifications.service.ts │ │ ├── organization.service.ts │ │ ├── passwordGeneration.service.ts │ │ ├── passwordReprompt.service.ts │ │ ├── platformUtils.service.ts │ │ ├── policy.service.ts │ │ ├── provider.service.ts │ │ ├── search.service.ts │ │ ├── send.service.ts │ │ ├── settings.service.ts │ │ ├── state.service.ts │ │ ├── stateMigration.service.ts │ │ ├── storage.service.ts │ │ ├── sync.service.ts │ │ ├── system.service.ts │ │ ├── token.service.ts │ │ ├── totp.service.ts │ │ ├── twoFactor.service.ts │ │ ├── userVerification.service.ts │ │ ├── usernameGeneration.service.ts │ │ └── vaultTimeout.service.ts │ ├── enums │ │ ├── authenticationStatus.ts │ │ ├── authenticationType.ts │ │ ├── cipherRepromptType.ts │ │ ├── cipherType.ts │ │ ├── clientType.ts │ │ ├── deviceType.ts │ │ ├── emergencyAccessStatusType.ts │ │ ├── emergencyAccessType.ts │ │ ├── encryptionType.ts │ │ ├── eventType.ts │ │ ├── fieldType.ts │ │ ├── fileUploadType.ts │ │ ├── hashPurpose.ts │ │ ├── htmlStorageLocation.ts │ │ ├── importOptions.ts │ │ ├── kdfType.ts │ │ ├── keySuffixOptions.ts │ │ ├── linkedIdType.ts │ │ ├── logLevelType.ts │ │ ├── notificationType.ts │ │ ├── organizationApiKeyType.ts │ │ ├── organizationConnectionType.ts │ │ ├── organizationUserStatusType.ts │ │ ├── organizationUserType.ts │ │ ├── paymentMethodType.ts │ │ ├── permissions.ts │ │ ├── planSponsorshipType.ts │ │ ├── planType.ts │ │ ├── policyType.ts │ │ ├── productType.ts │ │ ├── providerUserStatusType.ts │ │ ├── providerUserType.ts │ │ ├── secureNoteType.ts │ │ ├── sendType.ts │ │ ├── ssoEnums.ts │ │ ├── stateVersion.ts │ │ ├── storageLocation.ts │ │ ├── themeType.ts │ │ ├── transactionType.ts │ │ ├── twoFactorProviderType.ts │ │ ├── uriMatchType.ts │ │ └── verificationType.ts │ ├── factories │ │ ├── accountFactory.ts │ │ ├── globalStateFactory.ts │ │ └── stateFactory.ts │ ├── globals.d.ts │ ├── importers │ │ ├── ascendoCsvImporter.ts │ │ ├── avastCsvImporter.ts │ │ ├── avastJsonImporter.ts │ │ ├── aviraCsvImporter.ts │ │ ├── baseImporter.ts │ │ ├── bitwardenCsvImporter.ts │ │ ├── bitwardenJsonImporter.ts │ │ ├── bitwardenPasswordProtectedImporter.ts │ │ ├── blackBerryCsvImporter.ts │ │ ├── blurCsvImporter.ts │ │ ├── buttercupCsvImporter.ts │ │ ├── chromeCsvImporter.ts │ │ ├── clipperzHtmlImporter.ts │ │ ├── codebookCsvImporter.ts │ │ ├── dashlaneImporters │ │ │ ├── dashlaneCsvImporter.ts │ │ │ ├── dashlaneJsonImporter.ts │ │ │ └── types │ │ │ │ └── dashlaneCsvTypes.ts │ │ ├── encryptrCsvImporter.ts │ │ ├── enpassCsvImporter.ts │ │ ├── enpassJsonImporter.ts │ │ ├── firefoxCsvImporter.ts │ │ ├── fsecureFskImporter.ts │ │ ├── gnomeJsonImporter.ts │ │ ├── importError.ts │ │ ├── importer.ts │ │ ├── kasperskyTxtImporter.ts │ │ ├── keepass2XmlImporter.ts │ │ ├── keepassxCsvImporter.ts │ │ ├── keeperImporters │ │ │ ├── keeperCsvImporter.ts │ │ │ ├── keeperJsonImporter.ts │ │ │ └── types │ │ │ │ └── keeperJsonTypes.ts │ │ ├── lastpassCsvImporter.ts │ │ ├── logMeOnceCsvImporter.ts │ │ ├── meldiumCsvImporter.ts │ │ ├── msecureCsvImporter.ts │ │ ├── mykiCsvImporter.ts │ │ ├── nordpassCsvImporter.ts │ │ ├── onepasswordImporters │ │ │ ├── cipherImportContext.ts │ │ │ ├── onepassword1PifImporter.ts │ │ │ ├── onepassword1PuxImporter.ts │ │ │ ├── onepasswordCsvImporter.ts │ │ │ ├── onepasswordMacCsvImporter.ts │ │ │ ├── onepasswordWinCsvImporter.ts │ │ │ └── types │ │ │ │ └── onepassword1PuxImporterTypes.ts │ │ ├── padlockCsvImporter.ts │ │ ├── passkeepCsvImporter.ts │ │ ├── passmanJsonImporter.ts │ │ ├── passpackCsvImporter.ts │ │ ├── passwordAgentCsvImporter.ts │ │ ├── passwordBossJsonImporter.ts │ │ ├── passwordDragonXmlImporter.ts │ │ ├── passwordSafeXmlImporter.ts │ │ ├── passwordWalletTxtImporter.ts │ │ ├── rememBearCsvImporter.ts │ │ ├── roboformCsvImporter.ts │ │ ├── safariCsvImporter.ts │ │ ├── safeInCloudXmlImporter.ts │ │ ├── saferpassCsvImport.ts │ │ ├── secureSafeCsvImporter.ts │ │ ├── splashIdCsvImporter.ts │ │ ├── stickyPasswordXmlImporter.ts │ │ ├── truekeyCsvImporter.ts │ │ ├── upmCsvImporter.ts │ │ ├── yotiCsvImporter.ts │ │ └── zohoVaultCsvImporter.ts │ ├── misc │ │ ├── captcha_iframe.ts │ │ ├── iframe_component.ts │ │ ├── linkedFieldOption.decorator.ts │ │ ├── logInStrategies │ │ │ ├── apiLogin.strategy.ts │ │ │ ├── logIn.strategy.ts │ │ │ ├── passwordLogin.strategy.ts │ │ │ └── ssoLogin.strategy.ts │ │ ├── nodeUtils.ts │ │ ├── sequentialize.ts │ │ ├── serviceUtils.ts │ │ ├── throttle.ts │ │ ├── tldjs.noop.ts │ │ ├── utils.ts │ │ ├── webauthn_iframe.ts │ │ └── wordlist.ts │ ├── models │ │ ├── api │ │ │ ├── billingSyncConfigApi.ts │ │ │ ├── cardApi.ts │ │ │ ├── fieldApi.ts │ │ │ ├── identityApi.ts │ │ │ ├── loginApi.ts │ │ │ ├── loginUriApi.ts │ │ │ ├── permissionsApi.ts │ │ │ ├── secureNoteApi.ts │ │ │ ├── sendFileApi.ts │ │ │ ├── sendTextApi.ts │ │ │ └── ssoConfigApi.ts │ │ ├── data │ │ │ ├── attachmentData.ts │ │ │ ├── cardData.ts │ │ │ ├── cipherData.ts │ │ │ ├── collectionData.ts │ │ │ ├── eventData.ts │ │ │ ├── fieldData.ts │ │ │ ├── folderData.ts │ │ │ ├── identityData.ts │ │ │ ├── loginData.ts │ │ │ ├── loginUriData.ts │ │ │ ├── organizationData.ts │ │ │ ├── passwordHistoryData.ts │ │ │ ├── policyData.ts │ │ │ ├── providerData.ts │ │ │ ├── secureNoteData.ts │ │ │ ├── sendData.ts │ │ │ ├── sendFileData.ts │ │ │ └── sendTextData.ts │ │ ├── domain │ │ │ ├── account.ts │ │ │ ├── attachment.ts │ │ │ ├── authResult.ts │ │ │ ├── card.ts │ │ │ ├── cipher.ts │ │ │ ├── collection.ts │ │ │ ├── decryptParameters.ts │ │ │ ├── domainBase.ts │ │ │ ├── encArrayBuffer.ts │ │ │ ├── encString.ts │ │ │ ├── encryptedObject.ts │ │ │ ├── environmentUrls.ts │ │ │ ├── field.ts │ │ │ ├── folder.ts │ │ │ ├── generatedPasswordHistory.ts │ │ │ ├── globalState.ts │ │ │ ├── identity.ts │ │ │ ├── importResult.ts │ │ │ ├── logInCredentials.ts │ │ │ ├── login.ts │ │ │ ├── loginUri.ts │ │ │ ├── masterPasswordPolicyOptions.ts │ │ │ ├── organization.ts │ │ │ ├── password.ts │ │ │ ├── passwordGeneratorPolicyOptions.ts │ │ │ ├── policy.ts │ │ │ ├── provider.ts │ │ │ ├── resetPasswordPolicyOptions.ts │ │ │ ├── secureNote.ts │ │ │ ├── send.ts │ │ │ ├── sendAccess.ts │ │ │ ├── sendFile.ts │ │ │ ├── sendText.ts │ │ │ ├── sortedCiphersCache.ts │ │ │ ├── state.ts │ │ │ ├── storageOptions.ts │ │ │ ├── symmetricCryptoKey.ts │ │ │ ├── treeNode.ts │ │ │ └── windowState.ts │ │ ├── export │ │ │ ├── cardExport.ts │ │ │ ├── cipherExport.ts │ │ │ ├── cipherWithIdsExport.ts │ │ │ ├── collectionExport.ts │ │ │ ├── collectionWithIdExport.ts │ │ │ ├── eventExport.ts │ │ │ ├── fieldExport.ts │ │ │ ├── folderExport.ts │ │ │ ├── folderWithIdExport.ts │ │ │ ├── identityExport.ts │ │ │ ├── loginExport.ts │ │ │ ├── loginUriExport.ts │ │ │ └── secureNoteExport.ts │ │ ├── request │ │ │ ├── account │ │ │ │ ├── setKeyConnectorKeyRequest.ts │ │ │ │ └── verifyOTPRequest.ts │ │ │ ├── attachmentRequest.ts │ │ │ ├── billingSyncConfigRequest.ts │ │ │ ├── bitPayInvoiceRequest.ts │ │ │ ├── captchaProtectedRequest.ts │ │ │ ├── cipherBulkDeleteRequest.ts │ │ │ ├── cipherBulkMoveRequest.ts │ │ │ ├── cipherBulkRestoreRequest.ts │ │ │ ├── cipherBulkShareRequest.ts │ │ │ ├── cipherCollectionsRequest.ts │ │ │ ├── cipherCreateRequest.ts │ │ │ ├── cipherRequest.ts │ │ │ ├── cipherShareRequest.ts │ │ │ ├── cipherWithIdRequest.ts │ │ │ ├── collectionRequest.ts │ │ │ ├── deleteRecoverRequest.ts │ │ │ ├── deviceRequest.ts │ │ │ ├── deviceTokenRequest.ts │ │ │ ├── emailRequest.ts │ │ │ ├── emailTokenRequest.ts │ │ │ ├── emergencyAccessAcceptRequest.ts │ │ │ ├── emergencyAccessConfirmRequest.ts │ │ │ ├── emergencyAccessInviteRequest.ts │ │ │ ├── emergencyAccessPasswordRequest.ts │ │ │ ├── emergencyAccessUpdateRequest.ts │ │ │ ├── eventRequest.ts │ │ │ ├── folderRequest.ts │ │ │ ├── folderWithIdRequest.ts │ │ │ ├── groupRequest.ts │ │ │ ├── iapCheckRequest.ts │ │ │ ├── identityToken │ │ │ │ ├── apiTokenRequest.ts │ │ │ │ ├── passwordTokenRequest.ts │ │ │ │ ├── ssoTokenRequest.ts │ │ │ │ ├── tokenRequest.ts │ │ │ │ └── tokenRequestTwoFactor.ts │ │ │ ├── importCiphersRequest.ts │ │ │ ├── importDirectoryRequest.ts │ │ │ ├── importDirectoryRequestGroup.ts │ │ │ ├── importDirectoryRequestUser.ts │ │ │ ├── importOrganizationCiphersRequest.ts │ │ │ ├── kdfRequest.ts │ │ │ ├── keyConnectorUserKeyRequest.ts │ │ │ ├── keysRequest.ts │ │ │ ├── kvpRequest.ts │ │ │ ├── organization │ │ │ │ ├── organizationSponsorshipCreateRequest.ts │ │ │ │ ├── organizationSponsorshipRedeemRequest.ts │ │ │ │ └── organizationSsoRequest.ts │ │ │ ├── organizationApiKeyRequest.ts │ │ │ ├── organizationConnectionRequest.ts │ │ │ ├── organizationCreateRequest.ts │ │ │ ├── organizationImportGroupRequest.ts │ │ │ ├── organizationImportMemberRequest.ts │ │ │ ├── organizationImportRequest.ts │ │ │ ├── organizationKeysRequest.ts │ │ │ ├── organizationSubscriptionUpdateRequest.ts │ │ │ ├── organizationTaxInfoUpdateRequest.ts │ │ │ ├── organizationUpdateRequest.ts │ │ │ ├── organizationUpgradeRequest.ts │ │ │ ├── organizationUserAcceptRequest.ts │ │ │ ├── organizationUserBulkConfirmRequest.ts │ │ │ ├── organizationUserBulkRequest.ts │ │ │ ├── organizationUserConfirmRequest.ts │ │ │ ├── organizationUserInviteRequest.ts │ │ │ ├── organizationUserResetPasswordEnrollmentRequest.ts │ │ │ ├── organizationUserResetPasswordRequest.ts │ │ │ ├── organizationUserUpdateGroupsRequest.ts │ │ │ ├── organizationUserUpdateRequest.ts │ │ │ ├── passwordHintRequest.ts │ │ │ ├── passwordHistoryRequest.ts │ │ │ ├── passwordRequest.ts │ │ │ ├── paymentRequest.ts │ │ │ ├── policyRequest.ts │ │ │ ├── preloginRequest.ts │ │ │ ├── provider │ │ │ │ ├── providerAddOrganizationRequest.ts │ │ │ │ ├── providerOrganizationCreateRequest.ts │ │ │ │ ├── providerSetupRequest.ts │ │ │ │ ├── providerUpdateRequest.ts │ │ │ │ ├── providerUserAcceptRequest.ts │ │ │ │ ├── providerUserBulkConfirmRequest.ts │ │ │ │ ├── providerUserBulkRequest.ts │ │ │ │ ├── providerUserConfirmRequest.ts │ │ │ │ ├── providerUserInviteRequest.ts │ │ │ │ └── providerUserUpdateRequest.ts │ │ │ ├── referenceEventRequest.ts │ │ │ ├── registerRequest.ts │ │ │ ├── seatRequest.ts │ │ │ ├── secretVerificationRequest.ts │ │ │ ├── selectionReadOnlyRequest.ts │ │ │ ├── sendAccessRequest.ts │ │ │ ├── sendRequest.ts │ │ │ ├── sendWithIdRequest.ts │ │ │ ├── setPasswordRequest.ts │ │ │ ├── storageRequest.ts │ │ │ ├── taxInfoUpdateRequest.ts │ │ │ ├── twoFactorEmailRequest.ts │ │ │ ├── twoFactorProviderRequest.ts │ │ │ ├── twoFactorRecoveryRequest.ts │ │ │ ├── updateDomainsRequest.ts │ │ │ ├── updateKeyRequest.ts │ │ │ ├── updateProfileRequest.ts │ │ │ ├── updateTempPasswordRequest.ts │ │ │ ├── updateTwoFactorAuthenticatorRequest.ts │ │ │ ├── updateTwoFactorDuoRequest.ts │ │ │ ├── updateTwoFactorEmailRequest.ts │ │ │ ├── updateTwoFactorWebAuthnDeleteRequest.ts │ │ │ ├── updateTwoFactorWebAuthnRequest.ts │ │ │ ├── updateTwoFactorYubioOtpRequest.ts │ │ │ ├── verifyBankRequest.ts │ │ │ ├── verifyDeleteRecoverRequest.ts │ │ │ └── verifyEmailRequest.ts │ │ ├── response │ │ │ ├── apiKeyResponse.ts │ │ │ ├── attachmentResponse.ts │ │ │ ├── attachmentUploadDataResponse.ts │ │ │ ├── baseResponse.ts │ │ │ ├── billingHistoryResponse.ts │ │ │ ├── billingPaymentResponse.ts │ │ │ ├── billingResponse.ts │ │ │ ├── breachAccountResponse.ts │ │ │ ├── cipherResponse.ts │ │ │ ├── collectionResponse.ts │ │ │ ├── deviceResponse.ts │ │ │ ├── domainsResponse.ts │ │ │ ├── emergencyAccessResponse.ts │ │ │ ├── errorResponse.ts │ │ │ ├── eventResponse.ts │ │ │ ├── folderResponse.ts │ │ │ ├── globalDomainResponse.ts │ │ │ ├── groupResponse.ts │ │ │ ├── identityCaptchaResponse.ts │ │ │ ├── identityTokenResponse.ts │ │ │ ├── identityTwoFactorResponse.ts │ │ │ ├── keyConnectorUserKeyResponse.ts │ │ │ ├── keysResponse.ts │ │ │ ├── listResponse.ts │ │ │ ├── notificationResponse.ts │ │ │ ├── organization │ │ │ │ └── organizationSsoResponse.ts │ │ │ ├── organizationApiKeyInformationResponse.ts │ │ │ ├── organizationAutoEnrollStatusResponse.ts │ │ │ ├── organizationConnectionResponse.ts │ │ │ ├── organizationKeysResponse.ts │ │ │ ├── organizationResponse.ts │ │ │ ├── organizationSponsorshipSyncStatusResponse.ts │ │ │ ├── organizationSubscriptionResponse.ts │ │ │ ├── organizationUserBulkPublicKeyResponse.ts │ │ │ ├── organizationUserBulkResponse.ts │ │ │ ├── organizationUserResponse.ts │ │ │ ├── passwordHistoryResponse.ts │ │ │ ├── paymentResponse.ts │ │ │ ├── planResponse.ts │ │ │ ├── policyResponse.ts │ │ │ ├── preloginResponse.ts │ │ │ ├── profileOrganizationResponse.ts │ │ │ ├── profileProviderOrganizationResponse.ts │ │ │ ├── profileProviderResponse.ts │ │ │ ├── profileResponse.ts │ │ │ ├── provider │ │ │ │ ├── providerOrganizationResponse.ts │ │ │ │ ├── providerResponse.ts │ │ │ │ ├── providerUserBulkPublicKeyResponse.ts │ │ │ │ ├── providerUserBulkResponse.ts │ │ │ │ └── providerUserResponse.ts │ │ │ ├── selectionReadOnlyResponse.ts │ │ │ ├── sendAccessResponse.ts │ │ │ ├── sendFileDownloadDataResponse.ts │ │ │ ├── sendFileUploadDataResponse.ts │ │ │ ├── sendResponse.ts │ │ │ ├── ssoPreValidateResponse.ts │ │ │ ├── subscriptionResponse.ts │ │ │ ├── syncResponse.ts │ │ │ ├── taxInfoResponse.ts │ │ │ ├── taxRateResponse.ts │ │ │ ├── twoFactorAuthenticatorResponse.ts │ │ │ ├── twoFactorDuoResponse.ts │ │ │ ├── twoFactorEmailResponse.ts │ │ │ ├── twoFactorProviderResponse.ts │ │ │ ├── twoFactorRescoverResponse.ts │ │ │ ├── twoFactorWebAuthnResponse.ts │ │ │ ├── twoFactorYubiKeyResponse.ts │ │ │ └── userKeyResponse.ts │ │ └── view │ │ │ ├── attachmentView.ts │ │ │ ├── cardView.ts │ │ │ ├── cipherView.ts │ │ │ ├── collectionView.ts │ │ │ ├── eventView.ts │ │ │ ├── fieldView.ts │ │ │ ├── folderView.ts │ │ │ ├── identityView.ts │ │ │ ├── itemView.ts │ │ │ ├── loginUriView.ts │ │ │ ├── loginView.ts │ │ │ ├── passwordHistoryView.ts │ │ │ ├── secureNoteView.ts │ │ │ ├── sendAccessView.ts │ │ │ ├── sendFileView.ts │ │ │ ├── sendTextView.ts │ │ │ ├── sendView.ts │ │ │ ├── ssoConfigView.ts │ │ │ └── view.ts │ ├── services │ │ ├── api.service.ts │ │ ├── appId.service.ts │ │ ├── audit.service.ts │ │ ├── auth.service.ts │ │ ├── azureFileUpload.service.ts │ │ ├── bitwardenFileUpload.service.ts │ │ ├── broadcaster.service.ts │ │ ├── cipher.service.ts │ │ ├── collection.service.ts │ │ ├── consoleLog.service.ts │ │ ├── container.service.ts │ │ ├── crypto.service.ts │ │ ├── environment.service.ts │ │ ├── event.service.ts │ │ ├── export.service.ts │ │ ├── fileUpload.service.ts │ │ ├── folder.service.ts │ │ ├── i18n.service.ts │ │ ├── import.service.ts │ │ ├── keyConnector.service.ts │ │ ├── noopMessaging.service.ts │ │ ├── notifications.service.ts │ │ ├── organization.service.ts │ │ ├── passwordGeneration.service.ts │ │ ├── policy.service.ts │ │ ├── provider.service.ts │ │ ├── search.service.ts │ │ ├── send.service.ts │ │ ├── settings.service.ts │ │ ├── state.service.ts │ │ ├── stateMigration.service.ts │ │ ├── sync.service.ts │ │ ├── system.service.ts │ │ ├── token.service.ts │ │ ├── totp.service.ts │ │ ├── twoFactor.service.ts │ │ ├── userVerification.service.ts │ │ ├── usernameGeneration.service.ts │ │ ├── vaultTimeout.service.ts │ │ └── webCryptoFunction.service.ts │ └── types │ │ └── verification.ts ├── tsconfig.json └── tsconfig.spec.json ├── components ├── .browserslistrc ├── .gitignore ├── .storybook │ ├── main.js │ ├── preview.js │ ├── tsconfig.json │ └── typings.d.ts ├── README.md ├── angular.json ├── jest.config.js ├── package-lock.json ├── package.json ├── spec │ └── test.ts ├── src │ ├── app │ │ ├── app.component.ts │ │ └── app.module.ts │ ├── badge │ │ ├── badge.directive.ts │ │ ├── badge.module.ts │ │ ├── badge.stories.ts │ │ └── index.ts │ ├── banner │ │ ├── banner.component.html │ │ ├── banner.component.spec.ts │ │ ├── banner.component.ts │ │ ├── banner.module.ts │ │ ├── banner.stories.ts │ │ └── index.ts │ ├── button │ │ ├── button.directive.spec.ts │ │ ├── button.directive.ts │ │ ├── button.module.ts │ │ ├── button.stories.ts │ │ └── index.ts │ ├── callout │ │ ├── callout.component.html │ │ ├── callout.component.spec.ts │ │ ├── callout.component.ts │ │ ├── callout.module.ts │ │ ├── callout.stories.ts │ │ └── index.ts │ ├── favicon.ico │ ├── form-field │ │ ├── error-summary.component.ts │ │ ├── error-summary.stories.ts │ │ ├── error.component.ts │ │ ├── form-field.component.html │ │ ├── form-field.component.ts │ │ ├── form-field.module.ts │ │ ├── form-field.stories.ts │ │ ├── hint.component.ts │ │ ├── index.ts │ │ ├── label.directive.ts │ │ ├── prefix.directive.ts │ │ └── suffix.directive.ts │ ├── index.html │ ├── index.ts │ ├── input │ │ ├── input.directive.ts │ │ └── input.module.ts │ ├── main.ts │ ├── menu │ │ ├── index.ts │ │ ├── menu-divider.component.html │ │ ├── menu-divider.component.ts │ │ ├── menu-item.directive.ts │ │ ├── menu-trigger-for.directive.ts │ │ ├── menu.component.html │ │ ├── menu.component.spec.ts │ │ ├── menu.component.ts │ │ ├── menu.module.ts │ │ └── menu.stories.ts │ ├── polyfills.ts │ ├── stories │ │ ├── Introduction.stories.mdx │ │ └── colors.stories.mdx │ ├── styles.css │ ├── styles.scss │ ├── test.ts │ ├── tw-theme.css │ ├── utils │ │ └── i18n-mock.service.ts │ └── variables.scss ├── tailwind.config.base.js ├── tailwind.config.js ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json ├── electron ├── jest.config.js ├── package-lock.json ├── package.json ├── spec │ ├── services │ │ └── electronLog.service.spec.ts │ ├── test.ts │ └── utils.spec.ts ├── src │ ├── baseMenu.ts │ ├── globals.d.ts │ ├── services │ │ ├── electronCrypto.service.ts │ │ ├── electronLog.service.ts │ │ ├── electronMainMessaging.service.ts │ │ ├── electronPlatformUtils.service.ts │ │ ├── electronRendererMessaging.service.ts │ │ ├── electronRendererSecureStorage.service.ts │ │ ├── electronRendererStorage.service.ts │ │ └── electronStorage.service.ts │ ├── tray.main.ts │ ├── updater.main.ts │ ├── utils.ts │ └── window.main.ts ├── tsconfig.json └── tsconfig.spec.json ├── jest.config.js ├── node ├── jest.config.js ├── package-lock.json ├── package.json ├── spec │ ├── cli │ │ └── consoleLog.service.spec.ts │ ├── services │ │ └── nodeCryptoFunction.service.spec.ts │ └── test.ts ├── src │ ├── cli │ │ ├── baseProgram.ts │ │ ├── commands │ │ │ ├── login.command.ts │ │ │ ├── logout.command.ts │ │ │ └── update.command.ts │ │ ├── models │ │ │ ├── response.ts │ │ │ └── response │ │ │ │ ├── baseResponse.ts │ │ │ │ ├── fileResponse.ts │ │ │ │ ├── listResponse.ts │ │ │ │ ├── messageResponse.ts │ │ │ │ └── stringResponse.ts │ │ └── services │ │ │ ├── cliPlatformUtils.service.ts │ │ │ └── consoleLog.service.ts │ ├── globals.d.ts │ └── services │ │ ├── lowdbStorage.service.ts │ │ ├── nodeApi.service.ts │ │ └── nodeCryptoFunction.service.ts ├── tsconfig.json └── tsconfig.spec.json ├── package-lock.json ├── package.json ├── shared ├── eslintrc.json └── tsconfig.json ├── tsconfig.json └── tsconfig.spec.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | # Set default charset 13 | [*.{js,ts,scss,html}] 14 | charset = utf-8 15 | indent_style = space 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/dist 2 | **/jest.config.js 3 | 4 | **/node_modules 5 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": ["./shared/eslintrc.json"], 4 | "rules": { 5 | "import/order": [ 6 | "error", 7 | { 8 | "alphabetize": { 9 | "order": "asc" 10 | }, 11 | "newlines-between": "always", 12 | "pathGroups": [ 13 | { 14 | "pattern": "jslib-*/**", 15 | "group": "external", 16 | "position": "after" 17 | } 18 | ], 19 | "pathGroupsExcludedImportTypes": ["builtin"] 20 | } 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | 193434461dbd9c48fe5dcbad95693470aec422ac 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/enforce-labels.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enforce PR labels 3 | 4 | on: 5 | pull_request: 6 | types: [labeled, unlabeled, opened, edited, synchronize] 7 | jobs: 8 | enforce-label: 9 | name: EnforceLabel 10 | runs-on: ubuntu-20.04 11 | steps: 12 | - name: Enforce Label 13 | uses: yogevbd/enforce-label-action@8d1e1709b1011e6d90400a0e6cf7c0b77aa5efeb 14 | with: 15 | BANNED_LABELS: "hold" 16 | BANNED_LABELS_DESCRIPTION: "PRs on hold cannot be merged" 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | .idea 3 | node_modules 4 | npm-debug.log 5 | vwd.webinfo 6 | *.crx 7 | *.pem 8 | dist 9 | coverage 10 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Build directories 2 | dist 3 | .angular 4 | coverage 5 | 6 | # Github Workflows 7 | .github/workflows 8 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Jasmine Individual Test", 11 | "program": "${workspaceRoot}\\node_modules\\jasmine\\bin\\jasmine.js", 12 | "preLaunchTask": "npm run build", 13 | "args": ["${workspaceFolder}/dist\\spec\\node\\services\\nodeCryptoFunction.service.spec.js"] 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "npm run build", 8 | "type": "shell", 9 | "command": "npm run build" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /angular/jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require("ts-jest"); 2 | 3 | const { compilerOptions } = require("./tsconfig"); 4 | 5 | module.exports = { 6 | name: "angular", 7 | displayName: "angular tests", 8 | preset: "jest-preset-angular", 9 | testMatch: ["**/+(*.)+(spec).+(ts)"], 10 | setupFilesAfterEnv: ["/spec/test.ts"], 11 | collectCoverage: true, 12 | coverageReporters: ["html", "lcov"], 13 | coverageDirectory: "coverage", 14 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, { 15 | prefix: "/", 16 | }), 17 | }; 18 | -------------------------------------------------------------------------------- /angular/spec/test.ts: -------------------------------------------------------------------------------- 1 | import { webcrypto } from "crypto"; 2 | import "jest-preset-angular/setup-jest"; 3 | 4 | Object.defineProperty(window, "CSS", { value: null }); 5 | Object.defineProperty(window, "getComputedStyle", { 6 | value: () => { 7 | return { 8 | display: "none", 9 | appearance: ["-webkit-appearance"], 10 | }; 11 | }, 12 | }); 13 | 14 | Object.defineProperty(document, "doctype", { 15 | value: "", 16 | }); 17 | Object.defineProperty(document.body.style, "transform", { 18 | value: () => { 19 | return { 20 | enumerable: true, 21 | configurable: true, 22 | }; 23 | }, 24 | }); 25 | 26 | Object.defineProperty(window, "crypto", { 27 | value: webcrypto, 28 | }); 29 | -------------------------------------------------------------------------------- /angular/src/components/export-scope-callout.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{ scopeConfig.description | i18n: scopeConfig.scopeIdentifier }} 4 | 5 | 6 | -------------------------------------------------------------------------------- /angular/src/components/icon.component.html: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /angular/src/components/modal/modal-injector.ts: -------------------------------------------------------------------------------- 1 | import { InjectFlags, InjectionToken, Injector, Type } from "@angular/core"; 2 | 3 | export class ModalInjector implements Injector { 4 | constructor(private _parentInjector: Injector, private _additionalTokens: WeakMap) {} 5 | 6 | get(token: Type | InjectionToken, notFoundValue?: T, flags?: InjectFlags): T; 7 | get(token: any, notFoundValue?: any, flags?: any) { 8 | return this._additionalTokens.get(token) ?? this._parentInjector.get(token, notFoundValue); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /angular/src/directives/a11y-invalid.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ElementRef, OnDestroy, OnInit } from "@angular/core"; 2 | import { NgControl } from "@angular/forms"; 3 | import { Subscription } from "rxjs"; 4 | 5 | @Directive({ 6 | selector: "[appA11yInvalid]", 7 | }) 8 | export class A11yInvalidDirective implements OnDestroy, OnInit { 9 | private sub: Subscription; 10 | 11 | constructor(private el: ElementRef, private formControlDirective: NgControl) {} 12 | 13 | ngOnInit() { 14 | this.sub = this.formControlDirective.control.statusChanges.subscribe((status) => { 15 | if (status === "INVALID") { 16 | this.el.nativeElement.setAttribute("aria-invalid", "true"); 17 | } else if (status === "VALID") { 18 | this.el.nativeElement.setAttribute("aria-invalid", "false"); 19 | } 20 | }); 21 | } 22 | 23 | ngOnDestroy() { 24 | this.sub?.unsubscribe(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /angular/src/directives/a11y-title.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ElementRef, Input, Renderer2 } from "@angular/core"; 2 | 3 | @Directive({ 4 | selector: "[appA11yTitle]", 5 | }) 6 | export class A11yTitleDirective { 7 | @Input() set appA11yTitle(title: string) { 8 | this.title = title; 9 | } 10 | 11 | private title: string; 12 | 13 | constructor(private el: ElementRef, private renderer: Renderer2) {} 14 | 15 | ngOnInit() { 16 | if (!this.el.nativeElement.hasAttribute("title")) { 17 | this.renderer.setAttribute(this.el.nativeElement, "title", this.title); 18 | } 19 | if (!this.el.nativeElement.hasAttribute("aria-label")) { 20 | this.renderer.setAttribute(this.el.nativeElement, "aria-label", this.title); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /angular/src/directives/autofocus.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ElementRef, Input, NgZone } from "@angular/core"; 2 | import { take } from "rxjs/operators"; 3 | 4 | import { Utils } from "jslib-common/misc/utils"; 5 | 6 | @Directive({ 7 | selector: "[appAutofocus]", 8 | }) 9 | export class AutofocusDirective { 10 | @Input() set appAutofocus(condition: boolean | string) { 11 | this.autofocus = condition === "" || condition === true; 12 | } 13 | 14 | private autofocus: boolean; 15 | 16 | constructor(private el: ElementRef, private ngZone: NgZone) {} 17 | 18 | ngOnInit() { 19 | if (!Utils.isMobileBrowser && this.autofocus) { 20 | if (this.ngZone.isStable) { 21 | this.el.nativeElement.focus(); 22 | } else { 23 | this.ngZone.onStable.pipe(take(1)).subscribe(() => this.el.nativeElement.focus()); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /angular/src/directives/blur-click.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ElementRef, HostListener } from "@angular/core"; 2 | 3 | @Directive({ 4 | selector: "[appBlurClick]", 5 | }) 6 | export class BlurClickDirective { 7 | constructor(private el: ElementRef) {} 8 | 9 | @HostListener("click") onClick() { 10 | this.el.nativeElement.blur(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /angular/src/directives/fallback-src.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ElementRef, HostListener, Input } from "@angular/core"; 2 | 3 | @Directive({ 4 | selector: "[appFallbackSrc]", 5 | }) 6 | export class FallbackSrcDirective { 7 | @Input("appFallbackSrc") appFallbackSrc: string; 8 | 9 | constructor(private el: ElementRef) {} 10 | 11 | @HostListener("error") onError() { 12 | this.el.nativeElement.src = this.appFallbackSrc; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /angular/src/directives/input-strip-spaces.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, ElementRef, HostListener } from "@angular/core"; 2 | 3 | @Directive({ 4 | selector: "input[appInputStripSpaces]", 5 | }) 6 | export class InputStripSpacesDirective { 7 | constructor(private el: ElementRef) {} 8 | 9 | @HostListener("input") onInput() { 10 | this.el.nativeElement.value = this.el.nativeElement.value.replace(/ /g, ""); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /angular/src/directives/not-premium.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, OnInit, TemplateRef, ViewContainerRef } from "@angular/core"; 2 | 3 | import { StateService } from "jslib-common/abstractions/state.service"; 4 | 5 | /** 6 | * Hides the element if the user has premium. 7 | */ 8 | @Directive({ 9 | selector: "[appNotPremium]", 10 | }) 11 | export class NotPremiumDirective implements OnInit { 12 | constructor( 13 | private templateRef: TemplateRef, 14 | private viewContainer: ViewContainerRef, 15 | private stateService: StateService 16 | ) {} 17 | 18 | async ngOnInit(): Promise { 19 | const premium = await this.stateService.getCanAccessPremium(); 20 | 21 | if (premium) { 22 | this.viewContainer.clear(); 23 | } else { 24 | this.viewContainer.createEmbeddedView(this.templateRef); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /angular/src/directives/premium.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, OnInit, TemplateRef, ViewContainerRef } from "@angular/core"; 2 | 3 | import { StateService } from "jslib-common/abstractions/state.service"; 4 | 5 | /** 6 | * Only shows the element if the user has premium. 7 | */ 8 | @Directive({ 9 | selector: "[appPremium]", 10 | }) 11 | export class PremiumDirective implements OnInit { 12 | constructor( 13 | private templateRef: TemplateRef, 14 | private viewContainer: ViewContainerRef, 15 | private stateService: StateService 16 | ) {} 17 | 18 | async ngOnInit(): Promise { 19 | const premium = await this.stateService.getCanAccessPremium(); 20 | 21 | if (premium) { 22 | this.viewContainer.createEmbeddedView(this.templateRef); 23 | } else { 24 | this.viewContainer.clear(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /angular/src/directives/stop-click.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, HostListener } from "@angular/core"; 2 | 3 | @Directive({ 4 | selector: "[appStopClick]", 5 | }) 6 | export class StopClickDirective { 7 | @HostListener("click", ["$event"]) onClick($event: MouseEvent) { 8 | $event.preventDefault(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /angular/src/directives/stop-prop.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, HostListener } from "@angular/core"; 2 | 3 | @Directive({ 4 | selector: "[appStopProp]", 5 | }) 6 | export class StopPropDirective { 7 | @HostListener("click", ["$event"]) onClick($event: MouseEvent) { 8 | $event.stopPropagation(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /angular/src/guards/lock.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from "@angular/core"; 2 | import { CanActivate, Router } from "@angular/router"; 3 | 4 | import { AuthService } from "jslib-common/abstractions/auth.service"; 5 | import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus"; 6 | 7 | @Injectable() 8 | export class LockGuard implements CanActivate { 9 | protected homepage = "vault"; 10 | protected loginpage = "login"; 11 | constructor(private authService: AuthService, private router: Router) {} 12 | 13 | async canActivate() { 14 | const authStatus = await this.authService.getAuthStatus(); 15 | 16 | if (authStatus === AuthenticationStatus.Locked) { 17 | return true; 18 | } 19 | 20 | const redirectUrl = 21 | authStatus === AuthenticationStatus.LoggedOut ? this.loginpage : this.homepage; 22 | 23 | return this.router.createUrlTree([redirectUrl]); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /angular/src/guards/unauth.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from "@angular/core"; 2 | import { CanActivate, Router } from "@angular/router"; 3 | 4 | import { AuthService } from "jslib-common/abstractions/auth.service"; 5 | import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus"; 6 | 7 | @Injectable() 8 | export class UnauthGuard implements CanActivate { 9 | protected homepage = "vault"; 10 | constructor(private authService: AuthService, private router: Router) {} 11 | 12 | async canActivate() { 13 | const authStatus = await this.authService.getAuthStatus(); 14 | 15 | if (authStatus === AuthenticationStatus.LoggedOut) { 16 | return true; 17 | } 18 | 19 | if (authStatus === AuthenticationStatus.Locked) { 20 | return this.router.createUrlTree(["lock"]); 21 | } 22 | 23 | return this.router.createUrlTree([this.homepage]); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /angular/src/images/cards/amex-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/amex-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/amex-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/amex-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/diners_club-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/diners_club-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/diners_club-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/diners_club-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/discover-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/discover-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/discover-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/discover-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/jcb-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/jcb-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/jcb-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/jcb-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/maestro-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/maestro-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/maestro-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/maestro-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/mastercard-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/mastercard-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/mastercard-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/mastercard-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/ru_pay-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/ru_pay-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/ru_pay-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/ru_pay-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/union_pay-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/union_pay-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/union_pay-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/union_pay-light.png -------------------------------------------------------------------------------- /angular/src/images/cards/visa-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/visa-dark.png -------------------------------------------------------------------------------- /angular/src/images/cards/visa-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/images/cards/visa-light.png -------------------------------------------------------------------------------- /angular/src/interfaces/selectOptions.ts: -------------------------------------------------------------------------------- 1 | export interface SelectOptions { 2 | name: string; 3 | value: any; 4 | disabled?: boolean; 5 | } 6 | -------------------------------------------------------------------------------- /angular/src/modules/vault-filter/components/status-filter.component.ts: -------------------------------------------------------------------------------- 1 | import { Directive, EventEmitter, Input, Output } from "@angular/core"; 2 | 3 | import { CipherStatus } from "../models/cipher-status.model"; 4 | import { VaultFilter } from "../models/vault-filter.model"; 5 | 6 | @Directive() 7 | export class StatusFilterComponent { 8 | @Input() hideFavorites = false; 9 | @Input() hideTrash = false; 10 | @Output() onFilterChange: EventEmitter = new EventEmitter(); 11 | @Input() activeFilter: VaultFilter; 12 | 13 | get show() { 14 | return !(this.hideFavorites && this.hideTrash); 15 | } 16 | 17 | applyFilter(cipherStatus: CipherStatus) { 18 | this.activeFilter.resetFilter(); 19 | this.activeFilter.status = cipherStatus; 20 | this.onFilterChange.emit(this.activeFilter); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /angular/src/modules/vault-filter/models/cipher-status.model.ts: -------------------------------------------------------------------------------- 1 | export type CipherStatus = "all" | "favorites" | "trash"; 2 | -------------------------------------------------------------------------------- /angular/src/modules/vault-filter/models/display-mode.ts: -------------------------------------------------------------------------------- 1 | export type DisplayMode = 2 | | "noOrganizations" 3 | | "organizationMember" 4 | | "singleOrganizationPolicy" 5 | | "personalOwnershipPolicy" 6 | | "singleOrganizationAndPersonalOwnershipPolicies"; 7 | -------------------------------------------------------------------------------- /angular/src/modules/vault-filter/models/dynamic-tree-node.model.ts: -------------------------------------------------------------------------------- 1 | import { TreeNode } from "jslib-common/models/domain/treeNode"; 2 | import { CollectionView } from "jslib-common/models/view/collectionView"; 3 | import { FolderView } from "jslib-common/models/view/folderView"; 4 | 5 | export class DynamicTreeNode { 6 | fullList: T[]; 7 | nestedList: TreeNode[]; 8 | 9 | hasId(id: string): boolean { 10 | return this.fullList != null && this.fullList.filter((i: T) => i.id === id).length > 0; 11 | } 12 | 13 | constructor(init?: Partial>) { 14 | Object.assign(this, init); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /angular/src/modules/vault-filter/models/top-level-tree-node.model.ts: -------------------------------------------------------------------------------- 1 | import { ITreeNodeObject } from "jslib-common/models/domain/treeNode"; 2 | 3 | export type TopLevelTreeNodeId = "vaults" | "types" | "collections" | "folders"; 4 | export class TopLevelTreeNode implements ITreeNodeObject { 5 | id: TopLevelTreeNodeId; 6 | name: string; // localizationString 7 | } 8 | -------------------------------------------------------------------------------- /angular/src/pipes/color-password-count.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe } from "@angular/core"; 2 | 3 | import { ColorPasswordPipe } from "./color-password.pipe"; 4 | 5 | /* 6 | An updated pipe that extends ColourPasswordPipe to include a character count 7 | */ 8 | @Pipe({ name: "colorPasswordCount" }) 9 | export class ColorPasswordCountPipe extends ColorPasswordPipe { 10 | transform(password: string) { 11 | const template = (character: string, type: string, index: number) => 12 | ` 13 | ${character}${index + 1} 14 | `; 15 | const colorizedPasswordCount = this.generateTemplate(password, template); 16 | 17 | return colorizedPasswordCount; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /angular/src/pipes/ellipsis.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from "@angular/core"; 2 | 3 | @Pipe({ 4 | name: "ellipsis", 5 | }) 6 | export class EllipsisPipe implements PipeTransform { 7 | transform(value: string, limit = 25, completeWords = false, ellipsis = "...") { 8 | if (value.length <= limit) { 9 | return value; 10 | } 11 | limit -= ellipsis.length; 12 | if (completeWords && value.length > limit && value.indexOf(" ") > 0) { 13 | limit = value.substring(0, limit).lastIndexOf(" "); 14 | } 15 | return value.substring(0, limit) + ellipsis; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /angular/src/pipes/i18n.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from "@angular/core"; 2 | 3 | import { I18nService } from "jslib-common/abstractions/i18n.service"; 4 | 5 | @Pipe({ 6 | name: "i18n", 7 | }) 8 | export class I18nPipe implements PipeTransform { 9 | constructor(private i18nService: I18nService) {} 10 | 11 | transform(id: string, p1?: string, p2?: string, p3?: string): string { 12 | return this.i18nService.t(id, p1, p2, p3); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /angular/src/pipes/user-name.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from "@angular/core"; 2 | 3 | interface User { 4 | name?: string; 5 | email: string; 6 | } 7 | 8 | @Pipe({ 9 | name: "userName", 10 | }) 11 | export class UserNamePipe implements PipeTransform { 12 | transform(user?: User): string { 13 | if (user == null) { 14 | return null; 15 | } 16 | 17 | return user.name == null || user.name.trim() === "" ? user.email : user.name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /angular/src/scss/bwicons/fonts/bwi-font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/bwicons/fonts/bwi-font.ttf -------------------------------------------------------------------------------- /angular/src/scss/bwicons/fonts/bwi-font.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/bwicons/fonts/bwi-font.woff -------------------------------------------------------------------------------- /angular/src/scss/bwicons/fonts/bwi-font.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/bwicons/fonts/bwi-font.woff2 -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-italic-300.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-italic-300.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-italic-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-italic-400.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-italic-600.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-italic-600.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-italic-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-italic-700.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-italic-800.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-italic-800.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-normal-300.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-normal-300.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-normal-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-normal-400.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-normal-600.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-normal-600.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-normal-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-normal-700.woff -------------------------------------------------------------------------------- /angular/src/scss/webfonts/Open_Sans-normal-800.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/angular/src/scss/webfonts/Open_Sans-normal-800.woff -------------------------------------------------------------------------------- /angular/src/services/broadcaster.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from "@angular/core"; 2 | 3 | import { BroadcasterService as BaseBroadcasterService } from "jslib-common/services/broadcaster.service"; 4 | 5 | @Injectable() 6 | export class BroadcasterService extends BaseBroadcasterService {} 7 | -------------------------------------------------------------------------------- /angular/src/validators/dirty.validator.ts: -------------------------------------------------------------------------------- 1 | import { AbstractControl, ValidationErrors, Validators } from "@angular/forms"; 2 | 3 | /** 4 | * Runs Validators.required on a field only if it's dirty. This prevents error messages from being displayed 5 | * to the user prematurely. 6 | */ 7 | export function dirtyRequired(control: AbstractControl): ValidationErrors | null { 8 | return control.dirty ? Validators.required(control) : null; 9 | } 10 | -------------------------------------------------------------------------------- /angular/src/validators/notAllowedValueAsync.validator.ts: -------------------------------------------------------------------------------- 1 | import { AbstractControl, AsyncValidatorFn, ValidationErrors } from "@angular/forms"; 2 | 3 | export function notAllowedValueAsync( 4 | valueGetter: () => Promise, 5 | caseInsensitive = false 6 | ): AsyncValidatorFn { 7 | return async (control: AbstractControl): Promise => { 8 | let notAllowedValue = await valueGetter(); 9 | let controlValue = control.value; 10 | if (caseInsensitive) { 11 | notAllowedValue = notAllowedValue.toLowerCase(); 12 | controlValue = controlValue.toLowerCase(); 13 | } 14 | 15 | if (controlValue === notAllowedValue) { 16 | return { 17 | notAllowedValue: true, 18 | }; 19 | } 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /angular/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../shared/tsconfig", 3 | "compilerOptions": { 4 | "paths": { 5 | "jslib-common/*": ["../common/src/*"], 6 | "jslib-angular/*": ["./src/"] 7 | } 8 | }, 9 | "include": ["src", "spec"], 10 | "exclude": ["node_modules", "dist"] 11 | } 12 | -------------------------------------------------------------------------------- /angular/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /common/jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require("ts-jest"); 2 | 3 | const { compilerOptions } = require("./tsconfig"); 4 | 5 | module.exports = { 6 | name: "common", 7 | displayName: "common jslib tests", 8 | preset: "ts-jest", 9 | testEnvironment: "jsdom", 10 | testMatch: ["**/+(*.)+(spec).+(ts)"], 11 | setupFilesAfterEnv: ["/spec/test.ts"], 12 | collectCoverage: true, 13 | coverageReporters: ["html", "lcov"], 14 | coverageDirectory: "coverage", 15 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, { 16 | prefix: "/", 17 | }), 18 | }; 19 | -------------------------------------------------------------------------------- /common/spec/importers/testData/bitwardenJson/empty.json.ts: -------------------------------------------------------------------------------- 1 | export const data = '{"encrypted":false,"folders":[],"items":[]}'; 2 | -------------------------------------------------------------------------------- /common/spec/importers/testData/dashlaneCsv/credentials.csv.ts: -------------------------------------------------------------------------------- 1 | export const credentialsData = `username,username2,username3,title,password,note,url,category,otpSecret 2 | jdoe,,,example.com,somePassword,some note for example.com,https://www.example.com,Entertainment,someTOTPSeed`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/dashlaneCsv/id.csv.ts: -------------------------------------------------------------------------------- 1 | export const identityData = `type,number,name,issue_date,expiration_date,place_of_issue,state 2 | card,123123123,John Doe,2022-1-30,2032-1-30,, 3 | passport,123123123,John Doe,2022-1-30,2032-1-30,somewhere in Germany, 4 | license,1234556,John Doe,2022-8-10,2022-10-10,,DC 5 | social_security,123123123,John Doe,,,, 6 | tax_number,123123123,,,,,`; 7 | -------------------------------------------------------------------------------- /common/spec/importers/testData/dashlaneCsv/multiplePersonalInfo.csv.ts: -------------------------------------------------------------------------------- 1 | export const multiplePersonalInfoData = `type,title,first_name,middle_name,last_name,login,date_of_birth,place_of_birth,email,email_type,item_name,phone_number,address,country,state,city,zip,address_recipient,address_building,address_apartment,address_floor,address_door_code,job_title,url 2 | name,MR,John,,Doe,jdoe,2022-01-30,world,,,,,,,,,,,,,,,, 3 | email,,,,,,,,jdoe@example.com,personal,Johns email,,,,,,,,,,,,, 4 | number,,,,,,,,,,John's number,+49123123123,,,,,,,,,,,, 5 | address,,,,,,,,,,John's home address,,1 some street,de,DE-0-NW,some city,123123,John,1,1,1,123,, 6 | website,,,,,,,,,,Website,,,,,,,,,,,,,website.com 7 | name,Mrs,Jane,,Doe,jdoe,2022-01-30,earth,,,,,,,,,,,,,,,,`; 8 | -------------------------------------------------------------------------------- /common/spec/importers/testData/dashlaneCsv/payments.csv.ts: -------------------------------------------------------------------------------- 1 | export const paymentsData = `type,account_name,account_holder,cc_number,code,expiration_month,expiration_year,routing_number,account_number,country,issuing_bank 2 | bank,John's savings account,John Doe,,,,,routingNumber,accountNumber,US,US-ALLY 3 | credit_card,John Doe,,41111111111111111,123,01,2023,,,US,`; 4 | -------------------------------------------------------------------------------- /common/spec/importers/testData/dashlaneCsv/personalInfo.csv.ts: -------------------------------------------------------------------------------- 1 | export const personalInfoData = `type,title,first_name,middle_name,last_name,login,date_of_birth,place_of_birth,email,email_type,item_name,phone_number,address,country,state,city,zip,address_recipient,address_building,address_apartment,address_floor,address_door_code,job_title,url 2 | name,MR,John,,Doe,jdoe,2022-01-30,world,,,,,,,,,,,,,,,, 3 | email,,,,,,,,jdoe@example.com,personal,Johns email,,,,,,,,,,,,, 4 | number,,,,,,,,,,John's number,+49123123123,,,,,,,,,,,, 5 | address,,,,,,,,,,John's home address,,1 some street,de,DE-0-NW,some city,123123,John,1,1,1,123,, 6 | website,,,,,,,,,,Website,,,,,,,,,,,,,website.com`; 7 | -------------------------------------------------------------------------------- /common/spec/importers/testData/dashlaneCsv/securenotes.csv.ts: -------------------------------------------------------------------------------- 1 | export const secureNoteData = `title,note 2 | 01,test`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/firefoxCsv/simplePasswordData.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `"url","username","password","httpRealm","formActionOrigin","guid","timeCreated","timeLastUsed","timePasswordChanged" 2 | "https://example.com","foo","bar",,"","{d61e37fa-2bc4-469a-bd66-41fd3b0005e0}","1612345678900","1612345678900","1612345678900"`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/mykiCsv/UserAccount.csv.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const userAccountData = `nickname,url,username,password,additionalInfo,twofaSecret,status,tags 3 | PasswordNickname,www.google.com,user.name@email.com,abc123,This is the additional information text.,someTOTPSeed,active,someTag`; 4 | -------------------------------------------------------------------------------- /common/spec/importers/testData/mykiCsv/UserCreditCard.csv.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const userCreditCardData = `nickname,status,tags,cardNumber,cardName,exp_month,exp_year,cvv,additionalInfo 3 | Visa test card,active,someTag,4111111111111111,Joe User,04,24,222,This is the additional information field`; 4 | -------------------------------------------------------------------------------- /common/spec/importers/testData/mykiCsv/UserIdentity.csv.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const userIdentityData = `nickname,status,tags,firstName,middleName,lastName,email,firstAddressLine,secondAddressLine,title,gender,number,city,country,zipCode,additionalInfo 3 | Joe User's nickname,active,someTag,Joe,M,User,joe.user@email.com,1 Example House,Suite 300,Mr,Male,2223334444,Portland,United States,04101,Additional information field`; 4 | -------------------------------------------------------------------------------- /common/spec/importers/testData/mykiCsv/UserNote.csv.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const userNoteData = `nickname,status,content 3 | The title of a secure note,active,"The content of a secure note. Lorem ipsum, etc."`; 4 | -------------------------------------------------------------------------------- /common/spec/importers/testData/mykiCsv/UserTwofa.csv.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const userTwoFaData = `nickname,status,tags,authToken,additionalInfo 3 | 2FA nickname,active,someTag,someTOTPSeed,"Additional information field content. "`; 4 | -------------------------------------------------------------------------------- /common/spec/importers/testData/nordpassCsv/nordpass.card.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `name,url,username,password,note,cardholdername,cardnumber,cvc,expirydate,zipcode,folder,full_name,phone_number,email,address1,address2,city,country,state 2 | SomeVisa,,,,,SomeHolder,4024007103939509,123,01 / 22,12345,,,,,,,,,`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/nordpassCsv/nordpass.identity.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `name,url,username,password,note,cardholdername,cardnumber,cvc,expirydate,zipcode,folder,full_name,phone_number,email,address1,address2,city,country,state 2 | SomeTitle,,,,SomeNoteToMyIdentity,,,,,123456,,#fullName,123456789,hello@bitwarden.com,Test street 123,additional addressinfo,Cologne,Germany,North-Rhine-Westphalia`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/nordpassCsv/nordpass.login.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `name,url,username,password,note,cardholdername,cardnumber,cvc,expirydate,zipcode,folder,full_name,phone_number,email,address1,address2,city,country,state 2 | SomeVaultItemName,https://example.com,hello@bitwarden.com,someStrongPassword,Some note for the VaultItem,,,,,,SomeFolderForVaultItem,,,,,,,,`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/nordpassCsv/nordpass.secureNote.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `name,url,username,password,note,cardholdername,cardnumber,cvc,expirydate,zipcode,folder,full_name,phone_number,email,address1,address2,city,country,state 2 | notesFolder,,,,,,,,,,,,,,,,,, 3 | MySuperSecureNoteTitle,,,,MySuperSecureNote,,,,,,notesFolder,,,,,,,,`; 4 | -------------------------------------------------------------------------------- /common/spec/importers/testData/onePasswordCsv/creditCard.windows.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `"UUID","TITLE","SCOPE","AUTOSUBMIT","1: CARDHOLDER NAME","2: NUMBER","3: VERIFICATION NUMBER","4: EXPIRY DATE","SECTION 2: SECTION_PZET7LEKRQXZUINIEGH5ABA2UY","SECTION_PZET7LEKRQXZUINIEGH5ABA2UY 1: LABEL" 2 | "sd26pt226etnsijbl3kqzi5bmm","test card","Default","Default","test","4111111111111111","111","1/3/1970 12:23 AM","section","field (phone)"`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/safariCsv/oldSimplePasswordData.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `Title,Url,Username,Password 2 | example.com (example_user),https://example.com,example_user,example_p@ssword`; 3 | -------------------------------------------------------------------------------- /common/spec/importers/testData/safariCsv/simplePasswordData.csv.ts: -------------------------------------------------------------------------------- 1 | export const data = `Title,URL,Username,Password,Notes,OTPAuth 2 | example.com (example_user),https://example.com,example_user,example_p@ssword,"Example note 3 | More notes on new line",otpauth://totp/test?secret=examplesecret`; 4 | -------------------------------------------------------------------------------- /common/spec/test.ts: -------------------------------------------------------------------------------- 1 | import { webcrypto } from "crypto"; 2 | 3 | Object.defineProperty(window, "crypto", { 4 | value: webcrypto, 5 | }); 6 | -------------------------------------------------------------------------------- /common/src/abstractions/appId.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class AppIdService { 2 | getAppId: () => Promise; 3 | getAnonymousAppId: () => Promise; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/abstractions/audit.service.ts: -------------------------------------------------------------------------------- 1 | import { BreachAccountResponse } from "../models/response/breachAccountResponse"; 2 | 3 | export abstract class AuditService { 4 | passwordLeaked: (password: string) => Promise; 5 | breachedAccounts: (username: string) => Promise; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/abstractions/broadcaster.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class BroadcasterService { 2 | send: (message: any, id?: string) => void; 3 | subscribe: (id: string, messageCallback: (message: any) => any) => void; 4 | unsubscribe: (id: string) => void; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/abstractions/environment.service.ts: -------------------------------------------------------------------------------- 1 | import { Observable } from "rxjs"; 2 | 3 | export type Urls = { 4 | base?: string; 5 | webVault?: string; 6 | api?: string; 7 | identity?: string; 8 | icons?: string; 9 | notifications?: string; 10 | events?: string; 11 | keyConnector?: string; 12 | }; 13 | 14 | export type PayPalConfig = { 15 | businessId?: string; 16 | buttonAction?: string; 17 | }; 18 | 19 | export abstract class EnvironmentService { 20 | urls: Observable; 21 | 22 | hasBaseUrl: () => boolean; 23 | getNotificationsUrl: () => string; 24 | getWebVaultUrl: () => string; 25 | getSendUrl: () => string; 26 | getIconsUrl: () => string; 27 | getApiUrl: () => string; 28 | getIdentityUrl: () => string; 29 | getEventsUrl: () => string; 30 | getKeyConnectorUrl: () => string; 31 | setUrlsFromStorage: () => Promise; 32 | setUrls: (urls: Urls) => Promise; 33 | getUrls: () => Urls; 34 | } 35 | -------------------------------------------------------------------------------- /common/src/abstractions/event.service.ts: -------------------------------------------------------------------------------- 1 | import { EventType } from "../enums/eventType"; 2 | 3 | export abstract class EventService { 4 | collect: (eventType: EventType, cipherId?: string, uploadImmediately?: boolean) => Promise; 5 | uploadEvents: (userId?: string) => Promise; 6 | clearEvents: (userId?: string) => Promise; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/abstractions/export.service.ts: -------------------------------------------------------------------------------- 1 | import { EventView } from "../models/view/eventView"; 2 | 3 | export type ExportFormat = "csv" | "json" | "encrypted_json"; 4 | 5 | export abstract class ExportService { 6 | getExport: (format?: ExportFormat, organizationId?: string) => Promise; 7 | getPasswordProtectedExport: (password: string, organizationId?: string) => Promise; 8 | getOrganizationExport: (organizationId: string, format?: ExportFormat) => Promise; 9 | getEventExport: (events: EventView[]) => Promise; 10 | getFileName: (prefix?: string, extension?: string) => string; 11 | } 12 | -------------------------------------------------------------------------------- /common/src/abstractions/fileUpload.service.ts: -------------------------------------------------------------------------------- 1 | import { EncArrayBuffer } from "../models/domain/encArrayBuffer"; 2 | import { EncString } from "../models/domain/encString"; 3 | import { AttachmentUploadDataResponse } from "../models/response/attachmentUploadDataResponse"; 4 | import { SendFileUploadDataResponse } from "../models/response/sendFileUploadDataResponse"; 5 | 6 | export abstract class FileUploadService { 7 | uploadSendFile: ( 8 | uploadData: SendFileUploadDataResponse, 9 | fileName: EncString, 10 | encryptedFileData: EncArrayBuffer 11 | ) => Promise; 12 | uploadCipherAttachment: ( 13 | admin: boolean, 14 | uploadData: AttachmentUploadDataResponse, 15 | fileName: EncString, 16 | encryptedFileData: EncArrayBuffer 17 | ) => Promise; 18 | } 19 | -------------------------------------------------------------------------------- /common/src/abstractions/i18n.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class I18nService { 2 | locale: string; 3 | supportedTranslationLocales: string[]; 4 | translationLocale: string; 5 | collator: Intl.Collator; 6 | localeNames: Map; 7 | t: (id: string, p1?: string, p2?: string, p3?: string) => string; 8 | translate: (id: string, p1?: string, p2?: string, p3?: string) => string; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/abstractions/import.service.ts: -------------------------------------------------------------------------------- 1 | import { ImportOption, ImportType } from "../enums/importOptions"; 2 | import { ImportError } from "../importers/importError"; 3 | import { Importer } from "../importers/importer"; 4 | 5 | export abstract class ImportService { 6 | featuredImportOptions: readonly ImportOption[]; 7 | regularImportOptions: readonly ImportOption[]; 8 | getImportOptions: () => ImportOption[]; 9 | import: ( 10 | importer: Importer, 11 | fileContents: string, 12 | organizationId?: string 13 | ) => Promise; 14 | getImporter: ( 15 | format: ImportType | "bitwardenpasswordprotected", 16 | organizationId: string, 17 | password?: string 18 | ) => Importer; 19 | } 20 | -------------------------------------------------------------------------------- /common/src/abstractions/keyConnector.service.ts: -------------------------------------------------------------------------------- 1 | import { Organization } from "../models/domain/organization"; 2 | import { IdentityTokenResponse } from "../models/response/identityTokenResponse"; 3 | 4 | export abstract class KeyConnectorService { 5 | getAndSetKey: (url?: string) => Promise; 6 | getManagingOrganization: () => Promise; 7 | getUsesKeyConnector: () => Promise; 8 | migrateUser: () => Promise; 9 | userNeedsMigration: () => Promise; 10 | convertNewSsoUserToKeyConnector: ( 11 | tokenResponse: IdentityTokenResponse, 12 | orgId: string 13 | ) => Promise; 14 | setUsesKeyConnector: (enabled: boolean) => Promise; 15 | setConvertAccountRequired: (status: boolean) => Promise; 16 | getConvertAccountRequired: () => Promise; 17 | removeConvertAccountRequired: () => Promise; 18 | clear: () => Promise; 19 | } 20 | -------------------------------------------------------------------------------- /common/src/abstractions/log.service.ts: -------------------------------------------------------------------------------- 1 | import { LogLevelType } from "../enums/logLevelType"; 2 | 3 | export abstract class LogService { 4 | debug: (message: string) => void; 5 | info: (message: string) => void; 6 | warning: (message: string) => void; 7 | error: (message: string) => void; 8 | write: (level: LogLevelType, message: string) => void; 9 | time: (label: string) => void; 10 | timeEnd: (label: string) => [number, number]; 11 | } 12 | -------------------------------------------------------------------------------- /common/src/abstractions/messaging.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class MessagingService { 2 | send: (subscriber: string, arg?: any) => void; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/abstractions/notifications.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class NotificationsService { 2 | init: () => Promise; 3 | updateConnection: (sync?: boolean) => Promise; 4 | reconnectFromActivity: () => Promise; 5 | disconnectFromInactivity: () => Promise; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/abstractions/organization.service.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationData } from "../models/data/organizationData"; 2 | import { Organization } from "../models/domain/organization"; 3 | 4 | export abstract class OrganizationService { 5 | get: (id: string) => Promise; 6 | getByIdentifier: (identifier: string) => Promise; 7 | getAll: (userId?: string) => Promise; 8 | save: (orgs: { [id: string]: OrganizationData }) => Promise; 9 | canManageSponsorships: () => Promise; 10 | hasOrganizations: (userId?: string) => Promise; 11 | } 12 | -------------------------------------------------------------------------------- /common/src/abstractions/passwordReprompt.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class PasswordRepromptService { 2 | protectedFields: () => string[]; 3 | showPasswordPrompt: () => Promise; 4 | enabled: () => Promise; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/abstractions/provider.service.ts: -------------------------------------------------------------------------------- 1 | import { ProviderData } from "../models/data/providerData"; 2 | import { Provider } from "../models/domain/provider"; 3 | 4 | export abstract class ProviderService { 5 | get: (id: string) => Promise; 6 | getAll: () => Promise; 7 | save: (providers: { [id: string]: ProviderData }) => Promise; 8 | } 9 | -------------------------------------------------------------------------------- /common/src/abstractions/search.service.ts: -------------------------------------------------------------------------------- 1 | import { CipherView } from "../models/view/cipherView"; 2 | import { SendView } from "../models/view/sendView"; 3 | 4 | export abstract class SearchService { 5 | indexedEntityId?: string = null; 6 | clearIndex: () => void; 7 | isSearchable: (query: string) => boolean; 8 | indexCiphers: (indexedEntityGuid?: string, ciphersToIndex?: CipherView[]) => Promise; 9 | searchCiphers: ( 10 | query: string, 11 | filter?: ((cipher: CipherView) => boolean) | ((cipher: CipherView) => boolean)[], 12 | ciphers?: CipherView[] 13 | ) => Promise; 14 | searchCiphersBasic: (ciphers: CipherView[], query: string, deleted?: boolean) => CipherView[]; 15 | searchSends: (sends: SendView[], query: string) => SendView[]; 16 | } 17 | -------------------------------------------------------------------------------- /common/src/abstractions/settings.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class SettingsService { 2 | clearCache: () => Promise; 3 | getEquivalentDomains: () => Promise; 4 | setEquivalentDomains: (equivalentDomains: string[][]) => Promise; 5 | clear: (userId?: string) => Promise; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/abstractions/stateMigration.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class StateMigrationService { 2 | needsMigration: () => Promise; 3 | migrate: () => Promise; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/abstractions/storage.service.ts: -------------------------------------------------------------------------------- 1 | import { StorageOptions } from "../models/domain/storageOptions"; 2 | 3 | export abstract class StorageService { 4 | get: (key: string, options?: StorageOptions) => Promise; 5 | has: (key: string, options?: StorageOptions) => Promise; 6 | save: (key: string, obj: any, options?: StorageOptions) => Promise; 7 | remove: (key: string, options?: StorageOptions) => Promise; 8 | } 9 | -------------------------------------------------------------------------------- /common/src/abstractions/system.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class SystemService { 2 | startProcessReload: () => Promise; 3 | cancelProcessReload: () => void; 4 | clearClipboard: (clipboardValue: string, timeoutMs?: number) => Promise; 5 | clearPendingClipboard: () => Promise; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/abstractions/totp.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class TotpService { 2 | getCode: (key: string) => Promise; 3 | getTimeInterval: (key: string) => number; 4 | isAutoCopyEnabled: () => Promise; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/abstractions/twoFactor.service.ts: -------------------------------------------------------------------------------- 1 | import { TwoFactorProviderType } from "../enums/twoFactorProviderType"; 2 | import { IdentityTwoFactorResponse } from "../models/response/identityTwoFactorResponse"; 3 | 4 | export interface TwoFactorProviderDetails { 5 | type: TwoFactorProviderType; 6 | name: string; 7 | description: string; 8 | priority: number; 9 | sort: number; 10 | premium: boolean; 11 | } 12 | 13 | export abstract class TwoFactorService { 14 | init: () => void; 15 | getSupportedProviders: (win: Window) => TwoFactorProviderDetails[]; 16 | getDefaultProvider: (webAuthnSupported: boolean) => TwoFactorProviderType; 17 | setSelectedProvider: (type: TwoFactorProviderType) => void; 18 | clearSelectedProvider: () => void; 19 | 20 | setProviders: (response: IdentityTwoFactorResponse) => void; 21 | clearProviders: () => void; 22 | getProviders: () => Map; 23 | } 24 | -------------------------------------------------------------------------------- /common/src/abstractions/userVerification.service.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "../models/request/secretVerificationRequest"; 2 | import { Verification } from "../types/verification"; 3 | 4 | export abstract class UserVerificationService { 5 | buildRequest: ( 6 | verification: Verification, 7 | requestClass?: new () => T, 8 | alreadyHashed?: boolean 9 | ) => Promise; 10 | verifyUser: (verification: Verification) => Promise; 11 | requestOTP: () => Promise; 12 | } 13 | -------------------------------------------------------------------------------- /common/src/abstractions/usernameGeneration.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class UsernameGenerationService { 2 | generateUsername: (options: any) => Promise; 3 | generateWord: (options: any) => Promise; 4 | generateSubaddress: (options: any) => Promise; 5 | generateCatchall: (options: any) => Promise; 6 | generateForwarded: (options: any) => Promise; 7 | getOptions: () => Promise; 8 | saveOptions: (options: any) => Promise; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/abstractions/vaultTimeout.service.ts: -------------------------------------------------------------------------------- 1 | export abstract class VaultTimeoutService { 2 | checkVaultTimeout: () => Promise; 3 | lock: (allowSoftLock?: boolean, userId?: string) => Promise; 4 | logOut: (userId?: string) => Promise; 5 | setVaultTimeoutOptions: (vaultTimeout: number, vaultTimeoutAction: string) => Promise; 6 | getVaultTimeout: () => Promise; 7 | isPinLockSet: () => Promise<[boolean, boolean]>; 8 | isBiometricLockSet: () => Promise; 9 | clear: (userId?: string) => Promise; 10 | } 11 | -------------------------------------------------------------------------------- /common/src/enums/authenticationStatus.ts: -------------------------------------------------------------------------------- 1 | export enum AuthenticationStatus { 2 | LoggedOut = 0, 3 | Locked = 1, 4 | Unlocked = 2, 5 | } 6 | -------------------------------------------------------------------------------- /common/src/enums/authenticationType.ts: -------------------------------------------------------------------------------- 1 | export enum AuthenticationType { 2 | Password = 0, 3 | Sso = 1, 4 | Api = 2, 5 | } 6 | -------------------------------------------------------------------------------- /common/src/enums/cipherRepromptType.ts: -------------------------------------------------------------------------------- 1 | export enum CipherRepromptType { 2 | None = 0, 3 | Password = 1, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/cipherType.ts: -------------------------------------------------------------------------------- 1 | export enum CipherType { 2 | Login = 1, 3 | SecureNote = 2, 4 | Card = 3, 5 | Identity = 4, 6 | } 7 | -------------------------------------------------------------------------------- /common/src/enums/clientType.ts: -------------------------------------------------------------------------------- 1 | export enum ClientType { 2 | Web = "web", 3 | Browser = "browser", 4 | Desktop = "desktop", 5 | Mobile = "mobile", 6 | Cli = "cli", 7 | DirectoryConnector = "connector", 8 | } 9 | -------------------------------------------------------------------------------- /common/src/enums/deviceType.ts: -------------------------------------------------------------------------------- 1 | export enum DeviceType { 2 | Android = 0, 3 | iOS = 1, 4 | ChromeExtension = 2, 5 | FirefoxExtension = 3, 6 | OperaExtension = 4, 7 | EdgeExtension = 5, 8 | WindowsDesktop = 6, 9 | MacOsDesktop = 7, 10 | LinuxDesktop = 8, 11 | ChromeBrowser = 9, 12 | FirefoxBrowser = 10, 13 | OperaBrowser = 11, 14 | EdgeBrowser = 12, 15 | IEBrowser = 13, 16 | UnknownBrowser = 14, 17 | AndroidAmazon = 15, 18 | UWP = 16, 19 | SafariBrowser = 17, 20 | VivaldiBrowser = 18, 21 | VivaldiExtension = 19, 22 | SafariExtension = 20, 23 | } 24 | -------------------------------------------------------------------------------- /common/src/enums/emergencyAccessStatusType.ts: -------------------------------------------------------------------------------- 1 | export enum EmergencyAccessStatusType { 2 | Invited = 0, 3 | Accepted = 1, 4 | Confirmed = 2, 5 | RecoveryInitiated = 3, 6 | RecoveryApproved = 4, 7 | } 8 | -------------------------------------------------------------------------------- /common/src/enums/emergencyAccessType.ts: -------------------------------------------------------------------------------- 1 | export enum EmergencyAccessType { 2 | View = 0, 3 | Takeover = 1, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/encryptionType.ts: -------------------------------------------------------------------------------- 1 | export enum EncryptionType { 2 | AesCbc256_B64 = 0, 3 | AesCbc128_HmacSha256_B64 = 1, 4 | AesCbc256_HmacSha256_B64 = 2, 5 | Rsa2048_OaepSha256_B64 = 3, 6 | Rsa2048_OaepSha1_B64 = 4, 7 | Rsa2048_OaepSha256_HmacSha256_B64 = 5, 8 | Rsa2048_OaepSha1_HmacSha256_B64 = 6, 9 | } 10 | -------------------------------------------------------------------------------- /common/src/enums/fieldType.ts: -------------------------------------------------------------------------------- 1 | export enum FieldType { 2 | Text = 0, 3 | Hidden = 1, 4 | Boolean = 2, 5 | Linked = 3, 6 | } 7 | -------------------------------------------------------------------------------- /common/src/enums/fileUploadType.ts: -------------------------------------------------------------------------------- 1 | export enum FileUploadType { 2 | Direct = 0, 3 | Azure = 1, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/hashPurpose.ts: -------------------------------------------------------------------------------- 1 | export enum HashPurpose { 2 | ServerAuthorization = 1, 3 | LocalAuthorization = 2, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/htmlStorageLocation.ts: -------------------------------------------------------------------------------- 1 | export enum HtmlStorageLocation { 2 | Local = "local", 3 | Memory = "memory", 4 | Session = "session", 5 | } 6 | -------------------------------------------------------------------------------- /common/src/enums/kdfType.ts: -------------------------------------------------------------------------------- 1 | export enum KdfType { 2 | PBKDF2_SHA256 = 0, 3 | } 4 | 5 | export const DEFAULT_KDF_TYPE = KdfType.PBKDF2_SHA256; 6 | export const DEFAULT_KDF_ITERATIONS = 100000; 7 | export const SEND_KDF_ITERATIONS = 100000; 8 | -------------------------------------------------------------------------------- /common/src/enums/keySuffixOptions.ts: -------------------------------------------------------------------------------- 1 | export enum KeySuffixOptions { 2 | Auto = "auto", 3 | Biometric = "biometric", 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/linkedIdType.ts: -------------------------------------------------------------------------------- 1 | export type LinkedIdType = LoginLinkedId | CardLinkedId | IdentityLinkedId; 2 | 3 | // LoginView 4 | export enum LoginLinkedId { 5 | Username = 100, 6 | Password = 101, 7 | } 8 | 9 | // CardView 10 | export enum CardLinkedId { 11 | CardholderName = 300, 12 | ExpMonth = 301, 13 | ExpYear = 302, 14 | Code = 303, 15 | Brand = 304, 16 | Number = 305, 17 | } 18 | 19 | // IdentityView 20 | export enum IdentityLinkedId { 21 | Title = 400, 22 | MiddleName = 401, 23 | Address1 = 402, 24 | Address2 = 403, 25 | Address3 = 404, 26 | City = 405, 27 | State = 406, 28 | PostalCode = 407, 29 | Country = 408, 30 | Company = 409, 31 | Email = 410, 32 | Phone = 411, 33 | Ssn = 412, 34 | Username = 413, 35 | PassportNumber = 414, 36 | LicenseNumber = 415, 37 | FirstName = 416, 38 | LastName = 417, 39 | FullName = 418, 40 | } 41 | -------------------------------------------------------------------------------- /common/src/enums/logLevelType.ts: -------------------------------------------------------------------------------- 1 | export enum LogLevelType { 2 | Debug, 3 | Info, 4 | Warning, 5 | Error, 6 | } 7 | -------------------------------------------------------------------------------- /common/src/enums/notificationType.ts: -------------------------------------------------------------------------------- 1 | export enum NotificationType { 2 | SyncCipherUpdate = 0, 3 | SyncCipherCreate = 1, 4 | SyncLoginDelete = 2, 5 | SyncFolderDelete = 3, 6 | SyncCiphers = 4, 7 | 8 | SyncVault = 5, 9 | SyncOrgKeys = 6, 10 | SyncFolderCreate = 7, 11 | SyncFolderUpdate = 8, 12 | SyncCipherDelete = 9, 13 | SyncSettings = 10, 14 | 15 | LogOut = 11, 16 | 17 | SyncSendCreate = 12, 18 | SyncSendUpdate = 13, 19 | SyncSendDelete = 14, 20 | } 21 | -------------------------------------------------------------------------------- /common/src/enums/organizationApiKeyType.ts: -------------------------------------------------------------------------------- 1 | export enum OrganizationApiKeyType { 2 | Default = 0, 3 | BillingSync = 1, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/organizationConnectionType.ts: -------------------------------------------------------------------------------- 1 | export enum OrganizationConnectionType { 2 | CloudBillingSync = 1, 3 | } 4 | -------------------------------------------------------------------------------- /common/src/enums/organizationUserStatusType.ts: -------------------------------------------------------------------------------- 1 | export enum OrganizationUserStatusType { 2 | Invited = 0, 3 | Accepted = 1, 4 | Confirmed = 2, 5 | } 6 | -------------------------------------------------------------------------------- /common/src/enums/organizationUserType.ts: -------------------------------------------------------------------------------- 1 | export enum OrganizationUserType { 2 | Owner = 0, 3 | Admin = 1, 4 | User = 2, 5 | Manager = 3, 6 | Custom = 4, 7 | } 8 | -------------------------------------------------------------------------------- /common/src/enums/paymentMethodType.ts: -------------------------------------------------------------------------------- 1 | export enum PaymentMethodType { 2 | Card = 0, 3 | BankAccount = 1, 4 | PayPal = 2, 5 | BitPay = 3, 6 | Credit = 4, 7 | WireTransfer = 5, 8 | AppleInApp = 6, 9 | GoogleInApp = 7, 10 | Check = 8, 11 | } 12 | -------------------------------------------------------------------------------- /common/src/enums/planSponsorshipType.ts: -------------------------------------------------------------------------------- 1 | export enum PlanSponsorshipType { 2 | FamiliesForEnterprise = 0, 3 | } 4 | -------------------------------------------------------------------------------- /common/src/enums/planType.ts: -------------------------------------------------------------------------------- 1 | export enum PlanType { 2 | Free = 0, 3 | FamiliesAnnually2019 = 1, 4 | TeamsMonthly2019 = 2, 5 | TeamsAnnually2019 = 3, 6 | EnterpriseMonthly2019 = 4, 7 | EnterpriseAnnually2019 = 5, 8 | Custom = 6, 9 | FamiliesAnnually = 7, 10 | TeamsMonthly = 8, 11 | TeamsAnnually = 9, 12 | EnterpriseMonthly = 10, 13 | EnterpriseAnnually = 11, 14 | } 15 | -------------------------------------------------------------------------------- /common/src/enums/productType.ts: -------------------------------------------------------------------------------- 1 | export enum ProductType { 2 | Free = 0, 3 | Families = 1, 4 | Teams = 2, 5 | Enterprise = 3, 6 | } 7 | -------------------------------------------------------------------------------- /common/src/enums/providerUserStatusType.ts: -------------------------------------------------------------------------------- 1 | export enum ProviderUserStatusType { 2 | Invited = 0, 3 | Accepted = 1, 4 | Confirmed = 2, 5 | } 6 | -------------------------------------------------------------------------------- /common/src/enums/providerUserType.ts: -------------------------------------------------------------------------------- 1 | export enum ProviderUserType { 2 | ProviderAdmin = 0, 3 | ServiceUser = 1, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/secureNoteType.ts: -------------------------------------------------------------------------------- 1 | export enum SecureNoteType { 2 | Generic = 0, 3 | } 4 | -------------------------------------------------------------------------------- /common/src/enums/sendType.ts: -------------------------------------------------------------------------------- 1 | export enum SendType { 2 | Text = 0, 3 | File = 1, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/enums/ssoEnums.ts: -------------------------------------------------------------------------------- 1 | export enum SsoType { 2 | None = 0, 3 | OpenIdConnect = 1, 4 | Saml2 = 2, 5 | } 6 | 7 | export enum OpenIdConnectRedirectBehavior { 8 | RedirectGet = 0, 9 | FormPost = 1, 10 | } 11 | 12 | export enum Saml2BindingType { 13 | HttpRedirect = 1, 14 | HttpPost = 2, 15 | } 16 | 17 | export enum Saml2NameIdFormat { 18 | NotConfigured = 0, 19 | Unspecified = 1, 20 | EmailAddress = 2, 21 | X509SubjectName = 3, 22 | WindowsDomainQualifiedName = 4, 23 | KerberosPrincipalName = 5, 24 | EntityIdentifier = 6, 25 | Persistent = 7, 26 | Transient = 8, 27 | } 28 | 29 | export enum Saml2SigningBehavior { 30 | IfIdpWantAuthnRequestsSigned = 0, 31 | Always = 1, 32 | Never = 3, 33 | } 34 | -------------------------------------------------------------------------------- /common/src/enums/stateVersion.ts: -------------------------------------------------------------------------------- 1 | export enum StateVersion { 2 | One = 1, // Original flat key/value pair store 3 | Two = 2, // Move to a typed State object 4 | Three = 3, // Fix migration of users' premium status 5 | Four = 4, // Fix 'Never Lock' option by removing stale data 6 | Latest = Four, 7 | } 8 | -------------------------------------------------------------------------------- /common/src/enums/storageLocation.ts: -------------------------------------------------------------------------------- 1 | export enum StorageLocation { 2 | Both = "both", 3 | Disk = "disk", 4 | Memory = "memory", 5 | } 6 | -------------------------------------------------------------------------------- /common/src/enums/themeType.ts: -------------------------------------------------------------------------------- 1 | export enum ThemeType { 2 | System = "system", 3 | Light = "light", 4 | Dark = "dark", 5 | Nord = "nord", 6 | SolarizedDark = "solarizedDark", 7 | } 8 | -------------------------------------------------------------------------------- /common/src/enums/transactionType.ts: -------------------------------------------------------------------------------- 1 | export enum TransactionType { 2 | Charge = 0, 3 | Credit = 1, 4 | PromotionalCredit = 2, 5 | ReferralCredit = 3, 6 | Refund = 4, 7 | } 8 | -------------------------------------------------------------------------------- /common/src/enums/twoFactorProviderType.ts: -------------------------------------------------------------------------------- 1 | export enum TwoFactorProviderType { 2 | Authenticator = 0, 3 | Email = 1, 4 | Duo = 2, 5 | Yubikey = 3, 6 | U2f = 4, 7 | Remember = 5, 8 | OrganizationDuo = 6, 9 | WebAuthn = 7, 10 | } 11 | -------------------------------------------------------------------------------- /common/src/enums/uriMatchType.ts: -------------------------------------------------------------------------------- 1 | export enum UriMatchType { 2 | Domain = 0, 3 | Host = 1, 4 | StartsWith = 2, 5 | Exact = 3, 6 | RegularExpression = 4, 7 | Never = 5, 8 | } 9 | -------------------------------------------------------------------------------- /common/src/enums/verificationType.ts: -------------------------------------------------------------------------------- 1 | export enum VerificationType { 2 | MasterPassword = 0, 3 | OTP = 1, 4 | } 5 | -------------------------------------------------------------------------------- /common/src/factories/accountFactory.ts: -------------------------------------------------------------------------------- 1 | import { Account } from "../models/domain/account"; 2 | 3 | export class AccountFactory { 4 | private accountConstructor: new (init: Partial) => T; 5 | 6 | constructor(accountConstructor: new (init: Partial) => T) { 7 | this.accountConstructor = accountConstructor; 8 | } 9 | 10 | create(args: Partial) { 11 | return new this.accountConstructor(args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/factories/globalStateFactory.ts: -------------------------------------------------------------------------------- 1 | import { GlobalState } from "../models/domain/globalState"; 2 | 3 | export class GlobalStateFactory { 4 | private globalStateConstructor: new (init: Partial) => T; 5 | 6 | constructor(globalStateConstructor: new (init: Partial) => T) { 7 | this.globalStateConstructor = globalStateConstructor; 8 | } 9 | 10 | create(args?: Partial) { 11 | return new this.globalStateConstructor(args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/globals.d.ts: -------------------------------------------------------------------------------- 1 | declare function escape(s: string): string; 2 | declare function unescape(s: string): string; 3 | -------------------------------------------------------------------------------- /common/src/importers/importError.ts: -------------------------------------------------------------------------------- 1 | export class ImportError extends Error { 2 | constructor(message?: string, public passwordRequired: boolean = false) { 3 | super(message); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /common/src/importers/importer.ts: -------------------------------------------------------------------------------- 1 | import { ImportResult } from "../models/domain/importResult"; 2 | 3 | export interface Importer { 4 | organizationId: string; 5 | parse(data: string): Promise; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/importers/onepasswordImporters/cipherImportContext.ts: -------------------------------------------------------------------------------- 1 | import { CipherView } from "../../models/view/cipherView"; 2 | 3 | export class CipherImportContext { 4 | lowerProperty: string; 5 | constructor(public importRecord: any, public property: string, public cipher: CipherView) { 6 | this.lowerProperty = property.toLowerCase(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /common/src/misc/tldjs.noop.ts: -------------------------------------------------------------------------------- 1 | export function getDomain(host: string): string | null { 2 | return null; 3 | } 4 | 5 | export function isValid(host: string): boolean { 6 | return true; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/api/billingSyncConfigApi.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "../response/baseResponse"; 2 | 3 | export class BillingSyncConfigApi extends BaseResponse { 4 | billingSyncKey: string; 5 | 6 | constructor(data: any) { 7 | super(data); 8 | if (data == null) { 9 | return; 10 | } 11 | this.billingSyncKey = this.getResponseProperty("BillingSyncKey"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/models/api/cardApi.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "../response/baseResponse"; 2 | 3 | export class CardApi extends BaseResponse { 4 | cardholderName: string; 5 | brand: string; 6 | number: string; 7 | expMonth: string; 8 | expYear: string; 9 | code: string; 10 | 11 | constructor(data: any = null) { 12 | super(data); 13 | if (data == null) { 14 | return; 15 | } 16 | this.cardholderName = this.getResponseProperty("CardholderName"); 17 | this.brand = this.getResponseProperty("Brand"); 18 | this.number = this.getResponseProperty("Number"); 19 | this.expMonth = this.getResponseProperty("ExpMonth"); 20 | this.expYear = this.getResponseProperty("ExpYear"); 21 | this.code = this.getResponseProperty("Code"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/models/api/fieldApi.ts: -------------------------------------------------------------------------------- 1 | import { FieldType } from "../../enums/fieldType"; 2 | import { LinkedIdType } from "../../enums/linkedIdType"; 3 | import { BaseResponse } from "../response/baseResponse"; 4 | 5 | export class FieldApi extends BaseResponse { 6 | name: string; 7 | value: string; 8 | type: FieldType; 9 | linkedId: LinkedIdType; 10 | 11 | constructor(data: any = null) { 12 | super(data); 13 | if (data == null) { 14 | return; 15 | } 16 | this.type = this.getResponseProperty("Type"); 17 | this.name = this.getResponseProperty("Name"); 18 | this.value = this.getResponseProperty("Value"); 19 | this.linkedId = this.getResponseProperty("linkedId"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/models/api/loginUriApi.ts: -------------------------------------------------------------------------------- 1 | import { UriMatchType } from "../../enums/uriMatchType"; 2 | import { BaseResponse } from "../response/baseResponse"; 3 | 4 | export class LoginUriApi extends BaseResponse { 5 | uri: string; 6 | match: UriMatchType = null; 7 | 8 | constructor(data: any = null) { 9 | super(data); 10 | if (data == null) { 11 | return; 12 | } 13 | this.uri = this.getResponseProperty("Uri"); 14 | const match = this.getResponseProperty("Match"); 15 | this.match = match != null ? match : null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/models/api/secureNoteApi.ts: -------------------------------------------------------------------------------- 1 | import { SecureNoteType } from "../../enums/secureNoteType"; 2 | import { BaseResponse } from "../response/baseResponse"; 3 | 4 | export class SecureNoteApi extends BaseResponse { 5 | type: SecureNoteType; 6 | 7 | constructor(data: any = null) { 8 | super(data); 9 | if (data == null) { 10 | return; 11 | } 12 | this.type = this.getResponseProperty("Type"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/api/sendFileApi.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "../response/baseResponse"; 2 | 3 | export class SendFileApi extends BaseResponse { 4 | id: string; 5 | fileName: string; 6 | size: string; 7 | sizeName: string; 8 | 9 | constructor(data: any = null) { 10 | super(data); 11 | if (data == null) { 12 | return; 13 | } 14 | this.id = this.getResponseProperty("Id"); 15 | this.fileName = this.getResponseProperty("FileName"); 16 | this.size = this.getResponseProperty("Size"); 17 | this.sizeName = this.getResponseProperty("SizeName"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/models/api/sendTextApi.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "../response/baseResponse"; 2 | 3 | export class SendTextApi extends BaseResponse { 4 | text: string; 5 | hidden: boolean; 6 | 7 | constructor(data: any = null) { 8 | super(data); 9 | if (data == null) { 10 | return; 11 | } 12 | this.text = this.getResponseProperty("Text"); 13 | this.hidden = this.getResponseProperty("Hidden") || false; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/models/data/attachmentData.ts: -------------------------------------------------------------------------------- 1 | import { AttachmentResponse } from "../response/attachmentResponse"; 2 | 3 | export class AttachmentData { 4 | id: string; 5 | url: string; 6 | fileName: string; 7 | key: string; 8 | size: string; 9 | sizeName: string; 10 | 11 | constructor(response?: AttachmentResponse) { 12 | if (response == null) { 13 | return; 14 | } 15 | this.id = response.id; 16 | this.url = response.url; 17 | this.fileName = response.fileName; 18 | this.key = response.key; 19 | this.size = response.size; 20 | this.sizeName = response.sizeName; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/models/data/cardData.ts: -------------------------------------------------------------------------------- 1 | import { CardApi } from "../api/cardApi"; 2 | 3 | export class CardData { 4 | cardholderName: string; 5 | brand: string; 6 | number: string; 7 | expMonth: string; 8 | expYear: string; 9 | code: string; 10 | 11 | constructor(data?: CardApi) { 12 | if (data == null) { 13 | return; 14 | } 15 | 16 | this.cardholderName = data.cardholderName; 17 | this.brand = data.brand; 18 | this.number = data.number; 19 | this.expMonth = data.expMonth; 20 | this.expYear = data.expYear; 21 | this.code = data.code; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/models/data/collectionData.ts: -------------------------------------------------------------------------------- 1 | import { CollectionDetailsResponse } from "../response/collectionResponse"; 2 | 3 | export class CollectionData { 4 | id: string; 5 | organizationId: string; 6 | name: string; 7 | externalId: string; 8 | readOnly: boolean; 9 | 10 | constructor(response: CollectionDetailsResponse) { 11 | this.id = response.id; 12 | this.organizationId = response.organizationId; 13 | this.name = response.name; 14 | this.externalId = response.externalId; 15 | this.readOnly = response.readOnly; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/models/data/eventData.ts: -------------------------------------------------------------------------------- 1 | import { EventType } from "../../enums/eventType"; 2 | 3 | export class EventData { 4 | type: EventType; 5 | cipherId: string; 6 | date: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/data/fieldData.ts: -------------------------------------------------------------------------------- 1 | import { FieldType } from "../../enums/fieldType"; 2 | import { LinkedIdType } from "../../enums/linkedIdType"; 3 | import { FieldApi } from "../api/fieldApi"; 4 | 5 | export class FieldData { 6 | type: FieldType; 7 | name: string; 8 | value: string; 9 | linkedId: LinkedIdType; 10 | 11 | constructor(response?: FieldApi) { 12 | if (response == null) { 13 | return; 14 | } 15 | this.type = response.type; 16 | this.name = response.name; 17 | this.value = response.value; 18 | this.linkedId = response.linkedId; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/models/data/folderData.ts: -------------------------------------------------------------------------------- 1 | import { FolderResponse } from "../response/folderResponse"; 2 | 3 | export class FolderData { 4 | id: string; 5 | name: string; 6 | revisionDate: string; 7 | 8 | constructor(response: FolderResponse) { 9 | this.name = response.name; 10 | this.id = response.id; 11 | this.revisionDate = response.revisionDate; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/models/data/loginData.ts: -------------------------------------------------------------------------------- 1 | import { LoginApi } from "../api/loginApi"; 2 | 3 | import { LoginUriData } from "./loginUriData"; 4 | 5 | export class LoginData { 6 | uris: LoginUriData[]; 7 | username: string; 8 | password: string; 9 | passwordRevisionDate: string; 10 | totp: string; 11 | autofillOnPageLoad: boolean; 12 | 13 | constructor(data?: LoginApi) { 14 | if (data == null) { 15 | return; 16 | } 17 | 18 | this.username = data.username; 19 | this.password = data.password; 20 | this.passwordRevisionDate = data.passwordRevisionDate; 21 | this.totp = data.totp; 22 | this.autofillOnPageLoad = data.autofillOnPageLoad; 23 | 24 | if (data.uris) { 25 | this.uris = data.uris.map((u) => new LoginUriData(u)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/models/data/loginUriData.ts: -------------------------------------------------------------------------------- 1 | import { UriMatchType } from "../../enums/uriMatchType"; 2 | import { LoginUriApi } from "../api/loginUriApi"; 3 | 4 | export class LoginUriData { 5 | uri: string; 6 | match: UriMatchType = null; 7 | 8 | constructor(data?: LoginUriApi) { 9 | if (data == null) { 10 | return; 11 | } 12 | this.uri = data.uri; 13 | this.match = data.match; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/models/data/passwordHistoryData.ts: -------------------------------------------------------------------------------- 1 | import { PasswordHistoryResponse } from "../response/passwordHistoryResponse"; 2 | 3 | export class PasswordHistoryData { 4 | password: string; 5 | lastUsedDate: string; 6 | 7 | constructor(response?: PasswordHistoryResponse) { 8 | if (response == null) { 9 | return; 10 | } 11 | 12 | this.password = response.password; 13 | this.lastUsedDate = response.lastUsedDate; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/models/data/policyData.ts: -------------------------------------------------------------------------------- 1 | import { PolicyType } from "../../enums/policyType"; 2 | import { PolicyResponse } from "../response/policyResponse"; 3 | 4 | export class PolicyData { 5 | id: string; 6 | organizationId: string; 7 | type: PolicyType; 8 | data: any; 9 | enabled: boolean; 10 | 11 | constructor(response: PolicyResponse) { 12 | this.id = response.id; 13 | this.organizationId = response.organizationId; 14 | this.type = response.type; 15 | this.data = response.data; 16 | this.enabled = response.enabled; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/models/data/providerData.ts: -------------------------------------------------------------------------------- 1 | import { ProviderUserStatusType } from "../../enums/providerUserStatusType"; 2 | import { ProviderUserType } from "../../enums/providerUserType"; 3 | import { ProfileProviderResponse } from "../response/profileProviderResponse"; 4 | 5 | export class ProviderData { 6 | id: string; 7 | name: string; 8 | status: ProviderUserStatusType; 9 | type: ProviderUserType; 10 | enabled: boolean; 11 | userId: string; 12 | useEvents: boolean; 13 | 14 | constructor(response: ProfileProviderResponse) { 15 | this.id = response.id; 16 | this.name = response.name; 17 | this.status = response.status; 18 | this.type = response.type; 19 | this.enabled = response.enabled; 20 | this.userId = response.userId; 21 | this.useEvents = response.useEvents; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/models/data/secureNoteData.ts: -------------------------------------------------------------------------------- 1 | import { SecureNoteType } from "../../enums/secureNoteType"; 2 | import { SecureNoteApi } from "../api/secureNoteApi"; 3 | 4 | export class SecureNoteData { 5 | type: SecureNoteType; 6 | 7 | constructor(data?: SecureNoteApi) { 8 | if (data == null) { 9 | return; 10 | } 11 | 12 | this.type = data.type; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/data/sendFileData.ts: -------------------------------------------------------------------------------- 1 | import { SendFileApi } from "../api/sendFileApi"; 2 | 3 | export class SendFileData { 4 | id: string; 5 | fileName: string; 6 | size: string; 7 | sizeName: string; 8 | 9 | constructor(data?: SendFileApi) { 10 | if (data == null) { 11 | return; 12 | } 13 | 14 | this.id = data.id; 15 | this.fileName = data.fileName; 16 | this.size = data.size; 17 | this.sizeName = data.sizeName; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/models/data/sendTextData.ts: -------------------------------------------------------------------------------- 1 | import { SendTextApi } from "../api/sendTextApi"; 2 | 3 | export class SendTextData { 4 | text: string; 5 | hidden: boolean; 6 | 7 | constructor(data?: SendTextApi) { 8 | if (data == null) { 9 | return; 10 | } 11 | 12 | this.text = data.text; 13 | this.hidden = data.hidden; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/models/domain/authResult.ts: -------------------------------------------------------------------------------- 1 | import { TwoFactorProviderType } from "../../enums/twoFactorProviderType"; 2 | import { Utils } from "../../misc/utils"; 3 | 4 | export class AuthResult { 5 | captchaSiteKey = ""; 6 | resetMasterPassword = false; 7 | forcePasswordReset = false; 8 | twoFactorProviders: Map = null; 9 | 10 | get requiresCaptcha() { 11 | return !Utils.isNullOrWhitespace(this.captchaSiteKey); 12 | } 13 | 14 | get requiresTwoFactor() { 15 | return this.twoFactorProviders != null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/models/domain/decryptParameters.ts: -------------------------------------------------------------------------------- 1 | export class DecryptParameters { 2 | encKey: T; 3 | data: T; 4 | iv: T; 5 | macKey: T; 6 | mac: T; 7 | macData: T; 8 | } 9 | -------------------------------------------------------------------------------- /common/src/models/domain/encArrayBuffer.ts: -------------------------------------------------------------------------------- 1 | export class EncArrayBuffer { 2 | constructor(public buffer: ArrayBuffer) {} 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/domain/encryptedObject.ts: -------------------------------------------------------------------------------- 1 | import { SymmetricCryptoKey } from "./symmetricCryptoKey"; 2 | 3 | export class EncryptedObject { 4 | iv: ArrayBuffer; 5 | data: ArrayBuffer; 6 | mac: ArrayBuffer; 7 | key: SymmetricCryptoKey; 8 | } 9 | -------------------------------------------------------------------------------- /common/src/models/domain/environmentUrls.ts: -------------------------------------------------------------------------------- 1 | export class EnvironmentUrls { 2 | base: string = null; 3 | api: string = null; 4 | identity: string = null; 5 | icons: string = null; 6 | notifications: string = null; 7 | events: string = null; 8 | webVault: string = null; 9 | keyConnector: string = null; 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/domain/folder.ts: -------------------------------------------------------------------------------- 1 | import { FolderData } from "../data/folderData"; 2 | import { FolderView } from "../view/folderView"; 3 | 4 | import Domain from "./domainBase"; 5 | import { EncString } from "./encString"; 6 | 7 | export class Folder extends Domain { 8 | id: string; 9 | name: EncString; 10 | revisionDate: Date; 11 | 12 | constructor(obj?: FolderData) { 13 | super(); 14 | if (obj == null) { 15 | return; 16 | } 17 | 18 | this.buildDomainModel( 19 | this, 20 | obj, 21 | { 22 | id: null, 23 | name: null, 24 | }, 25 | ["id"] 26 | ); 27 | 28 | this.revisionDate = obj.revisionDate != null ? new Date(obj.revisionDate) : null; 29 | } 30 | 31 | decrypt(): Promise { 32 | return this.decryptObj( 33 | new FolderView(this), 34 | { 35 | name: null, 36 | }, 37 | null 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /common/src/models/domain/generatedPasswordHistory.ts: -------------------------------------------------------------------------------- 1 | export class GeneratedPasswordHistory { 2 | password: string; 3 | date: number; 4 | 5 | constructor(password: string, date: number) { 6 | this.password = password; 7 | this.date = date; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/domain/importResult.ts: -------------------------------------------------------------------------------- 1 | import { CipherView } from "../view/cipherView"; 2 | import { CollectionView } from "../view/collectionView"; 3 | import { FolderView } from "../view/folderView"; 4 | 5 | export class ImportResult { 6 | success = false; 7 | missingPassword = false; 8 | errorMessage: string; 9 | ciphers: CipherView[] = []; 10 | folders: FolderView[] = []; 11 | folderRelationships: [number, number][] = []; 12 | collections: CollectionView[] = []; 13 | collectionRelationships: [number, number][] = []; 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/domain/masterPasswordPolicyOptions.ts: -------------------------------------------------------------------------------- 1 | import Domain from "./domainBase"; 2 | 3 | export class MasterPasswordPolicyOptions extends Domain { 4 | minComplexity = 0; 5 | minLength = 0; 6 | requireUpper = false; 7 | requireLower = false; 8 | requireNumbers = false; 9 | requireSpecial = false; 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/domain/passwordGeneratorPolicyOptions.ts: -------------------------------------------------------------------------------- 1 | import Domain from "./domainBase"; 2 | 3 | export class PasswordGeneratorPolicyOptions extends Domain { 4 | defaultType = ""; 5 | minLength = 0; 6 | useUppercase = false; 7 | useLowercase = false; 8 | useNumbers = false; 9 | numberCount = 0; 10 | useSpecial = false; 11 | specialCount = 0; 12 | minNumberWords = 0; 13 | capitalize = false; 14 | includeNumber = false; 15 | 16 | inEffect() { 17 | return ( 18 | this.defaultType !== "" || 19 | this.minLength > 0 || 20 | this.numberCount > 0 || 21 | this.specialCount > 0 || 22 | this.useUppercase || 23 | this.useLowercase || 24 | this.useNumbers || 25 | this.useSpecial || 26 | this.minNumberWords > 0 || 27 | this.capitalize || 28 | this.includeNumber 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/models/domain/policy.ts: -------------------------------------------------------------------------------- 1 | import { PolicyType } from "../../enums/policyType"; 2 | import { PolicyData } from "../data/policyData"; 3 | 4 | import Domain from "./domainBase"; 5 | 6 | export class Policy extends Domain { 7 | id: string; 8 | organizationId: string; 9 | type: PolicyType; 10 | data: any; 11 | enabled: boolean; 12 | 13 | constructor(obj?: PolicyData) { 14 | super(); 15 | if (obj == null) { 16 | return; 17 | } 18 | 19 | this.id = obj.id; 20 | this.organizationId = obj.organizationId; 21 | this.type = obj.type; 22 | this.data = obj.data; 23 | this.enabled = obj.enabled; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/models/domain/resetPasswordPolicyOptions.ts: -------------------------------------------------------------------------------- 1 | import Domain from "./domainBase"; 2 | 3 | export class ResetPasswordPolicyOptions extends Domain { 4 | autoEnrollEnabled = false; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/domain/secureNote.ts: -------------------------------------------------------------------------------- 1 | import { SecureNoteType } from "../../enums/secureNoteType"; 2 | import { SecureNoteData } from "../data/secureNoteData"; 3 | import { SecureNoteView } from "../view/secureNoteView"; 4 | 5 | import Domain from "./domainBase"; 6 | import { SymmetricCryptoKey } from "./symmetricCryptoKey"; 7 | 8 | export class SecureNote extends Domain { 9 | type: SecureNoteType; 10 | 11 | constructor(obj?: SecureNoteData) { 12 | super(); 13 | if (obj == null) { 14 | return; 15 | } 16 | 17 | this.type = obj.type; 18 | } 19 | 20 | decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise { 21 | return Promise.resolve(new SecureNoteView(this)); 22 | } 23 | 24 | toSecureNoteData(): SecureNoteData { 25 | const n = new SecureNoteData(); 26 | n.type = this.type; 27 | return n; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /common/src/models/domain/sendText.ts: -------------------------------------------------------------------------------- 1 | import { SendTextData } from "../data/sendTextData"; 2 | import { SendTextView } from "../view/sendTextView"; 3 | 4 | import Domain from "./domainBase"; 5 | import { EncString } from "./encString"; 6 | import { SymmetricCryptoKey } from "./symmetricCryptoKey"; 7 | 8 | export class SendText extends Domain { 9 | text: EncString; 10 | hidden: boolean; 11 | 12 | constructor(obj?: SendTextData) { 13 | super(); 14 | if (obj == null) { 15 | return; 16 | } 17 | 18 | this.hidden = obj.hidden; 19 | this.buildDomainModel( 20 | this, 21 | obj, 22 | { 23 | text: null, 24 | }, 25 | [] 26 | ); 27 | } 28 | 29 | decrypt(key: SymmetricCryptoKey): Promise { 30 | return this.decryptObj( 31 | new SendTextView(this), 32 | { 33 | text: null, 34 | }, 35 | null, 36 | key 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /common/src/models/domain/state.ts: -------------------------------------------------------------------------------- 1 | import { Account } from "./account"; 2 | import { GlobalState } from "./globalState"; 3 | 4 | export class State< 5 | TGlobalState extends GlobalState = GlobalState, 6 | TAccount extends Account = Account 7 | > { 8 | accounts: { [userId: string]: TAccount } = {}; 9 | globals: TGlobalState; 10 | activeUserId: string; 11 | authenticatedAccounts: string[] = []; 12 | accountActivity: { [userId: string]: number } = {}; 13 | 14 | constructor(globals: TGlobalState) { 15 | this.globals = globals; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/models/domain/storageOptions.ts: -------------------------------------------------------------------------------- 1 | import { HtmlStorageLocation } from "../../enums/htmlStorageLocation"; 2 | import { StorageLocation } from "../../enums/storageLocation"; 3 | 4 | export type StorageOptions = { 5 | storageLocation?: StorageLocation; 6 | useSecureStorage?: boolean; 7 | userId?: string; 8 | htmlStorageLocation?: HtmlStorageLocation; 9 | keySuffix?: string; 10 | }; 11 | -------------------------------------------------------------------------------- /common/src/models/domain/treeNode.ts: -------------------------------------------------------------------------------- 1 | export class TreeNode { 2 | parent: T; 3 | node: T; 4 | children: TreeNode[] = []; 5 | 6 | constructor(node: T, name: string, parent: T) { 7 | this.parent = parent; 8 | this.node = node; 9 | this.node.name = name; 10 | } 11 | } 12 | 13 | export interface ITreeNodeObject { 14 | id: string; 15 | name: string; 16 | } 17 | -------------------------------------------------------------------------------- /common/src/models/domain/windowState.ts: -------------------------------------------------------------------------------- 1 | export class WindowState { 2 | width?: number; 3 | height?: number; 4 | isMaximized?: boolean; 5 | // TODO: displayBounds is an Electron.Rectangle. 6 | // We need to establish some kind of client-specific global state, similiar to the way we already extend a base Account. 7 | displayBounds: any; 8 | x?: number; 9 | y?: number; 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/export/cipherWithIdsExport.ts: -------------------------------------------------------------------------------- 1 | import { Cipher as CipherDomain } from "../domain/cipher"; 2 | import { CipherView } from "../view/cipherView"; 3 | 4 | import { CipherExport } from "./cipherExport"; 5 | 6 | export class CipherWithIdExport extends CipherExport { 7 | id: string; 8 | collectionIds: string[]; 9 | 10 | // Use build method instead of ctor so that we can control order of JSON stringify for pretty print 11 | build(o: CipherView | CipherDomain) { 12 | this.id = o.id; 13 | super.build(o); 14 | this.collectionIds = o.collectionIds; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/models/export/collectionWithIdExport.ts: -------------------------------------------------------------------------------- 1 | import { Collection as CollectionDomain } from "../domain/collection"; 2 | import { CollectionView } from "../view/collectionView"; 3 | 4 | import { CollectionExport } from "./collectionExport"; 5 | 6 | export class CollectionWithIdExport extends CollectionExport { 7 | id: string; 8 | 9 | // Use build method instead of ctor so that we can control order of JSON stringify for pretty print 10 | build(o: CollectionView | CollectionDomain) { 11 | this.id = o.id; 12 | super.build(o); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/export/eventExport.ts: -------------------------------------------------------------------------------- 1 | import { EventType } from "../../enums/eventType"; 2 | import { EventView } from "../view/eventView"; 3 | 4 | export class EventExport { 5 | message: string; 6 | appIcon: string; 7 | appName: string; 8 | userId: string; 9 | userName: string; 10 | userEmail: string; 11 | date: string; 12 | ip: string; 13 | type: string; 14 | installationId: string; 15 | 16 | constructor(event: EventView) { 17 | this.message = event.humanReadableMessage; 18 | this.appIcon = event.appIcon; 19 | this.appName = event.appName; 20 | this.userId = event.userId; 21 | this.userName = event.userName; 22 | this.userEmail = event.userEmail; 23 | this.date = event.date; 24 | this.ip = event.ip; 25 | this.type = EventType[event.type]; 26 | this.installationId = event.installationId; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/models/export/folderWithIdExport.ts: -------------------------------------------------------------------------------- 1 | import { Folder as FolderDomain } from "../domain/folder"; 2 | import { FolderView } from "../view/folderView"; 3 | 4 | import { FolderExport } from "./folderExport"; 5 | 6 | export class FolderWithIdExport extends FolderExport { 7 | id: string; 8 | 9 | // Use build method instead of ctor so that we can control order of JSON stringify for pretty print 10 | build(o: FolderView | FolderDomain) { 11 | this.id = o.id; 12 | super.build(o); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/export/secureNoteExport.ts: -------------------------------------------------------------------------------- 1 | import { SecureNoteType } from "../../enums/secureNoteType"; 2 | import { SecureNote as SecureNoteDomain } from "../domain/secureNote"; 3 | import { SecureNoteView } from "../view/secureNoteView"; 4 | 5 | export class SecureNoteExport { 6 | static template(): SecureNoteExport { 7 | const req = new SecureNoteExport(); 8 | req.type = SecureNoteType.Generic; 9 | return req; 10 | } 11 | 12 | static toView(req: SecureNoteExport, view = new SecureNoteView()) { 13 | view.type = req.type; 14 | return view; 15 | } 16 | 17 | static toDomain(req: SecureNoteExport, view = new SecureNoteDomain()) { 18 | view.type = req.type; 19 | return view; 20 | } 21 | 22 | type: SecureNoteType; 23 | 24 | constructor(o?: SecureNoteView | SecureNoteDomain) { 25 | if (o == null) { 26 | return; 27 | } 28 | 29 | this.type = o.type; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/models/request/account/setKeyConnectorKeyRequest.ts: -------------------------------------------------------------------------------- 1 | import { KdfType } from "../../../enums/kdfType"; 2 | import { KeysRequest } from "../keysRequest"; 3 | 4 | export class SetKeyConnectorKeyRequest { 5 | key: string; 6 | keys: KeysRequest; 7 | kdf: KdfType; 8 | kdfIterations: number; 9 | orgIdentifier: string; 10 | 11 | constructor( 12 | key: string, 13 | kdf: KdfType, 14 | kdfIterations: number, 15 | orgIdentifier: string, 16 | keys: KeysRequest 17 | ) { 18 | this.key = key; 19 | this.kdf = kdf; 20 | this.kdfIterations = kdfIterations; 21 | this.orgIdentifier = orgIdentifier; 22 | this.keys = keys; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/models/request/account/verifyOTPRequest.ts: -------------------------------------------------------------------------------- 1 | export class VerifyOTPRequest { 2 | OTP: string; 3 | 4 | constructor(OTP: string) { 5 | this.OTP = OTP; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/attachmentRequest.ts: -------------------------------------------------------------------------------- 1 | export class AttachmentRequest { 2 | fileName: string; 3 | key: string; 4 | fileSize: number; 5 | adminRequest: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/billingSyncConfigRequest.ts: -------------------------------------------------------------------------------- 1 | export class BillingSyncConfigRequest { 2 | constructor(private billingSyncKey: string) {} 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/bitPayInvoiceRequest.ts: -------------------------------------------------------------------------------- 1 | export class BitPayInvoiceRequest { 2 | userId: string; 3 | organizationId: string; 4 | credit: boolean; 5 | amount: number; 6 | returnUrl: string; 7 | name: string; 8 | email: string; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/captchaProtectedRequest.ts: -------------------------------------------------------------------------------- 1 | export abstract class CaptchaProtectedRequest { 2 | captchaResponse: string = null; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/cipherBulkDeleteRequest.ts: -------------------------------------------------------------------------------- 1 | export class CipherBulkDeleteRequest { 2 | ids: string[]; 3 | organizationId: string; 4 | 5 | constructor(ids: string[], organizationId?: string) { 6 | this.ids = ids == null ? [] : ids; 7 | this.organizationId = organizationId; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/cipherBulkMoveRequest.ts: -------------------------------------------------------------------------------- 1 | export class CipherBulkMoveRequest { 2 | ids: string[]; 3 | folderId: string; 4 | 5 | constructor(ids: string[], folderId: string) { 6 | this.ids = ids == null ? [] : ids; 7 | this.folderId = folderId; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/cipherBulkRestoreRequest.ts: -------------------------------------------------------------------------------- 1 | export class CipherBulkRestoreRequest { 2 | ids: string[]; 3 | 4 | constructor(ids: string[]) { 5 | this.ids = ids == null ? [] : ids; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/cipherBulkShareRequest.ts: -------------------------------------------------------------------------------- 1 | import { Cipher } from "../domain/cipher"; 2 | 3 | import { CipherWithIdRequest } from "./cipherWithIdRequest"; 4 | 5 | export class CipherBulkShareRequest { 6 | ciphers: CipherWithIdRequest[]; 7 | collectionIds: string[]; 8 | 9 | constructor(ciphers: Cipher[], collectionIds: string[]) { 10 | if (ciphers != null) { 11 | this.ciphers = []; 12 | ciphers.forEach((c) => { 13 | this.ciphers.push(new CipherWithIdRequest(c)); 14 | }); 15 | } 16 | this.collectionIds = collectionIds; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/models/request/cipherCollectionsRequest.ts: -------------------------------------------------------------------------------- 1 | export class CipherCollectionsRequest { 2 | collectionIds: string[]; 3 | 4 | constructor(collectionIds: string[]) { 5 | this.collectionIds = collectionIds == null ? [] : collectionIds; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/cipherCreateRequest.ts: -------------------------------------------------------------------------------- 1 | import { Cipher } from "../domain/cipher"; 2 | 3 | import { CipherRequest } from "./cipherRequest"; 4 | 5 | export class CipherCreateRequest { 6 | cipher: CipherRequest; 7 | collectionIds: string[]; 8 | 9 | constructor(cipher: Cipher) { 10 | this.cipher = new CipherRequest(cipher); 11 | this.collectionIds = cipher.collectionIds; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/models/request/cipherShareRequest.ts: -------------------------------------------------------------------------------- 1 | import { Cipher } from "../domain/cipher"; 2 | 3 | import { CipherRequest } from "./cipherRequest"; 4 | 5 | export class CipherShareRequest { 6 | cipher: CipherRequest; 7 | collectionIds: string[]; 8 | 9 | constructor(cipher: Cipher) { 10 | this.cipher = new CipherRequest(cipher); 11 | this.collectionIds = cipher.collectionIds; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/models/request/cipherWithIdRequest.ts: -------------------------------------------------------------------------------- 1 | import { Cipher } from "../domain/cipher"; 2 | 3 | import { CipherRequest } from "./cipherRequest"; 4 | 5 | export class CipherWithIdRequest extends CipherRequest { 6 | id: string; 7 | 8 | constructor(cipher: Cipher) { 9 | super(cipher); 10 | this.id = cipher.id; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/request/collectionRequest.ts: -------------------------------------------------------------------------------- 1 | import { Collection } from "../domain/collection"; 2 | 3 | import { SelectionReadOnlyRequest } from "./selectionReadOnlyRequest"; 4 | 5 | export class CollectionRequest { 6 | name: string; 7 | externalId: string; 8 | groups: SelectionReadOnlyRequest[] = []; 9 | 10 | constructor(collection?: Collection) { 11 | if (collection == null) { 12 | return; 13 | } 14 | this.name = collection.name ? collection.name.encryptedString : null; 15 | this.externalId = collection.externalId; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/models/request/deleteRecoverRequest.ts: -------------------------------------------------------------------------------- 1 | export class DeleteRecoverRequest { 2 | email: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/deviceRequest.ts: -------------------------------------------------------------------------------- 1 | import { PlatformUtilsService } from "../../abstractions/platformUtils.service"; 2 | import { DeviceType } from "../../enums/deviceType"; 3 | 4 | export class DeviceRequest { 5 | type: DeviceType; 6 | name: string; 7 | identifier: string; 8 | pushToken?: string; 9 | 10 | constructor(appId: string, platformUtilsService: PlatformUtilsService) { 11 | this.type = platformUtilsService.getDevice(); 12 | this.name = platformUtilsService.getDeviceString(); 13 | this.identifier = appId; 14 | this.pushToken = null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/models/request/deviceTokenRequest.ts: -------------------------------------------------------------------------------- 1 | export class DeviceTokenRequest { 2 | pushToken: string; 3 | 4 | constructor() { 5 | this.pushToken = null; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/emailRequest.ts: -------------------------------------------------------------------------------- 1 | import { EmailTokenRequest } from "./emailTokenRequest"; 2 | 3 | export class EmailRequest extends EmailTokenRequest { 4 | newMasterPasswordHash: string; 5 | token: string; 6 | key: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/emailTokenRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class EmailTokenRequest extends SecretVerificationRequest { 4 | newEmail: string; 5 | masterPasswordHash: string; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/emergencyAccessAcceptRequest.ts: -------------------------------------------------------------------------------- 1 | export class EmergencyAccessAcceptRequest { 2 | token: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/emergencyAccessConfirmRequest.ts: -------------------------------------------------------------------------------- 1 | export class EmergencyAccessConfirmRequest { 2 | key: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/emergencyAccessInviteRequest.ts: -------------------------------------------------------------------------------- 1 | import { EmergencyAccessType } from "../../enums/emergencyAccessType"; 2 | 3 | export class EmergencyAccessInviteRequest { 4 | email: string; 5 | type: EmergencyAccessType; 6 | waitTimeDays: number; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/emergencyAccessPasswordRequest.ts: -------------------------------------------------------------------------------- 1 | export class EmergencyAccessPasswordRequest { 2 | newMasterPasswordHash: string; 3 | key: string; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/emergencyAccessUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | import { EmergencyAccessType } from "../../enums/emergencyAccessType"; 2 | 3 | export class EmergencyAccessUpdateRequest { 4 | type: EmergencyAccessType; 5 | waitTimeDays: number; 6 | keyEncrypted?: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/eventRequest.ts: -------------------------------------------------------------------------------- 1 | import { EventType } from "../../enums/eventType"; 2 | 3 | export class EventRequest { 4 | type: EventType; 5 | cipherId: string; 6 | date: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/folderRequest.ts: -------------------------------------------------------------------------------- 1 | import { Folder } from "../domain/folder"; 2 | 3 | export class FolderRequest { 4 | name: string; 5 | 6 | constructor(folder: Folder) { 7 | this.name = folder.name ? folder.name.encryptedString : null; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/folderWithIdRequest.ts: -------------------------------------------------------------------------------- 1 | import { Folder } from "../domain/folder"; 2 | 3 | import { FolderRequest } from "./folderRequest"; 4 | 5 | export class FolderWithIdRequest extends FolderRequest { 6 | id: string; 7 | 8 | constructor(folder: Folder) { 9 | super(folder); 10 | this.id = folder.id; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/request/groupRequest.ts: -------------------------------------------------------------------------------- 1 | import { SelectionReadOnlyRequest } from "./selectionReadOnlyRequest"; 2 | 3 | export class GroupRequest { 4 | name: string; 5 | accessAll: boolean; 6 | externalId: string; 7 | collections: SelectionReadOnlyRequest[] = []; 8 | } 9 | -------------------------------------------------------------------------------- /common/src/models/request/iapCheckRequest.ts: -------------------------------------------------------------------------------- 1 | import { PaymentMethodType } from "../../enums/paymentMethodType"; 2 | 3 | export class IapCheckRequest { 4 | paymentMethodType: PaymentMethodType; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/identityToken/apiTokenRequest.ts: -------------------------------------------------------------------------------- 1 | import { DeviceRequest } from "../deviceRequest"; 2 | 3 | import { TokenRequest } from "./tokenRequest"; 4 | import { TokenRequestTwoFactor } from "./tokenRequestTwoFactor"; 5 | 6 | export class ApiTokenRequest extends TokenRequest { 7 | constructor( 8 | public clientId: string, 9 | public clientSecret: string, 10 | protected twoFactor: TokenRequestTwoFactor, 11 | device?: DeviceRequest 12 | ) { 13 | super(twoFactor, device); 14 | } 15 | 16 | toIdentityToken() { 17 | const obj = super.toIdentityToken(this.clientId); 18 | 19 | obj.scope = this.clientId.startsWith("organization") ? "api.organization" : "api"; 20 | obj.grant_type = "client_credentials"; 21 | obj.client_secret = this.clientSecret; 22 | 23 | return obj; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/models/request/identityToken/ssoTokenRequest.ts: -------------------------------------------------------------------------------- 1 | import { DeviceRequest } from "../deviceRequest"; 2 | 3 | import { TokenRequest } from "./tokenRequest"; 4 | import { TokenRequestTwoFactor } from "./tokenRequestTwoFactor"; 5 | 6 | export class SsoTokenRequest extends TokenRequest { 7 | constructor( 8 | public code: string, 9 | public codeVerifier: string, 10 | public redirectUri: string, 11 | protected twoFactor: TokenRequestTwoFactor, 12 | device?: DeviceRequest 13 | ) { 14 | super(twoFactor, device); 15 | } 16 | 17 | toIdentityToken(clientId: string) { 18 | const obj = super.toIdentityToken(clientId); 19 | 20 | obj.grant_type = "authorization_code"; 21 | obj.code = this.code; 22 | obj.code_verifier = this.codeVerifier; 23 | obj.redirect_uri = this.redirectUri; 24 | 25 | return obj; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/models/request/identityToken/tokenRequestTwoFactor.ts: -------------------------------------------------------------------------------- 1 | import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType"; 2 | 3 | export class TokenRequestTwoFactor { 4 | constructor( 5 | public provider: TwoFactorProviderType = null, 6 | public token: string = null, 7 | public remember: boolean = false 8 | ) {} 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/importCiphersRequest.ts: -------------------------------------------------------------------------------- 1 | import { CipherRequest } from "./cipherRequest"; 2 | import { FolderRequest } from "./folderRequest"; 3 | import { KvpRequest } from "./kvpRequest"; 4 | 5 | export class ImportCiphersRequest { 6 | ciphers: CipherRequest[] = []; 7 | folders: FolderRequest[] = []; 8 | folderRelationships: KvpRequest[] = []; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/importDirectoryRequest.ts: -------------------------------------------------------------------------------- 1 | import { ImportDirectoryRequestGroup } from "./importDirectoryRequestGroup"; 2 | import { ImportDirectoryRequestUser } from "./importDirectoryRequestUser"; 3 | 4 | export class ImportDirectoryRequest { 5 | groups: ImportDirectoryRequestGroup[] = []; 6 | users: ImportDirectoryRequestUser[] = []; 7 | overwriteExisting = false; 8 | largeImport = false; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/importDirectoryRequestGroup.ts: -------------------------------------------------------------------------------- 1 | export class ImportDirectoryRequestGroup { 2 | name: string; 3 | externalId: string; 4 | users: string[]; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/importDirectoryRequestUser.ts: -------------------------------------------------------------------------------- 1 | export class ImportDirectoryRequestUser { 2 | externalId: string; 3 | email: string; 4 | deleted: boolean; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/importOrganizationCiphersRequest.ts: -------------------------------------------------------------------------------- 1 | import { CipherRequest } from "./cipherRequest"; 2 | import { CollectionRequest } from "./collectionRequest"; 3 | import { KvpRequest } from "./kvpRequest"; 4 | 5 | export class ImportOrganizationCiphersRequest { 6 | ciphers: CipherRequest[] = []; 7 | collections: CollectionRequest[] = []; 8 | collectionRelationships: KvpRequest[] = []; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/kdfRequest.ts: -------------------------------------------------------------------------------- 1 | import { KdfType } from "../../enums/kdfType"; 2 | 3 | import { PasswordRequest } from "./passwordRequest"; 4 | 5 | export class KdfRequest extends PasswordRequest { 6 | kdf: KdfType; 7 | kdfIterations: number; 8 | } 9 | -------------------------------------------------------------------------------- /common/src/models/request/keyConnectorUserKeyRequest.ts: -------------------------------------------------------------------------------- 1 | export class KeyConnectorUserKeyRequest { 2 | key: string; 3 | 4 | constructor(key: string) { 5 | this.key = key; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/keysRequest.ts: -------------------------------------------------------------------------------- 1 | export class KeysRequest { 2 | publicKey: string; 3 | encryptedPrivateKey: string; 4 | 5 | constructor(publicKey: string, encryptedPrivateKey: string) { 6 | this.publicKey = publicKey; 7 | this.encryptedPrivateKey = encryptedPrivateKey; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/kvpRequest.ts: -------------------------------------------------------------------------------- 1 | export class KvpRequest { 2 | key: TK; 3 | value: TV; 4 | 5 | constructor(key: TK, value: TV) { 6 | this.key = key; 7 | this.value = value; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/organization/organizationSponsorshipCreateRequest.ts: -------------------------------------------------------------------------------- 1 | import { PlanSponsorshipType } from "../../../enums/planSponsorshipType"; 2 | 3 | export class OrganizationSponsorshipCreateRequest { 4 | sponsoredEmail: string; 5 | planSponsorshipType: PlanSponsorshipType; 6 | friendlyName: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/organization/organizationSponsorshipRedeemRequest.ts: -------------------------------------------------------------------------------- 1 | import { PlanSponsorshipType } from "../../../enums/planSponsorshipType"; 2 | 3 | export class OrganizationSponsorshipRedeemRequest { 4 | planSponsorshipType: PlanSponsorshipType; 5 | sponsoredOrganizationId: string; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/organization/organizationSsoRequest.ts: -------------------------------------------------------------------------------- 1 | import { SsoConfigApi } from "../../api/ssoConfigApi"; 2 | 3 | export class OrganizationSsoRequest { 4 | enabled = false; 5 | data: SsoConfigApi; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/organizationApiKeyRequest.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationApiKeyType } from "../../enums/organizationApiKeyType"; 2 | 3 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 4 | 5 | export class OrganizationApiKeyRequest extends SecretVerificationRequest { 6 | type: OrganizationApiKeyType = OrganizationApiKeyType.Default; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/organizationConnectionRequest.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationConnectionType } from "jslib-common/enums/organizationConnectionType"; 2 | 3 | import { BillingSyncConfigRequest } from "./billingSyncConfigRequest"; 4 | 5 | /**API request config types for OrganizationConnectionRequest */ 6 | export type OrganizationConnectionRequestConfigs = BillingSyncConfigRequest; 7 | 8 | export class OrganizationConnectionRequest { 9 | constructor( 10 | public organizationId: string, 11 | public type: OrganizationConnectionType, 12 | public enabled: boolean, 13 | public config: OrganizationConnectionRequestConfigs 14 | ) {} 15 | } 16 | -------------------------------------------------------------------------------- /common/src/models/request/organizationCreateRequest.ts: -------------------------------------------------------------------------------- 1 | import { PaymentMethodType } from "../../enums/paymentMethodType"; 2 | import { PlanType } from "../../enums/planType"; 3 | 4 | import { OrganizationKeysRequest } from "./organizationKeysRequest"; 5 | 6 | export class OrganizationCreateRequest { 7 | name: string; 8 | businessName: string; 9 | billingEmail: string; 10 | planType: PlanType; 11 | key: string; 12 | keys: OrganizationKeysRequest; 13 | paymentMethodType: PaymentMethodType; 14 | paymentToken: string; 15 | additionalSeats: number; 16 | maxAutoscaleSeats: number; 17 | additionalStorageGb: number; 18 | premiumAccessAddon: boolean; 19 | collectionName: string; 20 | taxIdNumber: string; 21 | billingAddressLine1: string; 22 | billingAddressLine2: string; 23 | billingAddressCity: string; 24 | billingAddressState: string; 25 | billingAddressPostalCode: string; 26 | billingAddressCountry: string; 27 | } 28 | -------------------------------------------------------------------------------- /common/src/models/request/organizationImportGroupRequest.ts: -------------------------------------------------------------------------------- 1 | import { ImportDirectoryRequestGroup } from "./importDirectoryRequestGroup"; 2 | 3 | export class OrganizationImportGroupRequest { 4 | name: string; 5 | externalId: string; 6 | memberExternalIds: string[]; 7 | 8 | constructor(model: Required | ImportDirectoryRequestGroup) { 9 | this.name = model.name; 10 | this.externalId = model.externalId; 11 | 12 | if (model instanceof ImportDirectoryRequestGroup) { 13 | this.memberExternalIds = model.users; 14 | } else { 15 | this.memberExternalIds = model.memberExternalIds; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/models/request/organizationImportMemberRequest.ts: -------------------------------------------------------------------------------- 1 | import { ImportDirectoryRequestUser } from "./importDirectoryRequestUser"; 2 | 3 | export class OrganizationImportMemberRequest { 4 | email: string; 5 | externalId: string; 6 | deleted: boolean; 7 | 8 | constructor(model: Required | ImportDirectoryRequestUser) { 9 | this.email = model.email; 10 | this.externalId = model.externalId; 11 | this.deleted = model.deleted; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/models/request/organizationKeysRequest.ts: -------------------------------------------------------------------------------- 1 | import { KeysRequest } from "./keysRequest"; 2 | 3 | export class OrganizationKeysRequest extends KeysRequest { 4 | constructor(publicKey: string, encryptedPrivateKey: string) { 5 | super(publicKey, encryptedPrivateKey); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/organizationSubscriptionUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | export class OrganizationSubscriptionUpdateRequest { 2 | constructor(public seatAdjustment: number, public maxAutoscaleSeats?: number) {} 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/organizationTaxInfoUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | import { TaxInfoUpdateRequest } from "./taxInfoUpdateRequest"; 2 | 3 | export class OrganizationTaxInfoUpdateRequest extends TaxInfoUpdateRequest { 4 | taxId: string; 5 | line1: string; 6 | line2: string; 7 | city: string; 8 | state: string; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationKeysRequest } from "./organizationKeysRequest"; 2 | 3 | export class OrganizationUpdateRequest { 4 | name: string; 5 | identifier: string; 6 | businessName: string; 7 | billingEmail: string; 8 | keys: OrganizationKeysRequest; 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUpgradeRequest.ts: -------------------------------------------------------------------------------- 1 | import { PlanType } from "../../enums/planType"; 2 | 3 | import { OrganizationKeysRequest } from "./organizationKeysRequest"; 4 | 5 | export class OrganizationUpgradeRequest { 6 | businessName: string; 7 | planType: PlanType; 8 | additionalSeats: number; 9 | additionalStorageGb: number; 10 | premiumAccessAddon: boolean; 11 | billingAddressCountry: string; 12 | billingAddressPostalCode: string; 13 | keys: OrganizationKeysRequest; 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserAcceptRequest.ts: -------------------------------------------------------------------------------- 1 | export class OrganizationUserAcceptRequest { 2 | token: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserBulkConfirmRequest.ts: -------------------------------------------------------------------------------- 1 | type OrganizationUserBulkRequestEntry = { 2 | id: string; 3 | key: string; 4 | }; 5 | 6 | export class OrganizationUserBulkConfirmRequest { 7 | keys: OrganizationUserBulkRequestEntry[]; 8 | 9 | constructor(keys: OrganizationUserBulkRequestEntry[]) { 10 | this.keys = keys; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserBulkRequest.ts: -------------------------------------------------------------------------------- 1 | export class OrganizationUserBulkRequest { 2 | ids: string[]; 3 | 4 | constructor(ids: string[]) { 5 | this.ids = ids == null ? [] : ids; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserConfirmRequest.ts: -------------------------------------------------------------------------------- 1 | export class OrganizationUserConfirmRequest { 2 | key: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserInviteRequest.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationUserType } from "../../enums/organizationUserType"; 2 | import { PermissionsApi } from "../api/permissionsApi"; 3 | 4 | import { SelectionReadOnlyRequest } from "./selectionReadOnlyRequest"; 5 | 6 | export class OrganizationUserInviteRequest { 7 | emails: string[] = []; 8 | type: OrganizationUserType; 9 | accessAll: boolean; 10 | collections: SelectionReadOnlyRequest[] = []; 11 | permissions: PermissionsApi; 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserResetPasswordEnrollmentRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class OrganizationUserResetPasswordEnrollmentRequest extends SecretVerificationRequest { 4 | resetPasswordKey: string; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserResetPasswordRequest.ts: -------------------------------------------------------------------------------- 1 | export class OrganizationUserResetPasswordRequest { 2 | newMasterPasswordHash: string; 3 | key: string; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserUpdateGroupsRequest.ts: -------------------------------------------------------------------------------- 1 | export class OrganizationUserUpdateGroupsRequest { 2 | groupIds: string[] = []; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/organizationUserUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationUserType } from "../../enums/organizationUserType"; 2 | import { PermissionsApi } from "../api/permissionsApi"; 3 | 4 | import { SelectionReadOnlyRequest } from "./selectionReadOnlyRequest"; 5 | 6 | export class OrganizationUserUpdateRequest { 7 | type: OrganizationUserType; 8 | accessAll: boolean; 9 | collections: SelectionReadOnlyRequest[] = []; 10 | permissions: PermissionsApi; 11 | } 12 | -------------------------------------------------------------------------------- /common/src/models/request/passwordHintRequest.ts: -------------------------------------------------------------------------------- 1 | export class PasswordHintRequest { 2 | email: string; 3 | 4 | constructor(email: string) { 5 | this.email = email; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/passwordHistoryRequest.ts: -------------------------------------------------------------------------------- 1 | export class PasswordHistoryRequest { 2 | password: string; 3 | lastUsedDate: Date; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/passwordRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class PasswordRequest extends SecretVerificationRequest { 4 | newMasterPasswordHash: string; 5 | key: string; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/paymentRequest.ts: -------------------------------------------------------------------------------- 1 | import { PaymentMethodType } from "../../enums/paymentMethodType"; 2 | import { OrganizationTaxInfoUpdateRequest } from "../request/organizationTaxInfoUpdateRequest"; 3 | 4 | export class PaymentRequest extends OrganizationTaxInfoUpdateRequest { 5 | paymentMethodType: PaymentMethodType; 6 | paymentToken: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/policyRequest.ts: -------------------------------------------------------------------------------- 1 | import { PolicyType } from "../../enums/policyType"; 2 | 3 | export class PolicyRequest { 4 | type: PolicyType; 5 | enabled: boolean; 6 | data: any; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/preloginRequest.ts: -------------------------------------------------------------------------------- 1 | export class PreloginRequest { 2 | email: string; 3 | 4 | constructor(email: string) { 5 | this.email = email; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerAddOrganizationRequest.ts: -------------------------------------------------------------------------------- 1 | export class ProviderAddOrganizationRequest { 2 | organizationId: string; 3 | key: string; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerOrganizationCreateRequest.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationCreateRequest } from "../organizationCreateRequest"; 2 | 3 | export class ProviderOrganizationCreateRequest { 4 | constructor( 5 | public clientOwnerEmail: string, 6 | public organizationCreateRequest: OrganizationCreateRequest 7 | ) {} 8 | } 9 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerSetupRequest.ts: -------------------------------------------------------------------------------- 1 | export class ProviderSetupRequest { 2 | name: string; 3 | businessName: string; 4 | billingEmail: string; 5 | token: string; 6 | key: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | export class ProviderUpdateRequest { 2 | name: string; 3 | businessName: string; 4 | billingEmail: string; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerUserAcceptRequest.ts: -------------------------------------------------------------------------------- 1 | export class ProviderUserAcceptRequest { 2 | token: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerUserBulkConfirmRequest.ts: -------------------------------------------------------------------------------- 1 | type ProviderUserBulkRequestEntry = { 2 | id: string; 3 | key: string; 4 | }; 5 | 6 | export class ProviderUserBulkConfirmRequest { 7 | keys: ProviderUserBulkRequestEntry[]; 8 | 9 | constructor(keys: ProviderUserBulkRequestEntry[]) { 10 | this.keys = keys; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerUserBulkRequest.ts: -------------------------------------------------------------------------------- 1 | export class ProviderUserBulkRequest { 2 | ids: string[]; 3 | 4 | constructor(ids: string[]) { 5 | this.ids = ids == null ? [] : ids; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerUserConfirmRequest.ts: -------------------------------------------------------------------------------- 1 | export class ProviderUserConfirmRequest { 2 | key: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerUserInviteRequest.ts: -------------------------------------------------------------------------------- 1 | import { ProviderUserType } from "../../../enums/providerUserType"; 2 | 3 | export class ProviderUserInviteRequest { 4 | emails: string[] = []; 5 | type: ProviderUserType; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/provider/providerUserUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | import { ProviderUserType } from "../../../enums/providerUserType"; 2 | 3 | export class ProviderUserUpdateRequest { 4 | type: ProviderUserType; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/referenceEventRequest.ts: -------------------------------------------------------------------------------- 1 | export class ReferenceEventRequest { 2 | id: string; 3 | layout: string; 4 | flow: string; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/registerRequest.ts: -------------------------------------------------------------------------------- 1 | import { KdfType } from "../../enums/kdfType"; 2 | 3 | import { CaptchaProtectedRequest } from "./captchaProtectedRequest"; 4 | import { KeysRequest } from "./keysRequest"; 5 | import { ReferenceEventRequest } from "./referenceEventRequest"; 6 | 7 | export class RegisterRequest implements CaptchaProtectedRequest { 8 | masterPasswordHint: string; 9 | keys: KeysRequest; 10 | token: string; 11 | organizationUserId: string; 12 | 13 | constructor( 14 | public email: string, 15 | public name: string, 16 | public masterPasswordHash: string, 17 | masterPasswordHint: string, 18 | public key: string, 19 | public kdf: KdfType, 20 | public kdfIterations: number, 21 | public referenceData: ReferenceEventRequest, 22 | public captchaResponse: string 23 | ) { 24 | this.masterPasswordHint = masterPasswordHint ? masterPasswordHint : null; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /common/src/models/request/seatRequest.ts: -------------------------------------------------------------------------------- 1 | export class SeatRequest { 2 | seatAdjustment: number; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/secretVerificationRequest.ts: -------------------------------------------------------------------------------- 1 | export class SecretVerificationRequest { 2 | masterPasswordHash: string; 3 | otp: string; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/selectionReadOnlyRequest.ts: -------------------------------------------------------------------------------- 1 | export class SelectionReadOnlyRequest { 2 | id: string; 3 | readOnly: boolean; 4 | hidePasswords: boolean; 5 | 6 | constructor(id: string, readOnly: boolean, hidePasswords: boolean) { 7 | this.id = id; 8 | this.readOnly = readOnly; 9 | this.hidePasswords = hidePasswords; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /common/src/models/request/sendAccessRequest.ts: -------------------------------------------------------------------------------- 1 | export class SendAccessRequest { 2 | password: string; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/sendWithIdRequest.ts: -------------------------------------------------------------------------------- 1 | import { Send } from "../domain/send"; 2 | 3 | import { SendRequest } from "./sendRequest"; 4 | 5 | export class SendWithIdRequest extends SendRequest { 6 | id: string; 7 | 8 | constructor(send: Send) { 9 | super(send); 10 | this.id = send.id; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/request/setPasswordRequest.ts: -------------------------------------------------------------------------------- 1 | import { KdfType } from "../../enums/kdfType"; 2 | 3 | import { KeysRequest } from "./keysRequest"; 4 | 5 | export class SetPasswordRequest { 6 | masterPasswordHash: string; 7 | key: string; 8 | masterPasswordHint: string; 9 | keys: KeysRequest; 10 | kdf: KdfType; 11 | kdfIterations: number; 12 | orgIdentifier: string; 13 | 14 | constructor( 15 | masterPasswordHash: string, 16 | key: string, 17 | masterPasswordHint: string, 18 | kdf: KdfType, 19 | kdfIterations: number, 20 | orgIdentifier: string, 21 | keys: KeysRequest 22 | ) { 23 | this.masterPasswordHash = masterPasswordHash; 24 | this.key = key; 25 | this.masterPasswordHint = masterPasswordHint; 26 | this.kdf = kdf; 27 | this.kdfIterations = kdfIterations; 28 | this.orgIdentifier = orgIdentifier; 29 | this.keys = keys; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/models/request/storageRequest.ts: -------------------------------------------------------------------------------- 1 | export class StorageRequest { 2 | storageGbAdjustment: number; 3 | } 4 | -------------------------------------------------------------------------------- /common/src/models/request/taxInfoUpdateRequest.ts: -------------------------------------------------------------------------------- 1 | export class TaxInfoUpdateRequest { 2 | country: string; 3 | postalCode: string; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/twoFactorEmailRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class TwoFactorEmailRequest extends SecretVerificationRequest { 4 | email: string; 5 | deviceIdentifier: string; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/twoFactorProviderRequest.ts: -------------------------------------------------------------------------------- 1 | import { TwoFactorProviderType } from "../../enums/twoFactorProviderType"; 2 | 3 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 4 | 5 | export class TwoFactorProviderRequest extends SecretVerificationRequest { 6 | type: TwoFactorProviderType; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/twoFactorRecoveryRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class TwoFactorRecoveryRequest extends SecretVerificationRequest { 4 | recoveryCode: string; 5 | email: string; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/updateDomainsRequest.ts: -------------------------------------------------------------------------------- 1 | export class UpdateDomainsRequest { 2 | equivalentDomains: string[][]; 3 | excludedGlobalEquivalentDomains: number[]; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/updateKeyRequest.ts: -------------------------------------------------------------------------------- 1 | import { CipherWithIdRequest } from "./cipherWithIdRequest"; 2 | import { FolderWithIdRequest } from "./folderWithIdRequest"; 3 | import { SendWithIdRequest } from "./sendWithIdRequest"; 4 | 5 | export class UpdateKeyRequest { 6 | ciphers: CipherWithIdRequest[] = []; 7 | folders: FolderWithIdRequest[] = []; 8 | sends: SendWithIdRequest[] = []; 9 | masterPasswordHash: string; 10 | privateKey: string; 11 | key: string; 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/request/updateProfileRequest.ts: -------------------------------------------------------------------------------- 1 | export class UpdateProfileRequest { 2 | name: string; 3 | masterPasswordHint: string; 4 | culture = "en-US"; // deprecated 5 | 6 | constructor(name: string, masterPasswordHint: string) { 7 | this.name = name; 8 | this.masterPasswordHint = masterPasswordHint ? masterPasswordHint : null; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/request/updateTempPasswordRequest.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationUserResetPasswordRequest } from "./organizationUserResetPasswordRequest"; 2 | 3 | export class UpdateTempPasswordRequest extends OrganizationUserResetPasswordRequest { 4 | masterPasswordHint: string; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/updateTwoFactorAuthenticatorRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class UpdateTwoFactorAuthenticatorRequest extends SecretVerificationRequest { 4 | token: string; 5 | key: string; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/updateTwoFactorDuoRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class UpdateTwoFactorDuoRequest extends SecretVerificationRequest { 4 | integrationKey: string; 5 | secretKey: string; 6 | host: string; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/updateTwoFactorEmailRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class UpdateTwoFactorEmailRequest extends SecretVerificationRequest { 4 | token: string; 5 | email: string; 6 | } 7 | -------------------------------------------------------------------------------- /common/src/models/request/updateTwoFactorWebAuthnDeleteRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class UpdateTwoFactorWebAuthnDeleteRequest extends SecretVerificationRequest { 4 | id: number; 5 | } 6 | -------------------------------------------------------------------------------- /common/src/models/request/updateTwoFactorWebAuthnRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class UpdateTwoFactorWebAuthnRequest extends SecretVerificationRequest { 4 | deviceResponse: PublicKeyCredential; 5 | name: string; 6 | id: number; 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/request/updateTwoFactorYubioOtpRequest.ts: -------------------------------------------------------------------------------- 1 | import { SecretVerificationRequest } from "./secretVerificationRequest"; 2 | 3 | export class UpdateTwoFactorYubioOtpRequest extends SecretVerificationRequest { 4 | key1: string; 5 | key2: string; 6 | key3: string; 7 | key4: string; 8 | key5: string; 9 | nfc: boolean; 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/request/verifyBankRequest.ts: -------------------------------------------------------------------------------- 1 | export class VerifyBankRequest { 2 | amount1: number; 3 | amount2: number; 4 | } 5 | -------------------------------------------------------------------------------- /common/src/models/request/verifyDeleteRecoverRequest.ts: -------------------------------------------------------------------------------- 1 | export class VerifyDeleteRecoverRequest { 2 | userId: string; 3 | token: string; 4 | 5 | constructor(userId: string, token: string) { 6 | this.userId = userId; 7 | this.token = token; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/request/verifyEmailRequest.ts: -------------------------------------------------------------------------------- 1 | export class VerifyEmailRequest { 2 | userId: string; 3 | token: string; 4 | 5 | constructor(userId: string, token: string) { 6 | this.userId = userId; 7 | this.token = token; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /common/src/models/response/apiKeyResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class ApiKeyResponse extends BaseResponse { 4 | apiKey: string; 5 | revisionDate: Date; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.apiKey = this.getResponseProperty("ApiKey"); 10 | this.revisionDate = new Date(this.getResponseProperty("RevisionDate")); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/attachmentResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class AttachmentResponse extends BaseResponse { 4 | id: string; 5 | url: string; 6 | fileName: string; 7 | key: string; 8 | size: string; 9 | sizeName: string; 10 | 11 | constructor(response: any) { 12 | super(response); 13 | this.id = this.getResponseProperty("Id"); 14 | this.url = this.getResponseProperty("Url"); 15 | this.fileName = this.getResponseProperty("FileName"); 16 | this.key = this.getResponseProperty("Key"); 17 | this.size = this.getResponseProperty("Size"); 18 | this.sizeName = this.getResponseProperty("SizeName"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/models/response/billingHistoryResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | import { BillingInvoiceResponse, BillingTransactionResponse } from "./billingResponse"; 3 | 4 | export class BillingHistoryResponse extends BaseResponse { 5 | invoices: BillingInvoiceResponse[] = []; 6 | transactions: BillingTransactionResponse[] = []; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | const transactions = this.getResponseProperty("Transactions"); 11 | const invoices = this.getResponseProperty("Invoices"); 12 | if (transactions != null) { 13 | this.transactions = transactions.map((t: any) => new BillingTransactionResponse(t)); 14 | } 15 | if (invoices != null) { 16 | this.invoices = invoices.map((i: any) => new BillingInvoiceResponse(i)); 17 | } 18 | } 19 | 20 | get hasNoHistory() { 21 | return this.invoices.length == 0 && this.transactions.length == 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /common/src/models/response/billingPaymentResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | import { BillingSourceResponse } from "./billingResponse"; 3 | 4 | export class BillingPaymentResponse extends BaseResponse { 5 | balance: number; 6 | paymentSource: BillingSourceResponse; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | this.balance = this.getResponseProperty("Balance"); 11 | const paymentSource = this.getResponseProperty("PaymentSource"); 12 | this.paymentSource = paymentSource == null ? null : new BillingSourceResponse(paymentSource); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/response/deviceResponse.ts: -------------------------------------------------------------------------------- 1 | import { DeviceType } from "../../enums/deviceType"; 2 | 3 | import { BaseResponse } from "./baseResponse"; 4 | 5 | export class DeviceResponse extends BaseResponse { 6 | id: string; 7 | name: number; 8 | identifier: string; 9 | type: DeviceType; 10 | creationDate: string; 11 | 12 | constructor(response: any) { 13 | super(response); 14 | this.id = this.getResponseProperty("Id"); 15 | this.name = this.getResponseProperty("Name"); 16 | this.identifier = this.getResponseProperty("Identifier"); 17 | this.type = this.getResponseProperty("Type"); 18 | this.creationDate = this.getResponseProperty("CreationDate"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/models/response/domainsResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | import { GlobalDomainResponse } from "./globalDomainResponse"; 3 | 4 | export class DomainsResponse extends BaseResponse { 5 | equivalentDomains: string[][]; 6 | globalEquivalentDomains: GlobalDomainResponse[] = []; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | this.equivalentDomains = this.getResponseProperty("EquivalentDomains"); 11 | const globalEquivalentDomains = this.getResponseProperty("GlobalEquivalentDomains"); 12 | if (globalEquivalentDomains != null) { 13 | this.globalEquivalentDomains = globalEquivalentDomains.map( 14 | (d: any) => new GlobalDomainResponse(d) 15 | ); 16 | } else { 17 | this.globalEquivalentDomains = []; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/models/response/folderResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class FolderResponse extends BaseResponse { 4 | id: string; 5 | name: string; 6 | revisionDate: string; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | this.id = this.getResponseProperty("Id"); 11 | this.name = this.getResponseProperty("Name"); 12 | this.revisionDate = this.getResponseProperty("RevisionDate"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/response/globalDomainResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class GlobalDomainResponse extends BaseResponse { 4 | type: number; 5 | domains: string[]; 6 | excluded: boolean; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | this.type = this.getResponseProperty("Type"); 11 | this.domains = this.getResponseProperty("Domains"); 12 | this.excluded = this.getResponseProperty("Excluded"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/response/identityCaptchaResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class IdentityCaptchaResponse extends BaseResponse { 4 | siteKey: string; 5 | 6 | constructor(response: any) { 7 | super(response); 8 | this.siteKey = this.getResponseProperty("HCaptcha_SiteKey"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/response/keyConnectorUserKeyResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class KeyConnectorUserKeyResponse extends BaseResponse { 4 | key: string; 5 | 6 | constructor(response: any) { 7 | super(response); 8 | this.key = this.getResponseProperty("Key"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/response/keysResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class KeysResponse extends BaseResponse { 4 | privateKey: string; 5 | publicKey: string; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.privateKey = this.getResponseProperty("PrivateKey"); 10 | this.publicKey = this.getResponseProperty("PublicKey"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/listResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class ListResponse extends BaseResponse { 4 | data: T[]; 5 | continuationToken: string; 6 | 7 | constructor(response: any, t: new (dataResponse: any) => T) { 8 | super(response); 9 | const data = this.getResponseProperty("Data"); 10 | this.data = data == null ? [] : data.map((dr: any) => new t(dr)); 11 | this.continuationToken = this.getResponseProperty("ContinuationToken"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/models/response/organizationApiKeyInformationResponse.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationApiKeyType } from "../../enums/organizationApiKeyType"; 2 | 3 | import { BaseResponse } from "./baseResponse"; 4 | 5 | export class OrganizationApiKeyInformationResponse extends BaseResponse { 6 | keyType: OrganizationApiKeyType; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | this.keyType = this.getResponseProperty("KeyType"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/organizationAutoEnrollStatusResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class OrganizationAutoEnrollStatusResponse extends BaseResponse { 4 | id: string; 5 | resetPasswordEnabled: boolean; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.id = this.getResponseProperty("Id"); 10 | this.resetPasswordEnabled = this.getResponseProperty("ResetPasswordEnabled"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/organizationKeysResponse.ts: -------------------------------------------------------------------------------- 1 | import { KeysResponse } from "./keysResponse"; 2 | 3 | export class OrganizationKeysResponse extends KeysResponse { 4 | constructor(response: any) { 5 | super(response); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/models/response/organizationSponsorshipSyncStatusResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class OrganizationSponsorshipSyncStatusResponse extends BaseResponse { 4 | lastSyncDate?: Date; 5 | 6 | constructor(response: any) { 7 | super(response); 8 | const lastSyncDate = this.getResponseProperty("LastSyncDate"); 9 | if (lastSyncDate) { 10 | this.lastSyncDate = new Date(lastSyncDate); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/src/models/response/organizationUserBulkPublicKeyResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class OrganizationUserBulkPublicKeyResponse extends BaseResponse { 4 | id: string; 5 | userId: string; 6 | key: string; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | this.id = this.getResponseProperty("Id"); 11 | this.userId = this.getResponseProperty("UserId"); 12 | this.key = this.getResponseProperty("Key"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/response/organizationUserBulkResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class OrganizationUserBulkResponse extends BaseResponse { 4 | id: string; 5 | error: string; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.id = this.getResponseProperty("Id"); 10 | this.error = this.getResponseProperty("Error"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/passwordHistoryResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class PasswordHistoryResponse extends BaseResponse { 4 | password: string; 5 | lastUsedDate: string; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.password = this.getResponseProperty("Password"); 10 | this.lastUsedDate = this.getResponseProperty("LastUsedDate"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/paymentResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | import { ProfileResponse } from "./profileResponse"; 3 | 4 | export class PaymentResponse extends BaseResponse { 5 | userProfile: ProfileResponse; 6 | paymentIntentClientSecret: string; 7 | success: boolean; 8 | 9 | constructor(response: any) { 10 | super(response); 11 | const userProfile = this.getResponseProperty("UserProfile"); 12 | if (userProfile != null) { 13 | this.userProfile = new ProfileResponse(userProfile); 14 | } 15 | this.paymentIntentClientSecret = this.getResponseProperty("PaymentIntentClientSecret"); 16 | this.success = this.getResponseProperty("Success"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/models/response/policyResponse.ts: -------------------------------------------------------------------------------- 1 | import { PolicyType } from "../../enums/policyType"; 2 | 3 | import { BaseResponse } from "./baseResponse"; 4 | 5 | export class PolicyResponse extends BaseResponse { 6 | id: string; 7 | organizationId: string; 8 | type: PolicyType; 9 | data: any; 10 | enabled: boolean; 11 | 12 | constructor(response: any) { 13 | super(response); 14 | this.id = this.getResponseProperty("Id"); 15 | this.organizationId = this.getResponseProperty("OrganizationId"); 16 | this.type = this.getResponseProperty("Type"); 17 | this.data = this.getResponseProperty("Data"); 18 | this.enabled = this.getResponseProperty("Enabled"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/models/response/preloginResponse.ts: -------------------------------------------------------------------------------- 1 | import { KdfType } from "../../enums/kdfType"; 2 | 3 | import { BaseResponse } from "./baseResponse"; 4 | 5 | export class PreloginResponse extends BaseResponse { 6 | kdf: KdfType; 7 | kdfIterations: number; 8 | 9 | constructor(response: any) { 10 | super(response); 11 | this.kdf = this.getResponseProperty("Kdf"); 12 | this.kdfIterations = this.getResponseProperty("KdfIterations"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/response/profileProviderOrganizationResponse.ts: -------------------------------------------------------------------------------- 1 | import { ProfileOrganizationResponse } from "./profileOrganizationResponse"; 2 | 3 | export class ProfileProviderOrganizationResponse extends ProfileOrganizationResponse { 4 | constructor(response: any) { 5 | super(response); 6 | this.keyConnectorEnabled = false; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /common/src/models/response/provider/providerResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "../baseResponse"; 2 | 3 | export class ProviderResponse extends BaseResponse { 4 | id: string; 5 | name: string; 6 | businessName: string; 7 | billingEmail: string; 8 | 9 | constructor(response: any) { 10 | super(response); 11 | this.id = this.getResponseProperty("Id"); 12 | this.name = this.getResponseProperty("Name"); 13 | this.businessName = this.getResponseProperty("BusinessName"); 14 | this.billingEmail = this.getResponseProperty("BillingEmail"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/models/response/provider/providerUserBulkPublicKeyResponse.ts: -------------------------------------------------------------------------------- 1 | import { OrganizationUserBulkPublicKeyResponse } from "../organizationUserBulkPublicKeyResponse"; 2 | 3 | export class ProviderUserBulkPublicKeyResponse extends OrganizationUserBulkPublicKeyResponse {} 4 | -------------------------------------------------------------------------------- /common/src/models/response/provider/providerUserBulkResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "../baseResponse"; 2 | 3 | export class ProviderUserBulkResponse extends BaseResponse { 4 | id: string; 5 | error: string; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.id = this.getResponseProperty("Id"); 10 | this.error = this.getResponseProperty("Error"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/selectionReadOnlyResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class SelectionReadOnlyResponse extends BaseResponse { 4 | id: string; 5 | readOnly: boolean; 6 | hidePasswords: boolean; 7 | 8 | constructor(response: any) { 9 | super(response); 10 | this.id = this.getResponseProperty("Id"); 11 | this.readOnly = this.getResponseProperty("ReadOnly"); 12 | this.hidePasswords = this.getResponseProperty("HidePasswords"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/response/sendFileDownloadDataResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class SendFileDownloadDataResponse extends BaseResponse { 4 | id: string = null; 5 | url: string = null; 6 | constructor(response: any) { 7 | super(response); 8 | this.id = this.getResponseProperty("Id"); 9 | this.url = this.getResponseProperty("Url"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /common/src/models/response/sendFileUploadDataResponse.ts: -------------------------------------------------------------------------------- 1 | import { FileUploadType } from "../../enums/fileUploadType"; 2 | 3 | import { BaseResponse } from "./baseResponse"; 4 | import { SendResponse } from "./sendResponse"; 5 | 6 | export class SendFileUploadDataResponse extends BaseResponse { 7 | fileUploadType: FileUploadType; 8 | sendResponse: SendResponse; 9 | url: string = null; 10 | constructor(response: any) { 11 | super(response); 12 | this.fileUploadType = this.getResponseProperty("FileUploadType"); 13 | const sendResponse = this.getResponseProperty("SendResponse"); 14 | this.sendResponse = sendResponse == null ? null : new SendResponse(sendResponse); 15 | this.url = this.getResponseProperty("Url"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/src/models/response/ssoPreValidateResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class SsoPreValidateResponse extends BaseResponse { 4 | token: string; 5 | 6 | constructor(response: any) { 7 | super(response); 8 | this.token = this.getResponseProperty("Token"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/response/taxInfoResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class TaxInfoResponse extends BaseResponse { 4 | taxId: string; 5 | taxIdType: string; 6 | line1: string; 7 | line2: string; 8 | city: string; 9 | state: string; 10 | country: string; 11 | postalCode: string; 12 | 13 | constructor(response: any) { 14 | super(response); 15 | this.taxId = this.getResponseProperty("TaxIdNumber"); 16 | this.taxIdType = this.getResponseProperty("TaxIdType"); 17 | this.line1 = this.getResponseProperty("Line1"); 18 | this.line2 = this.getResponseProperty("Line2"); 19 | this.city = this.getResponseProperty("City"); 20 | this.state = this.getResponseProperty("State"); 21 | this.postalCode = this.getResponseProperty("PostalCode"); 22 | this.country = this.getResponseProperty("Country"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /common/src/models/response/taxRateResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class TaxRateResponse extends BaseResponse { 4 | id: string; 5 | country: string; 6 | state: string; 7 | postalCode: string; 8 | rate: number; 9 | 10 | constructor(response: any) { 11 | super(response); 12 | this.id = this.getResponseProperty("Id"); 13 | this.country = this.getResponseProperty("Country"); 14 | this.state = this.getResponseProperty("State"); 15 | this.postalCode = this.getResponseProperty("PostalCode"); 16 | this.rate = this.getResponseProperty("Rate"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /common/src/models/response/twoFactorAuthenticatorResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class TwoFactorAuthenticatorResponse extends BaseResponse { 4 | enabled: boolean; 5 | key: string; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.enabled = this.getResponseProperty("Enabled"); 10 | this.key = this.getResponseProperty("Key"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/twoFactorDuoResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class TwoFactorDuoResponse extends BaseResponse { 4 | enabled: boolean; 5 | host: string; 6 | secretKey: string; 7 | integrationKey: string; 8 | 9 | constructor(response: any) { 10 | super(response); 11 | this.enabled = this.getResponseProperty("Enabled"); 12 | this.host = this.getResponseProperty("Host"); 13 | this.secretKey = this.getResponseProperty("SecretKey"); 14 | this.integrationKey = this.getResponseProperty("IntegrationKey"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/models/response/twoFactorEmailResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class TwoFactorEmailResponse extends BaseResponse { 4 | enabled: boolean; 5 | email: string; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.enabled = this.getResponseProperty("Enabled"); 10 | this.email = this.getResponseProperty("Email"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/response/twoFactorProviderResponse.ts: -------------------------------------------------------------------------------- 1 | import { TwoFactorProviderType } from "../../enums/twoFactorProviderType"; 2 | 3 | import { BaseResponse } from "./baseResponse"; 4 | 5 | export class TwoFactorProviderResponse extends BaseResponse { 6 | enabled: boolean; 7 | type: TwoFactorProviderType; 8 | 9 | constructor(response: any) { 10 | super(response); 11 | this.enabled = this.getResponseProperty("Enabled"); 12 | this.type = this.getResponseProperty("Type"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/models/response/twoFactorRescoverResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class TwoFactorRecoverResponse extends BaseResponse { 4 | code: string; 5 | 6 | constructor(response: any) { 7 | super(response); 8 | this.code = this.getResponseProperty("Code"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /common/src/models/response/twoFactorYubiKeyResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class TwoFactorYubiKeyResponse extends BaseResponse { 4 | enabled: boolean; 5 | key1: string; 6 | key2: string; 7 | key3: string; 8 | key4: string; 9 | key5: string; 10 | nfc: boolean; 11 | 12 | constructor(response: any) { 13 | super(response); 14 | this.enabled = this.getResponseProperty("Enabled"); 15 | this.key1 = this.getResponseProperty("Key1"); 16 | this.key2 = this.getResponseProperty("Key2"); 17 | this.key3 = this.getResponseProperty("Key3"); 18 | this.key4 = this.getResponseProperty("Key4"); 19 | this.key5 = this.getResponseProperty("Key5"); 20 | this.nfc = this.getResponseProperty("Nfc"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/models/response/userKeyResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class UserKeyResponse extends BaseResponse { 4 | userId: string; 5 | publicKey: string; 6 | 7 | constructor(response: any) { 8 | super(response); 9 | this.userId = this.getResponseProperty("UserId"); 10 | this.publicKey = this.getResponseProperty("PublicKey"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /common/src/models/view/attachmentView.ts: -------------------------------------------------------------------------------- 1 | import { Attachment } from "../domain/attachment"; 2 | import { SymmetricCryptoKey } from "../domain/symmetricCryptoKey"; 3 | 4 | import { View } from "./view"; 5 | 6 | export class AttachmentView implements View { 7 | id: string = null; 8 | url: string = null; 9 | size: string = null; 10 | sizeName: string = null; 11 | fileName: string = null; 12 | key: SymmetricCryptoKey = null; 13 | 14 | constructor(a?: Attachment) { 15 | if (!a) { 16 | return; 17 | } 18 | 19 | this.id = a.id; 20 | this.url = a.url; 21 | this.size = a.size; 22 | this.sizeName = a.sizeName; 23 | } 24 | 25 | get fileSize(): number { 26 | try { 27 | if (this.size != null) { 28 | return parseInt(this.size, null); 29 | } 30 | } catch { 31 | // Invalid file size. 32 | } 33 | return 0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/models/view/collectionView.ts: -------------------------------------------------------------------------------- 1 | import { Collection } from "../domain/collection"; 2 | import { ITreeNodeObject } from "../domain/treeNode"; 3 | import { CollectionGroupDetailsResponse } from "../response/collectionResponse"; 4 | 5 | import { View } from "./view"; 6 | 7 | export class CollectionView implements View, ITreeNodeObject { 8 | id: string = null; 9 | organizationId: string = null; 10 | name: string = null; 11 | externalId: string = null; 12 | readOnly: boolean = null; 13 | hidePasswords: boolean = null; 14 | 15 | constructor(c?: Collection | CollectionGroupDetailsResponse) { 16 | if (!c) { 17 | return; 18 | } 19 | 20 | this.id = c.id; 21 | this.organizationId = c.organizationId; 22 | this.externalId = c.externalId; 23 | if (c instanceof Collection) { 24 | this.readOnly = c.readOnly; 25 | this.hidePasswords = c.hidePasswords; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/models/view/eventView.ts: -------------------------------------------------------------------------------- 1 | import { EventType } from "../../enums/eventType"; 2 | 3 | export class EventView { 4 | message: string; 5 | humanReadableMessage: string; 6 | appIcon: string; 7 | appName: string; 8 | userId: string; 9 | userName: string; 10 | userEmail: string; 11 | date: string; 12 | ip: string; 13 | type: EventType; 14 | installationId: string; 15 | 16 | constructor(data: Required) { 17 | this.message = data.message; 18 | this.humanReadableMessage = data.humanReadableMessage; 19 | this.appIcon = data.appIcon; 20 | this.appName = data.appName; 21 | this.userId = data.userId; 22 | this.userName = data.userName; 23 | this.userEmail = data.userEmail; 24 | this.date = data.date; 25 | this.ip = data.ip; 26 | this.type = data.type; 27 | this.installationId = data.installationId; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /common/src/models/view/fieldView.ts: -------------------------------------------------------------------------------- 1 | import { FieldType } from "../../enums/fieldType"; 2 | import { LinkedIdType } from "../../enums/linkedIdType"; 3 | import { Field } from "../domain/field"; 4 | 5 | import { View } from "./view"; 6 | 7 | export class FieldView implements View { 8 | name: string = null; 9 | value: string = null; 10 | type: FieldType = null; 11 | newField = false; // Marks if the field is new and hasn't been saved 12 | showValue = false; 13 | showCount = false; 14 | linkedId: LinkedIdType = null; 15 | 16 | constructor(f?: Field) { 17 | if (!f) { 18 | return; 19 | } 20 | 21 | this.type = f.type; 22 | this.linkedId = f.linkedId; 23 | } 24 | 25 | get maskedValue(): string { 26 | return this.value != null ? "••••••••" : null; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/models/view/folderView.ts: -------------------------------------------------------------------------------- 1 | import { Folder } from "../domain/folder"; 2 | import { ITreeNodeObject } from "../domain/treeNode"; 3 | 4 | import { View } from "./view"; 5 | 6 | export class FolderView implements View, ITreeNodeObject { 7 | id: string = null; 8 | name: string = null; 9 | revisionDate: Date = null; 10 | 11 | constructor(f?: Folder) { 12 | if (!f) { 13 | return; 14 | } 15 | 16 | this.id = f.id; 17 | this.revisionDate = f.revisionDate; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/src/models/view/itemView.ts: -------------------------------------------------------------------------------- 1 | import { LinkedMetadata } from "../../misc/linkedFieldOption.decorator"; 2 | 3 | import { View } from "./view"; 4 | 5 | export abstract class ItemView implements View { 6 | linkedFieldOptions: Map; 7 | abstract get subTitle(): string; 8 | } 9 | -------------------------------------------------------------------------------- /common/src/models/view/passwordHistoryView.ts: -------------------------------------------------------------------------------- 1 | import { Password } from "../domain/password"; 2 | 3 | import { View } from "./view"; 4 | 5 | export class PasswordHistoryView implements View { 6 | password: string = null; 7 | lastUsedDate: Date = null; 8 | 9 | constructor(ph?: Password) { 10 | if (!ph) { 11 | return; 12 | } 13 | 14 | this.lastUsedDate = ph.lastUsedDate; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/models/view/secureNoteView.ts: -------------------------------------------------------------------------------- 1 | import { SecureNoteType } from "../../enums/secureNoteType"; 2 | import { SecureNote } from "../domain/secureNote"; 3 | 4 | import { ItemView } from "./itemView"; 5 | 6 | export class SecureNoteView extends ItemView { 7 | type: SecureNoteType = null; 8 | 9 | constructor(n?: SecureNote) { 10 | super(); 11 | if (!n) { 12 | return; 13 | } 14 | 15 | this.type = n.type; 16 | } 17 | 18 | get subTitle(): string { 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/models/view/sendAccessView.ts: -------------------------------------------------------------------------------- 1 | import { SendType } from "../../enums/sendType"; 2 | import { SendAccess } from "../domain/sendAccess"; 3 | 4 | import { SendFileView } from "./sendFileView"; 5 | import { SendTextView } from "./sendTextView"; 6 | import { View } from "./view"; 7 | 8 | export class SendAccessView implements View { 9 | id: string = null; 10 | name: string = null; 11 | type: SendType = null; 12 | text = new SendTextView(); 13 | file = new SendFileView(); 14 | expirationDate: Date = null; 15 | creatorIdentifier: string = null; 16 | 17 | constructor(s?: SendAccess) { 18 | if (!s) { 19 | return; 20 | } 21 | 22 | this.id = s.id; 23 | this.type = s.type; 24 | this.expirationDate = s.expirationDate; 25 | this.creatorIdentifier = s.creatorIdentifier; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /common/src/models/view/sendFileView.ts: -------------------------------------------------------------------------------- 1 | import { SendFile } from "../domain/sendFile"; 2 | 3 | import { View } from "./view"; 4 | 5 | export class SendFileView implements View { 6 | id: string = null; 7 | size: string = null; 8 | sizeName: string = null; 9 | fileName: string = null; 10 | 11 | constructor(f?: SendFile) { 12 | if (!f) { 13 | return; 14 | } 15 | 16 | this.id = f.id; 17 | this.size = f.size; 18 | this.sizeName = f.sizeName; 19 | } 20 | 21 | get fileSize(): number { 22 | try { 23 | if (this.size != null) { 24 | return parseInt(this.size, null); 25 | } 26 | } catch { 27 | // Invalid file size. 28 | } 29 | return 0; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/models/view/sendTextView.ts: -------------------------------------------------------------------------------- 1 | import { SendText } from "../domain/sendText"; 2 | 3 | import { View } from "./view"; 4 | 5 | export class SendTextView implements View { 6 | text: string = null; 7 | hidden: boolean; 8 | 9 | constructor(t?: SendText) { 10 | if (!t) { 11 | return; 12 | } 13 | 14 | this.hidden = t.hidden; 15 | } 16 | 17 | get maskedText(): string { 18 | return this.text != null ? "••••••••" : null; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/models/view/view.ts: -------------------------------------------------------------------------------- 1 | export class View {} 2 | -------------------------------------------------------------------------------- /common/src/services/broadcaster.service.ts: -------------------------------------------------------------------------------- 1 | import { BroadcasterService as BroadcasterServiceAbstraction } from "../abstractions/broadcaster.service"; 2 | 3 | export class BroadcasterService implements BroadcasterServiceAbstraction { 4 | subscribers: Map any> = new Map any>(); 5 | 6 | send(message: any, id?: string) { 7 | if (id != null) { 8 | if (this.subscribers.has(id)) { 9 | this.subscribers.get(id)(message); 10 | } 11 | return; 12 | } 13 | 14 | this.subscribers.forEach((value) => { 15 | value(message); 16 | }); 17 | } 18 | 19 | subscribe(id: string, messageCallback: (message: any) => any) { 20 | this.subscribers.set(id, messageCallback); 21 | } 22 | 23 | unsubscribe(id: string) { 24 | if (this.subscribers.has(id)) { 25 | this.subscribers.delete(id); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /common/src/services/container.service.ts: -------------------------------------------------------------------------------- 1 | import { CryptoService } from "../abstractions/crypto.service"; 2 | 3 | export class ContainerService { 4 | constructor(private cryptoService: CryptoService) {} 5 | 6 | // deprecated, use attachToGlobal instead 7 | attachToWindow(win: any) { 8 | this.attachToGlobal(win); 9 | } 10 | 11 | attachToGlobal(global: any) { 12 | if (!global.bitwardenContainerService) { 13 | global.bitwardenContainerService = this; 14 | } 15 | } 16 | 17 | getCryptoService(): CryptoService { 18 | return this.cryptoService; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/services/noopMessaging.service.ts: -------------------------------------------------------------------------------- 1 | import { MessagingService } from "../abstractions/messaging.service"; 2 | 3 | export class NoopMessagingService implements MessagingService { 4 | send(subscriber: string, arg: any = {}) { 5 | // Do nothing... 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /common/src/types/verification.ts: -------------------------------------------------------------------------------- 1 | import { VerificationType } from "../enums/verificationType"; 2 | 3 | export type Verification = { 4 | type: VerificationType; 5 | secret: string; 6 | }; 7 | -------------------------------------------------------------------------------- /common/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../shared/tsconfig", 3 | "compilerOptions": { 4 | "paths": { 5 | "jslib-common/*": ["./src/*"] 6 | } 7 | }, 8 | "include": ["src", "spec"], 9 | "exclude": ["node_modules", "dist"] 10 | } 11 | -------------------------------------------------------------------------------- /common/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /components/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /components/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | documentation.json 10 | 11 | # Node 12 | /node_modules 13 | npm-debug.log 14 | yarn-error.log 15 | 16 | # IDEs and editors 17 | .idea/ 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # Visual Studio Code 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # Miscellaneous 34 | /.angular/cache 35 | .sass-cache/ 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | testem.log 40 | /typings 41 | 42 | # System files 43 | .DS_Store 44 | Thumbs.db 45 | -------------------------------------------------------------------------------- /components/.storybook/main.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], 3 | addons: [ 4 | "@storybook/addon-links", 5 | "@storybook/addon-essentials", 6 | "@storybook/addon-a11y", 7 | "storybook-addon-designs", 8 | ], 9 | framework: "@storybook/angular", 10 | core: { 11 | builder: "webpack5", 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /components/.storybook/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.app.json", 3 | "compilerOptions": { 4 | "types": ["node"], 5 | "allowSyntheticDefaultImports": true 6 | }, 7 | "exclude": ["../src/test.ts", "../src/**/*.spec.ts", "../projects/**/*.spec.ts"], 8 | "include": ["../src/**/*", "../projects/**/*"], 9 | "files": ["./typings.d.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /components/.storybook/typings.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.md" { 2 | const content: string; 3 | export default content; 4 | } 5 | -------------------------------------------------------------------------------- /components/jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require("ts-jest"); 2 | 3 | const { compilerOptions } = require("./tsconfig"); 4 | 5 | module.exports = { 6 | name: "angular", 7 | displayName: "component library tests", 8 | preset: "jest-preset-angular", 9 | testMatch: ["**/+(*.)+(spec).+(ts)"], 10 | setupFilesAfterEnv: ["/spec/test.ts"], 11 | collectCoverage: true, 12 | coverageReporters: ["html", "lcov"], 13 | coverageDirectory: "coverage", 14 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, { 15 | prefix: "/", 16 | }), 17 | }; 18 | -------------------------------------------------------------------------------- /components/spec/test.ts: -------------------------------------------------------------------------------- 1 | import "jest-preset-angular/setup-jest"; 2 | -------------------------------------------------------------------------------- /components/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from "@angular/core"; 2 | 3 | @Component({ 4 | selector: "app-root", 5 | template: "", 6 | }) 7 | export class AppComponent { 8 | title = "components"; 9 | } 10 | -------------------------------------------------------------------------------- /components/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from "@angular/common"; 2 | import { NgModule } from "@angular/core"; 3 | import { BrowserModule } from "@angular/platform-browser"; 4 | 5 | import { AppComponent } from "./app.component"; 6 | 7 | @NgModule({ 8 | declarations: [AppComponent], 9 | imports: [BrowserModule, CommonModule], 10 | providers: [{ provide: "WINDOW", useValue: window }], 11 | bootstrap: [AppComponent], 12 | }) 13 | export class AppModule {} 14 | -------------------------------------------------------------------------------- /components/src/badge/badge.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from "@angular/common"; 2 | import { NgModule } from "@angular/core"; 3 | 4 | import { BadgeDirective } from "./badge.directive"; 5 | 6 | @NgModule({ 7 | imports: [CommonModule], 8 | exports: [BadgeDirective], 9 | declarations: [BadgeDirective], 10 | }) 11 | export class BadgeModule {} 12 | -------------------------------------------------------------------------------- /components/src/badge/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./badge.directive"; 2 | export * from "./badge.module"; 3 | -------------------------------------------------------------------------------- /components/src/banner/banner.component.html: -------------------------------------------------------------------------------- 1 |
7 | 8 | 9 | 10 | 11 | 14 |
15 | -------------------------------------------------------------------------------- /components/src/banner/banner.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from "@angular/common"; 2 | import { NgModule } from "@angular/core"; 3 | 4 | import { BannerComponent } from "./banner.component"; 5 | 6 | @NgModule({ 7 | imports: [CommonModule], 8 | exports: [BannerComponent], 9 | declarations: [BannerComponent], 10 | }) 11 | export class BannerModule {} 12 | -------------------------------------------------------------------------------- /components/src/banner/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./banner.component"; 2 | export * from "./banner.module"; 3 | -------------------------------------------------------------------------------- /components/src/button/button.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from "@angular/common"; 2 | import { NgModule } from "@angular/core"; 3 | 4 | import { ButtonDirective } from "./button.directive"; 5 | 6 | @NgModule({ 7 | imports: [CommonModule], 8 | exports: [ButtonDirective], 9 | declarations: [ButtonDirective], 10 | }) 11 | export class ButtonModule {} 12 | -------------------------------------------------------------------------------- /components/src/button/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./button.directive"; 2 | export * from "./button.module"; 3 | -------------------------------------------------------------------------------- /components/src/callout/callout.component.html: -------------------------------------------------------------------------------- 1 |
5 |

10 | 11 | {{ title }} 12 |

13 | 14 |
15 | -------------------------------------------------------------------------------- /components/src/callout/callout.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from "@angular/common"; 2 | import { NgModule } from "@angular/core"; 3 | 4 | import { CalloutComponent } from "./callout.component"; 5 | 6 | @NgModule({ 7 | imports: [CommonModule], 8 | exports: [CalloutComponent], 9 | declarations: [CalloutComponent], 10 | }) 11 | export class CalloutModule {} 12 | -------------------------------------------------------------------------------- /components/src/callout/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./callout.module"; 2 | export * from "./callout.component"; 3 | -------------------------------------------------------------------------------- /components/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/components/src/favicon.ico -------------------------------------------------------------------------------- /components/src/form-field/form-field.component.html: -------------------------------------------------------------------------------- 1 | 5 |
6 |
7 | 8 |
9 | 10 |
11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /components/src/form-field/hint.component.ts: -------------------------------------------------------------------------------- 1 | import { Directive, HostBinding } from "@angular/core"; 2 | 3 | // Increments for each instance of this component 4 | let nextId = 0; 5 | 6 | @Directive({ 7 | selector: "bit-hint", 8 | host: { 9 | class: "tw-text-muted tw-inline-block tw-mt-1", 10 | }, 11 | }) 12 | export class BitHintComponent { 13 | @HostBinding() id = `bit-hint-${nextId++}`; 14 | } 15 | -------------------------------------------------------------------------------- /components/src/form-field/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./form-field.module"; 2 | export * from "./form-field.component"; 3 | -------------------------------------------------------------------------------- /components/src/form-field/label.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive } from "@angular/core"; 2 | 3 | @Directive({ 4 | selector: "bit-label", 5 | }) 6 | export class BitLabel {} 7 | -------------------------------------------------------------------------------- /components/src/form-field/prefix.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, HostBinding, Input } from "@angular/core"; 2 | 3 | export const PrefixClasses = [ 4 | "tw-block", 5 | "tw-px-3", 6 | "tw-py-1.5", 7 | "tw-bg-background-alt", 8 | "tw-border", 9 | "tw-border-solid", 10 | "tw-border-secondary-500", 11 | "tw-text-muted", 12 | "tw-rounded", 13 | ]; 14 | 15 | @Directive({ 16 | selector: "[bitPrefix]", 17 | }) 18 | export class BitPrefixDirective { 19 | @HostBinding("class") @Input() get classList() { 20 | return PrefixClasses.concat([ 21 | "tw-border-r-0", 22 | "tw-rounded-r-none", 23 | !this.first ? "tw-rounded-l-none" : "", 24 | ]).filter((c) => c != ""); 25 | } 26 | 27 | @Input() first = false; 28 | } 29 | -------------------------------------------------------------------------------- /components/src/form-field/suffix.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive, HostBinding, Input } from "@angular/core"; 2 | 3 | import { PrefixClasses } from "./prefix.directive"; 4 | 5 | @Directive({ 6 | selector: "[bitSuffix]", 7 | }) 8 | export class BitSuffixDirective { 9 | @HostBinding("class") @Input() get classList() { 10 | return PrefixClasses.concat([ 11 | "tw-rounded-l-none", 12 | "tw-border-l-0", 13 | !this.last ? "tw-rounded-r-none" : "", 14 | ]).filter((c) => c != ""); 15 | } 16 | 17 | @Input() last = false; 18 | } 19 | -------------------------------------------------------------------------------- /components/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Components 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /components/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./badge"; 2 | export * from "./banner"; 3 | export * from "./button"; 4 | export * from "./callout"; 5 | export * from "./form-field"; 6 | export * from "./menu"; 7 | -------------------------------------------------------------------------------- /components/src/input/input.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from "@angular/common"; 2 | import { NgModule } from "@angular/core"; 3 | 4 | import { BitInputDirective } from "./input.directive"; 5 | 6 | @NgModule({ 7 | imports: [CommonModule], 8 | declarations: [BitInputDirective], 9 | exports: [BitInputDirective], 10 | }) 11 | export class InputModule {} 12 | -------------------------------------------------------------------------------- /components/src/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"; 2 | 3 | import { AppModule } from "./app/app.module"; 4 | 5 | platformBrowserDynamic() 6 | .bootstrapModule(AppModule) 7 | .catch((err) => console.error(err)); // eslint-disable-line 8 | -------------------------------------------------------------------------------- /components/src/menu/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./menu.module"; 2 | export * from "./menu.component"; 3 | export * from "./menu-trigger-for.directive"; 4 | export * from "./menu-item.directive"; 5 | export * from "./menu-divider.component"; 6 | -------------------------------------------------------------------------------- /components/src/menu/menu-divider.component.html: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /components/src/menu/menu-divider.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from "@angular/core"; 2 | 3 | @Component({ 4 | selector: "bit-menu-divider", 5 | templateUrl: "./menu-divider.component.html", 6 | }) 7 | export class MenuDividerComponent {} 8 | -------------------------------------------------------------------------------- /components/src/menu/menu.component.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /components/src/menu/menu.component.ts: -------------------------------------------------------------------------------- 1 | import { FocusKeyManager } from "@angular/cdk/a11y"; 2 | import { 3 | Component, 4 | Output, 5 | TemplateRef, 6 | ViewChild, 7 | EventEmitter, 8 | ContentChildren, 9 | QueryList, 10 | AfterContentInit, 11 | } from "@angular/core"; 12 | 13 | import { MenuItemDirective } from "./menu-item.directive"; 14 | 15 | @Component({ 16 | selector: "bit-menu", 17 | templateUrl: "./menu.component.html", 18 | exportAs: "menuComponent", 19 | }) 20 | export class MenuComponent implements AfterContentInit { 21 | @ViewChild(TemplateRef) templateRef: TemplateRef; 22 | @Output() closed = new EventEmitter(); 23 | @ContentChildren(MenuItemDirective, { descendants: true }) 24 | menuItems: QueryList; 25 | keyManager: FocusKeyManager; 26 | 27 | ngAfterContentInit() { 28 | this.keyManager = new FocusKeyManager(this.menuItems).withWrap(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/src/menu/menu.module.ts: -------------------------------------------------------------------------------- 1 | import { OverlayModule } from "@angular/cdk/overlay"; 2 | import { CommonModule } from "@angular/common"; 3 | import { NgModule } from "@angular/core"; 4 | 5 | import { MenuDividerComponent } from "./menu-divider.component"; 6 | import { MenuItemDirective } from "./menu-item.directive"; 7 | import { MenuTriggerForDirective } from "./menu-trigger-for.directive"; 8 | import { MenuComponent } from "./menu.component"; 9 | 10 | @NgModule({ 11 | imports: [CommonModule, OverlayModule], 12 | declarations: [MenuComponent, MenuTriggerForDirective, MenuItemDirective, MenuDividerComponent], 13 | exports: [MenuComponent, MenuTriggerForDirective, MenuItemDirective, MenuDividerComponent], 14 | }) 15 | export class MenuModule {} 16 | -------------------------------------------------------------------------------- /components/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | @import "./tw-theme.css"; 4 | 5 | @tailwind base; 6 | @tailwind components; 7 | @tailwind utilities; 8 | 9 | body { 10 | font-size: 14px; 11 | } 12 | -------------------------------------------------------------------------------- /components/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | // eslint-disable-next-line 3 | import "zone.js/testing"; 4 | 5 | import { getTestBed } from "@angular/core/testing"; 6 | import { 7 | BrowserDynamicTestingModule, 8 | platformBrowserDynamicTesting, 9 | } from "@angular/platform-browser-dynamic/testing"; 10 | 11 | declare const require: { 12 | context( 13 | path: string, 14 | deep?: boolean, 15 | filter?: RegExp 16 | ): { 17 | (id: string): T; 18 | keys(): string[]; 19 | }; 20 | }; 21 | 22 | // First, initialize the Angular testing environment. 23 | getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); 24 | 25 | // Then we find all the tests. 26 | const context = require.context("./", true, /\.spec\.ts$/); 27 | // And load the modules. 28 | context.keys().map(context); 29 | -------------------------------------------------------------------------------- /components/src/utils/i18n-mock.service.ts: -------------------------------------------------------------------------------- 1 | import { I18nService } from "jslib-common/abstractions/i18n.service"; 2 | 3 | export class I18nMockService implements I18nService { 4 | locale: string; 5 | supportedTranslationLocales: string[]; 6 | translationLocale: string; 7 | collator: Intl.Collator; 8 | localeNames: Map; 9 | 10 | constructor(private lookupTable: Record) {} 11 | 12 | t(id: string, p1?: string, p2?: string, p3?: string) { 13 | return this.lookupTable[id]; 14 | } 15 | 16 | translate(id: string, p1?: string, p2?: string, p3?: string) { 17 | return this.t(id, p1, p2, p3); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /components/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const config = require("./tailwind.config.base"); 3 | 4 | config.content = ["./src/**/*.{html,ts,mdx}", "./.storybook/preview.js"]; 5 | config.safelist = [ 6 | { 7 | pattern: /tw-bg-(.*)/, 8 | }, 9 | ]; 10 | 11 | module.exports = config; 12 | -------------------------------------------------------------------------------- /components/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "files": ["src/main.ts", "src/polyfills.ts"], 8 | "include": ["src/**/*.d.ts"], 9 | "exclude": ["**/*.stories.*"] 10 | } 11 | -------------------------------------------------------------------------------- /components/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /electron/jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require("ts-jest"); 2 | 3 | const { compilerOptions } = require("./tsconfig"); 4 | 5 | module.exports = { 6 | preset: "ts-jest", 7 | testEnvironment: "jsdom", 8 | testMatch: ["**/+(*.)+(spec).+(ts)"], 9 | setupFilesAfterEnv: ["/spec/test.ts"], 10 | collectCoverage: true, 11 | coverageReporters: ["html", "lcov"], 12 | coverageDirectory: "coverage", 13 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, { 14 | prefix: "/", 15 | }), 16 | }; 17 | -------------------------------------------------------------------------------- /electron/spec/services/electronLog.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { ElectronLogService } from "jslib-electron/services/electronLog.service"; 2 | 3 | describe("ElectronLogService", () => { 4 | it("sets dev based on electron method", () => { 5 | process.env.ELECTRON_IS_DEV = "1"; 6 | const logService = new ElectronLogService(); 7 | expect(logService).toEqual(expect.objectContaining({ isDev: true }) as any); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /electron/spec/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/electron/spec/test.ts -------------------------------------------------------------------------------- /electron/src/globals.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/electron/src/globals.d.ts -------------------------------------------------------------------------------- /electron/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../shared/tsconfig", 3 | "compilerOptions": { 4 | "paths": { 5 | "jslib-common/*": ["../common/src/*"], 6 | "jslib-electron/*": ["./src/*"] 7 | } 8 | }, 9 | "include": ["src", "spec"], 10 | "exclude": ["node_modules", "dist"] 11 | } 12 | -------------------------------------------------------------------------------- /electron/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require("ts-jest"); 2 | 3 | const { compilerOptions } = require("./tsconfig"); 4 | 5 | module.exports = { 6 | collectCoverage: true, 7 | coverageReporters: ["html", "lcov"], 8 | coverageDirectory: "coverage", 9 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, { 10 | prefix: "/", 11 | }), 12 | projects: [ 13 | "/angular/jest.config.js", 14 | "/common/jest.config.js", 15 | "/electron/jest.config.js", 16 | "/node/jest.config.js", 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /node/jest.config.js: -------------------------------------------------------------------------------- 1 | const { pathsToModuleNameMapper } = require("ts-jest"); 2 | 3 | const { compilerOptions } = require("./tsconfig"); 4 | 5 | module.exports = { 6 | preset: "ts-jest", 7 | testMatch: ["**/+(*.)+(spec).+(ts)"], 8 | setupFilesAfterEnv: ["/spec/test.ts"], 9 | collectCoverage: true, 10 | coverageReporters: ["html", "lcov"], 11 | coverageDirectory: "coverage", 12 | moduleNameMapper: pathsToModuleNameMapper(compilerOptions?.paths || {}, { 13 | prefix: "/", 14 | }), 15 | }; 16 | -------------------------------------------------------------------------------- /node/spec/test.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/node/spec/test.ts -------------------------------------------------------------------------------- /node/src/cli/commands/logout.command.ts: -------------------------------------------------------------------------------- 1 | import { AuthService } from "jslib-common/abstractions/auth.service"; 2 | import { I18nService } from "jslib-common/abstractions/i18n.service"; 3 | 4 | import { Response } from "../models/response"; 5 | import { MessageResponse } from "../models/response/messageResponse"; 6 | 7 | export class LogoutCommand { 8 | constructor( 9 | private authService: AuthService, 10 | private i18nService: I18nService, 11 | private logoutCallback: () => Promise 12 | ) {} 13 | 14 | async run() { 15 | await this.logoutCallback(); 16 | this.authService.logOut(() => { 17 | /* Do nothing */ 18 | }); 19 | const res = new MessageResponse("You have logged out.", null); 20 | return Response.success(res); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /node/src/cli/models/response/baseResponse.ts: -------------------------------------------------------------------------------- 1 | export interface BaseResponse { 2 | object: string; 3 | } 4 | -------------------------------------------------------------------------------- /node/src/cli/models/response/fileResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class FileResponse implements BaseResponse { 4 | object: string; 5 | data: Buffer; 6 | fileName: string; 7 | 8 | constructor(data: Buffer, fileName: string) { 9 | this.object = "file"; 10 | this.data = data; 11 | this.fileName = fileName; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /node/src/cli/models/response/listResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class ListResponse implements BaseResponse { 4 | object: string; 5 | data: BaseResponse[]; 6 | 7 | constructor(data: BaseResponse[]) { 8 | this.object = "list"; 9 | this.data = data; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /node/src/cli/models/response/messageResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class MessageResponse implements BaseResponse { 4 | object: string; 5 | title: string; 6 | message: string; 7 | raw: string; 8 | noColor = false; 9 | 10 | constructor(title: string, message: string) { 11 | this.object = "message"; 12 | this.title = title; 13 | this.message = message; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /node/src/cli/models/response/stringResponse.ts: -------------------------------------------------------------------------------- 1 | import { BaseResponse } from "./baseResponse"; 2 | 3 | export class StringResponse implements BaseResponse { 4 | object: string; 5 | data: string; 6 | 7 | constructor(data: string) { 8 | this.object = "string"; 9 | this.data = data; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /node/src/cli/services/consoleLog.service.ts: -------------------------------------------------------------------------------- 1 | import { LogLevelType } from "jslib-common/enums/logLevelType"; 2 | import { ConsoleLogService as BaseConsoleLogService } from "jslib-common/services/consoleLog.service"; 3 | 4 | export class ConsoleLogService extends BaseConsoleLogService { 5 | constructor(isDev: boolean, filter: (level: LogLevelType) => boolean = null) { 6 | super(isDev, filter); 7 | } 8 | 9 | write(level: LogLevelType, message: string) { 10 | if (this.filter != null && this.filter(level)) { 11 | return; 12 | } 13 | 14 | if (process.env.BW_RESPONSE === "true") { 15 | // eslint-disable-next-line 16 | console.error(message); 17 | return; 18 | } 19 | 20 | super.write(level, message); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /node/src/globals.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitwarden/jslib/6008a03395989060e984f6bc331642367ac1ab79/node/src/globals.d.ts -------------------------------------------------------------------------------- /node/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../shared/tsconfig", 3 | "compilerOptions": { 4 | "paths": { 5 | "jslib-common/*": ["../common/src/*"], 6 | "jslib-node/*": ["./src/*"] 7 | } 8 | }, 9 | "include": ["src", "spec"], 10 | "exclude": ["node_modules", "dist"] 11 | } 12 | -------------------------------------------------------------------------------- /node/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /shared/eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "plugins": ["@typescript-eslint"], 4 | "extends": [ 5 | "eslint:recommended", 6 | "plugin:@typescript-eslint/recommended", 7 | "plugin:import/recommended", 8 | "plugin:import/typescript", 9 | "prettier" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/no-explicit-any": "off", // TODO: This should be re-enabled 13 | "@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }], 14 | "@typescript-eslint/explicit-member-accessibility": [ 15 | "error", 16 | { 17 | "accessibility": "no-public" 18 | } 19 | ], 20 | "@typescript-eslint/no-this-alias": [ 21 | "error", 22 | { 23 | "allowedNames": ["self"] 24 | } 25 | ], 26 | "no-console": "warn", 27 | "import/no-unresolved": "off" // TODO: Look into turning off once each package is an actual package. 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /shared/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "pretty": true, 4 | "moduleResolution": "node", 5 | "noImplicitAny": true, 6 | "target": "ES6", 7 | "module": "commonjs", 8 | "lib": ["es5", "es6", "es7", "dom"], 9 | "sourceMap": true, 10 | "allowSyntheticDefaultImports": true, 11 | "experimentalDecorators": true, 12 | "emitDecoratorMetadata": true, 13 | "outDir": "dist" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "pretty": true, 4 | "moduleResolution": "node", 5 | "noImplicitAny": true, 6 | "target": "ES6", 7 | "module": "commonjs", 8 | "lib": ["es5", "es6", "es7", "dom"], 9 | "sourceMap": true, 10 | "declaration": true, 11 | "allowSyntheticDefaultImports": true, 12 | "experimentalDecorators": true, 13 | "emitDecoratorMetadata": true, 14 | "declarationDir": "dist/types", 15 | "outDir": "dist", 16 | "baseUrl": ".", 17 | "paths": { 18 | "jslib-common/*": ["common/src/*"], 19 | "jslib-angular/*": ["angular/src/*"], 20 | "jslib-electron/*": ["electron/src/*"], 21 | "jslib-node/*": ["node/src/*"] 22 | }, 23 | "plugins": [ 24 | { 25 | "transform": "typescript-transform-paths" 26 | } 27 | ] 28 | }, 29 | "exclude": ["node_modules", "dist"] 30 | } 31 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json" 3 | } 4 | --------------------------------------------------------------------------------