Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Jun 17, 2024
1 parent a9132df commit 931ca9c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
22 changes: 22 additions & 0 deletions CustomAuthDemo/CustomAuthDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,32 @@ struct ContentView: View {
} catch {
debugPrint(error)
}

}
}, label: {
Text("Google Login")
})
/*
Button(action: {
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .apple, verifier: "torus-auth0-apple-lrc", clientId: "m1Q0gvDfOyZsJCZ3cucSQEe9XMvl9d9L", redirectURL: "tdsdk://tdsdk/oauthCallback", jwtParams: Auth0ClientOptions(display: nil, prompt: nil, max_age: nil, ui_locales: nil, id_token_hint: nil, arc_values: nil, scope: nil, audience: nil, connection: "apple", domain: "torus-test.auth0.com", client_id: nil, redirect_url: nil, leeway: nil, verifierIdField: nil, isVerifierIdCaseSensitive: true, id_token: nil, access_token: nil, user_info_route: nil))

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_DEVNET), enableOneKey: true, web3AuthClientId: "BAh0_c0G8U8GoMUIYDcX_f65fU_N9O0mWz6xM6RqBfaaAlYsTha8oOef7ifXPjd_bCTJdfWQemmrbY6KepC7XNA")

let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
let encoded = try JSONEncoder().encode(torusLoginResponse)
debugPrint(String(data: encoded, encoding: .utf8)!)
} catch {
debugPrint(error)
}

}
}, label: {
Text("Apple Login")
})
*/
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Auth0ClientOptions: BaseLoginOptions {
public let access_token: String?
public let user_info_route: String?

public init(customParams: [String: String] = [:], display: String? = nil, prompt: String? = nil, max_age: Int? = nil, ui_locales: String? = nil, id_token_hint: String? = nil, arc_values: String? = nil, scope: String? = nil, audience: String? = nil, connection: String? = nil, domain: String? = nil, client_id: String? = nil, redirect_url: String? = nil, leeway: Int? = nil, verifierIdField: String? = nil, isVerifierIdCaseSensitive: Bool = false, id_token: String? = nil, access_token: String? = nil, user_info_route: String? = nil) {
public init(display: String? = nil, prompt: String? = nil, max_age: Int? = nil, ui_locales: String? = nil, id_token_hint: String? = nil, arc_values: String? = nil, scope: String? = nil, audience: String? = nil, connection: String? = nil, domain: String? = nil, client_id: String? = nil, redirect_url: String? = nil, leeway: Int? = nil, verifierIdField: String? = nil, isVerifierIdCaseSensitive: Bool = false, id_token: String? = nil, access_token: String? = nil, user_info_route: String? = nil) {
self.domain = domain
self.redirect_url = redirect_url
self.leeway = leeway
Expand All @@ -22,7 +22,7 @@ public class Auth0ClientOptions: BaseLoginOptions {
self.user_info_route = user_info_route
self.client_id = client_id

super.init(customParams: customParams, display: display, prompt: prompt, max_age: max_age, ui_locales: ui_locales, id_token_hint: id_token_hint, arc_values: arc_values, scope: scope, audience: audience, connection: connection)
super.init(display: display, prompt: prompt, max_age: max_age, ui_locales: ui_locales, id_token_hint: id_token_hint, arc_values: arc_values, scope: scope, audience: audience, connection: connection)
}

required init(from decoder: any Decoder) throws {
Expand Down
4 changes: 1 addition & 3 deletions Sources/CustomAuth/Common/LoginParams/BaseLoginOptions.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation

public class BaseLoginOptions: Codable {
public let customParams: [String: String]
public let display: String?
public let prompt: String?
public let max_age: Int?
Expand All @@ -12,8 +11,7 @@ public class BaseLoginOptions: Codable {
public let audience: String?
public let connection: String?

public init(customParams: [String: String] = [:], display: String? = nil, prompt: String? = nil, max_age: Int? = nil, ui_locales: String? = nil, id_token_hint: String? = nil, arc_values: String? = nil, scope: String? = nil, audience: String? = nil, connection: String? = nil) {
self.customParams = customParams
public init(display: String? = nil, prompt: String? = nil, max_age: Int? = nil, ui_locales: String? = nil, id_token_hint: String? = nil, arc_values: String? = nil, scope: String? = nil, audience: String? = nil, connection: String? = nil) {
self.display = display
self.prompt = prompt
self.max_age = max_age
Expand Down
9 changes: 3 additions & 6 deletions Sources/CustomAuth/Handlers/MockLoginHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ class MockLoginHandler: AbstractLoginHandler {
urlComponents.scheme = "https"
urlComponents.host = jwtParams?.domain
urlComponents.path = "/authorize"

let encoder = JSONEncoder()
encoder.outputFormatting = .sortedKeys
let hashParam = String(data: try encoder.encode(params), encoding: .utf8)!
urlComponents.setQueryItems(with: ["hash": hashParam])

urlComponents.fragment = params.compactMap({ (key, value) -> String in
return "\(key)=\(value)"
}).joined(separator: "&")
finalUrl = urlComponents
}

Expand Down

0 comments on commit 931ca9c

Please sign in to comment.