Skip to content

swift-jwt 0.0.1

Choose a tag to compare

@coenttb coenttb released this 28 Jul 07:58
· 15 commits to main since this release

swift-jwt 0.0.1

Initial release of swift-jwt, a comprehensive Swift package for creating, signing, and verifying JSON Web Tokens (JWTs) using Apple's Crypto framework.

✨ Features

  • Multiple Signing Algorithms: HMAC-SHA256/384/512 and ECDSA-SHA256 support
  • Standards Compliant: Built on swift-rfc-7519 and swift-crypto
  • Easy to Use: Convenience methods for common JWT operations
  • Type Safe: Leverages Swift's type system for secure JWT handling
  • Comprehensive: Full signature verification and timing validation
  • Flexible: Custom claims and header parameters support

🚀 Quick Start

import JWT

// Create a JWT with HMAC-SHA256
let jwt = try JWT.hmacSHA256(
    issuer: "example.com",
    subject: "user123",
    audience: "api.example.com",
    expiresIn: 3600,
    claims: ["role": "admin"],
    secretKey: "your-secret-key"
)

// Verify the JWT
let verificationKey = VerificationKey.symmetric(string: "your-secret-key")
let isValid = try jwt.verifyAndValidate(with: verificationKey)

📦 Installation

Add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/coenttb/swift-jwt.git", from: "0.0.1")
]

📋 Requirements

  • Platforms: macOS 13.0+, iOS 16.0+
  • Swift: 5.9+ (Swift 6.0 supported)

🔒 Security

This package includes comprehensive security features and follows JWT best practices. Please review the documentation for security considerations when implementing JWT authentication in your applications.


For complete documentation, examples, and advanced usage, see the README.