Skip to content

πŸͺ Cross-platform Swift library for RFC6265-compliant HTTP cookie management. Pure Swift implementation for Apple platforms, Linux & Swift on Server frameworks.

License

Notifications You must be signed in to change notification settings

kubens/swift-cookie-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

swift-cookie-storage

A cross-platform Swift Package Manager library providing RFC6265-compliant HTTP cookie management for Apple platforms, Linux, and Swift on Server frameworks.

Swift 6.0+ Platforms SPM Compatible

Features

  • 🎯 RFC6265 Compliant: Full implementation of HTTP State Management Mechanism specification
  • 🌍 Cross-Platform: Pure Swift implementation supporting Apple platforms and Linux
  • ⚑ High Performance: UTF-8 level parsing with optimized cookie operations
  • πŸ”’ Thread Safe: Actor-based concurrency model for safe concurrent access
  • πŸ–₯️ Server Ready: Designed for Swift on Server frameworks (Vapor, Hummingbird)
  • πŸ“Š Comprehensive: All standard cookie attributes with proper validation

RFC6265 Compliance

This library implements the full RFC6265 specification including:

Cookie Parsing (Section 4.1)

  • βœ… Cookie name/value extraction with proper token validation
  • βœ… Case-insensitive attribute parsing
  • βœ… Whitespace handling and trimming
  • βœ… Malformed input rejection

Domain Matching (Section 5.2.3)

  • βœ… Exact domain matching
  • βœ… Subdomain matching with proper dot handling
  • βœ… Leading dot normalization
  • βœ… Public suffix protection

Path Matching (Section 5.2.4)

  • βœ… Path prefix matching
  • βœ… Default path handling
  • βœ… Case-sensitive path comparison

Attribute Handling

  • βœ… Expires: RFC-compliant date parsing (multiple formats)
  • βœ… Max-Age: Takes precedence over Expires
  • βœ… Secure: HTTPS-only cookie transmission
  • βœ… HttpOnly: Script access prevention
  • βœ… SameSite: CSRF protection

Cookie Ordering (Section 5.4)

  • βœ… Longer paths first
  • βœ… Creation time ordering for equal paths

Requirements

  • Swift: 6.0 or later
  • Platforms:
    • macOS 10.15+
    • iOS 13.0+
    • watchOS 6.0+
    • tvOS 13.0+
    • Linux (Swift 6.0+)

Testing

Run the comprehensive test suite:

swift test

The library includes extensive RFC6265 compliance tests covering edge cases, malformed input, and cross-platform behavior.

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow Swift API Design Guidelines
  • Maintain RFC6265 compliance
  • Add tests for new functionality
  • Update documentation for public APIs
  • Ensure cross-platform compatibility

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

πŸͺ Cross-platform Swift library for RFC6265-compliant HTTP cookie management. Pure Swift implementation for Apple platforms, Linux & Swift on Server frameworks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages