Skip to content

Commit

Permalink
Added SDK and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abergs committed Aug 3, 2023
1 parent bd96715 commit 5f63378
Show file tree
Hide file tree
Showing 23 changed files with 720 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Passwordless-dotnet.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sdk.Tests", "Tests\Sdk.Tests\Sdk.Tests.csproj", "{F64C850E-9923-43F1-BC84-432AFBBA4425}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sdk", "src\Sdk\Sdk.csproj", "{A01503A8-6AB9-43A7-AC5A-4EAE091B07B6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F64C850E-9923-43F1-BC84-432AFBBA4425}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F64C850E-9923-43F1-BC84-432AFBBA4425}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F64C850E-9923-43F1-BC84-432AFBBA4425}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F64C850E-9923-43F1-BC84-432AFBBA4425}.Release|Any CPU.Build.0 = Release|Any CPU
{A01503A8-6AB9-43A7-AC5A-4EAE091B07B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A01503A8-6AB9-43A7-AC5A-4EAE091B07B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A01503A8-6AB9-43A7-AC5A-4EAE091B07B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A01503A8-6AB9-43A7-AC5A-4EAE091B07B6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions src/Sdk/Helpers/Json.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Text.Json;

namespace Passwordless.Net.Helpers;

internal static class Json
{
public static readonly JsonSerializerOptions Options = new(JsonSerializerDefaults.Web);
}
8 changes: 8 additions & 0 deletions src/Sdk/Models/AliasPointer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Passwordless.Net;

public class AliasPointer
{
public string UserId { get; set; }
public string Alias { get; set; }
public string Plaintext { get; set; }
}
9 changes: 9 additions & 0 deletions src/Sdk/Models/AuditLog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Passwordless.Net;

public class AuditLog
{
public DateTime Timestamp { get; set; }
public string Level { get; set; }
public string Message { get; set; }
public string Details { get; set; }
}
19 changes: 19 additions & 0 deletions src/Sdk/Models/Credential.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Passwordless.Net;

public class Credential
{
public CredentialDescriptor Descriptor { get; set; }
public byte[] PublicKey { get; set; }
public byte[] UserHandle { get; set; }
public uint SignatureCounter { get; set; }
public string AttestationFmt { get; set; }
public DateTime CreatedAt { get; set; }
public Guid AaGuid { get; set; }
public DateTime LastUsedAt { get; set; }
public string RPID { get; set; }
public string Origin { get; set; }
public string Country { get; set; }
public string Device { get; set; }
public string Nickname { get; set; }
public string UserId { get; set; }
}
11 changes: 11 additions & 0 deletions src/Sdk/Models/CredentialDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Text.Json.Serialization;

using static Passwordless.Net.PasswordlessClient;

namespace Passwordless.Net;

public class CredentialDescriptor
{
[JsonConverter(typeof(Base64UrlConverter))]
public byte[] Id { get; set; }
}
7 changes: 7 additions & 0 deletions src/Sdk/Models/NewAppOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Passwordless.Net;

public class NewAppOptions
{
public string AppId { get; set; } = "";
public string AdminEmail { get; set; } = "";
}
10 changes: 10 additions & 0 deletions src/Sdk/Models/NewAppResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Passwordless.Net;

public class NewAppResponse
{
public string Message { get; set; }
public string ApiKey1 { get; set; }
public string ApiKey2 { get; set; }
public string ApiSecret1 { get; set; }
public string ApiSecret2 { get; set; }
}
10 changes: 10 additions & 0 deletions src/Sdk/Models/PasswordlessUserSummary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Passwordless.Net;

public class PasswordlessUserSummary
{
public string UserId { get; set; }
public List<string> Aliases { get; set; }
public int CredentialsCount { get; set; }
public int AliasCount { get; set; }
public DateTime LastUsedAt { get; set; }
}
16 changes: 16 additions & 0 deletions src/Sdk/Models/RegisterOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Passwordless.Net;

public class RegisterOptions
{
public required string UserId { get; set; }
public string? DisplayName { get; set; }
public required string Username { get; set; }
public string Attestation { get; set; }
public string AuthenticatorType { get; set; }
public bool Discoverable { get; set; }
public string UserVerification { get; set; }
public HashSet<string>? Aliases { get; set; }
public bool AliasHashing { get; set; }

public DateTime ExpiresAt { get; set; }
}
6 changes: 6 additions & 0 deletions src/Sdk/Models/UsersCount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Passwordless.Net;

public class UsersCount
{
public int Count { get; set; }
}
17 changes: 17 additions & 0 deletions src/Sdk/Models/VerifiedUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Passwordless.Net;

public class VerifiedUser
{
public string UserId { get; set; }
public byte[] CredentialId { get; set; }
public bool Success { get; set; }
public DateTime Timestamp { get; set; }
public string RpId { get; set; }
public string Origin { get; set; }
public string Device { get; set; }
public string Country { get; set; }
public string Nickname { get; set; }
public DateTime ExpiresAt { get; set; }
public Guid TokenId { get; set; }
public string Type { get; set; }
}
27 changes: 27 additions & 0 deletions src/Sdk/PasswordlessApiException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Text.Json.Serialization;

namespace Passwordless.Net;

public sealed class PasswordlessApiException : HttpRequestException
{
public ProblemDetails Details { get; }

public PasswordlessApiException(ProblemDetails problemDetails) : base(problemDetails.Title)
{
Details = problemDetails;
}
}

public class ProblemDetails
{
// TODO: Make immutable
// TODO: Include errorCode as a property once it's more common
public string Type { get; set; } = null!;
public string Title { get; set; } = null!;
public int Status { get; set; }
public string? Detail { get; set; }
public string? Instance { get; set; }

[JsonExtensionData]
public Dictionary<string, object?> Extensions { get; set; }
}
Loading

0 comments on commit 5f63378

Please sign in to comment.