Skip to content

Add Channel Metadata Validation#3323

Merged
islathehut merged 24 commits into
featureBranch/private-channels-reduxfrom
taea/channel-metadata-validation-develop
Jul 6, 2026
Merged

Add Channel Metadata Validation#3323
islathehut merged 24 commits into
featureBranch/private-channels-reduxfrom
taea/channel-metadata-validation-develop

Conversation

@adrastaea

@adrastaea adrastaea commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

This PR hardens channel metadata storage and subscription readiness for public/private channels.

The main change is replacing permissive channel metadata writes with validated, role-aware OrbitDB metadata writes. Public and private channel metadata now live in separate stores, private channel metadata is encrypted to the channel-specific role, and metadata updates are checked against sigchain identity, team membership, owner, role, and privacy invariants.

Key Changes

  • Adds a custom ChannelMetadataAccessController that validates OrbitDB metadata writers, rejects duplicate metadata PUTs for an existing channel key, and restricts metadata DELs to admins (packages/backend/src/nest/storage/channels/orbitdb/ChannelMetadataAccessController.ts:121).
  • Splits channel metadata into public and private OrbitDB stores using CHANNEL_METADATA_STORE_NAME and PRIVATE_CHANNEL_METADATA_STORE_NAME (packages/backend/src/nest/storage/channels/channels.service.ts:248, packages/types/src/channel.ts:9).
  • Validates channel metadata end-to-end: key must match decrypted channel ID, encrypted payload signer must match owner, writer identity must match the active team, privacy must match the target store, role/public fields are immutable, and private metadata must use the channel role encryption scope (packages/backend/src/nest/storage/channels/channels.service.ts:322).
  • Moves channel ID generation to the backend and removes the old client-side channelName_random helper, so clients create channels by name/team/privacy and use the canonical channel returned by the backend (packages/backend/src/nest/storage/channels/channels.service.ts:955, packages/common/src/channelAddress.ts:1).
  • Tracks channel subscription as explicit state. The backend emits CHANNEL_SUBSCRIBED after the store is actually subscribed, state-manager records that status, and message sends wait for the target channel subscription before emitting to the backend (packages/backend/src/nest/storage/channels/channels.service.ts:1031, packages/state-manager/src/sagas/publicChannels/waitForChannelSubscription.saga.ts:8, packages/state-manager/src/sagas/messages/sendMessage/sendMessage.saga.ts:90).
  • Disables the desktop channel input until the current channel is subscribed, avoiding sends into a channel store that is known but not ready yet (packages/desktop/src/renderer/components/Channel/Channel.tsx:25, packages/desktop/src/renderer/components/Channel/ChannelComponent.tsx:267).
  • Improves OrbitDB store registration and lifecycle cleanup so fanout/pending-head replay can resolve stores through address aliases and unregister stores on close/drop (packages/backend/src/nest/storage/orbitDb/orbitDb.service.ts:64, packages/backend/src/nest/storage/orbitDb/orbitDb.service.ts:299).
  • Passes log context into log-aware access controllers, which lets metadata validation inspect existing channel metadata log entries (packages/backend/src/nest/storage/orbitDb/keyValueWithStorage.ts:8, packages/backend/src/nest/storage/orbitDb/keyValueWithStorage.ts:64).

Pull Request Checklist

  • I have linked this PR to a related GitHub issue.
  • I have added a description of the change (and Github issue number, if any) to the root CHANGELOG.md.

(Optional) Mobile checklist

Please ensure you completed the following checks if you did any changes to the mobile package:

  • I have run e2e tests for mobile
  • I have updated base screenshots for visual regression tests

holmes and others added 16 commits June 24, 2026 15:24
…dates

- Introduced channel metadata update handlers to manage updates more effectively.
- Added methods to attach and detach channel metadata update handlers.
- Improved channel subscription logic to ensure channels are subscribed before sending messages.
- Refactored channel subscription checks and added new selectors for subscribed channels.
- Implemented a saga to wait for channel subscriptions before proceeding with message sending and initial channel message creation.
- Updated tests to cover new subscription logic and ensure proper handling of channel states.
…n closing one; add unit test for ChannelStore to ignore updates without matching channel id
@adrastaea adrastaea linked an issue Jul 2, 2026 that may be closed by this pull request
@adrastaea
adrastaea marked this pull request as ready for review July 2, 2026 20:25
@islathehut

Copy link
Copy Markdown
Collaborator

Made a few small changes (added tests, small refactors, fixes post-merge from develop) and tests are passing locally. The validation logic looks good to me but I'd like Taea's input on my changes before approving/merging.

@islathehut

Copy link
Copy Markdown
Collaborator

Wanted to note for future us that these changes aren't backwards compatible.

@islathehut
islathehut changed the base branch from develop to featureBranch/private-channels-redux July 6, 2026 17:45
@islathehut
islathehut merged commit df67ab8 into featureBranch/private-channels-redux Jul 6, 2026
45 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Channel Metadata Access Controller

2 participants