Skip to content

Commit 87c4538

Browse files
authored
Release 1.0.0-preview.15 (#44)
* Make NatsJwt Static (#43)
1 parent 9dd7d2f commit 87c4538

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
This 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)
5553
var okp = KeyPair.CreatePair(PrefixByte.Operator);
5654
var 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);
6058
oc.Name = "Example Operator";
6159

6260
// add an operator signing key to sign accounts
@@ -68,22 +66,22 @@ var ospk = oskp.GetPublicKey();
6866
oc.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
7472
var akp = KeyPair.CreatePair(PrefixByte.Account);
7573
var 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);
7977
ac.Name = "Example Account";
8078

8179
var askp = KeyPair.CreatePair(PrefixByte.Account);
8280
var aspk = askp.GetPublicKey();
8381

8482
// add the signing key (public) to the account
8583
ac.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
9391
var ukp = KeyPair.CreatePair(PrefixByte.User);
9492
var 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
9997
uc.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
103101
var userSeed = ukp.GetSeed();
@@ -113,7 +111,7 @@ var conf = $$"""
113111

114112
// generate a creds formatted file that can be used by a NATS client
115113
const 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

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0-preview.14
1+
1.0.0-preview.15

0 commit comments

Comments
 (0)