1010This is a .NET implementation of the JWT library for the NATS ecosystem.
1111
1212> [ !CAUTION]
13- > ### Very Important Disclaimer
13+ > ### Important Disclaimer
1414>
1515> This repository provides an API to build NATS JWTs using .NET. However, at
1616> this time it is _ not_ a supported API. Use at your own risk.
@@ -35,8 +35,8 @@ This is a .NET implementation of the JWT library for the NATS ecosystem.
3535- [x] Remove No-warnings from build
3636- [x] Add more tests
3737- [x] Enable code coverage
38- - [ ] Add more examples
39- - [ ] Add more documentation
38+ - [ ] Add examples
39+ - [ ] Add documentation
4040
4141## Installation
4242
@@ -49,14 +49,12 @@ dotnet add package NATS.Jwt --prerelease
4949## Usage
5050
5151``` csharp
52- var jwt = new NatsJwt ();
53-
5452// create an operator key pair (private key)
5553var okp = KeyPair .CreatePair (PrefixByte .Operator );
5654var opk = okp .GetPublicKey ();
5755
5856// create an operator claim using the public key for the identifier
59- var oc = jwt .NewOperatorClaims (opk );
57+ var oc = NatsJwt .NewOperatorClaims (opk );
6058oc .Name = " Example Operator" ;
6159
6260// add an operator signing key to sign accounts
@@ -68,22 +66,22 @@ var ospk = oskp.GetPublicKey();
6866oc .Operator .SigningKeys = [ospk ];
6967
7068// self-sign the operator JWT - the operator trusts itself
71- var operatorJwt = jwt .Encode (oc , okp );
69+ var operatorJwt = NatsJwt .Encode (oc , okp );
7270
7371// create an account keypair
7472var akp = KeyPair .CreatePair (PrefixByte .Account );
7573var apk = akp .GetPublicKey ();
7674
7775// create the claim for the account using the public key of the account
78- var ac = jwt .NewAccountClaims (apk );
76+ var ac = NatsJwt .NewAccountClaims (apk );
7977ac .Name = " Example Account" ;
8078
8179var askp = KeyPair .CreatePair (PrefixByte .Account );
8280var aspk = askp .GetPublicKey ();
8381
8482// add the signing key (public) to the account
8583ac .Account .SigningKeys = [aspk ];
86- var accountJwt = jwt .Encode (ac , oskp );
84+ var accountJwt = NatsJwt .Encode (ac , oskp );
8785
8886// now back to the account, the account can issue users
8987// need not be known to the operator - the users are trusted
@@ -92,12 +90,12 @@ var accountJwt = jwt.Encode(ac, oskp);
9290// verify that the user was issued by one of those keys
9391var ukp = KeyPair .CreatePair (PrefixByte .User );
9492var upk = ukp .GetPublicKey ();
95- var uc = jwt .NewUserClaims (upk );
93+ var uc = NatsJwt .NewUserClaims (upk );
9694
9795// since the jwt will be issued by a signing key, the issuer account
9896// must be set to the public ID of the account
9997uc .User .IssuerAccount = apk ;
100- var userJwt = jwt .Encode (uc , askp );
98+ var userJwt = NatsJwt .Encode (uc , askp );
10199
102100// the seed is a version of the keypair that is stored as text
103101var userSeed = ukp .GetSeed ();
@@ -113,7 +111,7 @@ var conf = $$"""
113111
114112// generate a creds formatted file that can be used by a NATS client
115113const string credsPath = $" example_user.creds" ;
116- File .WriteAllText (credsPath , jwt .FormatUserConfig (userJwt , userSeed ));
114+ File .WriteAllText (credsPath , NatsJwt .FormatUserConfig (userJwt , userSeed ));
117115
118116// now we are going to put it together into something that can be run
119117// we create a file to store the server configuration, the creds
0 commit comments