From 7ba795132b3d330606595c6718b306d5d99613d4 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Wed, 2 Aug 2023 21:09:47 -0400 Subject: [PATCH] crypto primitives --- veilid-flutter/example/pubspec.lock | 10 +- .../lib/routing_context.freezed.dart | 118 +++--- veilid-flutter/lib/routing_context.g.dart | 14 +- veilid-flutter/lib/veilid.dart | 9 +- veilid-flutter/lib/veilid_config.freezed.dart | 170 ++++---- veilid-flutter/lib/veilid_config.g.dart | 77 ++-- veilid-flutter/lib/veilid_crypto.dart | 46 +++ veilid-flutter/lib/veilid_state.freezed.dart | 383 +++++++++--------- veilid-flutter/lib/veilid_state.g.dart | 62 ++- veilid-flutter/pubspec.yaml | 1 + 10 files changed, 465 insertions(+), 425 deletions(-) diff --git a/veilid-flutter/example/pubspec.lock b/veilid-flutter/example/pubspec.lock index da827445..81b9dd42 100644 --- a/veilid-flutter/example/pubspec.lock +++ b/veilid-flutter/example/pubspec.lock @@ -113,6 +113,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -430,4 +438,4 @@ packages: version: "3.5.0" sdks: dart: ">=3.0.0 <4.0.0" - flutter: ">=3.7.0" + flutter: ">=3.10.6" diff --git a/veilid-flutter/lib/routing_context.freezed.dart b/veilid-flutter/lib/routing_context.freezed.dart index 4bfc27c5..140c2214 100644 --- a/veilid-flutter/lib/routing_context.freezed.dart +++ b/veilid-flutter/lib/routing_context.freezed.dart @@ -600,8 +600,8 @@ DHTRecordDescriptor _$DHTRecordDescriptorFromJson(Map json) { mixin _$DHTRecordDescriptor { Typed get key => throw _privateConstructorUsedError; FixedEncodedString43 get owner => throw _privateConstructorUsedError; - FixedEncodedString43? get ownerSecret => throw _privateConstructorUsedError; DHTSchema get schema => throw _privateConstructorUsedError; + FixedEncodedString43? get ownerSecret => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -618,8 +618,8 @@ abstract class $DHTRecordDescriptorCopyWith<$Res> { $Res call( {Typed key, FixedEncodedString43 owner, - FixedEncodedString43? ownerSecret, - DHTSchema schema}); + DHTSchema schema, + FixedEncodedString43? ownerSecret}); $DHTSchemaCopyWith<$Res> get schema; } @@ -639,8 +639,8 @@ class _$DHTRecordDescriptorCopyWithImpl<$Res, $Val extends DHTRecordDescriptor> $Res call({ Object? key = null, Object? owner = null, - Object? ownerSecret = freezed, Object? schema = null, + Object? ownerSecret = freezed, }) { return _then(_value.copyWith( key: null == key @@ -651,14 +651,14 @@ class _$DHTRecordDescriptorCopyWithImpl<$Res, $Val extends DHTRecordDescriptor> ? _value.owner : owner // ignore: cast_nullable_to_non_nullable as FixedEncodedString43, - ownerSecret: freezed == ownerSecret - ? _value.ownerSecret - : ownerSecret // ignore: cast_nullable_to_non_nullable - as FixedEncodedString43?, schema: null == schema ? _value.schema : schema // ignore: cast_nullable_to_non_nullable as DHTSchema, + ownerSecret: freezed == ownerSecret + ? _value.ownerSecret + : ownerSecret // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43?, ) as $Val); } @@ -682,8 +682,8 @@ abstract class _$$_DHTRecordDescriptorCopyWith<$Res> $Res call( {Typed key, FixedEncodedString43 owner, - FixedEncodedString43? ownerSecret, - DHTSchema schema}); + DHTSchema schema, + FixedEncodedString43? ownerSecret}); @override $DHTSchemaCopyWith<$Res> get schema; @@ -702,8 +702,8 @@ class __$$_DHTRecordDescriptorCopyWithImpl<$Res> $Res call({ Object? key = null, Object? owner = null, - Object? ownerSecret = freezed, Object? schema = null, + Object? ownerSecret = freezed, }) { return _then(_$_DHTRecordDescriptor( key: null == key @@ -714,14 +714,14 @@ class __$$_DHTRecordDescriptorCopyWithImpl<$Res> ? _value.owner : owner // ignore: cast_nullable_to_non_nullable as FixedEncodedString43, - ownerSecret: freezed == ownerSecret - ? _value.ownerSecret - : ownerSecret // ignore: cast_nullable_to_non_nullable - as FixedEncodedString43?, schema: null == schema ? _value.schema : schema // ignore: cast_nullable_to_non_nullable as DHTSchema, + ownerSecret: freezed == ownerSecret + ? _value.ownerSecret + : ownerSecret // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43?, )); } } @@ -732,8 +732,8 @@ class _$_DHTRecordDescriptor implements _DHTRecordDescriptor { const _$_DHTRecordDescriptor( {required this.key, required this.owner, - this.ownerSecret, - required this.schema}); + required this.schema, + this.ownerSecret}); factory _$_DHTRecordDescriptor.fromJson(Map json) => _$$_DHTRecordDescriptorFromJson(json); @@ -743,13 +743,13 @@ class _$_DHTRecordDescriptor implements _DHTRecordDescriptor { @override final FixedEncodedString43 owner; @override - final FixedEncodedString43? ownerSecret; - @override final DHTSchema schema; + @override + final FixedEncodedString43? ownerSecret; @override String toString() { - return 'DHTRecordDescriptor(key: $key, owner: $owner, ownerSecret: $ownerSecret, schema: $schema)'; + return 'DHTRecordDescriptor(key: $key, owner: $owner, schema: $schema, ownerSecret: $ownerSecret)'; } @override @@ -759,14 +759,14 @@ class _$_DHTRecordDescriptor implements _DHTRecordDescriptor { other is _$_DHTRecordDescriptor && (identical(other.key, key) || other.key == key) && (identical(other.owner, owner) || other.owner == owner) && + (identical(other.schema, schema) || other.schema == schema) && (identical(other.ownerSecret, ownerSecret) || - other.ownerSecret == ownerSecret) && - (identical(other.schema, schema) || other.schema == schema)); + other.ownerSecret == ownerSecret)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, key, owner, ownerSecret, schema); + int get hashCode => Object.hash(runtimeType, key, owner, schema, ownerSecret); @JsonKey(ignore: true) @override @@ -787,8 +787,8 @@ abstract class _DHTRecordDescriptor implements DHTRecordDescriptor { const factory _DHTRecordDescriptor( {required final Typed key, required final FixedEncodedString43 owner, - final FixedEncodedString43? ownerSecret, - required final DHTSchema schema}) = _$_DHTRecordDescriptor; + required final DHTSchema schema, + final FixedEncodedString43? ownerSecret}) = _$_DHTRecordDescriptor; factory _DHTRecordDescriptor.fromJson(Map json) = _$_DHTRecordDescriptor.fromJson; @@ -798,10 +798,10 @@ abstract class _DHTRecordDescriptor implements DHTRecordDescriptor { @override FixedEncodedString43 get owner; @override - FixedEncodedString43? get ownerSecret; - @override DHTSchema get schema; @override + FixedEncodedString43? get ownerSecret; + @override @JsonKey(ignore: true) _$$_DHTRecordDescriptorCopyWith<_$_DHTRecordDescriptor> get copyWith => throw _privateConstructorUsedError; @@ -1151,10 +1151,10 @@ SafetySpec _$SafetySpecFromJson(Map json) { /// @nodoc mixin _$SafetySpec { - String? get preferredRoute => throw _privateConstructorUsedError; int get hopCount => throw _privateConstructorUsedError; Stability get stability => throw _privateConstructorUsedError; Sequencing get sequencing => throw _privateConstructorUsedError; + String? get preferredRoute => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -1169,10 +1169,10 @@ abstract class $SafetySpecCopyWith<$Res> { _$SafetySpecCopyWithImpl<$Res, SafetySpec>; @useResult $Res call( - {String? preferredRoute, - int hopCount, + {int hopCount, Stability stability, - Sequencing sequencing}); + Sequencing sequencing, + String? preferredRoute}); } /// @nodoc @@ -1188,16 +1188,12 @@ class _$SafetySpecCopyWithImpl<$Res, $Val extends SafetySpec> @pragma('vm:prefer-inline') @override $Res call({ - Object? preferredRoute = freezed, Object? hopCount = null, Object? stability = null, Object? sequencing = null, + Object? preferredRoute = freezed, }) { return _then(_value.copyWith( - preferredRoute: freezed == preferredRoute - ? _value.preferredRoute - : preferredRoute // ignore: cast_nullable_to_non_nullable - as String?, hopCount: null == hopCount ? _value.hopCount : hopCount // ignore: cast_nullable_to_non_nullable @@ -1210,6 +1206,10 @@ class _$SafetySpecCopyWithImpl<$Res, $Val extends SafetySpec> ? _value.sequencing : sequencing // ignore: cast_nullable_to_non_nullable as Sequencing, + preferredRoute: freezed == preferredRoute + ? _value.preferredRoute + : preferredRoute // ignore: cast_nullable_to_non_nullable + as String?, ) as $Val); } } @@ -1223,10 +1223,10 @@ abstract class _$$_SafetySpecCopyWith<$Res> @override @useResult $Res call( - {String? preferredRoute, - int hopCount, + {int hopCount, Stability stability, - Sequencing sequencing}); + Sequencing sequencing, + String? preferredRoute}); } /// @nodoc @@ -1240,16 +1240,12 @@ class __$$_SafetySpecCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? preferredRoute = freezed, Object? hopCount = null, Object? stability = null, Object? sequencing = null, + Object? preferredRoute = freezed, }) { return _then(_$_SafetySpec( - preferredRoute: freezed == preferredRoute - ? _value.preferredRoute - : preferredRoute // ignore: cast_nullable_to_non_nullable - as String?, hopCount: null == hopCount ? _value.hopCount : hopCount // ignore: cast_nullable_to_non_nullable @@ -1262,6 +1258,10 @@ class __$$_SafetySpecCopyWithImpl<$Res> ? _value.sequencing : sequencing // ignore: cast_nullable_to_non_nullable as Sequencing, + preferredRoute: freezed == preferredRoute + ? _value.preferredRoute + : preferredRoute // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -1270,26 +1270,26 @@ class __$$_SafetySpecCopyWithImpl<$Res> @JsonSerializable() class _$_SafetySpec implements _SafetySpec { const _$_SafetySpec( - {this.preferredRoute, - required this.hopCount, + {required this.hopCount, required this.stability, - required this.sequencing}); + required this.sequencing, + this.preferredRoute}); factory _$_SafetySpec.fromJson(Map json) => _$$_SafetySpecFromJson(json); - @override - final String? preferredRoute; @override final int hopCount; @override final Stability stability; @override final Sequencing sequencing; + @override + final String? preferredRoute; @override String toString() { - return 'SafetySpec(preferredRoute: $preferredRoute, hopCount: $hopCount, stability: $stability, sequencing: $sequencing)'; + return 'SafetySpec(hopCount: $hopCount, stability: $stability, sequencing: $sequencing, preferredRoute: $preferredRoute)'; } @override @@ -1297,20 +1297,20 @@ class _$_SafetySpec implements _SafetySpec { return identical(this, other) || (other.runtimeType == runtimeType && other is _$_SafetySpec && - (identical(other.preferredRoute, preferredRoute) || - other.preferredRoute == preferredRoute) && (identical(other.hopCount, hopCount) || other.hopCount == hopCount) && (identical(other.stability, stability) || other.stability == stability) && (identical(other.sequencing, sequencing) || - other.sequencing == sequencing)); + other.sequencing == sequencing) && + (identical(other.preferredRoute, preferredRoute) || + other.preferredRoute == preferredRoute)); } @JsonKey(ignore: true) @override int get hashCode => - Object.hash(runtimeType, preferredRoute, hopCount, stability, sequencing); + Object.hash(runtimeType, hopCount, stability, sequencing, preferredRoute); @JsonKey(ignore: true) @override @@ -1328,16 +1328,14 @@ class _$_SafetySpec implements _SafetySpec { abstract class _SafetySpec implements SafetySpec { const factory _SafetySpec( - {final String? preferredRoute, - required final int hopCount, + {required final int hopCount, required final Stability stability, - required final Sequencing sequencing}) = _$_SafetySpec; + required final Sequencing sequencing, + final String? preferredRoute}) = _$_SafetySpec; factory _SafetySpec.fromJson(Map json) = _$_SafetySpec.fromJson; - @override - String? get preferredRoute; @override int get hopCount; @override @@ -1345,6 +1343,8 @@ abstract class _SafetySpec implements SafetySpec { @override Sequencing get sequencing; @override + String? get preferredRoute; + @override @JsonKey(ignore: true) _$$_SafetySpecCopyWith<_$_SafetySpec> get copyWith => throw _privateConstructorUsedError; diff --git a/veilid-flutter/lib/routing_context.g.dart b/veilid-flutter/lib/routing_context.g.dart index 7cb46bac..da5aa313 100644 --- a/veilid-flutter/lib/routing_context.g.dart +++ b/veilid-flutter/lib/routing_context.g.dart @@ -22,7 +22,7 @@ _$DHTSchemaSMPL _$$DHTSchemaSMPLFromJson(Map json) => _$DHTSchemaSMPL( oCnt: json['o_cnt'] as int, members: (json['members'] as List) - .map((e) => DHTSchemaMember.fromJson(e as Map)) + .map(DHTSchemaMember.fromJson) .toList(), $type: json['kind'] as String?, ); @@ -51,10 +51,10 @@ _$_DHTRecordDescriptor _$$_DHTRecordDescriptorFromJson( _$_DHTRecordDescriptor( key: Typed.fromJson(json['key']), owner: FixedEncodedString43.fromJson(json['owner']), + schema: DHTSchema.fromJson(json['schema']), ownerSecret: json['owner_secret'] == null ? null : FixedEncodedString43.fromJson(json['owner_secret']), - schema: DHTSchema.fromJson(json['schema'] as Map), ); Map _$$_DHTRecordDescriptorToJson( @@ -62,8 +62,8 @@ Map _$$_DHTRecordDescriptorToJson( { 'key': instance.key.toJson(), 'owner': instance.owner.toJson(), - 'owner_secret': instance.ownerSecret?.toJson(), 'schema': instance.schema.toJson(), + 'owner_secret': instance.ownerSecret?.toJson(), }; _$_ValueSubkeyRange _$$_ValueSubkeyRangeFromJson(Map json) => @@ -93,18 +93,18 @@ Map _$$_ValueDataToJson(_$_ValueData instance) => _$_SafetySpec _$$_SafetySpecFromJson(Map json) => _$_SafetySpec( - preferredRoute: json['preferred_route'] as String?, hopCount: json['hop_count'] as int, - stability: Stability.fromJson(json['stability'] as String), - sequencing: Sequencing.fromJson(json['sequencing'] as String), + stability: Stability.fromJson(json['stability']), + sequencing: Sequencing.fromJson(json['sequencing']), + preferredRoute: json['preferred_route'] as String?, ); Map _$$_SafetySpecToJson(_$_SafetySpec instance) => { - 'preferred_route': instance.preferredRoute, 'hop_count': instance.hopCount, 'stability': instance.stability.toJson(), 'sequencing': instance.sequencing.toJson(), + 'preferred_route': instance.preferredRoute, }; _$_RouteBlob _$$_RouteBlobFromJson(Map json) => _$_RouteBlob( diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index b65ac68d..378cc732 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -3,6 +3,7 @@ import 'dart:typed_data'; import 'package:equatable/equatable.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:fixnum/fixnum.dart'; ////////////////////////////////////////////////////////// @@ -61,6 +62,8 @@ class VeilidVersion extends Equatable { @immutable class Timestamp extends Equatable { const Timestamp({required this.value}); + factory Timestamp.fromInt64(Int64 i64) => + Timestamp(value: BigInt.parse(i64.toStringUnsigned())); factory Timestamp.fromString(String s) => Timestamp(value: BigInt.parse(s)); factory Timestamp.fromJson(dynamic json) => Timestamp.fromString(json as String); @@ -70,8 +73,8 @@ class Timestamp extends Equatable { @override String toString() => value.toString(); - String toJson() => toString(); + Int64 toInt64() => Int64.parseInt(value.toString()); TimestampDuration diff(Timestamp other) => TimestampDuration(value: value - other.value); @@ -83,6 +86,8 @@ class Timestamp extends Equatable { @immutable class TimestampDuration extends Equatable { const TimestampDuration({required this.value}); + factory TimestampDuration.fromInt64(Int64 i64) => + TimestampDuration(value: BigInt.parse(i64.toStringUnsigned())); factory TimestampDuration.fromString(String s) => TimestampDuration(value: BigInt.parse(s)); factory TimestampDuration.fromJson(dynamic json) => @@ -93,8 +98,8 @@ class TimestampDuration extends Equatable { @override String toString() => value.toString(); - String toJson() => toString(); + Int64 toInt64() => Int64.parseInt(value.toString()); int toMillis() => (value ~/ BigInt.from(1000)).toInt(); BigInt toMicros() => value; diff --git a/veilid-flutter/lib/veilid_config.freezed.dart b/veilid-flutter/lib/veilid_config.freezed.dart index 26554b99..779981c9 100644 --- a/veilid-flutter/lib/veilid_config.freezed.dart +++ b/veilid-flutter/lib/veilid_config.freezed.dart @@ -4377,11 +4377,11 @@ VeilidConfigRPC _$VeilidConfigRPCFromJson(Map json) { mixin _$VeilidConfigRPC { int get concurrency => throw _privateConstructorUsedError; int get queueSize => throw _privateConstructorUsedError; - int? get maxTimestampBehindMs => throw _privateConstructorUsedError; - int? get maxTimestampAheadMs => throw _privateConstructorUsedError; int get timeoutMs => throw _privateConstructorUsedError; int get maxRouteHopCount => throw _privateConstructorUsedError; int get defaultRouteHopCount => throw _privateConstructorUsedError; + int? get maxTimestampBehindMs => throw _privateConstructorUsedError; + int? get maxTimestampAheadMs => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -4398,11 +4398,11 @@ abstract class $VeilidConfigRPCCopyWith<$Res> { $Res call( {int concurrency, int queueSize, - int? maxTimestampBehindMs, - int? maxTimestampAheadMs, int timeoutMs, int maxRouteHopCount, - int defaultRouteHopCount}); + int defaultRouteHopCount, + int? maxTimestampBehindMs, + int? maxTimestampAheadMs}); } /// @nodoc @@ -4420,11 +4420,11 @@ class _$VeilidConfigRPCCopyWithImpl<$Res, $Val extends VeilidConfigRPC> $Res call({ Object? concurrency = null, Object? queueSize = null, - Object? maxTimestampBehindMs = freezed, - Object? maxTimestampAheadMs = freezed, Object? timeoutMs = null, Object? maxRouteHopCount = null, Object? defaultRouteHopCount = null, + Object? maxTimestampBehindMs = freezed, + Object? maxTimestampAheadMs = freezed, }) { return _then(_value.copyWith( concurrency: null == concurrency @@ -4435,14 +4435,6 @@ class _$VeilidConfigRPCCopyWithImpl<$Res, $Val extends VeilidConfigRPC> ? _value.queueSize : queueSize // ignore: cast_nullable_to_non_nullable as int, - maxTimestampBehindMs: freezed == maxTimestampBehindMs - ? _value.maxTimestampBehindMs - : maxTimestampBehindMs // ignore: cast_nullable_to_non_nullable - as int?, - maxTimestampAheadMs: freezed == maxTimestampAheadMs - ? _value.maxTimestampAheadMs - : maxTimestampAheadMs // ignore: cast_nullable_to_non_nullable - as int?, timeoutMs: null == timeoutMs ? _value.timeoutMs : timeoutMs // ignore: cast_nullable_to_non_nullable @@ -4455,6 +4447,14 @@ class _$VeilidConfigRPCCopyWithImpl<$Res, $Val extends VeilidConfigRPC> ? _value.defaultRouteHopCount : defaultRouteHopCount // ignore: cast_nullable_to_non_nullable as int, + maxTimestampBehindMs: freezed == maxTimestampBehindMs + ? _value.maxTimestampBehindMs + : maxTimestampBehindMs // ignore: cast_nullable_to_non_nullable + as int?, + maxTimestampAheadMs: freezed == maxTimestampAheadMs + ? _value.maxTimestampAheadMs + : maxTimestampAheadMs // ignore: cast_nullable_to_non_nullable + as int?, ) as $Val); } } @@ -4470,11 +4470,11 @@ abstract class _$$_VeilidConfigRPCCopyWith<$Res> $Res call( {int concurrency, int queueSize, - int? maxTimestampBehindMs, - int? maxTimestampAheadMs, int timeoutMs, int maxRouteHopCount, - int defaultRouteHopCount}); + int defaultRouteHopCount, + int? maxTimestampBehindMs, + int? maxTimestampAheadMs}); } /// @nodoc @@ -4490,11 +4490,11 @@ class __$$_VeilidConfigRPCCopyWithImpl<$Res> $Res call({ Object? concurrency = null, Object? queueSize = null, - Object? maxTimestampBehindMs = freezed, - Object? maxTimestampAheadMs = freezed, Object? timeoutMs = null, Object? maxRouteHopCount = null, Object? defaultRouteHopCount = null, + Object? maxTimestampBehindMs = freezed, + Object? maxTimestampAheadMs = freezed, }) { return _then(_$_VeilidConfigRPC( concurrency: null == concurrency @@ -4505,14 +4505,6 @@ class __$$_VeilidConfigRPCCopyWithImpl<$Res> ? _value.queueSize : queueSize // ignore: cast_nullable_to_non_nullable as int, - maxTimestampBehindMs: freezed == maxTimestampBehindMs - ? _value.maxTimestampBehindMs - : maxTimestampBehindMs // ignore: cast_nullable_to_non_nullable - as int?, - maxTimestampAheadMs: freezed == maxTimestampAheadMs - ? _value.maxTimestampAheadMs - : maxTimestampAheadMs // ignore: cast_nullable_to_non_nullable - as int?, timeoutMs: null == timeoutMs ? _value.timeoutMs : timeoutMs // ignore: cast_nullable_to_non_nullable @@ -4525,6 +4517,14 @@ class __$$_VeilidConfigRPCCopyWithImpl<$Res> ? _value.defaultRouteHopCount : defaultRouteHopCount // ignore: cast_nullable_to_non_nullable as int, + maxTimestampBehindMs: freezed == maxTimestampBehindMs + ? _value.maxTimestampBehindMs + : maxTimestampBehindMs // ignore: cast_nullable_to_non_nullable + as int?, + maxTimestampAheadMs: freezed == maxTimestampAheadMs + ? _value.maxTimestampAheadMs + : maxTimestampAheadMs // ignore: cast_nullable_to_non_nullable + as int?, )); } } @@ -4537,11 +4537,11 @@ class _$_VeilidConfigRPC const _$_VeilidConfigRPC( {required this.concurrency, required this.queueSize, - this.maxTimestampBehindMs, - this.maxTimestampAheadMs, required this.timeoutMs, required this.maxRouteHopCount, - required this.defaultRouteHopCount}); + required this.defaultRouteHopCount, + this.maxTimestampBehindMs, + this.maxTimestampAheadMs}); factory _$_VeilidConfigRPC.fromJson(Map json) => _$$_VeilidConfigRPCFromJson(json); @@ -4551,19 +4551,19 @@ class _$_VeilidConfigRPC @override final int queueSize; @override - final int? maxTimestampBehindMs; - @override - final int? maxTimestampAheadMs; - @override final int timeoutMs; @override final int maxRouteHopCount; @override final int defaultRouteHopCount; + @override + final int? maxTimestampBehindMs; + @override + final int? maxTimestampAheadMs; @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'VeilidConfigRPC(concurrency: $concurrency, queueSize: $queueSize, maxTimestampBehindMs: $maxTimestampBehindMs, maxTimestampAheadMs: $maxTimestampAheadMs, timeoutMs: $timeoutMs, maxRouteHopCount: $maxRouteHopCount, defaultRouteHopCount: $defaultRouteHopCount)'; + return 'VeilidConfigRPC(concurrency: $concurrency, queueSize: $queueSize, timeoutMs: $timeoutMs, maxRouteHopCount: $maxRouteHopCount, defaultRouteHopCount: $defaultRouteHopCount, maxTimestampBehindMs: $maxTimestampBehindMs, maxTimestampAheadMs: $maxTimestampAheadMs)'; } @override @@ -4573,11 +4573,11 @@ class _$_VeilidConfigRPC ..add(DiagnosticsProperty('type', 'VeilidConfigRPC')) ..add(DiagnosticsProperty('concurrency', concurrency)) ..add(DiagnosticsProperty('queueSize', queueSize)) - ..add(DiagnosticsProperty('maxTimestampBehindMs', maxTimestampBehindMs)) - ..add(DiagnosticsProperty('maxTimestampAheadMs', maxTimestampAheadMs)) ..add(DiagnosticsProperty('timeoutMs', timeoutMs)) ..add(DiagnosticsProperty('maxRouteHopCount', maxRouteHopCount)) - ..add(DiagnosticsProperty('defaultRouteHopCount', defaultRouteHopCount)); + ..add(DiagnosticsProperty('defaultRouteHopCount', defaultRouteHopCount)) + ..add(DiagnosticsProperty('maxTimestampBehindMs', maxTimestampBehindMs)) + ..add(DiagnosticsProperty('maxTimestampAheadMs', maxTimestampAheadMs)); } @override @@ -4589,16 +4589,16 @@ class _$_VeilidConfigRPC other.concurrency == concurrency) && (identical(other.queueSize, queueSize) || other.queueSize == queueSize) && - (identical(other.maxTimestampBehindMs, maxTimestampBehindMs) || - other.maxTimestampBehindMs == maxTimestampBehindMs) && - (identical(other.maxTimestampAheadMs, maxTimestampAheadMs) || - other.maxTimestampAheadMs == maxTimestampAheadMs) && (identical(other.timeoutMs, timeoutMs) || other.timeoutMs == timeoutMs) && (identical(other.maxRouteHopCount, maxRouteHopCount) || other.maxRouteHopCount == maxRouteHopCount) && (identical(other.defaultRouteHopCount, defaultRouteHopCount) || - other.defaultRouteHopCount == defaultRouteHopCount)); + other.defaultRouteHopCount == defaultRouteHopCount) && + (identical(other.maxTimestampBehindMs, maxTimestampBehindMs) || + other.maxTimestampBehindMs == maxTimestampBehindMs) && + (identical(other.maxTimestampAheadMs, maxTimestampAheadMs) || + other.maxTimestampAheadMs == maxTimestampAheadMs)); } @JsonKey(ignore: true) @@ -4607,11 +4607,11 @@ class _$_VeilidConfigRPC runtimeType, concurrency, queueSize, - maxTimestampBehindMs, - maxTimestampAheadMs, timeoutMs, maxRouteHopCount, - defaultRouteHopCount); + defaultRouteHopCount, + maxTimestampBehindMs, + maxTimestampAheadMs); @JsonKey(ignore: true) @override @@ -4631,11 +4631,11 @@ abstract class _VeilidConfigRPC implements VeilidConfigRPC { const factory _VeilidConfigRPC( {required final int concurrency, required final int queueSize, - final int? maxTimestampBehindMs, - final int? maxTimestampAheadMs, required final int timeoutMs, required final int maxRouteHopCount, - required final int defaultRouteHopCount}) = _$_VeilidConfigRPC; + required final int defaultRouteHopCount, + final int? maxTimestampBehindMs, + final int? maxTimestampAheadMs}) = _$_VeilidConfigRPC; factory _VeilidConfigRPC.fromJson(Map json) = _$_VeilidConfigRPC.fromJson; @@ -4645,16 +4645,16 @@ abstract class _VeilidConfigRPC implements VeilidConfigRPC { @override int get queueSize; @override - int? get maxTimestampBehindMs; - @override - int? get maxTimestampAheadMs; - @override int get timeoutMs; @override int get maxRouteHopCount; @override int get defaultRouteHopCount; @override + int? get maxTimestampBehindMs; + @override + int? get maxTimestampAheadMs; + @override @JsonKey(ignore: true) _$$_VeilidConfigRPCCopyWith<_$_VeilidConfigRPC> get copyWith => throw _privateConstructorUsedError; @@ -5016,7 +5016,6 @@ mixin _$VeilidConfigNetwork { int get clientWhitelistTimeoutMs => throw _privateConstructorUsedError; int get reverseConnectionReceiptTimeMs => throw _privateConstructorUsedError; int get holePunchReceiptTimeMs => throw _privateConstructorUsedError; - String? get networkKeyPassword => throw _privateConstructorUsedError; VeilidConfigRoutingTable get routingTable => throw _privateConstructorUsedError; VeilidConfigRPC get rpc => throw _privateConstructorUsedError; @@ -5027,6 +5026,7 @@ mixin _$VeilidConfigNetwork { VeilidConfigTLS get tls => throw _privateConstructorUsedError; VeilidConfigApplication get application => throw _privateConstructorUsedError; VeilidConfigProtocol get protocol => throw _privateConstructorUsedError; + String? get networkKeyPassword => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -5050,7 +5050,6 @@ abstract class $VeilidConfigNetworkCopyWith<$Res> { int clientWhitelistTimeoutMs, int reverseConnectionReceiptTimeMs, int holePunchReceiptTimeMs, - String? networkKeyPassword, VeilidConfigRoutingTable routingTable, VeilidConfigRPC rpc, VeilidConfigDHT dht, @@ -5059,7 +5058,8 @@ abstract class $VeilidConfigNetworkCopyWith<$Res> { int restrictedNatRetries, VeilidConfigTLS tls, VeilidConfigApplication application, - VeilidConfigProtocol protocol}); + VeilidConfigProtocol protocol, + String? networkKeyPassword}); $VeilidConfigRoutingTableCopyWith<$Res> get routingTable; $VeilidConfigRPCCopyWith<$Res> get rpc; @@ -5091,7 +5091,6 @@ class _$VeilidConfigNetworkCopyWithImpl<$Res, $Val extends VeilidConfigNetwork> Object? clientWhitelistTimeoutMs = null, Object? reverseConnectionReceiptTimeMs = null, Object? holePunchReceiptTimeMs = null, - Object? networkKeyPassword = freezed, Object? routingTable = null, Object? rpc = null, Object? dht = null, @@ -5101,6 +5100,7 @@ class _$VeilidConfigNetworkCopyWithImpl<$Res, $Val extends VeilidConfigNetwork> Object? tls = null, Object? application = null, Object? protocol = null, + Object? networkKeyPassword = freezed, }) { return _then(_value.copyWith( connectionInitialTimeoutMs: null == connectionInitialTimeoutMs @@ -5139,10 +5139,6 @@ class _$VeilidConfigNetworkCopyWithImpl<$Res, $Val extends VeilidConfigNetwork> ? _value.holePunchReceiptTimeMs : holePunchReceiptTimeMs // ignore: cast_nullable_to_non_nullable as int, - networkKeyPassword: freezed == networkKeyPassword - ? _value.networkKeyPassword - : networkKeyPassword // ignore: cast_nullable_to_non_nullable - as String?, routingTable: null == routingTable ? _value.routingTable : routingTable // ignore: cast_nullable_to_non_nullable @@ -5179,6 +5175,10 @@ class _$VeilidConfigNetworkCopyWithImpl<$Res, $Val extends VeilidConfigNetwork> ? _value.protocol : protocol // ignore: cast_nullable_to_non_nullable as VeilidConfigProtocol, + networkKeyPassword: freezed == networkKeyPassword + ? _value.networkKeyPassword + : networkKeyPassword // ignore: cast_nullable_to_non_nullable + as String?, ) as $Val); } @@ -5250,7 +5250,6 @@ abstract class _$$_VeilidConfigNetworkCopyWith<$Res> int clientWhitelistTimeoutMs, int reverseConnectionReceiptTimeMs, int holePunchReceiptTimeMs, - String? networkKeyPassword, VeilidConfigRoutingTable routingTable, VeilidConfigRPC rpc, VeilidConfigDHT dht, @@ -5259,7 +5258,8 @@ abstract class _$$_VeilidConfigNetworkCopyWith<$Res> int restrictedNatRetries, VeilidConfigTLS tls, VeilidConfigApplication application, - VeilidConfigProtocol protocol}); + VeilidConfigProtocol protocol, + String? networkKeyPassword}); @override $VeilidConfigRoutingTableCopyWith<$Res> get routingTable; @@ -5295,7 +5295,6 @@ class __$$_VeilidConfigNetworkCopyWithImpl<$Res> Object? clientWhitelistTimeoutMs = null, Object? reverseConnectionReceiptTimeMs = null, Object? holePunchReceiptTimeMs = null, - Object? networkKeyPassword = freezed, Object? routingTable = null, Object? rpc = null, Object? dht = null, @@ -5305,6 +5304,7 @@ class __$$_VeilidConfigNetworkCopyWithImpl<$Res> Object? tls = null, Object? application = null, Object? protocol = null, + Object? networkKeyPassword = freezed, }) { return _then(_$_VeilidConfigNetwork( connectionInitialTimeoutMs: null == connectionInitialTimeoutMs @@ -5343,10 +5343,6 @@ class __$$_VeilidConfigNetworkCopyWithImpl<$Res> ? _value.holePunchReceiptTimeMs : holePunchReceiptTimeMs // ignore: cast_nullable_to_non_nullable as int, - networkKeyPassword: freezed == networkKeyPassword - ? _value.networkKeyPassword - : networkKeyPassword // ignore: cast_nullable_to_non_nullable - as String?, routingTable: null == routingTable ? _value.routingTable : routingTable // ignore: cast_nullable_to_non_nullable @@ -5383,6 +5379,10 @@ class __$$_VeilidConfigNetworkCopyWithImpl<$Res> ? _value.protocol : protocol // ignore: cast_nullable_to_non_nullable as VeilidConfigProtocol, + networkKeyPassword: freezed == networkKeyPassword + ? _value.networkKeyPassword + : networkKeyPassword // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -5402,7 +5402,6 @@ class _$_VeilidConfigNetwork required this.clientWhitelistTimeoutMs, required this.reverseConnectionReceiptTimeMs, required this.holePunchReceiptTimeMs, - this.networkKeyPassword, required this.routingTable, required this.rpc, required this.dht, @@ -5411,7 +5410,8 @@ class _$_VeilidConfigNetwork required this.restrictedNatRetries, required this.tls, required this.application, - required this.protocol}); + required this.protocol, + this.networkKeyPassword}); factory _$_VeilidConfigNetwork.fromJson(Map json) => _$$_VeilidConfigNetworkFromJson(json); @@ -5435,8 +5435,6 @@ class _$_VeilidConfigNetwork @override final int holePunchReceiptTimeMs; @override - final String? networkKeyPassword; - @override final VeilidConfigRoutingTable routingTable; @override final VeilidConfigRPC rpc; @@ -5454,10 +5452,12 @@ class _$_VeilidConfigNetwork final VeilidConfigApplication application; @override final VeilidConfigProtocol protocol; + @override + final String? networkKeyPassword; @override String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { - return 'VeilidConfigNetwork(connectionInitialTimeoutMs: $connectionInitialTimeoutMs, connectionInactivityTimeoutMs: $connectionInactivityTimeoutMs, maxConnectionsPerIp4: $maxConnectionsPerIp4, maxConnectionsPerIp6Prefix: $maxConnectionsPerIp6Prefix, maxConnectionsPerIp6PrefixSize: $maxConnectionsPerIp6PrefixSize, maxConnectionFrequencyPerMin: $maxConnectionFrequencyPerMin, clientWhitelistTimeoutMs: $clientWhitelistTimeoutMs, reverseConnectionReceiptTimeMs: $reverseConnectionReceiptTimeMs, holePunchReceiptTimeMs: $holePunchReceiptTimeMs, networkKeyPassword: $networkKeyPassword, routingTable: $routingTable, rpc: $rpc, dht: $dht, upnp: $upnp, detectAddressChanges: $detectAddressChanges, restrictedNatRetries: $restrictedNatRetries, tls: $tls, application: $application, protocol: $protocol)'; + return 'VeilidConfigNetwork(connectionInitialTimeoutMs: $connectionInitialTimeoutMs, connectionInactivityTimeoutMs: $connectionInactivityTimeoutMs, maxConnectionsPerIp4: $maxConnectionsPerIp4, maxConnectionsPerIp6Prefix: $maxConnectionsPerIp6Prefix, maxConnectionsPerIp6PrefixSize: $maxConnectionsPerIp6PrefixSize, maxConnectionFrequencyPerMin: $maxConnectionFrequencyPerMin, clientWhitelistTimeoutMs: $clientWhitelistTimeoutMs, reverseConnectionReceiptTimeMs: $reverseConnectionReceiptTimeMs, holePunchReceiptTimeMs: $holePunchReceiptTimeMs, routingTable: $routingTable, rpc: $rpc, dht: $dht, upnp: $upnp, detectAddressChanges: $detectAddressChanges, restrictedNatRetries: $restrictedNatRetries, tls: $tls, application: $application, protocol: $protocol, networkKeyPassword: $networkKeyPassword)'; } @override @@ -5482,7 +5482,6 @@ class _$_VeilidConfigNetwork 'reverseConnectionReceiptTimeMs', reverseConnectionReceiptTimeMs)) ..add( DiagnosticsProperty('holePunchReceiptTimeMs', holePunchReceiptTimeMs)) - ..add(DiagnosticsProperty('networkKeyPassword', networkKeyPassword)) ..add(DiagnosticsProperty('routingTable', routingTable)) ..add(DiagnosticsProperty('rpc', rpc)) ..add(DiagnosticsProperty('dht', dht)) @@ -5491,7 +5490,8 @@ class _$_VeilidConfigNetwork ..add(DiagnosticsProperty('restrictedNatRetries', restrictedNatRetries)) ..add(DiagnosticsProperty('tls', tls)) ..add(DiagnosticsProperty('application', application)) - ..add(DiagnosticsProperty('protocol', protocol)); + ..add(DiagnosticsProperty('protocol', protocol)) + ..add(DiagnosticsProperty('networkKeyPassword', networkKeyPassword)); } @override @@ -5524,8 +5524,6 @@ class _$_VeilidConfigNetwork reverseConnectionReceiptTimeMs) && (identical(other.holePunchReceiptTimeMs, holePunchReceiptTimeMs) || other.holePunchReceiptTimeMs == holePunchReceiptTimeMs) && - (identical(other.networkKeyPassword, networkKeyPassword) || - other.networkKeyPassword == networkKeyPassword) && (identical(other.routingTable, routingTable) || other.routingTable == routingTable) && (identical(other.rpc, rpc) || other.rpc == rpc) && @@ -5539,7 +5537,9 @@ class _$_VeilidConfigNetwork (identical(other.application, application) || other.application == application) && (identical(other.protocol, protocol) || - other.protocol == protocol)); + other.protocol == protocol) && + (identical(other.networkKeyPassword, networkKeyPassword) || + other.networkKeyPassword == networkKeyPassword)); } @JsonKey(ignore: true) @@ -5555,7 +5555,6 @@ class _$_VeilidConfigNetwork clientWhitelistTimeoutMs, reverseConnectionReceiptTimeMs, holePunchReceiptTimeMs, - networkKeyPassword, routingTable, rpc, dht, @@ -5564,7 +5563,8 @@ class _$_VeilidConfigNetwork restrictedNatRetries, tls, application, - protocol + protocol, + networkKeyPassword ]); @JsonKey(ignore: true) @@ -5593,7 +5593,6 @@ abstract class _VeilidConfigNetwork implements VeilidConfigNetwork { required final int clientWhitelistTimeoutMs, required final int reverseConnectionReceiptTimeMs, required final int holePunchReceiptTimeMs, - final String? networkKeyPassword, required final VeilidConfigRoutingTable routingTable, required final VeilidConfigRPC rpc, required final VeilidConfigDHT dht, @@ -5602,7 +5601,8 @@ abstract class _VeilidConfigNetwork implements VeilidConfigNetwork { required final int restrictedNatRetries, required final VeilidConfigTLS tls, required final VeilidConfigApplication application, - required final VeilidConfigProtocol protocol}) = _$_VeilidConfigNetwork; + required final VeilidConfigProtocol protocol, + final String? networkKeyPassword}) = _$_VeilidConfigNetwork; factory _VeilidConfigNetwork.fromJson(Map json) = _$_VeilidConfigNetwork.fromJson; @@ -5626,8 +5626,6 @@ abstract class _VeilidConfigNetwork implements VeilidConfigNetwork { @override int get holePunchReceiptTimeMs; @override - String? get networkKeyPassword; - @override VeilidConfigRoutingTable get routingTable; @override VeilidConfigRPC get rpc; @@ -5646,6 +5644,8 @@ abstract class _VeilidConfigNetwork implements VeilidConfigNetwork { @override VeilidConfigProtocol get protocol; @override + String? get networkKeyPassword; + @override @JsonKey(ignore: true) _$$_VeilidConfigNetworkCopyWith<_$_VeilidConfigNetwork> get copyWith => throw _privateConstructorUsedError; diff --git a/veilid-flutter/lib/veilid_config.g.dart b/veilid-flutter/lib/veilid_config.g.dart index fed9bae0..355367ee 100644 --- a/veilid-flutter/lib/veilid_config.g.dart +++ b/veilid-flutter/lib/veilid_config.g.dart @@ -55,12 +55,9 @@ Map _$$_VeilidFFIConfigLoggingApiToJson( _$_VeilidFFIConfigLogging _$$_VeilidFFIConfigLoggingFromJson( Map json) => _$_VeilidFFIConfigLogging( - terminal: VeilidFFIConfigLoggingTerminal.fromJson( - json['terminal'] as Map), - otlp: VeilidFFIConfigLoggingOtlp.fromJson( - json['otlp'] as Map), - api: VeilidFFIConfigLoggingApi.fromJson( - json['api'] as Map), + terminal: VeilidFFIConfigLoggingTerminal.fromJson(json['terminal']), + otlp: VeilidFFIConfigLoggingOtlp.fromJson(json['otlp']), + api: VeilidFFIConfigLoggingApi.fromJson(json['api']), ); Map _$$_VeilidFFIConfigLoggingToJson( @@ -73,8 +70,7 @@ Map _$$_VeilidFFIConfigLoggingToJson( _$_VeilidFFIConfig _$$_VeilidFFIConfigFromJson(Map json) => _$_VeilidFFIConfig( - logging: VeilidFFIConfigLogging.fromJson( - json['logging'] as Map), + logging: VeilidFFIConfigLogging.fromJson(json['logging']), ); Map _$$_VeilidFFIConfigToJson(_$_VeilidFFIConfig instance) => @@ -117,10 +113,9 @@ Map _$$_VeilidWASMConfigLoggingApiToJson( _$_VeilidWASMConfigLogging _$$_VeilidWASMConfigLoggingFromJson( Map json) => _$_VeilidWASMConfigLogging( - performance: VeilidWASMConfigLoggingPerformance.fromJson( - json['performance'] as Map), - api: VeilidWASMConfigLoggingApi.fromJson( - json['api'] as Map), + performance: + VeilidWASMConfigLoggingPerformance.fromJson(json['performance']), + api: VeilidWASMConfigLoggingApi.fromJson(json['api']), ); Map _$$_VeilidWASMConfigLoggingToJson( @@ -132,8 +127,7 @@ Map _$$_VeilidWASMConfigLoggingToJson( _$_VeilidWASMConfig _$$_VeilidWASMConfigFromJson(Map json) => _$_VeilidWASMConfig( - logging: VeilidWASMConfigLogging.fromJson( - json['logging'] as Map), + logging: VeilidWASMConfigLogging.fromJson(json['logging']), ); Map _$$_VeilidWASMConfigToJson(_$_VeilidWASMConfig instance) => @@ -177,8 +171,8 @@ Map _$$_VeilidConfigHTTPToJson(_$_VeilidConfigHTTP instance) => _$_VeilidConfigApplication _$$_VeilidConfigApplicationFromJson( Map json) => _$_VeilidConfigApplication( - https: VeilidConfigHTTPS.fromJson(json['https'] as Map), - http: VeilidConfigHTTP.fromJson(json['http'] as Map), + https: VeilidConfigHTTPS.fromJson(json['https']), + http: VeilidConfigHTTP.fromJson(json['http']), ); Map _$$_VeilidConfigApplicationToJson( @@ -265,10 +259,10 @@ Map _$$_VeilidConfigWSSToJson(_$_VeilidConfigWSS instance) => _$_VeilidConfigProtocol _$$_VeilidConfigProtocolFromJson( Map json) => _$_VeilidConfigProtocol( - udp: VeilidConfigUDP.fromJson(json['udp'] as Map), - tcp: VeilidConfigTCP.fromJson(json['tcp'] as Map), - ws: VeilidConfigWS.fromJson(json['ws'] as Map), - wss: VeilidConfigWSS.fromJson(json['wss'] as Map), + udp: VeilidConfigUDP.fromJson(json['udp']), + tcp: VeilidConfigTCP.fromJson(json['tcp']), + ws: VeilidConfigWS.fromJson(json['ws']), + wss: VeilidConfigWSS.fromJson(json['wss']), ); Map _$$_VeilidConfigProtocolToJson( @@ -349,22 +343,22 @@ _$_VeilidConfigRPC _$$_VeilidConfigRPCFromJson(Map json) => _$_VeilidConfigRPC( concurrency: json['concurrency'] as int, queueSize: json['queue_size'] as int, - maxTimestampBehindMs: json['max_timestamp_behind_ms'] as int?, - maxTimestampAheadMs: json['max_timestamp_ahead_ms'] as int?, timeoutMs: json['timeout_ms'] as int, maxRouteHopCount: json['max_route_hop_count'] as int, defaultRouteHopCount: json['default_route_hop_count'] as int, + maxTimestampBehindMs: json['max_timestamp_behind_ms'] as int?, + maxTimestampAheadMs: json['max_timestamp_ahead_ms'] as int?, ); Map _$$_VeilidConfigRPCToJson(_$_VeilidConfigRPC instance) => { 'concurrency': instance.concurrency, 'queue_size': instance.queueSize, - 'max_timestamp_behind_ms': instance.maxTimestampBehindMs, - 'max_timestamp_ahead_ms': instance.maxTimestampAheadMs, 'timeout_ms': instance.timeoutMs, 'max_route_hop_count': instance.maxRouteHopCount, 'default_route_hop_count': instance.defaultRouteHopCount, + 'max_timestamp_behind_ms': instance.maxTimestampBehindMs, + 'max_timestamp_ahead_ms': instance.maxTimestampAheadMs, }; _$_VeilidConfigRoutingTable _$$_VeilidConfigRoutingTableFromJson( @@ -414,19 +408,16 @@ _$_VeilidConfigNetwork _$$_VeilidConfigNetworkFromJson( reverseConnectionReceiptTimeMs: json['reverse_connection_receipt_time_ms'] as int, holePunchReceiptTimeMs: json['hole_punch_receipt_time_ms'] as int, - networkKeyPassword: json['network_key_password'] as String?, - routingTable: VeilidConfigRoutingTable.fromJson( - json['routing_table'] as Map), - rpc: VeilidConfigRPC.fromJson(json['rpc'] as Map), - dht: VeilidConfigDHT.fromJson(json['dht'] as Map), + routingTable: VeilidConfigRoutingTable.fromJson(json['routing_table']), + rpc: VeilidConfigRPC.fromJson(json['rpc']), + dht: VeilidConfigDHT.fromJson(json['dht']), upnp: json['upnp'] as bool, detectAddressChanges: json['detect_address_changes'] as bool, restrictedNatRetries: json['restricted_nat_retries'] as int, - tls: VeilidConfigTLS.fromJson(json['tls'] as Map), - application: VeilidConfigApplication.fromJson( - json['application'] as Map), - protocol: VeilidConfigProtocol.fromJson( - json['protocol'] as Map), + tls: VeilidConfigTLS.fromJson(json['tls']), + application: VeilidConfigApplication.fromJson(json['application']), + protocol: VeilidConfigProtocol.fromJson(json['protocol']), + networkKeyPassword: json['network_key_password'] as String?, ); Map _$$_VeilidConfigNetworkToJson( @@ -444,7 +435,6 @@ Map _$$_VeilidConfigNetworkToJson( 'reverse_connection_receipt_time_ms': instance.reverseConnectionReceiptTimeMs, 'hole_punch_receipt_time_ms': instance.holePunchReceiptTimeMs, - 'network_key_password': instance.networkKeyPassword, 'routing_table': instance.routingTable.toJson(), 'rpc': instance.rpc.toJson(), 'dht': instance.dht.toJson(), @@ -454,6 +444,7 @@ Map _$$_VeilidConfigNetworkToJson( 'tls': instance.tls.toJson(), 'application': instance.application.toJson(), 'protocol': instance.protocol.toJson(), + 'network_key_password': instance.networkKeyPassword, }; _$_VeilidConfigTableStore _$$_VeilidConfigTableStoreFromJson( @@ -526,16 +517,12 @@ _$_VeilidConfig _$$_VeilidConfigFromJson(Map json) => _$_VeilidConfig( programName: json['program_name'] as String, namespace: json['namespace'] as String, - capabilities: VeilidConfigCapabilities.fromJson( - json['capabilities'] as Map), - protectedStore: VeilidConfigProtectedStore.fromJson( - json['protected_store'] as Map), - tableStore: VeilidConfigTableStore.fromJson( - json['table_store'] as Map), - blockStore: VeilidConfigBlockStore.fromJson( - json['block_store'] as Map), - network: - VeilidConfigNetwork.fromJson(json['network'] as Map), + capabilities: VeilidConfigCapabilities.fromJson(json['capabilities']), + protectedStore: + VeilidConfigProtectedStore.fromJson(json['protected_store']), + tableStore: VeilidConfigTableStore.fromJson(json['table_store']), + blockStore: VeilidConfigBlockStore.fromJson(json['block_store']), + network: VeilidConfigNetwork.fromJson(json['network']), ); Map _$$_VeilidConfigToJson(_$_VeilidConfig instance) => diff --git a/veilid-flutter/lib/veilid_crypto.dart b/veilid-flutter/lib/veilid_crypto.dart index 97686ec7..21050517 100644 --- a/veilid-flutter/lib/veilid_crypto.dart +++ b/veilid-flutter/lib/veilid_crypto.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:convert'; import 'dart:typed_data'; import 'package:charcode/charcode.dart'; @@ -184,4 +185,49 @@ abstract class VeilidCryptoSystem { SharedSecret sharedSecret, Uint8List? associatedData); Future cryptNoAuth( Uint8List body, Nonce nonce, SharedSecret sharedSecret); + + Future encryptNoAuthWithNonce( + Uint8List body, SharedSecret secret) async { + // generate nonce + final nonce = await randomNonce(); + // crypt and append nonce + final b = BytesBuilder() + ..add(await cryptNoAuth(body, nonce, secret)) + ..add(nonce.decode()); + return b.toBytes(); + } + + Future decryptNoAuthWithNonce( + Uint8List body, SharedSecret secret) async { + if (body.length <= Nonce.decodedLength()) { + throw const FormatException('not enough data to decrypt'); + } + final nonce = + Nonce.fromBytes(body.sublist(body.length - Nonce.decodedLength())); + final encryptedData = body.sublist(0, body.length - Nonce.decodedLength()); + // decrypt + return cryptNoAuth(encryptedData, nonce, secret); + } + + Future encryptNoAuthWithPassword( + Uint8List body, String password) async { + final ekbytes = Uint8List.fromList(utf8.encode(password)); + final nonce = await randomNonce(); + final saltBytes = nonce.decode(); + final sharedSecret = await deriveSharedSecret(ekbytes, saltBytes); + return (await cryptNoAuth(body, nonce, sharedSecret))..addAll(saltBytes); + } + + Future decryptNoAuthWithPassword( + Uint8List body, String password) async { + if (body.length <= Nonce.decodedLength()) { + throw const FormatException('not enough data to decrypt'); + } + final ekbytes = Uint8List.fromList(utf8.encode(password)); + final bodyBytes = body.sublist(0, body.length - Nonce.decodedLength()); + final saltBytes = body.sublist(body.length - Nonce.decodedLength()); + final nonce = Nonce.fromBytes(saltBytes); + final sharedSecret = await deriveSharedSecret(ekbytes, saltBytes); + return cryptNoAuth(bodyBytes, nonce, sharedSecret); + } } diff --git a/veilid-flutter/lib/veilid_state.freezed.dart b/veilid-flutter/lib/veilid_state.freezed.dart index 6e7bf3f3..ca6d13af 100644 --- a/veilid-flutter/lib/veilid_state.freezed.dart +++ b/veilid-flutter/lib/veilid_state.freezed.dart @@ -866,8 +866,8 @@ PeerStats _$PeerStatsFromJson(Map json) { mixin _$PeerStats { Timestamp get timeAdded => throw _privateConstructorUsedError; RPCStats get rpcStats => throw _privateConstructorUsedError; - LatencyStats? get latency => throw _privateConstructorUsedError; TransferStatsDownUp get transfer => throw _privateConstructorUsedError; + LatencyStats? get latency => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -883,12 +883,12 @@ abstract class $PeerStatsCopyWith<$Res> { $Res call( {Timestamp timeAdded, RPCStats rpcStats, - LatencyStats? latency, - TransferStatsDownUp transfer}); + TransferStatsDownUp transfer, + LatencyStats? latency}); $RPCStatsCopyWith<$Res> get rpcStats; - $LatencyStatsCopyWith<$Res>? get latency; $TransferStatsDownUpCopyWith<$Res> get transfer; + $LatencyStatsCopyWith<$Res>? get latency; } /// @nodoc @@ -906,8 +906,8 @@ class _$PeerStatsCopyWithImpl<$Res, $Val extends PeerStats> $Res call({ Object? timeAdded = null, Object? rpcStats = null, - Object? latency = freezed, Object? transfer = null, + Object? latency = freezed, }) { return _then(_value.copyWith( timeAdded: null == timeAdded @@ -918,14 +918,14 @@ class _$PeerStatsCopyWithImpl<$Res, $Val extends PeerStats> ? _value.rpcStats : rpcStats // ignore: cast_nullable_to_non_nullable as RPCStats, - latency: freezed == latency - ? _value.latency - : latency // ignore: cast_nullable_to_non_nullable - as LatencyStats?, transfer: null == transfer ? _value.transfer : transfer // ignore: cast_nullable_to_non_nullable as TransferStatsDownUp, + latency: freezed == latency + ? _value.latency + : latency // ignore: cast_nullable_to_non_nullable + as LatencyStats?, ) as $Val); } @@ -937,6 +937,14 @@ class _$PeerStatsCopyWithImpl<$Res, $Val extends PeerStats> }); } + @override + @pragma('vm:prefer-inline') + $TransferStatsDownUpCopyWith<$Res> get transfer { + return $TransferStatsDownUpCopyWith<$Res>(_value.transfer, (value) { + return _then(_value.copyWith(transfer: value) as $Val); + }); + } + @override @pragma('vm:prefer-inline') $LatencyStatsCopyWith<$Res>? get latency { @@ -948,14 +956,6 @@ class _$PeerStatsCopyWithImpl<$Res, $Val extends PeerStats> return _then(_value.copyWith(latency: value) as $Val); }); } - - @override - @pragma('vm:prefer-inline') - $TransferStatsDownUpCopyWith<$Res> get transfer { - return $TransferStatsDownUpCopyWith<$Res>(_value.transfer, (value) { - return _then(_value.copyWith(transfer: value) as $Val); - }); - } } /// @nodoc @@ -968,15 +968,15 @@ abstract class _$$_PeerStatsCopyWith<$Res> implements $PeerStatsCopyWith<$Res> { $Res call( {Timestamp timeAdded, RPCStats rpcStats, - LatencyStats? latency, - TransferStatsDownUp transfer}); + TransferStatsDownUp transfer, + LatencyStats? latency}); @override $RPCStatsCopyWith<$Res> get rpcStats; @override - $LatencyStatsCopyWith<$Res>? get latency; - @override $TransferStatsDownUpCopyWith<$Res> get transfer; + @override + $LatencyStatsCopyWith<$Res>? get latency; } /// @nodoc @@ -992,8 +992,8 @@ class __$$_PeerStatsCopyWithImpl<$Res> $Res call({ Object? timeAdded = null, Object? rpcStats = null, - Object? latency = freezed, Object? transfer = null, + Object? latency = freezed, }) { return _then(_$_PeerStats( timeAdded: null == timeAdded @@ -1004,14 +1004,14 @@ class __$$_PeerStatsCopyWithImpl<$Res> ? _value.rpcStats : rpcStats // ignore: cast_nullable_to_non_nullable as RPCStats, - latency: freezed == latency - ? _value.latency - : latency // ignore: cast_nullable_to_non_nullable - as LatencyStats?, transfer: null == transfer ? _value.transfer : transfer // ignore: cast_nullable_to_non_nullable as TransferStatsDownUp, + latency: freezed == latency + ? _value.latency + : latency // ignore: cast_nullable_to_non_nullable + as LatencyStats?, )); } } @@ -1022,8 +1022,8 @@ class _$_PeerStats implements _PeerStats { const _$_PeerStats( {required this.timeAdded, required this.rpcStats, - this.latency, - required this.transfer}); + required this.transfer, + this.latency}); factory _$_PeerStats.fromJson(Map json) => _$$_PeerStatsFromJson(json); @@ -1033,13 +1033,13 @@ class _$_PeerStats implements _PeerStats { @override final RPCStats rpcStats; @override - final LatencyStats? latency; - @override final TransferStatsDownUp transfer; + @override + final LatencyStats? latency; @override String toString() { - return 'PeerStats(timeAdded: $timeAdded, rpcStats: $rpcStats, latency: $latency, transfer: $transfer)'; + return 'PeerStats(timeAdded: $timeAdded, rpcStats: $rpcStats, transfer: $transfer, latency: $latency)'; } @override @@ -1051,15 +1051,15 @@ class _$_PeerStats implements _PeerStats { other.timeAdded == timeAdded) && (identical(other.rpcStats, rpcStats) || other.rpcStats == rpcStats) && - (identical(other.latency, latency) || other.latency == latency) && (identical(other.transfer, transfer) || - other.transfer == transfer)); + other.transfer == transfer) && + (identical(other.latency, latency) || other.latency == latency)); } @JsonKey(ignore: true) @override int get hashCode => - Object.hash(runtimeType, timeAdded, rpcStats, latency, transfer); + Object.hash(runtimeType, timeAdded, rpcStats, transfer, latency); @JsonKey(ignore: true) @override @@ -1079,8 +1079,8 @@ abstract class _PeerStats implements PeerStats { const factory _PeerStats( {required final Timestamp timeAdded, required final RPCStats rpcStats, - final LatencyStats? latency, - required final TransferStatsDownUp transfer}) = _$_PeerStats; + required final TransferStatsDownUp transfer, + final LatencyStats? latency}) = _$_PeerStats; factory _PeerStats.fromJson(Map json) = _$_PeerStats.fromJson; @@ -1090,10 +1090,10 @@ abstract class _PeerStats implements PeerStats { @override RPCStats get rpcStats; @override - LatencyStats? get latency; - @override TransferStatsDownUp get transfer; @override + LatencyStats? get latency; + @override @JsonKey(ignore: true) _$$_PeerStatsCopyWith<_$_PeerStats> get copyWith => throw _privateConstructorUsedError; @@ -1335,11 +1335,11 @@ mixin _$VeilidUpdate { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -1361,11 +1361,11 @@ mixin _$VeilidUpdate { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -1386,11 +1386,11 @@ mixin _$VeilidUpdate { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -1562,11 +1562,11 @@ class _$VeilidLog implements VeilidLog { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -1591,11 +1591,11 @@ class _$VeilidLog implements VeilidLog { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -1619,11 +1619,11 @@ class _$VeilidLog implements VeilidLog { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -1725,8 +1725,8 @@ abstract class _$$VeilidAppMessageCopyWith<$Res> { __$$VeilidAppMessageCopyWithImpl<$Res>; @useResult $Res call( - {Typed? sender, - @Uint8ListJsonConverter() Uint8List message}); + {@Uint8ListJsonConverter() Uint8List message, + Typed? sender}); } /// @nodoc @@ -1740,18 +1740,18 @@ class __$$VeilidAppMessageCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? sender = freezed, Object? message = null, + Object? sender = freezed, }) { return _then(_$VeilidAppMessage( - sender: freezed == sender - ? _value.sender - : sender // ignore: cast_nullable_to_non_nullable - as Typed?, message: null == message ? _value.message : message // ignore: cast_nullable_to_non_nullable as Uint8List, + sender: freezed == sender + ? _value.sender + : sender // ignore: cast_nullable_to_non_nullable + as Typed?, )); } } @@ -1760,26 +1760,26 @@ class __$$VeilidAppMessageCopyWithImpl<$Res> @JsonSerializable() class _$VeilidAppMessage implements VeilidAppMessage { const _$VeilidAppMessage( - {this.sender, - @Uint8ListJsonConverter() required this.message, + {@Uint8ListJsonConverter() required this.message, + this.sender, final String? $type}) : $type = $type ?? 'AppMessage'; factory _$VeilidAppMessage.fromJson(Map json) => _$$VeilidAppMessageFromJson(json); - @override - final Typed? sender; @override @Uint8ListJsonConverter() final Uint8List message; + @override + final Typed? sender; @JsonKey(name: 'kind') final String $type; @override String toString() { - return 'VeilidUpdate.appMessage(sender: $sender, message: $message)'; + return 'VeilidUpdate.appMessage(message: $message, sender: $sender)'; } @override @@ -1787,14 +1787,14 @@ class _$VeilidAppMessage implements VeilidAppMessage { return identical(this, other) || (other.runtimeType == runtimeType && other is _$VeilidAppMessage && - (identical(other.sender, sender) || other.sender == sender) && - const DeepCollectionEquality().equals(other.message, message)); + const DeepCollectionEquality().equals(other.message, message) && + (identical(other.sender, sender) || other.sender == sender)); } @JsonKey(ignore: true) @override int get hashCode => Object.hash( - runtimeType, sender, const DeepCollectionEquality().hash(message)); + runtimeType, const DeepCollectionEquality().hash(message), sender); @JsonKey(ignore: true) @override @@ -1808,11 +1808,11 @@ class _$VeilidAppMessage implements VeilidAppMessage { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -1828,7 +1828,7 @@ class _$VeilidAppMessage implements VeilidAppMessage { List subkeys, int count, ValueData valueData) valueChange, }) { - return appMessage(sender, message); + return appMessage(message, sender); } @override @@ -1837,11 +1837,11 @@ class _$VeilidAppMessage implements VeilidAppMessage { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -1856,7 +1856,7 @@ class _$VeilidAppMessage implements VeilidAppMessage { List subkeys, int count, ValueData valueData)? valueChange, }) { - return appMessage?.call(sender, message); + return appMessage?.call(message, sender); } @override @@ -1865,11 +1865,11 @@ class _$VeilidAppMessage implements VeilidAppMessage { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -1886,7 +1886,7 @@ class _$VeilidAppMessage implements VeilidAppMessage { required TResult orElse(), }) { if (appMessage != null) { - return appMessage(sender, message); + return appMessage(message, sender); } return orElse(); } @@ -1950,16 +1950,15 @@ class _$VeilidAppMessage implements VeilidAppMessage { abstract class VeilidAppMessage implements VeilidUpdate { const factory VeilidAppMessage( - {final Typed? sender, - @Uint8ListJsonConverter() required final Uint8List message}) = - _$VeilidAppMessage; + {@Uint8ListJsonConverter() required final Uint8List message, + final Typed? sender}) = _$VeilidAppMessage; factory VeilidAppMessage.fromJson(Map json) = _$VeilidAppMessage.fromJson; - Typed? get sender; @Uint8ListJsonConverter() Uint8List get message; + Typed? get sender; @JsonKey(ignore: true) _$$VeilidAppMessageCopyWith<_$VeilidAppMessage> get copyWith => throw _privateConstructorUsedError; @@ -1972,9 +1971,9 @@ abstract class _$$VeilidAppCallCopyWith<$Res> { __$$VeilidAppCallCopyWithImpl<$Res>; @useResult $Res call( - {Typed? sender, - @Uint8ListJsonConverter() Uint8List message, - String callId}); + {@Uint8ListJsonConverter() Uint8List message, + String callId, + Typed? sender}); } /// @nodoc @@ -1988,15 +1987,11 @@ class __$$VeilidAppCallCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? sender = freezed, Object? message = null, Object? callId = null, + Object? sender = freezed, }) { return _then(_$VeilidAppCall( - sender: freezed == sender - ? _value.sender - : sender // ignore: cast_nullable_to_non_nullable - as Typed?, message: null == message ? _value.message : message // ignore: cast_nullable_to_non_nullable @@ -2005,6 +2000,10 @@ class __$$VeilidAppCallCopyWithImpl<$Res> ? _value.callId : callId // ignore: cast_nullable_to_non_nullable as String, + sender: freezed == sender + ? _value.sender + : sender // ignore: cast_nullable_to_non_nullable + as Typed?, )); } } @@ -2013,29 +2012,29 @@ class __$$VeilidAppCallCopyWithImpl<$Res> @JsonSerializable() class _$VeilidAppCall implements VeilidAppCall { const _$VeilidAppCall( - {this.sender, - @Uint8ListJsonConverter() required this.message, + {@Uint8ListJsonConverter() required this.message, required this.callId, + this.sender, final String? $type}) : $type = $type ?? 'AppCall'; factory _$VeilidAppCall.fromJson(Map json) => _$$VeilidAppCallFromJson(json); - @override - final Typed? sender; @override @Uint8ListJsonConverter() final Uint8List message; @override final String callId; + @override + final Typed? sender; @JsonKey(name: 'kind') final String $type; @override String toString() { - return 'VeilidUpdate.appCall(sender: $sender, message: $message, callId: $callId)'; + return 'VeilidUpdate.appCall(message: $message, callId: $callId, sender: $sender)'; } @override @@ -2043,15 +2042,15 @@ class _$VeilidAppCall implements VeilidAppCall { return identical(this, other) || (other.runtimeType == runtimeType && other is _$VeilidAppCall && - (identical(other.sender, sender) || other.sender == sender) && const DeepCollectionEquality().equals(other.message, message) && - (identical(other.callId, callId) || other.callId == callId)); + (identical(other.callId, callId) || other.callId == callId) && + (identical(other.sender, sender) || other.sender == sender)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, sender, - const DeepCollectionEquality().hash(message), callId); + int get hashCode => Object.hash(runtimeType, + const DeepCollectionEquality().hash(message), callId, sender); @JsonKey(ignore: true) @override @@ -2065,11 +2064,11 @@ class _$VeilidAppCall implements VeilidAppCall { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -2085,7 +2084,7 @@ class _$VeilidAppCall implements VeilidAppCall { List subkeys, int count, ValueData valueData) valueChange, }) { - return appCall(sender, message, callId); + return appCall(message, callId, sender); } @override @@ -2094,11 +2093,11 @@ class _$VeilidAppCall implements VeilidAppCall { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -2113,7 +2112,7 @@ class _$VeilidAppCall implements VeilidAppCall { List subkeys, int count, ValueData valueData)? valueChange, }) { - return appCall?.call(sender, message, callId); + return appCall?.call(message, callId, sender); } @override @@ -2122,11 +2121,11 @@ class _$VeilidAppCall implements VeilidAppCall { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -2143,7 +2142,7 @@ class _$VeilidAppCall implements VeilidAppCall { required TResult orElse(), }) { if (appCall != null) { - return appCall(sender, message, callId); + return appCall(message, callId, sender); } return orElse(); } @@ -2207,17 +2206,17 @@ class _$VeilidAppCall implements VeilidAppCall { abstract class VeilidAppCall implements VeilidUpdate { const factory VeilidAppCall( - {final Typed? sender, - @Uint8ListJsonConverter() required final Uint8List message, - required final String callId}) = _$VeilidAppCall; + {@Uint8ListJsonConverter() required final Uint8List message, + required final String callId, + final Typed? sender}) = _$VeilidAppCall; factory VeilidAppCall.fromJson(Map json) = _$VeilidAppCall.fromJson; - Typed? get sender; @Uint8ListJsonConverter() Uint8List get message; String get callId; + Typed? get sender; @JsonKey(ignore: true) _$$VeilidAppCallCopyWith<_$VeilidAppCall> get copyWith => throw _privateConstructorUsedError; @@ -2325,11 +2324,11 @@ class _$VeilidUpdateAttachment implements VeilidUpdateAttachment { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -2354,11 +2353,11 @@ class _$VeilidUpdateAttachment implements VeilidUpdateAttachment { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -2382,11 +2381,11 @@ class _$VeilidUpdateAttachment implements VeilidUpdateAttachment { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -2595,11 +2594,11 @@ class _$VeilidUpdateNetwork implements VeilidUpdateNetwork { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -2624,11 +2623,11 @@ class _$VeilidUpdateNetwork implements VeilidUpdateNetwork { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -2652,11 +2651,11 @@ class _$VeilidUpdateNetwork implements VeilidUpdateNetwork { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -2840,11 +2839,11 @@ class _$VeilidUpdateConfig implements VeilidUpdateConfig { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -2869,11 +2868,11 @@ class _$VeilidUpdateConfig implements VeilidUpdateConfig { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -2897,11 +2896,11 @@ class _$VeilidUpdateConfig implements VeilidUpdateConfig { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -3099,11 +3098,11 @@ class _$VeilidUpdateRouteChange implements VeilidUpdateRouteChange { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -3128,11 +3127,11 @@ class _$VeilidUpdateRouteChange implements VeilidUpdateRouteChange { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -3156,11 +3155,11 @@ class _$VeilidUpdateRouteChange implements VeilidUpdateRouteChange { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -3383,11 +3382,11 @@ class _$VeilidUpdateValueChange implements VeilidUpdateValueChange { required TResult Function( VeilidLogLevel logLevel, String message, String? backtrace) log, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender) appMessage, - required TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId) + required TResult Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender) appCall, required TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady) @@ -3412,11 +3411,11 @@ class _$VeilidUpdateValueChange implements VeilidUpdateValueChange { TResult? Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult? Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult? Function(@Uint8ListJsonConverter() Uint8List message, + String callId, Typed? sender)? appCall, TResult? Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? @@ -3440,11 +3439,11 @@ class _$VeilidUpdateValueChange implements VeilidUpdateValueChange { TResult Function( VeilidLogLevel logLevel, String message, String? backtrace)? log, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, + Typed? sender)? appMessage, - TResult Function(Typed? sender, - @Uint8ListJsonConverter() Uint8List message, String callId)? + TResult Function(@Uint8ListJsonConverter() Uint8List message, String callId, + Typed? sender)? appCall, TResult Function(AttachmentState state, bool publicInternetReady, bool localNetworkReady)? diff --git a/veilid-flutter/lib/veilid_state.g.dart b/veilid-flutter/lib/veilid_state.g.dart index 9acc648d..d3797e28 100644 --- a/veilid-flutter/lib/veilid_state.g.dart +++ b/veilid-flutter/lib/veilid_state.g.dart @@ -39,8 +39,8 @@ Map _$$_TransferStatsToJson(_$_TransferStats instance) => _$_TransferStatsDownUp _$$_TransferStatsDownUpFromJson( Map json) => _$_TransferStatsDownUp( - down: TransferStats.fromJson(json['down'] as Map), - up: TransferStats.fromJson(json['up'] as Map), + down: TransferStats.fromJson(json['down']), + up: TransferStats.fromJson(json['up']), ); Map _$$_TransferStatsDownUpToJson( @@ -81,20 +81,19 @@ Map _$$_RPCStatsToJson(_$_RPCStats instance) => _$_PeerStats _$$_PeerStatsFromJson(Map json) => _$_PeerStats( timeAdded: Timestamp.fromJson(json['time_added']), - rpcStats: RPCStats.fromJson(json['rpc_stats'] as Map), + rpcStats: RPCStats.fromJson(json['rpc_stats']), + transfer: TransferStatsDownUp.fromJson(json['transfer']), latency: json['latency'] == null ? null - : LatencyStats.fromJson(json['latency'] as Map), - transfer: TransferStatsDownUp.fromJson( - json['transfer'] as Map), + : LatencyStats.fromJson(json['latency']), ); Map _$$_PeerStatsToJson(_$_PeerStats instance) => { 'time_added': instance.timeAdded.toJson(), 'rpc_stats': instance.rpcStats.toJson(), - 'latency': instance.latency?.toJson(), 'transfer': instance.transfer.toJson(), + 'latency': instance.latency?.toJson(), }; _$_PeerTableData _$$_PeerTableDataFromJson(Map json) => @@ -103,7 +102,7 @@ _$_PeerTableData _$$_PeerTableDataFromJson(Map json) => .map(Typed.fromJson) .toList(), peerAddress: json['peer_address'] as String, - peerStats: PeerStats.fromJson(json['peer_stats'] as Map), + peerStats: PeerStats.fromJson(json['peer_stats']), ); Map _$$_PeerTableDataToJson(_$_PeerTableData instance) => @@ -114,7 +113,7 @@ Map _$$_PeerTableDataToJson(_$_PeerTableData instance) => }; _$VeilidLog _$$VeilidLogFromJson(Map json) => _$VeilidLog( - logLevel: VeilidLogLevel.fromJson(json['log_level'] as String), + logLevel: VeilidLogLevel.fromJson(json['log_level']), message: json['message'] as String, backtrace: json['backtrace'] as String?, $type: json['kind'] as String?, @@ -130,44 +129,44 @@ Map _$$VeilidLogToJson(_$VeilidLog instance) => _$VeilidAppMessage _$$VeilidAppMessageFromJson(Map json) => _$VeilidAppMessage( + message: + const Uint8ListJsonConverter().fromJson(json['message'] as String), sender: json['sender'] == null ? null : Typed.fromJson(json['sender']), - message: - const Uint8ListJsonConverter().fromJson(json['message'] as String), $type: json['kind'] as String?, ); Map _$$VeilidAppMessageToJson(_$VeilidAppMessage instance) => { - 'sender': instance.sender?.toJson(), 'message': const Uint8ListJsonConverter().toJson(instance.message), + 'sender': instance.sender?.toJson(), 'kind': instance.$type, }; _$VeilidAppCall _$$VeilidAppCallFromJson(Map json) => _$VeilidAppCall( - sender: json['sender'] == null - ? null - : Typed.fromJson(json['sender']), message: const Uint8ListJsonConverter().fromJson(json['message'] as String), callId: json['call_id'] as String, + sender: json['sender'] == null + ? null + : Typed.fromJson(json['sender']), $type: json['kind'] as String?, ); Map _$$VeilidAppCallToJson(_$VeilidAppCall instance) => { - 'sender': instance.sender?.toJson(), 'message': const Uint8ListJsonConverter().toJson(instance.message), 'call_id': instance.callId, + 'sender': instance.sender?.toJson(), 'kind': instance.$type, }; _$VeilidUpdateAttachment _$$VeilidUpdateAttachmentFromJson( Map json) => _$VeilidUpdateAttachment( - state: AttachmentState.fromJson(json['state'] as String), + state: AttachmentState.fromJson(json['state']), publicInternetReady: json['public_internet_ready'] as bool, localNetworkReady: json['local_network_ready'] as bool, $type: json['kind'] as String?, @@ -188,9 +187,8 @@ _$VeilidUpdateNetwork _$$VeilidUpdateNetworkFromJson( started: json['started'] as bool, bpsDown: BigInt.parse(json['bps_down'] as String), bpsUp: BigInt.parse(json['bps_up'] as String), - peers: (json['peers'] as List) - .map((e) => PeerTableData.fromJson(e as Map)) - .toList(), + peers: + (json['peers'] as List).map(PeerTableData.fromJson).toList(), $type: json['kind'] as String?, ); @@ -206,7 +204,7 @@ Map _$$VeilidUpdateNetworkToJson( _$VeilidUpdateConfig _$$VeilidUpdateConfigFromJson(Map json) => _$VeilidUpdateConfig( - config: VeilidConfig.fromJson(json['config'] as Map), + config: VeilidConfig.fromJson(json['config']), $type: json['kind'] as String?, ); @@ -242,10 +240,10 @@ _$VeilidUpdateValueChange _$$VeilidUpdateValueChangeFromJson( _$VeilidUpdateValueChange( key: Typed.fromJson(json['key']), subkeys: (json['subkeys'] as List) - .map((e) => ValueSubkeyRange.fromJson(e as Map)) + .map(ValueSubkeyRange.fromJson) .toList(), count: json['count'] as int, - valueData: ValueData.fromJson(json['value_data'] as Map), + valueData: ValueData.fromJson(json['value_data']), $type: json['kind'] as String?, ); @@ -262,7 +260,7 @@ Map _$$VeilidUpdateValueChangeToJson( _$_VeilidStateAttachment _$$_VeilidStateAttachmentFromJson( Map json) => _$_VeilidStateAttachment( - state: AttachmentState.fromJson(json['state'] as String), + state: AttachmentState.fromJson(json['state']), publicInternetReady: json['public_internet_ready'] as bool, localNetworkReady: json['local_network_ready'] as bool, ); @@ -281,9 +279,8 @@ _$_VeilidStateNetwork _$$_VeilidStateNetworkFromJson( started: json['started'] as bool, bpsDown: BigInt.parse(json['bps_down'] as String), bpsUp: BigInt.parse(json['bps_up'] as String), - peers: (json['peers'] as List) - .map((e) => PeerTableData.fromJson(e as Map)) - .toList(), + peers: + (json['peers'] as List).map(PeerTableData.fromJson).toList(), ); Map _$$_VeilidStateNetworkToJson( @@ -297,7 +294,7 @@ Map _$$_VeilidStateNetworkToJson( _$_VeilidStateConfig _$$_VeilidStateConfigFromJson(Map json) => _$_VeilidStateConfig( - config: VeilidConfig.fromJson(json['config'] as Map), + config: VeilidConfig.fromJson(json['config']), ); Map _$$_VeilidStateConfigToJson( @@ -308,12 +305,9 @@ Map _$$_VeilidStateConfigToJson( _$_VeilidState _$$_VeilidStateFromJson(Map json) => _$_VeilidState( - attachment: VeilidStateAttachment.fromJson( - json['attachment'] as Map), - network: - VeilidStateNetwork.fromJson(json['network'] as Map), - config: - VeilidStateConfig.fromJson(json['config'] as Map), + attachment: VeilidStateAttachment.fromJson(json['attachment']), + network: VeilidStateNetwork.fromJson(json['network']), + config: VeilidStateConfig.fromJson(json['config']), ); Map _$$_VeilidStateToJson(_$_VeilidState instance) => diff --git a/veilid-flutter/pubspec.yaml b/veilid-flutter/pubspec.yaml index 6aa84ed0..d3dc3ab4 100644 --- a/veilid-flutter/pubspec.yaml +++ b/veilid-flutter/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: charcode: ^1.3.1 equatable: ^2.0.5 ffi: ^2.0.0 + fixnum: ^1.1.0 flutter: sdk: flutter flutter_web_plugins: