AAuth 0.1.0-alpha.2

This is a prerelease version of AAuth.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package AAuth --version 0.1.0-alpha.2
                    
NuGet\Install-Package AAuth -Version 0.1.0-alpha.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AAuth" Version="0.1.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AAuth" Version="0.1.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="AAuth" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AAuth --version 0.1.0-alpha.2
                    
#r "nuget: AAuth, 0.1.0-alpha.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AAuth@0.1.0-alpha.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AAuth&version=0.1.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AAuth&version=0.1.0-alpha.2&prerelease
                    
Install as a Cake Tool

Getting Started

Prerequisites

Install

dotnet add package AAuth --prerelease

Or, if working within this repository, add a project reference:

dotnet add reference src/AAuth/AAuth.csproj

Generate a Key

using AAuth.Crypto;

var key = AAuthKey.Generate(); // Ed25519 keypair
var publicJwk = key.ToPublicJwk(); // Export for registration
var thumbprint = key.ComputeJwkThumbprint(); // JWK thumbprint (S256)

Make Your First Signed Request

The simplest mode is pseudonymous (HWK) — no Agent Provider needed:

using AAuth.Crypto;
using AAuth.HttpSig;

var key = AAuthKey.Generate();

using var client = new AAuthClientBuilder(key)
    .UseHwk()
    .Build();

var response = await client.GetAsync("https://resource.example/data");
// Request is signed with HTTP Message Signatures (RFC 9421)
// Resource sees: Signature-Key: sig=hwk;jkt="<thumbprint>";jwk="<public-key>"

Alternative: One-liner with static factory

using var client = AAuthSigningHandler.CreateClient(key, new HwkSignatureKeyProvider(key));

Alternative: DI / IHttpClientFactory

// In Program.cs
builder.Services.AddAAuthAgent("agent", options =>
{
    options.Key = key;
    options.PersonServer = "https://ps.example"; // omit for signing-only
});

// Inject via IHttpClientFactory
public class MyService(IHttpClientFactory factory)
{
    private readonly HttpClient _client = factory.CreateClient("agent");
}

What Just Happened?

  • AAuthKey.Generate() created an Ed25519 keypair.
  • AAuthClientBuilder configured the HWK signing mode and produced an HttpClient.
  • AAuthSigningHandler signs the request per RFC 9421 covering @method, @authority, @path, and signature-key.
  • The resource verifies the signature using the inline public key from Signature-Key.

Bootstrap with an Agent Provider (Three-Party Flow)

For production scenarios, agents register with an Agent Provider (AP) to get an identity-bound agent token. When a resource challenges with a 401, the SDK automatically exchanges the resource token at the Person Server (PS) and retries.

1. Enrol with the Agent Provider

using AAuth.Agent;
using AAuth.Crypto;
using AAuth.Discovery;
using AAuth.HttpSig;

var apClient = new AgentProviderClient(new HttpClient(), new InMemoryKeyStore());
var enrol = await apClient.EnrolAsync(
    apIssuer: "https://ap.example",
    agentId: "aauth:myagent@example.com",
    enrollEndpoint: "https://ap.example/enrol",
    personServer: "https://ps.example");

// enrol.Key        — your Ed25519 signing key
// enrol.AgentToken — aa-agent+jwt issued by the AP
// enrol.KeyId      — persisted key identifier

2. Build the Signed Client with Challenge Handling

using var client = new AAuthClientBuilder(enrol.Key)
    .UseJwt(enrol.AgentToken)
    .WithChallengeHandling(personServer: "https://ps.example")
    .Build();

<details> <summary>Manual Setup (Advanced)</summary>

// Carrier-token holder — shared between signer and challenge handler.
var holder = new AAuthTokenHolder(enrol.AgentToken);

var signingHandler = new AAuthSigningHandler(
    enrol.Key, new JwtSignatureKeyProvider(() => holder.Current))
{
    InnerHandler = new HttpClientHandler(),
};

var exchangeHttp = new HttpClient(
    new AAuthSigningHandler(enrol.Key, new JwtSignatureKeyProvider(() => enrol.AgentToken))
    { InnerHandler = new HttpClientHandler() });

var exchange = new TokenExchangeClient(exchangeHttp, new MetadataClient(new HttpClient()));

var pipeline = new ChallengeHandler(exchange, holder, "https://ps.example")
{
    InnerHandler = signingHandler,
};

using var client = new HttpClient(pipeline);

</details>

3. Make Requests

// First request may trigger a 401 challenge — the SDK handles it transparently
var response = await client.GetAsync("https://resource.example/protected");
Console.WriteLine(await response.Content.ReadAsStringAsync());

What Happens Under the Hood

  1. Agent sends a signed GET → Resource replies 401 with AAuth-Requirement: requirement=auth-token and a resource_token.
  2. ChallengeHandler extracts the resource token, POSTs it to the Person Server's token endpoint.
  3. The PS validates the agent token, confirms user consent (or defers), and returns an auth_token.
  4. AAuthTokenHolder is updated; the handler retries the original request signed with the auth token.
  5. Subsequent requests reuse the auth token until it expires.

Next Steps

Protocol Reference

Explore the interactive protocol specification at https://explorer.aauth.dev/.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on AAuth:

Package Downloads
AAuth.R3

Experimental AAuth Rich Resource Requests (R3) preview helpers — vocabulary-agnostic operations (OpenAPI, MCP, …). Depends on AAuth.

AAuth.Events

AAuth Events companion token, subscription and delivery contracts.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.10.0-alpha.1 50 9/10/2026
0.8.0-alpha.4 89 7/3/2026
0.8.0-alpha.3 89 6/29/2026
0.8.0-alpha.2 77 6/28/2026
0.8.0-alpha.1 77 6/27/2026
0.2.0-alpha.2 78 6/27/2026
0.2.0-alpha.1 77 6/10/2026
0.1.0-alpha.12 309 6/7/2026
0.1.0-alpha.11 66 6/3/2026
0.1.0-alpha.10 76 6/1/2026
0.1.0-alpha.9 65 5/31/2026
0.1.0-alpha.8 73 5/28/2026
0.1.0-alpha.7 66 5/27/2026
0.1.0-alpha.6 78 5/27/2026
0.1.0-alpha.5 78 5/26/2026
0.1.0-alpha.4 67 5/25/2026
0.1.0-alpha.3 70 5/24/2026
0.1.0-alpha.2 59 5/23/2026
0.1.0-alpha.1 73 5/23/2026