diff --git a/.yarn/cache/@typescript-eslint-eslint-plugin-npm-5.30.5-56e8842647-cf763fb091.zip b/.yarn/cache/@typescript-eslint-eslint-plugin-npm-5.30.5-56e8842647-cf763fb091.zip new file mode 100644 index 000000000..9ed7baa45 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-eslint-plugin-npm-5.30.5-56e8842647-cf763fb091.zip differ diff --git a/.yarn/cache/@typescript-eslint-scope-manager-npm-5.30.5-3e1fbf788a-509bee6d62.zip b/.yarn/cache/@typescript-eslint-scope-manager-npm-5.30.5-3e1fbf788a-509bee6d62.zip new file mode 100644 index 000000000..a3c62d9be Binary files /dev/null and b/.yarn/cache/@typescript-eslint-scope-manager-npm-5.30.5-3e1fbf788a-509bee6d62.zip differ diff --git a/.yarn/cache/@typescript-eslint-type-utils-npm-5.30.5-765594d88b-080cc12317.zip b/.yarn/cache/@typescript-eslint-type-utils-npm-5.30.5-765594d88b-080cc12317.zip new file mode 100644 index 000000000..7a816b538 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-type-utils-npm-5.30.5-765594d88b-080cc12317.zip differ diff --git a/.yarn/cache/@typescript-eslint-types-npm-5.30.5-77f495433c-c70420618c.zip b/.yarn/cache/@typescript-eslint-types-npm-5.30.5-77f495433c-c70420618c.zip new file mode 100644 index 000000000..c71017ab5 Binary files /dev/null and b/.yarn/cache/@typescript-eslint-types-npm-5.30.5-77f495433c-c70420618c.zip differ diff --git a/.yarn/cache/@typescript-eslint-typescript-estree-npm-5.30.5-da9a64fff6-19dce426c8.zip b/.yarn/cache/@typescript-eslint-typescript-estree-npm-5.30.5-da9a64fff6-19dce426c8.zip new file mode 100644 index 000000000..5ea0d78cb Binary files /dev/null and b/.yarn/cache/@typescript-eslint-typescript-estree-npm-5.30.5-da9a64fff6-19dce426c8.zip differ diff --git a/.yarn/cache/@typescript-eslint-utils-npm-5.30.5-4cd4c166a4-12f68cb34a.zip b/.yarn/cache/@typescript-eslint-utils-npm-5.30.5-4cd4c166a4-12f68cb34a.zip new file mode 100644 index 000000000..0a0f10c4b Binary files /dev/null and b/.yarn/cache/@typescript-eslint-utils-npm-5.30.5-4cd4c166a4-12f68cb34a.zip differ diff --git a/.yarn/cache/@typescript-eslint-visitor-keys-npm-5.30.5-027fead89e-c0de9ae483.zip b/.yarn/cache/@typescript-eslint-visitor-keys-npm-5.30.5-027fead89e-c0de9ae483.zip new file mode 100644 index 000000000..42a93a37c Binary files /dev/null and b/.yarn/cache/@typescript-eslint-visitor-keys-npm-5.30.5-027fead89e-c0de9ae483.zip differ diff --git a/packages/encryption/package.json b/packages/encryption/package.json index 9c08f66ec..5d028b358 100644 --- a/packages/encryption/package.json +++ b/packages/encryption/package.json @@ -22,17 +22,20 @@ "prebuild": "yarn clean", "build": "tsc -p tsconfig.json", "lint": "eslint . --ext .ts", + "format": "prettier --write src", "test": "jest" }, "devDependencies": { "@standardnotes/config": "2.4.3", "@types/jest": "^27.4.1", "@types/node": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.30.0", + "@typescript-eslint/eslint-plugin": "*", + "eslint": "*", "eslint-plugin-prettier": "^4.2.1", "jest": "^27.5.1", + "prettier": "*", "ts-jest": "^27.1.3", - "typescript": "^4.7.4" + "typescript": "*" }, "dependencies": { "@standardnotes/common": "^1.23.1", diff --git a/packages/encryption/src/Domain/Backups/BackupFile.ts b/packages/encryption/src/Domain/Backups/BackupFile.ts index 720d5d57c..115cd01a5 100644 --- a/packages/encryption/src/Domain/Backups/BackupFile.ts +++ b/packages/encryption/src/Domain/Backups/BackupFile.ts @@ -1,5 +1,5 @@ -import { BackupFileDecryptedContextualPayload, BackupFileEncryptedContextualPayload } from '@standardnotes/models' import { AnyKeyParamsContent, ProtocolVersion } from '@standardnotes/common' +import { BackupFileDecryptedContextualPayload, BackupFileEncryptedContextualPayload } from '@standardnotes/models' export type BackupFile = { version?: ProtocolVersion diff --git a/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts b/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts index 27f6f43ad..3a0f41ae8 100644 --- a/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts +++ b/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts @@ -1,35 +1,35 @@ import { AnyKeyParamsContent, - ContentType, - ProtocolVersion, - leftVersionGreaterThanOrEqualToRight, compareVersions, + ContentType, + leftVersionGreaterThanOrEqualToRight, + ProtocolVersion, } from '@standardnotes/common' -import { BackupFile } from './BackupFile' -import { BackupFileType } from './BackupFileType' -import { extendArray } from '@standardnotes/utils' -import { EncryptionService } from '../Service/Encryption/EncryptionService' import { - PayloadInterface, - DecryptedPayloadInterface, - ItemsKeyContent, - EncryptedPayloadInterface, - isEncryptedPayload, - isDecryptedPayload, - isEncryptedTransferPayload, - EncryptedPayload, - DecryptedPayload, - isDecryptedTransferPayload, CreateDecryptedItemFromPayload, - ItemsKeyInterface, CreatePayloadSplit, + DecryptedPayload, + DecryptedPayloadInterface, + EncryptedPayload, + EncryptedPayloadInterface, + isDecryptedPayload, + isDecryptedTransferPayload, + isEncryptedPayload, + isEncryptedTransferPayload, + ItemsKeyContent, + ItemsKeyInterface, + PayloadInterface, } from '@standardnotes/models' import { ClientDisplayableError } from '@standardnotes/responses' -import { CreateAnyKeyParams } from '../Keys/RootKey/KeyParamsFunctions' -import { SNRootKeyParams } from '../Keys/RootKey/RootKeyParams' -import { SNRootKey } from '../Keys/RootKey/RootKey' -import { ContentTypeUsesRootKeyEncryption } from '../Keys/RootKey/Functions' +import { extendArray } from '@standardnotes/utils' import { isItemsKey, SNItemsKey } from '../Keys/ItemsKey/ItemsKey' +import { ContentTypeUsesRootKeyEncryption } from '../Keys/RootKey/Functions' +import { CreateAnyKeyParams } from '../Keys/RootKey/KeyParamsFunctions' +import { SNRootKey } from '../Keys/RootKey/RootKey' +import { SNRootKeyParams } from '../Keys/RootKey/RootKeyParams' +import { EncryptionService } from '../Service/Encryption/EncryptionService' +import { BackupFile } from './BackupFile' +import { BackupFileType } from './BackupFileType' export async function DecryptBackupFile( file: BackupFile, diff --git a/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKey.ts b/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKey.ts index ada2003ae..8201dbda9 100644 --- a/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKey.ts +++ b/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKey.ts @@ -1,14 +1,14 @@ +import { ContentType, ProtocolVersion } from '@standardnotes/common' import { ConflictStrategy, - ItemsKeyContent, DecryptedItem, - DecryptedPayloadInterface, DecryptedItemInterface, + DecryptedPayloadInterface, HistoryEntryInterface, + ItemsKeyContent, ItemsKeyInterface, RootKeyInterface, } from '@standardnotes/models' -import { ContentType, ProtocolVersion } from '@standardnotes/common' export function isItemsKey(x: ItemsKeyInterface | RootKeyInterface): x is ItemsKeyInterface { return x.content_type === ContentType.ItemsKey diff --git a/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKeyMutator.ts b/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKeyMutator.ts index 817022271..6b5b047a5 100644 --- a/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKeyMutator.ts +++ b/packages/encryption/src/Domain/Keys/ItemsKey/ItemsKeyMutator.ts @@ -1,4 +1,4 @@ -import { DecryptedItemMutator, ItemsKeyMutatorInterface, ItemsKeyContent } from '@standardnotes/models' +import { DecryptedItemMutator, ItemsKeyContent, ItemsKeyMutatorInterface } from '@standardnotes/models' export class ItemsKeyMutator extends DecryptedItemMutator implements ItemsKeyMutatorInterface { set isDefault(isDefault: boolean) { diff --git a/packages/encryption/src/Domain/Keys/ItemsKey/Registration.ts b/packages/encryption/src/Domain/Keys/ItemsKey/Registration.ts index 1c78456fc..74e904d82 100644 --- a/packages/encryption/src/Domain/Keys/ItemsKey/Registration.ts +++ b/packages/encryption/src/Domain/Keys/ItemsKey/Registration.ts @@ -1,5 +1,5 @@ import { ContentType } from '@standardnotes/common' -import { RegisterItemClass, DecryptedItemMutator, ItemsKeyContent } from '@standardnotes/models' +import { DecryptedItemMutator, ItemsKeyContent, RegisterItemClass } from '@standardnotes/models' import { SNItemsKey } from './ItemsKey' import { ItemsKeyMutator } from './ItemsKeyMutator' diff --git a/packages/encryption/src/Domain/Keys/RootKey/Functions.ts b/packages/encryption/src/Domain/Keys/RootKey/Functions.ts index 284d27e25..793993b78 100644 --- a/packages/encryption/src/Domain/Keys/RootKey/Functions.ts +++ b/packages/encryption/src/Domain/Keys/RootKey/Functions.ts @@ -1,4 +1,4 @@ -import { SNRootKey } from './RootKey' +import { ContentType, ProtocolVersion } from '@standardnotes/common' import { DecryptedPayload, FillItemContentSpecialized, @@ -7,7 +7,7 @@ import { RootKeyContentSpecialized, } from '@standardnotes/models' import { UuidGenerator } from '@standardnotes/utils' -import { ContentType, ProtocolVersion } from '@standardnotes/common' +import { SNRootKey } from './RootKey' export function CreateNewRootKey(content: RootKeyContentSpecialized): SNRootKey { const uuid = UuidGenerator.GenerateUuid() diff --git a/packages/encryption/src/Domain/Keys/RootKey/KeyParamsFunctions.ts b/packages/encryption/src/Domain/Keys/RootKey/KeyParamsFunctions.ts index 69df68cf1..885a84570 100644 --- a/packages/encryption/src/Domain/Keys/RootKey/KeyParamsFunctions.ts +++ b/packages/encryption/src/Domain/Keys/RootKey/KeyParamsFunctions.ts @@ -1,13 +1,13 @@ -import { KeyParamsResponse } from '@standardnotes/responses' import { + AnyKeyParamsContent, KeyParamsContent001, KeyParamsContent002, KeyParamsContent003, KeyParamsContent004, - AnyKeyParamsContent, } from '@standardnotes/common' -import { SNRootKeyParams } from './RootKeyParams' +import { KeyParamsResponse } from '@standardnotes/responses' import { ProtocolVersionForKeyParams } from './ProtocolVersionForKeyParams' +import { SNRootKeyParams } from './RootKeyParams' /** * 001, 002: diff --git a/packages/encryption/src/Domain/Keys/RootKey/ProtocolVersionForKeyParams.ts b/packages/encryption/src/Domain/Keys/RootKey/ProtocolVersionForKeyParams.ts index df25d1502..9dcab9b83 100644 --- a/packages/encryption/src/Domain/Keys/RootKey/ProtocolVersionForKeyParams.ts +++ b/packages/encryption/src/Domain/Keys/RootKey/ProtocolVersionForKeyParams.ts @@ -1,6 +1,6 @@ -import { V001Algorithm, V002Algorithm } from '../../Algorithm' -import { KeyParamsData } from '@standardnotes/responses' import { AnyKeyParamsContent, ProtocolVersion } from '@standardnotes/common' +import { KeyParamsData } from '@standardnotes/responses' +import { V001Algorithm, V002Algorithm } from '../../Algorithm' export function ProtocolVersionForKeyParams(response: KeyParamsData | AnyKeyParamsContent): ProtocolVersion { if (response.version) { diff --git a/packages/encryption/src/Domain/Keys/RootKey/RootKey.ts b/packages/encryption/src/Domain/Keys/RootKey/RootKey.ts index 63b99e565..3b11dc825 100644 --- a/packages/encryption/src/Domain/Keys/RootKey/RootKey.ts +++ b/packages/encryption/src/Domain/Keys/RootKey/RootKey.ts @@ -1,14 +1,14 @@ -import { SNRootKeyParams } from './RootKeyParams' +import { ProtocolVersion } from '@standardnotes/common' import { - RootKeyInterface, - RootKeyContent, DecryptedItem, DecryptedPayloadInterface, - RootKeyContentInStorage, NamespacedRootKeyInKeychain, + RootKeyContent, + RootKeyContentInStorage, + RootKeyInterface, } from '@standardnotes/models' -import { ProtocolVersion } from '@standardnotes/common' import { timingSafeEqual } from '@standardnotes/sncrypto-common' +import { SNRootKeyParams } from './RootKeyParams' /** * A root key is a local only construct that houses the key used for the encryption diff --git a/packages/encryption/src/Domain/Keys/RootKey/RootKeyParams.ts b/packages/encryption/src/Domain/Keys/RootKey/RootKeyParams.ts index 6d31a7179..72f4ac908 100644 --- a/packages/encryption/src/Domain/Keys/RootKey/RootKeyParams.ts +++ b/packages/encryption/src/Domain/Keys/RootKey/RootKeyParams.ts @@ -1,11 +1,11 @@ import { + AnyKeyParamsContent, KeyParamsContent001, KeyParamsContent002, KeyParamsContent003, KeyParamsContent004, - AnyKeyParamsContent, - ProtocolVersion, KeyParamsOrigination, + ProtocolVersion, } from '@standardnotes/common' import { RootKeyParamsInterface } from '@standardnotes/models' import { pickByCopy } from '@standardnotes/utils' diff --git a/packages/encryption/src/Domain/Operator/001/Operator001.ts b/packages/encryption/src/Domain/Operator/001/Operator001.ts index 2d69cfd81..878ea5884 100644 --- a/packages/encryption/src/Domain/Operator/001/Operator001.ts +++ b/packages/encryption/src/Domain/Operator/001/Operator001.ts @@ -1,27 +1,27 @@ import { ContentType, KeyParamsOrigination, ProtocolVersion, ProtocolVersionLength } from '@standardnotes/common' -import { Create001KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' -import { firstHalfOfString, secondHalfOfString, splitString, UuidGenerator } from '@standardnotes/utils' -import { AsynchronousOperator } from '../Operator' import { CreateDecryptedItemFromPayload, - ItemsKeyContent, - ItemsKeyInterface, - FillItemContent, - ItemContent, DecryptedPayload, DecryptedPayloadInterface, + FillItemContent, + ItemContent, + ItemsKeyContent, + ItemsKeyInterface, PayloadTimestampDefaults, } from '@standardnotes/models' import { PureCryptoInterface } from '@standardnotes/sncrypto-common' -import { SNRootKey } from '../../Keys/RootKey/RootKey' -import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' +import { firstHalfOfString, secondHalfOfString, splitString, UuidGenerator } from '@standardnotes/utils' import { V001Algorithm } from '../../Algorithm' -import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } from '../../Types/EncryptedParameters' -import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' -import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' -import { LegacyAttachedData } from '../../Types/LegacyAttachedData' import { isItemsKey } from '../../Keys/ItemsKey/ItemsKey' import { CreateNewRootKey } from '../../Keys/RootKey/Functions' +import { Create001KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' +import { SNRootKey } from '../../Keys/RootKey/RootKey' +import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' +import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } from '../../Types/EncryptedParameters' +import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' +import { LegacyAttachedData } from '../../Types/LegacyAttachedData' +import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' +import { AsynchronousOperator } from '../Operator' const NO_IV = '00000000000000000000000000000000' diff --git a/packages/encryption/src/Domain/Operator/002/Operator002.ts b/packages/encryption/src/Domain/Operator/002/Operator002.ts index 409335de2..08e74f5ad 100644 --- a/packages/encryption/src/Domain/Operator/002/Operator002.ts +++ b/packages/encryption/src/Domain/Operator/002/Operator002.ts @@ -1,19 +1,19 @@ -import { Create002KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' -import { SNProtocolOperator001 } from '../001/Operator001' -import { SNRootKey } from '../../Keys/RootKey/RootKey' -import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' -import { UuidGenerator } from '@standardnotes/utils' -import { V002Algorithm } from '../../Algorithm' import * as Common from '@standardnotes/common' import * as Models from '@standardnotes/models' +import { ItemContent, PayloadTimestampDefaults } from '@standardnotes/models' import * as Utils from '@standardnotes/utils' -import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } from '../../Types/EncryptedParameters' -import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' -import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' -import { LegacyAttachedData } from '../../Types/LegacyAttachedData' +import { UuidGenerator } from '@standardnotes/utils' +import { V002Algorithm } from '../../Algorithm' import { isItemsKey } from '../../Keys/ItemsKey/ItemsKey' import { CreateNewRootKey } from '../../Keys/RootKey/Functions' -import { ItemContent, PayloadTimestampDefaults } from '@standardnotes/models' +import { Create002KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' +import { SNRootKey } from '../../Keys/RootKey/RootKey' +import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' +import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } from '../../Types/EncryptedParameters' +import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' +import { LegacyAttachedData } from '../../Types/LegacyAttachedData' +import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' +import { SNProtocolOperator001 } from '../001/Operator001' /** * @deprecated diff --git a/packages/encryption/src/Domain/Operator/003/Operator003.ts b/packages/encryption/src/Domain/Operator/003/Operator003.ts index abf2ffc86..d5e47a8f0 100644 --- a/packages/encryption/src/Domain/Operator/003/Operator003.ts +++ b/packages/encryption/src/Domain/Operator/003/Operator003.ts @@ -1,19 +1,19 @@ -import { splitString, UuidGenerator } from '@standardnotes/utils' +import { ContentType, KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common' import { CreateDecryptedItemFromPayload, DecryptedPayload, + FillItemContent, ItemsKeyContent, ItemsKeyInterface, - FillItemContent, PayloadTimestampDefaults, } from '@standardnotes/models' -import { SNRootKey } from '../../Keys/RootKey/RootKey' +import { splitString, UuidGenerator } from '@standardnotes/utils' import { V003Algorithm } from '../../Algorithm' -import { Create003KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' -import { SNProtocolOperator002 } from '../002/Operator002' -import { ContentType, KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common' -import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' import { CreateNewRootKey } from '../../Keys/RootKey/Functions' +import { Create003KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' +import { SNRootKey } from '../../Keys/RootKey/RootKey' +import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' +import { SNProtocolOperator002 } from '../002/Operator002' /** * @legacy diff --git a/packages/encryption/src/Domain/Operator/004/Operator004.ts b/packages/encryption/src/Domain/Operator/004/Operator004.ts index 58479973d..ce226a087 100644 --- a/packages/encryption/src/Domain/Operator/004/Operator004.ts +++ b/packages/encryption/src/Domain/Operator/004/Operator004.ts @@ -1,6 +1,5 @@ import { ContentType, KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common' -import { Create004KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' -import { SynchronousOperator } from '../Operator' +import * as Models from '@standardnotes/models' import { CreateDecryptedItemFromPayload, FillItemContent, @@ -10,17 +9,18 @@ import { PayloadTimestampDefaults, } from '@standardnotes/models' import { PureCryptoInterface } from '@standardnotes/sncrypto-common' +import * as Utils from '@standardnotes/utils' +import { V004Algorithm } from '../../Algorithm' +import { isItemsKey } from '../../Keys/ItemsKey/ItemsKey' +import { ContentTypeUsesRootKeyEncryption, CreateNewRootKey } from '../../Keys/RootKey/Functions' +import { Create004KeyParams } from '../../Keys/RootKey/KeyParamsFunctions' import { SNRootKey } from '../../Keys/RootKey/RootKey' import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' -import { V004Algorithm } from '../../Algorithm' -import * as Models from '@standardnotes/models' -import * as Utils from '@standardnotes/utils' -import { ContentTypeUsesRootKeyEncryption, CreateNewRootKey } from '../../Keys/RootKey/Functions' import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } from '../../Types/EncryptedParameters' -import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' import { LegacyAttachedData } from '../../Types/LegacyAttachedData' -import { isItemsKey } from '../../Keys/ItemsKey/ItemsKey' +import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' +import { SynchronousOperator } from '../Operator' type V004StringComponents = [version: string, nonce: string, ciphertext: string, authenticatedData: string] diff --git a/packages/encryption/src/Domain/Operator/Functions.ts b/packages/encryption/src/Domain/Operator/Functions.ts index 160cd1f4d..e5eb25f99 100644 --- a/packages/encryption/src/Domain/Operator/Functions.ts +++ b/packages/encryption/src/Domain/Operator/Functions.ts @@ -1,10 +1,10 @@ +import { ProtocolVersion } from '@standardnotes/common' import { PureCryptoInterface } from '@standardnotes/sncrypto-common' import { SNProtocolOperator001 } from '../Operator/001/Operator001' import { SNProtocolOperator002 } from '../Operator/002/Operator002' import { SNProtocolOperator003 } from '../Operator/003/Operator003' import { SNProtocolOperator004 } from '../Operator/004/Operator004' import { AsynchronousOperator, SynchronousOperator } from '../Operator/Operator' -import { ProtocolVersion } from '@standardnotes/common' export function createOperatorForVersion( version: ProtocolVersion, diff --git a/packages/encryption/src/Domain/Operator/Operator.ts b/packages/encryption/src/Domain/Operator/Operator.ts index 5b4599bb3..dd1b5d533 100644 --- a/packages/encryption/src/Domain/Operator/Operator.ts +++ b/packages/encryption/src/Domain/Operator/Operator.ts @@ -1,12 +1,12 @@ -import { ItemsKeyInterface, RootKeyInterface } from '@standardnotes/models' +import { KeyParamsOrigination } from '@standardnotes/common' import * as Models from '@standardnotes/models' +import { ItemsKeyInterface, RootKeyInterface } from '@standardnotes/models' import { SNRootKey } from '../Keys/RootKey/RootKey' import { SNRootKeyParams } from '../Keys/RootKey/RootKeyParams' -import { KeyParamsOrigination } from '@standardnotes/common' import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } from '../Types/EncryptedParameters' -import { RootKeyEncryptedAuthenticatedData } from '../Types/RootKeyEncryptedAuthenticatedData' import { ItemAuthenticatedData } from '../Types/ItemAuthenticatedData' import { LegacyAttachedData } from '../Types/LegacyAttachedData' +import { RootKeyEncryptedAuthenticatedData } from '../Types/RootKeyEncryptedAuthenticatedData' /**w * An operator is responsible for performing crypto operations, such as generating keys diff --git a/packages/encryption/src/Domain/Operator/OperatorManager.ts b/packages/encryption/src/Domain/Operator/OperatorManager.ts index 128b5753e..5441bcb31 100644 --- a/packages/encryption/src/Domain/Operator/OperatorManager.ts +++ b/packages/encryption/src/Domain/Operator/OperatorManager.ts @@ -1,5 +1,5 @@ -import { PureCryptoInterface } from '@standardnotes/sncrypto-common' import { ProtocolVersion, ProtocolVersionLatest } from '@standardnotes/common' +import { PureCryptoInterface } from '@standardnotes/sncrypto-common' import { createOperatorForVersion } from './Functions' import { AsynchronousOperator, SynchronousOperator } from './Operator' diff --git a/packages/encryption/src/Domain/Operator/OperatorWrapper.ts b/packages/encryption/src/Domain/Operator/OperatorWrapper.ts index 0b0663bff..b00092924 100644 --- a/packages/encryption/src/Domain/Operator/OperatorWrapper.ts +++ b/packages/encryption/src/Domain/Operator/OperatorWrapper.ts @@ -1,5 +1,3 @@ -import { isAsyncOperator } from './Functions' -import { OperatorManager } from './OperatorManager' import * as Models from '@standardnotes/models' import { DecryptedParameters, @@ -7,6 +5,8 @@ import { encryptedParametersFromPayload, ErrorDecryptingParameters, } from '../Types/EncryptedParameters' +import { isAsyncOperator } from './Functions' +import { OperatorManager } from './OperatorManager' export async function encryptPayload( payload: Models.DecryptedPayloadInterface, diff --git a/packages/encryption/src/Domain/Service/Encryption/EncryptionService.ts b/packages/encryption/src/Domain/Service/Encryption/EncryptionService.ts index 365efa506..423a4a153 100644 --- a/packages/encryption/src/Domain/Service/Encryption/EncryptionService.ts +++ b/packages/encryption/src/Domain/Service/Encryption/EncryptionService.ts @@ -1,35 +1,5 @@ -import { BackupFile } from '../../Backups/BackupFile' -import { CreateAnyKeyParams } from '../../Keys/RootKey/KeyParamsFunctions' -import { DecryptBackupFile } from '../../Backups/BackupFileDecryptor' -import { EncryptionProvider } from './EncryptionProvider' -import { findDefaultItemsKey } from '../Functions' -import { ItemsEncryptionService } from '../Items/ItemsEncryption' -import { KeyMode } from '../RootKey/KeyMode' -import { OperatorManager } from '../../Operator/OperatorManager' -import { PureCryptoInterface } from '@standardnotes/sncrypto-common' -import { SNRootKey } from '../../Keys/RootKey/RootKey' -import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' -import { V001Algorithm, V002Algorithm } from '../../Algorithm' import * as Common from '@standardnotes/common' -import { - CreateEncryptionSplitWithKeyLookup, - FindPayloadInDecryptionSplit, - FindPayloadInEncryptionSplit, -} from '../../Split/EncryptionSplit' import * as Models from '@standardnotes/models' -import * as RootKeyEncryption from '../RootKey/RootKeyEncryption' -import * as Services from '@standardnotes/services' -import * as Utils from '@standardnotes/utils' -import { - DecryptedParameters, - EncryptedParameters, - ErrorDecryptingParameters, - isErrorDecryptingParameters, - encryptedParametersFromPayload, -} from '../../Types/EncryptedParameters' -import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' -import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' -import { LegacyAttachedData } from '../../Types/LegacyAttachedData' import { CreateDecryptedBackupFileContextPayload, CreateEncryptedBackupFileContextPayload, @@ -38,12 +8,42 @@ import { isEncryptedPayload, RootKeyInterface, } from '@standardnotes/models' -import { SplitPayloadsByEncryptionType } from '../../Split/Functions' import { ClientDisplayableError } from '@standardnotes/responses' -import { isNotUndefined } from '@standardnotes/utils' +import * as Services from '@standardnotes/services' import { DiagnosticInfo } from '@standardnotes/services' -import { KeyedEncryptionSplit } from '../../Split/KeyedEncryptionSplit' +import { PureCryptoInterface } from '@standardnotes/sncrypto-common' +import * as Utils from '@standardnotes/utils' +import { isNotUndefined } from '@standardnotes/utils' +import { V001Algorithm, V002Algorithm } from '../../Algorithm' +import { BackupFile } from '../../Backups/BackupFile' +import { DecryptBackupFile } from '../../Backups/BackupFileDecryptor' +import { CreateAnyKeyParams } from '../../Keys/RootKey/KeyParamsFunctions' +import { SNRootKey } from '../../Keys/RootKey/RootKey' +import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' +import { OperatorManager } from '../../Operator/OperatorManager' +import { + CreateEncryptionSplitWithKeyLookup, + FindPayloadInDecryptionSplit, + FindPayloadInEncryptionSplit, +} from '../../Split/EncryptionSplit' +import { SplitPayloadsByEncryptionType } from '../../Split/Functions' import { KeyedDecryptionSplit } from '../../Split/KeyedDecryptionSplit' +import { KeyedEncryptionSplit } from '../../Split/KeyedEncryptionSplit' +import { + DecryptedParameters, + EncryptedParameters, + encryptedParametersFromPayload, + ErrorDecryptingParameters, + isErrorDecryptingParameters, +} from '../../Types/EncryptedParameters' +import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' +import { LegacyAttachedData } from '../../Types/LegacyAttachedData' +import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' +import { findDefaultItemsKey } from '../Functions' +import { ItemsEncryptionService } from '../Items/ItemsEncryption' +import { KeyMode } from '../RootKey/KeyMode' +import * as RootKeyEncryption from '../RootKey/RootKeyEncryption' +import { EncryptionProvider } from './EncryptionProvider' export enum EncryptionServiceEvent { RootKeyStatusChanged = 'RootKeyStatusChanged', diff --git a/packages/encryption/src/Domain/Service/Items/ItemsEncryption.ts b/packages/encryption/src/Domain/Service/Items/ItemsEncryption.ts index d9055b3b1..c829c20f6 100644 --- a/packages/encryption/src/Domain/Service/Items/ItemsEncryption.ts +++ b/packages/encryption/src/Domain/Service/Items/ItemsEncryption.ts @@ -1,19 +1,19 @@ import { ContentType, ProtocolVersion } from '@standardnotes/common' -import { findDefaultItemsKey } from '../Functions' -import { OperatorManager } from '../../Operator/OperatorManager' -import { StandardException } from '../../StandardException' -import * as OperatorWrapper from '../../Operator/OperatorWrapper' import * as Models from '@standardnotes/models' +import { isEncryptedPayload } from '@standardnotes/models' import * as Services from '@standardnotes/services' +import { DiagnosticInfo } from '@standardnotes/services' +import { Uuids } from '@standardnotes/utils' +import { OperatorManager } from '../../Operator/OperatorManager' +import * as OperatorWrapper from '../../Operator/OperatorWrapper' +import { StandardException } from '../../StandardException' import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters, isErrorDecryptingParameters, } from '../../Types/EncryptedParameters' -import { isEncryptedPayload } from '@standardnotes/models' -import { DiagnosticInfo } from '@standardnotes/services' -import { Uuids } from '@standardnotes/utils' +import { findDefaultItemsKey } from '../Functions' export class ItemsEncryptionService extends Services.AbstractService { private removeItemsObserver!: () => void diff --git a/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts b/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts index b51a1538a..9c6f82bf3 100644 --- a/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts +++ b/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts @@ -1,32 +1,32 @@ -import { CreateAnyKeyParams } from '../../Keys/RootKey/KeyParamsFunctions' -import { findDefaultItemsKey } from '../Functions' -import { KeyMode } from './KeyMode' -import { OperatorManager } from '../../Operator/OperatorManager' -import { SNRootKey } from '../../Keys/RootKey/RootKey' -import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' -import { UuidGenerator } from '@standardnotes/utils' import * as Common from '@standardnotes/common' import * as Models from '@standardnotes/models' -import * as OperatorWrapper from '../../Operator/OperatorWrapper' +import { + DecryptedPayload, + FillItemContentSpecialized, + ItemsKeyContent, + ItemsKeyContentSpecialized, + NamespacedRootKeyInKeychain, + PayloadTimestampDefaults, + RootKeyContent, + RootKeyInterface, +} from '@standardnotes/models' import * as Services from '@standardnotes/services' +import { UuidGenerator } from '@standardnotes/utils' +import { ItemsKeyMutator } from '../../Keys/ItemsKey/ItemsKeyMutator' +import { CreateNewRootKey } from '../../Keys/RootKey/Functions' +import { CreateAnyKeyParams } from '../../Keys/RootKey/KeyParamsFunctions' +import { SNRootKey } from '../../Keys/RootKey/RootKey' +import { SNRootKeyParams } from '../../Keys/RootKey/RootKeyParams' +import { OperatorManager } from '../../Operator/OperatorManager' +import * as OperatorWrapper from '../../Operator/OperatorWrapper' import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters, isErrorDecryptingParameters, } from '../../Types/EncryptedParameters' -import { ItemsKeyMutator } from '../../Keys/ItemsKey/ItemsKeyMutator' -import { CreateNewRootKey } from '../../Keys/RootKey/Functions' -import { - DecryptedPayload, - FillItemContentSpecialized, - ItemsKeyContent, - ItemsKeyContentSpecialized, - PayloadTimestampDefaults, - RootKeyContent, - RootKeyInterface, - NamespacedRootKeyInKeychain, -} from '@standardnotes/models' +import { findDefaultItemsKey } from '../Functions' +import { KeyMode } from './KeyMode' export enum RootKeyServiceEvent { RootKeyStatusChanged = 'RootKeyStatusChanged', diff --git a/packages/encryption/src/Domain/Types/ItemAuthenticatedData.ts b/packages/encryption/src/Domain/Types/ItemAuthenticatedData.ts index 6c354c00e..2b75da608 100644 --- a/packages/encryption/src/Domain/Types/ItemAuthenticatedData.ts +++ b/packages/encryption/src/Domain/Types/ItemAuthenticatedData.ts @@ -1,4 +1,4 @@ -import { Uuid, ProtocolVersion } from '@standardnotes/common' +import { ProtocolVersion, Uuid } from '@standardnotes/common' export type ItemAuthenticatedData = { u: Uuid diff --git a/packages/encryption/src/Domain/index.ts b/packages/encryption/src/Domain/index.ts index 02e2eed6e..d6e087691 100644 --- a/packages/encryption/src/Domain/index.ts +++ b/packages/encryption/src/Domain/index.ts @@ -1,3 +1,4 @@ +export * from './Algorithm' export * from './Backups/BackupFile' export * from './Backups/BackupFileDecryptor' export * from './Backups/BackupFileType' @@ -32,10 +33,9 @@ export * from './Split/EncryptionTypeSplit' export * from './Split/Functions' export * from './Split/KeyedDecryptionSplit' export * from './Split/KeyedEncryptionSplit' +export * from './StandardException' export * from './Types/EncryptedParameters' export * from './Types/ItemAuthenticatedData' export * from './Types/LegacyAttachedData' export * from './Types/RootKeyEncryptedAuthenticatedData' export * from './Workspace/PrivateWorkspace' -export * from './Algorithm' -export * from './StandardException' diff --git a/yarn.lock b/yarn.lock index b6081f262..424e5707b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6554,12 +6554,14 @@ __metadata: "@standardnotes/utils": ^1.6.12 "@types/jest": ^27.4.1 "@types/node": ^18.0.0 - "@typescript-eslint/eslint-plugin": ^5.30.0 + "@typescript-eslint/eslint-plugin": "*" + eslint: "*" eslint-plugin-prettier: ^4.2.1 jest: ^27.5.1 + prettier: "*" reflect-metadata: ^0.1.13 ts-jest: ^27.1.3 - typescript: ^4.7.4 + typescript: "*" languageName: unknown linkType: soft @@ -9118,6 +9120,29 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/eslint-plugin@npm:*": + version: 5.30.5 + resolution: "@typescript-eslint/eslint-plugin@npm:5.30.5" + dependencies: + "@typescript-eslint/scope-manager": 5.30.5 + "@typescript-eslint/type-utils": 5.30.5 + "@typescript-eslint/utils": 5.30.5 + debug: ^4.3.4 + functional-red-black-tree: ^1.0.1 + ignore: ^5.2.0 + regexpp: ^3.2.0 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependencies: + "@typescript-eslint/parser": ^5.0.0 + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: cf763fb091dcdfd6c25843251a220b654ca83968b17266e0f343771f489085c6afc4e41fcf2187b4c72c4d12a787070c64b5e5367069460f95a8174573f48905 + languageName: node + linkType: hard + "@typescript-eslint/eslint-plugin@npm:^5.12.1, @typescript-eslint/eslint-plugin@npm:^5.15.0, @typescript-eslint/eslint-plugin@npm:^5.20.0, @typescript-eslint/eslint-plugin@npm:^5.5.0": version: 5.30.0 resolution: "@typescript-eslint/eslint-plugin@npm:5.30.0" @@ -9212,6 +9237,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:5.30.5": + version: 5.30.5 + resolution: "@typescript-eslint/scope-manager@npm:5.30.5" + dependencies: + "@typescript-eslint/types": 5.30.5 + "@typescript-eslint/visitor-keys": 5.30.5 + checksum: 509bee6d62cca1716e8f4792d9180c189974992ba13d8103ca04423a64006cf184c4b2c606d55c776305458140c798a3a9a414d07a60790b83dd714f56c457b0 + languageName: node + linkType: hard + "@typescript-eslint/type-utils@npm:5.30.0": version: 5.30.0 resolution: "@typescript-eslint/type-utils@npm:5.30.0" @@ -9244,6 +9279,22 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/type-utils@npm:5.30.5": + version: 5.30.5 + resolution: "@typescript-eslint/type-utils@npm:5.30.5" + dependencies: + "@typescript-eslint/utils": 5.30.5 + debug: ^4.3.4 + tsutils: ^3.21.0 + peerDependencies: + eslint: "*" + peerDependenciesMeta: + typescript: + optional: true + checksum: 080cc1231729c34b778395658374e32d034474056f9b777dbc89d20d15eb93d93d0959328ad47c2a6623d40c6552364ababadce439842a944bce001f55b731b3 + languageName: node + linkType: hard + "@typescript-eslint/types@npm:5.30.0": version: 5.30.0 resolution: "@typescript-eslint/types@npm:5.30.0" @@ -9258,6 +9309,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:5.30.5": + version: 5.30.5 + resolution: "@typescript-eslint/types@npm:5.30.5" + checksum: c70420618cb875d4e964a20a3fa4cf40cb97a8ad3123e24860e3d829edf3b081c77fa1fe25644700499d27e44aee5783abc7765deee61e2ef59a928db96b2175 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.30.0": version: 5.30.0 resolution: "@typescript-eslint/typescript-estree@npm:5.30.0" @@ -9294,6 +9352,24 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:5.30.5": + version: 5.30.5 + resolution: "@typescript-eslint/typescript-estree@npm:5.30.5" + dependencies: + "@typescript-eslint/types": 5.30.5 + "@typescript-eslint/visitor-keys": 5.30.5 + debug: ^4.3.4 + globby: ^11.1.0 + is-glob: ^4.0.3 + semver: ^7.3.7 + tsutils: ^3.21.0 + peerDependenciesMeta: + typescript: + optional: true + checksum: 19dce426c826cddd4aadf2fa15be943c6ad7d2038685cc2665749486a5f44a47819aab5d260b54f8a4babf6acf2500e9f62e709d61fce337b12d5468ff285277 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:5.30.0, @typescript-eslint/utils@npm:^5.13.0": version: 5.30.0 resolution: "@typescript-eslint/utils@npm:5.30.0" @@ -9326,6 +9402,22 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/utils@npm:5.30.5": + version: 5.30.5 + resolution: "@typescript-eslint/utils@npm:5.30.5" + dependencies: + "@types/json-schema": ^7.0.9 + "@typescript-eslint/scope-manager": 5.30.5 + "@typescript-eslint/types": 5.30.5 + "@typescript-eslint/typescript-estree": 5.30.5 + eslint-scope: ^5.1.1 + eslint-utils: ^3.0.0 + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + checksum: 12f68cb34a150d39708f4e09a54964360f29589885cd50f119a2061660011752ec72eff3d90111f0e597575d32aae7250a6e2c730a84963e5e30352759d5f1f4 + languageName: node + linkType: hard + "@typescript-eslint/visitor-keys@npm:5.30.0": version: 5.30.0 resolution: "@typescript-eslint/visitor-keys@npm:5.30.0" @@ -9346,6 +9438,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:5.30.5": + version: 5.30.5 + resolution: "@typescript-eslint/visitor-keys@npm:5.30.5" + dependencies: + "@typescript-eslint/types": 5.30.5 + eslint-visitor-keys: ^3.3.0 + checksum: c0de9ae48378eec2682b860a059518bed213ea29575aad538d8d2f8137875e7279e375a7f23d38c1c183466fdd9cf1ca1db4ed5a1d374968f9460d83e48b2437 + languageName: node + linkType: hard + "@uiw/react-codemirror@npm:4.5.1": version: 4.5.1 resolution: "@uiw/react-codemirror@npm:4.5.1"