Skip to content

Commit 2c091c8

Browse files
authored
Merge pull request #177 from mattrubin/develop
Release OneTimePassword 3.1.2
2 parents eb5be38 + d6ea54a commit 2c091c8

14 files changed

+47
-54
lines changed

.swiftlint.yml

+4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ opt_in_rules:
1111
- contains_over_first_not_nil
1212
- discouraged_object_literal
1313
- discouraged_optional_boolean
14+
- discouraged_optional_collection
1415
- empty_count
16+
- empty_string
1517
- explicit_enum_raw_value
1618
- explicit_init
1719
- extension_access_modifier
@@ -23,6 +25,7 @@ opt_in_rules:
2325
- joined_default_parameter
2426
- let_var_whitespace
2527
- literal_expression_end_indentation
28+
- lower_acl_than_parent
2629
- multiline_parameters
2730
- nimble_operator
2831
- operator_usage_whitespace
@@ -36,6 +39,7 @@ opt_in_rules:
3639
- sorted_first_last
3740
- switch_case_on_newline
3841
- unneeded_parentheses_in_closure_argument
42+
- untyped_error_in_catch
3943
- vertical_parameter_alignment_on_call
4044
- yoda_condition
4145
disabled_rules:

.travis.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@ language: objective-c
55
xcode_workspace: OneTimePassword.xcworkspace
66
xcode_scheme: OneTimePassword (iOS)
77

8-
osx_image: xcode9
8+
osx_image: xcode9.3
99

1010
env:
11-
- RUNTIME="iOS 8.1" DEVICE="iPad 2"
12-
- RUNTIME="iOS 8.4" DEVICE="iPhone 4s"
13-
- RUNTIME="iOS 9.0" DEVICE="iPhone 5s"
1411
- RUNTIME="iOS 9.3" DEVICE="iPhone 6s"
15-
- RUNTIME="iOS 10.0" DEVICE="iPhone SE"
1612
- RUNTIME="iOS 10.3" DEVICE="iPhone 7 Plus"
17-
- RUNTIME="iOS 11.0" DEVICE="iPhone X"
13+
- RUNTIME="iOS 11.3" DEVICE="iPhone X"
1814

1915
# Include builds for watchOS
2016
matrix:
2117
include:
18+
# Include an Xcode 9.0 build to test Swift 4.0 support
19+
- osx_image: xcode9
20+
env: RUNTIME="iOS 11.0" DEVICE="iPhone 8"
21+
# Include an Xcode 9.2 build to test on iOS 8.x, because Xcode 9.3's iOS 8 simulator fails to launch
22+
- osx_image: xcode9.2
23+
env: RUNTIME="iOS 8.4" DEVICE="iPhone 4s"
24+
# Include several build-only jobs for watchOS
2225
- xcode_scheme: OneTimePassword (watchOS)
23-
env: BUILD_ONLY="YES" RUNTIME="watchOS 4.0" DEVICE="Apple Watch Series 3 - 38mm"
26+
env: BUILD_ONLY="YES" RUNTIME="watchOS 4.3" DEVICE="Apple Watch Series 3 - 38mm"
2427
- xcode_scheme: OneTimePassword (watchOS)
2528
env: BUILD_ONLY="YES" RUNTIME="watchOS 3.2" DEVICE="Apple Watch Series 2 - 42mm"
2629
- xcode_scheme: OneTimePassword (watchOS)

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
<!--## [In development][develop]-->
44

5+
## [3.1.2][] (2018-04-23)
6+
- Synthesize Equatable conformance when compiling with Swift 4.1. ([#173](https://github.com/mattrubin/OneTimePassword/pull/173))
7+
- Fix a warning about deprecation of cross-module struct initializers by simplifying test cases for impossible-to-create invalid Generators. ([#174](https://github.com/mattrubin/OneTimePassword/pull/174))
8+
- Upgrade xcconfigs for Xcode 9.3. ([#172](https://github.com/mattrubin/OneTimePassword/pull/172))
9+
- Enable several new SwiftLint opt-in rules. ([#175](https://github.com/mattrubin/OneTimePassword/pull/175))
10+
11+
512
## [3.1.1][] (2018-03-31)
613
- Add support for Swift 4.1. ([#168](https://github.com/mattrubin/OneTimePassword/pull/168))
714
- Update build and linter settings for Xcode 9.3. ([#167](https://github.com/mattrubin/OneTimePassword/pull/167))
@@ -148,8 +155,9 @@ Changes between prerelease versions of OneTimePassword version 2 can be found be
148155

149156
## [1.0.0][] (2014-07-17)
150157

151-
[develop]: https://github.com/mattrubin/OneTimePassword/compare/3.1.1...develop
158+
[develop]: https://github.com/mattrubin/OneTimePassword/compare/3.1.2...develop
152159

160+
[3.1.2]: https://github.com/mattrubin/OneTimePassword/compare/3.1.1...3.1.2
153161
[3.1.1]: https://github.com/mattrubin/OneTimePassword/compare/3.1...3.1.1
154162
[3.1]: https://github.com/mattrubin/OneTimePassword/compare/3.0.1...3.1
155163
[3.0.1]: https://github.com/mattrubin/OneTimePassword/compare/3.0...3.0.1

Cartfile.private

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Configuration for Carthage (https://github.com/Carthage/Carthage)
22

3-
github "jspahrsummers/xcconfigs" ~> 0.11
3+
github "jspahrsummers/xcconfigs" ~> 0.12

Cartfile.resolved

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "jspahrsummers/xcconfigs" "0.11"
1+
github "jspahrsummers/xcconfigs" "0.12"
22
github "mattrubin/Base32" "xcode9"

Carthage/Checkouts/xcconfigs

OneTimePassword.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OneTimePassword"
3-
s.version = "3.1.1"
3+
s.version = "3.1.2"
44
s.summary = "A small library for generating TOTP and HOTP one-time passwords."
55
s.homepage = "https://github.com/mattrubin/OneTimePassword"
66
s.license = "MIT"

OneTimePassword.xcodeproj/project.pbxproj

-1
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,6 @@
743743
baseConfigurationReference = C996EC2E1A74D5830076B105 /* Release.xcconfig */;
744744
buildSettings = {
745745
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
746-
SWIFT_COMPILATION_MODE = wholemodule;
747746
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
748747
SWIFT_VERSION = 4.0;
749748
WATCHOS_DEPLOYMENT_TARGET = 2.0;

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Then run `pod install` to install the latest version of the framework.
5252

5353
## Usage
5454

55-
> The [latest version][swift-4] of OneTimePassword uses Swift 4, and can be linked with Swift 3.2 projects using the Swift compiler's [compatibility mode](https://swift.org/blog/swift-4-0-released/#new-compatibility-modes). To use OneTimePassword with earlier versions of Swift, check out the [`swift-3`][swift-3] and [`swift-2.3`][swift-2.3] branches. To use OneTimePassword in an Objective-C based project, check out the [`objc` branch][objc] and the [1.x releases][releases].
55+
> The [latest version][swift-4] of OneTimePassword compiles with Swift 4.x, and can be linked with Swift 3.2+ projects using the Swift compiler's [compatibility mode](https://swift.org/blog/swift-4-0-released/#new-compatibility-modes). To use OneTimePassword with earlier versions of Swift, check out the [`swift-3`][swift-3] and [`swift-2.3`][swift-2.3] branches. To use OneTimePassword in an Objective-C based project, check out the [`objc` branch][objc] and the [1.x releases][releases].
5656
5757
[swift-4]: https://github.com/mattrubin/OneTimePassword/tree/swift-4
5858
[swift-3]: https://github.com/mattrubin/OneTimePassword/tree/swift-3

Sources/Generator.swift

+3
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ public struct Generator: Equatable {
192192
}
193193
}
194194

195+
#if swift(>=4.1)
196+
#else
195197
/// Compares two `Generator`s for equality.
196198
public func == (lhs: Generator, rhs: Generator) -> Bool {
197199
return (lhs.factor == rhs.factor)
@@ -211,6 +213,7 @@ public func == (lhs: Generator.Factor, rhs: Generator.Factor) -> Bool {
211213
return false
212214
}
213215
}
216+
#endif
214217

215218
// MARK: - Private
216219

Sources/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.1.1</string>
18+
<string>3.1.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>3.1.1</string>
22+
<string>3.1.2</string>
2323
<key>NSPrincipalClass</key>
2424
<string></string>
2525
</dict>

Sources/PersistentToken.swift

+3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ public struct PersistentToken: Equatable, Hashable {
4848
}
4949
}
5050

51+
#if swift(>=4.1)
52+
#else
5153
/// Compares two `PersistentToken`s for equality.
5254
public func == (lhs: PersistentToken, rhs: PersistentToken) -> Bool {
5355
return (lhs.identifier == rhs.identifier)
5456
&& (lhs.token == rhs.token)
5557
}
58+
#endif

Sources/Token.swift

+3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ public struct Token: Equatable {
7070
}
7171
}
7272

73+
#if swift(>=4.1)
74+
#else
7375
/// Compares two `Token`s for equality.
7476
public func == (lhs: Token, rhs: Token) -> Bool {
7577
return (lhs.name == rhs.name)
7678
&& (lhs.issuer == rhs.issuer)
7779
&& (lhs.generator == rhs.generator)
7880
}
81+
#endif

Tests/GeneratorTests.swift

+8-38
Original file line numberDiff line numberDiff line change
@@ -174,35 +174,17 @@ class GeneratorTests: XCTestCase {
174174
}
175175

176176
func testPasswordWithInvalidPeriod() {
177-
let generator = Generator(unvalidatedFactor: .timer(period: 0))
178-
let time = Date(timeIntervalSince1970: 100)
179-
180-
do {
181-
_ = try generator.password(at: time)
182-
} catch Generator.Error.invalidPeriod {
183-
// This is the expected type of error
184-
return
185-
} catch {
186-
XCTFail("passwordAtTime(\(time)) threw an unexpected type of error: \(error))")
187-
return
188-
}
189-
XCTFail("passwordAtTime(\(time)) should throw an error)")
177+
// It should not be possible to try to get a password from a generator with an invalid period, because the
178+
// generator initializer should fail when given an invalid period.
179+
let generator = Generator(factor: .timer(period: 0), secret: Data(), algorithm: .sha1, digits: 8)
180+
XCTAssertNil(generator)
190181
}
191182

192183
func testPasswordWithInvalidDigits() {
193-
let generator = Generator(unvalidatedDigits: 3)
194-
let time = Date(timeIntervalSince1970: 100)
195-
196-
do {
197-
_ = try generator.password(at: time)
198-
} catch Generator.Error.invalidDigits {
199-
// This is the expected type of error
200-
return
201-
} catch {
202-
XCTFail("passwordAtTime(\(time)) threw an unexpected type of error: \(error))")
203-
return
204-
}
205-
XCTFail("passwordAtTime(\(time)) should throw an error)")
184+
// It should not be possible to try to get a password from a generator with an invalid digit count, because the
185+
// generator initializer should fail when given an invalid digit count.
186+
let generator = Generator(factor: .timer(period: 30), secret: Data(), algorithm: .sha1, digits: 3)
187+
XCTAssertNil(generator)
206188
}
207189

208190
// The values in this test are found in Appendix D of the HOTP RFC
@@ -283,15 +265,3 @@ class GeneratorTests: XCTestCase {
283265
}
284266
}
285267
}
286-
287-
private extension Generator {
288-
init(unvalidatedFactor factor: Factor = .timer(period: 30),
289-
unvalidatedSecret secret: Data = Data(),
290-
unvalidatedAlgorithm algorithm: Algorithm = .sha1,
291-
unvalidatedDigits digits: Int = 8) {
292-
self.factor = factor
293-
self.secret = secret
294-
self.algorithm = algorithm
295-
self.digits = digits
296-
}
297-
}

0 commit comments

Comments
 (0)