convertTmrAccesses method
SealdConvertTmrAccessesResult
convertTmrAccesses(
- String tmrJWT,
- Uint8List overEncryptionKey, {
- SealdTmrAccessesConvertFilters? conversionFilters,
- bool deleteOnConvert = true,
Convert all TMR Accesses addressed to a given auth factor and matching specified filters to classic message keys.
All TMR accesses matching the specified filters must have been encrypted with the same overEncryptionKey
.
tmrJWT
- The TMR JWT.
overEncryptionKey
- The TMR over-encryption key. This MUST be a cryptographically random buffer of 64 bytes.
conversionFilters
- Convert tmr accesses filters. If multiple TMR Accesses with the auth factor, filter out the unwanted ones.
deleteOnConvert
- Whether or not to delete the TMR access after conversion.
Returns the retrieved SealdConvertTmrAccessesResult instance.
Implementation
SealdConvertTmrAccessesResult convertTmrAccesses(
String tmrJWT, Uint8List overEncryptionKey,
{SealdTmrAccessesConvertFilters? conversionFilters,
bool deleteOnConvert = true}) {
if (_closed) {
throw SealdException(
code: "INSTANCE_CLOSED",
id: "FLUTTER_INSTANCE_CLOSED",
description: "Instance already closed.");
}
final Pointer<Utf8> nativeTmrJWT = tmrJWT.toNativeUtf8();
final int deleteOnConvertInt = deleteOnConvert ? 1 : 0;
final Pointer<NativeSealdTmrAccessesConvertFilters> nativeFilters =
conversionFilters?._toC() ?? nullptr;
// Dart FFI forces us to copy the data from Uint8List to a newly allocated Pointer<Uint8>
final Pointer<Uint8> nativeOverEncryptionKey =
calloc<Uint8>(overEncryptionKey.length);
final pointerListOverEncryptionKey =
nativeOverEncryptionKey.asTypedList(overEncryptionKey.length);
pointerListOverEncryptionKey.setAll(0, overEncryptionKey);
final Pointer<Pointer<NativeSealdConvertTmrAccessesResult>> result =
calloc<Pointer<NativeSealdConvertTmrAccessesResult>>();
final Pointer<Pointer<NativeSealdError>> err =
calloc<Pointer<NativeSealdError>>();
final int resultCode = _bindings.SealdSdk_ConvertTmrAccesses(
_ptr.pointer(),
nativeTmrJWT,
nativeOverEncryptionKey,
overEncryptionKey.length,
nativeFilters,
deleteOnConvertInt,
result,
err);
calloc.free(nativeTmrJWT);
calloc.free(nativeOverEncryptionKey);
_bindings.SealdTmrAccessesConvertFilters_Free(nativeFilters);
if (resultCode != 0) {
calloc.free(result);
throw SealdException._fromCPtr(err);
} else {
final SealdConvertTmrAccessesResult conversionResult =
SealdConvertTmrAccessesResult._fromC(result.value);
calloc.free(result);
calloc.free(err);
return conversionResult;
}
}