user_switch_response.dart was left holding a single 13-line function after UserSwitchResponse's decorative fields were dropped, so the filename no longer described its contents and it sat at lib/models/ root while every other Plex model lives in lib/models/plex/. Renamed to lib/models/plex/plex_switch_response.dart, with the test moved alongside the other plex_*_test.dart files. The parser stays public so the #1488 drift characterization tests keep exercising it directly.
14 lines
667 B
Dart
14 lines
667 B
Dart
/// INVARIANT (#1488): a successful token mint must never be lost to parsing
|
|
/// of decorative fields. `authToken` is the only field any caller consumes
|
|
/// (see plex_home_switch.dart), so nothing else on the `/switch` body is
|
|
/// read. Plex has changed field shapes on this endpoint before (July 2026:
|
|
/// profile language lists became CSV strings), and each drift used to brick
|
|
/// token minting outright.
|
|
String parsePlexSwitchAuthToken(Map<String, dynamic> json) {
|
|
final authToken = json['authToken'];
|
|
if (authToken is! String || authToken.isEmpty) {
|
|
throw const FormatException('Plex /switch response has no usable authToken');
|
|
}
|
|
return authToken;
|
|
}
|