Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/validate-ae/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ runs:
working-directory: app
run: |
dart analyze lib
flutter test test/add_instance_flow_test.dart test/instance_serialization_test.dart
flutter test test/add_instance_flow_test.dart test/instance_serialization_test.dart test/bindery_brand_icon_test.dart
- if: inputs.suite == 'all' || inputs.suite == 'bindery'
shell: bash
working-directory: packages/core_models
run: flutter test test/service_kind_test.dart
- if: inputs.suite == 'all' || inputs.suite == 'bindery'
shell: bash
working-directory: packages/core_networking
run: flutter test test/service_health_test.dart test/service_auth_headers_test.dart
run: flutter test test/service_health_test.dart test/service_auth_headers_test.dart test/bindery_key_test.dart
25 changes: 25 additions & 0 deletions .github/workflows/bindery-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Validate Bindery foundation
on:
workflow_dispatch:
push:
branches:
- 'feature/bindery/**'
permissions:
contents: read
jobs:
validate:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && !github.event.created && !github.event.deleted && !contains(github.event.head_commit.message, '[build apk]') && !contains(github.event.head_commit.message, '[validate ae]') && contains(github.event.head_commit.message, '[validate bindery]'))
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.41.9'
channel: stable
cache: true
- run: flutter pub get --enforce-lockfile
working-directory: app
- run: dart run tool/build_all.dart
- uses: ./.github/actions/validate-ae
with:
suite: bindery
23 changes: 23 additions & 0 deletions app/assets/service_icons/BINDERY-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Bindery logo: https://github.com/vavallee/bindery/blob/v1.53.0/web/src/assets/logo.png

MIT License

Copyright (c) 2026 vavallee

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file added app/assets/service_icons/bindery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions app/lib/src/screens/bindery_foundation_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:core_models/core_models.dart';
import 'package:core_networking/core_networking.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../service_icon.dart';

final binderyVersionProvider =
FutureProvider.autoDispose.family<String, Instance>((ref, instance) async {
final Dio dio = await ref.watch(dioFactoryProvider).create(instance);
try {
final response = await dio.get<dynamic>('api/v1/system/status');
final data = response.data;
if (data is! Map || data['version'] is! String ||
(data['version'] as String).isEmpty) {
throw const FormatException('Invalid Bindery status response');
}
return data['version'] as String;
} finally {
dio.close(force: true);
}
});

class BinderyFoundationScreen extends ConsumerWidget {
const BinderyFoundationScreen({required this.instance, super.key});
final Instance instance;

@override
Widget build(BuildContext context, WidgetRef ref) {
final version = ref.watch(binderyVersionProvider(instance));
return ListView(
padding: const EdgeInsets.all(16),
children: [
Card(
child: ListTile(
leading: const ServiceIcon(kind: ServiceKind.bindery),
title: const Text('Bindery server'),
subtitle: version.when(
skipLoadingOnRefresh: false,
data: (value) => Text('Connected • Version $value'),
loading: () => const Text('Connecting…'),
error: (_, __) => const Text('Unable to read server status'),
),
trailing: IconButton(
tooltip: 'Refresh server status',
icon: version.isLoading
? const SizedBox.square(
dimension: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.refresh),
onPressed: version.isLoading
? null
: () => ref.invalidate(binderyVersionProvider(instance)),
),
),
),
const Padding(
padding: EdgeInsets.all(16),
child: Text('Library browsing and management are coming in later beta updates.'),
),
],
);
}
}
4 changes: 4 additions & 0 deletions app/lib/src/screens/dashboard_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:go_router/go_router.dart';

import '../dashboard/dashboard_board.dart';
import '../health_providers.dart';
import '../service_icon.dart';
import 'reorder_sidebar_screen.dart';

/// Home screen. Services live in the navigation drawer (the sidebar); the
Expand Down Expand Up @@ -502,6 +503,9 @@ class _HealthAwareTile extends ConsumerWidget {
final Health health = asyncHealth.value ?? Health.unknown;
return ServiceTile(
instance: instance,
serviceIcon: instance.kind == ServiceKind.bindery
? Center(child: ServiceIcon(kind: instance.kind))
: null,
health: health,
onTap: () {
final GoRouter router = GoRouter.of(context);
Expand Down
2 changes: 2 additions & 0 deletions app/lib/src/screens/service_detail_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:core_models/core_models.dart';
import 'bindery_foundation_screen.dart';
import 'package:core_profile/core_profile.dart';
import 'package:core_ui/core_ui.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -416,6 +417,7 @@ class _ServiceDetailScreenState extends ConsumerState<ServiceDetailScreen> {
ServiceKind.cleanuparr => const SizedBox.shrink(),
// Owns its own scaffold, handled above.
ServiceKind.slskd => const SizedBox.shrink(),
ServiceKind.bindery => BinderyFoundationScreen(instance: instance),
};
}
}
Expand Down
18 changes: 18 additions & 0 deletions app/test/bindery_brand_icon_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:core_models/core_models.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';

/// bindery has its own icon in the service picker.
///
/// The picker loads `assets/service_icons/<kind>.png` and falls back to a
/// generic server icon when there is none.
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

test('the icon the picker asks for is bundled', () async {
final ByteData icon = await rootBundle
.load('assets/service_icons/${ServiceKind.bindery.name}.png');

expect(icon.lengthInBytes, greaterThan(0));
});
}
11 changes: 9 additions & 2 deletions packages/core_models/lib/src/service_kind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ enum ServiceKind {
adguardHome,
aria2,
cleanuparr,
slskd;
slskd,
bindery;

/// All [ServiceKind] entries sorted alphabetically by their display name.
static List<ServiceKind> get sortedValues =>
Expand Down Expand Up @@ -82,6 +83,7 @@ extension ServiceKindX on ServiceKind {
ServiceKind.aria2 => 'aria2',
ServiceKind.cleanuparr => 'Cleanuparr',
ServiceKind.slskd => 'slskd',
ServiceKind.bindery => 'Bindery',
};

/// One-line role description.
Expand Down Expand Up @@ -116,6 +118,7 @@ extension ServiceKindX on ServiceKind {
ServiceKind.aria2 => 'Download client',
ServiceKind.cleanuparr => 'Malware blocker & cleaner',
ServiceKind.slskd => 'Soulseek client',
ServiceKind.bindery => 'Books',
};

/// Whether this service's integration is still in beta. Surfaced as a
Expand All @@ -126,6 +129,7 @@ extension ServiceKindX on ServiceKind {
ServiceKind.rtorrent ||
ServiceKind.aria2 ||
ServiceKind.cleanuparr ||
ServiceKind.bindery ||
ServiceKind.slskd =>
true,
_ => false,
Expand Down Expand Up @@ -174,6 +178,7 @@ extension ServiceKindX on ServiceKind {
ServiceKind.cleanuparr => 11011,
// slskd default HTTP/API port.
ServiceKind.slskd => 5030,
ServiceKind.bindery => 8787,
};

/// What auth flow the service uses by default. Some services (Jellyfin) can
Expand All @@ -192,6 +197,7 @@ extension ServiceKindX on ServiceKind {
ServiceKind.gluetun ||
ServiceKind.myspeed ||
ServiceKind.cleanuparr ||
ServiceKind.bindery ||
ServiceKind.ombi =>
AuthStyle.apiKey,
// aria2's credential is its `--rpc-secret`, which is sent as the
Expand Down Expand Up @@ -232,7 +238,8 @@ extension ServiceKindX on ServiceKind {
ServiceKind.radarr ||
ServiceKind.prowlarr ||
ServiceKind.bazarr ||
ServiceKind.lidarr =>
ServiceKind.lidarr ||
ServiceKind.bindery =>
ServiceRole.automation,
ServiceKind.seerr || ServiceKind.ombi => ServiceRole.requests,
ServiceKind.tautulli || ServiceKind.tracearr => ServiceRole.analytics,
Expand Down
10 changes: 10 additions & 0 deletions packages/core_models/test/service_kind_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void main() {
'aria2',
'cleanuparr',
'slskd',
'bindery',
],
);
});
Expand Down Expand Up @@ -169,6 +170,15 @@ void main() {
expect(ServiceKind.slskd.acceptsTorrents, isFalse);
});

test('Bindery is a beta API-key automation service', () {
expect(ServiceKind.bindery.displayName, 'Bindery');
expect(ServiceKind.bindery.isBeta, isTrue);
expect(ServiceKind.bindery.defaultPort, 8787);
expect(ServiceKind.bindery.authStyle, AuthStyle.apiKey);
expect(ServiceKind.bindery.role, ServiceRole.automation);
expect(ServiceKind.bindery.acceptsTorrents, isFalse);
});

test('existing services retain their default ports', () {
expect(ServiceKind.sonarr.defaultPort, 8989);
expect(ServiceKind.glances.defaultPort, 61208);
Expand Down
24 changes: 24 additions & 0 deletions packages/core_networking/lib/src/service_health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum _HealthMode {
case ServiceKind.sonarr:
case ServiceKind.radarr:
return (path: 'api/v3/system/status', mode: _HealthMode.authed);
case ServiceKind.bindery:
case ServiceKind.lidarr:
case ServiceKind.prowlarr:
return (path: 'api/v1/system/status', mode: _HealthMode.authed);
Expand Down Expand Up @@ -253,6 +254,19 @@ class HealthProbe {
? await dio.get<dynamic>(path, options: options)
: await dio.post<dynamic>(path, data: body, options: options);
final int status = resp.statusCode ?? 0;
if (instance.kind == ServiceKind.bindery && connectionOnly &&
interpretServiceHealthResponse(instance.kind, status, resp.data,
contentType: resp.headers.value(Headers.contentTypeHeader)) == Health.ok) {
// LAN bypass can accept an incorrect key. Compare against the
// admin auth configuration in memory; never log or store its key.
final config = await dio.get<dynamic>('api/v1/auth/config',
options: Options(validateStatus: (_) => true,
followRedirects: false, receiveTimeout: const Duration(seconds: 8)));
final auth = instance.auth;
return auth is InstanceAuthApiKey && config.statusCode == 200 &&
binderyKeyMatches(auth.apiKey, config.data)
? Health.ok : Health.warning;
}
return interpretServiceHealthResponse(
instance.kind,
status,
Expand Down Expand Up @@ -312,6 +326,11 @@ Health interpretServiceHealthResponse(
switch (mode) {
case _HealthMode.authed:
if (status >= 200 && status < 300) {
if (kind == ServiceKind.bindery &&
!(data is Map && data['version'] is String &&
(data['version'] as String).isNotEmpty)) {
return Health.warning;
}
if (kind == ServiceKind.speedtestTracker &&
!_isSpeedtestResultsEnvelope(data)) {
// The host answered, but not with the authenticated API contract.
Expand Down Expand Up @@ -437,3 +456,8 @@ bool _subsonicSaysOk(Object? data) {
final Object? envelope = data['subsonic-response'];
return envelope is Map && envelope['status'] == 'ok';
}

/// Compare the configured key without exposing the server credential.
bool binderyKeyMatches(String supplied, Object? config) =>
supplied.isNotEmpty && config is Map && config['apiKey'] is String &&
config['apiKey'] == supplied;
12 changes: 12 additions & 0 deletions packages/core_networking/test/bindery_key_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:core_networking/src/service_health.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
test('Bindery key verification requires an exact nonempty match', () {
expect(binderyKeyMatches('test-key', {'apiKey': 'test-key'}), isTrue);
expect(binderyKeyMatches('hello', {'apiKey': 'test-key'}), isFalse);
expect(binderyKeyMatches('', {'apiKey': ''}), isFalse);
expect(binderyKeyMatches('test-key', {'mode': 'local_only'}), isFalse);
expect(binderyKeyMatches('test-key', null), isFalse);
});
}
17 changes: 17 additions & 0 deletions packages/core_networking/test/service_health_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ import 'package:core_networking/core_networking.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
group('Bindery authenticated health', () {
test('version response is healthy', () {
expect(interpretServiceHealthResponse(ServiceKind.bindery, 200,
<String, dynamic>{'version': '1.53.0'}), Health.ok);
});
test('refused credentials and invalid responses warn', () {
for (final int status in <int>[401, 403, 404, 503]) {
expect(interpretServiceHealthResponse(ServiceKind.bindery, status,
null), Health.warning);
}
for (final Object? body in <Object?>[null, '<html>', <String, dynamic>{}]) {
expect(interpretServiceHealthResponse(ServiceKind.bindery, 200,
body), Health.warning);
}
});
});

group('aria2 JSON-RPC health', _aria2Tests);
group('AdGuard Home anonymous health', _adguardHomeTests);
group('proxy interception', _interceptionTests);
Expand Down
2 changes: 2 additions & 0 deletions packages/core_ui/lib/src/service_visuals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ abstract final class ServiceVisuals {
ServiceKind.aria2 => Icons.download_for_offline_outlined,
ServiceKind.cleanuparr => Icons.cleaning_services_outlined,
ServiceKind.slskd => Icons.library_music_outlined,
ServiceKind.bindery => Icons.menu_book_outlined,
};

static Color accent(ServiceKind kind) => switch (kind) {
Expand Down Expand Up @@ -71,6 +72,7 @@ abstract final class ServiceVisuals {
ServiceKind.aria2 => const Color(0xFF2F6FA8),
ServiceKind.cleanuparr => const Color(0xFF7C3AED),
ServiceKind.slskd => const Color(0xFF007ACC),
ServiceKind.bindery => const Color(0xFF8B7355),
};

/// Human label for a [ServiceRole] section header.
Expand Down
4 changes: 3 additions & 1 deletion packages/core_ui/lib/src/widgets/service_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ class ServiceTile extends StatelessWidget {
required this.instance,
this.health = Health.unknown,
this.subtitle,
this.serviceIcon,
this.onTap,
this.onLongPress,
super.key,
});

final Instance instance;
final Health health;
final Widget? serviceIcon;

/// Overrides the default subtitle (the service tagline) when provided -
/// e.g., a queue count or "3 missing".
Expand All @@ -39,7 +41,7 @@ class ServiceTile extends StatelessWidget {
color: accent.withValues(alpha: 0.18),
borderRadius: BorderRadius.circular(Radii.sm),
),
child: Icon(ServiceVisuals.icon(instance.kind), color: accent),
child: serviceIcon ?? Icon(ServiceVisuals.icon(instance.kind), color: accent),
),
title: Row(
children: <Widget>[
Expand Down
Loading