changeIdentityPassword method

String changeIdentityPassword(
  1. String userId,
  2. String currentPassword,
  3. String newPassword
)

Change the password use to encrypt the identity for the userId.

userId - The ID of the user. currentPassword - The user's current password. newPassword - The new password.

Returns the new SSKS ID of the stored identity

Implementation

String changeIdentityPassword(
    String userId, String currentPassword, String newPassword) {
  final Pointer<Utf8> nativeUserId = userId.toNativeUtf8();
  final Pointer<Utf8> nativeCurrentPassword = currentPassword.toNativeUtf8();
  final Pointer<Utf8> nativeNewPassword = newPassword.toNativeUtf8();
  final Pointer<Pointer<Utf8>> result = calloc<Pointer<Utf8>>();
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode =
      _bindings.SealdSsksPasswordPlugin_ChangeIdentityPassword(
          _ptr.pointer(),
          nativeUserId,
          nativeCurrentPassword,
          nativeNewPassword,
          result,
          err);

  calloc.free(nativeUserId);
  calloc.free(nativeCurrentPassword);
  calloc.free(nativeNewPassword);

  if (resultCode != 0) {
    throw SealdException._fromCPtr(err);
  } else {
    final String res = result.value.toDartString();
    calloc.free(result.value);
    calloc.free(result);
    calloc.free(err);
    return res;
  }
}