2019-10-17 00:37:08 +02:00
|
|
|
package org.thoughtcrime.securesms.registration.service;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
2020-10-05 15:26:51 +02:00
|
|
|
import org.thoughtcrime.securesms.pin.PinRestoreRepository;
|
2019-12-03 18:31:23 +01:00
|
|
|
import org.whispersystems.signalservice.internal.contacts.entities.TokenResponse;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2019-10-17 00:37:08 +02:00
|
|
|
public final class RegistrationService {
|
|
|
|
|
|
|
|
private final Credentials credentials;
|
|
|
|
|
|
|
|
private RegistrationService(@NonNull Credentials credentials) {
|
|
|
|
this.credentials = credentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static RegistrationService getInstance(@NonNull String e164number, @NonNull String password) {
|
|
|
|
return new RegistrationService(new Credentials(e164number, password));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See {@link RegistrationCodeRequest}.
|
|
|
|
*/
|
|
|
|
public void requestVerificationCode(@NonNull Activity activity,
|
|
|
|
@NonNull RegistrationCodeRequest.Mode mode,
|
|
|
|
@Nullable String captchaToken,
|
|
|
|
@NonNull RegistrationCodeRequest.SmsVerificationCodeCallback callback)
|
|
|
|
{
|
|
|
|
RegistrationCodeRequest.requestSmsVerificationCode(activity, credentials, captchaToken, mode, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* See {@link CodeVerificationRequest}.
|
|
|
|
*/
|
|
|
|
public void verifyAccount(@NonNull Activity activity,
|
|
|
|
@Nullable String fcmToken,
|
|
|
|
@NonNull String code,
|
|
|
|
@Nullable String pin,
|
2020-10-05 15:26:51 +02:00
|
|
|
@Nullable PinRestoreRepository.TokenData tokenData,
|
2019-10-17 00:37:08 +02:00
|
|
|
@NonNull CodeVerificationRequest.VerifyCallback callback)
|
|
|
|
{
|
2020-10-05 15:26:51 +02:00
|
|
|
CodeVerificationRequest.verifyAccount(activity, credentials, fcmToken, code, pin, tokenData, callback);
|
2019-12-03 18:31:23 +01:00
|
|
|
}
|
2019-10-17 00:37:08 +02:00
|
|
|
}
|