Identity Details Type Generation
The proxy generator can automatically discover and generate TypeScript types for your custom identity details. This enables type-safe access to identity information in your frontend application.
Overview
When you implement a strongly-typed identity details provider using IProvideIdentityDetails<TDetails>, the proxy generator will:
- Discover all implementations of
IProvideIdentityDetails<TDetails>in your assemblies - Extract the
TDetailstype parameter - Generate TypeScript representations of these types
- Include them in the standard proxy output alongside commands and queries
The Generic Interface
Arc provides a generic version of the identity details provider interface:
public interface IProvideIdentityDetails<TDetails> : IProvideIdentityDetails
where TDetails : class;
This interface extends the base IProvideIdentityDetails interface but adds type information that the proxy generator can discover and use.
For detailed information on implementing identity providers, see the Identity documentation.
How Discovery Works
The proxy generator scans all loaded assemblies for classes that:
- Are concrete (non-abstract) classes
- Implement
IProvideIdentityDetails<TDetails> - Have a valid type argument for
TDetails
The TDetails type is then processed like any other complex type, generating a corresponding TypeScript interface.
Generated Artifacts
For each identity details type discovered, the generator creates:
- TypeScript Interface: An interface matching the C# type structure
- Nested Types: Any complex types referenced by the details type
- Export Entry: Added to the appropriate
index.tsfile
Benefits of Using the Generic Interface
| Feature | IProvideIdentityDetails |
IProvideIdentityDetails<TDetails> |
|---|---|---|
| Runtime behavior | Identical | Identical |
| Type information | Lost at runtime | Captured for generation |
| Proxy generation | No type generated | TypeScript type generated |
| Frontend type safety | Manual typing required | Automatic type safety |
Best Practices
Use the Generic Interface: Always prefer
IProvideIdentityDetails<TDetails>over the base interface to enable proxy generation.Keep Types Simple: Identity details types should be simple DTOs without complex logic or dependencies.
Avoid Sensitive Data: Never include sensitive information like tokens or passwords in identity details.
Use Records: Consider using C# records for immutable identity detail types.
Frontend Integration
The generated TypeScript types can be used with the identity system in @cratis/arc/identity. The types ensure that your frontend code has compile-time type safety when accessing identity details.
For frontend usage patterns, see the @cratis/arc documentation.