@brightchain/brightchain-lib 0.13.0 → 0.15.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/brightchain-lib/BROWSER_COMPAT.md +54 -0
- package/package.json +15 -4
- package/src/browser.d.ts +1 -1
- package/src/browser.d.ts.map +1 -1
- package/src/browser.js +3 -3
- package/src/browser.js.map +1 -1
- package/src/lib/blocks/cblBase.d.ts +16 -1
- package/src/lib/blocks/cblBase.d.ts.map +1 -1
- package/src/lib/blocks/cblBase.js +33 -4
- package/src/lib/blocks/cblBase.js.map +1 -1
- package/src/lib/blocks/encryptedBlockFactory.d.ts +6 -1
- package/src/lib/blocks/encryptedBlockFactory.d.ts.map +1 -1
- package/src/lib/blocks/encryptedBlockFactory.js +14 -5
- package/src/lib/blocks/encryptedBlockFactory.js.map +1 -1
- package/src/lib/blocks/extendedCbl.d.ts.map +1 -1
- package/src/lib/blocks/extendedCbl.js +2 -1
- package/src/lib/blocks/extendedCbl.js.map +1 -1
- package/src/lib/blocks/handle.d.ts +5 -0
- package/src/lib/blocks/handle.d.ts.map +1 -1
- package/src/lib/blocks/handle.js.map +1 -1
- package/src/lib/blocks/handleTuple.d.ts +9 -1
- package/src/lib/blocks/handleTuple.d.ts.map +1 -1
- package/src/lib/blocks/handleTuple.js +23 -1
- package/src/lib/blocks/handleTuple.js.map +1 -1
- package/src/lib/blocks/index.d.ts +1 -0
- package/src/lib/blocks/index.d.ts.map +1 -1
- package/src/lib/blocks/index.js +1 -0
- package/src/lib/blocks/index.js.map +1 -1
- package/src/lib/blocks/memoryTuple.d.ts +9 -2
- package/src/lib/blocks/memoryTuple.d.ts.map +1 -1
- package/src/lib/blocks/memoryTuple.js +12 -3
- package/src/lib/blocks/memoryTuple.js.map +1 -1
- package/src/lib/blocks/vcbl.d.ts +27 -0
- package/src/lib/blocks/vcbl.d.ts.map +1 -0
- package/src/lib/blocks/vcbl.js +107 -0
- package/src/lib/blocks/vcbl.js.map +1 -0
- package/src/lib/constants.d.ts +5 -1
- package/src/lib/constants.d.ts.map +1 -1
- package/src/lib/constants.js +4 -0
- package/src/lib/constants.js.map +1 -1
- package/src/lib/crypto/index.d.ts +12 -0
- package/src/lib/crypto/index.d.ts.map +1 -0
- package/src/lib/crypto/index.js +23 -0
- package/src/lib/crypto/index.js.map +1 -0
- package/src/lib/crypto/platformCrypto.d.ts +132 -0
- package/src/lib/crypto/platformCrypto.d.ts.map +1 -0
- package/src/lib/crypto/platformCrypto.js +181 -0
- package/src/lib/crypto/platformCrypto.js.map +1 -0
- package/src/lib/enumeration-translations/blockType.d.ts.map +1 -1
- package/src/lib/enumeration-translations/blockType.js +16 -0
- package/src/lib/enumeration-translations/blockType.js.map +1 -1
- package/src/lib/enumerations/blockType.d.ts +12 -0
- package/src/lib/enumerations/blockType.d.ts.map +1 -1
- package/src/lib/enumerations/blockType.js +14 -0
- package/src/lib/enumerations/blockType.js.map +1 -1
- package/src/lib/enumerations/brightChainStrings.d.ts +5 -1
- package/src/lib/enumerations/brightChainStrings.d.ts.map +1 -1
- package/src/lib/enumerations/brightChainStrings.js +5 -1
- package/src/lib/enumerations/brightChainStrings.js.map +1 -1
- package/src/lib/enumerations/cblErrorType.d.ts +2 -1
- package/src/lib/enumerations/cblErrorType.d.ts.map +1 -1
- package/src/lib/enumerations/cblErrorType.js +1 -0
- package/src/lib/enumerations/cblErrorType.js.map +1 -1
- package/src/lib/enumerations/communication.d.ts +57 -0
- package/src/lib/enumerations/communication.d.ts.map +1 -0
- package/src/lib/enumerations/communication.js +89 -0
- package/src/lib/enumerations/communication.js.map +1 -0
- package/src/lib/enumerations/deviceType.d.ts +15 -0
- package/src/lib/enumerations/deviceType.d.ts.map +1 -0
- package/src/lib/enumerations/deviceType.js +19 -0
- package/src/lib/enumerations/deviceType.js.map +1 -0
- package/src/lib/enumerations/handleTupleErrorType.d.ts +2 -1
- package/src/lib/enumerations/handleTupleErrorType.d.ts.map +1 -1
- package/src/lib/enumerations/handleTupleErrorType.js +1 -0
- package/src/lib/enumerations/handleTupleErrorType.js.map +1 -1
- package/src/lib/enumerations/index.d.ts +6 -0
- package/src/lib/enumerations/index.d.ts.map +1 -1
- package/src/lib/enumerations/index.js +11 -0
- package/src/lib/enumerations/index.js.map +1 -1
- package/src/lib/enumerations/messaging/deliveryStatus.d.ts +50 -0
- package/src/lib/enumerations/messaging/deliveryStatus.d.ts.map +1 -0
- package/src/lib/enumerations/messaging/deliveryStatus.js +68 -0
- package/src/lib/enumerations/messaging/deliveryStatus.js.map +1 -0
- package/src/lib/enumerations/messaging/emailErrorType.d.ts +36 -0
- package/src/lib/enumerations/messaging/emailErrorType.d.ts.map +1 -0
- package/src/lib/enumerations/messaging/emailErrorType.js +46 -0
- package/src/lib/enumerations/messaging/emailErrorType.js.map +1 -0
- package/src/lib/enumerations/messaging/index.d.ts +2 -1
- package/src/lib/enumerations/messaging/index.d.ts.map +1 -1
- package/src/lib/enumerations/messaging/index.js +2 -1
- package/src/lib/enumerations/messaging/index.js.map +1 -1
- package/src/lib/enumerations/messaging/messageEncryptionScheme.d.ts +4 -2
- package/src/lib/enumerations/messaging/messageEncryptionScheme.d.ts.map +1 -1
- package/src/lib/enumerations/messaging/messageEncryptionScheme.js +3 -1
- package/src/lib/enumerations/messaging/messageEncryptionScheme.js.map +1 -1
- package/src/lib/enumerations/paperKeyPurpose.d.ts +15 -0
- package/src/lib/enumerations/paperKeyPurpose.d.ts.map +1 -0
- package/src/lib/enumerations/paperKeyPurpose.js +19 -0
- package/src/lib/enumerations/paperKeyPurpose.js.map +1 -0
- package/src/lib/enumerations/proofPlatform.d.ts +24 -0
- package/src/lib/enumerations/proofPlatform.d.ts.map +1 -0
- package/src/lib/enumerations/proofPlatform.js +28 -0
- package/src/lib/enumerations/proofPlatform.js.map +1 -0
- package/src/lib/enumerations/readConcern.d.ts +22 -0
- package/src/lib/enumerations/readConcern.d.ts.map +1 -0
- package/src/lib/enumerations/readConcern.js +26 -0
- package/src/lib/enumerations/readConcern.js.map +1 -0
- package/src/lib/enumerations/tupleErrorType.d.ts +2 -1
- package/src/lib/enumerations/tupleErrorType.d.ts.map +1 -1
- package/src/lib/enumerations/tupleErrorType.js +1 -0
- package/src/lib/enumerations/tupleErrorType.js.map +1 -1
- package/src/lib/enumerations/verificationStatus.d.ts +17 -0
- package/src/lib/enumerations/verificationStatus.d.ts.map +1 -0
- package/src/lib/enumerations/verificationStatus.js +21 -0
- package/src/lib/enumerations/verificationStatus.js.map +1 -0
- package/src/lib/errors/blockFetchError.d.ts +51 -0
- package/src/lib/errors/blockFetchError.d.ts.map +1 -0
- package/src/lib/errors/blockFetchError.js +63 -0
- package/src/lib/errors/blockFetchError.js.map +1 -0
- package/src/lib/errors/cblError.d.ts.map +1 -1
- package/src/lib/errors/cblError.js +1 -0
- package/src/lib/errors/cblError.js.map +1 -1
- package/src/lib/errors/handleTupleError.d.ts +10 -1
- package/src/lib/errors/handleTupleError.d.ts.map +1 -1
- package/src/lib/errors/handleTupleError.js +10 -1
- package/src/lib/errors/handleTupleError.js.map +1 -1
- package/src/lib/errors/index.d.ts +16 -0
- package/src/lib/errors/index.d.ts.map +1 -1
- package/src/lib/errors/index.js +22 -0
- package/src/lib/errors/index.js.map +1 -1
- package/src/lib/errors/messaging/emailError.d.ts +55 -0
- package/src/lib/errors/messaging/emailError.d.ts.map +1 -0
- package/src/lib/errors/messaging/emailError.js +64 -0
- package/src/lib/errors/messaging/emailError.js.map +1 -0
- package/src/lib/errors/messaging/index.d.ts +1 -0
- package/src/lib/errors/messaging/index.d.ts.map +1 -1
- package/src/lib/errors/messaging/index.js +1 -0
- package/src/lib/errors/messaging/index.js.map +1 -1
- package/src/lib/errors/poolDeletionError.d.ts +10 -0
- package/src/lib/errors/poolDeletionError.d.ts.map +1 -0
- package/src/lib/errors/poolDeletionError.js +16 -0
- package/src/lib/errors/poolDeletionError.js.map +1 -0
- package/src/lib/errors/poolDeletionTombstoneError.d.ts +12 -0
- package/src/lib/errors/poolDeletionTombstoneError.d.ts.map +1 -0
- package/src/lib/errors/poolDeletionTombstoneError.js +18 -0
- package/src/lib/errors/poolDeletionTombstoneError.js.map +1 -0
- package/src/lib/errors/tupleError.d.ts.map +1 -1
- package/src/lib/errors/tupleError.js +1 -0
- package/src/lib/errors/tupleError.js.map +1 -1
- package/src/lib/i18n/i18n-setup.d.ts +7 -2
- package/src/lib/i18n/i18n-setup.d.ts.map +1 -1
- package/src/lib/i18n/i18n-setup.js +84 -24
- package/src/lib/i18n/i18n-setup.js.map +1 -1
- package/src/lib/i18n/strings/englishUs.d.ts.map +1 -1
- package/src/lib/i18n/strings/englishUs.js +4 -0
- package/src/lib/i18n/strings/englishUs.js.map +1 -1
- package/src/lib/i18n/strings/french.d.ts.map +1 -1
- package/src/lib/i18n/strings/french.js +4 -0
- package/src/lib/i18n/strings/french.js.map +1 -1
- package/src/lib/i18n/strings/german.d.ts.map +1 -1
- package/src/lib/i18n/strings/german.js +4 -0
- package/src/lib/i18n/strings/german.js.map +1 -1
- package/src/lib/i18n/strings/japanese.d.ts.map +1 -1
- package/src/lib/i18n/strings/japanese.js +4 -0
- package/src/lib/i18n/strings/japanese.js.map +1 -1
- package/src/lib/i18n/strings/mandarin.d.ts.map +1 -1
- package/src/lib/i18n/strings/mandarin.js +4 -0
- package/src/lib/i18n/strings/mandarin.js.map +1 -1
- package/src/lib/i18n/strings/spanish.d.ts.map +1 -1
- package/src/lib/i18n/strings/spanish.js +4 -0
- package/src/lib/i18n/strings/spanish.js.map +1 -1
- package/src/lib/i18n/strings/ukrainian.d.ts.map +1 -1
- package/src/lib/i18n/strings/ukrainian.js +4 -0
- package/src/lib/i18n/strings/ukrainian.js.map +1 -1
- package/src/lib/index.d.ts +4 -0
- package/src/lib/index.d.ts.map +1 -1
- package/src/lib/index.js +4 -0
- package/src/lib/index.js.map +1 -1
- package/src/lib/interfaces/auth/index.d.ts +4 -0
- package/src/lib/interfaces/auth/index.d.ts.map +1 -0
- package/src/lib/interfaces/auth/index.js +8 -0
- package/src/lib/interfaces/auth/index.js.map +1 -0
- package/src/lib/interfaces/auth/nodeAuthenticator.d.ts +19 -0
- package/src/lib/interfaces/auth/nodeAuthenticator.d.ts.map +1 -0
- package/src/lib/interfaces/auth/nodeAuthenticator.js +3 -0
- package/src/lib/interfaces/auth/nodeAuthenticator.js.map +1 -0
- package/src/lib/interfaces/auth/poolAcl.d.ts +65 -0
- package/src/lib/interfaces/auth/poolAcl.d.ts.map +1 -0
- package/src/lib/interfaces/auth/poolAcl.js +52 -0
- package/src/lib/interfaces/auth/poolAcl.js.map +1 -0
- package/src/lib/interfaces/availability/availabilityService.d.ts +5 -3
- package/src/lib/interfaces/availability/availabilityService.d.ts.map +1 -1
- package/src/lib/interfaces/availability/availabilityService.js.map +1 -1
- package/src/lib/interfaces/availability/blockRegistry.d.ts +52 -3
- package/src/lib/interfaces/availability/blockRegistry.d.ts.map +1 -1
- package/src/lib/interfaces/availability/blockRegistry.js +1 -1
- package/src/lib/interfaces/availability/discoveryProtocol.d.ts +81 -3
- package/src/lib/interfaces/availability/discoveryProtocol.d.ts.map +1 -1
- package/src/lib/interfaces/availability/discoveryProtocol.js.map +1 -1
- package/src/lib/interfaces/availability/gossipService.d.ts +279 -8
- package/src/lib/interfaces/availability/gossipService.d.ts.map +1 -1
- package/src/lib/interfaces/availability/gossipService.js +232 -0
- package/src/lib/interfaces/availability/gossipService.js.map +1 -1
- package/src/lib/interfaces/availability/index.d.ts +1 -0
- package/src/lib/interfaces/availability/index.d.ts.map +1 -1
- package/src/lib/interfaces/availability/index.js +1 -0
- package/src/lib/interfaces/availability/index.js.map +1 -1
- package/src/lib/interfaces/availability/locationRecord.d.ts +6 -0
- package/src/lib/interfaces/availability/locationRecord.d.ts.map +1 -1
- package/src/lib/interfaces/availability/locationRecord.js +12 -0
- package/src/lib/interfaces/availability/locationRecord.js.map +1 -1
- package/src/lib/interfaces/availability/poolDeletionTombstone.d.ts +40 -0
- package/src/lib/interfaces/availability/poolDeletionTombstone.d.ts.map +1 -0
- package/src/lib/interfaces/availability/poolDeletionTombstone.js +19 -0
- package/src/lib/interfaces/availability/poolDeletionTombstone.js.map +1 -0
- package/src/lib/interfaces/availability/reconciliationService.d.ts +52 -0
- package/src/lib/interfaces/availability/reconciliationService.d.ts.map +1 -1
- package/src/lib/interfaces/availability/reconciliationService.js.map +1 -1
- package/src/lib/interfaces/blockCapacity.d.ts +9 -0
- package/src/lib/interfaces/blockCapacity.d.ts.map +1 -1
- package/src/lib/interfaces/blockEncryption.d.ts +4 -2
- package/src/lib/interfaces/blockEncryption.d.ts.map +1 -1
- package/src/lib/interfaces/blockFetch/blockFetchTransport.d.ts +26 -0
- package/src/lib/interfaces/blockFetch/blockFetchTransport.d.ts.map +1 -0
- package/src/lib/interfaces/blockFetch/blockFetchTransport.js +12 -0
- package/src/lib/interfaces/blockFetch/blockFetchTransport.js.map +1 -0
- package/src/lib/interfaces/blockFetch/blockFetcher.d.ts +71 -0
- package/src/lib/interfaces/blockFetch/blockFetcher.d.ts.map +1 -0
- package/src/lib/interfaces/blockFetch/blockFetcher.js +22 -0
- package/src/lib/interfaces/blockFetch/blockFetcher.js.map +1 -0
- package/src/lib/interfaces/blockFetch/enrichedQueryResult.d.ts +43 -0
- package/src/lib/interfaces/blockFetch/enrichedQueryResult.d.ts.map +1 -0
- package/src/lib/interfaces/blockFetch/enrichedQueryResult.js +13 -0
- package/src/lib/interfaces/blockFetch/enrichedQueryResult.js.map +1 -0
- package/src/lib/interfaces/blockFetch/fetchQueue.d.ts +70 -0
- package/src/lib/interfaces/blockFetch/fetchQueue.d.ts.map +1 -0
- package/src/lib/interfaces/blockFetch/fetchQueue.js +18 -0
- package/src/lib/interfaces/blockFetch/fetchQueue.js.map +1 -0
- package/src/lib/interfaces/blockFetch/index.d.ts +10 -0
- package/src/lib/interfaces/blockFetch/index.d.ts.map +1 -0
- package/src/lib/interfaces/blockFetch/index.js +13 -0
- package/src/lib/interfaces/blockFetch/index.js.map +1 -0
- package/src/lib/interfaces/blocks/index.d.ts +1 -0
- package/src/lib/interfaces/blocks/index.d.ts.map +1 -1
- package/src/lib/interfaces/blocks/vcbl.d.ts +16 -0
- package/src/lib/interfaces/blocks/vcbl.d.ts.map +1 -0
- package/src/lib/interfaces/{messaging/messageRouter.js → blocks/vcbl.js} +1 -1
- package/src/lib/interfaces/blocks/vcbl.js.map +1 -0
- package/src/lib/interfaces/brightpass/auditLog.d.ts +25 -0
- package/src/lib/interfaces/brightpass/auditLog.d.ts.map +1 -0
- package/src/lib/interfaces/brightpass/auditLog.js +21 -0
- package/src/lib/interfaces/brightpass/auditLog.js.map +1 -0
- package/src/lib/interfaces/brightpass/emergencyAccess.d.ts +11 -0
- package/src/lib/interfaces/brightpass/emergencyAccess.d.ts.map +1 -0
- package/src/lib/interfaces/{network/networkTransport.js → brightpass/emergencyAccess.js} +1 -1
- package/src/lib/interfaces/brightpass/emergencyAccess.js.map +1 -0
- package/src/lib/interfaces/brightpass/entryPropertyRecord.d.ts +11 -0
- package/src/lib/interfaces/brightpass/entryPropertyRecord.d.ts.map +1 -0
- package/src/lib/interfaces/brightpass/entryPropertyRecord.js +3 -0
- package/src/lib/interfaces/brightpass/entryPropertyRecord.js.map +1 -0
- package/src/lib/interfaces/brightpass/importTypes.d.ts +10 -0
- package/src/lib/interfaces/brightpass/importTypes.d.ts.map +1 -0
- package/src/lib/interfaces/brightpass/importTypes.js +3 -0
- package/src/lib/interfaces/brightpass/importTypes.js.map +1 -0
- package/src/lib/interfaces/brightpass/index.d.ts +7 -0
- package/src/lib/interfaces/brightpass/index.d.ts.map +1 -0
- package/src/lib/interfaces/brightpass/index.js +10 -0
- package/src/lib/interfaces/brightpass/index.js.map +1 -0
- package/src/lib/interfaces/brightpass/vaultEntry.d.ts +48 -0
- package/src/lib/interfaces/brightpass/vaultEntry.d.ts.map +1 -0
- package/src/lib/interfaces/brightpass/vaultEntry.js +3 -0
- package/src/lib/interfaces/brightpass/vaultEntry.js.map +1 -0
- package/src/lib/interfaces/brightpass/vaultMetadata.d.ts +34 -0
- package/src/lib/interfaces/brightpass/vaultMetadata.d.ts.map +1 -0
- package/src/lib/interfaces/brightpass/vaultMetadata.js +3 -0
- package/src/lib/interfaces/brightpass/vaultMetadata.js.map +1 -0
- package/src/lib/interfaces/clusterKeys.d.ts +4 -2
- package/src/lib/interfaces/clusterKeys.d.ts.map +1 -1
- package/src/lib/interfaces/communication.d.ts +173 -0
- package/src/lib/interfaces/communication.d.ts.map +1 -0
- package/src/lib/interfaces/communication.js +17 -0
- package/src/lib/interfaces/communication.js.map +1 -0
- package/src/lib/interfaces/communicationEvents.d.ts +168 -0
- package/src/lib/interfaces/communicationEvents.d.ts.map +1 -0
- package/src/lib/interfaces/communicationEvents.js +12 -0
- package/src/lib/interfaces/communicationEvents.js.map +1 -0
- package/src/lib/interfaces/crypto/ethereumWallet.d.ts +72 -0
- package/src/lib/interfaces/crypto/ethereumWallet.d.ts.map +1 -0
- package/src/lib/interfaces/crypto/ethereumWallet.js +12 -0
- package/src/lib/interfaces/crypto/ethereumWallet.js.map +1 -0
- package/src/lib/interfaces/crypto/gitSignature.d.ts +95 -0
- package/src/lib/interfaces/crypto/gitSignature.d.ts.map +1 -0
- package/src/lib/interfaces/crypto/gitSignature.js +12 -0
- package/src/lib/interfaces/crypto/gitSignature.js.map +1 -0
- package/src/lib/interfaces/crypto/index.d.ts +3 -0
- package/src/lib/interfaces/crypto/index.d.ts.map +1 -0
- package/src/lib/interfaces/crypto/index.js +3 -0
- package/src/lib/interfaces/crypto/index.js.map +1 -0
- package/src/lib/interfaces/dataKeyComponents.d.ts +7 -2
- package/src/lib/interfaces/dataKeyComponents.d.ts.map +1 -1
- package/src/lib/interfaces/encryptedBlockCreator.d.ts +4 -2
- package/src/lib/interfaces/encryptedBlockCreator.d.ts.map +1 -1
- package/src/lib/interfaces/events/communicationEventEmitter.d.ts +65 -0
- package/src/lib/interfaces/events/communicationEventEmitter.d.ts.map +1 -0
- package/src/lib/interfaces/events/communicationEventEmitter.js +60 -0
- package/src/lib/interfaces/events/communicationEventEmitter.js.map +1 -0
- package/src/lib/interfaces/events/index.d.ts +2 -0
- package/src/lib/interfaces/events/index.d.ts.map +1 -0
- package/src/lib/interfaces/events/index.js +5 -0
- package/src/lib/interfaces/events/index.js.map +1 -0
- package/src/lib/interfaces/failableResult.d.ts +15 -0
- package/src/lib/interfaces/failableResult.d.ts.map +1 -0
- package/src/lib/interfaces/failableResult.js +3 -0
- package/src/lib/interfaces/failableResult.js.map +1 -0
- package/src/lib/interfaces/identity/device.d.ts +59 -0
- package/src/lib/interfaces/identity/device.d.ts.map +1 -0
- package/src/lib/interfaces/identity/device.js +17 -0
- package/src/lib/interfaces/identity/device.js.map +1 -0
- package/src/lib/interfaces/identity/deviceKeyStorage.d.ts +71 -0
- package/src/lib/interfaces/identity/deviceKeyStorage.d.ts.map +1 -0
- package/src/lib/interfaces/identity/deviceKeyStorage.js +16 -0
- package/src/lib/interfaces/identity/deviceKeyStorage.js.map +1 -0
- package/src/lib/interfaces/identity/identityProof.d.ts +90 -0
- package/src/lib/interfaces/identity/identityProof.d.ts.map +1 -0
- package/src/lib/interfaces/identity/identityProof.js +18 -0
- package/src/lib/interfaces/identity/identityProof.js.map +1 -0
- package/src/lib/interfaces/identity/index.d.ts +7 -0
- package/src/lib/interfaces/identity/index.d.ts.map +1 -0
- package/src/lib/interfaces/identity/index.js +3 -0
- package/src/lib/interfaces/identity/index.js.map +1 -0
- package/src/lib/interfaces/identity/paperKey.d.ts +97 -0
- package/src/lib/interfaces/identity/paperKey.d.ts.map +1 -0
- package/src/lib/interfaces/identity/paperKey.js +17 -0
- package/src/lib/interfaces/identity/paperKey.js.map +1 -0
- package/src/lib/interfaces/identity/publicProfile.d.ts +74 -0
- package/src/lib/interfaces/identity/publicProfile.d.ts.map +1 -0
- package/src/lib/interfaces/identity/publicProfile.js +18 -0
- package/src/lib/interfaces/identity/publicProfile.js.map +1 -0
- package/src/lib/interfaces/identity/splitPaperKey.d.ts +73 -0
- package/src/lib/interfaces/identity/splitPaperKey.d.ts.map +1 -0
- package/src/lib/interfaces/identity/splitPaperKey.js +20 -0
- package/src/lib/interfaces/identity/splitPaperKey.js.map +1 -0
- package/src/lib/interfaces/index.d.ts +11 -2
- package/src/lib/interfaces/index.d.ts.map +1 -1
- package/src/lib/interfaces/index.js +12 -0
- package/src/lib/interfaces/index.js.map +1 -1
- package/src/lib/interfaces/messaging/attachmentMetadata.d.ts +47 -0
- package/src/lib/interfaces/messaging/attachmentMetadata.d.ts.map +1 -0
- package/src/lib/interfaces/messaging/attachmentMetadata.js +3 -0
- package/src/lib/interfaces/messaging/attachmentMetadata.js.map +1 -0
- package/src/lib/interfaces/messaging/emailAddress.d.ts +210 -0
- package/src/lib/interfaces/messaging/emailAddress.d.ts.map +1 -0
- package/src/lib/interfaces/messaging/emailAddress.js +213 -0
- package/src/lib/interfaces/messaging/emailAddress.js.map +1 -0
- package/src/lib/interfaces/messaging/emailDelivery.d.ts +80 -0
- package/src/lib/interfaces/messaging/emailDelivery.d.ts.map +1 -0
- package/src/lib/interfaces/messaging/emailDelivery.js +50 -0
- package/src/lib/interfaces/messaging/emailDelivery.js.map +1 -0
- package/src/lib/interfaces/messaging/emailMetadata.d.ts +269 -0
- package/src/lib/interfaces/messaging/emailMetadata.d.ts.map +1 -0
- package/src/lib/interfaces/messaging/emailMetadata.js +16 -0
- package/src/lib/interfaces/messaging/emailMetadata.js.map +1 -0
- package/src/lib/interfaces/messaging/index.d.ts +5 -1
- package/src/lib/interfaces/messaging/index.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/index.js +5 -1
- package/src/lib/interfaces/messaging/index.js.map +1 -1
- package/src/lib/interfaces/messaging/messageMetadata.d.ts +2 -2
- package/src/lib/interfaces/messaging/messageMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/messageMetadataStore.d.ts +2 -2
- package/src/lib/interfaces/messaging/messageMetadataStore.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/mimePart.d.ts +214 -0
- package/src/lib/interfaces/messaging/mimePart.d.ts.map +1 -0
- package/src/lib/interfaces/messaging/mimePart.js +71 -0
- package/src/lib/interfaces/messaging/mimePart.js.map +1 -0
- package/src/lib/interfaces/network/index.d.ts +0 -1
- package/src/lib/interfaces/network/index.d.ts.map +1 -1
- package/src/lib/interfaces/network/node.d.ts +4 -2
- package/src/lib/interfaces/network/node.d.ts.map +1 -1
- package/src/lib/interfaces/network/nodeAdvertisement.d.ts +4 -2
- package/src/lib/interfaces/network/nodeAdvertisement.d.ts.map +1 -1
- package/src/lib/interfaces/privateVotingDerivation.d.ts +7 -2
- package/src/lib/interfaces/privateVotingDerivation.d.ts.map +1 -1
- package/src/lib/interfaces/requests/communicationRequests.d.ts +154 -0
- package/src/lib/interfaces/requests/communicationRequests.d.ts.map +1 -0
- package/src/lib/interfaces/requests/communicationRequests.js +10 -0
- package/src/lib/interfaces/requests/communicationRequests.js.map +1 -0
- package/src/lib/interfaces/requests/index.d.ts +2 -0
- package/src/lib/interfaces/requests/index.d.ts.map +1 -0
- package/src/lib/interfaces/requests/index.js +3 -0
- package/src/lib/interfaces/requests/index.js.map +1 -0
- package/src/lib/interfaces/responses/blockDataResponse.d.ts +11 -0
- package/src/lib/interfaces/responses/blockDataResponse.d.ts.map +1 -0
- package/src/lib/interfaces/responses/blockDataResponse.js +3 -0
- package/src/lib/interfaces/responses/blockDataResponse.js.map +1 -0
- package/src/lib/interfaces/responses/communicationResponses.d.ts +82 -0
- package/src/lib/interfaces/responses/communicationResponses.d.ts.map +1 -0
- package/src/lib/interfaces/responses/communicationResponses.js +17 -0
- package/src/lib/interfaces/responses/communicationResponses.js.map +1 -0
- package/src/lib/interfaces/responses/cryptoResponses.d.ts +30 -0
- package/src/lib/interfaces/responses/cryptoResponses.d.ts.map +1 -0
- package/src/lib/interfaces/responses/cryptoResponses.js +12 -0
- package/src/lib/interfaces/responses/cryptoResponses.js.map +1 -0
- package/src/lib/interfaces/responses/deviceResponses.d.ts +26 -0
- package/src/lib/interfaces/responses/deviceResponses.d.ts.map +1 -0
- package/src/lib/interfaces/responses/deviceResponses.js +15 -0
- package/src/lib/interfaces/responses/deviceResponses.js.map +1 -0
- package/src/lib/interfaces/responses/directoryResponses.d.ts +26 -0
- package/src/lib/interfaces/responses/directoryResponses.d.ts.map +1 -0
- package/src/lib/interfaces/responses/directoryResponses.js +12 -0
- package/src/lib/interfaces/responses/directoryResponses.js.map +1 -0
- package/src/lib/interfaces/responses/emailResponses.d.ts +40 -0
- package/src/lib/interfaces/responses/emailResponses.d.ts.map +1 -0
- package/src/lib/interfaces/responses/emailResponses.js +18 -0
- package/src/lib/interfaces/responses/emailResponses.js.map +1 -0
- package/src/lib/interfaces/responses/explodingMessageResponses.d.ts +42 -0
- package/src/lib/interfaces/responses/explodingMessageResponses.d.ts.map +1 -0
- package/src/lib/interfaces/responses/explodingMessageResponses.js +11 -0
- package/src/lib/interfaces/responses/explodingMessageResponses.js.map +1 -0
- package/src/lib/interfaces/responses/identityProofResponses.d.ts +33 -0
- package/src/lib/interfaces/responses/identityProofResponses.d.ts.map +1 -0
- package/src/lib/interfaces/responses/identityProofResponses.js +12 -0
- package/src/lib/interfaces/responses/identityProofResponses.js.map +1 -0
- package/src/lib/interfaces/responses/index.d.ts +3 -1
- package/src/lib/interfaces/responses/index.d.ts.map +1 -1
- package/src/lib/interfaces/sealResults.d.ts +7 -2
- package/src/lib/interfaces/sealResults.d.ts.map +1 -1
- package/src/lib/interfaces/services/fecService.d.ts +7 -5
- package/src/lib/interfaces/services/fecService.d.ts.map +1 -1
- package/src/lib/interfaces/services/fecService.js +2 -0
- package/src/lib/interfaces/services/fecService.js.map +1 -1
- package/src/lib/interfaces/singleEncryptedBlockDetails.d.ts +7 -2
- package/src/lib/interfaces/singleEncryptedBlockDetails.d.ts.map +1 -1
- package/src/lib/interfaces/storage/blockMetadata.d.ts +8 -1
- package/src/lib/interfaces/storage/blockMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/storage/blockMetadata.js +3 -1
- package/src/lib/interfaces/storage/blockMetadata.js.map +1 -1
- package/src/lib/interfaces/storage/cblIndex.d.ts +141 -0
- package/src/lib/interfaces/storage/cblIndex.d.ts.map +1 -0
- package/src/lib/interfaces/storage/cblIndex.js +28 -0
- package/src/lib/interfaces/storage/cblIndex.js.map +1 -0
- package/src/lib/interfaces/storage/clientSession.d.ts +22 -0
- package/src/lib/interfaces/storage/clientSession.d.ts.map +1 -0
- package/src/lib/interfaces/storage/clientSession.js +3 -0
- package/src/lib/interfaces/storage/clientSession.js.map +1 -0
- package/src/lib/interfaces/storage/collection.d.ts +80 -0
- package/src/lib/interfaces/storage/collection.d.ts.map +1 -0
- package/src/lib/interfaces/storage/collection.js +3 -0
- package/src/lib/interfaces/storage/collection.js.map +1 -0
- package/src/lib/interfaces/storage/database.d.ts +30 -0
- package/src/lib/interfaces/storage/database.d.ts.map +1 -0
- package/src/lib/interfaces/storage/database.js +3 -0
- package/src/lib/interfaces/storage/database.js.map +1 -0
- package/src/lib/interfaces/storage/databaseLifecycleHooks.d.ts +43 -0
- package/src/lib/interfaces/storage/databaseLifecycleHooks.d.ts.map +1 -0
- package/src/lib/interfaces/storage/databaseLifecycleHooks.js +3 -0
- package/src/lib/interfaces/storage/databaseLifecycleHooks.js.map +1 -0
- package/src/lib/interfaces/storage/documentTypes.d.ts +413 -0
- package/src/lib/interfaces/storage/documentTypes.d.ts.map +1 -0
- package/src/lib/interfaces/storage/documentTypes.js +8 -0
- package/src/lib/interfaces/storage/documentTypes.js.map +1 -0
- package/src/lib/interfaces/storage/encryptedPool.d.ts +64 -0
- package/src/lib/interfaces/storage/encryptedPool.d.ts.map +1 -0
- package/src/lib/interfaces/storage/encryptedPool.js +26 -0
- package/src/lib/interfaces/storage/encryptedPool.js.map +1 -0
- package/src/lib/interfaces/storage/headRegistry.d.ts +128 -0
- package/src/lib/interfaces/storage/headRegistry.d.ts.map +1 -0
- package/src/lib/interfaces/storage/headRegistry.js +3 -0
- package/src/lib/interfaces/storage/headRegistry.js.map +1 -0
- package/src/lib/interfaces/storage/index.d.ts +14 -0
- package/src/lib/interfaces/storage/index.d.ts.map +1 -1
- package/src/lib/interfaces/storage/index.js +14 -1
- package/src/lib/interfaces/storage/index.js.map +1 -1
- package/src/lib/interfaces/storage/pooledBlockStore.d.ts +163 -0
- package/src/lib/interfaces/storage/pooledBlockStore.d.ts.map +1 -0
- package/src/lib/interfaces/storage/pooledBlockStore.js +77 -0
- package/src/lib/interfaces/storage/pooledBlockStore.js.map +1 -0
- package/src/lib/interfaces/storage/readConcernBlockStore.d.ts +47 -0
- package/src/lib/interfaces/storage/readConcernBlockStore.d.ts.map +1 -0
- package/src/lib/interfaces/storage/readConcernBlockStore.js +29 -0
- package/src/lib/interfaces/storage/readConcernBlockStore.js.map +1 -0
- package/src/lib/interfaces/symmetricEncryptionResults.d.ts +7 -5
- package/src/lib/interfaces/symmetricEncryptionResults.d.ts.map +1 -1
- package/src/lib/schemas/messaging/messageMetadataSchema.d.ts.map +1 -1
- package/src/lib/schemas/messaging/messageMetadataSchema.js.map +1 -1
- package/src/lib/services/blockCapacity.service.d.ts.map +1 -1
- package/src/lib/services/blockCapacity.service.js +15 -0
- package/src/lib/services/blockCapacity.service.js.map +1 -1
- package/src/lib/services/brightpass/auditLogger.d.ts +41 -0
- package/src/lib/services/brightpass/auditLogger.d.ts.map +1 -0
- package/src/lib/services/brightpass/auditLogger.js +47 -0
- package/src/lib/services/brightpass/auditLogger.js.map +1 -0
- package/src/lib/services/brightpass/breachDetector.d.ts +68 -0
- package/src/lib/services/brightpass/breachDetector.d.ts.map +1 -0
- package/src/lib/services/brightpass/breachDetector.js +102 -0
- package/src/lib/services/brightpass/breachDetector.js.map +1 -0
- package/src/lib/services/brightpass/importParser.d.ts +105 -0
- package/src/lib/services/brightpass/importParser.d.ts.map +1 -0
- package/src/lib/services/brightpass/importParser.js +380 -0
- package/src/lib/services/brightpass/importParser.js.map +1 -0
- package/src/lib/services/brightpass/index.d.ts +16 -0
- package/src/lib/services/brightpass/index.d.ts.map +1 -0
- package/src/lib/services/brightpass/index.js +19 -0
- package/src/lib/services/brightpass/index.js.map +1 -0
- package/src/lib/services/brightpass/passwordGenerator.d.ts +111 -0
- package/src/lib/services/brightpass/passwordGenerator.d.ts.map +1 -0
- package/src/lib/services/brightpass/passwordGenerator.js +162 -0
- package/src/lib/services/brightpass/passwordGenerator.js.map +1 -0
- package/src/lib/services/brightpass/totpEngine.d.ts +191 -0
- package/src/lib/services/brightpass/totpEngine.d.ts.map +1 -0
- package/src/lib/services/brightpass/totpEngine.js +198 -0
- package/src/lib/services/brightpass/totpEngine.js.map +1 -0
- package/src/lib/services/brightpass/vaultKeyDerivation.d.ts +26 -0
- package/src/lib/services/brightpass/vaultKeyDerivation.d.ts.map +1 -0
- package/src/lib/services/brightpass/vaultKeyDerivation.js +42 -0
- package/src/lib/services/brightpass/vaultKeyDerivation.js.map +1 -0
- package/src/lib/services/brightpass/vaultSerializer.d.ts +14 -0
- package/src/lib/services/brightpass/vaultSerializer.d.ts.map +1 -0
- package/src/lib/services/brightpass/vaultSerializer.js +77 -0
- package/src/lib/services/brightpass/vaultSerializer.js.map +1 -0
- package/src/lib/services/cblService.d.ts +4 -2
- package/src/lib/services/cblService.d.ts.map +1 -1
- package/src/lib/services/cblService.js +8 -4
- package/src/lib/services/cblService.js.map +1 -1
- package/src/lib/services/communication/channelService.d.ts +208 -0
- package/src/lib/services/communication/channelService.d.ts.map +1 -0
- package/src/lib/services/communication/channelService.js +575 -0
- package/src/lib/services/communication/channelService.js.map +1 -0
- package/src/lib/services/communication/conversationService.d.ts +130 -0
- package/src/lib/services/communication/conversationService.d.ts.map +1 -0
- package/src/lib/services/communication/conversationService.js +279 -0
- package/src/lib/services/communication/conversationService.js.map +1 -0
- package/src/lib/services/communication/explodingMessageService.d.ts +168 -0
- package/src/lib/services/communication/explodingMessageService.d.ts.map +1 -0
- package/src/lib/services/communication/explodingMessageService.js +287 -0
- package/src/lib/services/communication/explodingMessageService.js.map +1 -0
- package/src/lib/services/communication/groupService.d.ts +165 -0
- package/src/lib/services/communication/groupService.d.ts.map +1 -0
- package/src/lib/services/communication/groupService.js +437 -0
- package/src/lib/services/communication/groupService.js.map +1 -0
- package/src/lib/services/communication/index.d.ts +16 -0
- package/src/lib/services/communication/index.d.ts.map +1 -0
- package/src/lib/services/communication/index.js +63 -0
- package/src/lib/services/communication/index.js.map +1 -0
- package/src/lib/services/communication/messageOperationsService.d.ts +81 -0
- package/src/lib/services/communication/messageOperationsService.d.ts.map +1 -0
- package/src/lib/services/communication/messageOperationsService.js +162 -0
- package/src/lib/services/communication/messageOperationsService.js.map +1 -0
- package/src/lib/services/communication/permissionService.d.ts +47 -0
- package/src/lib/services/communication/permissionService.d.ts.map +1 -0
- package/src/lib/services/communication/permissionService.js +82 -0
- package/src/lib/services/communication/permissionService.js.map +1 -0
- package/src/lib/services/communication/searchService.d.ts +30 -0
- package/src/lib/services/communication/searchService.d.ts.map +1 -0
- package/src/lib/services/communication/searchService.js +83 -0
- package/src/lib/services/communication/searchService.js.map +1 -0
- package/src/lib/services/crypto/ethereumWalletService.d.ts +159 -0
- package/src/lib/services/crypto/ethereumWalletService.d.ts.map +1 -0
- package/src/lib/services/crypto/ethereumWalletService.js +345 -0
- package/src/lib/services/crypto/ethereumWalletService.js.map +1 -0
- package/src/lib/services/crypto/gitSigningService.d.ts +145 -0
- package/src/lib/services/crypto/gitSigningService.d.ts.map +1 -0
- package/src/lib/services/crypto/gitSigningService.js +291 -0
- package/src/lib/services/crypto/gitSigningService.js.map +1 -0
- package/src/lib/services/crypto/index.d.ts +3 -0
- package/src/lib/services/crypto/index.d.ts.map +1 -0
- package/src/lib/services/crypto/index.js +6 -0
- package/src/lib/services/crypto/index.js.map +1 -0
- package/src/lib/services/identity/deviceProvisioningService.d.ts +146 -0
- package/src/lib/services/identity/deviceProvisioningService.d.ts.map +1 -0
- package/src/lib/services/identity/deviceProvisioningService.js +219 -0
- package/src/lib/services/identity/deviceProvisioningService.js.map +1 -0
- package/src/lib/services/identity/identityProofService.d.ts +139 -0
- package/src/lib/services/identity/identityProofService.d.ts.map +1 -0
- package/src/lib/services/identity/identityProofService.js +245 -0
- package/src/lib/services/identity/identityProofService.js.map +1 -0
- package/src/lib/services/identity/index.d.ts +14 -0
- package/src/lib/services/identity/index.d.ts.map +1 -0
- package/src/lib/services/identity/index.js +17 -0
- package/src/lib/services/identity/index.js.map +1 -0
- package/src/lib/services/identity/memberIdentityProofService.d.ts +179 -0
- package/src/lib/services/identity/memberIdentityProofService.d.ts.map +1 -0
- package/src/lib/services/identity/memberIdentityProofService.js +232 -0
- package/src/lib/services/identity/memberIdentityProofService.js.map +1 -0
- package/src/lib/services/identity/memberPaperKeyService.d.ts +223 -0
- package/src/lib/services/identity/memberPaperKeyService.d.ts.map +1 -0
- package/src/lib/services/identity/memberPaperKeyService.js +279 -0
- package/src/lib/services/identity/memberPaperKeyService.js.map +1 -0
- package/src/lib/services/identity/paperKeyService.d.ts +106 -0
- package/src/lib/services/identity/paperKeyService.d.ts.map +1 -0
- package/src/lib/services/identity/paperKeyService.js +161 -0
- package/src/lib/services/identity/paperKeyService.js.map +1 -0
- package/src/lib/services/identity/publicKeyDirectoryService.d.ts +210 -0
- package/src/lib/services/identity/publicKeyDirectoryService.d.ts.map +1 -0
- package/src/lib/services/identity/publicKeyDirectoryService.js +328 -0
- package/src/lib/services/identity/publicKeyDirectoryService.js.map +1 -0
- package/src/lib/services/identity/splitPaperKeyService.d.ts +92 -0
- package/src/lib/services/identity/splitPaperKeyService.d.ts.map +1 -0
- package/src/lib/services/identity/splitPaperKeyService.js +305 -0
- package/src/lib/services/identity/splitPaperKeyService.js.map +1 -0
- package/src/lib/services/index.d.ts +4 -0
- package/src/lib/services/index.d.ts.map +1 -1
- package/src/lib/services/index.js +7 -0
- package/src/lib/services/index.js.map +1 -1
- package/src/lib/services/messaging/deliveryTimeoutService.js +2 -2
- package/src/lib/services/messaging/deliveryTimeoutService.js.map +1 -1
- package/src/lib/services/messaging/emailEncryptionService.d.ts +250 -0
- package/src/lib/services/messaging/emailEncryptionService.d.ts.map +1 -0
- package/src/lib/services/messaging/emailEncryptionService.js +420 -0
- package/src/lib/services/messaging/emailEncryptionService.js.map +1 -0
- package/src/lib/services/messaging/emailMessageService.d.ts +669 -0
- package/src/lib/services/messaging/emailMessageService.d.ts.map +1 -0
- package/src/lib/services/messaging/emailMessageService.js +1030 -0
- package/src/lib/services/messaging/emailMessageService.js.map +1 -0
- package/src/lib/services/messaging/emailParser.d.ts +476 -0
- package/src/lib/services/messaging/emailParser.d.ts.map +1 -0
- package/src/lib/services/messaging/emailParser.js +1316 -0
- package/src/lib/services/messaging/emailParser.js.map +1 -0
- package/src/lib/services/messaging/emailSerializer.d.ts +403 -0
- package/src/lib/services/messaging/emailSerializer.d.ts.map +1 -0
- package/src/lib/services/messaging/emailSerializer.js +852 -0
- package/src/lib/services/messaging/emailSerializer.js.map +1 -0
- package/src/lib/services/messaging/emailValidator.d.ts +448 -0
- package/src/lib/services/messaging/emailValidator.d.ts.map +1 -0
- package/src/lib/services/messaging/emailValidator.js +810 -0
- package/src/lib/services/messaging/emailValidator.js.map +1 -0
- package/src/lib/services/messaging/gossipRetryService.d.ts +204 -0
- package/src/lib/services/messaging/gossipRetryService.d.ts.map +1 -0
- package/src/lib/services/messaging/gossipRetryService.js +319 -0
- package/src/lib/services/messaging/gossipRetryService.js.map +1 -0
- package/src/lib/services/messaging/inMemoryEmailMetadataStore.d.ts +60 -0
- package/src/lib/services/messaging/inMemoryEmailMetadataStore.d.ts.map +1 -0
- package/src/lib/services/messaging/inMemoryEmailMetadataStore.js +281 -0
- package/src/lib/services/messaging/inMemoryEmailMetadataStore.js.map +1 -0
- package/src/lib/services/messaging/index.d.ts +11 -5
- package/src/lib/services/messaging/index.d.ts.map +1 -1
- package/src/lib/services/messaging/index.js +19 -5
- package/src/lib/services/messaging/index.js.map +1 -1
- package/src/lib/services/messaging/messageCBLService.js +2 -2
- package/src/lib/services/messaging/messageCBLService.js.map +1 -1
- package/src/lib/services/tuple.service.d.ts +27 -2
- package/src/lib/services/tuple.service.d.ts.map +1 -1
- package/src/lib/services/tuple.service.js +62 -20
- package/src/lib/services/tuple.service.js.map +1 -1
- package/src/lib/services/vcblService.d.ts +36 -0
- package/src/lib/services/vcblService.d.ts.map +1 -0
- package/src/lib/services/vcblService.js +326 -0
- package/src/lib/services/vcblService.js.map +1 -0
- package/src/lib/stores/index.d.ts +1 -0
- package/src/lib/stores/index.d.ts.map +1 -1
- package/src/lib/stores/index.js +1 -0
- package/src/lib/stores/index.js.map +1 -1
- package/src/lib/stores/messaging/memoryMessageMetadataStore.d.ts +2 -2
- package/src/lib/stores/messaging/memoryMessageMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/messaging/memoryMessageMetadataStore.js +2 -2
- package/src/lib/stores/messaging/memoryMessageMetadataStore.js.map +1 -1
- package/src/lib/stores/pooledMemoryBlockStore.d.ts +134 -0
- package/src/lib/stores/pooledMemoryBlockStore.d.ts.map +1 -0
- package/src/lib/stores/pooledMemoryBlockStore.js +583 -0
- package/src/lib/stores/pooledMemoryBlockStore.js.map +1 -0
- package/src/lib/types/checksum.d.ts +11 -0
- package/src/lib/types/checksum.d.ts.map +1 -1
- package/src/lib/types/checksum.js +11 -0
- package/src/lib/types/checksum.js.map +1 -1
- package/src/lib/utils/index.d.ts +9 -0
- package/src/lib/utils/index.d.ts.map +1 -1
- package/src/lib/utils/index.js +12 -0
- package/src/lib/utils/index.js.map +1 -1
- package/src/lib/utils/pagination.d.ts +27 -0
- package/src/lib/utils/pagination.d.ts.map +1 -0
- package/src/lib/utils/pagination.js +38 -0
- package/src/lib/utils/pagination.js.map +1 -0
- package/src/lib/enumerations/messaging/messageDeliveryStatus.d.ts +0 -18
- package/src/lib/enumerations/messaging/messageDeliveryStatus.d.ts.map +0 -1
- package/src/lib/enumerations/messaging/messageDeliveryStatus.js +0 -22
- package/src/lib/enumerations/messaging/messageDeliveryStatus.js.map +0 -1
- package/src/lib/enumerations/messaging/routingStrategy.d.ts +0 -12
- package/src/lib/enumerations/messaging/routingStrategy.d.ts.map +0 -1
- package/src/lib/enumerations/messaging/routingStrategy.js +0 -16
- package/src/lib/enumerations/messaging/routingStrategy.js.map +0 -1
- package/src/lib/interfaces/messaging/messageRouter.d.ts +0 -48
- package/src/lib/interfaces/messaging/messageRouter.d.ts.map +0 -1
- package/src/lib/interfaces/messaging/messageRouter.js.map +0 -1
- package/src/lib/interfaces/network/networkTransport.d.ts +0 -19
- package/src/lib/interfaces/network/networkTransport.d.ts.map +0 -1
- package/src/lib/interfaces/network/networkTransport.js.map +0 -1
- package/src/lib/services/messaging/broadcastMessageRouter.d.ts +0 -18
- package/src/lib/services/messaging/broadcastMessageRouter.d.ts.map +0 -1
- package/src/lib/services/messaging/broadcastMessageRouter.js +0 -32
- package/src/lib/services/messaging/broadcastMessageRouter.js.map +0 -1
- package/src/lib/services/messaging/directMessageRouter.d.ts +0 -25
- package/src/lib/services/messaging/directMessageRouter.d.ts.map +0 -1
- package/src/lib/services/messaging/directMessageRouter.js +0 -58
- package/src/lib/services/messaging/directMessageRouter.js.map +0 -1
- package/src/lib/services/messaging/messageForwardingService.d.ts +0 -40
- package/src/lib/services/messaging/messageForwardingService.d.ts.map +0 -1
- package/src/lib/services/messaging/messageForwardingService.js +0 -74
- package/src/lib/services/messaging/messageForwardingService.js.map +0 -1
- package/src/lib/services/messaging/messageRouter.d.ts +0 -24
- package/src/lib/services/messaging/messageRouter.d.ts.map +0 -1
- package/src/lib/services/messaging/messageRouter.js +0 -111
- package/src/lib/services/messaging/messageRouter.js.map +0 -1
- package/src/lib/services/messaging/webSocketTransport.d.ts +0 -34
- package/src/lib/services/messaging/webSocketTransport.d.ts.map +0 -1
- package/src/lib/services/messaging/webSocketTransport.js +0 -115
- package/src/lib/services/messaging/webSocketTransport.js.map +0 -1
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Email Message Service
|
|
4
|
+
*
|
|
5
|
+
* Main service for email operations in the BrightChain messaging system.
|
|
6
|
+
* Coordinates parsing, validation, storage, and delivery of RFC 5322
|
|
7
|
+
* compliant email messages.
|
|
8
|
+
*
|
|
9
|
+
* This service depends on:
|
|
10
|
+
* - MessageCBLService: For storing email content as CBL blocks
|
|
11
|
+
* - IGossipService: For delivering messages via gossip protocol
|
|
12
|
+
* - IEmailMetadataStore: For persisting email metadata
|
|
13
|
+
* - EmailParser, EmailSerializer, EmailValidator: For email processing
|
|
14
|
+
*
|
|
15
|
+
* @see RFC 5322 - Internet Message Format
|
|
16
|
+
* @see RFC 2045/2046 - MIME
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Requirements: 1.1-1.10
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.EmailMessageService = exports.DEFAULT_EMAIL_SERVICE_CONFIG = void 0;
|
|
23
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
24
|
+
const platformCrypto_1 = require("../../crypto/platformCrypto");
|
|
25
|
+
const durabilityLevel_1 = require("../../enumerations/durabilityLevel");
|
|
26
|
+
const deliveryStatus_1 = require("../../enumerations/messaging/deliveryStatus");
|
|
27
|
+
const emailErrorType_1 = require("../../enumerations/messaging/emailErrorType");
|
|
28
|
+
const messageEncryptionScheme_1 = require("../../enumerations/messaging/messageEncryptionScheme");
|
|
29
|
+
const messagePriority_1 = require("../../enumerations/messaging/messagePriority");
|
|
30
|
+
const replicationStatus_1 = require("../../enumerations/replicationStatus");
|
|
31
|
+
const emailError_1 = require("../../errors/messaging/emailError");
|
|
32
|
+
const mimePart_1 = require("../../interfaces/messaging/mimePart");
|
|
33
|
+
const emailEncryptionService_1 = require("./emailEncryptionService");
|
|
34
|
+
const emailValidator_1 = require("./emailValidator");
|
|
35
|
+
/**
|
|
36
|
+
* Default configuration values for EmailMessageService.
|
|
37
|
+
*/
|
|
38
|
+
exports.DEFAULT_EMAIL_SERVICE_CONFIG = {
|
|
39
|
+
maxAttachmentSize: 25 * 1024 * 1024, // 25MB
|
|
40
|
+
maxMessageSize: 50 * 1024 * 1024, // 50MB
|
|
41
|
+
inlinePartThreshold: 64 * 1024, // 64KB
|
|
42
|
+
maxInlinePartsTotal: 256 * 1024, // 256KB
|
|
43
|
+
defaultPageSize: 50,
|
|
44
|
+
maxReferencesCount: 20,
|
|
45
|
+
maxRetryAttempts: 3,
|
|
46
|
+
deliveryTimeoutMs: 24 * 60 * 60 * 1000, // 24 hours
|
|
47
|
+
nodeId: 'localhost',
|
|
48
|
+
};
|
|
49
|
+
// ─── EmailMessageService Class ──────────────────────────────────────────────
|
|
50
|
+
/**
|
|
51
|
+
* Main service for email operations in the BrightChain messaging system.
|
|
52
|
+
*
|
|
53
|
+
* Coordinates parsing, validation, storage, and delivery of RFC 5322
|
|
54
|
+
* compliant email messages. This service acts as the primary entry point
|
|
55
|
+
* for all email-related operations.
|
|
56
|
+
*
|
|
57
|
+
* @see Design Document: EmailMessageService Class
|
|
58
|
+
* @see Requirements 1.1-1.10
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const emailService = new EmailMessageService(
|
|
63
|
+
* messageCBLService,
|
|
64
|
+
* metadataStore,
|
|
65
|
+
* gossipService,
|
|
66
|
+
* config,
|
|
67
|
+
* );
|
|
68
|
+
*
|
|
69
|
+
* const result = await emailService.sendEmail({
|
|
70
|
+
* from: createMailbox('sender', 'example.com'),
|
|
71
|
+
* to: [createMailbox('recipient', 'example.com')],
|
|
72
|
+
* subject: 'Hello',
|
|
73
|
+
* textBody: 'Hello, World!',
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
class EmailMessageService {
|
|
78
|
+
constructor(messageCBLService, metadataStore, gossipService, config) {
|
|
79
|
+
this.messageCBLService = messageCBLService;
|
|
80
|
+
this.metadataStore = metadataStore;
|
|
81
|
+
this.gossipService = gossipService;
|
|
82
|
+
this.config = { ...exports.DEFAULT_EMAIL_SERVICE_CONFIG, ...config };
|
|
83
|
+
}
|
|
84
|
+
// ─── Core Operations ────────────────────────────────────────────────
|
|
85
|
+
/**
|
|
86
|
+
* Sends an email message.
|
|
87
|
+
*
|
|
88
|
+
* Validates the email, auto-generates required headers (Message-ID, Date),
|
|
89
|
+
* stores the email content as CBL blocks, and initiates delivery to
|
|
90
|
+
* all recipients.
|
|
91
|
+
*
|
|
92
|
+
* @param email - The email input to send
|
|
93
|
+
* @returns The send result with message ID and delivery status
|
|
94
|
+
* @throws {EmailError} If validation fails or storage/delivery errors occur
|
|
95
|
+
*
|
|
96
|
+
* @see Requirement 15.1 - Validate at least one recipient
|
|
97
|
+
* @see Requirement 15.4 - Auto-generate required headers
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Sends an email message.
|
|
101
|
+
*
|
|
102
|
+
* Validates the email, auto-generates required headers (Message-ID, Date),
|
|
103
|
+
* stores the email content as CBL blocks, and initiates delivery to
|
|
104
|
+
* all recipients.
|
|
105
|
+
*
|
|
106
|
+
* @param email - The email input to send
|
|
107
|
+
* @returns The send result with message ID and delivery status
|
|
108
|
+
* @throws {EmailError} If validation fails or storage/delivery errors occur
|
|
109
|
+
*
|
|
110
|
+
* @see Requirement 15.1 - Validate at least one recipient
|
|
111
|
+
* @see Requirement 15.4 - Auto-generate required headers
|
|
112
|
+
*/
|
|
113
|
+
async sendEmail(email) {
|
|
114
|
+
// 1. Auto-generate required headers if missing
|
|
115
|
+
const messageId = email.messageId ?? this.generateMessageId();
|
|
116
|
+
const date = email.date ?? new Date();
|
|
117
|
+
// 2. Adapt service IEmailInput to validator's IEmailInput and validate
|
|
118
|
+
const validatorInput = {
|
|
119
|
+
from: email.from,
|
|
120
|
+
to: email.to,
|
|
121
|
+
cc: email.cc,
|
|
122
|
+
bcc: email.bcc,
|
|
123
|
+
subject: email.subject,
|
|
124
|
+
date,
|
|
125
|
+
messageId,
|
|
126
|
+
contentType: email.contentType,
|
|
127
|
+
attachments: email.attachments
|
|
128
|
+
? email.attachments.map((a) => ({
|
|
129
|
+
filename: a.filename,
|
|
130
|
+
size: a.content.length,
|
|
131
|
+
}))
|
|
132
|
+
: undefined,
|
|
133
|
+
bodySize: (email.textBody ? new TextEncoder().encode(email.textBody).length : 0) +
|
|
134
|
+
(email.htmlBody ? new TextEncoder().encode(email.htmlBody).length : 0),
|
|
135
|
+
};
|
|
136
|
+
const emailValidator = new emailValidator_1.EmailValidator();
|
|
137
|
+
const validationResult = emailValidator.validate(validatorInput, {
|
|
138
|
+
maxAttachmentSize: this.config.maxAttachmentSize,
|
|
139
|
+
maxMessageSize: this.config.maxMessageSize,
|
|
140
|
+
});
|
|
141
|
+
if (!validationResult.valid) {
|
|
142
|
+
return {
|
|
143
|
+
messageId,
|
|
144
|
+
brightchainMessageId: '',
|
|
145
|
+
deliveryStatus: new Map(),
|
|
146
|
+
success: false,
|
|
147
|
+
error: validationResult.errors
|
|
148
|
+
.map((e) => `${e.field}: ${e.message}`)
|
|
149
|
+
.join('; '),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// 3. Build IEmailMetadata from the input
|
|
153
|
+
const brightchainMessageId = this.generateMessageId();
|
|
154
|
+
const now = new Date();
|
|
155
|
+
// Collect all recipient addresses for IMessageMetadata.recipients
|
|
156
|
+
const allRecipientAddresses = [];
|
|
157
|
+
if (email.to) {
|
|
158
|
+
allRecipientAddresses.push(...email.to.map((m) => m.address));
|
|
159
|
+
}
|
|
160
|
+
if (email.cc) {
|
|
161
|
+
allRecipientAddresses.push(...email.cc.map((m) => m.address));
|
|
162
|
+
}
|
|
163
|
+
if (email.bcc) {
|
|
164
|
+
allRecipientAddresses.push(...email.bcc.map((m) => m.address));
|
|
165
|
+
}
|
|
166
|
+
const contentType = email.contentType ??
|
|
167
|
+
(0, mimePart_1.createContentType)('text', 'plain', new Map([['charset', 'us-ascii']]));
|
|
168
|
+
const metadata = {
|
|
169
|
+
// IBlockMetadata fields
|
|
170
|
+
blockId: brightchainMessageId,
|
|
171
|
+
createdAt: now,
|
|
172
|
+
expiresAt: null,
|
|
173
|
+
durabilityLevel: durabilityLevel_1.DurabilityLevel.Standard,
|
|
174
|
+
parityBlockIds: [],
|
|
175
|
+
accessCount: 0,
|
|
176
|
+
lastAccessedAt: now,
|
|
177
|
+
replicationStatus: replicationStatus_1.ReplicationStatus.Pending,
|
|
178
|
+
targetReplicationFactor: 0,
|
|
179
|
+
replicaNodeIds: [],
|
|
180
|
+
size: (email.textBody ? new TextEncoder().encode(email.textBody).length : 0) +
|
|
181
|
+
(email.htmlBody ? new TextEncoder().encode(email.htmlBody).length : 0) +
|
|
182
|
+
(email.attachments
|
|
183
|
+
? email.attachments.reduce((sum, a) => sum + a.content.length, 0)
|
|
184
|
+
: 0),
|
|
185
|
+
checksum: '',
|
|
186
|
+
// IMessageMetadata fields
|
|
187
|
+
messageType: 'email',
|
|
188
|
+
senderId: email.from.address,
|
|
189
|
+
recipients: allRecipientAddresses,
|
|
190
|
+
priority: messagePriority_1.MessagePriority.NORMAL,
|
|
191
|
+
deliveryStatus: new Map(allRecipientAddresses.map((addr) => [addr, deliveryStatus_1.DeliveryStatus.Pending])),
|
|
192
|
+
acknowledgments: new Map(),
|
|
193
|
+
encryptionScheme: email.encryptionScheme ?? messageEncryptionScheme_1.MessageEncryptionScheme.NONE,
|
|
194
|
+
isCBL: false,
|
|
195
|
+
cblBlockIds: [brightchainMessageId],
|
|
196
|
+
// IEmailMetadata fields
|
|
197
|
+
from: email.from,
|
|
198
|
+
sender: email.sender,
|
|
199
|
+
replyTo: email.replyTo,
|
|
200
|
+
to: email.to ?? [],
|
|
201
|
+
cc: email.cc,
|
|
202
|
+
bcc: email.bcc,
|
|
203
|
+
messageId,
|
|
204
|
+
inReplyTo: email.inReplyTo,
|
|
205
|
+
references: email.references,
|
|
206
|
+
subject: email.subject,
|
|
207
|
+
date,
|
|
208
|
+
mimeVersion: '1.0',
|
|
209
|
+
contentType,
|
|
210
|
+
customHeaders: email.customHeaders ?? new Map(),
|
|
211
|
+
parts: email.parts,
|
|
212
|
+
attachments: undefined,
|
|
213
|
+
deliveryReceipts: new Map(),
|
|
214
|
+
readReceipts: new Map(),
|
|
215
|
+
};
|
|
216
|
+
// 3b. Process attachments if provided
|
|
217
|
+
if (email.attachments && email.attachments.length > 0) {
|
|
218
|
+
metadata.attachments = await Promise.all(email.attachments.map((attachment) => this.storeAttachment(attachment)));
|
|
219
|
+
}
|
|
220
|
+
// 3c. Apply encryption if requested (Requirements 16.1, 16.3, 16.4, 16.7)
|
|
221
|
+
if (email.encryptionScheme &&
|
|
222
|
+
email.encryptionScheme !== messageEncryptionScheme_1.MessageEncryptionScheme.NONE) {
|
|
223
|
+
try {
|
|
224
|
+
const encryptionService = new emailEncryptionService_1.EmailEncryptionService();
|
|
225
|
+
// Build plaintext content from the email body
|
|
226
|
+
const bodyContent = new TextEncoder().encode((email.textBody ?? '') + (email.htmlBody ?? ''));
|
|
227
|
+
if (email.encryptionScheme === messageEncryptionScheme_1.MessageEncryptionScheme.RECIPIENT_KEYS) {
|
|
228
|
+
// ECIES per-recipient encryption
|
|
229
|
+
if (!email.recipientPublicKeys ||
|
|
230
|
+
email.recipientPublicKeys.size === 0) {
|
|
231
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.ENCRYPTION_FAILED, 'Recipient public keys are required for RECIPIENT_KEYS encryption');
|
|
232
|
+
}
|
|
233
|
+
// Optionally sign if sender keys are provided
|
|
234
|
+
let result;
|
|
235
|
+
if (email.senderPrivateKey && email.senderPublicKey) {
|
|
236
|
+
result = await encryptionService.encryptAndSign(bodyContent, email.recipientPublicKeys, email.senderPrivateKey, email.senderPublicKey);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
result = await encryptionService.encryptForRecipients(bodyContent, email.recipientPublicKeys);
|
|
240
|
+
}
|
|
241
|
+
// Store encryption metadata in the email metadata
|
|
242
|
+
metadata.encryptedKeys = result.encryptionMetadata.encryptedKeys;
|
|
243
|
+
metadata.encryptionIv = result.encryptionMetadata.iv;
|
|
244
|
+
metadata.encryptionAuthTag = result.encryptionMetadata.authTag;
|
|
245
|
+
metadata.isSigned = result.encryptionMetadata.isSigned;
|
|
246
|
+
metadata.contentSignature = result.encryptionMetadata.signature;
|
|
247
|
+
metadata.signerPublicKey = result.encryptionMetadata.signerPublicKey;
|
|
248
|
+
}
|
|
249
|
+
else if (email.encryptionScheme === messageEncryptionScheme_1.MessageEncryptionScheme.SHARED_KEY) {
|
|
250
|
+
// Symmetric encryption with shared key
|
|
251
|
+
if (!email.sharedKey) {
|
|
252
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.ENCRYPTION_FAILED, 'Shared key is required for SHARED_KEY encryption');
|
|
253
|
+
}
|
|
254
|
+
const result = encryptionService.encryptContentSymmetric(bodyContent, email.sharedKey);
|
|
255
|
+
metadata.encryptionIv = result.encryptionMetadata.iv;
|
|
256
|
+
metadata.encryptionAuthTag = result.encryptionMetadata.authTag;
|
|
257
|
+
// Optionally sign
|
|
258
|
+
if (email.senderPrivateKey && email.senderPublicKey) {
|
|
259
|
+
const sig = encryptionService.signContent(bodyContent, email.senderPrivateKey, email.senderPublicKey);
|
|
260
|
+
metadata.isSigned = true;
|
|
261
|
+
metadata.contentSignature = sig.signature;
|
|
262
|
+
metadata.signerPublicKey = sig.signerPublicKey;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
else if (email.encryptionScheme === messageEncryptionScheme_1.MessageEncryptionScheme.S_MIME) {
|
|
266
|
+
// S/MIME encryption: requires both recipient keys and sender keys
|
|
267
|
+
if (!email.recipientPublicKeys ||
|
|
268
|
+
email.recipientPublicKeys.size === 0) {
|
|
269
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.ENCRYPTION_FAILED, 'Recipient public keys are required for S/MIME encryption');
|
|
270
|
+
}
|
|
271
|
+
if (!email.senderPrivateKey || !email.senderPublicKey) {
|
|
272
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.ENCRYPTION_FAILED, 'Sender private and public keys are required for S/MIME encryption');
|
|
273
|
+
}
|
|
274
|
+
const result = await encryptionService.encryptSmime(bodyContent, email.recipientPublicKeys, email.senderPrivateKey, email.senderPublicKey);
|
|
275
|
+
metadata.encryptedKeys = result.encryptionMetadata.encryptedKeys;
|
|
276
|
+
metadata.encryptionIv = result.encryptionMetadata.iv;
|
|
277
|
+
metadata.encryptionAuthTag = result.encryptionMetadata.authTag;
|
|
278
|
+
metadata.isSigned = result.encryptionMetadata.isSigned;
|
|
279
|
+
metadata.contentSignature = result.encryptionMetadata.signature;
|
|
280
|
+
metadata.signerPublicKey = result.encryptionMetadata.signerPublicKey;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
if (err instanceof emailError_1.EmailError)
|
|
285
|
+
throw err;
|
|
286
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.ENCRYPTION_FAILED, `Failed to encrypt email: ${err instanceof Error ? err.message : String(err)}`, { messageId });
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// 4. Store the sender's copy (retains BCC info for sender's records)
|
|
290
|
+
try {
|
|
291
|
+
await this.metadataStore.store(metadata);
|
|
292
|
+
}
|
|
293
|
+
catch (err) {
|
|
294
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.STORAGE_FAILED, `Failed to store email metadata: ${err instanceof Error ? err.message : String(err)}`, { messageId });
|
|
295
|
+
}
|
|
296
|
+
// 5. Initiate delivery to recipients via gossip with BCC privacy handling
|
|
297
|
+
//
|
|
298
|
+
// BCC Privacy (Requirements 9.2, 9.3, 6.3):
|
|
299
|
+
// - To/CC recipients receive a single gossip announcement WITHOUT BCC info
|
|
300
|
+
// - Each BCC recipient receives their own separate gossip announcement
|
|
301
|
+
// - All announcements have ackRequired=true (Requirement 6.5)
|
|
302
|
+
try {
|
|
303
|
+
// 5a. Deliver to To/CC recipients (no BCC info)
|
|
304
|
+
const toCcRecipientIds = [
|
|
305
|
+
...(email.to ?? []).map((m) => m.address),
|
|
306
|
+
...(email.cc ?? []).map((m) => m.address),
|
|
307
|
+
];
|
|
308
|
+
if (toCcRecipientIds.length > 0) {
|
|
309
|
+
const toCcMetadata = this.createBccStrippedCopy(metadata);
|
|
310
|
+
await this.metadataStore.store(toCcMetadata);
|
|
311
|
+
await this.gossipService.announceMessage(toCcMetadata.cblBlockIds ?? [], {
|
|
312
|
+
messageId,
|
|
313
|
+
recipientIds: toCcRecipientIds,
|
|
314
|
+
priority: 'normal',
|
|
315
|
+
blockIds: toCcMetadata.cblBlockIds ?? [],
|
|
316
|
+
cblBlockId: toCcMetadata.blockId,
|
|
317
|
+
ackRequired: true,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
// 5b. Deliver to each BCC recipient separately (BCC privacy)
|
|
321
|
+
// Each BCC recipient gets their own announcement with no BCC header and
|
|
322
|
+
// no information about other BCC recipients.
|
|
323
|
+
if (email.bcc && email.bcc.length > 0) {
|
|
324
|
+
for (const bccMailbox of email.bcc) {
|
|
325
|
+
const bccCopy = this.createBccRecipientCopy(metadata, bccMailbox);
|
|
326
|
+
await this.metadataStore.store(bccCopy);
|
|
327
|
+
await this.gossipService.announceMessage(bccCopy.cblBlockIds ?? [], {
|
|
328
|
+
messageId,
|
|
329
|
+
recipientIds: [bccMailbox.address],
|
|
330
|
+
priority: 'normal',
|
|
331
|
+
blockIds: bccCopy.cblBlockIds ?? [],
|
|
332
|
+
cblBlockId: bccCopy.blockId,
|
|
333
|
+
ackRequired: true,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
catch (err) {
|
|
339
|
+
// Delivery errors are non-fatal - the email is stored, delivery can be retried
|
|
340
|
+
// Return success with empty delivery status
|
|
341
|
+
return {
|
|
342
|
+
messageId,
|
|
343
|
+
brightchainMessageId,
|
|
344
|
+
deliveryStatus: new Map(),
|
|
345
|
+
success: true,
|
|
346
|
+
error: `Delivery initiation failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
// 6. Return result — gossip delivery is fire-and-forget; acks come later via gossip
|
|
350
|
+
return {
|
|
351
|
+
messageId,
|
|
352
|
+
brightchainMessageId,
|
|
353
|
+
deliveryStatus: new Map(),
|
|
354
|
+
success: true,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Retrieves email metadata by Message-ID.
|
|
359
|
+
*
|
|
360
|
+
* @param messageId - The Message-ID to look up
|
|
361
|
+
* @returns The email metadata, or null if not found
|
|
362
|
+
*/
|
|
363
|
+
async getEmail(messageId) {
|
|
364
|
+
return this.metadataStore.get(messageId);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Retrieves the full email content including decoded body and attachments.
|
|
368
|
+
*
|
|
369
|
+
* Reconstructs the complete message from CBL blocks, decoding all
|
|
370
|
+
* MIME parts and attachments.
|
|
371
|
+
*
|
|
372
|
+
* @param messageId - The Message-ID to retrieve content for
|
|
373
|
+
* @returns The full email content
|
|
374
|
+
* @throws {EmailError} If the message is not found
|
|
375
|
+
*
|
|
376
|
+
* @see Requirement 13.5 - Reconstruct complete message including all MIME parts
|
|
377
|
+
*/
|
|
378
|
+
async getEmailContent(messageId) {
|
|
379
|
+
const metadata = await this.metadataStore.get(messageId);
|
|
380
|
+
if (!metadata) {
|
|
381
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.MESSAGE_NOT_FOUND, `Email with messageId "${messageId}" not found`, { messageId });
|
|
382
|
+
}
|
|
383
|
+
// Extract textBody and htmlBody from MIME parts
|
|
384
|
+
let textBody;
|
|
385
|
+
let htmlBody;
|
|
386
|
+
const decoder = new TextDecoder();
|
|
387
|
+
if (metadata.parts) {
|
|
388
|
+
for (const part of metadata.parts) {
|
|
389
|
+
if (part.contentType.type === 'text' &&
|
|
390
|
+
part.contentType.subtype === 'plain' &&
|
|
391
|
+
part.body) {
|
|
392
|
+
textBody = decoder.decode(part.body);
|
|
393
|
+
}
|
|
394
|
+
else if (part.contentType.type === 'text' &&
|
|
395
|
+
part.contentType.subtype === 'html' &&
|
|
396
|
+
part.body) {
|
|
397
|
+
htmlBody = decoder.decode(part.body);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// Map attachment metadata to IRetrievedAttachment[]
|
|
402
|
+
const attachments = [];
|
|
403
|
+
if (metadata.attachments) {
|
|
404
|
+
for (const attachmentMeta of metadata.attachments) {
|
|
405
|
+
let content = new Uint8Array(0);
|
|
406
|
+
// Retrieve actual content from the attachment content store if available
|
|
407
|
+
if (this.metadataStore.getAttachmentContent) {
|
|
408
|
+
const stored = await this.metadataStore.getAttachmentContent(attachmentMeta.checksum);
|
|
409
|
+
if (stored) {
|
|
410
|
+
content = new Uint8Array(stored);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
attachments.push({ metadata: attachmentMeta, content });
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
metadata,
|
|
418
|
+
textBody,
|
|
419
|
+
htmlBody,
|
|
420
|
+
parts: metadata.parts ?? [],
|
|
421
|
+
attachments,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Deletes an email message and its associated blocks.
|
|
426
|
+
*
|
|
427
|
+
* @param messageId - The Message-ID to delete
|
|
428
|
+
* @throws {EmailError} If the message is not found
|
|
429
|
+
*/
|
|
430
|
+
async deleteEmail(messageId) {
|
|
431
|
+
const metadata = await this.metadataStore.get(messageId);
|
|
432
|
+
if (!metadata) {
|
|
433
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.MESSAGE_NOT_FOUND, `Email with messageId "${messageId}" not found`, { messageId });
|
|
434
|
+
}
|
|
435
|
+
await this.metadataStore.delete(messageId);
|
|
436
|
+
}
|
|
437
|
+
// ─── Inbox Operations ───────────────────────────────────────────────
|
|
438
|
+
/**
|
|
439
|
+
* Queries a user's inbox with filtering, sorting, and pagination.
|
|
440
|
+
*
|
|
441
|
+
* @param userId - The user ID to query inbox for
|
|
442
|
+
* @param query - Query parameters for filtering and sorting
|
|
443
|
+
* @returns Paginated inbox results with unread count
|
|
444
|
+
*
|
|
445
|
+
* @see Requirement 13.1 - Inbox query for To, Cc, or Bcc recipients
|
|
446
|
+
* @see Requirement 13.2 - Sort by Date header (newest first by default)
|
|
447
|
+
* @see Requirement 13.6 - Pagination with configurable page size
|
|
448
|
+
*/
|
|
449
|
+
async queryInbox(userId, query) {
|
|
450
|
+
// Apply defaults for pagination and sorting
|
|
451
|
+
const normalizedQuery = {
|
|
452
|
+
...query,
|
|
453
|
+
page: query.page ?? 1,
|
|
454
|
+
pageSize: query.pageSize ?? this.config.defaultPageSize,
|
|
455
|
+
sortBy: query.sortBy ?? 'date',
|
|
456
|
+
sortDirection: query.sortDirection ?? 'desc',
|
|
457
|
+
readStatus: query.readStatus ?? 'all',
|
|
458
|
+
};
|
|
459
|
+
return this.metadataStore.queryInbox(userId, normalizedQuery);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Marks an email as read for a specific user.
|
|
463
|
+
*
|
|
464
|
+
* @param messageId - The Message-ID to mark as read
|
|
465
|
+
* @param userId - The user who read the email
|
|
466
|
+
*
|
|
467
|
+
* @see Requirement 13.8 - Track unread count
|
|
468
|
+
*/
|
|
469
|
+
async markAsRead(messageId, userId) {
|
|
470
|
+
await this.metadataStore.markAsRead(messageId, userId);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Gets the unread email count for a user.
|
|
474
|
+
*
|
|
475
|
+
* @param userId - The user ID to get unread count for
|
|
476
|
+
* @returns The number of unread emails
|
|
477
|
+
*
|
|
478
|
+
* @see Requirement 13.8 - Return unread count for inbox queries
|
|
479
|
+
*/
|
|
480
|
+
async getUnreadCount(userId) {
|
|
481
|
+
return this.metadataStore.getUnreadCount(userId);
|
|
482
|
+
}
|
|
483
|
+
// ─── Threading Operations ───────────────────────────────────────────
|
|
484
|
+
/**
|
|
485
|
+
* Retrieves all emails in a thread by following the References chain.
|
|
486
|
+
*
|
|
487
|
+
* Messages are ordered chronologically by Date header.
|
|
488
|
+
* Handles broken threads where intermediate messages are missing.
|
|
489
|
+
*
|
|
490
|
+
* @param messageId - Any Message-ID in the thread
|
|
491
|
+
* @returns Array of email metadata in the thread, ordered chronologically
|
|
492
|
+
*
|
|
493
|
+
* @see Requirement 10.4 - Retrieve all emails in a thread
|
|
494
|
+
* @see Requirement 10.5 - Order messages chronologically
|
|
495
|
+
* @see Requirement 10.7 - Handle broken threads
|
|
496
|
+
*/
|
|
497
|
+
async getThread(messageId) {
|
|
498
|
+
// 1. Retrieve the starting email
|
|
499
|
+
const startEmail = await this.metadataStore.get(messageId);
|
|
500
|
+
if (!startEmail) {
|
|
501
|
+
return [];
|
|
502
|
+
}
|
|
503
|
+
// 2. Collect all known Message-IDs in the thread
|
|
504
|
+
// Start from the given email's References + its own Message-ID
|
|
505
|
+
const knownIds = new Set();
|
|
506
|
+
const toVisit = [];
|
|
507
|
+
// Seed with the starting email
|
|
508
|
+
knownIds.add(startEmail.messageId);
|
|
509
|
+
if (startEmail.references) {
|
|
510
|
+
for (const ref of startEmail.references) {
|
|
511
|
+
if (!knownIds.has(ref)) {
|
|
512
|
+
knownIds.add(ref);
|
|
513
|
+
toVisit.push(ref);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (startEmail.inReplyTo && !knownIds.has(startEmail.inReplyTo)) {
|
|
518
|
+
knownIds.add(startEmail.inReplyTo);
|
|
519
|
+
toVisit.push(startEmail.inReplyTo);
|
|
520
|
+
}
|
|
521
|
+
// 3. Walk the thread graph: for each known ID, try to fetch the email
|
|
522
|
+
// and discover more IDs from its References/In-Reply-To
|
|
523
|
+
const found = new Map();
|
|
524
|
+
found.set(startEmail.messageId, startEmail);
|
|
525
|
+
while (toVisit.length > 0) {
|
|
526
|
+
const visitId = toVisit.pop();
|
|
527
|
+
if (found.has(visitId)) {
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
const email = await this.metadataStore.get(visitId);
|
|
531
|
+
if (!email) {
|
|
532
|
+
// Broken thread - intermediate message missing, skip gracefully
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
found.set(email.messageId, email);
|
|
536
|
+
// Discover more thread members from this email's references
|
|
537
|
+
if (email.references) {
|
|
538
|
+
for (const ref of email.references) {
|
|
539
|
+
if (!knownIds.has(ref)) {
|
|
540
|
+
knownIds.add(ref);
|
|
541
|
+
toVisit.push(ref);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (email.inReplyTo && !knownIds.has(email.inReplyTo)) {
|
|
546
|
+
knownIds.add(email.inReplyTo);
|
|
547
|
+
toVisit.push(email.inReplyTo);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
// 4. Also use the metadata store's getThread for any additional thread members
|
|
551
|
+
// that might reference this thread but aren't in our References chain
|
|
552
|
+
try {
|
|
553
|
+
const storeThread = await this.metadataStore.getThread(messageId);
|
|
554
|
+
for (const email of storeThread) {
|
|
555
|
+
if (!found.has(email.messageId)) {
|
|
556
|
+
found.set(email.messageId, email);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
catch {
|
|
561
|
+
// If the store doesn't support getThread, that's fine - we have our graph walk
|
|
562
|
+
}
|
|
563
|
+
// 5. Order messages chronologically by Date header (Requirement 10.5)
|
|
564
|
+
const threadEmails = Array.from(found.values());
|
|
565
|
+
threadEmails.sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
566
|
+
return threadEmails;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Retrieves the root message of a thread.
|
|
570
|
+
*
|
|
571
|
+
* Follows the References chain to find the first Message-ID.
|
|
572
|
+
*
|
|
573
|
+
* @param messageId - Any Message-ID in the thread
|
|
574
|
+
* @returns The root email metadata, or null if not found
|
|
575
|
+
*
|
|
576
|
+
* @see Requirement 10.6 - Retrieve root message by following References
|
|
577
|
+
*/
|
|
578
|
+
async getRootMessage(messageId) {
|
|
579
|
+
// 1. Retrieve the starting email
|
|
580
|
+
const email = await this.metadataStore.get(messageId);
|
|
581
|
+
if (!email) {
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
// 2. If this email has no References, it is the root
|
|
585
|
+
if (!email.references || email.references.length === 0) {
|
|
586
|
+
return email;
|
|
587
|
+
}
|
|
588
|
+
// 3. The root is the first Message-ID in the References chain
|
|
589
|
+
const rootId = email.references[0];
|
|
590
|
+
const rootEmail = await this.metadataStore.get(rootId);
|
|
591
|
+
// If the root message is found, return it
|
|
592
|
+
if (rootEmail) {
|
|
593
|
+
return rootEmail;
|
|
594
|
+
}
|
|
595
|
+
// 4. If the root is missing (broken thread), walk up the chain
|
|
596
|
+
// trying each Reference until we find one that exists
|
|
597
|
+
for (let i = 1; i < email.references.length; i++) {
|
|
598
|
+
const candidate = await this.metadataStore.get(email.references[i]);
|
|
599
|
+
if (candidate) {
|
|
600
|
+
// Check if this candidate has no further references (is a root)
|
|
601
|
+
if (!candidate.references || candidate.references.length === 0) {
|
|
602
|
+
return candidate;
|
|
603
|
+
}
|
|
604
|
+
// Otherwise, recurse from this candidate
|
|
605
|
+
return this.getRootMessage(candidate.messageId);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
// 5. If no referenced messages exist, the current email is the earliest we can find
|
|
609
|
+
return email;
|
|
610
|
+
}
|
|
611
|
+
// ─── Reply/Forward Operations ───────────────────────────────────────
|
|
612
|
+
/**
|
|
613
|
+
* Creates a reply to an existing email.
|
|
614
|
+
*
|
|
615
|
+
* Sets In-Reply-To to the parent's Message-ID and constructs the
|
|
616
|
+
* References header by appending the parent's Message-ID to the
|
|
617
|
+
* parent's References list (limited to maxReferencesCount).
|
|
618
|
+
*
|
|
619
|
+
* @param originalId - The Message-ID of the email being replied to
|
|
620
|
+
* @param replyContent - The reply content and options
|
|
621
|
+
* @returns The send result for the reply
|
|
622
|
+
* @throws {EmailError} If the original message is not found
|
|
623
|
+
*
|
|
624
|
+
* @see Requirement 10.1 - Set In-Reply-To to parent Message-ID
|
|
625
|
+
* @see Requirement 10.2 - Construct References header
|
|
626
|
+
* @see Requirement 10.3 - Limit References to 20 Message-IDs
|
|
627
|
+
*/
|
|
628
|
+
async createReply(originalId, replyContent) {
|
|
629
|
+
// 1. Retrieve the original email
|
|
630
|
+
const original = await this.metadataStore.get(originalId);
|
|
631
|
+
if (!original) {
|
|
632
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.MESSAGE_NOT_FOUND, `Original email with messageId "${originalId}" not found`, { messageId: originalId });
|
|
633
|
+
}
|
|
634
|
+
// 2. Construct References header per RFC 5322:
|
|
635
|
+
// Append parent's Message-ID to parent's References list
|
|
636
|
+
const parentReferences = original.references ?? [];
|
|
637
|
+
const allReferences = [...parentReferences, original.messageId];
|
|
638
|
+
// 3. Limit References to maxReferencesCount (default 20) per Requirement 10.3
|
|
639
|
+
// Truncate from the beginning (keep most recent) if necessary
|
|
640
|
+
const maxRefs = this.config.maxReferencesCount;
|
|
641
|
+
const references = allReferences.length > maxRefs
|
|
642
|
+
? allReferences.slice(allReferences.length - maxRefs)
|
|
643
|
+
: allReferences;
|
|
644
|
+
// 4. Build recipients list
|
|
645
|
+
let toRecipients;
|
|
646
|
+
if (replyContent.replyAll) {
|
|
647
|
+
// Reply-All: include original sender + original To + original Cc
|
|
648
|
+
// but exclude the replier themselves, and never include original Bcc
|
|
649
|
+
const replierAddress = replyContent.from.address;
|
|
650
|
+
const originalRecipients = [
|
|
651
|
+
original.from,
|
|
652
|
+
...(original.to ?? []),
|
|
653
|
+
...(original.cc ?? []),
|
|
654
|
+
];
|
|
655
|
+
// Deduplicate by address and exclude the replier
|
|
656
|
+
const seen = new Set();
|
|
657
|
+
toRecipients = [];
|
|
658
|
+
for (const mailbox of originalRecipients) {
|
|
659
|
+
const addr = mailbox.address;
|
|
660
|
+
if (addr !== replierAddress && !seen.has(addr)) {
|
|
661
|
+
seen.add(addr);
|
|
662
|
+
toRecipients.push(mailbox);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
// Simple reply: reply to the original sender (or Reply-To if set)
|
|
668
|
+
toRecipients =
|
|
669
|
+
original.replyTo && original.replyTo.length > 0
|
|
670
|
+
? [...original.replyTo]
|
|
671
|
+
: [original.from];
|
|
672
|
+
}
|
|
673
|
+
// Add any additional recipients specified in the reply
|
|
674
|
+
if (replyContent.additionalTo) {
|
|
675
|
+
toRecipients.push(...replyContent.additionalTo);
|
|
676
|
+
}
|
|
677
|
+
// 5. Build subject with "Re: " prefix if not already present
|
|
678
|
+
const originalSubject = original.subject ?? '';
|
|
679
|
+
const subject = replyContent.subject ??
|
|
680
|
+
(originalSubject.match(/^Re:/i)
|
|
681
|
+
? originalSubject
|
|
682
|
+
: `Re: ${originalSubject}`);
|
|
683
|
+
// 6. Send the reply using sendEmail
|
|
684
|
+
const emailInput = {
|
|
685
|
+
from: replyContent.from,
|
|
686
|
+
to: toRecipients,
|
|
687
|
+
cc: replyContent.additionalCc,
|
|
688
|
+
subject,
|
|
689
|
+
textBody: replyContent.textBody,
|
|
690
|
+
htmlBody: replyContent.htmlBody,
|
|
691
|
+
attachments: replyContent.attachments,
|
|
692
|
+
inReplyTo: original.messageId,
|
|
693
|
+
references,
|
|
694
|
+
};
|
|
695
|
+
return this.sendEmail(emailInput);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Forwards an email to new recipients.
|
|
699
|
+
*
|
|
700
|
+
* Adds Resent-From, Resent-To, Resent-Date, and Resent-Message-ID
|
|
701
|
+
* headers per RFC 5322 Section 3.6.6. Preserves all original headers.
|
|
702
|
+
*
|
|
703
|
+
* @param originalId - The Message-ID of the email being forwarded
|
|
704
|
+
* @param forwardTo - The recipients to forward to
|
|
705
|
+
* @returns The send result for the forwarded email
|
|
706
|
+
* @throws {EmailError} If the original message is not found
|
|
707
|
+
*
|
|
708
|
+
* @see Requirement 17.1 - Add Resent-* headers per RFC 5322
|
|
709
|
+
* @see Requirement 17.2 - Preserve all original headers
|
|
710
|
+
*/
|
|
711
|
+
async forwardEmail(originalId, forwardTo) {
|
|
712
|
+
// 1. Retrieve the original email
|
|
713
|
+
const original = await this.metadataStore.get(originalId);
|
|
714
|
+
if (!original) {
|
|
715
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.MESSAGE_NOT_FOUND, `Original email with messageId "${originalId}" not found`, { messageId: originalId });
|
|
716
|
+
}
|
|
717
|
+
// 2. Build the Resent-* header block per RFC 5322 Section 3.6.6
|
|
718
|
+
const resentHeaderBlock = {
|
|
719
|
+
resentFrom: original.from,
|
|
720
|
+
resentTo: forwardTo,
|
|
721
|
+
resentDate: new Date(),
|
|
722
|
+
resentMessageId: this.generateMessageId(),
|
|
723
|
+
};
|
|
724
|
+
// 3. Prepend the new Resent-* block (most recent first) per Requirement 17.4
|
|
725
|
+
const existingResentHeaders = original.resentHeaders ?? [];
|
|
726
|
+
const updatedResentHeaders = [resentHeaderBlock, ...existingResentHeaders];
|
|
727
|
+
// 4. Build the forwarded email input preserving all original headers (Requirement 17.2)
|
|
728
|
+
const emailInput = {
|
|
729
|
+
from: original.from,
|
|
730
|
+
sender: original.sender,
|
|
731
|
+
replyTo: original.replyTo,
|
|
732
|
+
to: forwardTo,
|
|
733
|
+
subject: original.subject
|
|
734
|
+
? original.subject.match(/^Fwd:/i)
|
|
735
|
+
? original.subject
|
|
736
|
+
: `Fwd: ${original.subject}`
|
|
737
|
+
: undefined,
|
|
738
|
+
textBody: undefined,
|
|
739
|
+
htmlBody: undefined,
|
|
740
|
+
messageId: resentHeaderBlock.resentMessageId,
|
|
741
|
+
customHeaders: original.customHeaders,
|
|
742
|
+
};
|
|
743
|
+
// 5. Send the forwarded email
|
|
744
|
+
const result = await this.sendEmail(emailInput);
|
|
745
|
+
// 6. Update the stored metadata with Resent-* headers
|
|
746
|
+
if (result.success) {
|
|
747
|
+
try {
|
|
748
|
+
await this.metadataStore.update(result.messageId, {
|
|
749
|
+
resentHeaders: updatedResentHeaders,
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
catch {
|
|
753
|
+
// Non-fatal: the email was sent, resent headers are supplementary metadata
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return result;
|
|
757
|
+
}
|
|
758
|
+
// ─── Delivery Tracking ──────────────────────────────────────────────
|
|
759
|
+
/**
|
|
760
|
+
* Gets the delivery status for all recipients of an email.
|
|
761
|
+
*
|
|
762
|
+
* @param messageId - The Message-ID to get delivery status for
|
|
763
|
+
* @returns Map of recipient ID to delivery receipt
|
|
764
|
+
*
|
|
765
|
+
* @see Requirement 12.1 - Track delivery status per recipient
|
|
766
|
+
*/
|
|
767
|
+
async getDeliveryStatus(messageId) {
|
|
768
|
+
const metadata = await this.metadataStore.get(messageId);
|
|
769
|
+
if (!metadata) {
|
|
770
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.MESSAGE_NOT_FOUND, `Email with messageId "${messageId}" not found`, { messageId });
|
|
771
|
+
}
|
|
772
|
+
return metadata.deliveryReceipts;
|
|
773
|
+
}
|
|
774
|
+
// ─── Signature Verification (Requirement 16.5, 16.8) ─────────────
|
|
775
|
+
/**
|
|
776
|
+
* Verifies the digital signature on a stored email.
|
|
777
|
+
*
|
|
778
|
+
* Retrieves the email metadata, reconstructs the signed content,
|
|
779
|
+
* and verifies the signature using the signer's private key.
|
|
780
|
+
*
|
|
781
|
+
* @param messageId - The Message-ID of the email to verify
|
|
782
|
+
* @param signerPrivateKey - The signer's private key for HMAC verification
|
|
783
|
+
* @returns Object with verification result and metadata
|
|
784
|
+
* @throws {EmailError} If the message is not found
|
|
785
|
+
*
|
|
786
|
+
* @see Requirement 16.5 - S/MIME signatures for sender authentication
|
|
787
|
+
* @see Requirement 16.8 - Verify sender's signature on decryption
|
|
788
|
+
*/
|
|
789
|
+
async verifyEmailSignature(messageId, signerPrivateKey) {
|
|
790
|
+
const metadata = await this.metadataStore.get(messageId);
|
|
791
|
+
if (!metadata) {
|
|
792
|
+
throw new emailError_1.EmailError(emailErrorType_1.EmailErrorType.MESSAGE_NOT_FOUND, `Email with messageId "${messageId}" not found`, { messageId });
|
|
793
|
+
}
|
|
794
|
+
if (!metadata.isSigned || !metadata.contentSignature) {
|
|
795
|
+
return { verified: false, isSigned: false };
|
|
796
|
+
}
|
|
797
|
+
// Reconstruct the content that was signed (textBody + htmlBody)
|
|
798
|
+
let bodyContent = '';
|
|
799
|
+
if (metadata.parts) {
|
|
800
|
+
for (const part of metadata.parts) {
|
|
801
|
+
if (part.contentType.type === 'text' &&
|
|
802
|
+
(part.contentType.subtype === 'plain' ||
|
|
803
|
+
part.contentType.subtype === 'html') &&
|
|
804
|
+
part.body) {
|
|
805
|
+
bodyContent += new TextDecoder().decode(part.body);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
const content = new TextEncoder().encode(bodyContent);
|
|
810
|
+
const encryptionService = new emailEncryptionService_1.EmailEncryptionService();
|
|
811
|
+
const verified = encryptionService.verifySignature(content, metadata.contentSignature, signerPrivateKey);
|
|
812
|
+
return { verified, isSigned: true };
|
|
813
|
+
}
|
|
814
|
+
// ─── BCC Privacy Handling ─────────────────────────────────────────
|
|
815
|
+
/**
|
|
816
|
+
* Creates a copy of the email metadata with BCC information stripped.
|
|
817
|
+
* This copy is delivered to To and CC recipients.
|
|
818
|
+
*
|
|
819
|
+
* The copy has:
|
|
820
|
+
* - No `bcc` field (undefined)
|
|
821
|
+
* - No BCC recipients in the `recipients` array
|
|
822
|
+
* - No BCC delivery tracking in `deliveryReceipts`
|
|
823
|
+
* - A unique block ID for separate storage
|
|
824
|
+
*
|
|
825
|
+
* @param original - The original email metadata (sender's copy with full BCC info)
|
|
826
|
+
* @returns A new IEmailMetadata with BCC info removed
|
|
827
|
+
*
|
|
828
|
+
* @see Requirement 9.2 - BCC recipients excluded from all recipient copies
|
|
829
|
+
* @see Requirement 9.3 - Separate encrypted copies for BCC recipients
|
|
830
|
+
*/
|
|
831
|
+
createBccStrippedCopy(original) {
|
|
832
|
+
// Filter out BCC addresses from the recipients list
|
|
833
|
+
const bccAddresses = new Set((original.bcc ?? []).map((m) => m.address));
|
|
834
|
+
const filteredRecipients = original.recipients.filter((addr) => !bccAddresses.has(addr));
|
|
835
|
+
// Filter out BCC delivery status entries
|
|
836
|
+
const filteredDeliveryStatus = new Map();
|
|
837
|
+
for (const [addr, status] of original.deliveryStatus) {
|
|
838
|
+
if (!bccAddresses.has(addr)) {
|
|
839
|
+
filteredDeliveryStatus.set(addr, status);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
// Filter out BCC delivery receipts
|
|
843
|
+
const filteredDeliveryReceipts = new Map();
|
|
844
|
+
for (const [addr, receipt] of original.deliveryReceipts) {
|
|
845
|
+
if (!bccAddresses.has(addr)) {
|
|
846
|
+
filteredDeliveryReceipts.set(addr, receipt);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return {
|
|
850
|
+
...original,
|
|
851
|
+
blockId: `${original.blockId}-tocc`,
|
|
852
|
+
bcc: undefined,
|
|
853
|
+
recipients: filteredRecipients,
|
|
854
|
+
deliveryStatus: filteredDeliveryStatus,
|
|
855
|
+
deliveryReceipts: filteredDeliveryReceipts,
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Creates a private copy of the email for a single BCC recipient.
|
|
860
|
+
*
|
|
861
|
+
* The copy has:
|
|
862
|
+
* - No `bcc` field (no BCC header visible)
|
|
863
|
+
* - Only the specific BCC recipient in delivery tracking
|
|
864
|
+
* - A unique block ID for separate encrypted storage
|
|
865
|
+
* - Encryption scheme set to ECIES for per-recipient encryption
|
|
866
|
+
*
|
|
867
|
+
* This ensures that:
|
|
868
|
+
* - The BCC recipient cannot see other BCC recipients
|
|
869
|
+
* - To/CC recipients cannot see BCC recipients
|
|
870
|
+
* - Each BCC copy can be encrypted with the individual recipient's key
|
|
871
|
+
*
|
|
872
|
+
* @param original - The original email metadata
|
|
873
|
+
* @param bccRecipient - The specific BCC recipient this copy is for
|
|
874
|
+
* @returns A new IEmailMetadata for the BCC recipient
|
|
875
|
+
*
|
|
876
|
+
* @see Requirement 9.2 - BCC recipients excluded from all recipient copies
|
|
877
|
+
* @see Requirement 9.3 - Separate encrypted copies for BCC recipients
|
|
878
|
+
* @see Requirement 16.2 - BCC addresses cryptographically separated
|
|
879
|
+
*/
|
|
880
|
+
createBccRecipientCopy(original, bccRecipient) {
|
|
881
|
+
// The BCC copy includes the original To/CC recipients in headers
|
|
882
|
+
// (so the BCC recipient can see who the email was addressed to)
|
|
883
|
+
// but has NO Bcc header at all.
|
|
884
|
+
// The BCC recipient is added to the 'to' field so they appear in
|
|
885
|
+
// inbox queries (isRecipient checks to/cc/bcc fields).
|
|
886
|
+
const toCcAddresses = [
|
|
887
|
+
...original.to.map((m) => m.address),
|
|
888
|
+
...(original.cc ?? []).map((m) => m.address),
|
|
889
|
+
];
|
|
890
|
+
return {
|
|
891
|
+
...original,
|
|
892
|
+
blockId: `${original.blockId}-bcc-${bccRecipient.address}`,
|
|
893
|
+
to: [...original.to, bccRecipient],
|
|
894
|
+
bcc: undefined,
|
|
895
|
+
recipients: [...toCcAddresses, bccRecipient.address],
|
|
896
|
+
deliveryStatus: new Map([[bccRecipient.address, deliveryStatus_1.DeliveryStatus.Pending]]),
|
|
897
|
+
deliveryReceipts: new Map(),
|
|
898
|
+
encryptionScheme: messageEncryptionScheme_1.MessageEncryptionScheme.RECIPIENT_KEYS,
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
// ─── CC Visibility ──────────────────────────────────────────────────
|
|
902
|
+
/**
|
|
903
|
+
* Ensures CC recipients are included in the Cc header for all recipient copies.
|
|
904
|
+
*
|
|
905
|
+
* This is already handled by the metadata construction in sendEmail() which
|
|
906
|
+
* preserves the `cc` field in all copies (both To/CC and BCC copies).
|
|
907
|
+
* The CC header is visible to all recipients per RFC 5322.
|
|
908
|
+
*
|
|
909
|
+
* @see Requirement 9.1 - CC recipients visible to all recipients
|
|
910
|
+
*/
|
|
911
|
+
// ─── Undisclosed Recipients ─────────────────────────────────────────
|
|
912
|
+
/**
|
|
913
|
+
* Checks if the email has only BCC recipients (undisclosed recipients).
|
|
914
|
+
*
|
|
915
|
+
* When an email has only BCC recipients and no To or CC recipients,
|
|
916
|
+
* the To field is empty, which is valid per RFC 5322 for undisclosed
|
|
917
|
+
* recipients scenarios.
|
|
918
|
+
*
|
|
919
|
+
* @param email - The email input to check
|
|
920
|
+
* @returns true if the email has only BCC recipients
|
|
921
|
+
*
|
|
922
|
+
* @see Requirement 9.6 - Support empty To field when only Bcc recipients specified
|
|
923
|
+
*/
|
|
924
|
+
isUndisclosedRecipients(email) {
|
|
925
|
+
const hasTo = email.to && email.to.length > 0;
|
|
926
|
+
const hasCc = email.cc && email.cc.length > 0;
|
|
927
|
+
const hasBcc = email.bcc && email.bcc.length > 0;
|
|
928
|
+
return !hasTo && !hasCc && hasBcc === true;
|
|
929
|
+
}
|
|
930
|
+
// ─── Attachment Storage ─────────────────────────────────────────────
|
|
931
|
+
/**
|
|
932
|
+
* Stores an attachment and produces its metadata.
|
|
933
|
+
*
|
|
934
|
+
* Calculates SHA-256 and MD5 checksums for integrity verification,
|
|
935
|
+
* generates a CBL magnet URL, and persists the attachment content
|
|
936
|
+
* via the metadata store's attachment content storage.
|
|
937
|
+
*
|
|
938
|
+
* @param input - The attachment input containing filename, mimeType, content, and optional contentId
|
|
939
|
+
* @returns The attachment metadata with checksums and storage references
|
|
940
|
+
*
|
|
941
|
+
* @see Requirement 8.1 - Store attachments as ExtendedCBL blocks
|
|
942
|
+
* @see Requirement 8.2 - Support multiple attachments per email
|
|
943
|
+
* @see Requirement 8.3 - Preserve filename, MIME type, and file size
|
|
944
|
+
* @see Requirement 8.9 - Support inline attachments with Content-ID
|
|
945
|
+
* @see Requirement 8.10 - Calculate and store MD5 Content-MD5 header per RFC 1864
|
|
946
|
+
*/
|
|
947
|
+
async storeAttachment(input) {
|
|
948
|
+
// Calculate SHA-256 checksum (hex digest) using @noble/hashes (browser-compatible)
|
|
949
|
+
const sha256Hash = (0, sha256_1.sha256)(input.content);
|
|
950
|
+
const sha256Checksum = Array.from(sha256Hash)
|
|
951
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
952
|
+
.join('');
|
|
953
|
+
// Calculate MD5 checksum (base64 digest per RFC 1864)
|
|
954
|
+
// NOTE: @noble/hashes intentionally excludes MD5. We use a conditional
|
|
955
|
+
// Node.js fallback here. For full browser compatibility, a lightweight
|
|
956
|
+
// MD5 library (e.g., js-md5) would be needed.
|
|
957
|
+
let md5Checksum;
|
|
958
|
+
if (typeof process !== 'undefined' &&
|
|
959
|
+
process.versions != null &&
|
|
960
|
+
process.versions.node != null) {
|
|
961
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
962
|
+
const { createHash } = require('crypto');
|
|
963
|
+
md5Checksum = createHash('md5').update(input.content).digest('base64');
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
966
|
+
// Browser fallback: use empty string (MD5 Content-MD5 is optional per RFC 1864)
|
|
967
|
+
md5Checksum = '';
|
|
968
|
+
}
|
|
969
|
+
// Generate CBL magnet URL using the checksum
|
|
970
|
+
const cblMagnetUrl = `magnet:?xt=urn:cbl:${sha256Checksum}`;
|
|
971
|
+
// Generate block ID based on the checksum
|
|
972
|
+
const blockId = `cbl-block-${sha256Checksum}`;
|
|
973
|
+
// Persist attachment content if the store supports it
|
|
974
|
+
if (this.metadataStore.storeAttachmentContent) {
|
|
975
|
+
await this.metadataStore.storeAttachmentContent(sha256Checksum, input.content);
|
|
976
|
+
}
|
|
977
|
+
return {
|
|
978
|
+
filename: input.filename,
|
|
979
|
+
mimeType: input.mimeType,
|
|
980
|
+
size: input.content.length,
|
|
981
|
+
contentId: input.contentId,
|
|
982
|
+
cblMagnetUrl,
|
|
983
|
+
blockIds: [blockId],
|
|
984
|
+
checksum: sha256Checksum,
|
|
985
|
+
contentMd5: md5Checksum,
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
// ─── Message-ID Generation ────────────────────────────────────────────
|
|
989
|
+
/**
|
|
990
|
+
* Generates a globally unique Message-ID in RFC 5322 format.
|
|
991
|
+
*
|
|
992
|
+
* The generated Message-ID has the format: `<id-left@id-right>` where:
|
|
993
|
+
* - **id-left**: A combination of timestamp (milliseconds since epoch) and
|
|
994
|
+
* a cryptographically random hex string, separated by a dot.
|
|
995
|
+
* - **id-right**: The configured `nodeId` from the service configuration,
|
|
996
|
+
* representing the sender's node ID or domain.
|
|
997
|
+
*
|
|
998
|
+
* This ensures global uniqueness by incorporating:
|
|
999
|
+
* 1. A high-resolution timestamp component
|
|
1000
|
+
* 2. A cryptographically secure random component (16 bytes / 32 hex chars)
|
|
1001
|
+
* 3. The node identifier
|
|
1002
|
+
*
|
|
1003
|
+
* @returns A unique Message-ID string in the format `<timestamp.random@nodeId>`
|
|
1004
|
+
*
|
|
1005
|
+
* @see Requirement 3.1 - Message-ID format per RFC 5322 Section 3.6.4
|
|
1006
|
+
* @see Requirement 3.2 - Use sender's node ID as id-right portion
|
|
1007
|
+
* @see Requirement 3.3 - Ensure global uniqueness with timestamp, random, and node ID
|
|
1008
|
+
*/
|
|
1009
|
+
generateMessageId() {
|
|
1010
|
+
const timestamp = Date.now().toString(36);
|
|
1011
|
+
const randomBytesArr = (0, platformCrypto_1.getRandomBytes)(16);
|
|
1012
|
+
const random = Array.from(randomBytesArr)
|
|
1013
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
1014
|
+
.join('');
|
|
1015
|
+
const idLeft = `${timestamp}.${random}`;
|
|
1016
|
+
const idRight = this.config.nodeId;
|
|
1017
|
+
return `<${idLeft}@${idRight}>`;
|
|
1018
|
+
}
|
|
1019
|
+
// ─── Configuration Access ───────────────────────────────────────────
|
|
1020
|
+
/**
|
|
1021
|
+
* Returns the current service configuration.
|
|
1022
|
+
*
|
|
1023
|
+
* Useful for checking configured limits and defaults.
|
|
1024
|
+
*/
|
|
1025
|
+
getConfig() {
|
|
1026
|
+
return this.config;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
exports.EmailMessageService = EmailMessageService;
|
|
1030
|
+
//# sourceMappingURL=emailMessageService.js.map
|