/*
* Copyright (c) 2024-2026 Fabian Freund.
*
* This file is part of WebLibre
* (see https://weblibre.eu).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
import 'dart:convert';
import 'package:fast_equatable/fast_equatable.dart';
import 'package:flutter_singbox_proxy/flutter_singbox_proxy.dart';
/// Custom share-link scheme for round-tripping a WebLibre proxy profile
/// (including any secret config) between WebLibre installs. NOT cross-app
/// compatible — for that use the standard ss://, vless://, etc. URIs imported
/// from the editor (and exposed by future per-protocol exporters).
const weblibreProxyShareScheme = 'weblibre-proxy';
class ProxyShareEnvelope with FastEquatable {
/// Schema version — bumped if the wrapped JSON shape ever changes.
/// v1: name + type + config + secret.
/// v2: also carries dnsOverrideJson so per-profile DNS settings survive
/// share/import. Older v1 payloads stay readable (treated as no
/// override).
static const int currentVersion = 2;
final String name;
final SingboxProxyProfileType type;
final String configJson;
final String? secretJson;
final String? dnsOverrideJson;
ProxyShareEnvelope({
required this.name,
required this.type,
required this.configJson,
this.secretJson,
this.dnsOverrideJson,
});
@override
List