@@ -16,16 +16,10 @@ public static IFido2NetLibBuilder AddFido2(this IServiceCollection services, ICo
1616 services . AddSingleton (
1717 resolver => resolver . GetRequiredService < IOptions < Fido2Configuration > > ( ) . Value ) ;
1818
19- services . AddServices ( ) ;
20-
21- return new Fido2NetLibBuilder ( services ) ;
22- }
23-
24- private static void AddServices ( this IServiceCollection services )
25- {
2619 services . AddScoped < IFido2 , Fido2 > ( ) ;
27- services . AddSingleton < IMetadataService , NullMetadataService > ( ) ; //Default implementation if we choose not to enable MDS
2820 services . TryAddSingleton < ISystemClock , SystemClock > ( ) ;
21+
22+ return new Fido2NetLibBuilder ( services ) ;
2923 }
3024
3125 public static IFido2NetLibBuilder AddFido2 ( this IServiceCollection services , Action < Fido2Configuration > setupAction )
@@ -35,19 +29,27 @@ public static IFido2NetLibBuilder AddFido2(this IServiceCollection services, Act
3529 services . AddSingleton (
3630 resolver => resolver . GetRequiredService < IOptions < Fido2Configuration > > ( ) . Value ) ;
3731
38- services . AddServices ( ) ;
32+ services . AddScoped < IFido2 , Fido2 > ( ) ;
33+ services . TryAddSingleton < ISystemClock , SystemClock > ( ) ;
3934
4035 return new Fido2NetLibBuilder ( services ) ;
4136 }
42-
43- public static void AddCachedMetadataService ( this IFido2NetLibBuilder builder , Action < IFido2MetadataServiceBuilder > configAction )
37+
38+ public static IFido2NetLibBuilder AddMetadataService < T > ( this IFido2NetLibBuilder builder )
39+ where T : class , IMetadataService
40+ {
41+ builder . Services . AddScoped < IMetadataService , T > ( ) ;
42+ return builder ;
43+ }
44+
45+
46+ public static IFido2NetLibBuilder AddCachedMetadataService ( this IFido2NetLibBuilder builder )
4447 {
4548 builder . Services . AddScoped < IMetadataService , DistributedCacheMetadataService > ( ) ;
46-
47- configAction ( new Fido2NetLibBuilder ( builder . Services ) ) ;
49+ return builder ;
4850 }
4951
50- public static IFido2MetadataServiceBuilder AddFileSystemMetadataRepository ( this IFido2MetadataServiceBuilder builder , string directoryPath )
52+ public static IFido2NetLibBuilder AddFileSystemMetadataRepository ( this IFido2NetLibBuilder builder , string directoryPath )
5153 {
5254 builder . Services . AddScoped < IMetadataRepository , FileSystemMetadataRepository > ( provider =>
5355 {
@@ -57,8 +59,8 @@ public static IFido2MetadataServiceBuilder AddFileSystemMetadataRepository(this
5759 return builder ;
5860 }
5961
60- public static IFido2MetadataServiceBuilder AddConformanceMetadataRepository (
61- this IFido2MetadataServiceBuilder builder ,
62+ public static IFido2NetLibBuilder AddConformanceMetadataRepository (
63+ this IFido2NetLibBuilder builder ,
6264 HttpClient client = null ,
6365 string origin = "" )
6466 {
@@ -70,7 +72,7 @@ public static IFido2MetadataServiceBuilder AddConformanceMetadataRepository(
7072 return builder ;
7173 }
7274
73- public static IFido2MetadataServiceBuilder AddFidoMetadataRepository ( this IFido2MetadataServiceBuilder builder , Action < IHttpClientBuilder > clientBuilder = null )
75+ public static IFido2NetLibBuilder AddFidoMetadataRepository ( this IFido2NetLibBuilder builder , Action < IHttpClientBuilder > clientBuilder = null )
7476 {
7577 var httpClientBuilder = builder . Services . AddHttpClient ( nameof ( Fido2MetadataServiceRepository ) , client =>
7678 {
@@ -91,12 +93,7 @@ public interface IFido2NetLibBuilder
9193 IServiceCollection Services { get ; }
9294}
9395
94- public interface IFido2MetadataServiceBuilder
95- {
96- IServiceCollection Services { get ; }
97- }
98-
99- public class Fido2NetLibBuilder : IFido2NetLibBuilder , IFido2MetadataServiceBuilder
96+ public class Fido2NetLibBuilder : IFido2NetLibBuilder
10097{
10198 /// <summary>
10299 /// Initializes a new instance of the <see cref="Fido2NetLibBuilder"/> class.
0 commit comments