From 945248d7d3f0ac0fa153aeedd8ad18d64f30d6be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Tue, 5 Jul 2022 11:31:22 +0200 Subject: [PATCH] fix: encryption exports (#1205) * fix: encryptio exports * fix: imports * fix: items key mutator import --- .../src/Domain/Backups/BackupFile.ts | 14 ------- .../src/Domain/Backups/BackupFileDecryptor.ts | 5 ++- .../src/Domain/Backups/BackupFileType.ts | 13 ++++++ .../src/Domain/Keys/ItemsKey/index.ts | 3 -- .../src/Domain/Operator/001/Operator001.ts | 2 +- .../src/Domain/Operator/002/Operator002.ts | 2 +- .../Domain/Operator/004/Operator004.spec.ts | 2 +- .../src/Domain/Operator/004/Operator004.ts | 2 +- .../encryption/src/Domain/Operator/index.ts | 9 ---- .../Service/RootKey/RootKeyEncryption.ts | 2 +- .../encryption/src/Domain/Service/index.ts | 3 -- packages/encryption/src/Domain/index.ts | 42 ++++++++++++++----- 12 files changed, 53 insertions(+), 46 deletions(-) create mode 100644 packages/encryption/src/Domain/Backups/BackupFileType.ts delete mode 100644 packages/encryption/src/Domain/Keys/ItemsKey/index.ts delete mode 100644 packages/encryption/src/Domain/Operator/index.ts delete mode 100644 packages/encryption/src/Domain/Service/index.ts diff --git a/packages/encryption/src/Domain/Backups/BackupFile.ts b/packages/encryption/src/Domain/Backups/BackupFile.ts index 5ce9e9539..720d5d57c 100644 --- a/packages/encryption/src/Domain/Backups/BackupFile.ts +++ b/packages/encryption/src/Domain/Backups/BackupFile.ts @@ -7,17 +7,3 @@ export type BackupFile = { auth_params?: AnyKeyParamsContent items: (BackupFileDecryptedContextualPayload | BackupFileEncryptedContextualPayload)[] } - -export enum BackupFileType { - Encrypted = 'Encrypted', - - /** - * Generated when an export is made from an application with no account and no passcode. The - * items are encrypted, but the items keys are not. - */ - EncryptedWithNonEncryptedItemsKey = 'EncryptedWithNonEncryptedItemsKey', - - FullyDecrypted = 'FullyDecrypted', - - Corrupt = 'Corrupt', -} diff --git a/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts b/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts index 095e2786b..27f6f43ad 100644 --- a/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts +++ b/packages/encryption/src/Domain/Backups/BackupFileDecryptor.ts @@ -5,7 +5,8 @@ import { leftVersionGreaterThanOrEqualToRight, compareVersions, } from '@standardnotes/common' -import { BackupFile, BackupFileType } from './BackupFile' +import { BackupFile } from './BackupFile' +import { BackupFileType } from './BackupFileType' import { extendArray } from '@standardnotes/utils' import { EncryptionService } from '../Service/Encryption/EncryptionService' import { @@ -28,7 +29,7 @@ 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 { isItemsKey, SNItemsKey } from '../Keys/ItemsKey' +import { isItemsKey, SNItemsKey } from '../Keys/ItemsKey/ItemsKey' export async function DecryptBackupFile( file: BackupFile, diff --git a/packages/encryption/src/Domain/Backups/BackupFileType.ts b/packages/encryption/src/Domain/Backups/BackupFileType.ts new file mode 100644 index 000000000..6f9e97c0e --- /dev/null +++ b/packages/encryption/src/Domain/Backups/BackupFileType.ts @@ -0,0 +1,13 @@ +export enum BackupFileType { + Encrypted = 'Encrypted', + + /** + * Generated when an export is made from an application with no account and no passcode. The + * items are encrypted, but the items keys are not. + */ + EncryptedWithNonEncryptedItemsKey = 'EncryptedWithNonEncryptedItemsKey', + + FullyDecrypted = 'FullyDecrypted', + + Corrupt = 'Corrupt', +} diff --git a/packages/encryption/src/Domain/Keys/ItemsKey/index.ts b/packages/encryption/src/Domain/Keys/ItemsKey/index.ts deleted file mode 100644 index 05b0b381c..000000000 --- a/packages/encryption/src/Domain/Keys/ItemsKey/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './ItemsKey' -export * from './ItemsKeyMutator' -export * from './Registration' diff --git a/packages/encryption/src/Domain/Operator/001/Operator001.ts b/packages/encryption/src/Domain/Operator/001/Operator001.ts index 8ccdb5284..2d69cfd81 100644 --- a/packages/encryption/src/Domain/Operator/001/Operator001.ts +++ b/packages/encryption/src/Domain/Operator/001/Operator001.ts @@ -20,7 +20,7 @@ import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } f import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' import { LegacyAttachedData } from '../../Types/LegacyAttachedData' -import { isItemsKey } from '../../Keys/ItemsKey' +import { isItemsKey } from '../../Keys/ItemsKey/ItemsKey' import { CreateNewRootKey } from '../../Keys/RootKey/Functions' 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 5e7c0820d..409335de2 100644 --- a/packages/encryption/src/Domain/Operator/002/Operator002.ts +++ b/packages/encryption/src/Domain/Operator/002/Operator002.ts @@ -11,7 +11,7 @@ import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } f import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' import { LegacyAttachedData } from '../../Types/LegacyAttachedData' -import { isItemsKey } from '../../Keys/ItemsKey' +import { isItemsKey } from '../../Keys/ItemsKey/ItemsKey' import { CreateNewRootKey } from '../../Keys/RootKey/Functions' import { ItemContent, PayloadTimestampDefaults } from '@standardnotes/models' diff --git a/packages/encryption/src/Domain/Operator/004/Operator004.spec.ts b/packages/encryption/src/Domain/Operator/004/Operator004.spec.ts index 51674ca55..b7a717c5e 100644 --- a/packages/encryption/src/Domain/Operator/004/Operator004.spec.ts +++ b/packages/encryption/src/Domain/Operator/004/Operator004.spec.ts @@ -1,7 +1,7 @@ import { ContentType, ProtocolVersion } from '@standardnotes/common' import { DecryptedPayload, ItemContent, ItemsKeyContent, PayloadTimestampDefaults } from '@standardnotes/models' import { PureCryptoInterface } from '@standardnotes/sncrypto-common' -import { SNItemsKey } from '../../Keys/ItemsKey' +import { SNItemsKey } from '../../Keys/ItemsKey/ItemsKey' import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' import { SNProtocolOperator004 } from './Operator004' diff --git a/packages/encryption/src/Domain/Operator/004/Operator004.ts b/packages/encryption/src/Domain/Operator/004/Operator004.ts index b8316a5e3..58479973d 100644 --- a/packages/encryption/src/Domain/Operator/004/Operator004.ts +++ b/packages/encryption/src/Domain/Operator/004/Operator004.ts @@ -20,7 +20,7 @@ import { DecryptedParameters, EncryptedParameters, ErrorDecryptingParameters } f import { RootKeyEncryptedAuthenticatedData } from '../../Types/RootKeyEncryptedAuthenticatedData' import { ItemAuthenticatedData } from '../../Types/ItemAuthenticatedData' import { LegacyAttachedData } from '../../Types/LegacyAttachedData' -import { isItemsKey } from '../../Keys/ItemsKey' +import { isItemsKey } from '../../Keys/ItemsKey/ItemsKey' type V004StringComponents = [version: string, nonce: string, ciphertext: string, authenticatedData: string] diff --git a/packages/encryption/src/Domain/Operator/index.ts b/packages/encryption/src/Domain/Operator/index.ts deleted file mode 100644 index 992e81eeb..000000000 --- a/packages/encryption/src/Domain/Operator/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export * from './001/Operator001' -export * from './002/Operator002' -export * from './003/Operator003' -export * from './004/Operator004' -export * from './Operator' -export * from '../Types/EncryptedParameters' -export * from '../Types/ItemAuthenticatedData' -export * from '../Types/LegacyAttachedData' -export * from '../Types/RootKeyEncryptedAuthenticatedData' diff --git a/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts b/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts index c0450cb8d..b51a1538a 100644 --- a/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts +++ b/packages/encryption/src/Domain/Service/RootKey/RootKeyEncryption.ts @@ -15,7 +15,7 @@ import { ErrorDecryptingParameters, isErrorDecryptingParameters, } from '../../Types/EncryptedParameters' -import { ItemsKeyMutator } from '../../Keys/ItemsKey' +import { ItemsKeyMutator } from '../../Keys/ItemsKey/ItemsKeyMutator' import { CreateNewRootKey } from '../../Keys/RootKey/Functions' import { DecryptedPayload, diff --git a/packages/encryption/src/Domain/Service/index.ts b/packages/encryption/src/Domain/Service/index.ts deleted file mode 100644 index e15a9098e..000000000 --- a/packages/encryption/src/Domain/Service/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from '../Backups/BackupFile' -export * from './Encryption/EncryptionService' -export * from './RootKey/KeyMode' diff --git a/packages/encryption/src/Domain/index.ts b/packages/encryption/src/Domain/index.ts index 33bb939b2..260a1a00f 100644 --- a/packages/encryption/src/Domain/index.ts +++ b/packages/encryption/src/Domain/index.ts @@ -1,15 +1,37 @@ -export * from './Algorithm' -export * from './Split/EncryptionSplit' -export * from './Split/EncryptionTypeSplit' -export * from './Operator' +export * from './Backups/BackupFile' +export * from './Backups/BackupFileDecryptor' +export * from './Backups/BackupFileType' +export * from './Keys/ItemsKey/ItemsKey' +export * from './Keys/ItemsKey/ItemsKeyMutator' +export * from './Keys/ItemsKey/Registration' +export * from './Keys/RootKey/Functions' export * from './Keys/RootKey/KeyParamsFunctions' +export * from './Keys/RootKey/ProtocolVersionForKeyParams' export * from './Keys/RootKey/RootKey' export * from './Keys/RootKey/RootKeyParams' -export * from './Keys/RootKey/Functions' -export * from './Service' -export * from './Service/Encryption/EncryptionProvider' -export * from './Split/EncryptionSplit' -export * from './Workspace/PrivateWorkspace' -export * from './Keys/ItemsKey' +export * from './Keys/RootKey/ValidKeyParamsKeys' export * from './Keys/Utils/DecryptItemsKey' export * from './Keys/Utils/KeyRecoveryStrings' +export * from './Operator/001/Operator001' +export * from './Operator/002/Operator002' +export * from './Operator/003/Operator003' +export * from './Operator/004/Operator004' +export * from './Operator/Functions' +export * from './Operator/Operator' +export * from './Operator/OperatorManager' +export * from './Operator/OperatorWrapper' +export * from './Service/Encryption/EncryptionProvider' +export * from './Service/Encryption/EncryptionService' +export * from './Service/Functions' +export * from './Service/Items/ItemsEncryption' +export * from './Service/RootKey/KeyMode' +export * from './Service/RootKey/RootKeyEncryption' +export * from './Split/EncryptionSplit' +export * from './Split/EncryptionTypeSplit' +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'