Skip to content

Commit c11c3b6

Browse files
committed
docs: Update documentation for tag-value serialization
1 parent d774417 commit c11c3b6

File tree

2 files changed

+96
-56
lines changed

2 files changed

+96
-56
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### UI Controller API
66

77
- Renamed `InitiateEventStream()` to `Subscribe()`
8+
- Serialize `BackgroundEvent`, `HybridState`, `UsbState` as tag-value structs
89

910
# [0.1.0] - 2025-08-14
1011

doc/api.md

Lines changed: 95 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ sequenceDiagram
4949
### Breaking Changes
5050

5151
- (UI Controller): Renamed `InitiateEventStream()` to `Subscribe()`
52+
- (UI Controller): Serialize enums (including BackgroundEvent, HybridState and UsbState) as (yv) structs instead for a{sv} dicts
5253

5354
## [0.1.0] - 2025-08-14
5455

@@ -60,16 +61,24 @@ sequenceDiagram
6061

6162
# Terminology
6263

63-
_authenticator_: a device that securely stores and releases credentials
64-
_client_: a user agent requesting credentials for a relying party, for example, browsers or apps
65-
_credential_: a value that identifies a user to a relying party
66-
_gateway_: entrypoint for clients
67-
_privileged_ client: a client that is trusted to set any origin for its requests
68-
_relying party_: an entity wishing to auhtenticate a user
69-
_unprivileged client_: a client that is constrained to use a predetermined set of origin(s)
64+
- _authenticator_: a device that securely stores and releases credentials
65+
- _client_: a user agent requesting credentials for a relying party, for example, browsers or apps
66+
- _credential_: a value that identifies a user to a relying party
67+
- _gateway_: entrypoint for clients
68+
- _privileged_ client: a client that is trusted to set any origin for its requests
69+
- _relying party_: an entity wishing to auhtenticate a user
70+
- _unprivileged client_: a client that is constrained to use a predetermined set of origin(s)
7071

7172
# General Notes
7273

74+
## Enum values
75+
76+
Generally, enums are serialized as a tag-value structure with a single-byte tag
77+
and a variant as the value (`(yv)`, in D-Bus terms). The documentation for each
78+
specific enum variant describes how to parse the values.
79+
80+
A single null byte (`\0`) is sent for unused enum values.
81+
7382
## D-Bus/JSON serialization
7483

7584
> TODO: rename fields to snake_case so that this note is true in all cases.
@@ -169,6 +178,8 @@ CreateCredentialRequest[a{sv}] {
169178
}
170179
```
171180

181+
> TODO: We should make this a tagged enum
182+
172183
```
173184
CredentialType[s] [
174185
"publicKey"
@@ -380,7 +391,8 @@ See the WebAuthn spec for meanings of the [client capability keys][def-client-ca
380391

381392
# Flow Control API
382393

383-
The Flow Control API is used by the UI to pass user interactions through the Flow Controller to the authenticator.
394+
The Flow Control API is used by the UI to pass user interactions through the
395+
Flow Controller to the authenticator.
384396

385397
## Subscribe()
386398

@@ -407,44 +419,44 @@ to the UI until it calls this method.
407419
Notification of authenticator state change.
408420

409421
```
410-
BackgroundEvent[a{sv}] [
411-
HybridStateChanged: HybridState,
412-
UsbStateChanged: UsbState,
422+
BackgroundEvent[(yv)] [
423+
(0x01) UsbStateChanged: UsbState,
424+
(0x02) HybridStateChanged: HybridState,
413425
]
414426
```
415427

416428
```
417-
UsbState {
418-
type: UsbStateType,
419-
value: Value
420-
}
421-
UsbStateType[s] [
422-
"IDLE",
423-
"WAITING",
424-
"SELECTING_DEVICE",
425-
"CONNECTED",
426-
"NEEDS_PIN",
427-
"NEEDS_USER_VERIFICATION",
428-
"NEEDS_USER_PRESENCE",
429-
"SELECT_CREDENTIAL",
430-
"COMPLETED",
431-
"FAILED",
429+
UsbState[(yv)] {
430+
(0x01) "IDLE",
431+
(0x02) "WAITING" ,
432+
(0x03) "SELECTING_DEVICE",
433+
(0x04) "CONNECTED",
434+
(0x05) "NEEDS_PIN",
435+
(0x06) "NEEDS_USER_VERIFICATION",
436+
(0x07) "NEEDS_USER_PRESENCE",
437+
(0x08) "SELECT_CREDENTIAL",
438+
(0x09) "COMPLETED",
439+
(0x0a) "FAILED",
432440
]
433441
```
434442

435443
#### UsbState::IDLE
436444

437445
Not polling for FIDO USB device.
438446

439-
`type`: `"IDLE"`
447+
`name`: "IDLE"`
448+
449+
`tag`: `0x01`
440450

441451
`value`: No associated value.
442452

443453
#### UsbState::WAITING
444454

445455
Awaiting FIDO USB device to be plugged in.
446456

447-
`type`: `"WAITING"`
457+
`name`: `"WAITING"`
458+
459+
`tag`: `0x02`
448460

449461
`value`: No associated value.
450462

@@ -453,7 +465,9 @@ Awaiting FIDO USB device to be plugged in.
453465
Multiple USB devices have been detected and are blinking, prompt the user to
454466
tap one to select it.
455467

456-
`type`: `"SELECTING_DEVICE"`
468+
`name`: `"SELECTING_DEVICE"`
469+
470+
`tag`: `0x02`
457471

458472
`value`: No associated value.
459473

@@ -463,7 +477,9 @@ USB device connected, prompt user to tap. The device may require additional
463477
user verification, but that might not be known until after the user taps the
464478
device.
465479

466-
`type`: `"CONNECTED"`
480+
`name`: `"CONNECTED"`
481+
482+
`tag`: `0x04`
467483

468484
`value`: No associated value.
469485

@@ -475,7 +491,9 @@ device.
475491
The device needs PIN user verification: prompt the user to enter the pin. Send
476492
the pin to the flow controller using the enter_client_pin() method.
477493

478-
`type`: `"NEEDS_PIN"`
494+
`name`: `"NEEDS_PIN"`
495+
496+
`tag`: `0x05`
479497

480498
`value`: `[i]`, a signed integer indicating the number of PIN attempts remaining
481499
before the device is locked out. If the value is less than 0, the number of attempts
@@ -488,7 +506,9 @@ left is unknown.
488506
The device needs on-device user verification (likely biometrics, or can be
489507
on-device PIN entry). Prompt the user to interact with the device.
490508

491-
`type`: `"NEEDS_USER_VERIFICATION"`
509+
`name`: `"NEEDS_USER_VERIFICATION"`
510+
511+
`tag`: `0x06`
492512

493513
`value`: `[i]`, a signed integer indicating the number of user verification
494514
attempts remaining before the device is locked out. If the value is less than
@@ -498,7 +518,9 @@ attempts remaining before the device is locked out. If the value is less than
498518

499519
The device needs evidence of user presence (e.g. touch) to release the credential.
500520

501-
`type`: `"NEEDS_USER_PRESENCE"`
521+
`name`: `"NEEDS_USER_PRESENCE"`
522+
523+
`tag`: `0x07`
502524

503525
`value`: No associated value.
504526

@@ -511,7 +533,9 @@ The device needs evidence of user presence (e.g. touch) to release the credentia
511533
512534
Multiple credentials have been found and the user has to select which to use
513535

514-
`type`: `"SELECT_CREDENTIAL"`
536+
`name`: `"SELECT_CREDENTIAL"`
537+
538+
`tag`: `0x08`
515539

516540
`value`: `[aa{sv}]`: A list of `Credential` objects.
517541

@@ -531,7 +555,9 @@ actual CTAP credential ID before sending it to the UI.
531555

532556
User tapped USB tapped, flow controller has received credential.
533557

534-
`type`: `"COMPLETED"`
558+
`name`: `"COMPLETED"`
559+
560+
`tag`: `0x09`
535561

536562
`value`: No associated value.
537563

@@ -541,10 +567,14 @@ User tapped USB tapped, flow controller has received credential.
541567
542568
Interaction with the authenticator failed.
543569

544-
`type`: `"FAILED"`
570+
`name`: `"FAILED"`
571+
572+
`tag`: `0x0a`
545573

546574
`value`: `ServiceError`
547575

576+
> TODO: Change serialization of ServiceError
577+
548578
```
549579
ServiceError[?] [
550580
AUTHENTICATOR_ERROR,
@@ -587,19 +617,14 @@ Something went wrong with the credential service itself, not the authenticator.
587617
> TODO: Failed has no reason
588618
589619
```
590-
HybridState {
591-
type: HybridStateType
592-
value: [v]
593-
}
594-
595-
HybridStateType[s] [
596-
"IDLE",
597-
"STARTED",
598-
"CONNECTING",
599-
"CONNECTED",
600-
"COMPLETED",
601-
"USER_CANCELLED",
602-
"FAILED",
620+
HybridState[(yv)] [
621+
(0x01) "IDLE",
622+
(0x02) "STARTED",
623+
(0x03) "CONNECTING",
624+
(0x04) "CONNECTED",
625+
(0x05) "COMPLETED",
626+
(0x06) "USER_CANCELLED",
627+
(0x07) "FAILED",
603628
]
604629
```
605630

@@ -613,23 +638,29 @@ which is a `HybridStateType`, and `value` whose value depends on
613638

614639
Default state, not listening for hybrid transport.
615640

616-
`type`: `"IDLE"`
641+
`name`: `"IDLE"`
642+
643+
`tag`: `0x04`
617644

618645
`value`: No associated value.
619646

620647
#### HybridState::Started,
621648

622649
QR code flow is starting, awaiting QR code scan and BLE advert from phone.
623650

624-
`type`: `"STARTED"`
651+
`name`: `"STARTED"`
652+
653+
`tag`: `0x04`
625654

626655
`value`: `[s]`. String to be encoded as a QR code and displayed to the user to scan.
627656

628657
#### HybridState::Connecting,
629658

630659
BLE advert received, connecting to caBLE tunnel with shared secret.
631660

632-
`type`: `"CONNECTING"`
661+
`name`: `"CONNECTING"`
662+
663+
`tag`: `0x03`
633664

634665
`value`: No associated value
635666

@@ -638,31 +669,39 @@ BLE advert received, connecting to caBLE tunnel with shared secret.
638669
Connected to device via caBLE tunnel, waiting for user to release the
639670
credential from their remote device.
640671

641-
`type`: `"CONNECTED"`
672+
`name`: `"CONNECTED"`
673+
674+
`tag`: `0x04`
642675

643676
`value`: No associated value
644677

645678
#### HybridState::Completed,
646679

647680
Credential received over tunnel.
648681

649-
`type`: `"COMPLETED"`
682+
`name`: `"COMPLETED"`
683+
684+
`tag`: `0x05`
650685

651686
`value`: No associated value
652687

653688
#### HybridState::UserCancelled,
654689

655690
Authenticator operation was cancelled.
656691

657-
`type`: `"USER_CANCELLED"`
692+
`name`: `"USER_CANCELLED"`
693+
694+
`tag`: `0x06`
658695

659696
`value`: No associated value
660697

661698
#### HybridState::Failed,
662699

663700
Failed to receive a credential from the hybrid authenticator.
664701

665-
`type`: `"FAILED"`
702+
`name`: `"FAILED"`
703+
704+
`tag`: `0x07`
666705

667706
`value`: No associated value.
668707

0 commit comments

Comments
 (0)