diff --git a/.docctargetlist b/.docctargetlist new file mode 100644 index 0000000..cb7b8fe --- /dev/null +++ b/.docctargetlist @@ -0,0 +1 @@ +BCrypt \ No newline at end of file diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 5ad0dc3..d466738 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -5,6 +5,7 @@ on: tags: - 'v*' - '[0-9]*' + workflow_dispatch: jobs: diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index df114bc..c7325f4 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -15,7 +15,7 @@ jobs: format_check_enabled : true broken_symlink_check_enabled : true unacceptable_language_check_enabled : true - docs_check_enabled : true + docs_check_enabled : false api_breakage_check_enabled : false license_header_check_enabled : false shell_check_enabled : false @@ -27,6 +27,7 @@ jobs: uses: BinaryBirds/github-workflows/.github/workflows/extra_soundness.yml@main with: local_swift_dependencies_check_enabled : true + headers_check_enabled : false + docc_warnings_check_enabled : true run_tests_with_cache_enabled : true - headers_check_enabled : true run_tests_swift_versions: '["6.1","6.2"]' diff --git a/.swiftheaderignore b/.swiftheaderignore index 10005fd..68c6722 100644 --- a/.swiftheaderignore +++ b/.swiftheaderignore @@ -1,10 +1,11 @@ +Sources/CBCrypt/** +docker/** .gitignore .swift-format .swiftformatignore .swiftheaderignore -Sources/CBCrypt/** +.docctargetlist .github/** -docker/** AGENTS.md LICENSE Makefile diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..acc3581 --- /dev/null +++ b/LICENSE @@ -0,0 +1,25 @@ +# MIT License + +Copyright (c) 2018-2022 Tibor Bödecs +Copyright (c) 2022-2026 Binary Birds Kft. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +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. diff --git a/Makefile b/Makefile index a3e1b32..77a5c2e 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,10 @@ SHELL=/bin/bash baseUrl = https://raw.githubusercontent.com/BinaryBirds/github-workflows/refs/heads/main/scripts -check: symlinks language deps lint headers +check: symlinks language deps lint headers docc-warnings package + +package: + curl -s $(baseUrl)/check-swift-package.sh | bash symlinks: curl -s $(baseUrl)/check-broken-symlinks.sh | bash @@ -38,4 +41,4 @@ test: swift test --parallel docker-test: - docker build -t feather-database-tests . -f ./docker/tests/Dockerfile && docker run --rm feather-database-tests + docker build -t tests . -f ./docker/tests/Dockerfile && docker run --rm tests diff --git a/Package.swift b/Package.swift index c3c7697..dda3e31 100644 --- a/Package.swift +++ b/Package.swift @@ -24,27 +24,36 @@ defaultSwiftSettings.append( let package = Package( name: "swift-bcrypt", platforms: [ - .macOS(.v13), - .iOS(.v16), - .tvOS(.v16), - .watchOS(.v9), - .visionOS(.v1), + .macOS(.v15), + .iOS(.v18), + .tvOS(.v18), + .watchOS(.v11), + .visionOS(.v2), ], products: [ .library(name: "BCrypt", targets: ["BCrypt"]), ], dependencies: [ + // [docc-plugin-placeholder] ], targets: [ - .target(name: "CBCrypt"), - .target(name: "BCrypt", dependencies: [ - .target(name: "CBCrypt"), - ]), + .target( + name: "CBCrypt", + swiftSettings: defaultSwiftSettings + ), + .target( + name: "BCrypt", + dependencies: [ + .target(name: "CBCrypt"), + ], + swiftSettings: defaultSwiftSettings + ), .testTarget( name: "BCryptTests", dependencies: [ .target(name: "BCrypt"), - ] + ], + swiftSettings: defaultSwiftSettings ), ] ) diff --git a/README.md b/README.md index 43864c8..bedb173 100644 --- a/README.md +++ b/README.md @@ -3,29 +3,27 @@ Swift BCrypt implementation for securely hashing and verifying passwords using adaptive cost factors, random salts, and constant-time comparison. -![Release: 2.0.0](https://img.shields.io/badge/Release-2%2E0%2E0-F05138) +[![Release: 2.0.1](https://img.shields.io/badge/Release-2.0.1-F05138)]( https://github.com/binarybirds/swift-bcrypt/releases/tag/2.0.1) ## Requirements ![Swift 6.1+](https://img.shields.io/badge/Swift-6%2E1%2B-F05138) -![Platforms: Linux, macOS, iOS, tvOS, watchOS, visionOS](https://img.shields.io/badge/Platforms-Linux_%7C_macOS_%7C_iOS_%7C_tvOS_%7C_watchOS_%7C_visionOS-F05138) - -- Swift 6.1+ +![Platforms: macOS, iOS, tvOS, watchOS, visionOS](https://img.shields.io/badge/Platforms-macOS_%7C_iOS_%7C_tvOS_%7C_watchOS_%7C_visionOS-F05138) -- Platforms: - - Linux - - macOS 15+ - - iOS 18+ - - tvOS 18+ - - watchOS 11+ - - visionOS 2+ +- Swift 6.1+ +- Platforms: + - macOS 15+ + - iOS 18+ + - tvOS 18+ + - watchOS 11+ + - visionOS 2+ ## Installation Use Swift Package Manager; add the dependency to your `Package.swift` file: ```swift -.package(url: "https://github.com/binarybirds/swift-bcrypt", from: "1.0.0"), +.package(url: "https://github.com/binarybirds/swift-bcrypt", exact: "2.0.1"), ``` Then add `Bcrypt` to your target dependencies: @@ -37,14 +35,12 @@ Then add `Bcrypt` to your target dependencies: Update the packages and you are ready. ## Usage - -![DocC API documentation](https://img.shields.io/badge/DocC-API_documentation-F05138) -API documentation is available at the following [link](https://binarybirds.github.io/swift-bcrypt). Refer to the mock objects in the Tests directory if you want to build a custom database driver implementation. +[![DocC API documentation](https://img.shields.io/badge/DocC-API_documentation-F05138)](https://binarybirds.github.io/swift-bcrypt) -## Usage example +API documentation is available at the following link. Refer to the mock objects in the Tests directory if you want to build a custom database driver implementation. -Basic example +## Usage example ```swift import Bcrypt @@ -53,21 +49,21 @@ let digest = try Bcrypt.hash("binary-birds", cost: 6) let res = try Bcrypt.verify("binary-birds", created: digest) ``` -## Credits - -This code is derived from the Vapor web framework: - -- [Vapor](https://github.com/vapor/vapor) - ## Development - Build: `swift build` -- Test: - - local: `swift test` - - using Docker: `make docker-test` +- Test: + - local: `swift test` + - using Docker: `make docker-test` - Format: `make format` - Check: `make check` ## Contributing -[Pull requests](https://github.com/binarybirds/swift-bcrypt/pulls) are welcome. Please keep changes focused and include tests for new logic. 🙏 +[Pull requests](https://github.com/binarybirds/swift-bcrypt/pulls) are welcome. Please keep changes focused and include tests for new logic. + +## Credits + +This code is derived from the Vapor web framework: + +- [Vapor](https://github.com/vapor/vapor) diff --git a/Sources/BCrypt/BCrypt.swift b/Sources/BCrypt/BCrypt.swift index a4ef28d..d702d50 100644 --- a/Sources/BCrypt/BCrypt.swift +++ b/Sources/BCrypt/BCrypt.swift @@ -146,8 +146,8 @@ public final class BCrypt { /// - Parameters: /// - plaintext: The plaintext value to verify. /// - hash: A BCrypt hash string previously produced by ``hash(_:cost:)`` or compatible implementations. - /// - Throws: ``BcryptError/invalidHash`` if the provided hash is malformed, - /// or ``BcryptError/hashFailure`` if hashing fails during verification. + /// - Throws: ``BCryptError/invalidHash`` if the provided hash is malformed, + /// or ``BCryptError/hashFailure`` if hashing fails during verification. /// - Returns: `true` if `plaintext` matches the hash; otherwise `false`. public func verify( _ plaintext: String,