Skip to content

Commit cf798b7

Browse files
Support Swift 5 (#49)
1 parent 513e7fe commit cf798b7

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.2.3
1+
5.0

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ matrix:
2525
dist: xenial
2626
sudo: required
2727
services: docker
28-
env: DOCKER_IMAGE=swift:4.2.3
28+
env: DOCKER_IMAGE=swift:4.2.4 SWIFT_SNAPSHOT=4.2.4
2929
- os: linux
3030
dist: xenial
3131
sudo: required
3232
services: docker
33-
env: DOCKER_IMAGE=swift:4.2.3 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
33+
env: DOCKER_IMAGE=swift:5.0-xenial
3434
- os: linux
3535
dist: xenial
3636
sudo: required
3737
services: docker
38-
env: DOCKER_IMAGE=ubuntu:18.04
38+
env: DOCKER_IMAGE=swift:5.0 SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
3939
- os: osx
4040
osx_image: xcode9.2
4141
sudo: required
@@ -47,8 +47,12 @@ matrix:
4747
- os: osx
4848
osx_image: xcode10.1
4949
sudo: required
50+
env: SWIFT_SNAPSHOT=4.2.1
5051
- os: osx
51-
osx_image: xcode10.1
52+
osx_image: xcode10.2
53+
sudo: required
54+
- os: osx
55+
osx_image: xcode10.2
5256
sudo: required
5357
env: SWIFT_SNAPSHOT=$SWIFT_DEVELOPMENT_SNAPSHOT
5458

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.0
22

33
/**
4-
* Copyright IBM Corporation 2018
4+
* Copyright IBM Corporation 2018-2019
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

Package@swift-4.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// swift-tools-version:4.0
2+
3+
/**
4+
* Copyright IBM Corporation 2018-2019
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
**/
18+
19+
import PackageDescription
20+
21+
let package = Package(
22+
name: "SwiftJWT",
23+
products: [
24+
// Products define the executables and libraries produced by a package, and make them visible to other packages.
25+
.library(
26+
name: "SwiftJWT",
27+
targets: ["SwiftJWT"]
28+
)
29+
],
30+
dependencies: [
31+
.package(url: "https://github.com/IBM-Swift/BlueRSA.git", from: "1.0.24"),
32+
.package(url: "https://github.com/IBM-Swift/BlueCryptor.git", from: "1.0.0"),
33+
.package(url: "https://github.com/IBM-Swift/BlueECC.git", from: "1.1.0"),
34+
.package(url: "https://github.com/IBM-Swift/LoggerAPI.git", from: "1.7.0"),
35+
.package(url: "https://github.com/IBM-Swift/KituraContracts.git", from: "1.1.0")
36+
],
37+
targets: [
38+
.target(name: "SwiftJWT", dependencies: ["CryptorRSA", "LoggerAPI", "KituraContracts", "Cryptor", "CryptorECC"]),
39+
.testTarget(name: "SwiftJWTTests", dependencies: ["SwiftJWT"])
40+
]
41+
)

Sources/SwiftJWT/BlueHMAC.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ class BlueHMAC: SignerAlgorithm, VerifierAlgorithm {
4747
guard let hmac = HMAC(using: algorithm, key: key).update(data: data)?.final() else {
4848
throw JWTError.invalidPrivateKey
4949
}
50+
#if swift(>=5.0)
51+
return Data(hmac)
52+
#else
5053
return Data(bytes: hmac)
54+
#endif
5155
}
5256

5357

0 commit comments

Comments
 (0)