Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Commit 792fb5d

Browse files
authored
Use latest WordPressKit version (#808)
2 parents 7d32968 + 793f8ac commit 792fb5d

File tree

11 files changed

+34
-40
lines changed

11 files changed

+34
-40
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ _None._
4646

4747
### Internal Changes
4848

49-
_None._
49+
* Depend on WordPressKit 9.0.0 and make necessary code changes to adopt the new API. [808]
5050

5151
## 7.3.1
5252

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def wordpress_authenticator_pods
2828
## These should match the version requirement from the podspec.
2929
pod 'Gridicons', '~> 1.0'
3030
pod 'WordPressUI', '~> 1.7-beta'
31-
pod 'WordPressKit', '~> 8.7-beta'
31+
pod 'WordPressKit', '~> 9.0.0'
3232
pod 'WordPressShared', '~> 2.1-beta'
3333

3434
third_party_pods

Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ PODS:
1313
- Gridicons (~> 1.0)
1414
- "NSURL+IDN (= 0.4)"
1515
- SVProgressHUD (~> 2.2.5)
16-
- WordPressKit (~> 8.7-beta)
16+
- WordPressKit (~> 9.0.0)
1717
- WordPressShared (~> 2.1-beta)
1818
- WordPressUI (~> 1.7-beta)
19-
- WordPressKit (8.11.0):
19+
- WordPressKit (9.0.0):
2020
- Alamofire (~> 4.8.0)
2121
- NSObject-SafeExpectations (~> 0.0.4)
2222
- UIDeviceIdentifier (~> 2.0)
@@ -35,7 +35,7 @@ DEPENDENCIES:
3535
- SVProgressHUD (= 2.2.5)
3636
- SwiftLint (~> 0.49)
3737
- WordPressAuthenticator (from `.`)
38-
- WordPressKit (~> 8.7-beta)
38+
- WordPressKit (~> 9.0.0)
3939
- WordPressShared (~> 2.1-beta)
4040
- WordPressUI (~> 1.7-beta)
4141

@@ -71,12 +71,12 @@ SPEC CHECKSUMS:
7171
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
7272
SwiftLint: 32ee33ded0636d0905ef6911b2b67bbaeeedafa5
7373
UIDeviceIdentifier: 442b65b4ff1832d4ca9c2a157815cb29ad981b17
74-
WordPressAuthenticator: 503a174d8ccc0781a0f5769e5e284e07cb294dc0
75-
WordPressKit: 13e01ed70f6ab2397c228959bc47cb2073521f63
74+
WordPressAuthenticator: 5e7eadec3fecf2e1382a5ae8a810149413de962e
75+
WordPressKit: 3f599b50b996e4352efa5594e6de95e53315da12
7676
WordPressShared: 0aa459e5257a77184db87805a998f447443c9706
7777
WordPressUI: 1cf47a3b78154faf69caa18569ee7ece1e510fa0
7878
wpxmlrpc: 68db063041e85d186db21f674adf08d9c70627fd
7979

80-
PODFILE CHECKSUM: 537f0cb26852aae6d94a89c678a95bc8bd640a01
80+
PODFILE CHECKSUM: 53b90d4674a5a238bb3fca5e6e500c0a2d220ca6
8181

8282
COCOAPODS: 1.11.3

WordPressAuthenticator.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ Pod::Spec.new do |s|
4040
# Use a loose restriction that allows both production and beta versions, up to the next major version.
4141
# If you want to update which of these is used, specify it in the host app.
4242
s.dependency 'WordPressUI', '~> 1.7-beta'
43-
s.dependency 'WordPressKit', '~> 8.7-beta'
43+
s.dependency 'WordPressKit', '~> 9.0.0'
4444
s.dependency 'WordPressShared', '~> 2.1-beta'
4545
end

WordPressAuthenticator/Services/WordPressComOAuthClientFacade.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import WordPressKit
1717
password: String,
1818
multifactorCode: String?,
1919
success: @escaping (_ authToken: String?) -> Void,
20-
needsMultifactor: ((_ userID: Int, _ nonceInfo: SocialLogin2FANonceInfo?) -> Void)?,
20+
needsMultifactor: @escaping ((_ userID: Int, _ nonceInfo: SocialLogin2FANonceInfo?) -> Void),
2121
failure: ((_ error: Error) -> Void)?
2222
) {
23-
self.client.authenticateWithUsername(username, password: password, multifactorCode: multifactorCode, needsMultifactor: needsMultifactor, success: success, failure: { error in
24-
if error.code == WordPressComOAuthError.needsMultifactorCode.rawValue {
25-
needsMultifactor?(0, nil)
23+
self.client.authenticate(username: username, password: password, multifactorCode: multifactorCode, needsMultifactor: needsMultifactor, success: success, failure: { error in
24+
if case let .endpointError(authenticationFailure) = error, authenticationFailure.kind == .needsMultifactorCode {
25+
needsMultifactor(0, nil)
2626
} else {
2727
failure?(error)
2828
}
@@ -35,7 +35,7 @@ import WordPressKit
3535
success: @escaping () -> Void,
3636
failure: @escaping (_ error: Error) -> Void
3737
) {
38-
self.client.requestOneTimeCodeWithUsername(username, password: password, success: success, failure: failure)
38+
self.client.requestOneTimeCode(username: username, password: password, success: success, failure: failure)
3939
}
4040

4141
public func requestSocial2FACode(
@@ -44,7 +44,7 @@ import WordPressKit
4444
success: @escaping (_ newNonce: String) -> Void,
4545
failure: @escaping (_ error: Error, _ newNonce: String?) -> Void
4646
) {
47-
self.client.requestSocial2FACodeWithUserID(userID, nonce: nonce, success: success, failure: failure)
47+
self.client.requestSocial2FACode(userID: userID, nonce: nonce, success: success, failure: failure)
4848
}
4949

5050
public func authenticate(
@@ -55,8 +55,8 @@ import WordPressKit
5555
existingUserNeedsConnection: @escaping (_ email: String) -> Void,
5656
failure: @escaping (_ error: Error) -> Void
5757
) {
58-
self.client.authenticateWithIDToken(
59-
socialIDToken,
58+
self.client.authenticate(
59+
socialIDToken: socialIDToken,
6060
service: service,
6161
success: success,
6262
needsMultifactor: needsMultifactor,
@@ -73,8 +73,8 @@ import WordPressKit
7373
success: @escaping (_ authToken: String?) -> Void,
7474
failure: @escaping (_ error: Error) -> Void
7575
) {
76-
self.client.authenticateSocialLoginUser(
77-
userID,
76+
self.client.authenticate(
77+
socialLoginUserID: userID,
7878
authType: authType,
7979
twoStepCode: twoStepCode,
8080
twoStepNonce: twoStepNonce,

WordPressAuthenticator/Services/WordPressComOAuthClientFacadeProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import WordPressKit
1111
password: String,
1212
multifactorCode: String?,
1313
success: @escaping (_ authToken: String?) -> Void,
14-
needsMultifactor: ((_ userID: Int, _ nonceInfo: SocialLogin2FANonceInfo?) -> Void)?,
14+
needsMultifactor: @escaping ((_ userID: Int, _ nonceInfo: SocialLogin2FANonceInfo?) -> Void),
1515
failure: ((_ error: Error) -> Void)?
1616
)
1717

WordPressAuthenticator/Signin/Login2FAViewController.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,13 @@ extension Login2FAViewController {
316316
displayError(message: "")
317317

318318
configureViewLoading(false)
319-
let err = error as NSError
320319
let bad2FAMessage = NSLocalizedString("Whoops, that's not a valid two-factor verification code. Double-check your code and try again!", comment: "Error message shown when an incorrect two factor code is provided.")
321-
if err.domain == "WordPressComOAuthError" && err.code == WordPressComOAuthError.invalidOneTimePassword.rawValue {
320+
if (error as? WordPressComOAuthError)?.authenticationFailureKind == .invalidOneTimePassword {
322321
// Invalid verification code.
323322
displayError(message: bad2FAMessage)
324-
} else if err.domain == "WordPressComOAuthError" && err.code == WordPressComOAuthError.invalidTwoStepCode.rawValue {
323+
} else if case let .endpointError(authenticationFailure) = (error as? WordPressComOAuthError), authenticationFailure.kind == .invalidTwoStepCode {
325324
// Invalid 2FA during social login
326-
if let newNonce = (error as NSError).userInfo[WordPressComOAuthClient.WordPressComOAuthErrorNewNonceKey] as? String {
325+
if let newNonce = authenticationFailure.newNonce {
327326
loginFields.nonceInfo?.updateNonce(with: newNonce)
328327
}
329328
displayError(message: bad2FAMessage)

WordPressAuthenticator/Signin/LoginWPComViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ class LoginWPComViewController: LoginViewController, NUXKeyboardResponder {
206206
override func displayRemoteError(_ error: Error) {
207207
configureViewLoading(false)
208208

209-
let errorCode = (error as NSError).code
210-
let errorDomain = (error as NSError).domain
211-
if errorDomain == WordPressComOAuthClient.WordPressComOAuthErrorDomain, errorCode == WordPressComOAuthError.invalidRequest.rawValue {
209+
if (error as? WordPressComOAuthError)?.authenticationFailureKind == .invalidRequest {
212210
let message = NSLocalizedString("It seems like you've entered an incorrect password. Want to give it another try?", comment: "An error message shown when a wpcom user provides the wrong password.")
213211
displayError(message: message)
214212
} else {

WordPressAuthenticator/Unified Auth/GoogleAuthenticator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ extension GoogleAuthenticator: LoginFacadeDelegate {
340340

341341
var errorTitle = LocalizedText.googleUnableToConnect
342342
var errorDescription = error.localizedDescription
343-
let unknownUser = (error as NSError).code == WordPressComOAuthError.unknownUser.rawValue
343+
let unknownUser = (error as? WordPressComOAuthError)?.authenticationFailureKind == .unknownUser
344344

345345
if unknownUser {
346346
errorTitle = LocalizedText.googleConnected

WordPressAuthenticator/Unified Auth/View Related/2FA/TwoFAViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ final class TwoFAViewController: LoginViewController {
129129
}
130130

131131
configureViewLoading(false)
132-
if err.domain == "WordPressComOAuthError" && err.code == WordPressComOAuthError.invalidOneTimePassword.rawValue {
132+
if (error as? WordPressComOAuthError)?.authenticationFailureKind == .invalidOneTimePassword {
133133
// Invalid verification code.
134134
displayError(message: LocalizedText.bad2FAMessage, moveVoiceOverFocus: true)
135-
} else if err.domain == "WordPressComOAuthError" && err.code == WordPressComOAuthError.invalidTwoStepCode.rawValue {
135+
} else if case let .endpointError(authenticationFailure) = (error as? WordPressComOAuthError), authenticationFailure.kind == .invalidTwoStepCode {
136136
// Invalid 2FA during social login
137-
if let newNonce = (error as NSError).userInfo[WordPressComOAuthClient.WordPressComOAuthErrorNewNonceKey] as? String {
137+
if let newNonce = authenticationFailure.newNonce {
138138
loginFields.nonceInfo?.updateNonce(with: newNonce)
139139
}
140140
displayError(message: LocalizedText.bad2FAMessage, moveVoiceOverFocus: true)

0 commit comments

Comments
 (0)