lint cleanup
This commit is contained in:
parent
d49c631fac
commit
a589dbf100
@ -226,203 +226,198 @@ const int messageStreamClose = 8;
|
|||||||
Veilid getVeilid() => VeilidFFI(_dylib);
|
Veilid getVeilid() => VeilidFFI(_dylib);
|
||||||
|
|
||||||
// Parse handle async returns
|
// Parse handle async returns
|
||||||
Future<T> processFuturePlain<T>(Future<dynamic> future) async => future.then((value) {
|
Future<T> processFuturePlain<T>(Future<dynamic> future) async =>
|
||||||
final list = value as List<dynamic>;
|
future.then((value) {
|
||||||
switch (list[0] as int) {
|
final list = value as List<dynamic>;
|
||||||
case messageOk:
|
switch (list[0] as int) {
|
||||||
{
|
case messageOk:
|
||||||
if (list[1] == null && null is! T) {
|
{
|
||||||
throw const VeilidAPIExceptionInternal(
|
if (list[1] == null && null is! T) {
|
||||||
'Null MESSAGE_OK value on non-nullable type');
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
'Null MESSAGE_OK value on non-nullable type');
|
||||||
|
}
|
||||||
|
return list[1] as T;
|
||||||
}
|
}
|
||||||
return list[1] as T;
|
case messageErr:
|
||||||
}
|
{
|
||||||
case messageErr:
|
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
||||||
{
|
}
|
||||||
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
case messageErrJson:
|
||||||
}
|
{
|
||||||
case messageErrJson:
|
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
||||||
{
|
}
|
||||||
throw VeilidAPIException.fromJson(jsonDecode(list[1]));
|
default:
|
||||||
}
|
{
|
||||||
default:
|
throw VeilidAPIExceptionInternal(
|
||||||
{
|
'Unexpected async return message type: ${list[0]}');
|
||||||
throw VeilidAPIExceptionInternal(
|
}
|
||||||
'Unexpected async return message type: ${list[0]}');
|
}
|
||||||
}
|
// ignore: inference_failure_on_untyped_parameter
|
||||||
}
|
}).catchError((e) {
|
||||||
}).catchError((e) {
|
// Wrap all other errors in VeilidAPIExceptionInternal
|
||||||
// Wrap all other errors in VeilidAPIExceptionInternal
|
throw VeilidAPIExceptionInternal(e.toString());
|
||||||
throw VeilidAPIExceptionInternal(e.toString());
|
}, test: (e) => e is! VeilidAPIException);
|
||||||
}, test: (e) {
|
|
||||||
// Pass errors that are already VeilidAPIException through without wrapping
|
|
||||||
return e is! VeilidAPIException;
|
|
||||||
});
|
|
||||||
|
|
||||||
Future<T> processFutureJson<T>(
|
Future<T> processFutureJson<T>(
|
||||||
T Function(dynamic) jsonConstructor, Future<dynamic> future) async => future.then((value) {
|
T Function(dynamic) jsonConstructor, Future<dynamic> future) async =>
|
||||||
final list = value as List<dynamic>;
|
future.then((value) {
|
||||||
switch (list[0] as int) {
|
final list = value as List<dynamic>;
|
||||||
case messageErr:
|
switch (list[0] as int) {
|
||||||
{
|
case messageErr:
|
||||||
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
{
|
||||||
}
|
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
||||||
case messageOkJson:
|
|
||||||
{
|
|
||||||
if (list[1] is! String) {
|
|
||||||
throw const VeilidAPIExceptionInternal(
|
|
||||||
'Non-string MESSAGE_OK_JSON value');
|
|
||||||
}
|
}
|
||||||
final ret = jsonDecode(list[1] as String);
|
case messageOkJson:
|
||||||
if (ret == null) {
|
{
|
||||||
throw const VeilidAPIExceptionInternal(
|
if (list[1] is! String) {
|
||||||
'Null JSON object on non nullable type');
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
'Non-string MESSAGE_OK_JSON value');
|
||||||
|
}
|
||||||
|
final ret = jsonDecode(list[1] as String);
|
||||||
|
if (ret == null) {
|
||||||
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
'Null JSON object on non nullable type');
|
||||||
|
}
|
||||||
|
return jsonConstructor(ret);
|
||||||
}
|
}
|
||||||
return jsonConstructor(ret);
|
case messageErrJson:
|
||||||
}
|
{
|
||||||
case messageErrJson:
|
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
||||||
{
|
}
|
||||||
throw VeilidAPIException.fromJson(jsonDecode(list[1]));
|
default:
|
||||||
}
|
{
|
||||||
default:
|
throw VeilidAPIExceptionInternal(
|
||||||
{
|
'Unexpected async return message type: ${list[0]}');
|
||||||
throw VeilidAPIExceptionInternal(
|
}
|
||||||
'Unexpected async return message type: ${list[0]}');
|
}
|
||||||
}
|
// ignore: inference_failure_on_untyped_parameter
|
||||||
}
|
}).catchError((e) {
|
||||||
}).catchError((e) {
|
// Wrap all other errors in VeilidAPIExceptionInternal
|
||||||
// Wrap all other errors in VeilidAPIExceptionInternal
|
throw VeilidAPIExceptionInternal(e.toString());
|
||||||
throw VeilidAPIExceptionInternal(e.toString());
|
}, test: (e) => e is! VeilidAPIException);
|
||||||
}, test: (e) {
|
|
||||||
// Pass errors that are already VeilidAPIException through without wrapping
|
|
||||||
return e is! VeilidAPIException;
|
|
||||||
});
|
|
||||||
|
|
||||||
Future<T?> processFutureOptJson<T>(
|
Future<T?> processFutureOptJson<T>(
|
||||||
T Function(dynamic) jsonConstructor, Future<dynamic> future) async => future.then((value) {
|
T Function(dynamic) jsonConstructor, Future<dynamic> future) async =>
|
||||||
final list = value as List<dynamic>;
|
future.then((value) {
|
||||||
switch (list[0] as int) {
|
final list = value as List<dynamic>;
|
||||||
case messageErr:
|
switch (list[0] as int) {
|
||||||
{
|
case messageErr:
|
||||||
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
{
|
||||||
}
|
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
||||||
case messageOkJson:
|
|
||||||
{
|
|
||||||
if (list[1] == null) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
if (list[1] is! String) {
|
case messageOkJson:
|
||||||
throw const VeilidAPIExceptionInternal(
|
{
|
||||||
'Non-string MESSAGE_OK_JSON optional value');
|
if (list[1] == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (list[1] is! String) {
|
||||||
|
throw const VeilidAPIExceptionInternal(
|
||||||
|
'Non-string MESSAGE_OK_JSON optional value');
|
||||||
|
}
|
||||||
|
final ret = jsonDecode(list[1] as String);
|
||||||
|
if (ret == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return jsonConstructor(ret);
|
||||||
}
|
}
|
||||||
final ret = jsonDecode(list[1] as String);
|
case messageErrJson:
|
||||||
if (ret == null) {
|
{
|
||||||
return null;
|
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
||||||
}
|
}
|
||||||
return jsonConstructor(ret);
|
default:
|
||||||
}
|
{
|
||||||
case messageErrJson:
|
throw VeilidAPIExceptionInternal(
|
||||||
{
|
'Unexpected async return message type: ${list[0]}');
|
||||||
throw VeilidAPIException.fromJson(jsonDecode(list[1]));
|
}
|
||||||
}
|
}
|
||||||
default:
|
// ignore: inference_failure_on_untyped_parameter
|
||||||
{
|
}).catchError((e) {
|
||||||
throw VeilidAPIExceptionInternal(
|
// Wrap all other errors in VeilidAPIExceptionInternal
|
||||||
'Unexpected async return message type: ${list[0]}');
|
throw VeilidAPIExceptionInternal(e.toString());
|
||||||
}
|
}, test: (e) => e is! VeilidAPIException);
|
||||||
}
|
|
||||||
}).catchError((e) {
|
|
||||||
// Wrap all other errors in VeilidAPIExceptionInternal
|
|
||||||
throw VeilidAPIExceptionInternal(e.toString());
|
|
||||||
}, test: (e) {
|
|
||||||
// Pass errors that are already VeilidAPIException through without wrapping
|
|
||||||
return e is! VeilidAPIException;
|
|
||||||
});
|
|
||||||
|
|
||||||
Future<void> processFutureVoid(Future<dynamic> future) async => future.then((value) {
|
Future<void> processFutureVoid(Future<dynamic> future) async =>
|
||||||
final list = value as List<dynamic>;
|
future.then((value) {
|
||||||
switch (list[0] as int) {
|
final list = value as List<dynamic>;
|
||||||
case messageOk:
|
switch (list[0] as int) {
|
||||||
{
|
case messageOk:
|
||||||
if (list[1] != null) {
|
{
|
||||||
throw VeilidAPIExceptionInternal(
|
if (list[1] != null) {
|
||||||
"Unexpected MESSAGE_OK value '${list[1]}' where null expected");
|
throw VeilidAPIExceptionInternal(
|
||||||
|
"Unexpected MESSAGE_OK value '${list[1]}' where null expected");
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
case messageErr:
|
||||||
}
|
{
|
||||||
case messageErr:
|
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
||||||
{
|
|
||||||
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
|
||||||
}
|
|
||||||
case messageOkJson:
|
|
||||||
{
|
|
||||||
final ret = jsonDecode(list[1] as String);
|
|
||||||
if (ret != null) {
|
|
||||||
throw VeilidAPIExceptionInternal(
|
|
||||||
"Unexpected MESSAGE_OK_JSON value '$ret' where null expected");
|
|
||||||
}
|
}
|
||||||
return;
|
case messageOkJson:
|
||||||
}
|
{
|
||||||
case messageErrJson:
|
final ret = jsonDecode(list[1] as String);
|
||||||
{
|
if (ret != null) {
|
||||||
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
throw VeilidAPIExceptionInternal(
|
||||||
}
|
"Unexpected MESSAGE_OK_JSON value '$ret' where null expected");
|
||||||
default:
|
}
|
||||||
{
|
return;
|
||||||
throw VeilidAPIExceptionInternal(
|
}
|
||||||
'Unexpected async return message type: ${list[0]}');
|
case messageErrJson:
|
||||||
}
|
{
|
||||||
}
|
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
||||||
}).catchError((e) {
|
}
|
||||||
// Wrap all other errors in VeilidAPIExceptionInternal
|
default:
|
||||||
throw VeilidAPIExceptionInternal(e.toString());
|
{
|
||||||
}, test: (e) {
|
throw VeilidAPIExceptionInternal(
|
||||||
// Pass errors that are already VeilidAPIException through without wrapping
|
'Unexpected async return message type: ${list[0]}');
|
||||||
return e is! VeilidAPIException;
|
}
|
||||||
});
|
}
|
||||||
|
// ignore: inference_failure_on_untyped_parameter
|
||||||
|
}).catchError((e) {
|
||||||
|
// Wrap all other errors in VeilidAPIExceptionInternal
|
||||||
|
throw VeilidAPIExceptionInternal(e.toString());
|
||||||
|
}, test: (e) => e is! VeilidAPIException);
|
||||||
|
|
||||||
Future<Stream<T>> processFutureStream<T>(
|
Future<Stream<T>> processFutureStream<T>(
|
||||||
Stream<T> returnStream, Future<dynamic> future) async => future.then((value) {
|
Stream<T> returnStream, Future<dynamic> future) async =>
|
||||||
final list = value as List<dynamic>;
|
future.then((value) {
|
||||||
switch (list[0] as int) {
|
final list = value as List<dynamic>;
|
||||||
case messageOk:
|
switch (list[0] as int) {
|
||||||
{
|
case messageOk:
|
||||||
if (list[1] != null) {
|
{
|
||||||
throw VeilidAPIExceptionInternal(
|
if (list[1] != null) {
|
||||||
"Unexpected MESSAGE_OK value '${list[1]}' where null expected");
|
throw VeilidAPIExceptionInternal(
|
||||||
|
"Unexpected MESSAGE_OK value '${list[1]}' where null expected");
|
||||||
|
}
|
||||||
|
return returnStream;
|
||||||
}
|
}
|
||||||
return returnStream;
|
case messageErr:
|
||||||
}
|
{
|
||||||
case messageErr:
|
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
||||||
{
|
|
||||||
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
|
||||||
}
|
|
||||||
case messageOkJson:
|
|
||||||
{
|
|
||||||
final ret = jsonDecode(list[1] as String);
|
|
||||||
if (ret != null) {
|
|
||||||
throw VeilidAPIExceptionInternal(
|
|
||||||
"Unexpected MESSAGE_OK_JSON value '$ret' where null expected");
|
|
||||||
}
|
}
|
||||||
return returnStream;
|
case messageOkJson:
|
||||||
}
|
{
|
||||||
case messageErrJson:
|
final ret = jsonDecode(list[1] as String);
|
||||||
{
|
if (ret != null) {
|
||||||
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
throw VeilidAPIExceptionInternal(
|
||||||
}
|
"Unexpected MESSAGE_OK_JSON value '$ret' where null expected");
|
||||||
default:
|
}
|
||||||
{
|
return returnStream;
|
||||||
throw VeilidAPIExceptionInternal(
|
}
|
||||||
'Unexpected async return message type: ${list[0]}');
|
case messageErrJson:
|
||||||
}
|
{
|
||||||
}
|
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
||||||
}).catchError((e) {
|
}
|
||||||
// Wrap all other errors in VeilidAPIExceptionInternal
|
default:
|
||||||
throw VeilidAPIExceptionInternal(e.toString());
|
{
|
||||||
}, test: (e) {
|
throw VeilidAPIExceptionInternal(
|
||||||
// Pass errors that are already VeilidAPIException through without wrapping
|
'Unexpected async return message type: ${list[0]}');
|
||||||
return e is! VeilidAPIException;
|
}
|
||||||
});
|
}
|
||||||
|
// ignore: inference_failure_on_untyped_parameter
|
||||||
|
}).catchError((e) {
|
||||||
|
// Wrap all other errors in VeilidAPIExceptionInternal
|
||||||
|
throw VeilidAPIExceptionInternal(e.toString());
|
||||||
|
}, test: (e) => e is! VeilidAPIException);
|
||||||
|
|
||||||
Stream<T> processStreamJson<T>(
|
Stream<T> processStreamJson<T>(
|
||||||
T Function(dynamic) jsonConstructor, ReceivePort port) async* {
|
T Function(dynamic) jsonConstructor, ReceivePort port) async* {
|
||||||
@ -442,17 +437,14 @@ Stream<T> processStreamJson<T>(
|
|||||||
}
|
}
|
||||||
case messageStreamAbort:
|
case messageStreamAbort:
|
||||||
{
|
{
|
||||||
port.close();
|
|
||||||
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
throw VeilidAPIExceptionInternal('Internal API Error: ${list[1]}');
|
||||||
}
|
}
|
||||||
case messageStreamAbortJson:
|
case messageStreamAbortJson:
|
||||||
{
|
{
|
||||||
port.close();
|
throw VeilidAPIException.fromJson(jsonDecode(list[1] as String));
|
||||||
throw VeilidAPIException.fromJson(jsonDecode(list[1]));
|
|
||||||
}
|
}
|
||||||
case messageStreamClose:
|
case messageStreamClose:
|
||||||
{
|
{
|
||||||
port.close();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -462,10 +454,13 @@ Stream<T> processStreamJson<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} on VeilidAPIException catch (_) {
|
||||||
|
rethrow;
|
||||||
|
} on Exception catch (e, s) {
|
||||||
// Wrap all other errors in VeilidAPIExceptionInternal
|
// Wrap all other errors in VeilidAPIExceptionInternal
|
||||||
throw VeilidAPIExceptionInternal(
|
throw VeilidAPIExceptionInternal('$e\nStack Trace:\n$s');
|
||||||
'$e\nStack Trace:\n$s');
|
} finally {
|
||||||
|
port.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +485,6 @@ class _Ctx {
|
|||||||
|
|
||||||
// FFI implementation of VeilidRoutingContext
|
// FFI implementation of VeilidRoutingContext
|
||||||
class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
||||||
|
|
||||||
VeilidRoutingContextFFI._(this._ctx) {
|
VeilidRoutingContextFFI._(this._ctx) {
|
||||||
_finalizer.attach(this, _ctx, detach: this);
|
_finalizer.attach(this, _ctx, detach: this);
|
||||||
}
|
}
|
||||||
@ -535,7 +529,7 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
|||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_ctx.ffi._routingContextAppCall(sendPort.nativePort, _ctx.id!,
|
_ctx.ffi._routingContextAppCall(sendPort.nativePort, _ctx.id!,
|
||||||
nativeEncodedTarget, nativeEncodedRequest);
|
nativeEncodedTarget, nativeEncodedRequest);
|
||||||
final out = await processFuturePlain(recvPort.first);
|
final out = await processFuturePlain<String>(recvPort.first);
|
||||||
return base64UrlNoPadDecode(out);
|
return base64UrlNoPadDecode(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,8 +607,8 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
|||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_ctx.ffi._routingContextGetDHTValue(
|
_ctx.ffi._routingContextGetDHTValue(
|
||||||
sendPort.nativePort, _ctx.id!, nativeKey, subkey, forceRefresh);
|
sendPort.nativePort, _ctx.id!, nativeKey, subkey, forceRefresh);
|
||||||
final valueData = await processFutureOptJson(
|
final valueData =
|
||||||
optFromJson(ValueData.fromJson), recvPort.first);
|
await processFutureOptJson(ValueData.fromJson, recvPort.first);
|
||||||
return valueData;
|
return valueData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,8 +623,8 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
|||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_ctx.ffi._routingContextSetDHTValue(
|
_ctx.ffi._routingContextSetDHTValue(
|
||||||
sendPort.nativePort, _ctx.id!, nativeKey, subkey, nativeData);
|
sendPort.nativePort, _ctx.id!, nativeKey, subkey, nativeData);
|
||||||
final valueData = await processFutureOptJson(
|
final valueData =
|
||||||
optFromJson(ValueData.fromJson), recvPort.first);
|
await processFutureOptJson(ValueData.fromJson, recvPort.first);
|
||||||
return valueData;
|
return valueData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,7 +662,6 @@ class VeilidRoutingContextFFI extends VeilidRoutingContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TDBT {
|
class _TDBT {
|
||||||
|
|
||||||
_TDBT(int this.id, this.tdbffi, this.ffi);
|
_TDBT(int this.id, this.tdbffi, this.ffi);
|
||||||
int? id;
|
int? id;
|
||||||
final VeilidTableDBFFI tdbffi;
|
final VeilidTableDBFFI tdbffi;
|
||||||
@ -689,7 +682,6 @@ class _TDBT {
|
|||||||
|
|
||||||
// FFI implementation of VeilidTableDBTransaction
|
// FFI implementation of VeilidTableDBTransaction
|
||||||
class VeilidTableDBTransactionFFI extends VeilidTableDBTransaction {
|
class VeilidTableDBTransactionFFI extends VeilidTableDBTransaction {
|
||||||
|
|
||||||
VeilidTableDBTransactionFFI._(this._tdbt) {
|
VeilidTableDBTransactionFFI._(this._tdbt) {
|
||||||
_finalizer.attach(this, _tdbt, detach: this);
|
_finalizer.attach(this, _tdbt, detach: this);
|
||||||
}
|
}
|
||||||
@ -780,7 +772,6 @@ class _TDB {
|
|||||||
|
|
||||||
// FFI implementation of VeilidTableDB
|
// FFI implementation of VeilidTableDB
|
||||||
class VeilidTableDBFFI extends VeilidTableDB {
|
class VeilidTableDBFFI extends VeilidTableDB {
|
||||||
|
|
||||||
VeilidTableDBFFI._(this._tdb) {
|
VeilidTableDBFFI._(this._tdb) {
|
||||||
_finalizer.attach(this, _tdb, detach: this);
|
_finalizer.attach(this, _tdb, detach: this);
|
||||||
}
|
}
|
||||||
@ -852,7 +843,7 @@ class VeilidTableDBFFI extends VeilidTableDB {
|
|||||||
col,
|
col,
|
||||||
nativeEncodedKey,
|
nativeEncodedKey,
|
||||||
);
|
);
|
||||||
final out = await processFuturePlain(recvPort.first);
|
final out = await processFuturePlain<String?>(recvPort.first);
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -872,7 +863,7 @@ class VeilidTableDBFFI extends VeilidTableDB {
|
|||||||
col,
|
col,
|
||||||
nativeEncodedKey,
|
nativeEncodedKey,
|
||||||
);
|
);
|
||||||
final out = await processFuturePlain(recvPort.first);
|
final out = await processFuturePlain<String?>(recvPort.first);
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -882,7 +873,6 @@ class VeilidTableDBFFI extends VeilidTableDB {
|
|||||||
|
|
||||||
// FFI implementation of VeilidCryptoSystem
|
// FFI implementation of VeilidCryptoSystem
|
||||||
class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
|
class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
|
||||||
|
|
||||||
VeilidCryptoSystemFFI._(this._ffi, this._kind);
|
VeilidCryptoSystemFFI._(this._ffi, this._kind);
|
||||||
final CryptoKind _kind;
|
final CryptoKind _kind;
|
||||||
final VeilidFFI _ffi;
|
final VeilidFFI _ffi;
|
||||||
@ -917,7 +907,7 @@ class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
|
|||||||
final recvPort = ReceivePort('crypto_random_bytes');
|
final recvPort = ReceivePort('crypto_random_bytes');
|
||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_ffi._cryptoRandomBytes(sendPort.nativePort, _kind, len);
|
_ffi._cryptoRandomBytes(sendPort.nativePort, _kind, len);
|
||||||
final out = await processFuturePlain(recvPort.first);
|
final out = await processFuturePlain<String>(recvPort.first);
|
||||||
return base64UrlNoPadDecode(out);
|
return base64UrlNoPadDecode(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1088,7 +1078,7 @@ class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
|
|||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_ffi._cryptoDecryptAead(sendPort.nativePort, _kind, nativeEncodedBody,
|
_ffi._cryptoDecryptAead(sendPort.nativePort, _kind, nativeEncodedBody,
|
||||||
nativeNonce, nativeSharedSecret, nativeSignature);
|
nativeNonce, nativeSharedSecret, nativeSignature);
|
||||||
final out = await processFuturePlain(recvPort.first);
|
final out = await processFuturePlain<String>(recvPort.first);
|
||||||
return base64UrlNoPadDecode(out);
|
return base64UrlNoPadDecode(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,7 +1096,7 @@ class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
|
|||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_ffi._cryptoEncryptAead(sendPort.nativePort, _kind, nativeEncodedBody,
|
_ffi._cryptoEncryptAead(sendPort.nativePort, _kind, nativeEncodedBody,
|
||||||
nativeNonce, nativeSharedSecret, nativeSignature);
|
nativeNonce, nativeSharedSecret, nativeSignature);
|
||||||
final out = await processFuturePlain(recvPort.first);
|
final out = await processFuturePlain<String>(recvPort.first);
|
||||||
return base64UrlNoPadDecode(out);
|
return base64UrlNoPadDecode(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1121,31 +1111,34 @@ class VeilidCryptoSystemFFI extends VeilidCryptoSystem {
|
|||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_ffi._cryptoCryptNoAuth(sendPort.nativePort, _kind, nativeEncodedBody,
|
_ffi._cryptoCryptNoAuth(sendPort.nativePort, _kind, nativeEncodedBody,
|
||||||
nativeNonce, nativeSharedSecret);
|
nativeNonce, nativeSharedSecret);
|
||||||
final out = await processFuturePlain(recvPort.first);
|
final out = await processFuturePlain<String>(recvPort.first);
|
||||||
return base64UrlNoPadDecode(out);
|
return base64UrlNoPadDecode(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FFI implementation of high level Veilid API
|
// FFI implementation of high level Veilid API
|
||||||
class VeilidFFI extends Veilid {
|
class VeilidFFI extends Veilid {
|
||||||
|
|
||||||
VeilidFFI(DynamicLibrary dylib)
|
VeilidFFI(DynamicLibrary dylib)
|
||||||
: _dylib = dylib,
|
: _dylib = dylib,
|
||||||
_freeString =
|
_freeString =
|
||||||
dylib.lookupFunction<Void Function(Pointer<Utf8>), _FreeStringDart>('free_string'),
|
dylib.lookupFunction<Void Function(Pointer<Utf8>), _FreeStringDart>(
|
||||||
_initializeVeilidCore = dylib.lookupFunction<Void Function(Pointer<Utf8>),
|
'free_string'),
|
||||||
|
_initializeVeilidCore = dylib.lookupFunction<
|
||||||
|
Void Function(Pointer<Utf8>),
|
||||||
_InitializeVeilidCoreDart>('initialize_veilid_core'),
|
_InitializeVeilidCoreDart>('initialize_veilid_core'),
|
||||||
_changeLogLevel =
|
_changeLogLevel = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Pointer<Utf8>, Pointer<Utf8>), _ChangeLogLevelDart>(
|
Void Function(Pointer<Utf8>, Pointer<Utf8>),
|
||||||
'change_log_level'),
|
_ChangeLogLevelDart>('change_log_level'),
|
||||||
_startupVeilidCore =
|
_startupVeilidCore = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Int64, Pointer<Utf8>), _StartupVeilidCoreDart>(
|
Void Function(Int64, Int64, Pointer<Utf8>),
|
||||||
'startup_veilid_core'),
|
_StartupVeilidCoreDart>('startup_veilid_core'),
|
||||||
_getVeilidState =
|
_getVeilidState =
|
||||||
dylib.lookupFunction<Void Function(Int64), _GetVeilidStateDart>(
|
dylib.lookupFunction<Void Function(Int64), _GetVeilidStateDart>(
|
||||||
'get_veilid_state'),
|
'get_veilid_state'),
|
||||||
_attach = dylib.lookupFunction<Void Function(Int64), _AttachDart>('attach'),
|
_attach =
|
||||||
_detach = dylib.lookupFunction<Void Function(Int64), _DetachDart>('detach'),
|
dylib.lookupFunction<Void Function(Int64), _AttachDart>('attach'),
|
||||||
|
_detach =
|
||||||
|
dylib.lookupFunction<Void Function(Int64), _DetachDart>('detach'),
|
||||||
_shutdownVeilidCore =
|
_shutdownVeilidCore =
|
||||||
dylib.lookupFunction<Void Function(Int64), _ShutdownVeilidCoreDart>(
|
dylib.lookupFunction<Void Function(Int64), _ShutdownVeilidCoreDart>(
|
||||||
'shutdown_veilid_core'),
|
'shutdown_veilid_core'),
|
||||||
@ -1165,7 +1158,8 @@ class VeilidFFI extends Veilid {
|
|||||||
Uint32 Function(Uint32, Pointer<Utf8>),
|
Uint32 Function(Uint32, Pointer<Utf8>),
|
||||||
_RoutingContextWithSequencingDart>(
|
_RoutingContextWithSequencingDart>(
|
||||||
'routing_context_with_sequencing'),
|
'routing_context_with_sequencing'),
|
||||||
_routingContextAppCall = dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
_routingContextAppCall = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_RoutingContextAppCallDart>('routing_context_app_call'),
|
_RoutingContextAppCallDart>('routing_context_app_call'),
|
||||||
_routingContextAppMessage = dylib.lookupFunction<
|
_routingContextAppMessage = dylib.lookupFunction<
|
||||||
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
@ -1193,7 +1187,8 @@ class VeilidFFI extends Veilid {
|
|||||||
Void Function(Int64, Uint32, Pointer<Utf8>, Uint32, Pointer<Utf8>),
|
Void Function(Int64, Uint32, Pointer<Utf8>, Uint32, Pointer<Utf8>),
|
||||||
_RoutingContextSetDHTValueDart>('routing_context_set_dht_value'),
|
_RoutingContextSetDHTValueDart>('routing_context_set_dht_value'),
|
||||||
_routingContextWatchDHTValues = dylib.lookupFunction<
|
_routingContextWatchDHTValues = dylib.lookupFunction<
|
||||||
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Uint64, Uint32),
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>,
|
||||||
|
Uint64, Uint32),
|
||||||
_RoutingContextWatchDHTValuesDart>(
|
_RoutingContextWatchDHTValuesDart>(
|
||||||
'routing_context_watch_dht_values'),
|
'routing_context_watch_dht_values'),
|
||||||
_routingContextCancelDHTWatch = dylib.lookupFunction<
|
_routingContextCancelDHTWatch = dylib.lookupFunction<
|
||||||
@ -1203,35 +1198,41 @@ class VeilidFFI extends Veilid {
|
|||||||
_newPrivateRoute =
|
_newPrivateRoute =
|
||||||
dylib.lookupFunction<Void Function(Int64), _NewPrivateRouteDart>(
|
dylib.lookupFunction<Void Function(Int64), _NewPrivateRouteDart>(
|
||||||
'new_private_route'),
|
'new_private_route'),
|
||||||
_newCustomPrivateRoute = dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>),
|
_newCustomPrivateRoute = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_NewCustomPrivateRouteDart>('new_custom_private_route'),
|
_NewCustomPrivateRouteDart>('new_custom_private_route'),
|
||||||
_importRemotePrivateRoute = dylib.lookupFunction<
|
_importRemotePrivateRoute = dylib.lookupFunction<
|
||||||
Void Function(Int64, Pointer<Utf8>),
|
Void Function(Int64, Pointer<Utf8>),
|
||||||
_ImportRemotePrivateRouteDart>('import_remote_private_route'),
|
_ImportRemotePrivateRouteDart>('import_remote_private_route'),
|
||||||
_releasePrivateRoute = dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>),
|
_releasePrivateRoute = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Pointer<Utf8>),
|
||||||
_ReleasePrivateRouteDart>('release_private_route'),
|
_ReleasePrivateRouteDart>('release_private_route'),
|
||||||
_appCallReply = dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>), _AppCallReplyDart>(
|
_appCallReply = dylib.lookupFunction<
|
||||||
'app_call_reply'),
|
Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_openTableDb = dylib
|
_AppCallReplyDart>('app_call_reply'),
|
||||||
.lookupFunction<Void Function(Int64, Pointer<Utf8>, Uint32), _OpenTableDbDart>('open_table_db'),
|
_openTableDb = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Pointer<Utf8>, Uint32),
|
||||||
|
_OpenTableDbDart>('open_table_db'),
|
||||||
_releaseTableDb =
|
_releaseTableDb =
|
||||||
dylib.lookupFunction<Int32 Function(Uint32), _ReleaseTableDbDart>(
|
dylib.lookupFunction<Int32 Function(Uint32), _ReleaseTableDbDart>(
|
||||||
'release_table_db'),
|
'release_table_db'),
|
||||||
_deleteTableDb =
|
_deleteTableDb = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>), _DeleteTableDbDart>(
|
Void Function(Int64, Pointer<Utf8>),
|
||||||
'delete_table_db'),
|
_DeleteTableDbDart>('delete_table_db'),
|
||||||
_tableDbGetColumnCount = dylib.lookupFunction<Uint32 Function(Uint32),
|
_tableDbGetColumnCount = dylib.lookupFunction<Uint32 Function(Uint32),
|
||||||
_TableDbGetColumnCountDart>('table_db_get_column_count'),
|
_TableDbGetColumnCountDart>('table_db_get_column_count'),
|
||||||
_tableDbGetKeys =
|
_tableDbGetKeys = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Pointer<Utf8> Function(Uint64, Uint32, Uint32), _TableDbGetKeysDart>(
|
Pointer<Utf8> Function(Uint64, Uint32, Uint32),
|
||||||
'table_db_get_keys'),
|
_TableDbGetKeysDart>('table_db_get_keys'),
|
||||||
_tableDbStore = dylib.lookupFunction<Void Function(Int64, Uint32, Uint32, Pointer<Utf8>, Pointer<Utf8>), _TableDbStoreDart>(
|
_tableDbStore = dylib.lookupFunction<
|
||||||
'table_db_store'),
|
Void Function(Int64, Uint32, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_tableDbLoad = dylib
|
_TableDbStoreDart>('table_db_store'),
|
||||||
.lookupFunction<Void Function(Int64, Uint32, Uint32, Pointer<Utf8>), _TableDbLoadDart>('table_db_load'),
|
_tableDbLoad = dylib.lookupFunction<
|
||||||
_tableDbDelete =
|
Void Function(Int64, Uint32, Uint32, Pointer<Utf8>),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Uint32, Pointer<Utf8>), _TableDbDeleteDart>(
|
_TableDbLoadDart>('table_db_load'),
|
||||||
'table_db_delete'),
|
_tableDbDelete = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Uint32, Uint32, Pointer<Utf8>),
|
||||||
|
_TableDbDeleteDart>('table_db_delete'),
|
||||||
_tableDbTransact =
|
_tableDbTransact =
|
||||||
dylib.lookupFunction<Uint32 Function(Uint32), _TableDbTransactDart>(
|
dylib.lookupFunction<Uint32 Function(Uint32), _TableDbTransactDart>(
|
||||||
'table_db_transact'),
|
'table_db_transact'),
|
||||||
@ -1250,83 +1251,89 @@ class VeilidFFI extends Veilid {
|
|||||||
_tableDbTransactionDelete = dylib.lookupFunction<
|
_tableDbTransactionDelete = dylib.lookupFunction<
|
||||||
Void Function(Int64, Uint32, Uint32, Pointer<Utf8>),
|
Void Function(Int64, Uint32, Uint32, Pointer<Utf8>),
|
||||||
_TableDbTransactionDeleteDart>('table_db_transaction_delete'),
|
_TableDbTransactionDeleteDart>('table_db_transaction_delete'),
|
||||||
_validCryptoKinds =
|
_validCryptoKinds = dylib.lookupFunction<Pointer<Utf8> Function(),
|
||||||
dylib.lookupFunction<Pointer<Utf8> Function(), _ValidCryptoKindsDart>(
|
_ValidCryptoKindsDart>('valid_crypto_kinds'),
|
||||||
'valid_crypto_kinds'),
|
|
||||||
_bestCryptoKind =
|
_bestCryptoKind =
|
||||||
dylib.lookupFunction<Uint32 Function(), _BestCryptoKindDart>(
|
dylib.lookupFunction<Uint32 Function(), _BestCryptoKindDart>(
|
||||||
'best_crypto_kind'),
|
'best_crypto_kind'),
|
||||||
_verifySignatures =
|
_verifySignatures = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>), _VerifySignaturesDart>(
|
Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
'verify_signatures'),
|
_VerifySignaturesDart>('verify_signatures'),
|
||||||
_generateSignatures =
|
_generateSignatures = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>), _GenerateSignaturesDart>(
|
Void Function(Int64, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
'generate_signatures'),
|
_GenerateSignaturesDart>('generate_signatures'),
|
||||||
_generateKeyPair =
|
_generateKeyPair = dylib.lookupFunction<Void Function(Int64, Uint32),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32), _GenerateKeyPairDart>(
|
_GenerateKeyPairDart>('generate_key_pair'),
|
||||||
'generate_key_pair'),
|
_cryptoCachedDH = dylib.lookupFunction<
|
||||||
_cryptoCachedDH =
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>), _CryptoCachedDHDart>(
|
_CryptoCachedDHDart>('crypto_cached_dh'),
|
||||||
'crypto_cached_dh'),
|
_cryptoComputeDH = dylib.lookupFunction<
|
||||||
_cryptoComputeDH =
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>), _CryptoComputeDHDart>(
|
_CryptoComputeDHDart>('crypto_compute_dh'),
|
||||||
'crypto_compute_dh'),
|
_cryptoRandomBytes = dylib.lookupFunction<
|
||||||
_cryptoRandomBytes =
|
Void Function(Int64, Uint32, Uint32),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Uint32), _CryptoRandomBytesDart>(
|
_CryptoRandomBytesDart>('crypto_random_bytes'),
|
||||||
'crypto_random_bytes'),
|
|
||||||
_cryptoDefaultSaltLength = dylib.lookupFunction<
|
_cryptoDefaultSaltLength = dylib.lookupFunction<
|
||||||
Void Function(Int64, Uint32),
|
Void Function(Int64, Uint32),
|
||||||
_CryptoDefaultSaltLengthDart>('crypto_default_salt_length'),
|
_CryptoDefaultSaltLengthDart>('crypto_default_salt_length'),
|
||||||
_cryptoHashPassword =
|
_cryptoHashPassword = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>), _CryptoHashPasswordDart>(
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
'crypto_hash_password'),
|
_CryptoHashPasswordDart>('crypto_hash_password'),
|
||||||
_cryptoVerifyPassword = dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
_cryptoVerifyPassword = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_CryptoVerifyPasswordDart>('crypto_verify_password'),
|
_CryptoVerifyPasswordDart>('crypto_verify_password'),
|
||||||
_cryptoDeriveSharedSecret = dylib.lookupFunction<
|
_cryptoDeriveSharedSecret = dylib.lookupFunction<
|
||||||
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_CryptoVerifyPasswordDart>('crypto_derive_shared_secret'),
|
_CryptoVerifyPasswordDart>('crypto_derive_shared_secret'),
|
||||||
_cryptoRandomNonce =
|
_cryptoRandomNonce = dylib.lookupFunction<Void Function(Int64, Uint32),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32), _CryptoRandomNonceDart>(
|
_CryptoRandomNonceDart>('crypto_random_nonce'),
|
||||||
'crypto_random_nonce'),
|
|
||||||
_cryptoRandomSharedSecret = dylib.lookupFunction<
|
_cryptoRandomSharedSecret = dylib.lookupFunction<
|
||||||
Void Function(Int64, Uint32),
|
Void Function(Int64, Uint32),
|
||||||
_CryptoRandomSharedSecretDart>('crypto_random_shared_secret'),
|
_CryptoRandomSharedSecretDart>('crypto_random_shared_secret'),
|
||||||
_cryptoGenerateKeyPair = dylib.lookupFunction<Void Function(Int64, Uint32),
|
_cryptoGenerateKeyPair = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Uint32),
|
||||||
_CryptoGenerateKeyPairDart>('crypto_generate_key_pair'),
|
_CryptoGenerateKeyPairDart>('crypto_generate_key_pair'),
|
||||||
_cryptoGenerateHash =
|
_cryptoGenerateHash = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>), _CryptoGenerateHashDart>(
|
Void Function(Int64, Uint32, Pointer<Utf8>),
|
||||||
'crypto_generate_hash'),
|
_CryptoGenerateHashDart>('crypto_generate_hash'),
|
||||||
_cryptoValidateKeyPair = dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
_cryptoValidateKeyPair = dylib.lookupFunction<
|
||||||
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_CryptoValidateKeyPairDart>('crypto_validate_key_pair'),
|
_CryptoValidateKeyPairDart>('crypto_validate_key_pair'),
|
||||||
_cryptoValidateHash =
|
_cryptoValidateHash = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>), _CryptoValidateHashDart>(
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
'crypto_validate_hash'),
|
_CryptoValidateHashDart>('crypto_validate_hash'),
|
||||||
_cryptoDistance =
|
_cryptoDistance = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>), _CryptoDistanceDart>(
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
'crypto_distance'),
|
_CryptoDistanceDart>('crypto_distance'),
|
||||||
_cryptoSign =
|
_cryptoSign = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>), _CryptoSignDart>('crypto_sign'),
|
Void Function(
|
||||||
_cryptoVerify = dylib
|
Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>), _CryptoVerifyDart>('crypto_verify'),
|
_CryptoSignDart>('crypto_sign'),
|
||||||
_cryptoAeadOverhead =
|
_cryptoVerify = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32), _CryptoAeadOverheadDart>(
|
Void Function(
|
||||||
'crypto_aead_overhead'),
|
Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_cryptoDecryptAead =
|
_CryptoVerifyDart>('crypto_verify'),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>), _CryptoDecryptAeadDart>(
|
_cryptoAeadOverhead = dylib.lookupFunction<Void Function(Int64, Uint32),
|
||||||
'crypto_decrypt_aead'),
|
_CryptoAeadOverheadDart>('crypto_aead_overhead'),
|
||||||
_cryptoEncryptAead =
|
_cryptoDecryptAead = dylib.lookupFunction<
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>), _CryptoEncryptAeadDart>(
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>,
|
||||||
'crypto_encrypt_aead'),
|
Pointer<Utf8>, Pointer<Utf8>),
|
||||||
_cryptoCryptNoAuth =
|
_CryptoDecryptAeadDart>('crypto_decrypt_aead'),
|
||||||
dylib.lookupFunction<Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>), _CryptoCryptNoAuthDart>(
|
_cryptoEncryptAead = dylib.lookupFunction<
|
||||||
'crypto_crypt_no_auth'),
|
Void Function(Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>,
|
||||||
|
Pointer<Utf8>, Pointer<Utf8>),
|
||||||
|
_CryptoEncryptAeadDart>('crypto_encrypt_aead'),
|
||||||
|
_cryptoCryptNoAuth = dylib.lookupFunction<
|
||||||
|
Void Function(
|
||||||
|
Int64, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>),
|
||||||
|
_CryptoCryptNoAuthDart>('crypto_crypt_no_auth'),
|
||||||
_now = dylib.lookupFunction<Uint64 Function(), _NowDart>('now'),
|
_now = dylib.lookupFunction<Uint64 Function(), _NowDart>('now'),
|
||||||
_debug = dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>), _DebugDart>('debug'),
|
_debug = dylib.lookupFunction<Void Function(Int64, Pointer<Utf8>),
|
||||||
|
_DebugDart>('debug'),
|
||||||
_veilidVersionString = dylib.lookupFunction<Pointer<Utf8> Function(),
|
_veilidVersionString = dylib.lookupFunction<Pointer<Utf8> Function(),
|
||||||
_VeilidVersionStringDart>('veilid_version_string'),
|
_VeilidVersionStringDart>('veilid_version_string'),
|
||||||
_veilidVersion =
|
_veilidVersion = dylib.lookupFunction<VeilidVersionFFI Function(),
|
||||||
dylib.lookupFunction<VeilidVersionFFI Function(), _VeilidVersionDart>(
|
_VeilidVersionDart>('veilid_version') {
|
||||||
'veilid_version') {
|
|
||||||
// Get veilid_flutter initializer
|
// Get veilid_flutter initializer
|
||||||
final initializeVeilidFlutter = _dylib.lookupFunction<
|
final initializeVeilidFlutter = _dylib.lookupFunction<
|
||||||
Void Function(Pointer<_DartPostCObject>),
|
Void Function(Pointer<_DartPostCObject>),
|
||||||
@ -1397,7 +1404,8 @@ class VeilidFFI extends Veilid {
|
|||||||
final _CryptoDefaultSaltLengthDart _cryptoDefaultSaltLength;
|
final _CryptoDefaultSaltLengthDart _cryptoDefaultSaltLength;
|
||||||
final _CryptoHashPasswordDart _cryptoHashPassword;
|
final _CryptoHashPasswordDart _cryptoHashPassword;
|
||||||
final _CryptoVerifyPasswordDart _cryptoVerifyPassword;
|
final _CryptoVerifyPasswordDart _cryptoVerifyPassword;
|
||||||
final void Function(int, int, Pointer<Utf8>, Pointer<Utf8>) _cryptoDeriveSharedSecret;
|
final void Function(int, int, Pointer<Utf8>, Pointer<Utf8>)
|
||||||
|
_cryptoDeriveSharedSecret;
|
||||||
|
|
||||||
final _CryptoRandomNonceDart _cryptoRandomNonce;
|
final _CryptoRandomNonceDart _cryptoRandomNonce;
|
||||||
final _CryptoRandomSharedSecretDart _cryptoRandomSharedSecret;
|
final _CryptoRandomSharedSecretDart _cryptoRandomSharedSecret;
|
||||||
@ -1432,8 +1440,9 @@ class VeilidFFI extends Veilid {
|
|||||||
final nativeLogLevel = jsonEncode(logLevel).toNativeUtf8();
|
final nativeLogLevel = jsonEncode(logLevel).toNativeUtf8();
|
||||||
final nativeLayer = layer.toNativeUtf8();
|
final nativeLayer = layer.toNativeUtf8();
|
||||||
_changeLogLevel(nativeLayer, nativeLogLevel);
|
_changeLogLevel(nativeLayer, nativeLogLevel);
|
||||||
malloc.free(nativeLayer);
|
malloc
|
||||||
malloc.free(nativeLogLevel);
|
..free(nativeLayer)
|
||||||
|
..free(nativeLogLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1488,7 +1497,7 @@ class VeilidFFI extends Veilid {
|
|||||||
final recvPort = ReceivePort('routing_context');
|
final recvPort = ReceivePort('routing_context');
|
||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_routingContext(sendPort.nativePort);
|
_routingContext(sendPort.nativePort);
|
||||||
final id = await processFuturePlain(recvPort.first);
|
final id = await processFuturePlain<int>(recvPort.first);
|
||||||
return VeilidRoutingContextFFI._(_Ctx(id, this));
|
return VeilidRoutingContextFFI._(_Ctx(id, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1548,7 +1557,7 @@ class VeilidFFI extends Veilid {
|
|||||||
final recvPort = ReceivePort('open_table_db');
|
final recvPort = ReceivePort('open_table_db');
|
||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_openTableDb(sendPort.nativePort, name.toNativeUtf8(), columnCount);
|
_openTableDb(sendPort.nativePort, name.toNativeUtf8(), columnCount);
|
||||||
final id = await processFuturePlain(recvPort.first);
|
final id = await processFuturePlain<int>(recvPort.first);
|
||||||
return VeilidTableDBFFI._(_TDB(id, this));
|
return VeilidTableDBFFI._(_TDB(id, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1557,8 +1566,7 @@ class VeilidFFI extends Veilid {
|
|||||||
final recvPort = ReceivePort('delete_table_db');
|
final recvPort = ReceivePort('delete_table_db');
|
||||||
final sendPort = recvPort.sendPort;
|
final sendPort = recvPort.sendPort;
|
||||||
_deleteTableDb(sendPort.nativePort, name.toNativeUtf8());
|
_deleteTableDb(sendPort.nativePort, name.toNativeUtf8());
|
||||||
final deleted = await processFuturePlain(recvPort.first);
|
return await processFuturePlain(recvPort.first);
|
||||||
return deleted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1578,7 +1586,8 @@ class VeilidFFI extends Veilid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<VeilidCryptoSystem> bestCryptoSystem() async => VeilidCryptoSystemFFI._(this, _bestCryptoKind());
|
Future<VeilidCryptoSystem> bestCryptoSystem() async =>
|
||||||
|
VeilidCryptoSystemFFI._(this, _bestCryptoKind());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<TypedKey>> verifySignatures(List<TypedKey> nodeIds,
|
Future<List<TypedKey>> verifySignatures(List<TypedKey> nodeIds,
|
||||||
|
@ -14,11 +14,13 @@ Veilid getVeilid() => VeilidJS();
|
|||||||
Object wasm = js_util.getProperty(html.window, 'veilid_wasm');
|
Object wasm = js_util.getProperty(html.window, 'veilid_wasm');
|
||||||
|
|
||||||
Future<T> _wrapApiPromise<T>(Object p) => js_util
|
Future<T> _wrapApiPromise<T>(Object p) => js_util
|
||||||
.promiseToFuture<T>(p)
|
.promiseToFuture<T>(p)
|
||||||
.then((value) => value)
|
.then((value) => value)
|
||||||
// ignore: inference_failure_on_untyped_parameter
|
// ignore: inference_failure_on_untyped_parameter
|
||||||
.catchError((error) => Future<T>.error(
|
.catchError((e) {
|
||||||
VeilidAPIException.fromJson(jsonDecode(error as String))));
|
// Wrap all other errors in VeilidAPIExceptionInternal
|
||||||
|
throw VeilidAPIExceptionInternal(e.toString());
|
||||||
|
}, test: (e) => e is! VeilidAPIException);
|
||||||
|
|
||||||
class _Ctx {
|
class _Ctx {
|
||||||
_Ctx(int this.id, this.js);
|
_Ctx(int this.id, this.js);
|
||||||
|
Loading…
Reference in New Issue
Block a user