Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README and DocC #190

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Then, pass the payload to `JWTKeyCollection.sign`.

```swift
// Sign the payload, returning the JWT as String
let jwt = try await keys.sign(payload, header: ["kid": "my-key"])
let jwt = try await keys.sign(payload, kid: "my-key")
print(jwt)
```

Expand Down Expand Up @@ -289,21 +289,14 @@ let key = try Insecure.RSA.PublicKey(pem: rsaPublicKey)
```

Use `Insecure.RSA.PrivateKey(pem:)` for loading private RSA pem keys and `Insecure.RSA.PublicKey(certificatePEM:)` for loading X.509 certificates.
Once you have an RSA key, you can add to the key collection using the following methods depending on the digest and the padding:

- `addRS256`: RSA with SHA-256 and PKCS1.5 padding
- `addRS384`: RSA with SHA-384 and PKCS1.5 padding
- `addRS512`: RSA with SHA-512 and PKCS1.5 padding
- `addPS256`: RSA with SHA-256 and PSS padding
- `addPS384`: RSA with SHA-384 and PSS padding
- `addPS512`: RSA with SHA-512 and PSS padding
Once you have an RSA key, you can add to the key collection using the dedicated methods depending on the digest and the padding:

```swift
// Add RSA with SHA-256 algorithm
await keys.add(rsa: key, digestAlgorithm: .sha256)

// Add RSA with SHA-256 and PSS padding algorithm
await keys.add(pss: key, digestAlgorithm: .sha256)
// Add RSA with SHA-512 and PSS padding algorithm
await keys.add(pss: key, digestAlgorithm: .sha512)
```

## Claims
Expand Down
4 changes: 2 additions & 2 deletions Snippets/JWTKitExamples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ do {
// Add RSA with SHA-256 algorithm
await keys.add(rsa: key, digestAlgorithm: .sha256)

// Add RSA with SHA-256 and PSS padding algorithm
await keys.add(pss: key, digestAlgorithm: .sha256)
// Add RSA with SHA-512 and PSS padding algorithm
await keys.add(pss: key, digestAlgorithm: .sha512)
// snippet.end
}

Expand Down
21 changes: 2 additions & 19 deletions Sources/JWTKit/Docs.docc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@

🔑 JSON Web Token signing and verification (HMAC, RSA, PSS, ECDSA, EdDSA) using SwiftCrypto.

### Major Releases

The table below shows a list of JWTKit major releases alongside their compatible Swift versions.

|Version|Swift|SPM|
|---|---|---|
|5.0|5.9+|`from: "5.0.0"`|

Use the SPM string to easily include the dependendency in your `Package.swift` file

```swift
Expand All @@ -26,11 +18,9 @@ and add it to your target's dependencies:
.product(name: "JWTKit", package: "jwt-kit")
```

> Note: Prior to version 4.0, this package was part of [vapor/jwt](https://github.com/vapor/jwt).

### Supported Platforms

JWTKit supports all platforms supported by Swift 5.9 and later, with the exception of Windows.
JWTKit supports all platforms supported by Swift 5.10 and later, with the exception of Windows.

## Overview

Expand Down Expand Up @@ -188,14 +178,7 @@ You can also choose to load a PEM file:
@Snippet(path: "jwt-kit/Snippets/JWTKitExamples", slice: RSA_FROM_PEM)

Use `Insecure.RSA.PrivateKey(pem:)` for loading private RSA pem keys and `Insecure.RSA.PublicKey(certificatePEM:)` for loading X.509 certificates.
Once you have an RSA key, you can add to the key collection using the following methods depending on the digest and the padding:

- `addRS256`: RSA with SHA-256 and PKCS1.5 padding
- `addRS384`: RSA with SHA-384 and PKCS1.5 padding
- `addRS512`: RSA with SHA-512 and PKCS1.5 padding
- `addPS256`: RSA with SHA-256 and PSS padding
- `addPS384`: RSA with SHA-384 and PSS padding
- `addPS512`: RSA with SHA-512 and PSS padding
Once you have an RSA key, you can add to the key collection using the dedicated methods depending on the digest and the padding:

@Snippet(path: "jwt-kit/Snippets/JWTKitExamples", slice: RSA_ADD)

Expand Down