Skip to content

Commit

Permalink
maintenance: add swift 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
beatt83 committed Oct 28, 2024
1 parent c289a01 commit 3117deb
Show file tree
Hide file tree
Showing 48 changed files with 62 additions and 60 deletions.
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8.1
// swift-tools-version: 5.9.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down Expand Up @@ -112,5 +112,6 @@ let package = Package(
"JSONWebToken"
]
),
]
],
swiftLanguageVersions: [.version("6"), .v5]
)
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Screenshot](jose-swift-logo.png)
# Jose Swift Library

[![Swift](https://img.shields.io/badge/swift-brightgreen.svg)]() [![iOS](https://img.shields.io/badge/ios-brightgreen.svg)]() [![MacOS](https://img.shields.io/badge/macos-brightgreen.svg)]() [![WatchOS](https://img.shields.io/badge/watchos-brightgreen.svg)]() [![TvOS](https://img.shields.io/badge/tvos-brightgreen.svg)]()
[![Swift](https://img.shields.io/badge/swift-brightgreen.svg)]() [![Swift6](https://img.shields.io/badge/swift6-brightgreen.svg)]() [![iOS](https://img.shields.io/badge/ios-brightgreen.svg)]() [![MacOS](https://img.shields.io/badge/macos-brightgreen.svg)]() [![WatchOS](https://img.shields.io/badge/watchos-brightgreen.svg)]() [![TvOS](https://img.shields.io/badge/tvos-brightgreen.svg)]()

This library provides comprehensive support for the Jose suite of standards, including JWA (JSON Web Algorithms), JWK (JSON Web Key), JWE (JSON Web Encryption), JWS (JSON Web Signature), and JWT (JSON Web Token). These standards are integral to modern security protocols on the web, offering methods for secure key management, data encryption, signing, and representation of claims among different parties.

Expand Down Expand Up @@ -168,7 +168,8 @@ Note: JWS Unencoded payload as referenced in the [RFC-7797](https://datatracker.

## Requirements

- Swift 5.7.1 or later
- Swift 5.8.1 or later
- Swift 6 or later
- iOS 15.0 or later
- macOS 12.0 or later
- Mac Catalyst 15.0 or later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Foundation

/// `ContentCompressionAlgorithm` is an enumeration representing the supported content compression algorithms.
public enum ContentCompressionAlgorithm: String, Codable {
public enum ContentCompressionAlgorithm: String, Codable, Sendable {
/// The DEFLATE compression algorithm.
case deflate = "DEF"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation

/// `XC20P` provides methods to encrypt and decrypt data using the XChaCha20-Poly1305 algorithm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

/// `ContentEncryptionAlgorithm` is an enumeration representing the supported content encryption algorithms.
public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable, Hashable {
public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable, Hashable, Sendable {
/// AES encryption in CBC mode with an HMAC using SHA-256.
/// The algorithm uses a 256-bit key and is commonly used for its balance of security and performance.
case a128CBCHS256 = "A128CBC-HS256"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import CryptoKit
import Foundation
import JSONWebKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import CryptoKit
import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import secp256k1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import CryptoKit
import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
/// Supported JWE cryptographic algorithms for key management.
///
/// For more information, see [RFC7518 Section 4.1](https://www.rfc-editor.org/rfc/rfc7518#section-4.1)
public enum KeyManagementAlgorithm: String, Equatable, Codable {
public enum KeyManagementAlgorithm: String, Sendable, Equatable, Codable {
/// RSA algorithm with PKCS #1 v1.5 padding.
case rsa1_5 = "RSA1_5"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import CryptoKit
import Foundation
import JSONWebKey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CryptoKit
import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import secp256k1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CryptoKit
import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey
import Security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public struct ES256KSigner: Signer {
}

/// The output format of the signature.
public static var outputFormat = ES256KSigner.SignatureFormat.raw
nonisolated(unsafe) public static var outputFormat = ES256KSigner.SignatureFormat.raw
/// Indicates whether the bytes R and S are inverted.
public static var invertedBytesR_S = false
nonisolated(unsafe) public static var invertedBytesR_S = false

/// The algorithm used for signing.
public var algorithm: String { SigningAlgorithm.ES256K.rawValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import secp256k1
public struct ES256KVerifier: Verifier {

/// Indicates whether to use a fail-safe mechanism compatible with Bouncy Castle.
public static var bouncyCastleFailSafe = false
nonisolated(unsafe) public static var bouncyCastleFailSafe = false

/// The algorithm used for verification.
public var algorithm: String { SigningAlgorithm.ES256K.rawValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import CryptoSwift
@preconcurrency import CryptoSwift
import Foundation
import JSONWebKey

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Foundation
/// - `PS256`, `PS384`, `PS512`: RSASSA-PSS (RSA Probabilistic Signature Scheme) using SHA-256, SHA-384, and SHA-512 hash functions, respectively, and MGF1 (Mask Generation Function 1).
/// - `none`: Represents the absence of a digital signature or MAC.
/// - `invalid`: A placeholder for an invalid or unsupported algorithm, useful for error handling or invalid state representation.
public enum SigningAlgorithm: String, Codable {
public enum SigningAlgorithm: String, Codable, Sendable {
/// HMAC using SHA-256
case HS256 = "HS256"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import JSONWebAlgorithms
import JSONWebKey

/// `JWEDecryptor` protocol defines functionality for decrypting JWE objects.
public protocol JWEDecryptor {
public protocol JWEDecryptor: Sendable {
/// Supported key management algorithms by this decryptor.
var supportedKeyManagementAlgorithms: [KeyManagementAlgorithm] { get }

Expand Down Expand Up @@ -59,7 +59,7 @@ public protocol JWEDecryptor {
}

/// `JWEMultiDecryptor` protocol defines functionality for decrypting JWE objects with multiple recipients.
public protocol JWEMultiDecryptor {
public protocol JWEMultiDecryptor: Sendable {
/// Decrypts a JWE object with multiple recipients given various headers and cryptographic components.
/// - Parameters:
/// - protectedHeader: Protected header, conforming to `JWERegisteredFieldsHeader`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import JSONWebAlgorithms
import JSONWebKey

/// JWEEncryptor protocol defines the encryption process for JWE.
public protocol JWEEncryptor {
public protocol JWEEncryptor: Sendable {
/// Supported key management algorithms.
var supportedKeyManagmentAlgorithms: [KeyManagementAlgorithm] { get }

Expand Down Expand Up @@ -62,7 +62,7 @@ public protocol JWEEncryptor {
}

/// JWEMultiEncryptor protocol defines the encryption process for JWE with multiple recipients.
public protocol JWEMultiEncryptor {
public protocol JWEMultiEncryptor: Sendable {
/// Encrypts a payload for multiple recipients.
/// - Parameters:
/// - payload: Data to be encrypted.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

extension JWE {
public static var encryptionModule: JWEEncryptionModule = .default
public static let encryptionModule: JWEEncryptionModule = .default
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
import JSONWebAlgorithms

/// `JWEEncryptionProvider` represents an encryption provider for JSON Web Encryption (JWE) with a specific algorithm family.
public struct JWEEncryptionProvider: Hashable {
public struct JWEEncryptionProvider: Sendable, Hashable {
/// The family of key management algorithm.
public let family: KeyManagementAlgorithm.Family

Expand Down Expand Up @@ -60,7 +60,7 @@ public struct JWEEncryptionProvider: Hashable {
}

/// `JWEEncryptionModule` manages a collection of `JWEEncryptionProvider` instances and provides encryption and decryption functionalities.
public struct JWEEncryptionModule {
public struct JWEEncryptionModule: Sendable {
/// A set of registered encryption providers.
public let registeredEncryptions: Set<JWEEncryptionProvider>

Expand Down Expand Up @@ -99,7 +99,7 @@ public struct JWEEncryptionModule {

extension JWEEncryptionModule {
/// The default `JWEEncryptionModule` instance with a predefined set of encryption providers.
public static var `default`: JWEEncryptionModule = .init(
public static let `default`: JWEEncryptionModule = .init(
registeredEncryptions: Set(
[
.init(
Expand Down Expand Up @@ -145,7 +145,7 @@ extension JWEEncryptionModule {

/// The default `JWEEncryptionModule` instance with a predefined set of encryption providers, were ECDH-1PU and ECDH-ES
/// use a master ephemeral key for multiple recipients.
public static var defaultWithMasterEphemeralKey: JWEEncryptionModule = .init(
public static let defaultWithMasterEphemeralKey: JWEEncryptionModule = .init(
registeredEncryptions: Set(
[
.init(
Expand Down
Loading

0 comments on commit 3117deb

Please sign in to comment.