Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Create Docomentation and Deploy it

on:
push:
tags:
- 'v*'
- '[0-9]*'

jobs:

create-docc-and-deploy:
uses: BinaryBirds/github-workflows/.github/workflows/docc_deploy.yml@main
permissions:
contents: read
pages: write
id-token: write
with:
docc_swift_version: "6.2"
32 changes: 32 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Actions

on:
pull_request:
branches:
- main

jobs:

swiftlang_checks:
name: Swiftlang Checks
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "project"
format_check_enabled : true
broken_symlink_check_enabled : true
unacceptable_language_check_enabled : true
docs_check_enabled : true
api_breakage_check_enabled : false
license_header_check_enabled : false
shell_check_enabled : false
yamllint_check_enabled : false
python_lint_check_enabled : false

bb_checks:
name: BB Checks
uses: BinaryBirds/github-workflows/.github/workflows/extra_soundness.yml@main
with:
local_swift_dependencies_check_enabled : true
run_tests_with_cache_enabled : true
headers_check_enabled : true
run_tests_swift_versions: '["6.1","6.2"]'
1 change: 1 addition & 0 deletions .swiftformatignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package.swift
15 changes: 15 additions & 0 deletions .swiftheaderignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.gitignore
.swift-format
.swiftformatignore
.swiftheaderignore
Sources/CBCrypt/**
.github/**
docker/**
AGENTS.md
LICENSE
Makefile
Package.swift
Package.resolved
README.md
.unacceptablelanguageignore
docker-compose.yaml
1 change: 1 addition & 0 deletions .unacceptablelanguageignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tests/BCryptTests/BCryptTests.swift
48 changes: 36 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,41 @@
build:
swift build
SHELL=/bin/bash

release:
swift build -c release

test:
swift test --parallel
baseUrl = https://raw.githubusercontent.com/BinaryBirds/github-workflows/refs/heads/main/scripts

check: symlinks language deps lint headers

test-with-coverage:
swift test --parallel --enable-code-coverage
symlinks:
curl -s $(baseUrl)/check-broken-symlinks.sh | bash

clean:
rm -rf .build
language:
curl -s $(baseUrl)/check-unacceptable-language.sh | bash

deps:
curl -s $(baseUrl)/check-local-swift-dependencies.sh | bash

lint:
curl -s $(baseUrl)/run-swift-format.sh | bash

format:
swift-format -i -r ./Sources && swift-format -i -r ./Tests
curl -s $(baseUrl)/run-swift-format.sh | bash -s -- --fix

docc-local:
curl -s $(baseUrl)/generate-docc.sh | bash -s -- --local

run-docc:
curl -s $(baseUrl)/run-docc-docker.sh | bash

docc-warnings:
curl -s $(baseUrl)/check-docc-warnings.sh | bash

headers:
curl -s $(baseUrl)/check-swift-headers.sh | bash

fix-headers:
curl -s $(baseUrl)/check-swift-headers.sh | bash -s -- --fix

test:
swift test --parallel

docker-test:
docker build -t feather-database-tests . -f ./docker/tests/Dockerfile && docker run --rm feather-database-tests
34 changes: 27 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
// swift-tools-version:5.9
// swift-tools-version:6.1
import PackageDescription

// NOTE: https://github.com/swift-server/swift-http-server/blob/main/Package.swift
var defaultSwiftSettings: [SwiftSetting] =
[
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0441-formalize-language-mode-terminology.md
.swiftLanguageMode(.v6),
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
.enableUpcomingFeature("MemberImportVisibility"),
// https://forums.swift.org/t/experimental-support-for-lifetime-dependencies-in-swift-6-2-and-beyond/78638
.enableExperimentalFeature("Lifetimes"),
// https://github.com/swiftlang/swift/pull/65218
.enableExperimentalFeature("AvailabilityMacro=featherDatabase 1.0:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"),
]

#if compiler(>=6.2)
defaultSwiftSettings.append(
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0461-async-function-isolation.md
.enableUpcomingFeature("NonisolatedNonsendingByDefault")
)
#endif

let package = Package(
name: "swift-bcrypt",
platforms: [
Expand All @@ -11,19 +31,19 @@ let package = Package(
.visionOS(.v1),
],
products: [
.library(name: "Bcrypt", targets: ["Bcrypt"]),
.library(name: "BCrypt", targets: ["BCrypt"]),
],
dependencies: [
],
targets: [
.target(name: "CBcrypt"),
.target(name: "Bcrypt", dependencies: [
.target(name: "CBcrypt"),
.target(name: "CBCrypt"),
.target(name: "BCrypt", dependencies: [
.target(name: "CBCrypt"),
]),
.testTarget(
name: "BcryptTests",
name: "BCryptTests",
dependencies: [
.target(name: "Bcrypt"),
.target(name: "BCrypt"),
]
),
]
Expand Down
51 changes: 48 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
# Swift BCrypt

## Install
Swift BCrypt implementation for securely hashing and verifying passwords using
adaptive cost factors, random salts, and constant-time comparison.

Add the repository as a dependency:
![Release: 2.0.0](https://img.shields.io/badge/Release-2%2E0%2E0-F05138)

## 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:
- Linux
- 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"),
```

Add `Bcrypt` to the target dependencies:
Then add `Bcrypt` to your target dependencies:

```swift
.product(name: "Bcrypt", package: "swift-bcrypt"),
```

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/bcrypt). Refer to the mock objects in the Tests directory if you want to build a custom database driver implementation.

> [!TIP]
> Avoid calling `database.execute` while in a transaction; use the transaction `connection` instead.

> [!WARNING]
> This repository is a work in progress, things can break until it reaches v1.0.0.

## Usage example

Basic example
Expand All @@ -32,3 +64,16 @@ let res = try Bcrypt.verify("binary-birds", created: digest)
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`
- 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. 🙏
Loading
Loading