-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from NeedleInAJayStack/feature/client
Haystack client
- Loading branch information
Showing
23 changed files
with
1,432 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: test | ||
on: | ||
pull_request: | ||
push: { branches: [ main ] } | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: fwal/setup-swift@v1 | ||
- uses: actions/checkout@v2 | ||
- name: Run tests | ||
run: swift test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import CryptoKit | ||
|
||
@available(macOS 10.15, *) | ||
enum AuthHash: String { | ||
case SHA512 = "SHA-512" | ||
case SHA256 = "SHA-256" | ||
|
||
var hash: any HashFunction.Type { | ||
switch self { | ||
case .SHA256: | ||
return CryptoKit.SHA256.self | ||
case .SHA512: | ||
return CryptoKit.SHA512.self | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
struct AuthMessage: CustomStringConvertible { | ||
let scheme: String | ||
let attributes: [String: String] | ||
|
||
var description: String { | ||
// Unwrap is safe because attributes is immutable | ||
"\(scheme) \(attributes.keys.sorted().map { "\($0)=\(attributes[$0]!)" }.joined(separator: ", "))" | ||
} | ||
|
||
static func from(_ string: String) throws -> Self { | ||
// Example input: "SCRAM hash=SHA-256, handshakeToken=aabbcc" | ||
let scheme: String | ||
let attributes: [String: String] | ||
// If space exists then parse attributes as well. | ||
if let spaceIndex = string.firstIndex(of: " ") { | ||
scheme = String(string[..<spaceIndex]).trimmingCharacters(in: .whitespaces) | ||
let attributesString = String(string[spaceIndex...]).trimmingCharacters(in: .whitespaces) | ||
attributes = extractNameValuePairs(from: attributesString) | ||
} else { | ||
scheme = string | ||
attributes = [:] | ||
} | ||
return Self(scheme: scheme, attributes: attributes) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@available(macOS 10.15, *) | ||
protocol Authenticator { | ||
func getAuthToken() async throws -> String | ||
} |
Oops, something went wrong.