unified code verification service
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'package:pshared/models/confirmation_target.dart';
|
||||
import 'package:pshared/api/requests/tokens/session_identifier.dart';
|
||||
|
||||
part 'login_confirmation.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class LoginConfirmationRequest {
|
||||
final ConfirmationTarget target;
|
||||
final String? destination;
|
||||
|
||||
const LoginConfirmationRequest({
|
||||
this.target = ConfirmationTarget.login,
|
||||
this.destination,
|
||||
});
|
||||
|
||||
factory LoginConfirmationRequest.fromJson(Map<String, dynamic> json) => _$LoginConfirmationRequestFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$LoginConfirmationRequestToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class LoginConfirmationVerifyRequest {
|
||||
final ConfirmationTarget target;
|
||||
final String code;
|
||||
final String? destination;
|
||||
final SessionIdentifierDto sessionIdentifier;
|
||||
|
||||
const LoginConfirmationVerifyRequest({
|
||||
this.target = ConfirmationTarget.login,
|
||||
required this.code,
|
||||
this.destination,
|
||||
required this.sessionIdentifier,
|
||||
});
|
||||
|
||||
factory LoginConfirmationVerifyRequest.fromJson(Map<String, dynamic> json) => _$LoginConfirmationVerifyRequestFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$LoginConfirmationVerifyRequestToJson(this);
|
||||
}
|
||||
@@ -4,15 +4,15 @@ part 'session_identifier.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable()
|
||||
class SessionIdentifierDto {
|
||||
class SessionIdentifierDTO {
|
||||
final String clientId;
|
||||
final String deviceId;
|
||||
|
||||
const SessionIdentifierDto({
|
||||
const SessionIdentifierDTO({
|
||||
required this.clientId,
|
||||
required this.deviceId,
|
||||
});
|
||||
|
||||
factory SessionIdentifierDto.fromJson(Map<String, dynamic> json) => _$SessionIdentifierDtoFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SessionIdentifierDtoToJson(this);
|
||||
factory SessionIdentifierDTO.fromJson(Map<String, dynamic> json) => _$SessionIdentifierDTOFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SessionIdentifierDTOToJson(this);
|
||||
}
|
||||
|
||||
41
frontend/pshared/lib/api/requests/verification/login.dart
Normal file
41
frontend/pshared/lib/api/requests/verification/login.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import 'package:pshared/models/verification/purpose.dart';
|
||||
import 'package:pshared/api/requests/tokens/session_identifier.dart';
|
||||
|
||||
part 'login.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class LoginVerificationRequest {
|
||||
final VerificationPurpose purpose;
|
||||
final String? target;
|
||||
final String idempotencyKey;
|
||||
|
||||
const LoginVerificationRequest({
|
||||
this.purpose = VerificationPurpose.login,
|
||||
this.target,
|
||||
required this.idempotencyKey,
|
||||
});
|
||||
|
||||
factory LoginVerificationRequest.fromJson(Map<String, dynamic> json) => _$LoginVerificationRequestFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$LoginVerificationRequestToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class LoginCodeVerifyicationRequest extends LoginVerificationRequest {
|
||||
final String code;
|
||||
final SessionIdentifierDTO sessionIdentifier;
|
||||
|
||||
const LoginCodeVerifyicationRequest({
|
||||
super.purpose = VerificationPurpose.login,
|
||||
super.target,
|
||||
required super.idempotencyKey,
|
||||
required this.code,
|
||||
required this.sessionIdentifier,
|
||||
});
|
||||
|
||||
factory LoginCodeVerifyicationRequest.fromJson(Map<String, dynamic> json) => _$LoginCodeVerifyicationRequestFromJson(json);
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$LoginCodeVerifyicationRequestToJson(this);
|
||||
}
|
||||
22
frontend/pshared/lib/api/requests/verification/resend.dart
Normal file
22
frontend/pshared/lib/api/requests/verification/resend.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'resend.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable()
|
||||
class ResendVerificationEmailRequest {
|
||||
final String login;
|
||||
|
||||
const ResendVerificationEmailRequest({
|
||||
required this.login,
|
||||
});
|
||||
|
||||
factory ResendVerificationEmailRequest.fromJson(Map<String, dynamic> json) => _$ResendVerificationEmailRequestFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ResendVerificationEmailRequestToJson(this);
|
||||
|
||||
static ResendVerificationEmailRequest build({
|
||||
required String login,
|
||||
}) => ResendVerificationEmailRequest(login: login);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,11 @@ class PendingLoginResponse {
|
||||
final AccountResponse account;
|
||||
final TokenData pendingToken;
|
||||
final String destination;
|
||||
final int ttlSeconds;
|
||||
|
||||
const PendingLoginResponse({
|
||||
required this.account,
|
||||
required this.pendingToken,
|
||||
required this.destination,
|
||||
required this.ttlSeconds,
|
||||
});
|
||||
|
||||
factory PendingLoginResponse.fromJson(Map<String, dynamic> json) => _$PendingLoginResponseFromJson(json);
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'confirmation.g.dart';
|
||||
part 'response.g.dart';
|
||||
|
||||
|
||||
@JsonSerializable()
|
||||
class ConfirmationResponse {
|
||||
class VerificationResponse {
|
||||
@JsonKey(name: 'ttl_seconds', defaultValue: 0)
|
||||
final int ttlSeconds;
|
||||
@JsonKey(name: 'cooldown_seconds', defaultValue: 0)
|
||||
final int cooldownSeconds;
|
||||
@JsonKey(defaultValue: '')
|
||||
final String destination;
|
||||
final String idempotencyKey;
|
||||
|
||||
const ConfirmationResponse({
|
||||
const VerificationResponse({
|
||||
required this.ttlSeconds,
|
||||
required this.cooldownSeconds,
|
||||
required this.destination,
|
||||
required this.idempotencyKey,
|
||||
});
|
||||
|
||||
Duration get cooldownDuration => Duration(seconds: cooldownSeconds);
|
||||
Duration get ttlDuration => Duration(seconds: ttlSeconds);
|
||||
|
||||
factory ConfirmationResponse.fromJson(Map<String, dynamic> json) => _$ConfirmationResponseFromJson(json);
|
||||
factory VerificationResponse.fromJson(Map<String, dynamic> json) => _$VerificationResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ConfirmationResponseToJson(this);
|
||||
Map<String, dynamic> toJson() => _$VerificationResponseToJson(this);
|
||||
}
|
||||
Reference in New Issue
Block a user