Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

2.8 KB
Raw Blame
//-----------------------------------------------------------------------
// <copyright file="LoginInitiateResponse.cs" company="aliasvault">
// Copyright (c) aliasvault. All rights reserved.
// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
// </copyright>
//-----------------------------------------------------------------------

namespace AliasVault.Shared.Models.WebApi.V2.Auth;

using System.Text.Json.Serialization;

/// <summary>
/// Server answer to an SRP handshake: the stored salt, the server ephemeral and the key derivation parameters.
/// </summary>
public class LoginInitiateResponse
{
    /// <summary>
    /// Initializes a new instance of the <see cref="LoginInitiateResponse"/> class.
    /// </summary>
    /// <param name="salt">Salt.</param>
    /// <param name="serverEphemeral">Server ephemeral.</param>
    /// <param name="encryptionType">Encryption type.</param>
    /// <param name="encryptionSettings">Encryption settings.</param>
    /// <param name="srpIdentity">The SRP identity.</param>
    /// <param name="loginSessionId">The login session id, only set for a login.</param>
    public LoginInitiateResponse(string salt, string serverEphemeral, string encryptionType, string encryptionSettings, string srpIdentity, string? loginSessionId = null)
    {
        Salt = salt;
        ServerEphemeral = serverEphemeral;
        EncryptionType = encryptionType;
        EncryptionSettings = encryptionSettings;
        SrpIdentity = srpIdentity;
        LoginSessionId = loginSessionId;
    }

    /// <summary>
    /// Gets or sets the salt.
    /// </summary>
    [JsonPropertyName("salt")]
    public string Salt { get; set; }

    /// <summary>
    /// Gets or sets the server's public ephemeral value.
    /// </summary>
    [JsonPropertyName("serverEphemeral")]
    public string ServerEphemeral { get; set; }

    /// <summary>
    /// Gets or sets the encryption type.
    /// </summary>
    [JsonPropertyName("encryptionType")]
    public string EncryptionType { get; set; }

    /// <summary>
    /// Gets or sets the encryption settings.
    /// </summary>
    [JsonPropertyName("encryptionSettings")]
    public string EncryptionSettings { get; set; }

    /// <summary>
    /// Gets or sets the SRP identity to use for authentication. This is a fixed value that doesn't change
    /// even if the display username is updated. Clients should use this value (instead of the typed username)
    /// for all SRP operations.
    /// </summary>
    [JsonPropertyName("srpIdentity")]
    public string SrpIdentity { get; set; }

    /// <summary>
    /// Gets or sets the id of this login exchange, which the client sends back with its proof.
    /// </summary>
    [JsonPropertyName("loginSessionId")]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public string? LoginSessionId { get; set; }
}