Skip to content

Commit

Permalink
update cocoapods demo
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Sep 12, 2024
1 parent 896569a commit 576139c
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 242 deletions.
105 changes: 51 additions & 54 deletions CustomAuthDemo/CustomAuthDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import CustomAuth
import SwiftUI

struct ContentView: View {

var body: some View {
VStack {
Button(action: {
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .google, verifier: "w3a-google-demo", clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com")

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
Expand All @@ -18,19 +17,18 @@ struct ContentView: View {
} catch {
print(error)
}

}
}, label: {
Text("Google Login")
})

Button(action: {
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .discord, verifier: "w3a-discord-demo", clientId: "1151006428610433095")

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")

let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
let encoded = try JSONEncoder().encode(torusLoginResponse)
Expand All @@ -42,32 +40,31 @@ struct ContentView: View {
}, label: {
Text("Discord Login")
})


Button(action: {
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .facebook, verifier: "w3a-facebook-demo", clientId: "342380202252650")

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")

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


Button(action: {
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .facebook, verifier: "w3a-facebook-demo", clientId: "342380202252650")

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")

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

Button(action: {
let sub = SingleLoginParams(typeOfLogin: .twitch, verifier: "w3a-twitch-demo", clientId: "3k7e70gowvxjaxg71hjnc8h8ih3bpf")
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .twitch, verifier: "w3a-twitch-demo", clientId: "3k7e70gowvxjaxg71hjnc8h8ih3bpf")
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
let encoded = try JSONEncoder().encode(torusLoginResponse)
Expand All @@ -79,12 +76,13 @@ struct ContentView: View {
}, label: {
Text("Twitch Login")
})

Button(action: {
let sub = SingleLoginParams(typeOfLogin: .apple, verifier: "w3a-auth0-demo", clientId: "hUVVf4SEsZT7syOiL0gLU9hFEtm2gQ6O", jwtParams: Auth0ClientOptions(connection: "apple", domain: "web3auth.au.auth0.com"))
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .apple, verifier: "w3a-auth0-demo", clientId: "hUVVf4SEsZT7syOiL0gLU9hFEtm2gQ6O", jwtParams: Auth0ClientOptions(connection: "apple", domain: "web3auth.au.auth0.com"))
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")

let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
let encoded = try JSONEncoder().encode(torusLoginResponse)
Expand All @@ -96,12 +94,12 @@ struct ContentView: View {
}, label: {
Text("Apple Login")
})

Button(action: {
let sub = SingleLoginParams(typeOfLogin: .github, verifier: "w3a-auth0-demo", clientId: "hUVVf4SEsZT7syOiL0gLU9hFEtm2gQ6O", jwtParams: Auth0ClientOptions(connection: "github", domain: "web3auth.au.auth0.com", verifierIdField: "sub"))
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .github, verifier: "w3a-auth0-demo", clientId: "hUVVf4SEsZT7syOiL0gLU9hFEtm2gQ6O", jwtParams: Auth0ClientOptions(connection: "github", domain: "web3auth.au.auth0.com", verifierIdField: "sub"))
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
let encoded = try JSONEncoder().encode(torusLoginResponse)
Expand All @@ -113,17 +111,17 @@ struct ContentView: View {
}, label: {
Text("GitHub Login")
})

Button(action: {
let sub = SingleLoginParams(typeOfLogin: .email_password,
verifier: "torus-auth0-email-password", clientId: "sqKRBVSdwa4WLkaq419U7Bamlh5vK1H7",
jwtParams: Auth0ClientOptions(
connection: "Username-Password-Authentication",
domain: "torus-test.auth0.com",
verifierIdField: "name"))
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .legacy(.TESTNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
Task {
do {
let sub = SingleLoginParams(typeOfLogin: .email_password,
verifier: "torus-auth0-email-password", clientId: "sqKRBVSdwa4WLkaq419U7Bamlh5vK1H7",
jwtParams: Auth0ClientOptions(
connection: "Username-Password-Authentication",
domain: "torus-test.auth0.com",
verifierIdField: "name"))
let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .legacy(.TESTNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
let encoded = try JSONEncoder().encode(torusLoginResponse)
Expand All @@ -135,18 +133,18 @@ struct ContentView: View {
}, label: {
Text("Email Password")
})

Label(
title: { Text("Aggregate Verifiers") },
icon: { Image(systemName: "circle") }
)

Button(action: {
let aggregateLoginParams = AggregateLoginParams(aggregateVerifierType: AggregateVerifierType.single_id_verifier, verifierIdentifier: "aggregate-sapphire", subVerifierDetailsArray: [SingleLoginParams(typeOfLogin: .google, verifier: "w3a-google", clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com")])

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
Task {
do {
let aggregateLoginParams = AggregateLoginParams(aggregateVerifierType: AggregateVerifierType.single_id_verifier, verifierIdentifier: "aggregate-sapphire", subVerifierDetailsArray: [SingleLoginParams(typeOfLogin: .google, verifier: "w3a-google", clientId: "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com")])

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerAggregateLogin(args: aggregateLoginParams)
let encoded = try JSONEncoder().encode(torusLoginResponse)
Expand All @@ -158,14 +156,14 @@ struct ContentView: View {
}, label: {
Text("Aggregate Gmail")
})

Button(action: {
let subVerifierDetailsArray = SingleLoginParams(typeOfLogin: .github, verifier: "w3a-a0-github", clientId: "hiLqaop0amgzCC0AXo4w0rrG9abuJTdu", jwtParams: OAuthClientOptions(domain: "web3auth.au.auth0.com", verifierIdField: "email"))
let aggregateLoginParams = AggregateLoginParams(aggregateVerifierType: AggregateVerifierType.single_id_verifier, verifierIdentifier: "aggregate-sapphire", subVerifierDetailsArray: [subVerifierDetailsArray])

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
Task {
do {
let subVerifierDetailsArray = SingleLoginParams(typeOfLogin: .github, verifier: "w3a-a0-github", clientId: "hiLqaop0amgzCC0AXo4w0rrG9abuJTdu", jwtParams: OAuthClientOptions(domain: "web3auth.au.auth0.com", verifierIdField: "email"))
let aggregateLoginParams = AggregateLoginParams(aggregateVerifierType: AggregateVerifierType.single_id_verifier, verifierIdentifier: "aggregate-sapphire", subVerifierDetailsArray: [subVerifierDetailsArray])

let customAuthArgs = CustomAuthArgs(urlScheme: "tdsdk://tdsdk/oauthCallback", network: .sapphire(.SAPPHIRE_MAINNET), enableOneKey: true, web3AuthClientId: "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ")
let customAuth = try CustomAuth(config: customAuthArgs)
let torusLoginResponse = try await customAuth.triggerAggregateLogin(args: aggregateLoginParams)
let encoded = try JSONEncoder().encode(torusLoginResponse)
Expand All @@ -177,7 +175,6 @@ struct ContentView: View {
}, label: {
Text("Aggregate GitHub")
})

}
}
}
32 changes: 1 addition & 31 deletions cocoapods/cptest/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,13 @@ struct LoginView: View {
List {
Section(header: Text("Single Logins")) {
Group {
Button(action: {
vm.googlePolygonLogin()
}, label: {
Text("Google Polygon")
})

Button(action: {
vm.googleLogin()
}, label: {
Text("Google Login")
})
}

Button(action: {
vm.redditLogin()
}, label: {
Text("Reddit Login")
})

Button(action: {
vm.discordLogin()
}, label: {
Expand All @@ -43,36 +31,18 @@ struct LoginView: View {
Text("Twitch Login")
})

Button(action: {
vm.twitterLogin()
}, label: {
Text("Twitter Login")
})

Button(action: {
vm.githubLogin()
}, label: {
Text("Github Login")
})

Button(action: {
vm.linkedinLogin()
}, label: {
Text("Linkedin Login")
})

Button(action: {
vm.appleLogin()
}, label: {
Text("Apple Login")
})

Button(action: {
vm.weiboLogin()
}, label: {
Text("Weibo Login")
})


Button(action: {
vm.emailPasswordLogin()
}, label: {
Expand Down
Loading

0 comments on commit 576139c

Please sign in to comment.