-
Notifications
You must be signed in to change notification settings - Fork 2
Home
All interaction with TokenD-based system relies on ...Api
instances.
API
class serves as "umbrella" and instantiates others Api
s in a lazy manner.
"Umbrella" class can be initialized like this:
let tokenDApi = TokenDSDK.API(
configuration: apiConfiguration,
callbacks: callbacks,
keyDataProvider: keyDataProvider
)
Each parameter is described in details below.
API configuration can be initialized like this:
let userAgent: String = ...
let apiConfiguration = ApiConfiguration(
urlString: "https://api.testnet.tokend.org",
userAgent: ...
)
It consists of API URL string and user agent. User agent is a client identifier string that usually consists of app name, system version, device name, etc.
Callbacks can be initialized like this:
let callbacks = ApiCallbacks(onTFARequired: { (tfaInput, cancel) in
// handle TFA...
})
ApiCallbacks
used to notify when there is a special event occurs.
Currently, it serves to notify when 2Factor authentication required.
In theory, any API request may require 2Factor authentication of the user if it is set. For example, sign in may require a code from Google Authenticator.
The key data provider is required to give access to the private key and perform request signing.
API requests that interact with sensitive data require signing by user's Account
i.e. the keypair.
The key data provider should conform to RequestSignKeyDataProviderProtocol
.
You can get more info about requests signing in our Knowledge base or in API documentation