mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
lint cleanup
This commit is contained in:
parent
fe9d9f8aca
commit
9fa1666e8b
@ -2,6 +2,14 @@ include: package:lint_hard/all.yaml
|
|||||||
analyzer:
|
analyzer:
|
||||||
errors:
|
errors:
|
||||||
invalid_annotation_target: ignore
|
invalid_annotation_target: ignore
|
||||||
|
exclude:
|
||||||
|
- '**/*.g.dart'
|
||||||
|
- '**/*.freezed.dart'
|
||||||
|
- '**/*.pb.dart'
|
||||||
|
- '**/*.pbenum.dart'
|
||||||
|
- '**/*.pbjson.dart'
|
||||||
|
- '**/*.pbserver.dart'
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
- unawaited_futures
|
unawaited_futures: true
|
||||||
|
avoid_positional_boolean_parameters: false
|
@ -24,7 +24,8 @@ class AccountRecordInfo with _$AccountRecordInfo {
|
|||||||
// DHT Schema: DFLT(1)
|
// DHT Schema: DFLT(1)
|
||||||
// DHT Key (Private): identityRecordKey
|
// DHT Key (Private): identityRecordKey
|
||||||
// DHT Owner Key: identityPublicKey
|
// DHT Owner Key: identityPublicKey
|
||||||
// DHT Secret: identitySecretKey (stored encrypted with unlock code in local table store)
|
// DHT Secret: identitySecretKey (stored encrypted
|
||||||
|
// with unlock code in local table store)
|
||||||
@freezed
|
@freezed
|
||||||
class Identity with _$Identity {
|
class Identity with _$Identity {
|
||||||
const factory Identity({
|
const factory Identity({
|
||||||
@ -71,7 +72,9 @@ class IdentityMaster with _$IdentityMaster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension IdentityMasterExtension on IdentityMaster {
|
extension IdentityMasterExtension on IdentityMaster {
|
||||||
KeyPair identityWriter(SecretKey secret) => KeyPair(key: identityPublicKey, secret: secret);
|
KeyPair identityWriter(SecretKey secret) =>
|
||||||
|
KeyPair(key: identityPublicKey, secret: secret);
|
||||||
|
|
||||||
KeyPair masterWriter(SecretKey secret) => KeyPair(key: masterPublicKey, secret: secret);
|
KeyPair masterWriter(SecretKey secret) =>
|
||||||
|
KeyPair(key: masterPublicKey, secret: secret);
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,10 @@ enum EncryptionKeyType {
|
|||||||
pin,
|
pin,
|
||||||
password;
|
password;
|
||||||
|
|
||||||
String toJson() => name.toPascalCase();
|
|
||||||
factory EncryptionKeyType.fromJson(dynamic j) =>
|
factory EncryptionKeyType.fromJson(dynamic j) =>
|
||||||
EncryptionKeyType.values.byName((j as String).toCamelCase());
|
EncryptionKeyType.values.byName((j as String).toCamelCase());
|
||||||
|
|
||||||
|
String toJson() => name.toPascalCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local Accounts are stored in a table locally and not backed by a DHT key
|
// Local Accounts are stored in a table locally and not backed by a DHT key
|
||||||
|
@ -11,9 +11,10 @@ enum DarkModePreference {
|
|||||||
light,
|
light,
|
||||||
dark;
|
dark;
|
||||||
|
|
||||||
String toJson() => name.toPascalCase();
|
|
||||||
factory DarkModePreference.fromJson(dynamic j) =>
|
factory DarkModePreference.fromJson(dynamic j) =>
|
||||||
DarkModePreference.values.byName((j as String).toCamelCase());
|
DarkModePreference.values.byName((j as String).toCamelCase());
|
||||||
|
|
||||||
|
String toJson() => name.toPascalCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock preference changes how frequently the messenger locks its
|
// Lock preference changes how frequently the messenger locks its
|
||||||
@ -61,18 +62,18 @@ enum ColorPreference {
|
|||||||
violet,
|
violet,
|
||||||
yellow;
|
yellow;
|
||||||
|
|
||||||
String toJson() => name.toPascalCase();
|
|
||||||
factory ColorPreference.fromJson(dynamic j) =>
|
factory ColorPreference.fromJson(dynamic j) =>
|
||||||
ColorPreference.values.byName((j as String).toCamelCase());
|
ColorPreference.values.byName((j as String).toCamelCase());
|
||||||
|
String toJson() => name.toPascalCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Theme supports multiple translations
|
// Theme supports multiple translations
|
||||||
enum LanguagePreference {
|
enum LanguagePreference {
|
||||||
englishUS;
|
englishUS;
|
||||||
|
|
||||||
String toJson() => name.toPascalCase();
|
|
||||||
factory LanguagePreference.fromJson(dynamic j) =>
|
factory LanguagePreference.fromJson(dynamic j) =>
|
||||||
LanguagePreference.values.byName((j as String).toCamelCase());
|
LanguagePreference.values.byName((j as String).toCamelCase());
|
||||||
|
String toJson() => name.toPascalCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preferences are stored in a table locally and globally affect all
|
// Preferences are stored in a table locally and globally affect all
|
||||||
|
@ -11,15 +11,15 @@ export 'proto/veilidchat.pb.dart';
|
|||||||
extension CryptoKeyProto on CryptoKey {
|
extension CryptoKeyProto on CryptoKey {
|
||||||
proto.CryptoKey toProto() {
|
proto.CryptoKey toProto() {
|
||||||
final b = decode();
|
final b = decode();
|
||||||
final out = proto.CryptoKey();
|
final out = proto.CryptoKey()
|
||||||
out.u0 = b[0];
|
..u0 = b[0]
|
||||||
out.u1 = b[1];
|
..u1 = b[1]
|
||||||
out.u2 = b[2];
|
..u2 = b[2]
|
||||||
out.u3 = b[3];
|
..u3 = b[3]
|
||||||
out.u4 = b[4];
|
..u4 = b[4]
|
||||||
out.u5 = b[5];
|
..u5 = b[5]
|
||||||
out.u6 = b[6];
|
..u6 = b[6]
|
||||||
out.u7 = b[7];
|
..u7 = b[7];
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,23 +42,23 @@ extension CryptoKeyProto on CryptoKey {
|
|||||||
extension SignatureProto on Signature {
|
extension SignatureProto on Signature {
|
||||||
proto.Signature toProto() {
|
proto.Signature toProto() {
|
||||||
final b = decode();
|
final b = decode();
|
||||||
final out = proto.Signature();
|
final out = proto.Signature()
|
||||||
out.u0 = b[0];
|
..u0 = b[0]
|
||||||
out.u1 = b[1];
|
..u1 = b[1]
|
||||||
out.u2 = b[2];
|
..u2 = b[2]
|
||||||
out.u3 = b[3];
|
..u3 = b[3]
|
||||||
out.u4 = b[4];
|
..u4 = b[4]
|
||||||
out.u5 = b[5];
|
..u5 = b[5]
|
||||||
out.u6 = b[6];
|
..u6 = b[6]
|
||||||
out.u7 = b[7];
|
..u7 = b[7]
|
||||||
out.u8 = b[8];
|
..u8 = b[8]
|
||||||
out.u9 = b[9];
|
..u9 = b[9]
|
||||||
out.u10 = b[10];
|
..u10 = b[10]
|
||||||
out.u11 = b[11];
|
..u11 = b[11]
|
||||||
out.u12 = b[12];
|
..u12 = b[12]
|
||||||
out.u13 = b[13];
|
..u13 = b[13]
|
||||||
out.u14 = b[14];
|
..u14 = b[14]
|
||||||
out.u15 = b[15];
|
..u15 = b[15];
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,13 +89,13 @@ extension SignatureProto on Signature {
|
|||||||
extension NonceProto on Nonce {
|
extension NonceProto on Nonce {
|
||||||
proto.Signature toProto() {
|
proto.Signature toProto() {
|
||||||
final b = decode();
|
final b = decode();
|
||||||
final out = proto.Signature();
|
final out = proto.Signature()
|
||||||
out.u0 = b[0];
|
..u0 = b[0]
|
||||||
out.u1 = b[1];
|
..u1 = b[1]
|
||||||
out.u2 = b[2];
|
..u2 = b[2]
|
||||||
out.u3 = b[3];
|
..u3 = b[3]
|
||||||
out.u4 = b[4];
|
..u4 = b[4]
|
||||||
out.u5 = b[5];
|
..u5 = b[5];
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,11 +115,12 @@ extension NonceProto on Nonce {
|
|||||||
///
|
///
|
||||||
extension TypedKeyProto on TypedKey {
|
extension TypedKeyProto on TypedKey {
|
||||||
proto.TypedKey toProto() {
|
proto.TypedKey toProto() {
|
||||||
final out = proto.TypedKey();
|
final out = proto.TypedKey()
|
||||||
out.kind = kind;
|
..kind = kind
|
||||||
out.value = value.toProto();
|
..value = value.toProto();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TypedKey fromProto(proto.TypedKey p) => TypedKey(kind: p.kind, value: CryptoKeyProto.fromProto(p.value));
|
static TypedKey fromProto(proto.TypedKey p) =>
|
||||||
|
TypedKey(kind: p.kind, value: CryptoKeyProto.fromProto(p.value));
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,8 @@ void initLoggy() {
|
|||||||
logOptions: getLogOptions(null),
|
logOptions: getLogOptions(null),
|
||||||
);
|
);
|
||||||
|
|
||||||
const isTrace = String.fromEnvironment('logTrace') != '';
|
// ignore: do_not_use_environment
|
||||||
|
const isTrace = String.fromEnvironment('LOG_TRACE') != '';
|
||||||
LogLevel logLevel;
|
LogLevel logLevel;
|
||||||
if (isTrace) {
|
if (isTrace) {
|
||||||
logLevel = traceLevel;
|
logLevel = traceLevel;
|
||||||
|
@ -10,11 +10,11 @@ class LoginPage extends ConsumerWidget {
|
|||||||
const LoginPage({super.key});
|
const LoginPage({super.key});
|
||||||
static const path = '/login';
|
static const path = '/login';
|
||||||
|
|
||||||
void _onReorder(WidgetRef ref, int oldIndex, int newIndex) {
|
// void _onReorder(WidgetRef ref, int oldIndex, int newIndex) {
|
||||||
final accounts = ref.read(localAccountsProvider.notifier);
|
// final accounts = ref.read(localAccountsProvider.notifier);
|
||||||
accounts.reorderAccount(oldIndex, newIndex);
|
// accounts.reorderAccount(oldIndex, newIndex);
|
||||||
// xxx fix this so we can await this properly, use FutureBuilder or whatever
|
// // xxx fix this so we can await this properly, use FutureBuilder or whatever
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@ -52,7 +52,8 @@ class LoginPage extends ConsumerWidget {
|
|||||||
// _onReorder(ref, oldIndex, newIndex),
|
// _onReorder(ref, oldIndex, newIndex),
|
||||||
// children: accountList.map<Widget>((account) {
|
// children: accountList.map<Widget>((account) {
|
||||||
// return AccountBubble(
|
// return AccountBubble(
|
||||||
// key: ValueKey(account.identityMaster.masterRecordKey),
|
// key: ValueKey(
|
||||||
|
// account.identityMaster.masterRecordKey),
|
||||||
// account: account);
|
// account: account);
|
||||||
// }).toList(),
|
// }).toList(),
|
||||||
// )),
|
// )),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:riverpod/src/stream_provider.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
import '../tools/tools.dart';
|
import '../tools/tools.dart';
|
||||||
|
|
||||||
@ -15,4 +15,5 @@ enum ConnectionState {
|
|||||||
|
|
||||||
ExternalStreamState<ConnectionState> globalConnectionState =
|
ExternalStreamState<ConnectionState> globalConnectionState =
|
||||||
ExternalStreamState<ConnectionState>(ConnectionState.detached);
|
ExternalStreamState<ConnectionState>(ConnectionState.detached);
|
||||||
AutoDisposeStreamProvider<ConnectionState> globalConnectionStateProvider = globalConnectionState.provider();
|
AutoDisposeStreamProvider<ConnectionState> globalConnectionStateProvider =
|
||||||
|
globalConnectionState.provider();
|
||||||
|
@ -55,7 +55,8 @@ class LocalAccounts extends _$LocalAccounts
|
|||||||
Future<LocalAccount> newAccount(
|
Future<LocalAccount> newAccount(
|
||||||
{required IdentityMaster identityMaster,
|
{required IdentityMaster identityMaster,
|
||||||
required SecretKey identitySecret,
|
required SecretKey identitySecret,
|
||||||
required proto.Account account, EncryptionKeyType encryptionKeyType = EncryptionKeyType.none,
|
required proto.Account account,
|
||||||
|
EncryptionKeyType encryptionKeyType = EncryptionKeyType.none,
|
||||||
String encryptionKey = ''}) async {
|
String encryptionKey = ''}) async {
|
||||||
final veilid = await eventualVeilid.future;
|
final veilid = await eventualVeilid.future;
|
||||||
final localAccounts = state.requireValue;
|
final localAccounts = state.requireValue;
|
||||||
@ -109,7 +110,7 @@ class LocalAccounts extends _$LocalAccounts
|
|||||||
|
|
||||||
// Update identity key to include account
|
// Update identity key to include account
|
||||||
final newAccountRecordInfo = AccountRecordInfo(
|
final newAccountRecordInfo = AccountRecordInfo(
|
||||||
key: accountRec.key(), owner: accountRec.ownerKeyPair()!);
|
key: accountRec.key, owner: accountRec.ownerKeyPair!);
|
||||||
|
|
||||||
await identityRec.eventualUpdateJson(Identity.fromJson,
|
await identityRec.eventualUpdateJson(Identity.fromJson,
|
||||||
(oldIdentity) async {
|
(oldIdentity) async {
|
||||||
@ -141,7 +142,7 @@ class LocalAccounts extends _$LocalAccounts
|
|||||||
await store(updated);
|
await store(updated);
|
||||||
state = AsyncValue.data(updated);
|
state = AsyncValue.data(updated);
|
||||||
|
|
||||||
// xxx todo: wipe messages
|
// TO DO: wipe messages
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,18 @@ class RouterNotifier extends _$RouterNotifier implements Listenable {
|
|||||||
|
|
||||||
// When this notifier's state changes, inform GoRouter
|
// When this notifier's state changes, inform GoRouter
|
||||||
ref.listenSelf((_, __) {
|
ref.listenSelf((_, __) {
|
||||||
if (state.isLoading) return;
|
if (state.isLoading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
routerListener?.call();
|
routerListener?.call();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Redirects when our state changes
|
/// Redirects when our state changes
|
||||||
String? redirect(BuildContext context, GoRouterState state) {
|
String? redirect(BuildContext context, GoRouterState state) {
|
||||||
if (this.state.isLoading || this.state.hasError) return null;
|
if (this.state.isLoading || this.state.hasError) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
switch (state.location) {
|
switch (state.location) {
|
||||||
case IndexPage.path:
|
case IndexPage.path:
|
||||||
|
@ -23,25 +23,25 @@ Future<void> setupDesktopWindow() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableTitleBar(bool enabled) {
|
Future<void> enableTitleBar(bool enabled) async {
|
||||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
windowManager.setTitleBarStyle(TitleBarStyle.normal);
|
await windowManager.setTitleBarStyle(TitleBarStyle.normal);
|
||||||
} else {
|
} else {
|
||||||
windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
await windowManager.setTitleBarStyle(TitleBarStyle.hidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void portraitOnly() {
|
Future<void> portraitOnly() async {
|
||||||
SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.portraitUp,
|
DeviceOrientation.portraitUp,
|
||||||
DeviceOrientation.portraitDown,
|
DeviceOrientation.portraitDown,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void landscapeOnly() {
|
Future<void> landscapeOnly() async {
|
||||||
SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([
|
||||||
DeviceOrientation.landscapeLeft,
|
DeviceOrientation.landscapeLeft,
|
||||||
DeviceOrientation.landscapeRight,
|
DeviceOrientation.landscapeRight,
|
||||||
]);
|
]);
|
||||||
|
@ -14,7 +14,8 @@ class ExternalStreamState<T> {
|
|||||||
streamController.add(newState);
|
streamController.add(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoDisposeStreamProvider<T> provider() => AutoDisposeStreamProvider<T>((ref) async* {
|
AutoDisposeStreamProvider<T> provider() =>
|
||||||
|
AutoDisposeStreamProvider<T>((ref) async* {
|
||||||
if (await streamController.stream.isEmpty) {
|
if (await streamController.stream.isEmpty) {
|
||||||
yield currentState;
|
yield currentState;
|
||||||
}
|
}
|
||||||
|
@ -275,10 +275,10 @@ Map<String, int> _buildPhonoToByte() {
|
|||||||
|
|
||||||
String prettyPhonoString(String s,
|
String prettyPhonoString(String s,
|
||||||
{int wordsPerLine = 5, int phonoPerWord = 2}) {
|
{int wordsPerLine = 5, int phonoPerWord = 2}) {
|
||||||
assert(wordsPerLine >= 1);
|
assert(wordsPerLine >= 1, 'Should not have zero or negative words per line');
|
||||||
assert(phonoPerWord >= 1);
|
assert(phonoPerWord >= 1, 'Should not have zero or negative phono per word');
|
||||||
final cs = canonicalPhonoString(s).toUpperCase();
|
final cs = canonicalPhonoString(s).toUpperCase();
|
||||||
var out = '';
|
final out = StringBuffer();
|
||||||
var words = 0;
|
var words = 0;
|
||||||
var phonos = 0;
|
var phonos = 0;
|
||||||
for (var i = 0; i < cs.length; i += 3) {
|
for (var i = 0; i < cs.length; i += 3) {
|
||||||
@ -289,15 +289,15 @@ String prettyPhonoString(String s,
|
|||||||
words += 1;
|
words += 1;
|
||||||
if (words == wordsPerLine) {
|
if (words == wordsPerLine) {
|
||||||
words = 0;
|
words = 0;
|
||||||
out += '\n';
|
out.write('\n');
|
||||||
} else {
|
} else {
|
||||||
out += ' ';
|
out.write(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out += cs.substring(i, i + 3);
|
out.write(cs.substring(i, i + 3));
|
||||||
}
|
}
|
||||||
return out;
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
String canonicalPhonoString(String s) {
|
String canonicalPhonoString(String s) {
|
||||||
@ -334,9 +334,9 @@ Uint8List decodePhono(String s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String encodePhono(Uint8List b) {
|
String encodePhono(Uint8List b) {
|
||||||
var out = '';
|
final out = StringBuffer();
|
||||||
for (var i = 0; i < b.length; i++) {
|
for (var i = 0; i < b.length; i++) {
|
||||||
out += _byteToPhono[b[i]];
|
out.write(_byteToPhono[b[i]]);
|
||||||
}
|
}
|
||||||
return out;
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,5 @@ Future<Uint8List> protobufUpdateBytes<T extends GeneratedMessage>(
|
|||||||
|
|
||||||
Future<Uint8List> Function(Uint8List)
|
Future<Uint8List> Function(Uint8List)
|
||||||
protobufUpdate<T extends GeneratedMessage>(
|
protobufUpdate<T extends GeneratedMessage>(
|
||||||
T Function(List<int>) fromBuffer, Future<T> Function(T) update) => (oldBytes) => protobufUpdateBytes(fromBuffer, oldBytes, update);
|
T Function(List<int>) fromBuffer, Future<T> Function(T) update) =>
|
||||||
|
(oldBytes) => protobufUpdateBytes(fromBuffer, oldBytes, update);
|
||||||
|
@ -2,14 +2,17 @@ import 'package:veilid/veilid.dart';
|
|||||||
|
|
||||||
Future<VeilidConfig> getVeilidChatConfig() async {
|
Future<VeilidConfig> getVeilidChatConfig() async {
|
||||||
var config = await getDefaultVeilidConfig('VeilidChat');
|
var config = await getDefaultVeilidConfig('VeilidChat');
|
||||||
|
// ignore: do_not_use_environment
|
||||||
if (const String.fromEnvironment('DELETE_TABLE_STORE') == '1') {
|
if (const String.fromEnvironment('DELETE_TABLE_STORE') == '1') {
|
||||||
config =
|
config =
|
||||||
config.copyWith(tableStore: config.tableStore.copyWith(delete: true));
|
config.copyWith(tableStore: config.tableStore.copyWith(delete: true));
|
||||||
}
|
}
|
||||||
|
// ignore: do_not_use_environment
|
||||||
if (const String.fromEnvironment('DELETE_PROTECTED_STORE') == '1') {
|
if (const String.fromEnvironment('DELETE_PROTECTED_STORE') == '1') {
|
||||||
config = config.copyWith(
|
config = config.copyWith(
|
||||||
protectedStore: config.protectedStore.copyWith(delete: true));
|
protectedStore: config.protectedStore.copyWith(delete: true));
|
||||||
}
|
}
|
||||||
|
// ignore: do_not_use_environment
|
||||||
if (const String.fromEnvironment('DELETE_BLOCK_STORE') == '1') {
|
if (const String.fromEnvironment('DELETE_BLOCK_STORE') == '1') {
|
||||||
config =
|
config =
|
||||||
config.copyWith(blockStore: config.blockStore.copyWith(delete: true));
|
config.copyWith(blockStore: config.blockStore.copyWith(delete: true));
|
||||||
|
@ -12,17 +12,16 @@ class DHTRecord {
|
|||||||
required DHTRecordDescriptor recordDescriptor,
|
required DHTRecordDescriptor recordDescriptor,
|
||||||
int defaultSubkey = 0,
|
int defaultSubkey = 0,
|
||||||
KeyPair? writer,
|
KeyPair? writer,
|
||||||
DHTRecordCrypto crypto = const DHTRecordCryptoPublic()})
|
this.crypto = const DHTRecordCryptoPublic()})
|
||||||
: _dhtctx = dhtctx,
|
: _dhtctx = dhtctx,
|
||||||
_recordDescriptor = recordDescriptor,
|
_recordDescriptor = recordDescriptor,
|
||||||
_defaultSubkey = defaultSubkey,
|
_defaultSubkey = defaultSubkey,
|
||||||
_writer = writer,
|
_writer = writer;
|
||||||
_crypto = crypto;
|
|
||||||
final VeilidRoutingContext _dhtctx;
|
final VeilidRoutingContext _dhtctx;
|
||||||
final DHTRecordDescriptor _recordDescriptor;
|
final DHTRecordDescriptor _recordDescriptor;
|
||||||
final int _defaultSubkey;
|
final int _defaultSubkey;
|
||||||
final KeyPair? _writer;
|
final KeyPair? _writer;
|
||||||
DHTRecordCrypto _crypto;
|
DHTRecordCrypto crypto;
|
||||||
|
|
||||||
static Future<DHTRecord> create(VeilidRoutingContext dhtctx,
|
static Future<DHTRecord> create(VeilidRoutingContext dhtctx,
|
||||||
{DHTSchema schema = const DHTSchema.dflt(oCnt: 1),
|
{DHTSchema schema = const DHTSchema.dflt(oCnt: 1),
|
||||||
@ -76,17 +75,13 @@ class DHTRecord {
|
|||||||
|
|
||||||
int subkeyOrDefault(int subkey) => (subkey == -1) ? _defaultSubkey : subkey;
|
int subkeyOrDefault(int subkey) => (subkey == -1) ? _defaultSubkey : subkey;
|
||||||
|
|
||||||
TypedKey key() => _recordDescriptor.key;
|
TypedKey get key => _recordDescriptor.key;
|
||||||
|
|
||||||
PublicKey owner() => _recordDescriptor.owner;
|
PublicKey get owner => _recordDescriptor.owner;
|
||||||
|
|
||||||
KeyPair? ownerKeyPair() => _recordDescriptor.ownerKeyPair();
|
KeyPair? get ownerKeyPair => _recordDescriptor.ownerKeyPair();
|
||||||
|
|
||||||
KeyPair? writer() => _writer;
|
KeyPair? get writer => _writer;
|
||||||
|
|
||||||
void setCrypto(DHTRecordCrypto crypto) {
|
|
||||||
_crypto = crypto;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await _dhtctx.closeDHTRecord(_recordDescriptor.key);
|
await _dhtctx.closeDHTRecord(_recordDescriptor.key);
|
||||||
@ -122,7 +117,7 @@ class DHTRecord {
|
|||||||
if (valueData == null) {
|
if (valueData == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return _crypto.decrypt(valueData.data, subkey);
|
return crypto.decrypt(valueData.data, subkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<T?> getJson<T>(T Function(dynamic) fromJson,
|
Future<T?> getJson<T>(T Function(dynamic) fromJson,
|
||||||
@ -136,7 +131,7 @@ class DHTRecord {
|
|||||||
|
|
||||||
Future<void> eventualWriteBytes(Uint8List newValue, {int subkey = -1}) async {
|
Future<void> eventualWriteBytes(Uint8List newValue, {int subkey = -1}) async {
|
||||||
subkey = subkeyOrDefault(subkey);
|
subkey = subkeyOrDefault(subkey);
|
||||||
newValue = await _crypto.encrypt(newValue, subkey);
|
newValue = await crypto.encrypt(newValue, subkey);
|
||||||
// Get existing identity key
|
// Get existing identity key
|
||||||
ValueData? valueData;
|
ValueData? valueData;
|
||||||
do {
|
do {
|
||||||
@ -162,9 +157,9 @@ class DHTRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the data
|
// Update the data
|
||||||
final oldData = await _crypto.decrypt(valueData.data, subkey);
|
final oldData = await crypto.decrypt(valueData.data, subkey);
|
||||||
final updatedData = await update(oldData);
|
final updatedData = await update(oldData);
|
||||||
final newData = await _crypto.encrypt(updatedData, subkey);
|
final newData = await crypto.encrypt(updatedData, subkey);
|
||||||
|
|
||||||
// Set it back
|
// Set it back
|
||||||
valueData =
|
valueData =
|
||||||
|
@ -13,7 +13,6 @@ abstract class DHTRecordCrypto {
|
|||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
/// Private DHT Record: Encrypted for a specific symmetric key
|
/// Private DHT Record: Encrypted for a specific symmetric key
|
||||||
class DHTRecordCryptoPrivate implements DHTRecordCrypto {
|
class DHTRecordCryptoPrivate implements DHTRecordCrypto {
|
||||||
|
|
||||||
DHTRecordCryptoPrivate._(
|
DHTRecordCryptoPrivate._(
|
||||||
VeilidCryptoSystem cryptoSystem, SharedSecret secretKey)
|
VeilidCryptoSystem cryptoSystem, SharedSecret secretKey)
|
||||||
: _cryptoSystem = cryptoSystem,
|
: _cryptoSystem = cryptoSystem,
|
||||||
@ -41,9 +40,9 @@ class DHTRecordCryptoPrivate implements DHTRecordCrypto {
|
|||||||
// generate nonce
|
// generate nonce
|
||||||
final nonce = await _cryptoSystem.randomNonce();
|
final nonce = await _cryptoSystem.randomNonce();
|
||||||
// crypt and append nonce
|
// crypt and append nonce
|
||||||
final b = BytesBuilder();
|
final b = BytesBuilder()
|
||||||
b.add(await _cryptoSystem.cryptNoAuth(data, nonce, _secretKey));
|
..add(await _cryptoSystem.cryptNoAuth(data, nonce, _secretKey))
|
||||||
b.add(nonce.decode());
|
..add(nonce.decode());
|
||||||
return b.toBytes();
|
return b.toBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,19 +40,20 @@ Future<IdentityMasterWithSecrets> newIdentityMaster() async {
|
|||||||
// Identity record is private
|
// Identity record is private
|
||||||
return (await DHTRecord.create(dhtctx)).deleteScope((identityRec) async {
|
return (await DHTRecord.create(dhtctx)).deleteScope((identityRec) async {
|
||||||
// Make IdentityMaster
|
// Make IdentityMaster
|
||||||
final masterRecordKey = masterRec.key();
|
final masterRecordKey = masterRec.key;
|
||||||
final masterOwner = masterRec.ownerKeyPair()!;
|
final masterOwner = masterRec.ownerKeyPair!;
|
||||||
final masterSigBuf = BytesBuilder();
|
final masterSigBuf = BytesBuilder()
|
||||||
masterSigBuf.add(masterRecordKey.decode());
|
..add(masterRecordKey.decode())
|
||||||
masterSigBuf.add(masterOwner.key.decode());
|
..add(masterOwner.key.decode());
|
||||||
|
|
||||||
final identityRecordKey = identityRec.key();
|
final identityRecordKey = identityRec.key;
|
||||||
final identityOwner = identityRec.ownerKeyPair()!;
|
final identityOwner = identityRec.ownerKeyPair!;
|
||||||
final identitySigBuf = BytesBuilder();
|
final identitySigBuf = BytesBuilder()
|
||||||
identitySigBuf.add(identityRecordKey.decode());
|
..add(identityRecordKey.decode())
|
||||||
identitySigBuf.add(identityOwner.key.decode());
|
..add(identityOwner.key.decode());
|
||||||
|
|
||||||
assert(masterRecordKey.kind == identityRecordKey.kind);
|
assert(masterRecordKey.kind == identityRecordKey.kind,
|
||||||
|
'new master and identity should have same cryptosystem');
|
||||||
final crypto = await veilid.getCryptoSystem(masterRecordKey.kind);
|
final crypto = await veilid.getCryptoSystem(masterRecordKey.kind);
|
||||||
|
|
||||||
final identitySignature =
|
final identitySignature =
|
||||||
|
@ -75,4 +75,5 @@ Future<void> initializeVeilid() async {
|
|||||||
|
|
||||||
// Expose the Veilid instance as a FutureProvider
|
// Expose the Veilid instance as a FutureProvider
|
||||||
@riverpod
|
@riverpod
|
||||||
FutureOr<Veilid> veilidInstance(VeilidInstanceRef ref) async => await eventualVeilid.future;
|
FutureOr<Veilid> veilidInstance(VeilidInstanceRef ref) async =>
|
||||||
|
await eventualVeilid.future;
|
||||||
|
@ -39,8 +39,7 @@ Future<void> processLog(VeilidLog log) async {
|
|||||||
Object? error;
|
Object? error;
|
||||||
final backtrace = log.backtrace;
|
final backtrace = log.backtrace;
|
||||||
if (backtrace != null) {
|
if (backtrace != null) {
|
||||||
stackTrace =
|
stackTrace = StackTrace.fromString('$backtrace\n${StackTrace.current}');
|
||||||
StackTrace.fromString('$backtrace\n${StackTrace.current}');
|
|
||||||
error = 'embedded stack trace for ${log.logLevel} ${log.message}';
|
error = 'embedded stack trace for ${log.logLevel} ${log.message}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +63,8 @@ Future<void> processLog(VeilidLog log) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initVeilidLog() {
|
void initVeilidLog() {
|
||||||
const isTrace = String.fromEnvironment('logTrace') != '';
|
// ignore: do_not_use_environment
|
||||||
|
const isTrace = String.fromEnvironment('LOG_TRACE') != '';
|
||||||
LogLevel logLevel;
|
LogLevel logLevel;
|
||||||
if (isTrace) {
|
if (isTrace) {
|
||||||
logLevel = traceLevel;
|
logLevel = traceLevel;
|
||||||
|
66
pubspec.yaml
66
pubspec.yaml
@ -8,58 +8,58 @@ environment:
|
|||||||
flutter: ">=3.10.0"
|
flutter: ">=3.10.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
animated_theme_switcher: ^2.0.7
|
||||||
|
ansicolor: ^2.0.1
|
||||||
|
awesome_extensions: ^2.0.9
|
||||||
|
badges: ^3.1.1
|
||||||
|
blurry_modal_progress_hud: ^1.1.0
|
||||||
|
change_case: ^1.1.0
|
||||||
|
charcode: ^1.3.1
|
||||||
|
circular_profile_avatar: ^2.0.5
|
||||||
|
cupertino_icons: ^1.0.2
|
||||||
|
equatable: ^2.0.5
|
||||||
|
fast_immutable_collections: ^9.1.5
|
||||||
|
fixnum: ^1.1.0
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_form_builder: ^9.1.0
|
||||||
|
flutter_hooks: ^0.18.0
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_hooks: ^0.18.0
|
|
||||||
hooks_riverpod: ^2.1.3
|
|
||||||
flutter_riverpod: ^2.1.3
|
flutter_riverpod: ^2.1.3
|
||||||
riverpod_annotation: ^2.1.1
|
flutter_spinkit: ^5.2.0
|
||||||
cupertino_icons: ^1.0.2
|
flutter_svg: ^2.0.7
|
||||||
ansicolor: ^2.0.1
|
flutter_translate: ^4.0.4
|
||||||
|
form_builder_validators: ^9.0.0
|
||||||
|
freezed_annotation: ^2.2.0
|
||||||
|
go_router: ^9.0.0
|
||||||
|
hooks_riverpod: ^2.1.3
|
||||||
|
intl: ^0.18.0
|
||||||
|
json_annotation: ^4.8.1
|
||||||
loggy: ^2.0.3
|
loggy: ^2.0.3
|
||||||
uuid: ^3.0.7
|
|
||||||
path: ^1.8.2
|
path: ^1.8.2
|
||||||
path_provider: ^2.0.11
|
path_provider: ^2.0.11
|
||||||
|
protobuf: ^3.0.0
|
||||||
|
quickalert: ^1.0.1
|
||||||
|
radix_colors: ^1.0.4
|
||||||
|
reorderable_grid: ^1.0.7
|
||||||
|
riverpod_annotation: ^2.1.1
|
||||||
|
shared_preferences: ^2.0.15
|
||||||
|
uuid: ^3.0.7
|
||||||
veilid:
|
veilid:
|
||||||
# veilid: ^0.0.1
|
# veilid: ^0.0.1
|
||||||
path: ../veilid/veilid-flutter
|
path: ../veilid/veilid-flutter
|
||||||
animated_theme_switcher: ^2.0.7
|
|
||||||
shared_preferences: ^2.0.15
|
|
||||||
go_router: ^9.0.0
|
|
||||||
fast_immutable_collections: ^9.1.5
|
|
||||||
freezed_annotation: ^2.2.0
|
|
||||||
json_annotation: ^4.8.1
|
|
||||||
equatable: ^2.0.5
|
|
||||||
change_case: ^1.1.0
|
|
||||||
radix_colors: ^1.0.4
|
|
||||||
flutter_translate: ^4.0.4
|
|
||||||
intl: ^0.18.0
|
|
||||||
fixnum: ^1.1.0
|
|
||||||
protobuf: ^3.0.0
|
|
||||||
charcode: ^1.3.1
|
|
||||||
window_manager: ^0.3.5
|
window_manager: ^0.3.5
|
||||||
flutter_svg: ^2.0.7
|
|
||||||
reorderable_grid: ^1.0.7
|
|
||||||
circular_profile_avatar: ^2.0.5
|
|
||||||
badges: ^3.1.1
|
|
||||||
awesome_extensions: ^2.0.9
|
|
||||||
flutter_form_builder: ^9.1.0
|
|
||||||
form_builder_validators: ^9.0.0
|
|
||||||
blurry_modal_progress_hud: ^1.1.0
|
|
||||||
flutter_spinkit: ^5.2.0
|
|
||||||
quickalert: ^1.0.1
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
build_runner: ^2.4.6
|
||||||
|
flutter_launcher_icons: "^0.13.1"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
build_runner: ^2.4.6
|
|
||||||
freezed: ^2.3.5
|
freezed: ^2.3.5
|
||||||
json_serializable: ^6.7.1
|
json_serializable: ^6.7.1
|
||||||
riverpod_generator: ^2.2.3
|
|
||||||
flutter_launcher_icons: "^0.13.1"
|
|
||||||
lint_hard: ^4.0.0
|
lint_hard: ^4.0.0
|
||||||
|
riverpod_generator: ^2.2.3
|
||||||
|
|
||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
image_path: "assets/launcher/icon.png"
|
image_path: "assets/launcher/icon.png"
|
||||||
|
Loading…
Reference in New Issue
Block a user