bugfixes
This commit is contained in:
@@ -5,7 +5,6 @@ import 'package:change_case/change_case.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'veilid_encoding.dart';
|
||||
import 'veilid.dart';
|
||||
|
||||
part 'routing_context.freezed.dart';
|
||||
@@ -51,8 +50,8 @@ sealed class DHTSchema with _$DHTSchema {
|
||||
{required int oCnt,
|
||||
required List<DHTSchemaMember> members}) = DHTSchemaSMPL;
|
||||
|
||||
factory DHTSchema.fromJson(Map<String, dynamic> json) =>
|
||||
_$DHTSchemaFromJson(json);
|
||||
factory DHTSchema.fromJson(dynamic json) =>
|
||||
_$DHTSchemaFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
const DHTSchema defaultDHTSchema = DHTSchema.dflt(oCnt: 1);
|
||||
@@ -65,8 +64,8 @@ class DHTSchemaMember with _$DHTSchemaMember {
|
||||
required int mCnt,
|
||||
}) = _DHTSchemaMember;
|
||||
|
||||
factory DHTSchemaMember.fromJson(Map<String, dynamic> json) =>
|
||||
_$DHTSchemaMemberFromJson(json);
|
||||
factory DHTSchemaMember.fromJson(dynamic json) =>
|
||||
_$DHTSchemaMemberFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -80,8 +79,8 @@ class DHTRecordDescriptor with _$DHTRecordDescriptor {
|
||||
PublicKey? ownerSecret,
|
||||
required DHTSchema schema,
|
||||
}) = _DHTRecordDescriptor;
|
||||
factory DHTRecordDescriptor.fromJson(Map<String, dynamic> json) =>
|
||||
_$DHTRecordDescriptorFromJson(json);
|
||||
factory DHTRecordDescriptor.fromJson(dynamic json) =>
|
||||
_$DHTRecordDescriptorFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
extension DHTRecordDescriptorExt on DHTRecordDescriptor {
|
||||
@@ -112,8 +111,8 @@ class ValueSubkeyRange with _$ValueSubkeyRange {
|
||||
required int high,
|
||||
}) = _ValueSubkeyRange;
|
||||
|
||||
factory ValueSubkeyRange.fromJson(Map<String, dynamic> json) =>
|
||||
_$ValueSubkeyRangeFromJson(json);
|
||||
factory ValueSubkeyRange.fromJson(dynamic json) =>
|
||||
_$ValueSubkeyRangeFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -128,8 +127,8 @@ class ValueData with _$ValueData {
|
||||
required PublicKey writer,
|
||||
}) = _ValueData;
|
||||
|
||||
factory ValueData.fromJson(Map<String, dynamic> json) =>
|
||||
_$ValueDataFromJson(json);
|
||||
factory ValueData.fromJson(dynamic json) =>
|
||||
_$ValueDataFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -140,8 +139,8 @@ enum Stability {
|
||||
reliable;
|
||||
|
||||
String toJson() => name.toPascalCase();
|
||||
factory Stability.fromJson(String j) =>
|
||||
Stability.values.byName(j.toCamelCase());
|
||||
factory Stability.fromJson(dynamic j) =>
|
||||
Stability.values.byName((j as String).toCamelCase());
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -153,8 +152,8 @@ enum Sequencing {
|
||||
ensureOrdered;
|
||||
|
||||
String toJson() => name.toPascalCase();
|
||||
factory Sequencing.fromJson(String j) =>
|
||||
Sequencing.values.byName(j.toCamelCase());
|
||||
factory Sequencing.fromJson(dynamic j) =>
|
||||
Sequencing.values.byName((j as String).toCamelCase());
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -162,7 +161,8 @@ enum Sequencing {
|
||||
|
||||
@immutable
|
||||
abstract class SafetySelection extends Equatable {
|
||||
factory SafetySelection.fromJson(Map<String, dynamic> json) {
|
||||
factory SafetySelection.fromJson(dynamic jsond) {
|
||||
final json = jsond as Map<String, dynamic>;
|
||||
if (json.containsKey("Unsafe")) {
|
||||
return SafetySelectionUnsafe(
|
||||
sequencing: Sequencing.fromJson(json["Unsafe"]));
|
||||
@@ -223,8 +223,8 @@ class SafetySpec with _$SafetySpec {
|
||||
required Sequencing sequencing,
|
||||
}) = _SafetySpec;
|
||||
|
||||
factory SafetySpec.fromJson(Map<String, dynamic> json) =>
|
||||
_$SafetySpecFromJson(json);
|
||||
factory SafetySpec.fromJson(dynamic json) =>
|
||||
_$SafetySpecFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -234,8 +234,8 @@ class RouteBlob with _$RouteBlob {
|
||||
const factory RouteBlob(
|
||||
{required String routeId,
|
||||
@Uint8ListJsonConverter() required Uint8List blob}) = _RouteBlob;
|
||||
factory RouteBlob.fromJson(Map<String, dynamic> json) =>
|
||||
_$RouteBlobFromJson(json);
|
||||
factory RouteBlob.fromJson(dynamic json) =>
|
||||
_$RouteBlobFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
@@ -156,7 +156,7 @@ abstract class Veilid {
|
||||
Future<void> releasePrivateRoute(String key);
|
||||
|
||||
// App calls
|
||||
Future<void> appCallReply(String id, Uint8List message);
|
||||
Future<void> appCallReply(String callId, Uint8List message);
|
||||
|
||||
// TableStore
|
||||
Future<VeilidTableDB> openTableDB(String name, int columnCount);
|
||||
|
||||
@@ -17,8 +17,8 @@ class VeilidFFIConfigLoggingTerminal with _$VeilidFFIConfigLoggingTerminal {
|
||||
required VeilidConfigLogLevel level,
|
||||
}) = _VeilidFFIConfigLoggingTerminal;
|
||||
|
||||
factory VeilidFFIConfigLoggingTerminal.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidFFIConfigLoggingTerminalFromJson(json);
|
||||
factory VeilidFFIConfigLoggingTerminal.fromJson(dynamic json) =>
|
||||
_$VeilidFFIConfigLoggingTerminalFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -30,8 +30,8 @@ class VeilidFFIConfigLoggingOtlp with _$VeilidFFIConfigLoggingOtlp {
|
||||
required String serviceName,
|
||||
}) = _VeilidFFIConfigLoggingOtlp;
|
||||
|
||||
factory VeilidFFIConfigLoggingOtlp.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidFFIConfigLoggingOtlpFromJson(json);
|
||||
factory VeilidFFIConfigLoggingOtlp.fromJson(dynamic json) =>
|
||||
_$VeilidFFIConfigLoggingOtlpFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -41,8 +41,8 @@ class VeilidFFIConfigLoggingApi with _$VeilidFFIConfigLoggingApi {
|
||||
required VeilidConfigLogLevel level,
|
||||
}) = _VeilidFFIConfigLoggingApi;
|
||||
|
||||
factory VeilidFFIConfigLoggingApi.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidFFIConfigLoggingApiFromJson(json);
|
||||
factory VeilidFFIConfigLoggingApi.fromJson(dynamic json) =>
|
||||
_$VeilidFFIConfigLoggingApiFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -52,8 +52,8 @@ class VeilidFFIConfigLogging with _$VeilidFFIConfigLogging {
|
||||
required VeilidFFIConfigLoggingOtlp otlp,
|
||||
required VeilidFFIConfigLoggingApi api}) = _VeilidFFIConfigLogging;
|
||||
|
||||
factory VeilidFFIConfigLogging.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidFFIConfigLoggingFromJson(json);
|
||||
factory VeilidFFIConfigLogging.fromJson(dynamic json) =>
|
||||
_$VeilidFFIConfigLoggingFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -62,8 +62,8 @@ class VeilidFFIConfig with _$VeilidFFIConfig {
|
||||
required VeilidFFIConfigLogging logging,
|
||||
}) = _VeilidFFIConfig;
|
||||
|
||||
factory VeilidFFIConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidFFIConfigFromJson(json);
|
||||
factory VeilidFFIConfig.fromJson(dynamic json) =>
|
||||
_$VeilidFFIConfigFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
@@ -79,9 +79,9 @@ class VeilidWASMConfigLoggingPerformance
|
||||
required bool logsInConsole,
|
||||
}) = _VeilidWASMConfigLoggingPerformance;
|
||||
|
||||
factory VeilidWASMConfigLoggingPerformance.fromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$VeilidWASMConfigLoggingPerformanceFromJson(json);
|
||||
factory VeilidWASMConfigLoggingPerformance.fromJson(dynamic json) =>
|
||||
_$VeilidWASMConfigLoggingPerformanceFromJson(
|
||||
json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -91,8 +91,8 @@ class VeilidWASMConfigLoggingApi with _$VeilidWASMConfigLoggingApi {
|
||||
required VeilidConfigLogLevel level,
|
||||
}) = _VeilidWASMConfigLoggingApi;
|
||||
|
||||
factory VeilidWASMConfigLoggingApi.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidWASMConfigLoggingApiFromJson(json);
|
||||
factory VeilidWASMConfigLoggingApi.fromJson(dynamic json) =>
|
||||
_$VeilidWASMConfigLoggingApiFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -101,8 +101,8 @@ class VeilidWASMConfigLogging with _$VeilidWASMConfigLogging {
|
||||
{required VeilidWASMConfigLoggingPerformance performance,
|
||||
required VeilidWASMConfigLoggingApi api}) = _VeilidWASMConfigLogging;
|
||||
|
||||
factory VeilidWASMConfigLogging.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidWASMConfigLoggingFromJson(json);
|
||||
factory VeilidWASMConfigLogging.fromJson(dynamic json) =>
|
||||
_$VeilidWASMConfigLoggingFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -111,8 +111,8 @@ class VeilidWASMConfig with _$VeilidWASMConfig {
|
||||
required VeilidWASMConfigLogging logging,
|
||||
}) = _VeilidWASMConfig;
|
||||
|
||||
factory VeilidWASMConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidWASMConfigFromJson(json);
|
||||
factory VeilidWASMConfig.fromJson(dynamic json) =>
|
||||
_$VeilidWASMConfigFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -147,8 +147,8 @@ class VeilidConfigHTTPS with _$VeilidConfigHTTPS {
|
||||
String? url,
|
||||
}) = _VeilidConfigHTTPS;
|
||||
|
||||
factory VeilidConfigHTTPS.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigHTTPSFromJson(json);
|
||||
factory VeilidConfigHTTPS.fromJson(dynamic json) =>
|
||||
_$VeilidConfigHTTPSFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -162,8 +162,8 @@ class VeilidConfigHTTP with _$VeilidConfigHTTP {
|
||||
String? url,
|
||||
}) = _VeilidConfigHTTP;
|
||||
|
||||
factory VeilidConfigHTTP.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigHTTPFromJson(json);
|
||||
factory VeilidConfigHTTP.fromJson(dynamic json) =>
|
||||
_$VeilidConfigHTTPFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -175,8 +175,8 @@ class VeilidConfigApplication with _$VeilidConfigApplication {
|
||||
required VeilidConfigHTTP http,
|
||||
}) = _VeilidConfigApplication;
|
||||
|
||||
factory VeilidConfigApplication.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigApplicationFromJson(json);
|
||||
factory VeilidConfigApplication.fromJson(dynamic json) =>
|
||||
_$VeilidConfigApplicationFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -188,8 +188,8 @@ class VeilidConfigUDP with _$VeilidConfigUDP {
|
||||
required String listenAddress,
|
||||
String? publicAddress}) = _VeilidConfigUDP;
|
||||
|
||||
factory VeilidConfigUDP.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigUDPFromJson(json);
|
||||
factory VeilidConfigUDP.fromJson(dynamic json) =>
|
||||
_$VeilidConfigUDPFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -202,8 +202,8 @@ class VeilidConfigTCP with _$VeilidConfigTCP {
|
||||
required String listenAddress,
|
||||
String? publicAddress}) = _VeilidConfigTCP;
|
||||
|
||||
factory VeilidConfigTCP.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigTCPFromJson(json);
|
||||
factory VeilidConfigTCP.fromJson(dynamic json) =>
|
||||
_$VeilidConfigTCPFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -217,8 +217,8 @@ class VeilidConfigWS with _$VeilidConfigWS {
|
||||
required String path,
|
||||
String? url}) = _VeilidConfigWS;
|
||||
|
||||
factory VeilidConfigWS.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigWSFromJson(json);
|
||||
factory VeilidConfigWS.fromJson(dynamic json) =>
|
||||
_$VeilidConfigWSFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -232,8 +232,8 @@ class VeilidConfigWSS with _$VeilidConfigWSS {
|
||||
required String path,
|
||||
String? url}) = _VeilidConfigWSS;
|
||||
|
||||
factory VeilidConfigWSS.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigWSSFromJson(json);
|
||||
factory VeilidConfigWSS.fromJson(dynamic json) =>
|
||||
_$VeilidConfigWSSFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -247,8 +247,8 @@ class VeilidConfigProtocol with _$VeilidConfigProtocol {
|
||||
required VeilidConfigWSS wss,
|
||||
}) = _VeilidConfigProtocol;
|
||||
|
||||
factory VeilidConfigProtocol.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigProtocolFromJson(json);
|
||||
factory VeilidConfigProtocol.fromJson(dynamic json) =>
|
||||
_$VeilidConfigProtocolFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -261,8 +261,8 @@ class VeilidConfigTLS with _$VeilidConfigTLS {
|
||||
required int connectionInitialTimeoutMs,
|
||||
}) = _VeilidConfigTLS;
|
||||
|
||||
factory VeilidConfigTLS.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigTLSFromJson(json);
|
||||
factory VeilidConfigTLS.fromJson(dynamic json) =>
|
||||
_$VeilidConfigTLSFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -289,8 +289,8 @@ class VeilidConfigDHT with _$VeilidConfigDHT {
|
||||
required int remoteMaxSubkeyCacheMemoryMb,
|
||||
required int remoteMaxStorageSpaceMb}) = _VeilidConfigDHT;
|
||||
|
||||
factory VeilidConfigDHT.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigDHTFromJson(json);
|
||||
factory VeilidConfigDHT.fromJson(dynamic json) =>
|
||||
_$VeilidConfigDHTFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -306,8 +306,8 @@ class VeilidConfigRPC with _$VeilidConfigRPC {
|
||||
required int maxRouteHopCount,
|
||||
required int defaultRouteHopCount}) = _VeilidConfigRPC;
|
||||
|
||||
factory VeilidConfigRPC.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigRPCFromJson(json);
|
||||
factory VeilidConfigRPC.fromJson(dynamic json) =>
|
||||
_$VeilidConfigRPCFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -325,8 +325,8 @@ class VeilidConfigRoutingTable with _$VeilidConfigRoutingTable {
|
||||
required int limitAttachedWeak,
|
||||
}) = _VeilidConfigRoutingTable;
|
||||
|
||||
factory VeilidConfigRoutingTable.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigRoutingTableFromJson(json);
|
||||
factory VeilidConfigRoutingTable.fromJson(dynamic json) =>
|
||||
_$VeilidConfigRoutingTableFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -355,8 +355,8 @@ class VeilidConfigNetwork with _$VeilidConfigNetwork {
|
||||
required VeilidConfigProtocol protocol,
|
||||
}) = _VeilidConfigNetwork;
|
||||
|
||||
factory VeilidConfigNetwork.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigNetworkFromJson(json);
|
||||
factory VeilidConfigNetwork.fromJson(dynamic json) =>
|
||||
_$VeilidConfigNetworkFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -368,8 +368,8 @@ class VeilidConfigTableStore with _$VeilidConfigTableStore {
|
||||
required bool delete,
|
||||
}) = _VeilidConfigTableStore;
|
||||
|
||||
factory VeilidConfigTableStore.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigTableStoreFromJson(json);
|
||||
factory VeilidConfigTableStore.fromJson(dynamic json) =>
|
||||
_$VeilidConfigTableStoreFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -381,8 +381,8 @@ class VeilidConfigBlockStore with _$VeilidConfigBlockStore {
|
||||
required bool delete,
|
||||
}) = _VeilidConfigBlockStore;
|
||||
|
||||
factory VeilidConfigBlockStore.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigBlockStoreFromJson(json);
|
||||
factory VeilidConfigBlockStore.fromJson(dynamic json) =>
|
||||
_$VeilidConfigBlockStoreFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -397,8 +397,8 @@ class VeilidConfigProtectedStore with _$VeilidConfigProtectedStore {
|
||||
required String deviceEncryptionKeyPassword,
|
||||
String? newDeviceEncryptionKeyPassword}) = _VeilidConfigProtectedStore;
|
||||
|
||||
factory VeilidConfigProtectedStore.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigProtectedStoreFromJson(json);
|
||||
factory VeilidConfigProtectedStore.fromJson(dynamic json) =>
|
||||
_$VeilidConfigProtectedStoreFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -409,8 +409,8 @@ class VeilidConfigCapabilities with _$VeilidConfigCapabilities {
|
||||
required List<String> disable,
|
||||
}) = _VeilidConfigCapabilities;
|
||||
|
||||
factory VeilidConfigCapabilities.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigCapabilitiesFromJson(json);
|
||||
factory VeilidConfigCapabilities.fromJson(dynamic json) =>
|
||||
_$VeilidConfigCapabilitiesFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -427,6 +427,6 @@ class VeilidConfig with _$VeilidConfig {
|
||||
required VeilidConfigNetwork network,
|
||||
}) = _VeilidConfig;
|
||||
|
||||
factory VeilidConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidConfigFromJson(json);
|
||||
factory VeilidConfig.fromJson(dynamic json) =>
|
||||
_$VeilidConfigFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
@@ -18,17 +18,14 @@ const CryptoKind cryptoKindNONE =
|
||||
$N << 0 | $O << 8 | $N << 16 | $E << 24; // "NONE"
|
||||
|
||||
String cryptoKindToString(CryptoKind kind) {
|
||||
return "${String.fromCharCode(kind & 0xFF)}${String.fromCharCode((kind >> 8) & 0xFF)}${String.fromCharCode((kind >> 16) & 0xFF)}${String.fromCharCode((kind >> 24) & 0xFF)}";
|
||||
return cryptoKindToBytes(kind).map((c) => String.fromCharCode(c)).join();
|
||||
}
|
||||
|
||||
const CryptoKind bestCryptoKind = cryptoKindVLD0;
|
||||
|
||||
Uint8List cryptoKindToBytes(CryptoKind kind) {
|
||||
var b = Uint8List(4);
|
||||
b[0] = kind & 0xFF;
|
||||
b[1] = (kind >> 8) & 0xFF;
|
||||
b[2] = (kind >> 16) & 0xFF;
|
||||
b[3] = (kind >> 24) & 0xFF;
|
||||
ByteData.sublistView(b).setUint32(0, kind, Endian.big);
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -36,10 +33,8 @@ CryptoKind cryptoKindFromString(String s) {
|
||||
if (s.codeUnits.length != 4) {
|
||||
throw const FormatException("malformed string");
|
||||
}
|
||||
CryptoKind kind = s.codeUnits[0] |
|
||||
s.codeUnits[1] << 8 |
|
||||
s.codeUnits[2] << 16 |
|
||||
s.codeUnits[3] << 24;
|
||||
CryptoKind kind = ByteData.sublistView(Uint8List.fromList(s.codeUnits))
|
||||
.getUint32(0, Endian.big);
|
||||
return kind;
|
||||
}
|
||||
|
||||
@@ -71,9 +66,10 @@ class Typed<V extends EncodedString> extends Equatable {
|
||||
}
|
||||
|
||||
Uint8List decode() {
|
||||
var b = cryptoKindToBytes(kind);
|
||||
b.addAll(value.decode());
|
||||
return b;
|
||||
var b = BytesBuilder();
|
||||
b.add(cryptoKindToBytes(kind));
|
||||
b.add(value.decode());
|
||||
return b.toBytes();
|
||||
}
|
||||
|
||||
String toJson() => toString();
|
||||
|
||||
@@ -27,7 +27,7 @@ class Uint8ListJsonConverter implements JsonConverter<Uint8List, String> {
|
||||
const Uint8ListJsonConverter();
|
||||
|
||||
@override
|
||||
Uint8List fromJson(String json) => base64UrlNoPadDecode(json);
|
||||
Uint8List fromJson(dynamic json) => base64UrlNoPadDecode(json as String);
|
||||
@override
|
||||
String toJson(Uint8List data) => base64UrlNoPadEncode(data);
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ Future<T> processFuturePlain<T>(Future<dynamic> future) {
|
||||
}
|
||||
|
||||
Future<T> processFutureJson<T>(
|
||||
T Function(Map<String, dynamic>) jsonConstructor, Future<dynamic> future) {
|
||||
T Function(dynamic) jsonConstructor, Future<dynamic> future) {
|
||||
return future.then((value) {
|
||||
final list = value as List<dynamic>;
|
||||
switch (list[0] as int) {
|
||||
@@ -541,7 +541,7 @@ Future<Stream<T>> processFutureStream<T>(
|
||||
}
|
||||
|
||||
Stream<T> processStreamJson<T>(
|
||||
T Function(Map<String, dynamic>) jsonConstructor, ReceivePort port) async* {
|
||||
T Function(dynamic) jsonConstructor, ReceivePort port) async* {
|
||||
try {
|
||||
await for (var value in port) {
|
||||
final list = value as List<dynamic>;
|
||||
@@ -729,7 +729,7 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
||||
final sendPort = recvPort.sendPort;
|
||||
_ctx.ffi._routingContextGetDHTValue(
|
||||
sendPort.nativePort, _ctx.id!, nativeKey, subkey, forceRefresh);
|
||||
final valueData = await processFutureJson(
|
||||
final valueData = await processFutureOptJson(
|
||||
optFromJson(ValueData.fromJson), recvPort.first);
|
||||
return valueData;
|
||||
}
|
||||
@@ -745,7 +745,7 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
||||
final sendPort = recvPort.sendPort;
|
||||
_ctx.ffi._routingContextSetDHTValue(
|
||||
sendPort.nativePort, _ctx.id!, nativeKey, subkey, nativeData);
|
||||
final valueData = await processFutureJson(
|
||||
final valueData = await processFutureOptJson(
|
||||
optFromJson(ValueData.fromJson), recvPort.first);
|
||||
return valueData;
|
||||
}
|
||||
@@ -1651,8 +1651,8 @@ class VeilidFFI extends Veilid {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> appCallReply(String call_id, Uint8List message) {
|
||||
final nativeCallId = call_id.toNativeUtf8();
|
||||
Future<void> appCallReply(String callId, Uint8List message) {
|
||||
final nativeCallId = callId.toNativeUtf8();
|
||||
final nativeEncodedMessage = base64UrlNoPadEncode(message).toNativeUtf8();
|
||||
final recvPort = ReceivePort("app_call_reply");
|
||||
final sendPort = recvPort.sendPort;
|
||||
@@ -1681,15 +1681,15 @@ class VeilidFFI extends Veilid {
|
||||
@override
|
||||
List<CryptoKind> validCryptoKinds() {
|
||||
final vckString = _validCryptoKinds();
|
||||
final vck = jsonDecode(vckString.toDartString());
|
||||
final vck = jsonDecode(vckString.toDartString()) as List<dynamic>;
|
||||
_freeString(vckString);
|
||||
return vck;
|
||||
return vck.map((v) => v as CryptoKind).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<VeilidCryptoSystem> getCryptoSystem(CryptoKind kind) async {
|
||||
if (!validCryptoKinds().contains(kind)) {
|
||||
throw VeilidAPIExceptionGeneric("unsupported cryptosystem");
|
||||
throw const VeilidAPIExceptionGeneric("unsupported cryptosystem");
|
||||
}
|
||||
return VeilidCryptoSystemFFI._(this, kind);
|
||||
}
|
||||
|
||||
@@ -571,13 +571,15 @@ class VeilidJS extends Veilid {
|
||||
|
||||
@override
|
||||
List<CryptoKind> validCryptoKinds() {
|
||||
return jsonDecode(js_util.callMethod(wasm, "valid_crypto_kinds", []));
|
||||
final vck = jsonDecode(js_util.callMethod(wasm, "valid_crypto_kinds", []))
|
||||
as List<dynamic>;
|
||||
return vck.map((v) => v as CryptoKind).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<VeilidCryptoSystem> getCryptoSystem(CryptoKind kind) async {
|
||||
if (!validCryptoKinds().contains(kind)) {
|
||||
throw VeilidAPIExceptionGeneric("unsupported cryptosystem");
|
||||
throw const VeilidAPIExceptionGeneric("unsupported cryptosystem");
|
||||
}
|
||||
return VeilidCryptoSystemJS._(this, kind);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ enum AttachmentState {
|
||||
detaching;
|
||||
|
||||
String toJson() => name.toPascalCase();
|
||||
factory AttachmentState.fromJson(String j) =>
|
||||
AttachmentState.values.byName(j.toCamelCase());
|
||||
factory AttachmentState.fromJson(dynamic j) =>
|
||||
AttachmentState.values.byName((j as String).toCamelCase());
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -37,8 +37,8 @@ enum VeilidLogLevel {
|
||||
trace;
|
||||
|
||||
String toJson() => name.toPascalCase();
|
||||
factory VeilidLogLevel.fromJson(String j) =>
|
||||
VeilidLogLevel.values.byName(j.toCamelCase());
|
||||
factory VeilidLogLevel.fromJson(dynamic j) =>
|
||||
VeilidLogLevel.values.byName((j as String).toCamelCase());
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -51,8 +51,8 @@ class LatencyStats with _$LatencyStats {
|
||||
required TimestampDuration slowest,
|
||||
}) = _LatencyStats;
|
||||
|
||||
factory LatencyStats.fromJson(Map<String, dynamic> json) =>
|
||||
_$LatencyStatsFromJson(json);
|
||||
factory LatencyStats.fromJson(dynamic json) =>
|
||||
_$LatencyStatsFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -66,8 +66,8 @@ class TransferStats with _$TransferStats {
|
||||
required BigInt minimum,
|
||||
}) = _TransferStats;
|
||||
|
||||
factory TransferStats.fromJson(Map<String, dynamic> json) =>
|
||||
_$TransferStatsFromJson(json);
|
||||
factory TransferStats.fromJson(dynamic json) =>
|
||||
_$TransferStatsFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -79,8 +79,8 @@ class TransferStatsDownUp with _$TransferStatsDownUp {
|
||||
required TransferStats up,
|
||||
}) = _TransferStatsDownUp;
|
||||
|
||||
factory TransferStatsDownUp.fromJson(Map<String, dynamic> json) =>
|
||||
_$TransferStatsDownUpFromJson(json);
|
||||
factory TransferStatsDownUp.fromJson(dynamic json) =>
|
||||
_$TransferStatsDownUpFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -98,8 +98,8 @@ class RPCStats with _$RPCStats {
|
||||
required int failedToSend,
|
||||
}) = _RPCStats;
|
||||
|
||||
factory RPCStats.fromJson(Map<String, dynamic> json) =>
|
||||
_$RPCStatsFromJson(json);
|
||||
factory RPCStats.fromJson(dynamic json) =>
|
||||
_$RPCStatsFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -113,8 +113,8 @@ class PeerStats with _$PeerStats {
|
||||
required TransferStatsDownUp transfer,
|
||||
}) = _PeerStats;
|
||||
|
||||
factory PeerStats.fromJson(Map<String, dynamic> json) =>
|
||||
_$PeerStatsFromJson(json);
|
||||
factory PeerStats.fromJson(dynamic json) =>
|
||||
_$PeerStatsFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
////////////
|
||||
@@ -127,8 +127,8 @@ class PeerTableData with _$PeerTableData {
|
||||
required PeerStats peerStats,
|
||||
}) = _PeerTableData;
|
||||
|
||||
factory PeerTableData.fromJson(Map<String, dynamic> json) =>
|
||||
_$PeerTableDataFromJson(json);
|
||||
factory PeerTableData.fromJson(dynamic json) =>
|
||||
_$PeerTableDataFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -173,8 +173,8 @@ sealed class VeilidUpdate with _$VeilidUpdate {
|
||||
required ValueData valueData,
|
||||
}) = VeilidUpdateValueChange;
|
||||
|
||||
factory VeilidUpdate.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidUpdateFromJson(json);
|
||||
factory VeilidUpdate.fromJson(dynamic json) =>
|
||||
_$VeilidUpdateFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -187,8 +187,8 @@ class VeilidStateAttachment with _$VeilidStateAttachment {
|
||||
required bool publicInternetReady,
|
||||
required bool localNetworkReady}) = _VeilidStateAttachment;
|
||||
|
||||
factory VeilidStateAttachment.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidStateAttachmentFromJson(json);
|
||||
factory VeilidStateAttachment.fromJson(dynamic json) =>
|
||||
_$VeilidStateAttachmentFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -202,8 +202,8 @@ class VeilidStateNetwork with _$VeilidStateNetwork {
|
||||
required BigInt bpsUp,
|
||||
required List<PeerTableData> peers}) = _VeilidStateNetwork;
|
||||
|
||||
factory VeilidStateNetwork.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidStateNetworkFromJson(json);
|
||||
factory VeilidStateNetwork.fromJson(dynamic json) =>
|
||||
_$VeilidStateNetworkFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -215,8 +215,8 @@ class VeilidStateConfig with _$VeilidStateConfig {
|
||||
required VeilidConfig config,
|
||||
}) = _VeilidStateConfig;
|
||||
|
||||
factory VeilidStateConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidStateConfigFromJson(json);
|
||||
factory VeilidStateConfig.fromJson(dynamic json) =>
|
||||
_$VeilidStateConfigFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
@@ -230,6 +230,6 @@ class VeilidState with _$VeilidState {
|
||||
required VeilidStateConfig config,
|
||||
}) = _VeilidState;
|
||||
|
||||
factory VeilidState.fromJson(Map<String, dynamic> json) =>
|
||||
_$VeilidStateFromJson(json);
|
||||
factory VeilidState.fromJson(dynamic json) =>
|
||||
_$VeilidStateFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user