TorusAuthService
public class TorusAuthService : NSObject
extension TorusAuthService: ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding
TorusAuthService is a wrapper around the SDK provided by: https://tor.us/ to allow the creation of TorusWallet
‘s.
This allows users to create a wallet from their social media accounts without having to use a seed phrase / mnemonic.
TorusAuthService allows Tezos apps to leverage this service for a number of providers, and also has the ability to query the network for someone else’s wallet address,
based on their social profile. This allows you to send XTZ or tokens to your friend based on their twitter username for example
-
Setup the TorusAuthService verifiers and networking clients for testnet and mainnet, so they can be queried easier.
Declaration
Swift
public init(networkService: NetworkService, verifiers: [TorusAuthProvider : SubverifierWrapper], web3AuthClientId: String)
Parameters
networkService
A networking service instance used for converting twitter handles into twitter id’s
verifiers
List of verifiers available to the library for the given app context
-
Create a
TorusWallet
insteace from a social media providerDeclaration
Swift
public func createWallet(from authType: TorusAuthProvider, displayOver: UIViewController?, mockedTorus: CustomAuth? = nil, completion: @escaping ((Result<TorusWallet, KukaiError>) -> Void))
Parameters
from
The
TorusAuthProvider
that you want to invokedisplayOver
The
UIViewController
that the webpage will display on top ofmockedTorus
To avoid issues attempting to stub aspects of the Torus SDK, a mocked version of the SDK can be supplied instead
completion
The callback returned when all the networking and cryptography is complete
-
Get a TZ2 address from a social media user name. If Twitter, will first convert the username to a userid and then query
Declaration
Swift
public func getAddress(from authType: TorusAuthProvider, for socialUsername: String, completion: @escaping ((Result<String, KukaiError>) -> Void))
Parameters
from
The
TorusAuthProvider
that you want to invokefor
The social media username to search for
completion
The callback returned when all the networking and cryptography is complete
-
Take in a Twitter id and fetch the Twitter username instead.
Declaration
Swift
public func twitterHandleLookup(id: String, completion: @escaping ((Result<String, KukaiError>) -> Void))
Parameters
id
The users ID. Can contain a prefix of “twitter|” or not
completion
The callback fired when the username has been found
-
Take in a Twitter username and fetch the Twitter userId instead.
Declaration
Swift
public func twitterAddressLookup(username: String, completion: @escaping ((Result<String, KukaiError>) -> Void))
Parameters
username
The users username. Can contain an
@
symbol, but will be stripped out by the code as its not requiredcompletion
The callback fired when the userId has been found
-
Declaration
Swift
@MainActor public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor
-
Declaration
Swift
@MainActor public func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error)
-
Declaration
Swift
@MainActor public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization)