From ac3c9e144840c8315dd1cb947cd673a181a52dbd Mon Sep 17 00:00:00 2001 From: metalurgical <97008724+metalurgical@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:20:21 +0200 Subject: [PATCH] fix: update demo for v7 --- .../CustomAuthDemo.xcodeproj/project.pbxproj | 26 +- .../xcshareddata/swiftpm/Package.resolved | 97 ++++ .../CustomAuthDemo/ContentView.swift | 506 +++++++++--------- Sources/CustomAuth/CustomAuth.swift | 2 - .../Extension/CASDK+extension.swift | 8 +- .../EthereumNetworkFND+extension.swift | 2 +- cocoapods/Podfile | 2 +- 7 files changed, 392 insertions(+), 251 deletions(-) create mode 100644 CustomAuthDemo/CustomAuthDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/CustomAuthDemo/CustomAuthDemo.xcodeproj/project.pbxproj b/CustomAuthDemo/CustomAuthDemo.xcodeproj/project.pbxproj index f6d5904..f62f369 100644 --- a/CustomAuthDemo/CustomAuthDemo.xcodeproj/project.pbxproj +++ b/CustomAuthDemo/CustomAuthDemo.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -16,6 +16,7 @@ 511CEAE32452D4EF00A7ACE9 /* CustomAuthDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 511CEAE22452D4EF00A7ACE9 /* CustomAuthDemoTests.swift */; }; 511CEAEE2452D4EF00A7ACE9 /* CustomAuthDemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 511CEAED2452D4EF00A7ACE9 /* CustomAuthDemoUITests.swift */; }; 51775EB72484B66A00A29680 /* CustomAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 51775EB62484B66A00A29680 /* CustomAuth */; }; + B36D0EFF2BA033AD008F4C71 /* PromiseKit in Frameworks */ = {isa = PBXBuildFile; productRef = B36D0EFE2BA033AD008F4C71 /* PromiseKit */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -61,6 +62,7 @@ buildActionMask = 2147483647; files = ( 51775EB72484B66A00A29680 /* CustomAuth in Frameworks */, + B36D0EFF2BA033AD008F4C71 /* PromiseKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -186,6 +188,7 @@ name = CustomAuthDemo; packageProductDependencies = ( 51775EB62484B66A00A29680 /* CustomAuth */, + B36D0EFE2BA033AD008F4C71 /* PromiseKit */, ); productName = CustomAuthDemo; productReference = 511CEAC82452D4EC00A7ACE9 /* CustomAuthDemo.app */; @@ -260,6 +263,7 @@ ); mainGroup = 511CEABF2452D4EC00A7ACE9; packageReferences = ( + B36D0EFD2BA033AD008F4C71 /* XCRemoteSwiftPackageReference "PromiseKit" */, ); productRefGroup = 511CEAC92452D4EC00A7ACE9 /* Products */; projectDirPath = ""; @@ -475,7 +479,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_ENTITLEMENTS = CustomAuthDemo/CustomAuthDemo.entitlements; + CODE_SIGN_ENTITLEMENTS = ""; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"CustomAuthDemo/Preview Content\""; DEVELOPMENT_TEAM = 2Q63NCPY55; @@ -497,7 +501,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_ENTITLEMENTS = CustomAuthDemo/CustomAuthDemo.entitlements; + CODE_SIGN_ENTITLEMENTS = ""; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_ASSET_PATHS = "\"CustomAuthDemo/Preview Content\""; DEVELOPMENT_TEAM = 2Q63NCPY55; @@ -636,11 +640,27 @@ }; /* End XCConfigurationList section */ +/* Begin XCRemoteSwiftPackageReference section */ + B36D0EFD2BA033AD008F4C71 /* XCRemoteSwiftPackageReference "PromiseKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/mxcl/PromiseKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 8.1.1; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + /* Begin XCSwiftPackageProductDependency section */ 51775EB62484B66A00A29680 /* CustomAuth */ = { isa = XCSwiftPackageProductDependency; productName = CustomAuth; }; + B36D0EFE2BA033AD008F4C71 /* PromiseKit */ = { + isa = XCSwiftPackageProductDependency; + package = B36D0EFD2BA033AD008F4C71 /* XCRemoteSwiftPackageReference "PromiseKit" */; + productName = PromiseKit; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 511CEAC02452D4EC00A7ACE9 /* Project object */; diff --git a/CustomAuthDemo/CustomAuthDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CustomAuthDemo/CustomAuthDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..80f6b1d --- /dev/null +++ b/CustomAuthDemo/CustomAuthDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,97 @@ +{ + "object": { + "pins": [ + { + "package": "AnyCodable", + "repositoryURL": "https://github.com/Flight-School/AnyCodable", + "state": { + "branch": null, + "revision": "862808b2070cd908cb04f9aafe7de83d35f81b05", + "version": "0.6.7" + } + }, + { + "package": "BigInt", + "repositoryURL": "https://github.com/attaswift/BigInt.git", + "state": { + "branch": null, + "revision": "0ed110f7555c34ff468e72e1686e59721f2b0da6", + "version": "5.3.0" + } + }, + { + "package": "CryptoSwift", + "repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift", + "state": { + "branch": null, + "revision": "7892a123f7e8d0fe62f9f03728b17bbd4f94df5c", + "version": "1.8.1" + } + }, + { + "package": "curvelib.swift", + "repositoryURL": "https://github.com/tkey/curvelib.swift", + "state": { + "branch": null, + "revision": "7dad3bf1793de263f83406c08c18c9316abf082f", + "version": "0.1.2" + } + }, + { + "package": "FetchNodeDetails", + "repositoryURL": "https://github.com/torusresearch/fetch-node-details-swift", + "state": { + "branch": null, + "revision": "d591af500f32ce3c88d04af9bb74d746585acfea", + "version": "5.1.0" + } + }, + { + "package": "jwt-kit", + "repositoryURL": "https://github.com/vapor/jwt-kit.git", + "state": { + "branch": null, + "revision": "e05513b5aec24f88012b6e3034115b6bc915356a", + "version": "4.13.2" + } + }, + { + "package": "JWTDecode", + "repositoryURL": "https://github.com/auth0/JWTDecode.swift.git", + "state": { + "branch": null, + "revision": "58af7278797871e460d79496621b3e5366b865b2", + "version": "3.1.0" + } + }, + { + "package": "PromiseKit", + "repositoryURL": "https://github.com/mxcl/PromiseKit", + "state": { + "branch": null, + "revision": "cb70b070cde06837cd10a1febdf6105c1a3bb348", + "version": "8.1.1" + } + }, + { + "package": "swift-crypto", + "repositoryURL": "https://github.com/apple/swift-crypto.git", + "state": { + "branch": null, + "revision": "cc76b894169a3c86b71bac10c78a4db6beb7a9ad", + "version": "3.2.0" + } + }, + { + "package": "TorusUtils", + "repositoryURL": "https://github.com/torusresearch/torus-utils-swift.git", + "state": { + "branch": null, + "revision": "3fb829e71caa275556a067a1ffa1ca579bafbf8e", + "version": "7.0.1" + } + } + ] + }, + "version": 1 +} diff --git a/CustomAuthDemo/CustomAuthDemo/ContentView.swift b/CustomAuthDemo/CustomAuthDemo/ContentView.swift index 2043273..405fbf5 100644 --- a/CustomAuthDemo/CustomAuthDemo/ContentView.swift +++ b/CustomAuthDemo/CustomAuthDemo/ContentView.swift @@ -20,271 +20,297 @@ struct ContentView: View { NavigationView { List { Section(header: Text("Single Logins")) { - Group { - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .google, - clientId: "221898609709-obfn3p63741l5333093430j3qeiinaa8.apps.googleusercontent.com", - verifierName: "google-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - browserRedirectURL: "https://scripts.toruswallet.io/redirect.html") - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "google-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + // Group { + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .google, + clientId: "221898609709-obfn3p63741l5333093430j3qeiinaa8.apps.googleusercontent.com", + verifier: "google-lrc", + redirectURL: "tdsdk://tdsdk/oauthCallback", + browserRedirectURL: "https://scripts.toruswallet.io/redirect.html") + + let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "google-lrc", subVerifierDetails: [sub], network: .legacy(.TESTNET)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Google Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .reddit, - clientId: "rXIp6g2y3h1wqg", - verifierName: "reddit-shubs", - redirectURL: "tdsdk://tdsdk/oauthCallback") - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "reddit-shubs", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Google Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .reddit, + clientId: "rXIp6g2y3h1wqg", + verifier: "reddit-shubs", + redirectURL: "tdsdk://tdsdk/oauthCallback") + let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "reddit-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Reddit Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .discord, - clientId: "700259843063152661", - verifierName: "discord-shubs", - redirectURL: "tdsdk://tdsdk/oauthCallback") - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "discord-shubs", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Reddit Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .discord, + clientId: "700259843063152661", + verifier: "discord-shubs", + redirectURL: "tdsdk://tdsdk/oauthCallback") + let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "discord-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Discord Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .facebook, - clientId: "659561074900150", - verifierName: "facebook-shubs", - redirectURL: "tdsdk://tdsdk/oauthCallback", browserRedirectURL: "https://scripts.toruswallet.io/redirect.html") - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "facebook-shubs", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Discord Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .facebook, + clientId: "659561074900150", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Facebook Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .twitch, - clientId: "p560duf74b2bidzqu6uo0b3ot7qaao", - verifierName: "twitch-shubs", - redirectURL: "tdsdk://tdsdk/oauthCallback") - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "twitch-shubs", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Facebook Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .twitch, + clientId: "p560duf74b2bidzqu6uo0b3ot7qaao", + verifier: "twitch-shubs", + redirectURL: "tdsdk://tdsdk/oauthCallback") + let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifier: "twitch-shubs", subVerifierDetails: [sub], network: .legacy(.TESTNET)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Twitch Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .twitter, - clientId: "A7H8kkcmyFRlusJQ9dZiqBLraG2yWIsO", - verifierName: "torus-auth0-twitter-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - jwtParams: ["domain": "torus-test.auth0.com"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-twitter-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Twitch Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .twitter, + clientId: "A7H8kkcmyFRlusJQ9dZiqBLraG2yWIsO", + verifier: "torus-auth0-twitter-lrc", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Twitter Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .github, - clientId: "PC2a4tfNRvXbT48t89J5am0oFM21Nxff", - verifierName: "torus-auth0-github-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - browserRedirectURL: "https://scripts.toruswallet.io/redirect.html", - jwtParams: ["domain": "torus-test.auth0.com"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-github-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Twitter Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .github, + clientId: "PC2a4tfNRvXbT48t89J5am0oFM21Nxff", + verifier: "torus-auth0-github-lrc", + redirectURL: "tdsdk://tdsdk/oauthCallback", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Github Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .linkedin, - clientId: "59YxSgx79Vl3Wi7tQUBqQTRTxWroTuoc", - verifierName: "torus-auth0-linkedin-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - jwtParams: ["domain": "torus-test.auth0.com"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-linkedin-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Github Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .linkedin, + clientId: "59YxSgx79Vl3Wi7tQUBqQTRTxWroTuoc", + verifier: "torus-auth0-linkedin-lrc", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Linkedin Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .apple, - clientId: "m1Q0gvDfOyZsJCZ3cucSQEe9XMvl9d9L", - verifierName: "torus-auth0-apple-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - jwtParams: ["domain": "torus-test.auth0.com"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-apple-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Linkedin Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .apple, + clientId: "m1Q0gvDfOyZsJCZ3cucSQEe9XMvl9d9L", + verifier: "torus-auth0-apple-lrc", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Apple Login") - }) - } - - Group { - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .jwt, - clientId: "P7PJuBCXIHP41lcyty0NEb7Lgf7Zme8Q", - verifierName: "torus-auth0-email-passwordless", - redirectURL: "tdsdk://tdsdk/oauthCallback", - jwtParams: ["domain": "torus-test.auth0.com", "verifier_id_field": "name"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-email-passwordless", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Apple Login") + }) + // } + + // Group { + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .jwt, + clientId: "P7PJuBCXIHP41lcyty0NEb7Lgf7Zme8Q", + verifier: "torus-auth0-email-passwordless", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Email-password Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .kakao, - clientId: "wpkcc7alGJjEgjaL6q5AWRqgRWHFsdTL", - verifierName: "torus-auth0-kakao-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - jwtParams: ["domain": "torus-test.auth0.com"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-kakao-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Email-password Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .kakao, + clientId: "wpkcc7alGJjEgjaL6q5AWRqgRWHFsdTL", + verifier: "torus-auth0-kakao-lrc", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Kakao Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .apple, - clientId: "dhFGlWQMoACOI5oS5A1jFglp772OAWr1", - verifierName: "torus-auth0-weibo-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - jwtParams: ["domain": "torus-test.auth0.com"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-weibo-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Kakao Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .apple, + clientId: "dhFGlWQMoACOI5oS5A1jFglp772OAWr1", + verifier: "torus-auth0-weibo-lrc", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Weibo Login") - }) - - Button(action: { - let sub = SubVerifierDetails(loginType: .web, - loginProvider: .wechat, - clientId: "cewDD3i6F1vtHeV1KIbaxUZ8vJQjJZ8V", - verifierName: "torus-auth0-wechat-lrc", - redirectURL: "tdsdk://tdsdk/oauthCallback", - jwtParams: ["domain": "torus-test.auth0.com"]) - - let tdsdk = CustomAuth(aggregateVerifierType: .singleLogin, aggregateVerifierName: "torus-auth0-wechat-lrc", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + } + }, label: { + Text("Weibo Login") + }) + + Button(action: { + let sub = SubVerifierDetails(loginType: .web, + loginProvider: .wechat, + clientId: "cewDD3i6F1vtHeV1KIbaxUZ8vJQjJZ8V", + verifier: "torus-auth0-wechat-lrc", + 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)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") } - }, label: { - Text("Wechat Login") - }) - } + } + }, label: { + Text("Wechat Login") + }) } + // } Section(header: Text("Single ID verifier")) { Button(action: { let sub = SubVerifierDetails(loginType: .installed, loginProvider: .google, clientId: "238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4.apps.googleusercontent.com", - verifierName: "google-ios", + verifier: "google-ios", redirectURL: "com.googleusercontent.apps.238941746713-vfap8uumijal4ump28p9jd3lbe6onqt4:/oauthredirect") - let tdsdk = CustomAuth(aggregateVerifierType: .singleIdVerifier, aggregateVerifierName: "multigoogle-torus", subVerifierDetails: [sub], network: .ROPSTEN) - tdsdk.triggerLogin().done { data in - print("private key rebuild", data) - }.catch { err in - print(err) + let tdsdk = CustomAuth(aggregateVerifierType: .singleIdVerifier, aggregateVerifier: "multigoogle-torus", subVerifierDetails: [sub], network: .legacy(.TESTNET)) + Task { + do { + let loginData = try await tdsdk.triggerLogin().torusKey.finalKeyData! + print(loginData) + } catch { + print("Error occured") + } } }, label: { Text("Google Login - Deep link flow") }) - -// Button(action: { -// let sub = SubVerifierDetails(loginType: .web, -// loginProvider: .google, -// clientId: "238941746713-qqe4a7rduuk256d8oi5l0q34qtu9gpfg.apps.googleusercontent.com", -// verifierName: "google-shubs", -// redirectURL: "https://backend.relayer.dev.tor.us/demoapp/redirect") -// let tdsdk = CustomAuth(aggregateVerifierType: .singleIdVerifier, aggregateVerifierName: "multigoogle-torus", subVerifierDetails: [sub]) -// tdsdk.triggerLogin().done{ data in -// print("private key rebuild", data) -// }.catch{ err in -// print(err) -// } -// }, label: { -// Text("Google Login - Universal link flow") -// }) } }.navigationBarTitle(Text("DirectAuth app")) diff --git a/Sources/CustomAuth/CustomAuth.swift b/Sources/CustomAuth/CustomAuth.swift index 696a8a9..311dac4 100644 --- a/Sources/CustomAuth/CustomAuth.swift +++ b/Sources/CustomAuth/CustomAuth.swift @@ -218,7 +218,6 @@ open class CustomAuth { /// - Returns: A promise that resolve with a Dictionary that contain at least `privateKey` and `publicAddress` field.. open func getTorusKey(verifier: String, verifierId: String, idToken: String, userData: [String: Any] = [:]) async throws -> TorusKey { let extraParams = ["verifier_id": verifierId] as [String: Codable] - let buffer: Data = try! NSKeyedArchiver.archivedData(withRootObject: extraParams, requiringSecureCoding: false) let verifierParams = VerifierParams(verifier_id: verifierId) do { let nodeDetails = try await nodeDetailManager.getNodeDetails(verifier: verifier, verifierID: verifierId) @@ -240,7 +239,6 @@ open class CustomAuth { /// - Returns: A promise that resolve with a Dictionary that contain at least `privateKey` and `publicAddress` field.. open func getAggregateTorusKey(verifier: String, verifierId: String, idToken: String, subVerifierDetails: SubVerifierDetails, userData: [String: Any] = [:]) async throws -> TorusKey { let extraParams = ["verifieridentifier": verifier, "verifier_id": verifierId, "sub_verifier_ids": [subVerifierDetails.verifier], "verify_params": [["verifier_id": verifierId, "idtoken": idToken]]] as [String: Codable] - let buffer: Data = try! NSKeyedArchiver.archivedData(withRootObject: extraParams, requiringSecureCoding: false) let hashedOnce = idToken.sha3(.keccak256) let verifierParams = VerifierParams(verifier_id: verifierId) diff --git a/Sources/CustomAuth/Extension/CASDK+extension.swift b/Sources/CustomAuth/Extension/CASDK+extension.swift index 0240adf..e2d7e69 100644 --- a/Sources/CustomAuth/Extension/CASDK+extension.swift +++ b/Sources/CustomAuth/Extension/CASDK+extension.swift @@ -24,11 +24,11 @@ public enum verifierTypes: String { // MARK: - torus extension extension CustomAuth { - open class var notificationCenter: NotificationCenter { + public class var notificationCenter: NotificationCenter { return NotificationCenter.default } - open class var notificationQueue: OperationQueue { + public class var notificationQueue: OperationQueue { return OperationQueue.main } @@ -108,13 +108,13 @@ extension CustomAuth { return rq } - open class func handle(url: URL) { + public class func handle(url: URL) { // CustomAuth.logger.info("Posting notification after Universal link/deep link flow") let notification = Notification(name: CustomAuth.didHandleCallbackURL, object: nil, userInfo: ["URL": url]) notificationCenter.post(notification) } - open class func handleError(err: String) { + public class func handleError(err: String) { // CustomAuth.logger.info("Posting notification after Universal link/deep link flow") let notification = Notification(name: CustomAuth.didHandleCallbackURL, object: nil, userInfo: ["ERROR": err]) notificationCenter.post(notification) diff --git a/Sources/CustomAuth/Extension/EthereumNetworkFND+extension.swift b/Sources/CustomAuth/Extension/EthereumNetworkFND+extension.swift index e409e1b..e800b96 100644 --- a/Sources/CustomAuth/Extension/EthereumNetworkFND+extension.swift +++ b/Sources/CustomAuth/Extension/EthereumNetworkFND+extension.swift @@ -25,7 +25,7 @@ extension TorusNetwork { case .CELESTE: return "https://signer-polygon.tor.us" case let .CUSTOM(path): - return "https://signer.tor.us" + return path } case .sapphire(let network) : switch network { diff --git a/cocoapods/Podfile b/cocoapods/Podfile index 80c5620..b95d373 100644 --- a/cocoapods/Podfile +++ b/cocoapods/Podfile @@ -7,7 +7,7 @@ target 'cptest' do use_frameworks! # pod 'Torus-utils', '~>' # pod 'SingleFactorAuth', '~> 2.0.1' - pod 'CustomAuth', :path=>"../" +# pod 'CustomAuth', :path=>"../" # Pods for cptest post_install do |installer|