Skip to content

Commit

Permalink
Merge pull request #70 from torusresearch/feat/web3authClientId
Browse files Browse the repository at this point in the history
feat: make clientId mandatory
  • Loading branch information
ieow authored Mar 26, 2024
2 parents 6b7c4d1 + b388fbd commit bb0c824
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@
"repositoryURL": "https://github.com/apple/swift-crypto.git",
"state": {
"branch": null,
"revision": "cc76b894169a3c86b71bac10c78a4db6beb7a9ad",
"version": "3.2.0"
"revision": "f0525da24dc3c6cbb2b6b338b65042bc91cbc4bb",
"version": "3.3.0"
}
},
{
"package": "TorusUtils",
"repositoryURL": "https://github.com/torusresearch/torus-utils-swift.git",
"state": {
"branch": null,
"revision": "3fb829e71caa275556a067a1ffa1ca579bafbf8e",
"version": "7.0.1"
"revision": "04c62fd5f73f21bd01b7c07e08f6135db26c5940",
"version": "8.0.0"
}
}
]
Expand Down
28 changes: 14 additions & 14 deletions CustomAuthDemo/CustomAuthDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
browserRedirectURL: "https://scripts.toruswallet.io/redirect.html")

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "google-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "221898609709-obfn3p63741l5333093430j3qeiinaa8.apps.googleusercontent.com", aggregateVerifierType: .singleLogin, aggregateVerifier: "google-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -48,7 +48,7 @@ struct ContentView: View {
clientId: "rXIp6g2y3h1wqg",
verifier: "reddit-shubs",
redirectURL: "tdsdk://tdsdk/oauthCallback")
let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "reddit-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "rXIp6g2y3h1wqg", aggregateVerifierType: .singleLogin, aggregateVerifier: "reddit-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -67,7 +67,7 @@ struct ContentView: View {
clientId: "700259843063152661",
verifier: "discord-shubs",
redirectURL: "tdsdk://tdsdk/oauthCallback")
let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "discord-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "700259843063152661", aggregateVerifierType: .singleLogin, aggregateVerifier: "discord-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -87,7 +87,7 @@ struct ContentView: View {
verifier: "facebook-shubs",
redirectURL: "tdsdk://tdsdk/oauthCallback", browserRedirectURL: "https://scripts.toruswallet.io/redirect.html")

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "facebook-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "221898609709-obfn3p63741l5333093430j3qeiinaa8.apps.googleusercontent.com", aggregateVerifierType: .singleLogin, aggregateVerifier: "facebook-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -106,7 +106,7 @@ struct ContentView: View {
clientId: "p560duf74b2bidzqu6uo0b3ot7qaao",
verifier: "twitch-shubs",
redirectURL: "tdsdk://tdsdk/oauthCallback")
let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "twitch-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "p560duf74b2bidzqu6uo0b3ot7qaao", aggregateVerifierType: .singleLogin, aggregateVerifier: "twitch-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -127,7 +127,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
jwtParams: ["domain": "torus-test.auth0.com"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-twitter-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "A7H8kkcmyFRlusJQ9dZiqBLraG2yWIsO", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-twitter-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -149,7 +149,7 @@ struct ContentView: View {
browserRedirectURL: "https://scripts.toruswallet.io/redirect.html",
jwtParams: ["domain": "torus-test.auth0.com"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-github-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "PC2a4tfNRvXbT48t89J5am0oFM21Nxff", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-github-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -170,7 +170,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
jwtParams: ["domain": "torus-test.auth0.com"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-linkedin-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "59YxSgx79Vl3Wi7tQUBqQTRTxWroTuoc", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-linkedin-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -191,7 +191,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
jwtParams: ["domain": "torus-test.auth0.com"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-apple-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "m1Q0gvDfOyZsJCZ3cucSQEe9XMvl9d9L", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-apple-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -214,7 +214,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
jwtParams: ["domain": "torus-test.auth0.com", "verifier_id_field": "name"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-email-passwordless", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "P7PJuBCXIHP41lcyty0NEb7Lgf7Zme8Q", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-email-passwordless", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -235,7 +235,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
jwtParams: ["domain": "torus-test.auth0.com"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-kakao-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "wpkcc7alGJjEgjaL6q5AWRqgRWHFsdTL", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-kakao-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -256,7 +256,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
jwtParams: ["domain": "torus-test.auth0.com"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-weibo-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "dhFGlWQMoACOI5oS5A1jFglp772OAWr1", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-weibo-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -277,7 +277,7 @@ struct ContentView: View {
redirectURL: "tdsdk://tdsdk/oauthCallback",
jwtParams: ["domain": "torus-test.auth0.com"])

let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-wechat-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "cewDD3i6F1vtHeV1KIbaxUZ8vJQjJZ8V", aggregateVerifierType: .singleLogin, aggregateVerifier: "torus-auth0-wechat-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand All @@ -299,7 +299,7 @@ struct ContentView: View {
clientId: "238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4.apps.googleusercontent.com",
verifier: "google-ios",
redirectURL: "com.googleusercontent.apps.238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4:/oauthredirect")
let tdsdk = CustomAuth(aggregateVerifierType: .singleIdVerifier, aggregateVerifier: "multigoogle-torus", subVerifierDetails: [sub], network: .legacy(.TESTNET))
let tdsdk = CustomAuth(web3AuthClientId: "238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4.apps.googleusercontent.com", aggregateVerifierType: .singleIdVerifier, aggregateVerifier: "multigoogle-torus", subVerifierDetails: [sub], network: .legacy(.TESTNET))
Task {
do {
let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData!
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"repositoryURL": "https://github.com/torusresearch/torus-utils-swift.git",
"state": {
"branch": null,
"revision": "3fb829e71caa275556a067a1ffa1ca579bafbf8e",
"version": "7.0.1"
"revision": "04c62fd5f73f21bd01b7c07e08f6135db26c5940",
"version": "8.0.0"
}
}
]
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.2
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -14,14 +14,14 @@ let package = Package(
targets: ["CustomAuth"])
],
dependencies: [
.package(name: "TorusUtils", url: "https://github.com/torusresearch/torus-utils-swift.git", from: "7.0.1"),
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", from: "8.0.0"),
.package(name: "jwt-kit", url: "https://github.com/vapor/jwt-kit.git", from: "4.13.0"),
.package(name: "JWTDecode", url: "https://github.com/auth0/JWTDecode.swift.git", from: "3.1.0")
],
targets: [
.target(
name: "CustomAuth",
dependencies: ["TorusUtils", "JWTDecode"]),
dependencies: ["JWTDecode", .product(name: "TorusUtils", package: "torus-utils-swift")]),
.testTarget(
name: "CustomAuthTests",
dependencies: ["CustomAuth", .product(name: "JWTKit", package: "jwt-kit")])
Expand Down
21 changes: 13 additions & 8 deletions Sources/CustomAuth/CustomAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ var tsSdkLogType = OSLogType.default
public struct TorusKeyData {
public let torusKey : TorusKey
public var userInfo : [String: Any]

public init(torusKey: TorusKey, userInfo: [String : Any]) {
self.torusKey = torusKey
self.userInfo = userInfo
}
}

/// Provides integration of an iOS app with Torus CustomAuth.
Expand All @@ -44,15 +49,15 @@ open class CustomAuth {
/// - factory: Providng mocking by implementing TDSDKFactoryProtocol.
/// - network: Etherum network to be used.
/// - loglevel: Indicates the log level of this instance. All logs lower than this level will be ignored.
public init(aggregateVerifierType: verifierTypes, aggregateVerifier: String, subVerifierDetails: [SubVerifierDetails], network: TorusNetwork = .legacy(.MAINNET), loglevel: OSLogType = .debug, urlSession: URLSession = URLSession.shared, enableOneKey: Bool = false, networkUrl: String? = nil) {
public init(web3AuthClientId: String ,aggregateVerifierType: verifierTypes, aggregateVerifier: String, subVerifierDetails: [SubVerifierDetails], network: TorusNetwork, loglevel: OSLogType = .debug, urlSession: URLSession = URLSession.shared, enableOneKey: Bool = false, networkUrl: String? = nil) {
tsSdkLogType = loglevel
self.networkUrl = networkUrl
self.enableOneKey = enableOneKey
// factory method
self.nodeDetailManager = NodeDetailManager(network: network)
self.urlSession = urlSession

self.torusUtils = TorusUtils(loglevel: loglevel, urlSession: urlSession, enableOneKey: enableOneKey, serverTimeOffset: 1000, network: network)
self.torusUtils = TorusUtils( loglevel: loglevel, urlSession: urlSession, enableOneKey: enableOneKey, serverTimeOffset: 1000, network: network, clientId: web3AuthClientId)

// verifier details
self.aggregateVerifier = aggregateVerifier
Expand All @@ -66,15 +71,15 @@ open class CustomAuth {
/// - aggregateVerifierType: Type of the verifier. Use `singleLogin` for single providers. Only `singleLogin` and `singleIdVerifier` is supported currently.
/// - aggregateVerifier: Name of the verifier to be used..
/// - subVerifierDetails: Details of each subverifiers to be used.
public convenience init(aggregateVerifierType: verifierTypes, aggregateVerifier: String, subVerifierDetails: [SubVerifierDetails], enableOneKey: Bool = false, networkUrl: String? = nil) {
public convenience init(web3AuthClientId: String ,aggregateVerifierType: verifierTypes, aggregateVerifier: String, subVerifierDetails: [SubVerifierDetails], network: TorusNetwork, enableOneKey: Bool = false, networkUrl: String? = nil) {
// let factory = CASDKFactory()
self.init(aggregateVerifierType: aggregateVerifierType, aggregateVerifier: aggregateVerifier, subVerifierDetails: subVerifierDetails, network: .legacy(.MAINNET), loglevel: .debug, enableOneKey: enableOneKey, networkUrl: networkUrl)
self.init(web3AuthClientId: web3AuthClientId, aggregateVerifierType: aggregateVerifierType, aggregateVerifier: aggregateVerifier, subVerifierDetails: subVerifierDetails, network: network, loglevel: .debug, enableOneKey: enableOneKey, networkUrl: networkUrl)
}

public convenience init(aggregateVerifierType: verifierTypes, aggregateVerifier: String, subVerifierDetails: [SubVerifierDetails], loglevel: OSLogType = .debug, enableOneKey: Bool = false, networkUrl: String? = nil) {
// let factory = CASDKFactory()
self.init(aggregateVerifierType: aggregateVerifierType, aggregateVerifier: aggregateVerifier, subVerifierDetails: subVerifierDetails, network: .legacy(.MAINNET), loglevel: loglevel, enableOneKey: enableOneKey, networkUrl: networkUrl)
}
// public convenience init(web3AuthClientId: String ,aggregateVerifierType: verifierTypes, aggregateVerifier: String, subVerifierDetails: [SubVerifierDetails], network: TorusNetwork, loglevel: OSLogType = .debug, enableOneKey: Bool = false, networkUrl: String? = nil) {
//// let factory = CASDKFactory()
// self.init(web3AuthClientId: web3AuthClientId, aggregateVerifierType: aggregateVerifierType, aggregateVerifier: aggregateVerifier, subVerifierDetails: subVerifierDetails, network: network, loglevel: loglevel, enableOneKey: enableOneKey, networkUrl: networkUrl)
// }

/// Retrieve information of Torus nodes from a predefined Etherum contract.
/// - Returns: An array of URLs to the nodes.
Expand Down
Loading

0 comments on commit bb0c824

Please sign in to comment.