RollingTokenAuth

0.1

alexeichhorn/swift-rolling-token-auth

What's New

0.1

2026-02-23T15:39:37Z

Initial release of RollingTokenAuth.

Includes rolling token generation/validation, URLRequest helpers, and CI for Apple platforms + Linux.

RollingTokenAuth

Rolling token authentication for Swift clients and servers.

Features

  • HMAC-SHA256 rolling token generation
  • Tolerance window validation (past/current/future intervals)
  • URLRequest helpers for bearer auth headers

Installation

dependencies: [
    .package(url: "https://github.com/alexeichhorn/swift-rolling-token-auth.git", from: "0.1.0")
]

Usage

Two Variants

This package provides two public token types for different use-cases:

  • RollingTokenManager
    • Full generator + validator.
    • Use this when you need tolerance-based token validation (typically server-side).
  • RollingAuthorizationToken
    • Lightweight generator-only helper.
    • Use this when you only need to attach outbound bearer tokens (typically client-side).

RollingTokenManager (generation + validation)

import RollingTokenAuth

var manager = RollingTokenManager(secret: "my_secret", interval: 3600, tolerance: 1)
let token = manager.generateToken()

let isValid = manager.isValid(token.token)

With tolerance: 1, previous, current, and next interval tokens are accepted.

RollingAuthorizationToken (generation only)

import Foundation
import RollingTokenAuth

let auth = RollingAuthorizationToken(secret: "my_secret", interval: 3600)
var request = URLRequest(url: URL(string: "https://example.com")!)
request.addAuthentication(with: auth)

You can also use RollingTokenManager directly for request auth:

import Foundation
import RollingTokenAuth

let manager = RollingTokenManager(secret: "my_secret", interval: 3600, tolerance: 1)
var request = URLRequest(url: URL(string: "https://example.com")!)
request.addAuthentication(with: manager)

Description

  • Swift Tools 6.2.0
View More Packages from this Author

Dependencies

Last updated: Sun Mar 01 2026 15:11:07 GMT-1000 (Hawaii-Aleutian Standard Time)