massReencrypt method

SealdMassReencryptResponse massReencrypt(
  1. String deviceId, {
  2. int retries = 3,
  3. int retrieveBatchSize = 1000,
  4. Duration waitBetweenRetries = const Duration(seconds: 3),
  5. bool waitProvisioning = true,
  6. Duration waitProvisioningTime = const Duration(seconds: 5),
  7. Duration waitProvisioningTimeMax = const Duration(seconds: 10),
  8. Duration waitProvisioningTimeStep = const Duration(seconds: 1),
  9. int waitProvisioningRetries = 100,
  10. bool forceLocalAccountUpdate = false,
})

Retrieve, re-encrypt, and add missing keys for a certain device.

deviceId - The ID of the device for which to re-rencrypt. retries - Number of times to retry. Defaults to 3. retrieveBatchSize - Defaults to 1000. waitBetweenRetries - Time to wait between retries. Defaults to 3 seconds. waitProvisioning - Whether to wait for provisioning (new behaviour) or not. true to wait, false to not wait. Defaults to true. waitProvisioningTime - Time to wait if device is not provisioned on the server yet. The actual wait time will be increased on subsequent tries, by waitProvisioningTimeStep, up to waitProvisioningTimeMax. Defaults to 5 seconds. waitProvisioningTimeMax - Maximum time to wait if device is not provisioned on the server yet. Defaults to 10 seconds. waitProvisioningTimeStep - Amount to increase the time to wait if device is not provisioned on the server yet. Defaults to 1 second. waitProvisioningRetries - Maximum number of tries to check if the device is provisioned yet. Defaults to 100. forceLocalAccountUpdate - Whether to update the local account before trying the reencryption. true to update, false to not update. Defaults to false. Returns a SealdMassReencryptResponse instance, which will be populated with the number of re-encrypted keys, and the number of keys for which re-encryption failed.

Implementation

SealdMassReencryptResponse massReencrypt(String deviceId,
    {int retries = 3,
    int retrieveBatchSize = 1000,
    Duration waitBetweenRetries = const Duration(seconds: 3),
    bool waitProvisioning = true,
    Duration waitProvisioningTime = const Duration(seconds: 5),
    Duration waitProvisioningTimeMax = const Duration(seconds: 10),
    Duration waitProvisioningTimeStep = const Duration(seconds: 1),
    int waitProvisioningRetries = 100,
    bool forceLocalAccountUpdate = false}) {
  if (_closed) {
    throw SealdException(
        code: "INSTANCE_CLOSED",
        id: "FLUTTER_INSTANCE_CLOSED",
        description: "Instance already closed.");
  }
  final Pointer<Utf8> nativeDeviceId = deviceId.toNativeUtf8();
  final Pointer<NativeSealdMassReencryptOptions> options =
      calloc<NativeSealdMassReencryptOptions>();
  options.ref
    ..Retries = retries
    ..RetrieveBatchSize = retrieveBatchSize
    ..WaitBetweenRetries = waitBetweenRetries.inMilliseconds
    ..WaitProvisioning = waitProvisioning ? 1 : 0
    ..WaitProvisioningTime = waitProvisioningTime.inMilliseconds
    ..WaitProvisioningTimeMax = waitProvisioningTimeMax.inMilliseconds
    ..WaitProvisioningTimeStep = waitProvisioningTimeStep.inMilliseconds
    ..WaitProvisioningRetries = waitProvisioningRetries
    ..ForceLocalAccountUpdate = forceLocalAccountUpdate ? 1 : 0;
  final Pointer<NativeSealdMassReencryptResponse> result =
      calloc<NativeSealdMassReencryptResponse>();
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode = _bindings.SealdSdk_MassReencrypt(
      _ptr.pointer(), nativeDeviceId, options.ref, result, err);

  calloc.free(nativeDeviceId);
  calloc.free(options);

  if (resultCode != 0) {
    calloc.free(result);
    throw SealdException._fromCPtr(err);
  } else {
    final SealdMassReencryptResponse response =
        SealdMassReencryptResponse._fromC(result);
    calloc.free(err);
    return response;
  }
}