---
title: atprotokit/jot
framework: Swift Package Catalog
role: article
path: packages/atprotokit/jot
---

# atprotokit/jot

Very simple JWT/JWK library for Swift

## Integration

```swift dependencies: [     .package(url: "https://github.com/ATProtoKit/Jot", branch: "main") ] ```

## Usage

```swift import Jot

// Define your custom payload. You can omit fields that you do not need. struct MyCustomPayload: JSONWebTokenPayload {     let iss: String?     let sub: String?     let aud: JSONWebTokenAudience?     let jti: String?     let nbf: Date?     let iat: Date?     let exp: Date?

let customClaim: String }

// create a token let token = JSONWebToken<MyCustomPayload>(     header: JSONWebTokenHeader(algorithm: .ES256),     payload: MyCustomPayload(iss: nil, sub: nil, aud: nil, jti: nil, nbf: nil, iat: nil, exp: nil, customClaim: "my_claim") )

import CryptoKit

let key = P256.Signing.PrivateKey()

// encode it let string = token.encode(with: key)

// decode it let decodedToken = JSONWebToken<MyCustomPayload>(encodedString: string, key: key) ```

Jot also supports custom signing/verification if CryptoKit is unavailable, or you want to use an algorithm that is does not support.

```swift // custom signature let string = token.encode { algorithm, data in     // custom JSONWebTokenSigner implementation goes here

return signature }

// custom verification let token = try JSONWebToken<MyCustomPayload>(encodedString: tokenString) { algorithm, message, signature in     // custom JSONWebTokenValidator implementation goes here } ```

## Supported Algorithms

Remember, this library supports bring-your-own-cyptography-system. But, when CryptoKit is available, there are some convenience implementations for `ES256`, `HS256`, `HS384`, `HS512`. If you need something else open up an issue and we can get it going.

## Contributing and Collaboration

I would love to hear from you! Issues or pull requests work great.

I prefer collaboration, and would love to find ways to work together if you have a similar project.

I prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.

By participating in this project you agree to abide by the [Contributor Code of Conduct](https://github.com/ATProtoKit/.github/blob/main/CODE_OF_CONDUCT.md).

[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FATProtoKit%2FJot%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/ATProtoKit/Jot)

[build status]: https://github.com/mattmassicotte/Jot/actions [build status badge]: https://github.com/mattmassicotte/Jot/workflows/CI/badge.svg [platforms]: https://swiftpackageindex.com/ATProtoKit/Jot [platforms badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FATProtoKit%2FJot%2Fbadge%3Ftype%3Dswift-versions [documentation]: https://swiftpackageindex.com/mattmassicotte/Jot/main/documentation [documentation badge]: https://img.shields.io/badge/Documentation-DocC-blue

## Package Metadata

Repository: atprotokit/jot

Default branch: main

README: README.md
