2024-03-02 17:45:26 -05:00
|
|
|
import 'dart:convert';
|
2023-07-23 21:49:10 -04:00
|
|
|
|
2022-12-26 16:33:48 -05:00
|
|
|
import 'package:path/path.dart' as p;
|
2023-07-26 14:20:17 -04:00
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
|
2022-12-26 16:33:48 -05:00
|
|
|
import 'veilid.dart';
|
|
|
|
|
2024-03-02 17:45:26 -05:00
|
|
|
Future<VeilidConfig> getDefaultVeilidConfig({
|
|
|
|
required bool isWeb,
|
|
|
|
required String programName,
|
|
|
|
String bootstrap = '',
|
|
|
|
String namespace = '',
|
|
|
|
String deviceEncryptionKeyPassword = '',
|
|
|
|
String? newDeviceEncryptionKeyPassword,
|
|
|
|
String networkKeyPassword = '',
|
|
|
|
}) async {
|
|
|
|
final defaultConfigStr = Veilid.instance.defaultVeilidConfig();
|
|
|
|
final defaultConfig = VeilidConfig.fromJson(jsonDecode(defaultConfigStr));
|
|
|
|
return defaultConfig.copyWith(
|
2024-03-02 11:32:08 -05:00
|
|
|
programName: programName,
|
2024-03-02 17:45:26 -05:00
|
|
|
namespace: namespace,
|
|
|
|
tableStore: defaultConfig.tableStore.copyWith(
|
|
|
|
directory: isWeb
|
2024-03-02 11:32:08 -05:00
|
|
|
? ''
|
|
|
|
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
|
|
|
'table_store'),
|
2022-12-26 16:33:48 -05:00
|
|
|
),
|
2024-03-02 17:45:26 -05:00
|
|
|
blockStore: defaultConfig.blockStore.copyWith(
|
|
|
|
directory: isWeb
|
2024-03-02 11:32:08 -05:00
|
|
|
? ''
|
|
|
|
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
|
|
|
'block_store'),
|
2023-08-22 13:19:59 -04:00
|
|
|
),
|
2024-03-02 17:45:26 -05:00
|
|
|
protectedStore: defaultConfig.protectedStore.copyWith(
|
|
|
|
directory: isWeb
|
|
|
|
? ''
|
|
|
|
: p.join((await getApplicationSupportDirectory()).absolute.path,
|
|
|
|
'protected_store'),
|
|
|
|
deviceEncryptionKeyPassword: deviceEncryptionKeyPassword,
|
|
|
|
newDeviceEncryptionKeyPassword: newDeviceEncryptionKeyPassword,
|
2022-12-26 16:33:48 -05:00
|
|
|
),
|
2024-03-02 17:45:26 -05:00
|
|
|
network: defaultConfig.network.copyWith(
|
|
|
|
networkKeyPassword: networkKeyPassword,
|
|
|
|
routingTable: defaultConfig.network.routingTable.copyWith(
|
|
|
|
bootstrap: bootstrap.isNotEmpty
|
|
|
|
? bootstrap.split(',')
|
|
|
|
: defaultConfig.network.routingTable.bootstrap),
|
|
|
|
dht: defaultConfig.network.dht.copyWith()));
|
|
|
|
}
|