@brightchain/brightchain-lib 0.21.1 → 0.23.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/README.md +66 -0
- package/package.json +2 -2
- package/src/browser.d.ts +2 -0
- package/src/browser.d.ts.map +1 -1
- package/src/browser.js +4 -1
- package/src/browser.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/tcbl/index.d.ts +7 -0
- package/src/lib/blocks/tcbl/index.d.ts.map +1 -0
- package/src/lib/blocks/tcbl/index.js +10 -0
- package/src/lib/blocks/tcbl/index.js.map +1 -0
- package/src/lib/blocks/tcbl/manifestSerializer.d.ts +79 -0
- package/src/lib/blocks/tcbl/manifestSerializer.d.ts.map +1 -0
- package/src/lib/blocks/tcbl/manifestSerializer.js +258 -0
- package/src/lib/blocks/tcbl/manifestSerializer.js.map +1 -0
- package/src/lib/blocks/tcbl/tcbl.d.ts +190 -0
- package/src/lib/blocks/tcbl/tcbl.d.ts.map +1 -0
- package/src/lib/blocks/tcbl/tcbl.js +263 -0
- package/src/lib/blocks/tcbl/tcbl.js.map +1 -0
- package/src/lib/blocks/tcbl/tcblAttachmentUtils.d.ts +49 -0
- package/src/lib/blocks/tcbl/tcblAttachmentUtils.d.ts.map +1 -0
- package/src/lib/blocks/tcbl/tcblAttachmentUtils.js +126 -0
- package/src/lib/blocks/tcbl/tcblAttachmentUtils.js.map +1 -0
- package/src/lib/blocks/tcbl/tcblBuilder.d.ts +89 -0
- package/src/lib/blocks/tcbl/tcblBuilder.d.ts.map +1 -0
- package/src/lib/blocks/tcbl/tcblBuilder.js +180 -0
- package/src/lib/blocks/tcbl/tcblBuilder.js.map +1 -0
- package/src/lib/blocks/tcbl/tcblReader.d.ts +126 -0
- package/src/lib/blocks/tcbl/tcblReader.d.ts.map +1 -0
- package/src/lib/blocks/tcbl/tcblReader.js +224 -0
- package/src/lib/blocks/tcbl/tcblReader.js.map +1 -0
- package/src/lib/blocks/tcbl/tcblValidator.d.ts +56 -0
- package/src/lib/blocks/tcbl/tcblValidator.d.ts.map +1 -0
- package/src/lib/blocks/tcbl/tcblValidator.js +100 -0
- package/src/lib/blocks/tcbl/tcblValidator.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/documents/member/memberDocument.d.ts +3 -3
- package/src/lib/documents/member/memberDocument.d.ts.map +1 -1
- package/src/lib/documents/member/memberDocument.js +2 -2
- package/src/lib/documents/member/memberDocument.js.map +1 -1
- package/src/lib/documents/member/memberHydration.js +3 -3
- package/src/lib/documents/member/memberHydration.js.map +1 -1
- package/src/lib/documents/member/memberOperational.d.ts.map +1 -1
- package/src/lib/documents/member/memberOperational.js +2 -2
- package/src/lib/documents/member/memberOperational.js.map +1 -1
- package/src/lib/documents/member/memberProfileHydration.js +4 -4
- package/src/lib/documents/member/memberProfileHydration.js.map +1 -1
- package/src/lib/ecies-config.js +1 -1
- package/src/lib/ecies-config.js.map +1 -1
- 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 +12 -0
- package/src/lib/enumerations/brightChainStrings.d.ts.map +1 -1
- package/src/lib/enumerations/brightChainStrings.js +13 -0
- package/src/lib/enumerations/brightChainStrings.js.map +1 -1
- package/src/lib/enumerations/index.d.ts +1 -0
- package/src/lib/enumerations/index.d.ts.map +1 -1
- package/src/lib/enumerations/index.js +2 -0
- package/src/lib/enumerations/index.js.map +1 -1
- package/src/lib/enumerations/tcblErrorType.d.ts +34 -0
- package/src/lib/enumerations/tcblErrorType.d.ts.map +1 -0
- package/src/lib/enumerations/tcblErrorType.js +38 -0
- package/src/lib/enumerations/tcblErrorType.js.map +1 -0
- package/src/lib/errors/index.d.ts +4 -0
- package/src/lib/errors/index.d.ts.map +1 -1
- package/src/lib/errors/index.js +7 -0
- package/src/lib/errors/index.js.map +1 -1
- package/src/lib/errors/tcblError.d.ts +30 -0
- package/src/lib/errors/tcblError.d.ts.map +1 -0
- package/src/lib/errors/tcblError.js +53 -0
- package/src/lib/errors/tcblError.js.map +1 -0
- package/src/lib/errors/typeGuards.d.ts +19 -0
- package/src/lib/errors/typeGuards.d.ts.map +1 -1
- package/src/lib/errors/typeGuards.js +22 -0
- package/src/lib/errors/typeGuards.js.map +1 -1
- package/src/lib/i18n/strings/englishUs.d.ts.map +1 -1
- package/src/lib/i18n/strings/englishUs.js +13 -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 +13 -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 +13 -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 +13 -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 +13 -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 +13 -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 +13 -0
- package/src/lib/i18n/strings/ukrainian.js.map +1 -1
- package/src/lib/interfaces/aliasRecord.d.ts +3 -5
- package/src/lib/interfaces/aliasRecord.d.ts.map +1 -1
- package/src/lib/interfaces/auditLogEntry.d.ts +7 -6
- package/src/lib/interfaces/auditLogEntry.d.ts.map +1 -1
- package/src/lib/interfaces/availability/availabilityService.d.ts +12 -11
- 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 +8 -7
- package/src/lib/interfaces/availability/blockRegistry.d.ts.map +1 -1
- package/src/lib/interfaces/availability/discoveryProtocol.d.ts +6 -5
- 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 +16 -15
- package/src/lib/interfaces/availability/gossipService.d.ts.map +1 -1
- package/src/lib/interfaces/availability/gossipService.js.map +1 -1
- package/src/lib/interfaces/availability/locationRecord.d.ts +2 -1
- package/src/lib/interfaces/availability/locationRecord.d.ts.map +1 -1
- package/src/lib/interfaces/availability/locationRecord.js.map +1 -1
- package/src/lib/interfaces/availability/reconciliationService.d.ts +5 -4
- 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/blockFetch/blockFetcher.d.ts +2 -1
- package/src/lib/interfaces/blockFetch/blockFetcher.d.ts.map +1 -1
- package/src/lib/interfaces/blockFetch/blockFetcher.js.map +1 -1
- package/src/lib/interfaces/branded/primitives/blockId.d.ts +13 -0
- package/src/lib/interfaces/branded/primitives/blockId.d.ts.map +1 -1
- package/src/lib/interfaces/branded/primitives/blockId.js +13 -0
- package/src/lib/interfaces/branded/primitives/blockId.js.map +1 -1
- package/src/lib/interfaces/brightpass/vaultEntry.d.ts +2 -1
- package/src/lib/interfaces/brightpass/vaultEntry.d.ts.map +1 -1
- package/src/lib/interfaces/brightpass/vaultMetadata.d.ts +2 -1
- package/src/lib/interfaces/brightpass/vaultMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/chainedAuditLogEntry.d.ts +3 -2
- package/src/lib/interfaces/chainedAuditLogEntry.d.ts.map +1 -1
- package/src/lib/interfaces/contentWithIdentity.d.ts +3 -3
- package/src/lib/interfaces/contentWithIdentity.d.ts.map +1 -1
- package/src/lib/interfaces/identityRecoveryRecord.d.ts +5 -7
- package/src/lib/interfaces/identityRecoveryRecord.d.ts.map +1 -1
- package/src/lib/interfaces/index.d.ts +1 -0
- package/src/lib/interfaces/index.d.ts.map +1 -1
- package/src/lib/interfaces/member/memberDto.d.ts +4 -4
- package/src/lib/interfaces/member/memberDto.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/attachmentMetadata.d.ts +2 -1
- package/src/lib/interfaces/messaging/attachmentMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/emailDelivery.d.ts +3 -2
- package/src/lib/interfaces/messaging/emailDelivery.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/emailDelivery.js.map +1 -1
- package/src/lib/interfaces/messaging/emailMetadata.d.ts +7 -3
- package/src/lib/interfaces/messaging/emailMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/emailMetadata.js.map +1 -1
- package/src/lib/interfaces/messaging/messageMetadata.d.ts +12 -6
- package/src/lib/interfaces/messaging/messageMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/messageMetadataStore.d.ts +17 -10
- package/src/lib/interfaces/messaging/messageMetadataStore.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/mimePart.d.ts +2 -1
- package/src/lib/interfaces/messaging/mimePart.d.ts.map +1 -1
- package/src/lib/interfaces/messaging/mimePart.js.map +1 -1
- package/src/lib/interfaces/proposal.d.ts +26 -10
- package/src/lib/interfaces/proposal.d.ts.map +1 -1
- package/src/lib/interfaces/quorumDocumentMetadata.d.ts +2 -2
- package/src/lib/interfaces/quorumDocumentMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/quorumEpoch.d.ts +3 -5
- package/src/lib/interfaces/quorumEpoch.d.ts.map +1 -1
- package/src/lib/interfaces/readOnlyDataObjectDto.d.ts +2 -2
- package/src/lib/interfaces/readOnlyDataObjectDto.d.ts.map +1 -1
- package/src/lib/interfaces/redistributionJournalEntry.d.ts +4 -4
- package/src/lib/interfaces/redistributionJournalEntry.d.ts.map +1 -1
- package/src/lib/interfaces/responses/getBlock.d.ts +2 -1
- package/src/lib/interfaces/responses/getBlock.d.ts.map +1 -1
- package/src/lib/interfaces/responses/index.d.ts +1 -0
- package/src/lib/interfaces/responses/index.d.ts.map +1 -1
- package/src/lib/interfaces/responses/memberProfileData.d.ts +51 -0
- package/src/lib/interfaces/responses/memberProfileData.d.ts.map +1 -0
- package/src/lib/interfaces/responses/memberProfileData.js +3 -0
- package/src/lib/interfaces/responses/memberProfileData.js.map +1 -0
- package/src/lib/interfaces/responses/replicateBlockResponse.d.ts +2 -1
- package/src/lib/interfaces/responses/replicateBlockResponse.d.ts.map +1 -1
- package/src/lib/interfaces/responses/storeBlock.d.ts +2 -1
- package/src/lib/interfaces/responses/storeBlock.d.ts.map +1 -1
- package/src/lib/interfaces/services/contentIngestion.d.ts +3 -3
- package/src/lib/interfaces/services/contentIngestion.d.ts.map +1 -1
- package/src/lib/interfaces/services/expirationScheduler.d.ts +2 -2
- package/src/lib/interfaces/services/expirationScheduler.d.ts.map +1 -1
- package/src/lib/interfaces/services/identitySealingPipeline.d.ts +3 -3
- package/src/lib/interfaces/services/identitySealingPipeline.d.ts.map +1 -1
- package/src/lib/interfaces/services/identityValidator.d.ts +2 -2
- package/src/lib/interfaces/services/identityValidator.d.ts.map +1 -1
- package/src/lib/interfaces/services/operatorPrompt.d.ts +4 -4
- package/src/lib/interfaces/services/operatorPrompt.d.ts.map +1 -1
- package/src/lib/interfaces/services/quorumDatabase.d.ts +9 -9
- package/src/lib/interfaces/services/quorumDatabase.d.ts.map +1 -1
- package/src/lib/interfaces/services/quorumService.d.ts +23 -22
- package/src/lib/interfaces/services/quorumService.d.ts.map +1 -1
- package/src/lib/interfaces/services/quorumStateMachine.d.ts +6 -6
- package/src/lib/interfaces/services/quorumStateMachine.d.ts.map +1 -1
- package/src/lib/interfaces/services/redistributionConfig.d.ts +2 -2
- package/src/lib/interfaces/services/redistributionConfig.d.ts.map +1 -1
- package/src/lib/interfaces/storage/blockMetadata.d.ts +7 -6
- package/src/lib/interfaces/storage/blockMetadata.d.ts.map +1 -1
- package/src/lib/interfaces/storage/blockMetadata.js.map +1 -1
- package/src/lib/interfaces/storage/blockMetadataStore.d.ts +5 -4
- package/src/lib/interfaces/storage/blockMetadataStore.d.ts.map +1 -1
- package/src/lib/interfaces/storage/cblIndex.d.ts +5 -4
- package/src/lib/interfaces/storage/cblIndex.d.ts.map +1 -1
- package/src/lib/interfaces/storage/cblIndex.js.map +1 -1
- package/src/lib/interfaces/storage/cblWhitening.d.ts +9 -8
- package/src/lib/interfaces/storage/cblWhitening.d.ts.map +1 -1
- package/src/lib/interfaces/tcbl/index.d.ts +5 -0
- package/src/lib/interfaces/tcbl/index.d.ts.map +1 -0
- package/src/lib/interfaces/tcbl/index.js +3 -0
- package/src/lib/interfaces/tcbl/index.js.map +1 -0
- package/src/lib/interfaces/tcbl/tcblArchiveOptions.d.ts +21 -0
- package/src/lib/interfaces/tcbl/tcblArchiveOptions.d.ts.map +1 -0
- package/src/lib/interfaces/tcbl/tcblArchiveOptions.js +12 -0
- package/src/lib/interfaces/tcbl/tcblArchiveOptions.js.map +1 -0
- package/src/lib/interfaces/tcbl/tcblEntryDescriptor.d.ts +25 -0
- package/src/lib/interfaces/tcbl/tcblEntryDescriptor.d.ts.map +1 -0
- package/src/lib/interfaces/tcbl/tcblEntryDescriptor.js +10 -0
- package/src/lib/interfaces/tcbl/tcblEntryDescriptor.js.map +1 -0
- package/src/lib/interfaces/tcbl/tcblEntryInput.d.ts +21 -0
- package/src/lib/interfaces/tcbl/tcblEntryInput.d.ts.map +1 -0
- package/src/lib/interfaces/tcbl/tcblEntryInput.js +10 -0
- package/src/lib/interfaces/tcbl/tcblEntryInput.js.map +1 -0
- package/src/lib/interfaces/tcbl/tcblManifest.d.ts +28 -0
- package/src/lib/interfaces/tcbl/tcblManifest.d.ts.map +1 -0
- package/src/lib/interfaces/tcbl/tcblManifest.js +11 -0
- package/src/lib/interfaces/tcbl/tcblManifest.js.map +1 -0
- package/src/lib/interfaces/vote.d.ts +5 -9
- package/src/lib/interfaces/vote.d.ts.map +1 -1
- package/src/lib/quorum.d.ts +4 -4
- package/src/lib/quorum.d.ts.map +1 -1
- package/src/lib/quorum.js +1 -1
- package/src/lib/quorum.js.map +1 -1
- package/src/lib/quorumDataRecord.d.ts +4 -4
- package/src/lib/quorumDataRecord.d.ts.map +1 -1
- package/src/lib/quorumDataRecord.js +3 -3
- package/src/lib/quorumDataRecord.js.map +1 -1
- package/src/lib/quorumDataRecordDto.d.ts +5 -5
- package/src/lib/quorumDataRecordDto.d.ts.map +1 -1
- package/src/lib/schemas/messaging/messageMetadataSchema.d.ts.map +1 -1
- package/src/lib/schemas/messaging/messageMetadataSchema.js +1 -1
- package/src/lib/schemas/messaging/messageMetadataSchema.js.map +1 -1
- package/src/lib/schemas/quorumDocument.d.ts +1 -1
- package/src/lib/schemas/quorumDocument.d.ts.map +1 -1
- package/src/lib/schemas/quorumDocument.js +1 -1
- package/src/lib/schemas/quorumDocument.js.map +1 -1
- package/src/lib/services/aliasRegistry.d.ts +3 -3
- package/src/lib/services/aliasRegistry.d.ts.map +1 -1
- package/src/lib/services/aliasRegistry.js +2 -3
- package/src/lib/services/aliasRegistry.js.map +1 -1
- package/src/lib/services/auditLogService.d.ts +3 -3
- package/src/lib/services/auditLogService.d.ts.map +1 -1
- package/src/lib/services/auditLogService.js.map +1 -1
- package/src/lib/services/blockCapacity.service.d.ts.map +1 -1
- package/src/lib/services/blockCapacity.service.js +3 -1
- package/src/lib/services/blockCapacity.service.js.map +1 -1
- package/src/lib/services/blockFormatService.d.ts +13 -0
- package/src/lib/services/blockFormatService.d.ts.map +1 -1
- package/src/lib/services/blockFormatService.js +24 -0
- package/src/lib/services/blockFormatService.js.map +1 -1
- package/src/lib/services/communication/explodingMessageService.js +7 -7
- package/src/lib/services/communication/explodingMessageService.js.map +1 -1
- package/src/lib/services/identity/memberIdentityProofService.js +2 -2
- package/src/lib/services/identity/memberIdentityProofService.js.map +1 -1
- package/src/lib/services/identity/memberPaperKeyService.js +5 -5
- package/src/lib/services/identity/memberPaperKeyService.js.map +1 -1
- package/src/lib/services/identitySealingPipeline.d.ts +2 -2
- package/src/lib/services/identitySealingPipeline.d.ts.map +1 -1
- package/src/lib/services/identitySealingPipeline.js.map +1 -1
- package/src/lib/services/identityValidator.d.ts +1 -1
- package/src/lib/services/identityValidator.d.ts.map +1 -1
- package/src/lib/services/identityValidator.js +1 -1
- package/src/lib/services/identityValidator.js.map +1 -1
- package/src/lib/services/index.d.ts +1 -0
- package/src/lib/services/index.d.ts.map +1 -1
- package/src/lib/services/index.js +1 -0
- package/src/lib/services/index.js.map +1 -1
- package/src/lib/services/memberStore.d.ts.map +1 -1
- package/src/lib/services/memberStore.js +7 -6
- package/src/lib/services/memberStore.js.map +1 -1
- package/src/lib/services/messaging/emailMessageService.d.ts.map +1 -1
- package/src/lib/services/messaging/emailMessageService.js +2 -1
- package/src/lib/services/messaging/emailMessageService.js.map +1 -1
- package/src/lib/services/messaging/emailParser.d.ts.map +1 -1
- package/src/lib/services/messaging/emailParser.js.map +1 -1
- package/src/lib/services/messaging/gossipRetryService.d.ts +3 -2
- package/src/lib/services/messaging/gossipRetryService.d.ts.map +1 -1
- package/src/lib/services/messaging/gossipRetryService.js.map +1 -1
- package/src/lib/services/messaging/messageCBLService.d.ts.map +1 -1
- package/src/lib/services/messaging/messageCBLService.js +2 -1
- package/src/lib/services/messaging/messageCBLService.js.map +1 -1
- package/src/lib/services/quorumService.d.ts +16 -16
- package/src/lib/services/quorumService.d.ts.map +1 -1
- package/src/lib/services/quorumService.js +72 -39
- package/src/lib/services/quorumService.js.map +1 -1
- package/src/lib/services/quorumStateMachine.d.ts +7 -7
- package/src/lib/services/quorumStateMachine.d.ts.map +1 -1
- package/src/lib/services/quorumStateMachine.js +31 -24
- package/src/lib/services/quorumStateMachine.js.map +1 -1
- package/src/lib/services/sealing.service.d.ts +4 -4
- package/src/lib/services/sealing.service.d.ts.map +1 -1
- package/src/lib/services/sealing.service.js +2 -2
- package/src/lib/services/sealing.service.js.map +1 -1
- package/src/lib/stores/energyAccountStore.d.ts.map +1 -1
- package/src/lib/stores/energyAccountStore.js.map +1 -1
- package/src/lib/stores/energyLedger.d.ts.map +1 -1
- package/src/lib/stores/energyLedger.js.map +1 -1
- package/src/lib/stores/memoryBlockMetadataStore.d.ts +6 -5
- package/src/lib/stores/memoryBlockMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/memoryBlockMetadataStore.js.map +1 -1
- package/src/lib/stores/memoryBlockStore.d.ts.map +1 -1
- package/src/lib/stores/memoryBlockStore.js +38 -22
- package/src/lib/stores/memoryBlockStore.js.map +1 -1
- package/src/lib/stores/memoryCblStore.d.ts.map +1 -1
- package/src/lib/stores/memoryCblStore.js +14 -3
- package/src/lib/stores/memoryCblStore.js.map +1 -1
- package/src/lib/stores/messaging/memoryMessageMetadataStore.d.ts.map +1 -1
- package/src/lib/stores/messaging/memoryMessageMetadataStore.js.map +1 -1
- package/src/lib/stores/pooledMemoryBlockStore.d.ts.map +1 -1
- package/src/lib/stores/pooledMemoryBlockStore.js +19 -8
- package/src/lib/stores/pooledMemoryBlockStore.js.map +1 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview TarballConstituentBlockListBlock — a CBL that bundles
|
|
3
|
+
* multiple file/data entries into a single archive with a manifest.
|
|
4
|
+
*
|
|
5
|
+
* The TCBL extends {@link ConstituentBlockListBlock} and adds:
|
|
6
|
+
* - Structured block header validation (magic prefix + TarballCBL type byte)
|
|
7
|
+
* - A lazily-deserialized, cached manifest describing all contained entries
|
|
8
|
+
* - A compression flag indicating whether the payload is bzip2-compressed
|
|
9
|
+
*
|
|
10
|
+
* The manifest and compression flag live in the *reconstructed payload*
|
|
11
|
+
* (the data that the CBL addresses point to). The builder/reader sets
|
|
12
|
+
* this payload via {@link setPayloadData} after assembling or
|
|
13
|
+
* reconstructing the constituent blocks.
|
|
14
|
+
*
|
|
15
|
+
* Payload format (after reconstruction):
|
|
16
|
+
* Byte 0: compression flag (0x00 = uncompressed, 0x01 = bzip2)
|
|
17
|
+
* Bytes 1+: serialized manifest (possibly bzip2-compressed)
|
|
18
|
+
*
|
|
19
|
+
* ## Encrypted TCBL Detection (Req 6.6)
|
|
20
|
+
*
|
|
21
|
+
* Encrypted TCBLs are stored as {@link EncryptedBlock} instances with
|
|
22
|
+
* `BlockType.EncryptedTarballConstituentBlockListBlock`. The encrypted
|
|
23
|
+
* block wraps the TCBL data using the standard ECIES encryption pattern
|
|
24
|
+
* (same as CBL, ExtendedCBL, and VCBL).
|
|
25
|
+
*
|
|
26
|
+
* After decryption, the inner data is a plain TCBL that can be detected
|
|
27
|
+
* via {@link isTarballCblData} (checks the 0xBC + 0x07 header bytes) and
|
|
28
|
+
* instantiated as a `TarballConstituentBlockListBlock`. The CBL stores
|
|
29
|
+
* (`MemoryCBLStore`, `DiskCBLStore`) perform this detection automatically
|
|
30
|
+
* when retrieving blocks.
|
|
31
|
+
*
|
|
32
|
+
* @typeParam TID - Platform ID type for frontend/backend DTO compatibility
|
|
33
|
+
*
|
|
34
|
+
* @see Requirement 6 (Transparent Detection and Polymorphic Handling)
|
|
35
|
+
* @see Requirement 2 (TCBL Manifest Structure)
|
|
36
|
+
* @see Requirement 7 (Whole-Archive Compression)
|
|
37
|
+
* @see Requirement 10 (Validation and Error Handling)
|
|
38
|
+
*/
|
|
39
|
+
import { Member, PlatformID } from '@digitaldefiance/ecies-lib';
|
|
40
|
+
import { BlockSize } from '../../enumerations/blockSize';
|
|
41
|
+
import { ICBLServices } from '../../interfaces/services/cblServices';
|
|
42
|
+
import { ITcblEntryDescriptor } from '../../interfaces/tcbl/tcblEntryDescriptor';
|
|
43
|
+
import { ITcblManifest } from '../../interfaces/tcbl/tcblManifest';
|
|
44
|
+
import { ConstituentBlockListBlock } from '../cbl';
|
|
45
|
+
/**
|
|
46
|
+
* A Tarball Constituent Block List block — an archive container that
|
|
47
|
+
* bundles multiple file/data entries into a single CBL structure with
|
|
48
|
+
* a manifest.
|
|
49
|
+
*
|
|
50
|
+
* Extends {@link ConstituentBlockListBlock} so that any code accepting
|
|
51
|
+
* a CBL reference can also accept a TCBL reference (Req 6.3, 6.5).
|
|
52
|
+
*
|
|
53
|
+
* @typeParam TID - Platform ID type (defaults to `Uint8Array`)
|
|
54
|
+
*
|
|
55
|
+
* @see Requirement 6.3 — extends ConstituentBlockListBlock
|
|
56
|
+
* @see Requirement 6.1 — header uses magic prefix + TarballCBL type byte
|
|
57
|
+
* @see Requirement 10.1 — validates structured block header during construction
|
|
58
|
+
*/
|
|
59
|
+
export declare class TarballConstituentBlockListBlock<TID extends PlatformID = Uint8Array> extends ConstituentBlockListBlock<TID> {
|
|
60
|
+
/** Cached deserialized manifest (lazy, populated on first access). */
|
|
61
|
+
private _manifest?;
|
|
62
|
+
/** Cached compression flag (set when payload data is provided). */
|
|
63
|
+
private _isCompressed?;
|
|
64
|
+
/** Reconstructed payload data set by the builder/reader. */
|
|
65
|
+
private _payloadData?;
|
|
66
|
+
/**
|
|
67
|
+
* Create a new TCBL block.
|
|
68
|
+
*
|
|
69
|
+
* @param data - Raw CBL data (header + addresses, optionally padded)
|
|
70
|
+
* @param creator - The creator of the CBL
|
|
71
|
+
* @param blockSize - Optional block size for signature validation
|
|
72
|
+
* @param services - Optional injected CBL services for dependency injection
|
|
73
|
+
*
|
|
74
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if the
|
|
75
|
+
* structured block header does not identify this as a TarballCBL
|
|
76
|
+
*
|
|
77
|
+
* @see Requirement 6.1, 10.1
|
|
78
|
+
*/
|
|
79
|
+
constructor(data: Uint8Array, creator: Member<TID>, blockSize?: BlockSize, services?: ICBLServices<TID>);
|
|
80
|
+
/**
|
|
81
|
+
* Validate that the structured block header identifies this block as
|
|
82
|
+
* a TarballCBL (magic prefix 0xBC followed by type byte 0x07).
|
|
83
|
+
*
|
|
84
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader}
|
|
85
|
+
*
|
|
86
|
+
* @see Requirement 6.1, 10.1, 10.3
|
|
87
|
+
*/
|
|
88
|
+
private validateTcblHeader;
|
|
89
|
+
/**
|
|
90
|
+
* Set the reconstructed payload data.
|
|
91
|
+
*
|
|
92
|
+
* Called by the builder after assembling the archive or by the reader
|
|
93
|
+
* after reconstructing the payload from the CBL's constituent blocks.
|
|
94
|
+
*
|
|
95
|
+
* Payload format:
|
|
96
|
+
* Byte 0: compression flag (0x00 = uncompressed, 0x01 = compressed)
|
|
97
|
+
* Bytes 1+: serialized manifest data (possibly bzip2-compressed)
|
|
98
|
+
*
|
|
99
|
+
* @param payloadData - The reconstructed payload bytes
|
|
100
|
+
*
|
|
101
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if
|
|
102
|
+
* the payload is empty or the compression flag is invalid
|
|
103
|
+
*
|
|
104
|
+
* @see Requirement 7.3
|
|
105
|
+
*/
|
|
106
|
+
setPayloadData(payloadData: Uint8Array): void;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the archive payload is bzip2-compressed.
|
|
109
|
+
*
|
|
110
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if
|
|
111
|
+
* payload data has not been set via {@link setPayloadData}
|
|
112
|
+
*
|
|
113
|
+
* @see Requirement 7.3
|
|
114
|
+
*/
|
|
115
|
+
get isCompressed(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* The TCBL manifest — lazily deserialized and cached on first access.
|
|
118
|
+
*
|
|
119
|
+
* The manifest is parsed from the payload data (bytes after the
|
|
120
|
+
* compression flag). The checksum embedded in the manifest is
|
|
121
|
+
* validated during deserialization by {@link TcblManifestSerializer}.
|
|
122
|
+
*
|
|
123
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if
|
|
124
|
+
* payload data has not been set
|
|
125
|
+
* @throws {TcblError} with {@link TcblErrorType.ManifestCorrupted} or
|
|
126
|
+
* {@link TcblErrorType.ManifestTruncated} if deserialization fails
|
|
127
|
+
*
|
|
128
|
+
* @see Requirement 2, 10.2
|
|
129
|
+
*/
|
|
130
|
+
get manifest(): ITcblManifest;
|
|
131
|
+
/**
|
|
132
|
+
* The entry descriptors from the manifest.
|
|
133
|
+
*
|
|
134
|
+
* @see Requirement 5.4
|
|
135
|
+
*/
|
|
136
|
+
get entries(): ITcblEntryDescriptor[];
|
|
137
|
+
/**
|
|
138
|
+
* Synchronous validation including TCBL-specific checks.
|
|
139
|
+
*
|
|
140
|
+
* Validates:
|
|
141
|
+
* 1. Base CBL structure (via `super.validateSync()`)
|
|
142
|
+
* 2. Structured block header (magic prefix + TarballCBL type byte)
|
|
143
|
+
* 3. Manifest entry count consistency (if manifest has been loaded)
|
|
144
|
+
*
|
|
145
|
+
* @throws {TcblError} with {@link TcblErrorType.ManifestCountMismatch}
|
|
146
|
+
* if the manifest's `entryCount` does not match `entries.length`
|
|
147
|
+
*
|
|
148
|
+
* @see Requirement 10.4
|
|
149
|
+
*/
|
|
150
|
+
validateSync(): void;
|
|
151
|
+
/**
|
|
152
|
+
* Asynchronous validation including TCBL-specific checks.
|
|
153
|
+
*
|
|
154
|
+
* @see Requirement 10.4
|
|
155
|
+
*/
|
|
156
|
+
validateAsync(): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Validate that the manifest entry count matches the actual number
|
|
159
|
+
* of entry descriptors. Only runs if the manifest has already been
|
|
160
|
+
* loaded (avoids forcing deserialization during validation).
|
|
161
|
+
*
|
|
162
|
+
* @throws {TcblError} with {@link TcblErrorType.ManifestCountMismatch}
|
|
163
|
+
*
|
|
164
|
+
* @see Requirement 10.4
|
|
165
|
+
*/
|
|
166
|
+
private validateManifestCount;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Type guard that narrows a {@link ConstituentBlockListBlock} to a
|
|
170
|
+
* {@link TarballConstituentBlockListBlock}.
|
|
171
|
+
*
|
|
172
|
+
* Use this to safely upcast a CBL reference when you need to access
|
|
173
|
+
* TCBL-specific APIs (manifest, entries, isCompressed).
|
|
174
|
+
*
|
|
175
|
+
* @param block - Any CBL instance
|
|
176
|
+
* @returns `true` if `block` is a `TarballConstituentBlockListBlock`
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const cbl = await cblStore.get(checksum, hydrateGuid);
|
|
181
|
+
* if (isTcbl(cbl)) {
|
|
182
|
+
* // cbl is now typed as TarballConstituentBlockListBlock
|
|
183
|
+
* const entries = cbl.entries;
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @see Requirement 6.4 — consumer can upcast CBL to TCBL
|
|
188
|
+
*/
|
|
189
|
+
export declare function isTcbl<TID extends PlatformID = Uint8Array>(block: ConstituentBlockListBlock<TID>): block is TarballConstituentBlockListBlock<TID>;
|
|
190
|
+
//# sourceMappingURL=tcbl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcbl.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/blocks/tcbl/tcbl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,C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@@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview TarballConstituentBlockListBlock — a CBL that bundles
|
|
4
|
+
* multiple file/data entries into a single archive with a manifest.
|
|
5
|
+
*
|
|
6
|
+
* The TCBL extends {@link ConstituentBlockListBlock} and adds:
|
|
7
|
+
* - Structured block header validation (magic prefix + TarballCBL type byte)
|
|
8
|
+
* - A lazily-deserialized, cached manifest describing all contained entries
|
|
9
|
+
* - A compression flag indicating whether the payload is bzip2-compressed
|
|
10
|
+
*
|
|
11
|
+
* The manifest and compression flag live in the *reconstructed payload*
|
|
12
|
+
* (the data that the CBL addresses point to). The builder/reader sets
|
|
13
|
+
* this payload via {@link setPayloadData} after assembling or
|
|
14
|
+
* reconstructing the constituent blocks.
|
|
15
|
+
*
|
|
16
|
+
* Payload format (after reconstruction):
|
|
17
|
+
* Byte 0: compression flag (0x00 = uncompressed, 0x01 = bzip2)
|
|
18
|
+
* Bytes 1+: serialized manifest (possibly bzip2-compressed)
|
|
19
|
+
*
|
|
20
|
+
* ## Encrypted TCBL Detection (Req 6.6)
|
|
21
|
+
*
|
|
22
|
+
* Encrypted TCBLs are stored as {@link EncryptedBlock} instances with
|
|
23
|
+
* `BlockType.EncryptedTarballConstituentBlockListBlock`. The encrypted
|
|
24
|
+
* block wraps the TCBL data using the standard ECIES encryption pattern
|
|
25
|
+
* (same as CBL, ExtendedCBL, and VCBL).
|
|
26
|
+
*
|
|
27
|
+
* After decryption, the inner data is a plain TCBL that can be detected
|
|
28
|
+
* via {@link isTarballCblData} (checks the 0xBC + 0x07 header bytes) and
|
|
29
|
+
* instantiated as a `TarballConstituentBlockListBlock`. The CBL stores
|
|
30
|
+
* (`MemoryCBLStore`, `DiskCBLStore`) perform this detection automatically
|
|
31
|
+
* when retrieving blocks.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam TID - Platform ID type for frontend/backend DTO compatibility
|
|
34
|
+
*
|
|
35
|
+
* @see Requirement 6 (Transparent Detection and Polymorphic Handling)
|
|
36
|
+
* @see Requirement 2 (TCBL Manifest Structure)
|
|
37
|
+
* @see Requirement 7 (Whole-Archive Compression)
|
|
38
|
+
* @see Requirement 10 (Validation and Error Handling)
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.TarballConstituentBlockListBlock = void 0;
|
|
42
|
+
exports.isTcbl = isTcbl;
|
|
43
|
+
const constants_1 = require("../../constants");
|
|
44
|
+
const tcblErrorType_1 = require("../../enumerations/tcblErrorType");
|
|
45
|
+
const tcblError_1 = require("../../errors/tcblError");
|
|
46
|
+
const cbl_1 = require("../cbl");
|
|
47
|
+
const manifestSerializer_1 = require("./manifestSerializer");
|
|
48
|
+
/**
|
|
49
|
+
* A Tarball Constituent Block List block — an archive container that
|
|
50
|
+
* bundles multiple file/data entries into a single CBL structure with
|
|
51
|
+
* a manifest.
|
|
52
|
+
*
|
|
53
|
+
* Extends {@link ConstituentBlockListBlock} so that any code accepting
|
|
54
|
+
* a CBL reference can also accept a TCBL reference (Req 6.3, 6.5).
|
|
55
|
+
*
|
|
56
|
+
* @typeParam TID - Platform ID type (defaults to `Uint8Array`)
|
|
57
|
+
*
|
|
58
|
+
* @see Requirement 6.3 — extends ConstituentBlockListBlock
|
|
59
|
+
* @see Requirement 6.1 — header uses magic prefix + TarballCBL type byte
|
|
60
|
+
* @see Requirement 10.1 — validates structured block header during construction
|
|
61
|
+
*/
|
|
62
|
+
class TarballConstituentBlockListBlock extends cbl_1.ConstituentBlockListBlock {
|
|
63
|
+
/**
|
|
64
|
+
* Create a new TCBL block.
|
|
65
|
+
*
|
|
66
|
+
* @param data - Raw CBL data (header + addresses, optionally padded)
|
|
67
|
+
* @param creator - The creator of the CBL
|
|
68
|
+
* @param blockSize - Optional block size for signature validation
|
|
69
|
+
* @param services - Optional injected CBL services for dependency injection
|
|
70
|
+
*
|
|
71
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if the
|
|
72
|
+
* structured block header does not identify this as a TarballCBL
|
|
73
|
+
*
|
|
74
|
+
* @see Requirement 6.1, 10.1
|
|
75
|
+
*/
|
|
76
|
+
constructor(data, creator, blockSize, services) {
|
|
77
|
+
super(data, creator, blockSize, services);
|
|
78
|
+
this.validateTcblHeader();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Validate that the structured block header identifies this block as
|
|
82
|
+
* a TarballCBL (magic prefix 0xBC followed by type byte 0x07).
|
|
83
|
+
*
|
|
84
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader}
|
|
85
|
+
*
|
|
86
|
+
* @see Requirement 6.1, 10.1, 10.3
|
|
87
|
+
*/
|
|
88
|
+
validateTcblHeader() {
|
|
89
|
+
if (this._data.length < 2) {
|
|
90
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([['reason', 'data too short for structured block header']]));
|
|
91
|
+
}
|
|
92
|
+
if (this._data[0] !== constants_1.BLOCK_HEADER.MAGIC_PREFIX) {
|
|
93
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([
|
|
94
|
+
['reason', 'missing magic prefix'],
|
|
95
|
+
['expected', `0x${constants_1.BLOCK_HEADER.MAGIC_PREFIX.toString(16)}`],
|
|
96
|
+
['actual', `0x${this._data[0].toString(16)}`],
|
|
97
|
+
]));
|
|
98
|
+
}
|
|
99
|
+
if (this._data[1] !== constants_1.StructuredBlockType.TarballCBL) {
|
|
100
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([
|
|
101
|
+
['reason', 'wrong structured block type'],
|
|
102
|
+
['expected', `0x${constants_1.StructuredBlockType.TarballCBL.toString(16)}`],
|
|
103
|
+
['actual', `0x${this._data[1].toString(16)}`],
|
|
104
|
+
]));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Set the reconstructed payload data.
|
|
109
|
+
*
|
|
110
|
+
* Called by the builder after assembling the archive or by the reader
|
|
111
|
+
* after reconstructing the payload from the CBL's constituent blocks.
|
|
112
|
+
*
|
|
113
|
+
* Payload format:
|
|
114
|
+
* Byte 0: compression flag (0x00 = uncompressed, 0x01 = compressed)
|
|
115
|
+
* Bytes 1+: serialized manifest data (possibly bzip2-compressed)
|
|
116
|
+
*
|
|
117
|
+
* @param payloadData - The reconstructed payload bytes
|
|
118
|
+
*
|
|
119
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if
|
|
120
|
+
* the payload is empty or the compression flag is invalid
|
|
121
|
+
*
|
|
122
|
+
* @see Requirement 7.3
|
|
123
|
+
*/
|
|
124
|
+
setPayloadData(payloadData) {
|
|
125
|
+
if (payloadData.length < 1) {
|
|
126
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([['reason', 'payload data is empty']]));
|
|
127
|
+
}
|
|
128
|
+
const compressionByte = payloadData[0];
|
|
129
|
+
if (compressionByte !== 0x00 && compressionByte !== 0x01) {
|
|
130
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([
|
|
131
|
+
['reason', 'invalid compression flag'],
|
|
132
|
+
['expected', '0x00 or 0x01'],
|
|
133
|
+
['actual', `0x${compressionByte.toString(16)}`],
|
|
134
|
+
]));
|
|
135
|
+
}
|
|
136
|
+
this._isCompressed = compressionByte === 0x01;
|
|
137
|
+
this._payloadData = payloadData;
|
|
138
|
+
// Invalidate cached manifest so it is re-parsed from the new payload
|
|
139
|
+
this._manifest = undefined;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Whether the archive payload is bzip2-compressed.
|
|
143
|
+
*
|
|
144
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if
|
|
145
|
+
* payload data has not been set via {@link setPayloadData}
|
|
146
|
+
*
|
|
147
|
+
* @see Requirement 7.3
|
|
148
|
+
*/
|
|
149
|
+
get isCompressed() {
|
|
150
|
+
if (this._isCompressed === undefined) {
|
|
151
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([['reason', 'payload data not loaded; call setPayloadData()']]));
|
|
152
|
+
}
|
|
153
|
+
return this._isCompressed;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The TCBL manifest — lazily deserialized and cached on first access.
|
|
157
|
+
*
|
|
158
|
+
* The manifest is parsed from the payload data (bytes after the
|
|
159
|
+
* compression flag). The checksum embedded in the manifest is
|
|
160
|
+
* validated during deserialization by {@link TcblManifestSerializer}.
|
|
161
|
+
*
|
|
162
|
+
* @throws {TcblError} with {@link TcblErrorType.InvalidHeader} if
|
|
163
|
+
* payload data has not been set
|
|
164
|
+
* @throws {TcblError} with {@link TcblErrorType.ManifestCorrupted} or
|
|
165
|
+
* {@link TcblErrorType.ManifestTruncated} if deserialization fails
|
|
166
|
+
*
|
|
167
|
+
* @see Requirement 2, 10.2
|
|
168
|
+
*/
|
|
169
|
+
get manifest() {
|
|
170
|
+
if (!this._manifest) {
|
|
171
|
+
if (!this._payloadData) {
|
|
172
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([
|
|
173
|
+
['reason', 'payload data not loaded; call setPayloadData()'],
|
|
174
|
+
]));
|
|
175
|
+
}
|
|
176
|
+
// Skip the compression flag byte, deserialize the manifest
|
|
177
|
+
const manifestData = this._payloadData.subarray(1);
|
|
178
|
+
this._manifest = manifestSerializer_1.TcblManifestSerializer.deserialize(manifestData);
|
|
179
|
+
}
|
|
180
|
+
return this._manifest;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The entry descriptors from the manifest.
|
|
184
|
+
*
|
|
185
|
+
* @see Requirement 5.4
|
|
186
|
+
*/
|
|
187
|
+
get entries() {
|
|
188
|
+
return this.manifest.entries;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Synchronous validation including TCBL-specific checks.
|
|
192
|
+
*
|
|
193
|
+
* Validates:
|
|
194
|
+
* 1. Base CBL structure (via `super.validateSync()`)
|
|
195
|
+
* 2. Structured block header (magic prefix + TarballCBL type byte)
|
|
196
|
+
* 3. Manifest entry count consistency (if manifest has been loaded)
|
|
197
|
+
*
|
|
198
|
+
* @throws {TcblError} with {@link TcblErrorType.ManifestCountMismatch}
|
|
199
|
+
* if the manifest's `entryCount` does not match `entries.length`
|
|
200
|
+
*
|
|
201
|
+
* @see Requirement 10.4
|
|
202
|
+
*/
|
|
203
|
+
validateSync() {
|
|
204
|
+
super.validateSync();
|
|
205
|
+
this.validateTcblHeader();
|
|
206
|
+
this.validateManifestCount();
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Asynchronous validation including TCBL-specific checks.
|
|
210
|
+
*
|
|
211
|
+
* @see Requirement 10.4
|
|
212
|
+
*/
|
|
213
|
+
async validateAsync() {
|
|
214
|
+
await super.validateAsync();
|
|
215
|
+
this.validateTcblHeader();
|
|
216
|
+
this.validateManifestCount();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Validate that the manifest entry count matches the actual number
|
|
220
|
+
* of entry descriptors. Only runs if the manifest has already been
|
|
221
|
+
* loaded (avoids forcing deserialization during validation).
|
|
222
|
+
*
|
|
223
|
+
* @throws {TcblError} with {@link TcblErrorType.ManifestCountMismatch}
|
|
224
|
+
*
|
|
225
|
+
* @see Requirement 10.4
|
|
226
|
+
*/
|
|
227
|
+
validateManifestCount() {
|
|
228
|
+
if (this._manifest) {
|
|
229
|
+
if (this._manifest.entryCount !== this._manifest.entries.length) {
|
|
230
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.ManifestCountMismatch, new Map([
|
|
231
|
+
['entryCount', String(this._manifest.entryCount)],
|
|
232
|
+
['actualEntries', String(this._manifest.entries.length)],
|
|
233
|
+
]));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
exports.TarballConstituentBlockListBlock = TarballConstituentBlockListBlock;
|
|
239
|
+
/**
|
|
240
|
+
* Type guard that narrows a {@link ConstituentBlockListBlock} to a
|
|
241
|
+
* {@link TarballConstituentBlockListBlock}.
|
|
242
|
+
*
|
|
243
|
+
* Use this to safely upcast a CBL reference when you need to access
|
|
244
|
+
* TCBL-specific APIs (manifest, entries, isCompressed).
|
|
245
|
+
*
|
|
246
|
+
* @param block - Any CBL instance
|
|
247
|
+
* @returns `true` if `block` is a `TarballConstituentBlockListBlock`
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* const cbl = await cblStore.get(checksum, hydrateGuid);
|
|
252
|
+
* if (isTcbl(cbl)) {
|
|
253
|
+
* // cbl is now typed as TarballConstituentBlockListBlock
|
|
254
|
+
* const entries = cbl.entries;
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* @see Requirement 6.4 — consumer can upcast CBL to TCBL
|
|
259
|
+
*/
|
|
260
|
+
function isTcbl(block) {
|
|
261
|
+
return block instanceof TarballConstituentBlockListBlock;
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=tcbl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcbl.js","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/blocks/tcbl/tcbl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;;;AAmRH,wBAIC;AApRD,+CAAoE;AAEpE,oEAAiE;AACjE,sDAAmD;AAInD,gCAAmD;AACnD,6DAA8D;AAE9D;;;;;;;;;;;;;GAaG;AACH,MAAa,gCAEX,SAAQ,+BAA8B;IAUtC;;;;;;;;;;;;OAYG;IACH,YACE,IAAgB,EAChB,OAAoB,EACpB,SAAqB,EACrB,QAA4B;QAE5B,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QAC1C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,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAjOD,4EAiOC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,MAAM,CACpB,KAAqC;IAErC,OAAO,KAAK,YAAY,gCAAgC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Utility functions for working with TCBL attachments
|
|
3
|
+
* in the context of quorum proposals.
|
|
4
|
+
*
|
|
5
|
+
* Provides a unified way to enumerate entries from an attachment
|
|
6
|
+
* that may be either a plain CBL or a TCBL archive. This allows
|
|
7
|
+
* proposal consumers to handle both formats transparently.
|
|
8
|
+
*
|
|
9
|
+
* @see Requirement 9.2 — enumerate entries from TCBL attachments
|
|
10
|
+
* @see Requirement 9.3 — handle plain CBL attachments as single-entry
|
|
11
|
+
*/
|
|
12
|
+
import { PlatformID } from '@digitaldefiance/ecies-lib';
|
|
13
|
+
import { ICBLServices } from '../../interfaces/services/cblServices';
|
|
14
|
+
import { IBlockStore } from '../../interfaces/storage/blockStore';
|
|
15
|
+
import { ITcblEntryDescriptor } from '../../interfaces/tcbl/tcblEntryDescriptor';
|
|
16
|
+
import { Checksum } from '../../types/checksum';
|
|
17
|
+
/**
|
|
18
|
+
* Enumerate the entries contained in a proposal attachment.
|
|
19
|
+
*
|
|
20
|
+
* If the attachment is a TCBL archive, this function retrieves the
|
|
21
|
+
* payload, parses the manifest, and returns all entry descriptors.
|
|
22
|
+
*
|
|
23
|
+
* If the attachment is a plain CBL, this function returns a single-entry
|
|
24
|
+
* list with a generic descriptor (fileName: 'attachment', mimeType:
|
|
25
|
+
* 'application/octet-stream').
|
|
26
|
+
*
|
|
27
|
+
* @typeParam TID - Platform ID type for frontend/backend DTO compatibility
|
|
28
|
+
* @param attachmentCblId - The CBL/TCBL checksum identifying the attachment
|
|
29
|
+
* @param blockStore - The block store to retrieve block data from
|
|
30
|
+
* @param services - Optional CBL services for dependency injection
|
|
31
|
+
* @returns Array of entry descriptors for the attachment contents
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const entries = await enumerateAttachmentEntries(
|
|
36
|
+
* proposal.attachmentCblId,
|
|
37
|
+
* blockStore,
|
|
38
|
+
* );
|
|
39
|
+
* for (const entry of entries) {
|
|
40
|
+
* console.log(`${entry.fileName} (${entry.mimeType}, ${entry.originalDataLength} bytes)`);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @see Requirement 9.1 — attachmentCblId accepts both CBL and TCBL
|
|
45
|
+
* @see Requirement 9.2 — TCBL attachments enumerate all entries
|
|
46
|
+
* @see Requirement 9.3 — plain CBL attachments return single entry
|
|
47
|
+
*/
|
|
48
|
+
export declare function enumerateAttachmentEntries<TID extends PlatformID = Uint8Array>(attachmentCblId: Checksum, blockStore: IBlockStore, services?: ICBLServices<TID>): Promise<ITcblEntryDescriptor[]>;
|
|
49
|
+
//# sourceMappingURL=tcblAttachmentUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcblAttachmentUtils.d.ts","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/blocks/tcbl/tcblAttachmentUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAGjF,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,0BAA0B,CAC9C,GAAG,SAAS,UAAU,GAAG,UAAU,EAEnC,eAAe,EAAE,QAAQ,EACzB,UAAU,EAAE,WAAW,EACvB,QAAQ,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,GAC3B,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAmBjC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Utility functions for working with TCBL attachments
|
|
4
|
+
* in the context of quorum proposals.
|
|
5
|
+
*
|
|
6
|
+
* Provides a unified way to enumerate entries from an attachment
|
|
7
|
+
* that may be either a plain CBL or a TCBL archive. This allows
|
|
8
|
+
* proposal consumers to handle both formats transparently.
|
|
9
|
+
*
|
|
10
|
+
* @see Requirement 9.2 — enumerate entries from TCBL attachments
|
|
11
|
+
* @see Requirement 9.3 — handle plain CBL attachments as single-entry
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.enumerateAttachmentEntries = enumerateAttachmentEntries;
|
|
15
|
+
const tcblErrorType_1 = require("../../enumerations/tcblErrorType");
|
|
16
|
+
const tcblError_1 = require("../../errors/tcblError");
|
|
17
|
+
const blockFormatService_1 = require("../../services/blockFormatService");
|
|
18
|
+
const globalServiceProvider_1 = require("../../services/globalServiceProvider");
|
|
19
|
+
const manifestSerializer_1 = require("./manifestSerializer");
|
|
20
|
+
/**
|
|
21
|
+
* Enumerate the entries contained in a proposal attachment.
|
|
22
|
+
*
|
|
23
|
+
* If the attachment is a TCBL archive, this function retrieves the
|
|
24
|
+
* payload, parses the manifest, and returns all entry descriptors.
|
|
25
|
+
*
|
|
26
|
+
* If the attachment is a plain CBL, this function returns a single-entry
|
|
27
|
+
* list with a generic descriptor (fileName: 'attachment', mimeType:
|
|
28
|
+
* 'application/octet-stream').
|
|
29
|
+
*
|
|
30
|
+
* @typeParam TID - Platform ID type for frontend/backend DTO compatibility
|
|
31
|
+
* @param attachmentCblId - The CBL/TCBL checksum identifying the attachment
|
|
32
|
+
* @param blockStore - The block store to retrieve block data from
|
|
33
|
+
* @param services - Optional CBL services for dependency injection
|
|
34
|
+
* @returns Array of entry descriptors for the attachment contents
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const entries = await enumerateAttachmentEntries(
|
|
39
|
+
* proposal.attachmentCblId,
|
|
40
|
+
* blockStore,
|
|
41
|
+
* );
|
|
42
|
+
* for (const entry of entries) {
|
|
43
|
+
* console.log(`${entry.fileName} (${entry.mimeType}, ${entry.originalDataLength} bytes)`);
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @see Requirement 9.1 — attachmentCblId accepts both CBL and TCBL
|
|
48
|
+
* @see Requirement 9.2 — TCBL attachments enumerate all entries
|
|
49
|
+
* @see Requirement 9.3 — plain CBL attachments return single entry
|
|
50
|
+
*/
|
|
51
|
+
async function enumerateAttachmentEntries(attachmentCblId, blockStore, services) {
|
|
52
|
+
// Retrieve the raw block data for the attachment
|
|
53
|
+
const rawBlock = await blockStore.getData(attachmentCblId);
|
|
54
|
+
const data = rawBlock.data;
|
|
55
|
+
// Check if the data has a TCBL header (0xBC + TarballCBL type byte)
|
|
56
|
+
if ((0, blockFormatService_1.isTarballCblData)(data)) {
|
|
57
|
+
return enumerateTcblEntries(data, blockStore, services);
|
|
58
|
+
}
|
|
59
|
+
// Plain CBL — return a single-entry descriptor with generic metadata
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
fileName: 'attachment',
|
|
63
|
+
mimeType: 'application/octet-stream',
|
|
64
|
+
originalDataLength: data.length,
|
|
65
|
+
cblAddress: attachmentCblId,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parse a TCBL block's addresses and extract manifest entries.
|
|
71
|
+
*
|
|
72
|
+
* Uses the CBL service to parse addresses from the raw TCBL data,
|
|
73
|
+
* retrieves the payload block (last address), handles decompression,
|
|
74
|
+
* and parses the manifest.
|
|
75
|
+
*
|
|
76
|
+
* @param data - Raw TCBL block data (header + addresses)
|
|
77
|
+
* @param blockStore - Block store for retrieving the payload block
|
|
78
|
+
* @param services - Optional CBL services for dependency injection
|
|
79
|
+
* @returns Array of entry descriptors from the TCBL manifest
|
|
80
|
+
*/
|
|
81
|
+
async function enumerateTcblEntries(data, blockStore, services) {
|
|
82
|
+
const cblService = services?.cblService ?? (0, globalServiceProvider_1.getGlobalServiceProvider)().cblService;
|
|
83
|
+
// Parse addresses from the CBL data
|
|
84
|
+
const addresses = cblService.addressDataToAddresses(data);
|
|
85
|
+
if (addresses.length === 0) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
// The payload block is the last address in the CBL
|
|
89
|
+
const payloadAddress = addresses[addresses.length - 1];
|
|
90
|
+
const payloadBlock = await blockStore.getData(payloadAddress);
|
|
91
|
+
const rawPayload = payloadBlock.data;
|
|
92
|
+
if (rawPayload.length < 1) {
|
|
93
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.InvalidHeader, new Map([['reason', 'payload block is empty']]));
|
|
94
|
+
}
|
|
95
|
+
// Check compression flag (byte 0)
|
|
96
|
+
const compressionFlag = rawPayload[0];
|
|
97
|
+
let manifestData;
|
|
98
|
+
if (compressionFlag === 0x01) {
|
|
99
|
+
// Compressed payload: [0x01][uncompressedLength(4 bytes BE)][bzip2 data]
|
|
100
|
+
if (rawPayload.length < 5) {
|
|
101
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.DecompressionFailed, new Map([['reason', 'compressed payload too short']]));
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const view = new DataView(rawPayload.buffer, rawPayload.byteOffset, rawPayload.byteLength);
|
|
105
|
+
const uncompressedLength = view.getUint32(1, false);
|
|
106
|
+
const compressedData = rawPayload.subarray(5);
|
|
107
|
+
const BZip2Module = await Promise.resolve().then(() => require('@digitaldefiance/bzip2-wasm'));
|
|
108
|
+
const BZip2 = BZip2Module.default;
|
|
109
|
+
const bzip2 = new BZip2();
|
|
110
|
+
await bzip2.init();
|
|
111
|
+
manifestData = bzip2.decompress(compressedData, uncompressedLength);
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
if (e instanceof tcblError_1.TcblError)
|
|
115
|
+
throw e;
|
|
116
|
+
throw new tcblError_1.TcblError(tcblErrorType_1.TcblErrorType.DecompressionFailed, new Map([['reason', String(e)]]));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// Uncompressed: skip the compression flag byte
|
|
121
|
+
manifestData = rawPayload.subarray(1);
|
|
122
|
+
}
|
|
123
|
+
const manifest = manifestSerializer_1.TcblManifestSerializer.deserialize(manifestData);
|
|
124
|
+
return manifest.entries;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=tcblAttachmentUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcblAttachmentUtils.js","sourceRoot":"","sources":["../../../../../../brightchain-lib/src/lib/blocks/tcbl/tcblAttachmentUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA4CH,gEAyBC;AAlED,oEAAiE;AACjE,sDAAmD;AAInD,0EAAqE;AACrE,gFAAgF;AAEhF,6DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACI,KAAK,UAAU,0BAA0B,CAG9C,eAAyB,EACzB,UAAuB,EACvB,QAA4B;IAE5B,iDAAiD;IACjD,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAE3B,oEAAoE;IACpE,IAAI,IAAA,qCAAgB,EAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,oBAAoB,CAAM,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAED,qEAAqE;IACrE,OAAO;QACL;YACE,QAAQ,EAAE,Y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