cozy-keys-lib 4.3.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -10
- package/src/components/PasswordField.jsx +3 -3
- package/src/components/UnlockForm.jsx +4 -4
- package/src/components/UnlockForm.spec.jsx +2 -2
- package/src/components/VaultUnlocker.jsx +2 -2
- package/transpiled/@bitwarden/jslib/abstractions/api.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/appId.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/audit.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/auth.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/biometric.main.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/broadcaster.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/cipher.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/collection.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/crypto.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/cryptoFunction.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/environment.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/event.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/export.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/folder.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/i18n.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/import.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/log.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/messaging.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/notifications.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/passwordGeneration.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/platformUtils.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/policy.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/search.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/send.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/settings.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/state.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/storage.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/sync.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/system.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/token.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/totp.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/user.service.js +3 -2
- package/transpiled/@bitwarden/jslib/abstractions/vaultTimeout.service.js +3 -2
- package/transpiled/@bitwarden/jslib/angular/components/add-edit.component.js +328 -468
- package/transpiled/@bitwarden/jslib/angular/components/attachments.component.js +316 -435
- package/transpiled/@bitwarden/jslib/angular/components/callout.component.js +3 -23
- package/transpiled/@bitwarden/jslib/angular/components/change-password.component.js +145 -216
- package/transpiled/@bitwarden/jslib/angular/components/ciphers.component.js +97 -156
- package/transpiled/@bitwarden/jslib/angular/components/collections.component.js +77 -119
- package/transpiled/@bitwarden/jslib/angular/components/environment.component.js +32 -52
- package/transpiled/@bitwarden/jslib/angular/components/export.component.js +60 -96
- package/transpiled/@bitwarden/jslib/angular/components/folder-add-edit.component.js +93 -141
- package/transpiled/@bitwarden/jslib/angular/components/groupings.component.js +77 -133
- package/transpiled/@bitwarden/jslib/angular/components/hint.component.js +36 -56
- package/transpiled/@bitwarden/jslib/angular/components/icon.component.js +19 -46
- package/transpiled/@bitwarden/jslib/angular/components/lock.component.js +273 -375
- package/transpiled/@bitwarden/jslib/angular/components/login.component.js +147 -209
- package/transpiled/@bitwarden/jslib/angular/components/modal.component.js +3 -24
- package/transpiled/@bitwarden/jslib/angular/components/password-generator-history.component.js +10 -23
- package/transpiled/@bitwarden/jslib/angular/components/password-generator.component.js +71 -115
- package/transpiled/@bitwarden/jslib/angular/components/password-history.component.js +22 -39
- package/transpiled/@bitwarden/jslib/angular/components/premium.component.js +50 -77
- package/transpiled/@bitwarden/jslib/angular/components/register.component.js +143 -194
- package/transpiled/@bitwarden/jslib/angular/components/set-password.component.js +102 -139
- package/transpiled/@bitwarden/jslib/angular/components/share.component.js +94 -142
- package/transpiled/@bitwarden/jslib/angular/components/sso.component.js +220 -299
- package/transpiled/@bitwarden/jslib/angular/components/two-factor-options.component.js +3 -15
- package/transpiled/@bitwarden/jslib/angular/components/two-factor.component.js +234 -312
- package/transpiled/@bitwarden/jslib/angular/components/view.component.js +260 -376
- package/transpiled/@bitwarden/jslib/angular/directives/a11y-title.directive.js +8 -20
- package/transpiled/@bitwarden/jslib/angular/directives/api-action.directive.js +3 -17
- package/transpiled/@bitwarden/jslib/angular/directives/autofocus.directive.js +8 -19
- package/transpiled/@bitwarden/jslib/angular/directives/blur-click.directive.js +3 -14
- package/transpiled/@bitwarden/jslib/angular/directives/box-row.directive.js +3 -20
- package/transpiled/@bitwarden/jslib/angular/directives/fallback-src.directive.js +3 -15
- package/transpiled/@bitwarden/jslib/angular/directives/input-verbatim.directive.js +8 -23
- package/transpiled/@bitwarden/jslib/angular/directives/select-copy.directive.js +5 -22
- package/transpiled/@bitwarden/jslib/angular/directives/stop-click.directive.js +3 -13
- package/transpiled/@bitwarden/jslib/angular/directives/stop-prop.directive.js +3 -13
- package/transpiled/@bitwarden/jslib/angular/directives/true-false-value.directive.js +5 -18
- package/transpiled/@bitwarden/jslib/angular/pipes/color-password.pipe.js +5 -22
- package/transpiled/@bitwarden/jslib/angular/pipes/i18n.pipe.js +3 -13
- package/transpiled/@bitwarden/jslib/angular/pipes/search-ciphers.pipe.js +3 -19
- package/transpiled/@bitwarden/jslib/angular/pipes/search.pipe.js +3 -16
- package/transpiled/@bitwarden/jslib/angular/services/auth-guard.service.js +40 -67
- package/transpiled/@bitwarden/jslib/angular/services/broadcaster.service.js +10 -15
- package/transpiled/@bitwarden/jslib/angular/services/validation.service.js +3 -16
- package/transpiled/@bitwarden/jslib/cli/baseProgram.js +31 -66
- package/transpiled/@bitwarden/jslib/cli/commands/login.command.js +441 -572
- package/transpiled/@bitwarden/jslib/cli/commands/logout.command.js +12 -25
- package/transpiled/@bitwarden/jslib/cli/commands/update.command.js +113 -179
- package/transpiled/@bitwarden/jslib/cli/models/response/listResponse.js +3 -3
- package/transpiled/@bitwarden/jslib/cli/models/response/messageResponse.js +3 -3
- package/transpiled/@bitwarden/jslib/cli/models/response/stringResponse.js +3 -3
- package/transpiled/@bitwarden/jslib/cli/models/response.js +0 -4
- package/transpiled/@bitwarden/jslib/cli/services/cliPlatformUtils.service.js +2 -9
- package/transpiled/@bitwarden/jslib/cli/services/consoleLog.service.js +0 -10
- package/transpiled/@bitwarden/jslib/electron/baseMenu.js +0 -7
- package/transpiled/@bitwarden/jslib/electron/biometric.darwin.main.js +44 -71
- package/transpiled/@bitwarden/jslib/electron/biometric.windows.main.js +115 -175
- package/transpiled/@bitwarden/jslib/electron/electronConstants.js +3 -2
- package/transpiled/@bitwarden/jslib/electron/keytarStorageListener.js +42 -66
- package/transpiled/@bitwarden/jslib/electron/services/electronLog.service.js +0 -13
- package/transpiled/@bitwarden/jslib/electron/services/electronMainMessaging.service.js +0 -4
- package/transpiled/@bitwarden/jslib/electron/services/electronPlatformUtils.service.js +26 -46
- package/transpiled/@bitwarden/jslib/electron/services/electronRendererMessaging.service.js +9 -23
- package/transpiled/@bitwarden/jslib/electron/services/electronRendererSecureStorage.service.js +32 -49
- package/transpiled/@bitwarden/jslib/electron/services/electronStorage.service.js +2 -8
- package/transpiled/@bitwarden/jslib/electron/tray.main.js +97 -145
- package/transpiled/@bitwarden/jslib/electron/updater.main.js +163 -217
- package/transpiled/@bitwarden/jslib/electron/utils.js +0 -3
- package/transpiled/@bitwarden/jslib/electron/window.main.js +237 -314
- package/transpiled/@bitwarden/jslib/enums/cipherType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/deviceType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/encryptionType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/eventType.js +2 -3
- package/transpiled/@bitwarden/jslib/enums/fieldType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/kdfType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/logLevelType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/notificationType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/organizationUserStatusType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/organizationUserType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/paymentMethodType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/planType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/policyType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/productType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/secureNoteType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/sendType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/transactionType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/twoFactorProviderType.js +0 -1
- package/transpiled/@bitwarden/jslib/enums/uriMatchType.js +0 -1
- package/transpiled/@bitwarden/jslib/importers/ascendoCsvImporter.js +5 -18
- package/transpiled/@bitwarden/jslib/importers/avastCsvImporter.js +5 -12
- package/transpiled/@bitwarden/jslib/importers/avastJsonImporter.js +5 -23
- package/transpiled/@bitwarden/jslib/importers/aviraCsvImporter.js +5 -13
- package/transpiled/@bitwarden/jslib/importers/baseImporter.js +26 -80
- package/transpiled/@bitwarden/jslib/importers/bitwardenCsvImporter.js +5 -27
- package/transpiled/@bitwarden/jslib/importers/bitwardenJsonImporter.js +9 -20
- package/transpiled/@bitwarden/jslib/importers/blackBerryCsvImporter.js +5 -15
- package/transpiled/@bitwarden/jslib/importers/blurCsvImporter.js +5 -14
- package/transpiled/@bitwarden/jslib/importers/buttercupCsvImporter.js +5 -17
- package/transpiled/@bitwarden/jslib/importers/chromeCsvImporter.js +5 -12
- package/transpiled/@bitwarden/jslib/importers/clipperzHtmlImporter.js +5 -24
- package/transpiled/@bitwarden/jslib/importers/codebookCsvImporter.js +5 -21
- package/transpiled/@bitwarden/jslib/importers/dashlaneJsonImporter.js +5 -41
- package/transpiled/@bitwarden/jslib/importers/encryptrCsvImporter.js +5 -20
- package/transpiled/@bitwarden/jslib/importers/enpassCsvImporter.js +5 -22
- package/transpiled/@bitwarden/jslib/importers/enpassJsonImporter.js +5 -28
- package/transpiled/@bitwarden/jslib/importers/firefoxCsvImporter.js +5 -13
- package/transpiled/@bitwarden/jslib/importers/fsecureFskImporter.js +5 -14
- package/transpiled/@bitwarden/jslib/importers/gnomeJsonImporter.js +5 -25
- package/transpiled/@bitwarden/jslib/importers/kasperskyTxtImporter.js +5 -35
- package/transpiled/@bitwarden/jslib/importers/keepass2XmlImporter.js +5 -29
- package/transpiled/@bitwarden/jslib/importers/keepassxCsvImporter.js +5 -17
- package/transpiled/@bitwarden/jslib/importers/keeperCsvImporter.js +5 -17
- package/transpiled/@bitwarden/jslib/importers/lastpassCsvImporter.js +9 -52
- package/transpiled/@bitwarden/jslib/importers/logMeOnceCsvImporter.js +5 -13
- package/transpiled/@bitwarden/jslib/importers/meldiumCsvImporter.js +5 -12
- package/transpiled/@bitwarden/jslib/importers/msecureCsvImporter.js +5 -20
- package/transpiled/@bitwarden/jslib/importers/mykiCsvImporter.js +5 -13
- package/transpiled/@bitwarden/jslib/importers/onepassword1PifImporter.js +9 -49
- package/transpiled/@bitwarden/jslib/importers/onepasswordWinCsvImporter.js +5 -24
- package/transpiled/@bitwarden/jslib/importers/padlockCsvImporter.js +5 -23
- package/transpiled/@bitwarden/jslib/importers/passkeepCsvImporter.js +5 -16
- package/transpiled/@bitwarden/jslib/importers/passmanJsonImporter.js +5 -22
- package/transpiled/@bitwarden/jslib/importers/passpackCsvImporter.js +5 -22
- package/transpiled/@bitwarden/jslib/importers/passwordAgentCsvImporter.js +5 -22
- package/transpiled/@bitwarden/jslib/importers/passwordBossJsonImporter.js +5 -24
- package/transpiled/@bitwarden/jslib/importers/passwordDragonXmlImporter.js +5 -25
- package/transpiled/@bitwarden/jslib/importers/passwordSafeXmlImporter.js +5 -26
- package/transpiled/@bitwarden/jslib/importers/passwordWalletTxtImporter.js +5 -20
- package/transpiled/@bitwarden/jslib/importers/rememBearCsvImporter.js +5 -24
- package/transpiled/@bitwarden/jslib/importers/roboformCsvImporter.js +5 -24
- package/transpiled/@bitwarden/jslib/importers/safeInCloudXmlImporter.js +5 -27
- package/transpiled/@bitwarden/jslib/importers/saferpassCsvImport.js +5 -12
- package/transpiled/@bitwarden/jslib/importers/secureSafeCsvImporter.js +5 -12
- package/transpiled/@bitwarden/jslib/importers/splashIdCsvImporter.js +5 -20
- package/transpiled/@bitwarden/jslib/importers/stickyPasswordXmlImporter.js +5 -25
- package/transpiled/@bitwarden/jslib/importers/truekeyCsvImporter.js +5 -17
- package/transpiled/@bitwarden/jslib/importers/upmCsvImporter.js +5 -13
- package/transpiled/@bitwarden/jslib/importers/yotiCsvImporter.js +5 -12
- package/transpiled/@bitwarden/jslib/importers/zohoVaultCsvImporter.js +5 -26
- package/transpiled/@bitwarden/jslib/misc/analytics.js +49 -85
- package/transpiled/@bitwarden/jslib/misc/nodeUtils.js +0 -4
- package/transpiled/@bitwarden/jslib/misc/sequentialize.js +0 -11
- package/transpiled/@bitwarden/jslib/misc/serviceUtils.js +0 -10
- package/transpiled/@bitwarden/jslib/misc/throttle.js +0 -13
- package/transpiled/@bitwarden/jslib/misc/u2f.js +0 -7
- package/transpiled/@bitwarden/jslib/misc/utils.js +8 -57
- package/transpiled/@bitwarden/jslib/models/api/cardApi.js +7 -10
- package/transpiled/@bitwarden/jslib/models/api/fieldApi.js +7 -10
- package/transpiled/@bitwarden/jslib/models/api/identityApi.js +7 -10
- package/transpiled/@bitwarden/jslib/models/api/loginApi.js +7 -13
- package/transpiled/@bitwarden/jslib/models/api/loginUriApi.js +7 -12
- package/transpiled/@bitwarden/jslib/models/api/secureNoteApi.js +7 -10
- package/transpiled/@bitwarden/jslib/models/api/sendFileApi.js +7 -10
- package/transpiled/@bitwarden/jslib/models/api/sendTextApi.js +7 -10
- package/transpiled/@bitwarden/jslib/models/data/attachmentData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/data/cardData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/data/cipherData.js +3 -12
- package/transpiled/@bitwarden/jslib/models/data/collectionData.js +3 -3
- package/transpiled/@bitwarden/jslib/models/data/eventData.js +3 -2
- package/transpiled/@bitwarden/jslib/models/data/fieldData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/data/folderData.js +3 -3
- package/transpiled/@bitwarden/jslib/models/data/identityData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/data/loginData.js +3 -5
- package/transpiled/@bitwarden/jslib/models/data/loginUriData.js +3 -5
- package/transpiled/@bitwarden/jslib/models/data/organizationData.js +3 -3
- package/transpiled/@bitwarden/jslib/models/data/passwordHistoryData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/data/policyData.js +3 -3
- package/transpiled/@bitwarden/jslib/models/data/secureNoteData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/data/sendData.js +3 -7
- package/transpiled/@bitwarden/jslib/models/data/sendFileData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/data/sendTextData.js +3 -4
- package/transpiled/@bitwarden/jslib/models/domain/attachment.js +48 -75
- package/transpiled/@bitwarden/jslib/models/domain/authResult.js +3 -3
- package/transpiled/@bitwarden/jslib/models/domain/card.js +6 -12
- package/transpiled/@bitwarden/jslib/models/domain/cipher.js +98 -153
- package/transpiled/@bitwarden/jslib/models/domain/cipherString.js +45 -84
- package/transpiled/@bitwarden/jslib/models/domain/collection.js +6 -12
- package/transpiled/@bitwarden/jslib/models/domain/decryptParameters.js +3 -2
- package/transpiled/@bitwarden/jslib/models/domain/domainBase.js +40 -69
- package/transpiled/@bitwarden/jslib/models/domain/encryptedObject.js +3 -2
- package/transpiled/@bitwarden/jslib/models/domain/environmentUrls.js +3 -2
- package/transpiled/@bitwarden/jslib/models/domain/field.js +6 -13
- package/transpiled/@bitwarden/jslib/models/domain/folder.js +6 -12
- package/transpiled/@bitwarden/jslib/models/domain/generatedPasswordHistory.js +3 -3
- package/transpiled/@bitwarden/jslib/models/domain/identity.js +6 -12
- package/transpiled/@bitwarden/jslib/models/domain/importResult.js +3 -3
- package/transpiled/@bitwarden/jslib/models/domain/login.js +41 -68
- package/transpiled/@bitwarden/jslib/models/domain/loginUri.js +6 -13
- package/transpiled/@bitwarden/jslib/models/domain/masterPasswordPolicyOptions.js +7 -7
- package/transpiled/@bitwarden/jslib/models/domain/organization.js +0 -5
- package/transpiled/@bitwarden/jslib/models/domain/password.js +6 -12
- package/transpiled/@bitwarden/jslib/models/domain/passwordGeneratorPolicyOptions.js +5 -7
- package/transpiled/@bitwarden/jslib/models/domain/policy.js +7 -9
- package/transpiled/@bitwarden/jslib/models/domain/secureNote.js +5 -10
- package/transpiled/@bitwarden/jslib/models/domain/send.js +63 -101
- package/transpiled/@bitwarden/jslib/models/domain/sendAccess.js +37 -63
- package/transpiled/@bitwarden/jslib/models/domain/sendFile.js +19 -36
- package/transpiled/@bitwarden/jslib/models/domain/sendText.js +6 -13
- package/transpiled/@bitwarden/jslib/models/domain/sortedCiphersCache.js +0 -10
- package/transpiled/@bitwarden/jslib/models/domain/symmetricCryptoKey.js +3 -9
- package/transpiled/@bitwarden/jslib/models/domain/treeNode.js +3 -3
- package/transpiled/@bitwarden/jslib/models/export/card.js +0 -5
- package/transpiled/@bitwarden/jslib/models/export/cipher.js +2 -19
- package/transpiled/@bitwarden/jslib/models/export/cipherWithIds.js +8 -10
- package/transpiled/@bitwarden/jslib/models/export/collection.js +2 -8
- package/transpiled/@bitwarden/jslib/models/export/collectionWithId.js +8 -9
- package/transpiled/@bitwarden/jslib/models/export/field.js +0 -6
- package/transpiled/@bitwarden/jslib/models/export/folder.js +2 -4
- package/transpiled/@bitwarden/jslib/models/export/folderWithId.js +8 -9
- package/transpiled/@bitwarden/jslib/models/export/identity.js +0 -5
- package/transpiled/@bitwarden/jslib/models/export/login.js +0 -8
- package/transpiled/@bitwarden/jslib/models/export/loginUri.js +0 -7
- package/transpiled/@bitwarden/jslib/models/export/secureNote.js +0 -4
- package/transpiled/@bitwarden/jslib/models/request/attachmentRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/bitPayInvoiceRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/cipherBulkDeleteRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/cipherBulkMoveRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/cipherBulkRestoreRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/cipherBulkShareRequest.js +3 -5
- package/transpiled/@bitwarden/jslib/models/request/cipherCollectionsRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/cipherCreateRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/cipherRequest.js +3 -16
- package/transpiled/@bitwarden/jslib/models/request/cipherShareRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/cipherWithIdRequest.js +7 -7
- package/transpiled/@bitwarden/jslib/models/request/collectionRequest.js +3 -5
- package/transpiled/@bitwarden/jslib/models/request/deleteRecoverRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/deviceRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/deviceTokenRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/emailRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/emailTokenRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/eventRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/folderRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/folderWithIdRequest.js +7 -7
- package/transpiled/@bitwarden/jslib/models/request/groupRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/iapCheckRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/importCiphersRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/importDirectoryRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/importDirectoryRequestGroup.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/importDirectoryRequestUser.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/importOrganizationCiphersRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/kdfRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/keysRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/kvpRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/organizationCreateRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/organizationTaxInfoUpdateRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/organizationUpdateRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/organizationUpgradeRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/organizationUserAcceptRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/organizationUserConfirmRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/organizationUserInviteRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/organizationUserUpdateGroupsRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/organizationUserUpdateRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/passwordHintRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/passwordHistoryRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/passwordRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/passwordVerificationRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/paymentRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/policyRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/preloginRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/referenceEventRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/registerRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/seatRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/selectionReadOnlyRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/sendAccessRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/sendRequest.js +3 -6
- package/transpiled/@bitwarden/jslib/models/request/setPasswordRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/storageRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/taxInfoUpdateRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/tokenRequest.js +2 -8
- package/transpiled/@bitwarden/jslib/models/request/twoFactorEmailRequest.js +7 -7
- package/transpiled/@bitwarden/jslib/models/request/twoFactorProviderRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/twoFactorRecoveryRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/updateDomainsRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/updateKeyRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/updateProfileRequest.js +3 -4
- package/transpiled/@bitwarden/jslib/models/request/updateTwoFactorAuthenticatorRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/updateTwoFactorDuoRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/updateTwoFactorEmailRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/updateTwoFactorU2fDeleteRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/updateTwoFactorU2fRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/updateTwoFactorYubioOtpRequest.js +7 -6
- package/transpiled/@bitwarden/jslib/models/request/verifyBankRequest.js +3 -2
- package/transpiled/@bitwarden/jslib/models/request/verifyDeleteRecoverRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/request/verifyEmailRequest.js +3 -3
- package/transpiled/@bitwarden/jslib/models/response/apiKeyResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/attachmentResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/baseResponse.js +0 -13
- package/transpiled/@bitwarden/jslib/models/response/billingResponse.js +16 -32
- package/transpiled/@bitwarden/jslib/models/response/breachAccountResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/cipherResponse.js +7 -24
- package/transpiled/@bitwarden/jslib/models/response/collectionResponse.js +13 -22
- package/transpiled/@bitwarden/jslib/models/response/deviceResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/domainsResponse.js +7 -10
- package/transpiled/@bitwarden/jslib/models/response/errorResponse.js +5 -23
- package/transpiled/@bitwarden/jslib/models/response/eventResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/folderResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/globalDomainResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/groupResponse.js +10 -16
- package/transpiled/@bitwarden/jslib/models/response/identityTokenResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/identityTwoFactorResponse.js +7 -10
- package/transpiled/@bitwarden/jslib/models/response/keysResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/listResponse.js +7 -9
- package/transpiled/@bitwarden/jslib/models/response/notificationResponse.js +16 -31
- package/transpiled/@bitwarden/jslib/models/response/organizationResponse.js +7 -9
- package/transpiled/@bitwarden/jslib/models/response/organizationSubscriptionResponse.js +7 -11
- package/transpiled/@bitwarden/jslib/models/response/organizationUserResponse.js +13 -22
- package/transpiled/@bitwarden/jslib/models/response/passwordHistoryResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/paymentResponse.js +7 -10
- package/transpiled/@bitwarden/jslib/models/response/planResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/policyResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/preloginResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/profileOrganizationResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/profileResponse.js +7 -10
- package/transpiled/@bitwarden/jslib/models/response/selectionReadOnlyResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/sendAccessResponse.js +7 -12
- package/transpiled/@bitwarden/jslib/models/response/sendResponse.js +7 -12
- package/transpiled/@bitwarden/jslib/models/response/subscriptionResponse.js +16 -31
- package/transpiled/@bitwarden/jslib/models/response/syncResponse.js +7 -22
- package/transpiled/@bitwarden/jslib/models/response/taxInfoResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/twoFactorAuthenticatorResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/twoFactorDuoResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/twoFactorEmailResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/twoFactorProviderResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/twoFactorRescoverResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/twoFactorU2fResponse.js +13 -21
- package/transpiled/@bitwarden/jslib/models/response/twoFactorYubiKeyResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/response/userKeyResponse.js +7 -7
- package/transpiled/@bitwarden/jslib/models/view/attachmentView.js +0 -6
- package/transpiled/@bitwarden/jslib/models/view/cardView.js +11 -17
- package/transpiled/@bitwarden/jslib/models/view/cipherView.js +0 -12
- package/transpiled/@bitwarden/jslib/models/view/collectionView.js +3 -6
- package/transpiled/@bitwarden/jslib/models/view/fieldView.js +0 -6
- package/transpiled/@bitwarden/jslib/models/view/folderView.js +3 -5
- package/transpiled/@bitwarden/jslib/models/view/identityView.js +4 -24
- package/transpiled/@bitwarden/jslib/models/view/loginUriView.js +4 -19
- package/transpiled/@bitwarden/jslib/models/view/loginView.js +0 -7
- package/transpiled/@bitwarden/jslib/models/view/passwordHistoryView.js +3 -5
- package/transpiled/@bitwarden/jslib/models/view/secureNoteView.js +0 -5
- package/transpiled/@bitwarden/jslib/models/view/sendAccessView.js +3 -5
- package/transpiled/@bitwarden/jslib/models/view/sendFileView.js +0 -6
- package/transpiled/@bitwarden/jslib/models/view/sendTextView.js +0 -5
- package/transpiled/@bitwarden/jslib/models/view/sendView.js +0 -5
- package/transpiled/@bitwarden/jslib/models/view/view.js +3 -2
- package/transpiled/@bitwarden/jslib/services/api.service.js +1348 -1867
- package/transpiled/@bitwarden/jslib/services/appId.service.js +21 -38
- package/transpiled/@bitwarden/jslib/services/audit.service.js +49 -77
- package/transpiled/@bitwarden/jslib/services/auth.service.js +241 -339
- package/transpiled/@bitwarden/jslib/services/broadcaster.service.js +0 -5
- package/transpiled/@bitwarden/jslib/services/cipher.service.js +1350 -1828
- package/transpiled/@bitwarden/jslib/services/collection.service.js +235 -324
- package/transpiled/@bitwarden/jslib/services/constants.service.js +3 -3
- package/transpiled/@bitwarden/jslib/services/container.service.js +2 -5
- package/transpiled/@bitwarden/jslib/services/crypto.service.js +1001 -1380
- package/transpiled/@bitwarden/jslib/services/environment.service.js +83 -111
- package/transpiled/@bitwarden/jslib/services/event.service.js +119 -171
- package/transpiled/@bitwarden/jslib/services/export.service.js +250 -320
- package/transpiled/@bitwarden/jslib/services/folder.service.js +264 -361
- package/transpiled/@bitwarden/jslib/services/i18n.service.js +96 -143
- package/transpiled/@bitwarden/jslib/services/import.service.js +138 -248
- package/transpiled/@bitwarden/jslib/services/lowdbStorage.service.js +0 -11
- package/transpiled/@bitwarden/jslib/services/nodeApi.service.js +5 -9
- package/transpiled/@bitwarden/jslib/services/nodeCryptoFunction.service.js +145 -206
- package/transpiled/@bitwarden/jslib/services/noopMessaging.service.js +2 -5
- package/transpiled/@bitwarden/jslib/services/notifications.service.js +260 -358
- package/transpiled/@bitwarden/jslib/services/passwordGeneration.service.js +507 -711
- package/transpiled/@bitwarden/jslib/services/policy.service.js +108 -161
- package/transpiled/@bitwarden/jslib/services/search.service.js +178 -237
- package/transpiled/@bitwarden/jslib/services/send.service.js +335 -457
- package/transpiled/@bitwarden/jslib/services/settings.service.js +72 -109
- package/transpiled/@bitwarden/jslib/services/state.service.js +0 -4
- package/transpiled/@bitwarden/jslib/services/sync.service.js +481 -653
- package/transpiled/@bitwarden/jslib/services/system.service.js +61 -103
- package/transpiled/@bitwarden/jslib/services/token.service.js +119 -192
- package/transpiled/@bitwarden/jslib/services/totp.service.js +103 -157
- package/transpiled/@bitwarden/jslib/services/user.service.js +210 -300
- package/transpiled/@bitwarden/jslib/services/vaultTimeout.service.js +212 -305
- package/transpiled/@bitwarden/jslib/services/webCryptoFunction.service.js +384 -502
- package/transpiled/CozyUtils.js +73 -102
- package/transpiled/CozyUtils.spec.js +61 -85
- package/transpiled/HtmlStorageService.js +24 -57
- package/transpiled/MemoryStorageService.js +0 -7
- package/transpiled/NodeEnvSecureStorageService.js +94 -145
- package/transpiled/NodeVaultClient.js +5 -9
- package/transpiled/StrippedWebPlatformUtilsService.js +1 -8
- package/transpiled/WebPlatformUtilsService.js +89 -127
- package/transpiled/WebVaultClient.js +880 -1337
- package/transpiled/WebVaultClient.spec.js +79 -103
- package/transpiled/__mocks__/WebVaultClient.js +0 -5
- package/transpiled/components/IconCozySecurity.js +3 -5
- package/transpiled/components/PasswordField.js +14 -20
- package/transpiled/components/UnlockForm.js +53 -71
- package/transpiled/components/UnlockForm.spec.js +73 -89
- package/transpiled/components/VaultContext.js +30 -58
- package/transpiled/components/VaultContext.spec.js +45 -52
- package/transpiled/components/VaultUnlockPlaceholder.js +3 -6
- package/transpiled/components/VaultUnlocker.js +36 -51
- package/transpiled/components/defaults.js +24 -34
- package/transpiled/components/defaults.spec.js +37 -51
- package/transpiled/components/vaultUnlockContext.js +47 -60
- package/transpiled/components/vaultUnlockContext.spec.js +62 -85
- package/transpiled/services/crypto.service.js +6 -7
- package/transpiled/stubs/node-forge.js +0 -7
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
4
|
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
6
5
|
var c = arguments.length,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--)
|
|
10
|
-
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
11
|
-
}
|
|
6
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
7
|
+
d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12
9
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
10
|
};
|
|
14
|
-
|
|
15
11
|
var __metadata = this && this.__metadata || function (k, v) {
|
|
16
12
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
17
13
|
};
|
|
18
|
-
|
|
19
14
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
20
15
|
function adopt(value) {
|
|
21
16
|
return value instanceof P ? value : new P(function (resolve) {
|
|
22
17
|
resolve(value);
|
|
23
18
|
});
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
27
21
|
function fulfilled(value) {
|
|
28
22
|
try {
|
|
@@ -31,7 +25,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
31
25
|
reject(e);
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
function rejected(value) {
|
|
36
29
|
try {
|
|
37
30
|
step(generator["throw"](value));
|
|
@@ -39,15 +32,12 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
39
32
|
reject(e);
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
function step(result) {
|
|
44
36
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
39
|
});
|
|
49
40
|
};
|
|
50
|
-
|
|
51
41
|
import * as bigInt from 'big-integer';
|
|
52
42
|
import { EncryptionType } from '../enums/encryptionType';
|
|
53
43
|
import { KdfType } from '../enums/kdfType';
|
|
@@ -68,48 +58,38 @@ var Keys = {
|
|
|
68
58
|
export var CryptoService = /*#__PURE__*/function () {
|
|
69
59
|
function CryptoService(storageService, secureStorageService, cryptoFunctionService, platformUtilService) {
|
|
70
60
|
_classCallCheck(this, CryptoService);
|
|
71
|
-
|
|
72
61
|
this.storageService = storageService;
|
|
73
62
|
this.secureStorageService = secureStorageService;
|
|
74
63
|
this.cryptoFunctionService = cryptoFunctionService;
|
|
75
64
|
this.platformUtilService = platformUtilService;
|
|
76
65
|
}
|
|
77
|
-
|
|
78
66
|
_createClass(CryptoService, [{
|
|
79
67
|
key: "setKey",
|
|
80
68
|
value: function setKey(key) {
|
|
81
69
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
82
70
|
var option, biometric;
|
|
83
71
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
84
|
-
while (1) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
case 9:
|
|
107
|
-
return _context.abrupt("return", this.secureStorageService.save(Keys.key, key.keyB64));
|
|
108
|
-
|
|
109
|
-
case 10:
|
|
110
|
-
case "end":
|
|
111
|
-
return _context.stop();
|
|
112
|
-
}
|
|
72
|
+
while (1) switch (_context.prev = _context.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
this.key = key;
|
|
75
|
+
_context.next = 3;
|
|
76
|
+
return this.storageService.get(ConstantsService.vaultTimeoutKey);
|
|
77
|
+
case 3:
|
|
78
|
+
option = _context.sent;
|
|
79
|
+
_context.next = 6;
|
|
80
|
+
return this.storageService.get(ConstantsService.biometricUnlockKey);
|
|
81
|
+
case 6:
|
|
82
|
+
biometric = _context.sent;
|
|
83
|
+
if (!(option != null && !(biometric && this.platformUtilService.supportsSecureStorage()))) {
|
|
84
|
+
_context.next = 9;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
return _context.abrupt("return");
|
|
88
|
+
case 9:
|
|
89
|
+
return _context.abrupt("return", this.secureStorageService.save(Keys.key, key.keyB64));
|
|
90
|
+
case 10:
|
|
91
|
+
case "end":
|
|
92
|
+
return _context.stop();
|
|
113
93
|
}
|
|
114
94
|
}, _callee, this);
|
|
115
95
|
}));
|
|
@@ -125,27 +105,21 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
125
105
|
value: function setEncKey(encKey) {
|
|
126
106
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
127
107
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
128
|
-
while (1) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.encKey = null;
|
|
144
|
-
|
|
145
|
-
case 5:
|
|
146
|
-
case "end":
|
|
147
|
-
return _context2.stop();
|
|
148
|
-
}
|
|
108
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
109
|
+
case 0:
|
|
110
|
+
if (!(encKey == null)) {
|
|
111
|
+
_context2.next = 2;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return _context2.abrupt("return");
|
|
115
|
+
case 2:
|
|
116
|
+
_context2.next = 4;
|
|
117
|
+
return this.storageService.save(Keys.encKey, encKey);
|
|
118
|
+
case 4:
|
|
119
|
+
this.encKey = null;
|
|
120
|
+
case 5:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context2.stop();
|
|
149
123
|
}
|
|
150
124
|
}, _callee2, this);
|
|
151
125
|
}));
|
|
@@ -155,27 +129,21 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
155
129
|
value: function setEncPrivateKey(encPrivateKey) {
|
|
156
130
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
157
131
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
158
|
-
while (1) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.privateKey = null;
|
|
174
|
-
|
|
175
|
-
case 5:
|
|
176
|
-
case "end":
|
|
177
|
-
return _context3.stop();
|
|
178
|
-
}
|
|
132
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
if (!(encPrivateKey == null)) {
|
|
135
|
+
_context3.next = 2;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
return _context3.abrupt("return");
|
|
139
|
+
case 2:
|
|
140
|
+
_context3.next = 4;
|
|
141
|
+
return this.storageService.save(Keys.encPrivateKey, encPrivateKey);
|
|
142
|
+
case 4:
|
|
143
|
+
this.privateKey = null;
|
|
144
|
+
case 5:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context3.stop();
|
|
179
147
|
}
|
|
180
148
|
}, _callee3, this);
|
|
181
149
|
}));
|
|
@@ -196,33 +164,25 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
196
164
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
197
165
|
var key;
|
|
198
166
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
199
|
-
while (1) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return _context4.abrupt("return", key == null ? null : this.key);
|
|
221
|
-
|
|
222
|
-
case 7:
|
|
223
|
-
case "end":
|
|
224
|
-
return _context4.stop();
|
|
225
|
-
}
|
|
167
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
168
|
+
case 0:
|
|
169
|
+
if (!(this.key != null)) {
|
|
170
|
+
_context4.next = 2;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
return _context4.abrupt("return", this.key);
|
|
174
|
+
case 2:
|
|
175
|
+
_context4.next = 4;
|
|
176
|
+
return this.secureStorageService.get(Keys.key);
|
|
177
|
+
case 4:
|
|
178
|
+
key = _context4.sent;
|
|
179
|
+
if (key != null) {
|
|
180
|
+
this.key = new SymmetricCryptoKey(Utils.fromB64ToArray(key).buffer);
|
|
181
|
+
}
|
|
182
|
+
return _context4.abrupt("return", key == null ? null : this.key);
|
|
183
|
+
case 7:
|
|
184
|
+
case "end":
|
|
185
|
+
return _context4.stop();
|
|
226
186
|
}
|
|
227
187
|
}, _callee4, this);
|
|
228
188
|
}));
|
|
@@ -233,33 +193,25 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
233
193
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
234
194
|
var keyHash;
|
|
235
195
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
236
|
-
while (1) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return _context5.abrupt("return", keyHash == null ? null : this.keyHash);
|
|
258
|
-
|
|
259
|
-
case 7:
|
|
260
|
-
case "end":
|
|
261
|
-
return _context5.stop();
|
|
262
|
-
}
|
|
196
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
197
|
+
case 0:
|
|
198
|
+
if (!(this.keyHash != null)) {
|
|
199
|
+
_context5.next = 2;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
return _context5.abrupt("return", this.keyHash);
|
|
203
|
+
case 2:
|
|
204
|
+
_context5.next = 4;
|
|
205
|
+
return this.storageService.get(Keys.keyHash);
|
|
206
|
+
case 4:
|
|
207
|
+
keyHash = _context5.sent;
|
|
208
|
+
if (keyHash != null) {
|
|
209
|
+
this.keyHash = keyHash;
|
|
210
|
+
}
|
|
211
|
+
return _context5.abrupt("return", keyHash == null ? null : this.keyHash);
|
|
212
|
+
case 7:
|
|
213
|
+
case "end":
|
|
214
|
+
return _context5.stop();
|
|
263
215
|
}
|
|
264
216
|
}, _callee5, this);
|
|
265
217
|
}));
|
|
@@ -271,104 +223,79 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
271
223
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
272
224
|
var encKey, decEncKey, encKeyCipher, newKey;
|
|
273
225
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
274
|
-
while (1) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
_context6.next = 10;
|
|
305
|
-
return this.getKey();
|
|
306
|
-
|
|
307
|
-
case 10:
|
|
308
|
-
key = _context6.sent;
|
|
309
|
-
|
|
310
|
-
case 11:
|
|
311
|
-
if (!(key == null)) {
|
|
312
|
-
_context6.next = 13;
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
return _context6.abrupt("return", null);
|
|
317
|
-
|
|
318
|
-
case 13:
|
|
319
|
-
encKeyCipher = new CipherString(encKey);
|
|
320
|
-
|
|
321
|
-
if (!(encKeyCipher.encryptionType === EncryptionType.AesCbc256_B64)) {
|
|
322
|
-
_context6.next = 20;
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
_context6.next = 17;
|
|
327
|
-
return this.decryptToBytes(encKeyCipher, key);
|
|
328
|
-
|
|
329
|
-
case 17:
|
|
330
|
-
decEncKey = _context6.sent;
|
|
331
|
-
_context6.next = 30;
|
|
226
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
227
|
+
case 0:
|
|
228
|
+
if (!(this.encKey != null)) {
|
|
229
|
+
_context6.next = 2;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
return _context6.abrupt("return", this.encKey);
|
|
233
|
+
case 2:
|
|
234
|
+
_context6.next = 4;
|
|
235
|
+
return this.storageService.get(Keys.encKey);
|
|
236
|
+
case 4:
|
|
237
|
+
encKey = _context6.sent;
|
|
238
|
+
if (!(encKey == null)) {
|
|
239
|
+
_context6.next = 7;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
return _context6.abrupt("return", null);
|
|
243
|
+
case 7:
|
|
244
|
+
if (!(key == null)) {
|
|
245
|
+
_context6.next = 11;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
_context6.next = 10;
|
|
249
|
+
return this.getKey();
|
|
250
|
+
case 10:
|
|
251
|
+
key = _context6.sent;
|
|
252
|
+
case 11:
|
|
253
|
+
if (!(key == null)) {
|
|
254
|
+
_context6.next = 13;
|
|
332
255
|
break;
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
_context6.next = 23;
|
|
341
|
-
return this.stretchKey(key);
|
|
342
|
-
|
|
343
|
-
case 23:
|
|
344
|
-
newKey = _context6.sent;
|
|
345
|
-
_context6.next = 26;
|
|
346
|
-
return this.decryptToBytes(encKeyCipher, newKey);
|
|
347
|
-
|
|
348
|
-
case 26:
|
|
349
|
-
decEncKey = _context6.sent;
|
|
350
|
-
_context6.next = 30;
|
|
256
|
+
}
|
|
257
|
+
return _context6.abrupt("return", null);
|
|
258
|
+
case 13:
|
|
259
|
+
encKeyCipher = new CipherString(encKey);
|
|
260
|
+
if (!(encKeyCipher.encryptionType === EncryptionType.AesCbc256_B64)) {
|
|
261
|
+
_context6.next = 20;
|
|
351
262
|
break;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
263
|
+
}
|
|
264
|
+
_context6.next = 17;
|
|
265
|
+
return this.decryptToBytes(encKeyCipher, key);
|
|
266
|
+
case 17:
|
|
267
|
+
decEncKey = _context6.sent;
|
|
268
|
+
_context6.next = 30;
|
|
269
|
+
break;
|
|
270
|
+
case 20:
|
|
271
|
+
if (!(encKeyCipher.encryptionType === EncryptionType.AesCbc256_HmacSha256_B64)) {
|
|
272
|
+
_context6.next = 29;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
_context6.next = 23;
|
|
276
|
+
return this.stretchKey(key);
|
|
277
|
+
case 23:
|
|
278
|
+
newKey = _context6.sent;
|
|
279
|
+
_context6.next = 26;
|
|
280
|
+
return this.decryptToBytes(encKeyCipher, newKey);
|
|
281
|
+
case 26:
|
|
282
|
+
decEncKey = _context6.sent;
|
|
283
|
+
_context6.next = 30;
|
|
284
|
+
break;
|
|
285
|
+
case 29:
|
|
286
|
+
throw new Error('Unsupported encKey type.');
|
|
287
|
+
case 30:
|
|
288
|
+
if (!(decEncKey == null)) {
|
|
289
|
+
_context6.next = 32;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
return _context6.abrupt("return", null);
|
|
293
|
+
case 32:
|
|
294
|
+
this.encKey = new SymmetricCryptoKey(decEncKey);
|
|
295
|
+
return _context6.abrupt("return", this.encKey);
|
|
296
|
+
case 34:
|
|
297
|
+
case "end":
|
|
298
|
+
return _context6.stop();
|
|
372
299
|
}
|
|
373
300
|
}, _callee6, this);
|
|
374
301
|
}));
|
|
@@ -379,42 +306,32 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
379
306
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
380
307
|
var privateKey;
|
|
381
308
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
382
|
-
while (1) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return this.cryptoFunctionService.rsaExtractPublicKey(privateKey);
|
|
409
|
-
|
|
410
|
-
case 9:
|
|
411
|
-
this.publicKey = _context7.sent;
|
|
412
|
-
return _context7.abrupt("return", this.publicKey);
|
|
413
|
-
|
|
414
|
-
case 11:
|
|
415
|
-
case "end":
|
|
416
|
-
return _context7.stop();
|
|
417
|
-
}
|
|
309
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
310
|
+
case 0:
|
|
311
|
+
if (!(this.publicKey != null)) {
|
|
312
|
+
_context7.next = 2;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
return _context7.abrupt("return", this.publicKey);
|
|
316
|
+
case 2:
|
|
317
|
+
_context7.next = 4;
|
|
318
|
+
return this.getPrivateKey();
|
|
319
|
+
case 4:
|
|
320
|
+
privateKey = _context7.sent;
|
|
321
|
+
if (!(privateKey == null)) {
|
|
322
|
+
_context7.next = 7;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
return _context7.abrupt("return", null);
|
|
326
|
+
case 7:
|
|
327
|
+
_context7.next = 9;
|
|
328
|
+
return this.cryptoFunctionService.rsaExtractPublicKey(privateKey);
|
|
329
|
+
case 9:
|
|
330
|
+
this.publicKey = _context7.sent;
|
|
331
|
+
return _context7.abrupt("return", this.publicKey);
|
|
332
|
+
case 11:
|
|
333
|
+
case "end":
|
|
334
|
+
return _context7.stop();
|
|
418
335
|
}
|
|
419
336
|
}, _callee7, this);
|
|
420
337
|
}));
|
|
@@ -425,42 +342,32 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
425
342
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
426
343
|
var encPrivateKey;
|
|
427
344
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
428
|
-
while (1) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return this.decryptToBytes(new CipherString(encPrivateKey), null);
|
|
455
|
-
|
|
456
|
-
case 9:
|
|
457
|
-
this.privateKey = _context8.sent;
|
|
458
|
-
return _context8.abrupt("return", this.privateKey);
|
|
459
|
-
|
|
460
|
-
case 11:
|
|
461
|
-
case "end":
|
|
462
|
-
return _context8.stop();
|
|
463
|
-
}
|
|
345
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
if (!(this.privateKey != null)) {
|
|
348
|
+
_context8.next = 2;
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
return _context8.abrupt("return", this.privateKey);
|
|
352
|
+
case 2:
|
|
353
|
+
_context8.next = 4;
|
|
354
|
+
return this.storageService.get(Keys.encPrivateKey);
|
|
355
|
+
case 4:
|
|
356
|
+
encPrivateKey = _context8.sent;
|
|
357
|
+
if (!(encPrivateKey == null)) {
|
|
358
|
+
_context8.next = 7;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
return _context8.abrupt("return", null);
|
|
362
|
+
case 7:
|
|
363
|
+
_context8.next = 9;
|
|
364
|
+
return this.decryptToBytes(new CipherString(encPrivateKey), null);
|
|
365
|
+
case 9:
|
|
366
|
+
this.privateKey = _context8.sent;
|
|
367
|
+
return _context8.abrupt("return", this.privateKey);
|
|
368
|
+
case 11:
|
|
369
|
+
case "end":
|
|
370
|
+
return _context8.stop();
|
|
464
371
|
}
|
|
465
372
|
}, _callee8, this);
|
|
466
373
|
}));
|
|
@@ -471,45 +378,35 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
471
378
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
472
379
|
var keyFingerprint, userFingerprint;
|
|
473
380
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
474
|
-
while (1) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
return this.cryptoFunctionService.hkdfExpand(keyFingerprint, userId, 32, 'sha256');
|
|
504
|
-
|
|
505
|
-
case 11:
|
|
506
|
-
userFingerprint = _context9.sent;
|
|
507
|
-
return _context9.abrupt("return", this.hashPhrase(userFingerprint));
|
|
508
|
-
|
|
509
|
-
case 13:
|
|
510
|
-
case "end":
|
|
511
|
-
return _context9.stop();
|
|
512
|
-
}
|
|
381
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
382
|
+
case 0:
|
|
383
|
+
if (!(publicKey == null)) {
|
|
384
|
+
_context9.next = 4;
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
_context9.next = 3;
|
|
388
|
+
return this.getPublicKey();
|
|
389
|
+
case 3:
|
|
390
|
+
publicKey = _context9.sent;
|
|
391
|
+
case 4:
|
|
392
|
+
if (!(publicKey === null)) {
|
|
393
|
+
_context9.next = 6;
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
throw new Error('No public key available.');
|
|
397
|
+
case 6:
|
|
398
|
+
_context9.next = 8;
|
|
399
|
+
return this.cryptoFunctionService.hash(publicKey, 'sha256');
|
|
400
|
+
case 8:
|
|
401
|
+
keyFingerprint = _context9.sent;
|
|
402
|
+
_context9.next = 11;
|
|
403
|
+
return this.cryptoFunctionService.hkdfExpand(keyFingerprint, userId, 32, 'sha256');
|
|
404
|
+
case 11:
|
|
405
|
+
userFingerprint = _context9.sent;
|
|
406
|
+
return _context9.abrupt("return", this.hashPhrase(userFingerprint));
|
|
407
|
+
case 13:
|
|
408
|
+
case "end":
|
|
409
|
+
return _context9.stop();
|
|
513
410
|
}
|
|
514
411
|
}, _callee9, this);
|
|
515
412
|
}));
|
|
@@ -520,72 +417,55 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
520
417
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
521
418
|
var encOrgKeys, orgKeys, setKey, orgId, decValue;
|
|
522
419
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
523
|
-
while (1) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
case 7:
|
|
548
|
-
orgKeys = new Map();
|
|
549
|
-
setKey = false;
|
|
550
|
-
_context10.t0 = _regeneratorRuntime.keys(encOrgKeys);
|
|
551
|
-
|
|
552
|
-
case 10:
|
|
553
|
-
if ((_context10.t1 = _context10.t0()).done) {
|
|
554
|
-
_context10.next = 21;
|
|
555
|
-
break;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
orgId = _context10.t1.value;
|
|
559
|
-
|
|
560
|
-
if (encOrgKeys.hasOwnProperty(orgId)) {
|
|
561
|
-
_context10.next = 14;
|
|
562
|
-
break;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
return _context10.abrupt("continue", 10);
|
|
566
|
-
|
|
567
|
-
case 14:
|
|
568
|
-
_context10.next = 16;
|
|
569
|
-
return this.rsaDecrypt(encOrgKeys[orgId]);
|
|
570
|
-
|
|
571
|
-
case 16:
|
|
572
|
-
decValue = _context10.sent;
|
|
573
|
-
orgKeys.set(orgId, new SymmetricCryptoKey(decValue));
|
|
574
|
-
setKey = true;
|
|
575
|
-
_context10.next = 10;
|
|
420
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
421
|
+
case 0:
|
|
422
|
+
if (!(this.orgKeys != null && this.orgKeys.size > 0)) {
|
|
423
|
+
_context10.next = 2;
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
return _context10.abrupt("return", this.orgKeys);
|
|
427
|
+
case 2:
|
|
428
|
+
_context10.next = 4;
|
|
429
|
+
return this.storageService.get(Keys.encOrgKeys);
|
|
430
|
+
case 4:
|
|
431
|
+
encOrgKeys = _context10.sent;
|
|
432
|
+
if (!(encOrgKeys == null)) {
|
|
433
|
+
_context10.next = 7;
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
return _context10.abrupt("return", null);
|
|
437
|
+
case 7:
|
|
438
|
+
orgKeys = new Map();
|
|
439
|
+
setKey = false;
|
|
440
|
+
_context10.t0 = _regeneratorRuntime.keys(encOrgKeys);
|
|
441
|
+
case 10:
|
|
442
|
+
if ((_context10.t1 = _context10.t0()).done) {
|
|
443
|
+
_context10.next = 21;
|
|
576
444
|
break;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
445
|
+
}
|
|
446
|
+
orgId = _context10.t1.value;
|
|
447
|
+
if (encOrgKeys.hasOwnProperty(orgId)) {
|
|
448
|
+
_context10.next = 14;
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
return _context10.abrupt("continue", 10);
|
|
452
|
+
case 14:
|
|
453
|
+
_context10.next = 16;
|
|
454
|
+
return this.rsaDecrypt(encOrgKeys[orgId]);
|
|
455
|
+
case 16:
|
|
456
|
+
decValue = _context10.sent;
|
|
457
|
+
orgKeys.set(orgId, new SymmetricCryptoKey(decValue));
|
|
458
|
+
setKey = true;
|
|
459
|
+
_context10.next = 10;
|
|
460
|
+
break;
|
|
461
|
+
case 21:
|
|
462
|
+
if (setKey) {
|
|
463
|
+
this.orgKeys = orgKeys;
|
|
464
|
+
}
|
|
465
|
+
return _context10.abrupt("return", this.orgKeys);
|
|
466
|
+
case 23:
|
|
467
|
+
case "end":
|
|
468
|
+
return _context10.stop();
|
|
589
469
|
}
|
|
590
470
|
}, _callee10, this);
|
|
591
471
|
}));
|
|
@@ -596,37 +476,28 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
596
476
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
597
477
|
var orgKeys;
|
|
598
478
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
599
|
-
while (1) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
return _context11.abrupt("return", null);
|
|
622
|
-
|
|
623
|
-
case 7:
|
|
624
|
-
return _context11.abrupt("return", orgKeys.get(orgId));
|
|
625
|
-
|
|
626
|
-
case 8:
|
|
627
|
-
case "end":
|
|
628
|
-
return _context11.stop();
|
|
629
|
-
}
|
|
479
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
480
|
+
case 0:
|
|
481
|
+
if (!(orgId == null)) {
|
|
482
|
+
_context11.next = 2;
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
return _context11.abrupt("return", null);
|
|
486
|
+
case 2:
|
|
487
|
+
_context11.next = 4;
|
|
488
|
+
return this.getOrgKeys();
|
|
489
|
+
case 4:
|
|
490
|
+
orgKeys = _context11.sent;
|
|
491
|
+
if (!(orgKeys == null || !orgKeys.has(orgId))) {
|
|
492
|
+
_context11.next = 7;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
return _context11.abrupt("return", null);
|
|
496
|
+
case 7:
|
|
497
|
+
return _context11.abrupt("return", orgKeys.get(orgId));
|
|
498
|
+
case 8:
|
|
499
|
+
case "end":
|
|
500
|
+
return _context11.stop();
|
|
630
501
|
}
|
|
631
502
|
}, _callee11, this);
|
|
632
503
|
}));
|
|
@@ -636,20 +507,16 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
636
507
|
value: function hasKey() {
|
|
637
508
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
638
509
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
639
|
-
while (1) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
case 4:
|
|
650
|
-
case "end":
|
|
651
|
-
return _context12.stop();
|
|
652
|
-
}
|
|
510
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
511
|
+
case 0:
|
|
512
|
+
_context12.next = 2;
|
|
513
|
+
return this.getKey();
|
|
514
|
+
case 2:
|
|
515
|
+
_context12.t0 = _context12.sent;
|
|
516
|
+
return _context12.abrupt("return", _context12.t0 != null);
|
|
517
|
+
case 4:
|
|
518
|
+
case "end":
|
|
519
|
+
return _context12.stop();
|
|
653
520
|
}
|
|
654
521
|
}, _callee12, this);
|
|
655
522
|
}));
|
|
@@ -660,20 +527,16 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
660
527
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
661
528
|
var encKey;
|
|
662
529
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
663
|
-
while (1) {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
case 4:
|
|
674
|
-
case "end":
|
|
675
|
-
return _context13.stop();
|
|
676
|
-
}
|
|
530
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
531
|
+
case 0:
|
|
532
|
+
_context13.next = 2;
|
|
533
|
+
return this.storageService.get(Keys.encKey);
|
|
534
|
+
case 2:
|
|
535
|
+
encKey = _context13.sent;
|
|
536
|
+
return _context13.abrupt("return", encKey != null);
|
|
537
|
+
case 4:
|
|
538
|
+
case "end":
|
|
539
|
+
return _context13.stop();
|
|
677
540
|
}
|
|
678
541
|
}, _callee13, this);
|
|
679
542
|
}));
|
|
@@ -694,11 +557,9 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
694
557
|
key: "clearEncKey",
|
|
695
558
|
value: function clearEncKey(memoryOnly) {
|
|
696
559
|
this.encKey = null;
|
|
697
|
-
|
|
698
560
|
if (memoryOnly) {
|
|
699
561
|
return Promise.resolve();
|
|
700
562
|
}
|
|
701
|
-
|
|
702
563
|
return this.storageService.remove(Keys.encKey);
|
|
703
564
|
}
|
|
704
565
|
}, {
|
|
@@ -706,22 +567,18 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
706
567
|
value: function clearKeyPair(memoryOnly) {
|
|
707
568
|
this.privateKey = null;
|
|
708
569
|
this.publicKey = null;
|
|
709
|
-
|
|
710
570
|
if (memoryOnly) {
|
|
711
571
|
return Promise.resolve();
|
|
712
572
|
}
|
|
713
|
-
|
|
714
573
|
return this.storageService.remove(Keys.encPrivateKey);
|
|
715
574
|
}
|
|
716
575
|
}, {
|
|
717
576
|
key: "clearOrgKeys",
|
|
718
577
|
value: function clearOrgKeys(memoryOnly) {
|
|
719
578
|
this.orgKeys = null;
|
|
720
|
-
|
|
721
579
|
if (memoryOnly) {
|
|
722
580
|
return Promise.resolve();
|
|
723
581
|
}
|
|
724
|
-
|
|
725
582
|
return this.storageService.remove(Keys.encOrgKeys);
|
|
726
583
|
}
|
|
727
584
|
}, {
|
|
@@ -740,45 +597,35 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
740
597
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
741
598
|
var key, option, biometric;
|
|
742
599
|
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
743
|
-
while (1) {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
return _context14.abrupt("return");
|
|
773
|
-
|
|
774
|
-
case 14:
|
|
775
|
-
_context14.next = 16;
|
|
776
|
-
return this.setKey(key);
|
|
777
|
-
|
|
778
|
-
case 16:
|
|
779
|
-
case "end":
|
|
780
|
-
return _context14.stop();
|
|
781
|
-
}
|
|
600
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
601
|
+
case 0:
|
|
602
|
+
_context14.next = 2;
|
|
603
|
+
return this.getKey();
|
|
604
|
+
case 2:
|
|
605
|
+
key = _context14.sent;
|
|
606
|
+
_context14.next = 5;
|
|
607
|
+
return this.storageService.get(ConstantsService.vaultTimeoutKey);
|
|
608
|
+
case 5:
|
|
609
|
+
option = _context14.sent;
|
|
610
|
+
_context14.next = 8;
|
|
611
|
+
return this.storageService.get(ConstantsService.biometricUnlockKey);
|
|
612
|
+
case 8:
|
|
613
|
+
biometric = _context14.sent;
|
|
614
|
+
if (!(!biometric && this.platformUtilService.supportsSecureStorage() && (option != null || option === 0))) {
|
|
615
|
+
_context14.next = 14;
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
_context14.next = 12;
|
|
619
|
+
return this.clearKey();
|
|
620
|
+
case 12:
|
|
621
|
+
this.key = key;
|
|
622
|
+
return _context14.abrupt("return");
|
|
623
|
+
case 14:
|
|
624
|
+
_context14.next = 16;
|
|
625
|
+
return this.setKey(key);
|
|
626
|
+
case 16:
|
|
627
|
+
case "end":
|
|
628
|
+
return _context14.stop();
|
|
782
629
|
}
|
|
783
630
|
}, _callee14, this);
|
|
784
631
|
}));
|
|
@@ -789,52 +636,40 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
789
636
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
790
637
|
var key;
|
|
791
638
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
792
|
-
while (1) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if (!(kdfIterations == null)) {
|
|
803
|
-
_context15.next = 6;
|
|
804
|
-
break;
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
kdfIterations = 5000;
|
|
808
|
-
_context15.next = 8;
|
|
639
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
640
|
+
case 0:
|
|
641
|
+
key = null;
|
|
642
|
+
if (!(kdf == null || kdf === KdfType.PBKDF2_SHA256)) {
|
|
643
|
+
_context15.next = 13;
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
if (!(kdfIterations == null)) {
|
|
647
|
+
_context15.next = 6;
|
|
809
648
|
break;
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
throw new Error('PBKDF2 iteration minimum is 5000.');
|
|
818
|
-
|
|
819
|
-
case 8:
|
|
820
|
-
_context15.next = 10;
|
|
821
|
-
return this.cryptoFunctionService.pbkdf2(password, salt, 'sha256', kdfIterations);
|
|
822
|
-
|
|
823
|
-
case 10:
|
|
824
|
-
key = _context15.sent;
|
|
825
|
-
_context15.next = 14;
|
|
649
|
+
}
|
|
650
|
+
kdfIterations = 5000;
|
|
651
|
+
_context15.next = 8;
|
|
652
|
+
break;
|
|
653
|
+
case 6:
|
|
654
|
+
if (!(kdfIterations < 5000)) {
|
|
655
|
+
_context15.next = 8;
|
|
826
656
|
break;
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
657
|
+
}
|
|
658
|
+
throw new Error('PBKDF2 iteration minimum is 5000.');
|
|
659
|
+
case 8:
|
|
660
|
+
_context15.next = 10;
|
|
661
|
+
return this.cryptoFunctionService.pbkdf2(password, salt, 'sha256', kdfIterations);
|
|
662
|
+
case 10:
|
|
663
|
+
key = _context15.sent;
|
|
664
|
+
_context15.next = 14;
|
|
665
|
+
break;
|
|
666
|
+
case 13:
|
|
667
|
+
throw new Error('Unknown Kdf.');
|
|
668
|
+
case 14:
|
|
669
|
+
return _context15.abrupt("return", new SymmetricCryptoKey(key));
|
|
670
|
+
case 15:
|
|
671
|
+
case "end":
|
|
672
|
+
return _context15.stop();
|
|
838
673
|
}
|
|
839
674
|
}, _callee15, this);
|
|
840
675
|
}));
|
|
@@ -846,47 +681,36 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
846
681
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
|
|
847
682
|
var pinProtectedKey, pinKey, decKey;
|
|
848
683
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
849
|
-
while (1) {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
_context16.next = 12;
|
|
880
|
-
return this.decryptToBytes(protectedKeyCs, pinKey);
|
|
881
|
-
|
|
882
|
-
case 12:
|
|
883
|
-
decKey = _context16.sent;
|
|
884
|
-
return _context16.abrupt("return", new SymmetricCryptoKey(decKey));
|
|
885
|
-
|
|
886
|
-
case 14:
|
|
887
|
-
case "end":
|
|
888
|
-
return _context16.stop();
|
|
889
|
-
}
|
|
684
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
685
|
+
case 0:
|
|
686
|
+
if (!(protectedKeyCs == null)) {
|
|
687
|
+
_context16.next = 7;
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
_context16.next = 3;
|
|
691
|
+
return this.storageService.get(ConstantsService.pinProtectedKey);
|
|
692
|
+
case 3:
|
|
693
|
+
pinProtectedKey = _context16.sent;
|
|
694
|
+
if (!(pinProtectedKey == null)) {
|
|
695
|
+
_context16.next = 6;
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
throw new Error('No PIN protected key found.');
|
|
699
|
+
case 6:
|
|
700
|
+
protectedKeyCs = new CipherString(pinProtectedKey);
|
|
701
|
+
case 7:
|
|
702
|
+
_context16.next = 9;
|
|
703
|
+
return this.makePinKey(pin, salt, kdf, kdfIterations);
|
|
704
|
+
case 9:
|
|
705
|
+
pinKey = _context16.sent;
|
|
706
|
+
_context16.next = 12;
|
|
707
|
+
return this.decryptToBytes(protectedKeyCs, pinKey);
|
|
708
|
+
case 12:
|
|
709
|
+
decKey = _context16.sent;
|
|
710
|
+
return _context16.abrupt("return", new SymmetricCryptoKey(decKey));
|
|
711
|
+
case 14:
|
|
712
|
+
case "end":
|
|
713
|
+
return _context16.stop();
|
|
890
714
|
}
|
|
891
715
|
}, _callee16, this);
|
|
892
716
|
}));
|
|
@@ -897,30 +721,24 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
897
721
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
|
|
898
722
|
var shareKey, publicKey, encShareKey;
|
|
899
723
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
900
|
-
while (1) {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
return _context17.abrupt("return", [encShareKey, new SymmetricCryptoKey(shareKey)]);
|
|
919
|
-
|
|
920
|
-
case 10:
|
|
921
|
-
case "end":
|
|
922
|
-
return _context17.stop();
|
|
923
|
-
}
|
|
724
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
725
|
+
case 0:
|
|
726
|
+
_context17.next = 2;
|
|
727
|
+
return this.cryptoFunctionService.randomBytes(64);
|
|
728
|
+
case 2:
|
|
729
|
+
shareKey = _context17.sent;
|
|
730
|
+
_context17.next = 5;
|
|
731
|
+
return this.getPublicKey();
|
|
732
|
+
case 5:
|
|
733
|
+
publicKey = _context17.sent;
|
|
734
|
+
_context17.next = 8;
|
|
735
|
+
return this.rsaEncrypt(shareKey, publicKey);
|
|
736
|
+
case 8:
|
|
737
|
+
encShareKey = _context17.sent;
|
|
738
|
+
return _context17.abrupt("return", [encShareKey, new SymmetricCryptoKey(shareKey)]);
|
|
739
|
+
case 10:
|
|
740
|
+
case "end":
|
|
741
|
+
return _context17.stop();
|
|
924
742
|
}
|
|
925
743
|
}, _callee17, this);
|
|
926
744
|
}));
|
|
@@ -931,26 +749,21 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
931
749
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
|
932
750
|
var keyPair, publicB64, privateEnc;
|
|
933
751
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
934
|
-
while (1) {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
case 8:
|
|
951
|
-
case "end":
|
|
952
|
-
return _context18.stop();
|
|
953
|
-
}
|
|
752
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
753
|
+
case 0:
|
|
754
|
+
_context18.next = 2;
|
|
755
|
+
return this.cryptoFunctionService.rsaGenerateKeyPair(2048);
|
|
756
|
+
case 2:
|
|
757
|
+
keyPair = _context18.sent;
|
|
758
|
+
publicB64 = Utils.fromBufferToB64(keyPair[0]);
|
|
759
|
+
_context18.next = 6;
|
|
760
|
+
return this.encrypt(keyPair[1], key);
|
|
761
|
+
case 6:
|
|
762
|
+
privateEnc = _context18.sent;
|
|
763
|
+
return _context18.abrupt("return", [publicB64, privateEnc]);
|
|
764
|
+
case 8:
|
|
765
|
+
case "end":
|
|
766
|
+
return _context18.stop();
|
|
954
767
|
}
|
|
955
768
|
}, _callee18, this);
|
|
956
769
|
}));
|
|
@@ -961,24 +774,19 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
961
774
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee19() {
|
|
962
775
|
var pinKey;
|
|
963
776
|
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
964
|
-
while (1) {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
case 6:
|
|
979
|
-
case "end":
|
|
980
|
-
return _context19.stop();
|
|
981
|
-
}
|
|
777
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
778
|
+
case 0:
|
|
779
|
+
_context19.next = 2;
|
|
780
|
+
return this.makeKey(pin, salt, kdf, kdfIterations);
|
|
781
|
+
case 2:
|
|
782
|
+
pinKey = _context19.sent;
|
|
783
|
+
_context19.next = 5;
|
|
784
|
+
return this.stretchKey(pinKey);
|
|
785
|
+
case 5:
|
|
786
|
+
return _context19.abrupt("return", _context19.sent);
|
|
787
|
+
case 6:
|
|
788
|
+
case "end":
|
|
789
|
+
return _context19.stop();
|
|
982
790
|
}
|
|
983
791
|
}, _callee19, this);
|
|
984
792
|
}));
|
|
@@ -989,20 +797,16 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
989
797
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee20() {
|
|
990
798
|
var sendKey;
|
|
991
799
|
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
992
|
-
while (1) {
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
case 4:
|
|
1003
|
-
case "end":
|
|
1004
|
-
return _context20.stop();
|
|
1005
|
-
}
|
|
800
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
801
|
+
case 0:
|
|
802
|
+
_context20.next = 2;
|
|
803
|
+
return this.cryptoFunctionService.hkdf(keyMaterial, 'bitwarden-send', 'send', 64, 'sha256');
|
|
804
|
+
case 2:
|
|
805
|
+
sendKey = _context20.sent;
|
|
806
|
+
return _context20.abrupt("return", new SymmetricCryptoKey(sendKey));
|
|
807
|
+
case 4:
|
|
808
|
+
case "end":
|
|
809
|
+
return _context20.stop();
|
|
1006
810
|
}
|
|
1007
811
|
}, _callee20, this);
|
|
1008
812
|
}));
|
|
@@ -1013,40 +817,31 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1013
817
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
|
|
1014
818
|
var hash;
|
|
1015
819
|
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1016
|
-
while (1) {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
case 8:
|
|
1043
|
-
hash = _context21.sent;
|
|
1044
|
-
return _context21.abrupt("return", Utils.fromBufferToB64(hash));
|
|
1045
|
-
|
|
1046
|
-
case 10:
|
|
1047
|
-
case "end":
|
|
1048
|
-
return _context21.stop();
|
|
1049
|
-
}
|
|
820
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
821
|
+
case 0:
|
|
822
|
+
if (!(key == null)) {
|
|
823
|
+
_context21.next = 4;
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
_context21.next = 3;
|
|
827
|
+
return this.getKey();
|
|
828
|
+
case 3:
|
|
829
|
+
key = _context21.sent;
|
|
830
|
+
case 4:
|
|
831
|
+
if (!(password == null || key == null)) {
|
|
832
|
+
_context21.next = 6;
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
throw new Error('Invalid parameters.');
|
|
836
|
+
case 6:
|
|
837
|
+
_context21.next = 8;
|
|
838
|
+
return this.cryptoFunctionService.pbkdf2(key.key, password, 'sha256', 1);
|
|
839
|
+
case 8:
|
|
840
|
+
hash = _context21.sent;
|
|
841
|
+
return _context21.abrupt("return", Utils.fromBufferToB64(hash));
|
|
842
|
+
case 10:
|
|
843
|
+
case "end":
|
|
844
|
+
return _context21.stop();
|
|
1050
845
|
}
|
|
1051
846
|
}, _callee21, this);
|
|
1052
847
|
}));
|
|
@@ -1057,25 +852,20 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1057
852
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee22() {
|
|
1058
853
|
var theKey, encKey;
|
|
1059
854
|
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1060
|
-
while (1) {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
case 7:
|
|
1076
|
-
case "end":
|
|
1077
|
-
return _context22.stop();
|
|
1078
|
-
}
|
|
855
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
856
|
+
case 0:
|
|
857
|
+
_context22.next = 2;
|
|
858
|
+
return this.getKeyForEncryption(key);
|
|
859
|
+
case 2:
|
|
860
|
+
theKey = _context22.sent;
|
|
861
|
+
_context22.next = 5;
|
|
862
|
+
return this.cryptoFunctionService.randomBytes(64);
|
|
863
|
+
case 5:
|
|
864
|
+
encKey = _context22.sent;
|
|
865
|
+
return _context22.abrupt("return", this.buildEncKey(theKey, encKey));
|
|
866
|
+
case 7:
|
|
867
|
+
case "end":
|
|
868
|
+
return _context22.stop();
|
|
1079
869
|
}
|
|
1080
870
|
}, _callee22, this);
|
|
1081
871
|
}));
|
|
@@ -1086,20 +876,16 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1086
876
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee23() {
|
|
1087
877
|
var encKey;
|
|
1088
878
|
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1089
|
-
while (1) {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
case 4:
|
|
1100
|
-
case "end":
|
|
1101
|
-
return _context23.stop();
|
|
1102
|
-
}
|
|
879
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
880
|
+
case 0:
|
|
881
|
+
_context23.next = 2;
|
|
882
|
+
return this.getEncKey();
|
|
883
|
+
case 2:
|
|
884
|
+
encKey = _context23.sent;
|
|
885
|
+
return _context23.abrupt("return", this.buildEncKey(key, encKey.key));
|
|
886
|
+
case 4:
|
|
887
|
+
case "end":
|
|
888
|
+
return _context23.stop();
|
|
1103
889
|
}
|
|
1104
890
|
}, _callee23, this);
|
|
1105
891
|
}));
|
|
@@ -1110,37 +896,30 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1110
896
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee24() {
|
|
1111
897
|
var plainBuf, encObj, iv, data, mac;
|
|
1112
898
|
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1113
|
-
while (1) {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
mac = encObj.mac != null ? Utils.fromBufferToB64(encObj.mac) : null;
|
|
1138
|
-
return _context24.abrupt("return", new CipherString(encObj.key.encType, data, iv, mac));
|
|
1139
|
-
|
|
1140
|
-
case 10:
|
|
1141
|
-
case "end":
|
|
1142
|
-
return _context24.stop();
|
|
1143
|
-
}
|
|
899
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
900
|
+
case 0:
|
|
901
|
+
if (!(plainValue == null)) {
|
|
902
|
+
_context24.next = 2;
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
return _context24.abrupt("return", Promise.resolve(null));
|
|
906
|
+
case 2:
|
|
907
|
+
if (typeof plainValue === 'string') {
|
|
908
|
+
plainBuf = Utils.fromUtf8ToArray(plainValue).buffer;
|
|
909
|
+
} else {
|
|
910
|
+
plainBuf = plainValue;
|
|
911
|
+
}
|
|
912
|
+
_context24.next = 5;
|
|
913
|
+
return this.aesEncrypt(plainBuf, key);
|
|
914
|
+
case 5:
|
|
915
|
+
encObj = _context24.sent;
|
|
916
|
+
iv = Utils.fromBufferToB64(encObj.iv);
|
|
917
|
+
data = Utils.fromBufferToB64(encObj.data);
|
|
918
|
+
mac = encObj.mac != null ? Utils.fromBufferToB64(encObj.mac) : null;
|
|
919
|
+
return _context24.abrupt("return", new CipherString(encObj.key.encType, data, iv, mac));
|
|
920
|
+
case 10:
|
|
921
|
+
case "end":
|
|
922
|
+
return _context24.stop();
|
|
1144
923
|
}
|
|
1145
924
|
}, _callee24, this);
|
|
1146
925
|
}));
|
|
@@ -1151,35 +930,27 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1151
930
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
|
|
1152
931
|
var encValue, macLen, encBytes;
|
|
1153
932
|
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
1154
|
-
while (1) {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
macLen =
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
encBytes
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
encBytes.set(new Uint8Array(encValue.data), 1 + encValue.iv.byteLength + macLen);
|
|
1177
|
-
return _context25.abrupt("return", encBytes.buffer);
|
|
1178
|
-
|
|
1179
|
-
case 11:
|
|
1180
|
-
case "end":
|
|
1181
|
-
return _context25.stop();
|
|
1182
|
-
}
|
|
933
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
934
|
+
case 0:
|
|
935
|
+
_context25.next = 2;
|
|
936
|
+
return this.aesEncrypt(plainValue, key);
|
|
937
|
+
case 2:
|
|
938
|
+
encValue = _context25.sent;
|
|
939
|
+
macLen = 0;
|
|
940
|
+
if (encValue.mac != null) {
|
|
941
|
+
macLen = encValue.mac.byteLength;
|
|
942
|
+
}
|
|
943
|
+
encBytes = new Uint8Array(1 + encValue.iv.byteLength + macLen + encValue.data.byteLength);
|
|
944
|
+
encBytes.set([encValue.key.encType]);
|
|
945
|
+
encBytes.set(new Uint8Array(encValue.iv), 1);
|
|
946
|
+
if (encValue.mac != null) {
|
|
947
|
+
encBytes.set(new Uint8Array(encValue.mac), 1 + encValue.iv.byteLength);
|
|
948
|
+
}
|
|
949
|
+
encBytes.set(new Uint8Array(encValue.data), 1 + encValue.iv.byteLength + macLen);
|
|
950
|
+
return _context25.abrupt("return", encBytes.buffer);
|
|
951
|
+
case 11:
|
|
952
|
+
case "end":
|
|
953
|
+
return _context25.stop();
|
|
1183
954
|
}
|
|
1184
955
|
}, _callee25, this);
|
|
1185
956
|
}));
|
|
@@ -1190,40 +961,31 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1190
961
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee26() {
|
|
1191
962
|
var encBytes;
|
|
1192
963
|
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
1193
|
-
while (1) {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
case 8:
|
|
1220
|
-
encBytes = _context26.sent;
|
|
1221
|
-
return _context26.abrupt("return", new CipherString(EncryptionType.Rsa2048_OaepSha1_B64, Utils.fromBufferToB64(encBytes)));
|
|
1222
|
-
|
|
1223
|
-
case 10:
|
|
1224
|
-
case "end":
|
|
1225
|
-
return _context26.stop();
|
|
1226
|
-
}
|
|
964
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
965
|
+
case 0:
|
|
966
|
+
if (!(publicKey == null)) {
|
|
967
|
+
_context26.next = 4;
|
|
968
|
+
break;
|
|
969
|
+
}
|
|
970
|
+
_context26.next = 3;
|
|
971
|
+
return this.getPublicKey();
|
|
972
|
+
case 3:
|
|
973
|
+
publicKey = _context26.sent;
|
|
974
|
+
case 4:
|
|
975
|
+
if (!(publicKey == null)) {
|
|
976
|
+
_context26.next = 6;
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
throw new Error('Public key unavailable.');
|
|
980
|
+
case 6:
|
|
981
|
+
_context26.next = 8;
|
|
982
|
+
return this.cryptoFunctionService.rsaEncrypt(data, publicKey, 'sha1');
|
|
983
|
+
case 8:
|
|
984
|
+
encBytes = _context26.sent;
|
|
985
|
+
return _context26.abrupt("return", new CipherString(EncryptionType.Rsa2048_OaepSha1_B64, Utils.fromBufferToB64(encBytes)));
|
|
986
|
+
case 10:
|
|
987
|
+
case "end":
|
|
988
|
+
return _context26.stop();
|
|
1227
989
|
}
|
|
1228
990
|
}, _callee26, this);
|
|
1229
991
|
}));
|
|
@@ -1234,32 +996,25 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1234
996
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee27() {
|
|
1235
997
|
var iv, data, mac, decipher;
|
|
1236
998
|
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
1237
|
-
while (1) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
case 8:
|
|
1257
|
-
return _context27.abrupt("return", decipher);
|
|
1258
|
-
|
|
1259
|
-
case 9:
|
|
1260
|
-
case "end":
|
|
1261
|
-
return _context27.stop();
|
|
1262
|
-
}
|
|
999
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1000
|
+
case 0:
|
|
1001
|
+
iv = Utils.fromB64ToArray(cipherString.iv).buffer;
|
|
1002
|
+
data = Utils.fromB64ToArray(cipherString.data).buffer;
|
|
1003
|
+
mac = cipherString.mac ? Utils.fromB64ToArray(cipherString.mac).buffer : null;
|
|
1004
|
+
_context27.next = 5;
|
|
1005
|
+
return this.aesDecryptToBytes(cipherString.encryptionType, data, iv, mac, key);
|
|
1006
|
+
case 5:
|
|
1007
|
+
decipher = _context27.sent;
|
|
1008
|
+
if (!(decipher == null)) {
|
|
1009
|
+
_context27.next = 8;
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
return _context27.abrupt("return", null);
|
|
1013
|
+
case 8:
|
|
1014
|
+
return _context27.abrupt("return", decipher);
|
|
1015
|
+
case 9:
|
|
1016
|
+
case "end":
|
|
1017
|
+
return _context27.stop();
|
|
1263
1018
|
}
|
|
1264
1019
|
}, _callee27, this);
|
|
1265
1020
|
}));
|
|
@@ -1269,19 +1024,15 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1269
1024
|
value: function decryptToUtf8(cipherString, key) {
|
|
1270
1025
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee28() {
|
|
1271
1026
|
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
1272
|
-
while (1) {
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
case 3:
|
|
1282
|
-
case "end":
|
|
1283
|
-
return _context28.stop();
|
|
1284
|
-
}
|
|
1027
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1028
|
+
case 0:
|
|
1029
|
+
_context28.next = 2;
|
|
1030
|
+
return this.aesDecryptToUtf8(cipherString.encryptionType, cipherString.data, cipherString.iv, cipherString.mac, key);
|
|
1031
|
+
case 2:
|
|
1032
|
+
return _context28.abrupt("return", _context28.sent);
|
|
1033
|
+
case 3:
|
|
1034
|
+
case "end":
|
|
1035
|
+
return _context28.stop();
|
|
1285
1036
|
}
|
|
1286
1037
|
}, _callee28, this);
|
|
1287
1038
|
}));
|
|
@@ -1292,182 +1043,145 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1292
1043
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee29() {
|
|
1293
1044
|
var encBytes, encType, ctBytes, ivBytes, macBytes;
|
|
1294
1045
|
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
1295
|
-
while (1) {
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1046
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1047
|
+
case 0:
|
|
1048
|
+
if (!(encBuf == null)) {
|
|
1049
|
+
_context29.next = 2;
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
throw new Error('no encBuf.');
|
|
1053
|
+
case 2:
|
|
1054
|
+
encBytes = new Uint8Array(encBuf);
|
|
1055
|
+
encType = encBytes[0];
|
|
1056
|
+
ctBytes = null;
|
|
1057
|
+
ivBytes = null;
|
|
1058
|
+
macBytes = null;
|
|
1059
|
+
_context29.t0 = encType;
|
|
1060
|
+
_context29.next = _context29.t0 === EncryptionType.AesCbc128_HmacSha256_B64 ? 10 : _context29.t0 === EncryptionType.AesCbc256_HmacSha256_B64 ? 10 : _context29.t0 === EncryptionType.AesCbc256_B64 ? 16 : 21;
|
|
1061
|
+
break;
|
|
1062
|
+
case 10:
|
|
1063
|
+
if (!(encBytes.length <= 49)) {
|
|
1064
|
+
_context29.next = 12;
|
|
1313
1065
|
break;
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
case 21:
|
|
1343
|
-
return _context29.abrupt("return", null);
|
|
1344
|
-
|
|
1345
|
-
case 22:
|
|
1346
|
-
_context29.next = 24;
|
|
1347
|
-
return this.aesDecryptToBytes(encType, ctBytes.buffer, ivBytes.buffer, macBytes != null ? macBytes.buffer : null, key);
|
|
1348
|
-
|
|
1349
|
-
case 24:
|
|
1350
|
-
return _context29.abrupt("return", _context29.sent);
|
|
1351
|
-
|
|
1352
|
-
case 25:
|
|
1353
|
-
case "end":
|
|
1354
|
-
return _context29.stop();
|
|
1355
|
-
}
|
|
1066
|
+
}
|
|
1067
|
+
return _context29.abrupt("return", null);
|
|
1068
|
+
case 12:
|
|
1069
|
+
ivBytes = encBytes.slice(1, 17);
|
|
1070
|
+
macBytes = encBytes.slice(17, 49);
|
|
1071
|
+
ctBytes = encBytes.slice(49);
|
|
1072
|
+
return _context29.abrupt("break", 22);
|
|
1073
|
+
case 16:
|
|
1074
|
+
if (!(encBytes.length <= 17)) {
|
|
1075
|
+
_context29.next = 18;
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
return _context29.abrupt("return", null);
|
|
1079
|
+
case 18:
|
|
1080
|
+
ivBytes = encBytes.slice(1, 17);
|
|
1081
|
+
ctBytes = encBytes.slice(17);
|
|
1082
|
+
return _context29.abrupt("break", 22);
|
|
1083
|
+
case 21:
|
|
1084
|
+
return _context29.abrupt("return", null);
|
|
1085
|
+
case 22:
|
|
1086
|
+
_context29.next = 24;
|
|
1087
|
+
return this.aesDecryptToBytes(encType, ctBytes.buffer, ivBytes.buffer, macBytes != null ? macBytes.buffer : null, key);
|
|
1088
|
+
case 24:
|
|
1089
|
+
return _context29.abrupt("return", _context29.sent);
|
|
1090
|
+
case 25:
|
|
1091
|
+
case "end":
|
|
1092
|
+
return _context29.stop();
|
|
1356
1093
|
}
|
|
1357
1094
|
}, _callee29, this);
|
|
1358
1095
|
}));
|
|
1359
|
-
}
|
|
1096
|
+
}
|
|
1097
|
+
// EFForg/OpenWireless
|
|
1360
1098
|
// ref https://github.com/EFForg/OpenWireless/blob/master/app/js/diceware.js
|
|
1361
|
-
|
|
1362
1099
|
}, {
|
|
1363
1100
|
key: "randomNumber",
|
|
1364
1101
|
value: function randomNumber(min, max) {
|
|
1365
1102
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
|
|
1366
1103
|
var rval, range, bitsNeeded, bytesNeeded, mask, byteArray, p, i;
|
|
1367
1104
|
return _regeneratorRuntime.wrap(function _callee30$(_context30) {
|
|
1368
|
-
while (1) {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
_context30.next = 17;
|
|
1407
|
-
break;
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
return _context30.abrupt("return", this.randomNumber(min, max));
|
|
1411
|
-
|
|
1412
|
-
case 17:
|
|
1413
|
-
return _context30.abrupt("return", min + rval);
|
|
1414
|
-
|
|
1415
|
-
case 18:
|
|
1416
|
-
case "end":
|
|
1417
|
-
return _context30.stop();
|
|
1418
|
-
}
|
|
1105
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
1106
|
+
case 0:
|
|
1107
|
+
rval = 0;
|
|
1108
|
+
range = max - min + 1;
|
|
1109
|
+
bitsNeeded = Math.ceil(Math.log2(range));
|
|
1110
|
+
if (!(bitsNeeded > 53)) {
|
|
1111
|
+
_context30.next = 5;
|
|
1112
|
+
break;
|
|
1113
|
+
}
|
|
1114
|
+
throw new Error('We cannot generate numbers larger than 53 bits.');
|
|
1115
|
+
case 5:
|
|
1116
|
+
bytesNeeded = Math.ceil(bitsNeeded / 8);
|
|
1117
|
+
mask = Math.pow(2, bitsNeeded) - 1; // 7776 -> (2^13 = 8192) -1 == 8191 or 0x00001111 11111111
|
|
1118
|
+
// Fill a byte array with N random numbers
|
|
1119
|
+
_context30.t0 = Uint8Array;
|
|
1120
|
+
_context30.next = 10;
|
|
1121
|
+
return this.cryptoFunctionService.randomBytes(bytesNeeded);
|
|
1122
|
+
case 10:
|
|
1123
|
+
_context30.t1 = _context30.sent;
|
|
1124
|
+
byteArray = new _context30.t0(_context30.t1);
|
|
1125
|
+
p = (bytesNeeded - 1) * 8;
|
|
1126
|
+
for (i = 0; i < bytesNeeded; i++) {
|
|
1127
|
+
rval += byteArray[i] * Math.pow(2, p);
|
|
1128
|
+
p -= 8;
|
|
1129
|
+
}
|
|
1130
|
+
// Use & to apply the mask and reduce the number of recursive lookups
|
|
1131
|
+
// tslint:disable-next-line
|
|
1132
|
+
rval = rval & mask;
|
|
1133
|
+
if (!(rval >= range)) {
|
|
1134
|
+
_context30.next = 17;
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
return _context30.abrupt("return", this.randomNumber(min, max));
|
|
1138
|
+
case 17:
|
|
1139
|
+
return _context30.abrupt("return", min + rval);
|
|
1140
|
+
case 18:
|
|
1141
|
+
case "end":
|
|
1142
|
+
return _context30.stop();
|
|
1419
1143
|
}
|
|
1420
1144
|
}, _callee30, this);
|
|
1421
1145
|
}));
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1146
|
+
}
|
|
1147
|
+
// Helpers
|
|
1424
1148
|
}, {
|
|
1425
1149
|
key: "aesEncrypt",
|
|
1426
1150
|
value: function aesEncrypt(data, key) {
|
|
1427
1151
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
|
|
1428
1152
|
var obj, macData;
|
|
1429
1153
|
return _regeneratorRuntime.wrap(function _callee31$(_context31) {
|
|
1430
|
-
while (1) {
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
case 16:
|
|
1462
|
-
obj.mac = _context31.sent;
|
|
1463
|
-
|
|
1464
|
-
case 17:
|
|
1465
|
-
return _context31.abrupt("return", obj);
|
|
1466
|
-
|
|
1467
|
-
case 18:
|
|
1468
|
-
case "end":
|
|
1469
|
-
return _context31.stop();
|
|
1470
|
-
}
|
|
1154
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
1155
|
+
case 0:
|
|
1156
|
+
obj = new EncryptedObject();
|
|
1157
|
+
_context31.next = 3;
|
|
1158
|
+
return this.getKeyForEncryption(key);
|
|
1159
|
+
case 3:
|
|
1160
|
+
obj.key = _context31.sent;
|
|
1161
|
+
_context31.next = 6;
|
|
1162
|
+
return this.cryptoFunctionService.randomBytes(16);
|
|
1163
|
+
case 6:
|
|
1164
|
+
obj.iv = _context31.sent;
|
|
1165
|
+
_context31.next = 9;
|
|
1166
|
+
return this.cryptoFunctionService.aesEncrypt(data, obj.iv, obj.key.encKey);
|
|
1167
|
+
case 9:
|
|
1168
|
+
obj.data = _context31.sent;
|
|
1169
|
+
if (!(obj.key.macKey != null)) {
|
|
1170
|
+
_context31.next = 17;
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
macData = new Uint8Array(obj.iv.byteLength + obj.data.byteLength);
|
|
1174
|
+
macData.set(new Uint8Array(obj.iv), 0);
|
|
1175
|
+
macData.set(new Uint8Array(obj.data), obj.iv.byteLength);
|
|
1176
|
+
_context31.next = 16;
|
|
1177
|
+
return this.cryptoFunctionService.hmac(macData.buffer, obj.key.macKey, 'sha256');
|
|
1178
|
+
case 16:
|
|
1179
|
+
obj.mac = _context31.sent;
|
|
1180
|
+
case 17:
|
|
1181
|
+
return _context31.abrupt("return", obj);
|
|
1182
|
+
case 18:
|
|
1183
|
+
case "end":
|
|
1184
|
+
return _context31.stop();
|
|
1471
1185
|
}
|
|
1472
1186
|
}, _callee31, this);
|
|
1473
1187
|
}));
|
|
@@ -1478,70 +1192,54 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1478
1192
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee32() {
|
|
1479
1193
|
var keyForEnc, theKey, fastParams, computedMac, macsEqual;
|
|
1480
1194
|
return _regeneratorRuntime.wrap(function _callee32$(_context32) {
|
|
1481
|
-
while (1) {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
_context32.next =
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
if (macsEqual) {
|
|
1530
|
-
_context32.next = 21;
|
|
1531
|
-
break;
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
// tslint:disable-next-line
|
|
1535
|
-
console.error('mac failed.');
|
|
1536
|
-
return _context32.abrupt("return", null);
|
|
1537
|
-
|
|
1538
|
-
case 21:
|
|
1539
|
-
return _context32.abrupt("return", this.cryptoFunctionService.aesDecryptFast(fastParams));
|
|
1540
|
-
|
|
1541
|
-
case 22:
|
|
1542
|
-
case "end":
|
|
1543
|
-
return _context32.stop();
|
|
1544
|
-
}
|
|
1195
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
1196
|
+
case 0:
|
|
1197
|
+
_context32.next = 2;
|
|
1198
|
+
return this.getKeyForEncryption(key);
|
|
1199
|
+
case 2:
|
|
1200
|
+
keyForEnc = _context32.sent;
|
|
1201
|
+
theKey = this.resolveLegacyKey(encType, keyForEnc);
|
|
1202
|
+
if (!(theKey.macKey != null && mac == null)) {
|
|
1203
|
+
_context32.next = 7;
|
|
1204
|
+
break;
|
|
1205
|
+
}
|
|
1206
|
+
// tslint:disable-next-line
|
|
1207
|
+
console.error('mac required.');
|
|
1208
|
+
return _context32.abrupt("return", null);
|
|
1209
|
+
case 7:
|
|
1210
|
+
if (!(theKey.encType !== encType)) {
|
|
1211
|
+
_context32.next = 10;
|
|
1212
|
+
break;
|
|
1213
|
+
}
|
|
1214
|
+
// tslint:disable-next-line
|
|
1215
|
+
console.error('encType unavailable.');
|
|
1216
|
+
return _context32.abrupt("return", null);
|
|
1217
|
+
case 10:
|
|
1218
|
+
fastParams = this.cryptoFunctionService.aesDecryptFastParameters(data, iv, mac, theKey);
|
|
1219
|
+
if (!(fastParams.macKey != null && fastParams.mac != null)) {
|
|
1220
|
+
_context32.next = 21;
|
|
1221
|
+
break;
|
|
1222
|
+
}
|
|
1223
|
+
_context32.next = 14;
|
|
1224
|
+
return this.cryptoFunctionService.hmacFast(fastParams.macData, fastParams.macKey, 'sha256');
|
|
1225
|
+
case 14:
|
|
1226
|
+
computedMac = _context32.sent;
|
|
1227
|
+
_context32.next = 17;
|
|
1228
|
+
return this.cryptoFunctionService.compareFast(fastParams.mac, computedMac);
|
|
1229
|
+
case 17:
|
|
1230
|
+
macsEqual = _context32.sent;
|
|
1231
|
+
if (macsEqual) {
|
|
1232
|
+
_context32.next = 21;
|
|
1233
|
+
break;
|
|
1234
|
+
}
|
|
1235
|
+
// tslint:disable-next-line
|
|
1236
|
+
console.error('mac failed.');
|
|
1237
|
+
return _context32.abrupt("return", null);
|
|
1238
|
+
case 21:
|
|
1239
|
+
return _context32.abrupt("return", this.cryptoFunctionService.aesDecryptFast(fastParams));
|
|
1240
|
+
case 22:
|
|
1241
|
+
case "end":
|
|
1242
|
+
return _context32.stop();
|
|
1545
1243
|
}
|
|
1546
1244
|
}, _callee32, this);
|
|
1547
1245
|
}));
|
|
@@ -1552,80 +1250,61 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1552
1250
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee33() {
|
|
1553
1251
|
var keyForEnc, theKey, macData, computedMac, macsMatch;
|
|
1554
1252
|
return _regeneratorRuntime.wrap(function _callee33$(_context33) {
|
|
1555
|
-
while (1) {
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
_context33.next = 23;
|
|
1611
|
-
break;
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
// tslint:disable-next-line
|
|
1615
|
-
console.error('mac failed.');
|
|
1616
|
-
return _context33.abrupt("return", null);
|
|
1617
|
-
|
|
1618
|
-
case 23:
|
|
1619
|
-
_context33.next = 25;
|
|
1620
|
-
return this.cryptoFunctionService.aesDecrypt(data, iv, theKey.encKey);
|
|
1621
|
-
|
|
1622
|
-
case 25:
|
|
1623
|
-
return _context33.abrupt("return", _context33.sent);
|
|
1624
|
-
|
|
1625
|
-
case 26:
|
|
1626
|
-
case "end":
|
|
1627
|
-
return _context33.stop();
|
|
1628
|
-
}
|
|
1253
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
1254
|
+
case 0:
|
|
1255
|
+
_context33.next = 2;
|
|
1256
|
+
return this.getKeyForEncryption(key);
|
|
1257
|
+
case 2:
|
|
1258
|
+
keyForEnc = _context33.sent;
|
|
1259
|
+
theKey = this.resolveLegacyKey(encType, keyForEnc);
|
|
1260
|
+
if (!(theKey.macKey != null && mac == null)) {
|
|
1261
|
+
_context33.next = 6;
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
return _context33.abrupt("return", null);
|
|
1265
|
+
case 6:
|
|
1266
|
+
if (!(theKey.encType !== encType)) {
|
|
1267
|
+
_context33.next = 8;
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
return _context33.abrupt("return", null);
|
|
1271
|
+
case 8:
|
|
1272
|
+
if (!(theKey.macKey != null && mac != null)) {
|
|
1273
|
+
_context33.next = 23;
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
macData = new Uint8Array(iv.byteLength + data.byteLength);
|
|
1277
|
+
macData.set(new Uint8Array(iv), 0);
|
|
1278
|
+
macData.set(new Uint8Array(data), iv.byteLength);
|
|
1279
|
+
_context33.next = 14;
|
|
1280
|
+
return this.cryptoFunctionService.hmac(macData.buffer, theKey.macKey, 'sha256');
|
|
1281
|
+
case 14:
|
|
1282
|
+
computedMac = _context33.sent;
|
|
1283
|
+
if (!(computedMac === null)) {
|
|
1284
|
+
_context33.next = 17;
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
return _context33.abrupt("return", null);
|
|
1288
|
+
case 17:
|
|
1289
|
+
_context33.next = 19;
|
|
1290
|
+
return this.cryptoFunctionService.compare(mac, computedMac);
|
|
1291
|
+
case 19:
|
|
1292
|
+
macsMatch = _context33.sent;
|
|
1293
|
+
if (macsMatch) {
|
|
1294
|
+
_context33.next = 23;
|
|
1295
|
+
break;
|
|
1296
|
+
}
|
|
1297
|
+
// tslint:disable-next-line
|
|
1298
|
+
console.error('mac failed.');
|
|
1299
|
+
return _context33.abrupt("return", null);
|
|
1300
|
+
case 23:
|
|
1301
|
+
_context33.next = 25;
|
|
1302
|
+
return this.cryptoFunctionService.aesDecrypt(data, iv, theKey.encKey);
|
|
1303
|
+
case 25:
|
|
1304
|
+
return _context33.abrupt("return", _context33.sent);
|
|
1305
|
+
case 26:
|
|
1306
|
+
case "end":
|
|
1307
|
+
return _context33.stop();
|
|
1629
1308
|
}
|
|
1630
1309
|
}, _callee33, this);
|
|
1631
1310
|
}));
|
|
@@ -1636,78 +1315,60 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1636
1315
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee34() {
|
|
1637
1316
|
var headerPieces, encType, encPieces, data, privateKey, alg;
|
|
1638
1317
|
return _regeneratorRuntime.wrap(function _callee34$(_context34) {
|
|
1639
|
-
while (1) {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1318
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
1319
|
+
case 0:
|
|
1320
|
+
headerPieces = encValue.split('.');
|
|
1321
|
+
encType = null;
|
|
1322
|
+
if (headerPieces.length === 1) {
|
|
1323
|
+
encType = EncryptionType.Rsa2048_OaepSha256_B64;
|
|
1324
|
+
encPieces = [headerPieces[0]];
|
|
1325
|
+
} else if (headerPieces.length === 2) {
|
|
1326
|
+
try {
|
|
1327
|
+
encType = parseInt(headerPieces[0], null);
|
|
1328
|
+
encPieces = headerPieces[1].split('|');
|
|
1329
|
+
} catch (e) {}
|
|
1330
|
+
}
|
|
1331
|
+
_context34.t0 = encType;
|
|
1332
|
+
_context34.next = _context34.t0 === EncryptionType.Rsa2048_OaepSha256_B64 ? 6 : _context34.t0 === EncryptionType.Rsa2048_OaepSha1_B64 ? 6 : _context34.t0 === EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64 ? 6 : _context34.t0 === EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64 ? 6 : 7;
|
|
1333
|
+
break;
|
|
1334
|
+
case 6:
|
|
1335
|
+
return _context34.abrupt("break", 8);
|
|
1336
|
+
case 7:
|
|
1337
|
+
throw new Error('encType unavailable.');
|
|
1338
|
+
case 8:
|
|
1339
|
+
if (!(encPieces == null || encPieces.length <= 0)) {
|
|
1340
|
+
_context34.next = 10;
|
|
1657
1341
|
break;
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
break;
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
throw new Error('encPieces unavailable.');
|
|
1672
|
-
|
|
1673
|
-
case 10:
|
|
1674
|
-
data = Utils.fromB64ToArray(encPieces[0]).buffer;
|
|
1675
|
-
_context34.next = 13;
|
|
1676
|
-
return this.getPrivateKey();
|
|
1677
|
-
|
|
1678
|
-
case 13:
|
|
1679
|
-
privateKey = _context34.sent;
|
|
1680
|
-
|
|
1681
|
-
if (!(privateKey == null)) {
|
|
1682
|
-
_context34.next = 16;
|
|
1683
|
-
break;
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
throw new Error('No private key.');
|
|
1687
|
-
|
|
1688
|
-
case 16:
|
|
1689
|
-
alg = 'sha1';
|
|
1690
|
-
_context34.t1 = encType;
|
|
1691
|
-
_context34.next = _context34.t1 === EncryptionType.Rsa2048_OaepSha256_B64 ? 20 : _context34.t1 === EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64 ? 20 : _context34.t1 === EncryptionType.Rsa2048_OaepSha1_B64 ? 22 : _context34.t1 === EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64 ? 22 : 23;
|
|
1342
|
+
}
|
|
1343
|
+
throw new Error('encPieces unavailable.');
|
|
1344
|
+
case 10:
|
|
1345
|
+
data = Utils.fromB64ToArray(encPieces[0]).buffer;
|
|
1346
|
+
_context34.next = 13;
|
|
1347
|
+
return this.getPrivateKey();
|
|
1348
|
+
case 13:
|
|
1349
|
+
privateKey = _context34.sent;
|
|
1350
|
+
if (!(privateKey == null)) {
|
|
1351
|
+
_context34.next = 16;
|
|
1692
1352
|
break;
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1353
|
+
}
|
|
1354
|
+
throw new Error('No private key.');
|
|
1355
|
+
case 16:
|
|
1356
|
+
alg = 'sha1';
|
|
1357
|
+
_context34.t1 = encType;
|
|
1358
|
+
_context34.next = _context34.t1 === EncryptionType.Rsa2048_OaepSha256_B64 ? 20 : _context34.t1 === EncryptionType.Rsa2048_OaepSha256_HmacSha256_B64 ? 20 : _context34.t1 === EncryptionType.Rsa2048_OaepSha1_B64 ? 22 : _context34.t1 === EncryptionType.Rsa2048_OaepSha1_HmacSha256_B64 ? 22 : 23;
|
|
1359
|
+
break;
|
|
1360
|
+
case 20:
|
|
1361
|
+
alg = 'sha256';
|
|
1362
|
+
return _context34.abrupt("break", 24);
|
|
1363
|
+
case 22:
|
|
1364
|
+
return _context34.abrupt("break", 24);
|
|
1365
|
+
case 23:
|
|
1366
|
+
throw new Error('encType unavailable.');
|
|
1367
|
+
case 24:
|
|
1368
|
+
return _context34.abrupt("return", this.cryptoFunctionService.rsaDecrypt(data, privateKey, alg));
|
|
1369
|
+
case 25:
|
|
1370
|
+
case "end":
|
|
1371
|
+
return _context34.stop();
|
|
1711
1372
|
}
|
|
1712
1373
|
}, _callee34, this);
|
|
1713
1374
|
}));
|
|
@@ -1718,41 +1379,31 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1718
1379
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee35() {
|
|
1719
1380
|
var encKey;
|
|
1720
1381
|
return _regeneratorRuntime.wrap(function _callee35$(_context35) {
|
|
1721
|
-
while (1) {
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
_context35.next = 9;
|
|
1747
|
-
return this.getKey();
|
|
1748
|
-
|
|
1749
|
-
case 9:
|
|
1750
|
-
return _context35.abrupt("return", _context35.sent);
|
|
1751
|
-
|
|
1752
|
-
case 10:
|
|
1753
|
-
case "end":
|
|
1754
|
-
return _context35.stop();
|
|
1755
|
-
}
|
|
1382
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
1383
|
+
case 0:
|
|
1384
|
+
if (!(key != null)) {
|
|
1385
|
+
_context35.next = 2;
|
|
1386
|
+
break;
|
|
1387
|
+
}
|
|
1388
|
+
return _context35.abrupt("return", key);
|
|
1389
|
+
case 2:
|
|
1390
|
+
_context35.next = 4;
|
|
1391
|
+
return this.getEncKey();
|
|
1392
|
+
case 4:
|
|
1393
|
+
encKey = _context35.sent;
|
|
1394
|
+
if (!(encKey != null)) {
|
|
1395
|
+
_context35.next = 7;
|
|
1396
|
+
break;
|
|
1397
|
+
}
|
|
1398
|
+
return _context35.abrupt("return", encKey);
|
|
1399
|
+
case 7:
|
|
1400
|
+
_context35.next = 9;
|
|
1401
|
+
return this.getKey();
|
|
1402
|
+
case 9:
|
|
1403
|
+
return _context35.abrupt("return", _context35.sent);
|
|
1404
|
+
case 10:
|
|
1405
|
+
case "end":
|
|
1406
|
+
return _context35.stop();
|
|
1756
1407
|
}
|
|
1757
1408
|
}, _callee35, this);
|
|
1758
1409
|
}));
|
|
@@ -1765,10 +1416,8 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1765
1416
|
if (this.legacyEtmKey == null) {
|
|
1766
1417
|
this.legacyEtmKey = new SymmetricCryptoKey(key.key, EncryptionType.AesCbc128_HmacSha256_B64);
|
|
1767
1418
|
}
|
|
1768
|
-
|
|
1769
1419
|
return this.legacyEtmKey;
|
|
1770
1420
|
}
|
|
1771
|
-
|
|
1772
1421
|
return key;
|
|
1773
1422
|
}
|
|
1774
1423
|
}, {
|
|
@@ -1777,28 +1426,23 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1777
1426
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee36() {
|
|
1778
1427
|
var newKey, encKey, macKey;
|
|
1779
1428
|
return _regeneratorRuntime.wrap(function _callee36$(_context36) {
|
|
1780
|
-
while (1) {
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
case 10:
|
|
1799
|
-
case "end":
|
|
1800
|
-
return _context36.stop();
|
|
1801
|
-
}
|
|
1429
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
1430
|
+
case 0:
|
|
1431
|
+
newKey = new Uint8Array(64);
|
|
1432
|
+
_context36.next = 3;
|
|
1433
|
+
return this.cryptoFunctionService.hkdfExpand(key.key, 'enc', 32, 'sha256');
|
|
1434
|
+
case 3:
|
|
1435
|
+
encKey = _context36.sent;
|
|
1436
|
+
_context36.next = 6;
|
|
1437
|
+
return this.cryptoFunctionService.hkdfExpand(key.key, 'mac', 32, 'sha256');
|
|
1438
|
+
case 6:
|
|
1439
|
+
macKey = _context36.sent;
|
|
1440
|
+
newKey.set(new Uint8Array(encKey));
|
|
1441
|
+
newKey.set(new Uint8Array(macKey), 32);
|
|
1442
|
+
return _context36.abrupt("return", new SymmetricCryptoKey(newKey.buffer));
|
|
1443
|
+
case 10:
|
|
1444
|
+
case "end":
|
|
1445
|
+
return _context36.stop();
|
|
1802
1446
|
}
|
|
1803
1447
|
}, _callee36, this);
|
|
1804
1448
|
}));
|
|
@@ -1810,37 +1454,29 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1810
1454
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee37() {
|
|
1811
1455
|
var entropyPerWord, numWords, hashArr, entropyAvailable, phrase, hashNumber, remainder;
|
|
1812
1456
|
return _regeneratorRuntime.wrap(function _callee37$(_context37) {
|
|
1813
|
-
while (1) {
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
return _context37.abrupt("return", phrase);
|
|
1839
|
-
|
|
1840
|
-
case 10:
|
|
1841
|
-
case "end":
|
|
1842
|
-
return _context37.stop();
|
|
1843
|
-
}
|
|
1457
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
1458
|
+
case 0:
|
|
1459
|
+
entropyPerWord = Math.log(EEFLongWordList.length) / Math.log(2);
|
|
1460
|
+
numWords = Math.ceil(minimumEntropy / entropyPerWord);
|
|
1461
|
+
hashArr = Array.from(new Uint8Array(hash));
|
|
1462
|
+
entropyAvailable = hashArr.length * 4;
|
|
1463
|
+
if (!(numWords * entropyPerWord > entropyAvailable)) {
|
|
1464
|
+
_context37.next = 6;
|
|
1465
|
+
break;
|
|
1466
|
+
}
|
|
1467
|
+
throw new Error('Output entropy of hash function is too small');
|
|
1468
|
+
case 6:
|
|
1469
|
+
phrase = [];
|
|
1470
|
+
hashNumber = bigInt.fromArray(hashArr, 256);
|
|
1471
|
+
while (numWords--) {
|
|
1472
|
+
remainder = hashNumber.mod(EEFLongWordList.length);
|
|
1473
|
+
hashNumber = hashNumber.divide(EEFLongWordList.length);
|
|
1474
|
+
phrase.push(EEFLongWordList[remainder]);
|
|
1475
|
+
}
|
|
1476
|
+
return _context37.abrupt("return", phrase);
|
|
1477
|
+
case 10:
|
|
1478
|
+
case "end":
|
|
1479
|
+
return _context37.stop();
|
|
1844
1480
|
}
|
|
1845
1481
|
}, _callee37);
|
|
1846
1482
|
}));
|
|
@@ -1851,66 +1487,51 @@ export var CryptoService = /*#__PURE__*/function () {
|
|
|
1851
1487
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee38() {
|
|
1852
1488
|
var encKeyEnc, newKey;
|
|
1853
1489
|
return _regeneratorRuntime.wrap(function _callee38$(_context38) {
|
|
1854
|
-
while (1) {
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
if (!(key.key.byteLength === 32)) {
|
|
1860
|
-
_context38.next = 10;
|
|
1861
|
-
break;
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
_context38.next = 4;
|
|
1865
|
-
return this.stretchKey(key);
|
|
1866
|
-
|
|
1867
|
-
case 4:
|
|
1868
|
-
newKey = _context38.sent;
|
|
1869
|
-
_context38.next = 7;
|
|
1870
|
-
return this.encrypt(encKey, newKey);
|
|
1871
|
-
|
|
1872
|
-
case 7:
|
|
1873
|
-
encKeyEnc = _context38.sent;
|
|
1874
|
-
_context38.next = 17;
|
|
1490
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
1491
|
+
case 0:
|
|
1492
|
+
encKeyEnc = null;
|
|
1493
|
+
if (!(key.key.byteLength === 32)) {
|
|
1494
|
+
_context38.next = 10;
|
|
1875
1495
|
break;
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1496
|
+
}
|
|
1497
|
+
_context38.next = 4;
|
|
1498
|
+
return this.stretchKey(key);
|
|
1499
|
+
case 4:
|
|
1500
|
+
newKey = _context38.sent;
|
|
1501
|
+
_context38.next = 7;
|
|
1502
|
+
return this.encrypt(encKey, newKey);
|
|
1503
|
+
case 7:
|
|
1504
|
+
encKeyEnc = _context38.sent;
|
|
1505
|
+
_context38.next = 17;
|
|
1506
|
+
break;
|
|
1507
|
+
case 10:
|
|
1508
|
+
if (!(key.key.byteLength === 64)) {
|
|
1509
|
+
_context38.next = 16;
|
|
1889
1510
|
break;
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1511
|
+
}
|
|
1512
|
+
_context38.next = 13;
|
|
1513
|
+
return this.encrypt(encKey, key);
|
|
1514
|
+
case 13:
|
|
1515
|
+
encKeyEnc = _context38.sent;
|
|
1516
|
+
_context38.next = 17;
|
|
1517
|
+
break;
|
|
1518
|
+
case 16:
|
|
1519
|
+
throw new Error('Invalid key size.');
|
|
1520
|
+
case 17:
|
|
1521
|
+
return _context38.abrupt("return", [new SymmetricCryptoKey(encKey), encKeyEnc]);
|
|
1522
|
+
case 18:
|
|
1523
|
+
case "end":
|
|
1524
|
+
return _context38.stop();
|
|
1901
1525
|
}
|
|
1902
1526
|
}, _callee38, this);
|
|
1903
1527
|
}));
|
|
1904
1528
|
}
|
|
1905
1529
|
}]);
|
|
1906
|
-
|
|
1907
1530
|
return CryptoService;
|
|
1908
1531
|
}();
|
|
1909
|
-
|
|
1910
1532
|
__decorate([sequentialize(function () {
|
|
1911
1533
|
return 'getEncKey';
|
|
1912
1534
|
}), __metadata("design:type", Function), __metadata("design:paramtypes", [SymmetricCryptoKey]), __metadata("design:returntype", Promise)], CryptoService.prototype, "getEncKey", null);
|
|
1913
|
-
|
|
1914
1535
|
__decorate([sequentialize(function () {
|
|
1915
1536
|
return 'getOrgKeys';
|
|
1916
1537
|
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], CryptoService.prototype, "getOrgKeys", null);
|