Skip to content

Conversation

@nathabonfim59
Copy link

This build upon #4.

I'm working in a project, which has an embedded system that runs strictly Firefox and we need to filter the devices, so I'm trying to finish the PR started by @RealTirex.

Still very much a work in progress.

RealTirex and others added 6 commits September 7, 2025 13:36
- Add comprehensive filter validation per Web Serial API specification:
  * Mutual exclusivity: Bluetooth and USB filters cannot be combined
  * USB dependency: usbProductId requires usbVendorId to be present
  * Empty filter prevention: at least one property must be specified
- Add validation to requestPort() and listAvailablePorts() with TypeError rejection
- Fix filter matching logic to handle undefined values correctly
- Add documentation for Bluetooth service class ID limitation
- Fix bluetoothServiceClassId check to use !== undefined for consistency
- Fix empty filter validation to only apply to USB filters, not Bluetooth
- Prevent false positives when validating valid Bluetooth-only filters
- Update error message to be more specific about USB filter requirements

This fixes the critical flaw where Bluetooth-only filters would incorrectly
trigger the empty filter validation, making the code fully compliant with
the Web Serial API specification.
@kuba2k2
Copy link
Owner

kuba2k2 commented Sep 7, 2025

Looking good 👍
Two little things so far:

  • moving filter-related functions from utils/utils.ts to a separate file utils/filter.ts to keep them in a separate unit
  • naming commits according to the commit history, so that it maintains consistency (not strictly necessary if this PR is to be squash-merged)

@nathabonfim59
Copy link
Author

Wow, that was some fast feedback! Thanks

I'll do the changes.

About the commit history, I remembered mid-project we should credit the original guy who created this, that's why It's a little messy.

But that's a great catch, even if this gets squashed, I'll rebase them properly 🫡

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.

3 participants