Skip to content

Add peer security configuration - #21

Merged
rchatham merged 20 commits into
masterfrom
feature/security-improvements
Aug 7, 2026
Merged

Add peer security configuration#21
rchatham merged 20 commits into
masterfrom
feature/security-improvements

Conversation

@rchatham

@rchatham rchatham commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • introduce PeerSecurityConfiguration, PeerCertificatePolicy, and PeerInvitationPolicy
  • thread session security settings into MCSession creation
  • replace hardcoded certificate acceptance with explicit policy handling
  • preserve .receivedCertificate as an observation-only compatibility event
  • add PeerDiscoveryInfo support for advertised Bonjour discovery metadata
  • surface browser-provided discovery metadata with foundPeerWithDiscoveryInfo while preserving existing foundPeer events
  • replace blind .automatic invitation acceptance with policy-based handling
  • preserve .receivedInvitation for manual invitation policy and non-automatic connection types
  • add non-breaking validation helpers for MultipeerConnectivity service types and display names
  • document display name privacy and service type constraints
  • expose PeerConnectivityUI browser peer filtering via discovery metadata
  • fix the demo workspace local package reference so it resolves from repo/worktree checkouts
  • retain the PeerConnectivityUI browser delegate without subclassing MCBrowserViewController
  • ignore local SwiftPM/Xcode workspace state under .swiftpm/
  • tighten service type validation to reject additional values that MultipeerConnectivity rejects at initialization
  • preserve automatic invitation observation by emitting compatibility .receivedInvitation events while keeping policy decisions authoritative
  • document event compatibility notes for discovery metadata and automatic invitation policy events
  • merge the latest master demo/test improvements and log discovery metadata events in the expanded demo app
  • add changelog notes for the peer security configuration release and source compatibility considerations

Verification

  • git diff --check
  • swift build && swift test
  • swift test after Phase 2 discovery metadata changes
  • swift test after Phase 3 invitation policy changes
  • swift test after Phase 4 validation/privacy hardening changes
  • swift test after Phase 5 browser filtering changes
  • swift test after certificate compatibility fix
  • swift test after demo coverage changes
  • xcodebuild build -workspace PeerConnectivity.xcworkspace -scheme PeerConnectivityUI -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.3.1' -configuration Debug
  • xcodebuild test -workspace PeerConnectivity.xcworkspace -scheme PeerConnectivity -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.3.1' -configuration Debug
  • xcodebuild build -project PeerConnectivityDemo.xcodeproj -scheme PeerConnectivityDemo -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.3.1' -configuration Debug
  • git diff --check, swift test, and demo xcodebuild build after filtered-browser stabilization
  • git diff --check, swift test, and xcodebuild test -workspace PeerConnectivity.xcworkspace -scheme PeerConnectivity -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.3.1' -configuration Debug after review-fix updates
  • git diff --check and swift test after changelog/demo documentation updates
  • final pre-merge verification after merging latest master: git diff --check, swift build, swift test, xcodebuild build for PeerConnectivityUI, xcodebuild test for PeerConnectivity, demo xcodebuild build, and two-simulator generated XCTest smoke test all passed

Notes

  • Security defaults remain backward-compatible: optional encryption, no security identity, accept-all certificate policy, and accept-all automatic invitation policy.
  • Certificate decisions now live in PeerSecurityConfiguration.certificatePolicy.
  • .receivedCertificate remains observable for API compatibility, but its supplied handler is observation-only and does not affect the certificate decision.
  • Discovery info is public, unauthenticated Bonjour TXT record metadata; docs warn not to include secrets, tokens, emails, stable user IDs, or sensitive device information.
  • Existing .foundPeer(peer:) events are preserved; metadata is exposed through the additional .foundPeerWithDiscoveryInfo(peer:discoveryInfo:) event.
  • Source compatibility note: PeerConnectionEvent has a new .foundPeerWithDiscoveryInfo(peer:discoveryInfo:) case. Existing exhaustive switches over PeerConnectionEvent may need a new case or default.
  • Invitation context is received before session establishment and should be treated as public, unauthenticated metadata.
  • In automatic mode, non-manual invitation policies still emit .receivedInvitation for observation/API compatibility; the emitted handler is a no-op and policy decisions remain authoritative.
  • Service type and display name validation helpers are advisory/non-breaking; initialization behavior is unchanged. Service type validation now rejects leading/trailing hyphens, consecutive hyphens, and all-numeric names to better match MultipeerConnectivity constraints.
  • Browser peer filtering is synchronous and defaults to presenting all peers when no filter is supplied.
  • The demo app can be run on two simulators/devices to exercise advertising, browsing, connection state, typed messages, raw data, resources, and event logging. Discovery metadata events are logged as peer.found.metadata.

Follow-up

  • Potential future work: typed Codable helpers for invitation context or stronger service type wrapper APIs.

@rchatham
rchatham merged commit cc02ec2 into master Aug 7, 2026
@rchatham
rchatham deleted the feature/security-improvements branch August 7, 2026 22:23
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.

1 participant