https://github.com/gitubpatrice/files_tech_core
Code partagé entre les apps Files Tech (PDF Tech, Read Files Tech, Pass Tech)
https://github.com/gitubpatrice/files_tech_core
Last synced: about 1 month ago
JSON representation
Code partagé entre les apps Files Tech (PDF Tech, Read Files Tech, Pass Tech)
- Host: GitHub
- URL: https://github.com/gitubpatrice/files_tech_core
- Owner: gitubpatrice
- License: apache-2.0
- Created: 2026-04-30T20:16:15.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-01T12:27:35.000Z (about 1 month ago)
- Last Synced: 2026-05-01T14:11:01.977Z (about 1 month ago)
- Language: Dart
- Homepage: https://files-tech.com
- Size: 38.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Notice: NOTICE
Awesome Lists containing this project
README
# files_tech_core
[](https://github.com/gitubpatrice/files_tech_core/actions/workflows/ci.yml)
[](LICENSE)
[](https://flutter.dev)
Code partagé entre les apps Files Tech (PDF Tech, Read Files Tech, Pass Tech).
Package local Flutter (path-dependency) — **non publié sur pub.dev**.
## Contenu
| Module | Rôle |
|---|---|
| `RecentFile` + `RecentFilesService` | Liste des fichiers récents persistée dans `SharedPreferences`, robuste aux entrées corrompues |
| `UpdateService` + `UpdateInfo` | Vérification de mises à jour via GitHub Releases, cache 12h, validation semver + host whitelist |
| `CloudShareRow` + `CloudTargets` | Boutons de partage cloud (kDrive, Google Drive, Proton Drive) via MethodChannel |
| `LegalSupportSections` | Sections "Aide & support" + "Mentions légales" avec whitelist de schemes (anti `intent:`/`javascript:`) |
| `FormatUtils` | Formatage humanisé d'octets (`bytes` style FR, `bytesStorage` style EN) |
| `PathSafe` | Validation et sanitisation de noms de fichiers (anti path-traversal) |
## Usage
Ajouter dans le `pubspec.yaml` de l'app consommatrice :
```yaml
dependencies:
files_tech_core:
path: ../files_tech_core
```
### RecentFiles
```dart
import 'package:files_tech_core/files_tech_core.dart';
final svc = RecentFilesService();
List recents = await svc.load();
recents = await svc.addOrUpdate(recents, '/storage/emulated/0/Download/foo.pdf');
```
### UpdateService
Configurer un singleton par app :
```dart
// app/lib/services/app_update.dart
const appUpdateService = UpdateService(
owner: 'gitubpatrice',
repo: 'PDF-TECH',
currentVersion: '1.8.0',
);
// Usage
final info = await appUpdateService.checkForUpdate();
final manualCheck = await appUpdateService.checkForUpdate(force: true);
```
### CloudShareRow
Wrapper per-app pour injecter le nom de channel :
```dart
// app/lib/widgets/cloud_share_row.dart
import 'package:files_tech_core/files_tech_core.dart' as core;
class CloudShareRow extends StatelessWidget {
final String path;
const CloudShareRow({super.key, required this.path});
@override
Widget build(BuildContext context) => core.CloudShareRow(
path: path,
channelName: 'com.pdftech.pdf_tech/share',
alignment: WrapAlignment.center,
);
}
```
Côté Kotlin, le channel doit exposer `sendToPackage` qui prend `path`, `mime`, `package`.
### LegalSupportSections
```dart
const LegalSupportSections(
appName: 'PDF Tech',
version: '1.8.0',
)
```
L'app consommatrice doit déclarer dans son `pubspec.yaml` :
```yaml
flutter:
assets:
- assets/legal/PRIVACY.fr.md
- assets/legal/TERMS.fr.md
```
Override possible des chemins via `privacyAsset` / `termsAsset`, et de
`contactEmail` / `websiteUrl` si nécessaire.
### FormatUtils
```dart
FormatUtils.bytes(1500); // → "1.5 Ko" (FR)
FormatUtils.bytesStorage(1500); // → "1.5 KB" (EN, MB sans décimale)
```
### PathSafe
```dart
PathSafe.basename('/foo/bar.pdf'); // → "bar.pdf"
PathSafe.basename('..'); // → throws ArgumentError
PathSafe.sanitizeFileName('my:file*.txt'); // → "my_file_.txt"
PathSafe.sanitizeForFs('hello world'); // → "hello_world" (variante FS-safe)
PathSafe.isValidUserFileName('foo.pdf'); // → true
```
## Sécurité
- Pas de secret hardcodé
- HTTPS uniquement (`api.github.com`)
- Schemes autorisés dans les liens : `https`, `http`, `mailto` (refus de `intent:`, `javascript:`, `file:`, etc.)
- Refus des URIs avec `userInfo` (anti credential phishing)
- `LaunchMode.externalApplication` (pas de browser-in-app)
- `RecentFilesService.load` filtre silencieusement les entrées corrompues (anti DoS)
- `UpdateService` valide `tag_name` en regex semver et whitelist le host de l'APK (`github.com` / `objects.githubusercontent.com`)
- `mailto` strip CRLF (anti header injection)
## Tests
```bash
flutter test
```
## Conventions
- Versions des apps doivent rester synchronisées entre `pubspec.yaml`,
`AboutScreen._version` et `app_update.dart` `currentVersion`.
- Les channels Kotlin sont par-app (`com.pdftech.pdf_tech/share`,
`com.readfilestech/open_file`, etc.) — déclarés dans le wrapper local.