Skip to content

Commit

Permalink
Merge pull request #82 from SAP/add-oauth-disconnect
Browse files Browse the repository at this point in the history
Add oauth disconnect
  • Loading branch information
sagishm authored Apr 21, 2024
2 parents 25b469b + a257fb2 commit 61d5fc4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Gigya.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'Gigya'
spec.version = '1.6.0'
spec.version = '1.6.1'
spec.license = 'Apache 2.0'
spec.homepage = 'https://developers.gigya.com/display/GD/Swift+SDK'
spec.author = 'Gigya SAP'
Expand All @@ -10,7 +10,7 @@ Pod::Spec.new do |spec|
your Swift application
DESC

spec.source = { :git => 'https://github.com/SAP/gigya-swift-sdk.git', :tag => 'core/v1.6.0' }
spec.source = { :git => 'https://github.com/SAP/gigya-swift-sdk.git', :tag => 'core/v1.6.1' }
spec.module_name = 'Gigya'
spec.swift_version = '5.3'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ class SocialLoginProvider: Provider {
func getProviderSessions(token: String, expiration: String?, code: String?, firstName: String?, lastName: String?) -> String {
switch providerType {
case .facebook:
return "{\"\(providerType.rawValue)\": {\"authToken\": \"\(token)\", tokenExpiration: \"\(expiration ?? "")\"}}"
if let code = code {
return "{\"\(providerType.rawValue)\": {\"authToken\": \"\(token)\", tokenExpiration: \"\(expiration ?? "")\", idToken: \"\(code)\"}}"
} else {
return "{\"\(providerType.rawValue)\": {\"authToken\": \"\(token)\", tokenExpiration: \"\(expiration ?? "")\"}}"
}
case .line:
return "{\"\(providerType.rawValue)\":{\"authToken\": \"\(token)\"}}"
case .google:
Expand Down
9 changes: 9 additions & 0 deletions GigyaSwift/Global/WebAuthn/OauthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ class OauthService {
}
}

func disconnect(regToken: String, idToken: String, ignoreApiQueue: Bool = true, completion: @escaping (GigyaApiResult<GigyaDictionary>) -> Void) {
var model = ApiRequestModel(method: GigyaDefinitions.Oauth.disconnect, params: ["ignoreApiQueue": ignoreApiQueue, "regToken": regToken])
model.headers = ["Authorization": "Bearer \(idToken)"]
businessApiService.apiService.send(model: model, responseType: GigyaDictionary.self) { result in
completion(result)
}

}

@available(iOS 13.0.0, *)
func authorize<T: Codable>(token: String) async -> GigyaLoginResult<T> {
return await withCheckedContinuation { [weak self] continuation in
Expand Down
17 changes: 15 additions & 2 deletions GigyaSwift/Global/WebAuthn/WebAuthnService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,21 @@ public class WebAuthnService<T: GigyaAccountProtocol> {
private func revoke(key: String) async -> GigyaApiResult<GigyaDictionary> {
return await withCheckedContinuation({
continuation in
businessApiService.send(dataType: GigyaDictionary.self, api: GigyaDefinitions.WenAuthn.removeCredential, params: ["credentialId": key]) { result in
continuation.resume(returning: result)
businessApiService.send(dataType: GigyaDictionary.self, api: GigyaDefinitions.WenAuthn.removeCredential, params: ["credentialId": key]) { [weak self] result in
switch result {
case .success(let data):
guard let idToken = data["idToken"]?.value as? String else {
continuation.resume(returning: result)
return
}

self?.oauthService.disconnect(regToken: key, idToken: idToken) { _ in
continuation.resume(returning: result)
}
case .failure(_):
continuation.resume(returning: result)
}

}
})
}
Expand Down
1 change: 1 addition & 0 deletions GigyaSwift/Models/Config/GigyaDefinitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public struct GigyaDefinitions {

public struct Oauth {
static let connect = "oauth.connect"
static let disconnect = "oauth.disconnect"
static let authorize = "oauth.authorize"
static let token = "oauth.token"
}
Expand Down
2 changes: 1 addition & 1 deletion GigyaSwift/Models/Config/InternalConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

struct InternalConfig {
struct General {
internal static let version = "\(GigyaDefinitions.versionPrefix ?? "")ios_swift_1.6.0"
internal static let version = "\(GigyaDefinitions.versionPrefix ?? "")ios_swift_1.6.1"
internal static let sdkDomain = "com.gigya.GigyaSDK"
internal static let defaultLang = "en"
}
Expand Down

0 comments on commit 61d5fc4

Please sign in to comment.