Define the format of device ID's
I'd like to propose we agree to a format for device ID's, just so there's no ambiguity. Clients would continue to sanitize IDs for their needs (at least until a hypothetical future date), but the format can be added to the schemas as a regex and used in tests.
Some options:
-
UUIDv4
- Pros: well-defined, lots of API support, also used in Bluetooth backend
- Cons: must be sanitized for D-Bus (very common for clients to use)
- regex (strict):
/[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}/i
- regex (loose):
/[0-9A-F\-]{36}/i
-
D-Bus Safe
- Pros: simple, easily adapted from UUIDv4
- Cons: only requires non-zero length, higher chance of collision
- regex:
/[\w]+/
- Alphanumeric,
-
and_
with length >= UUIDv4- Pros: flexible, ASCII-only, explicit backwards-compatibility
- Cons: still must be sanitized for D-Bus
- regex:
/[\w\-]{36,}/
-
ULID (or something else, fairly well known)
- Pros: less chance of collision, alphanumeric & D-Bus safe
- Cons: probably needs a 3rd-party library (Kotlin: aallam/ulid-kotlin, C++ header: suyash/ulid)
- regex:
/[0-7][0-9A-HJKMNP-TV-Z]{25}/
My Take
#3
is basically the current situation: UUIDv4 with (most) clients replacing -
with _
at some point. I think this is the most reasonable choice, and doesn't require any current client to change anything. I seem recall Android used shorter alphanumeric IDs at some point, so we could even lower the minimum length if anyone can remember that.
See also: kdeconnect-kde!593 (merged)