EThree
@objc(VTEEThree)
open class EThree : NSObject
Main class containing all features of E3Kit
-
Typealias for the valid result of lookupPublicKeys call
Declaration
Swift
public typealias LookupResult = [String : VirgilPublicKey]
-
Typealias for callback used below
Declaration
Swift
public typealias JwtStringCallback = (String?, Error?) -> Void
-
Typealias for callback used below
Declaration
Swift
public typealias RenewJwtCallback = (@escaping JwtStringCallback) -> Void
-
Typealias for callback used below
Declaration
Swift
public typealias PublishCardCallback = (RawSignedModel) throws -> Card
-
Identity of user
Declaration
Swift
@objc public let identity: String
-
CardManager instance
Declaration
Swift
@objc public let cardManager: CardManager
-
AccessTokenProvider
Declaration
Swift
@objc public let accessTokenProvider: AccessTokenProvider
-
LocalKeyStorage
Declaration
Swift
@objc public let localKeyStorage: LocalKeyStorage
-
Offline init
Declaration
Swift
@objc public let offlineInit: Bool
-
VirgilCrypto instance
Declaration
Swift
@objc public var crypto: VirgilCrypto { get }
-
ChangedKeyDelegate to notify changing of User’s keys
Declaration
Swift
@objc public var changedKeyDelegate: ChangedKeyDelegate? { get }
-
init(identity:
tokenCallback: changedKeyDelegate: storageParams: keyPairType: enableRatchet: enableRatchetPqc: keyRotationInterval: ) Initializer
Throws
corresponding errorImportant
identity should be the same as in JWT generated at server sideDeclaration
Swift
@objc public convenience init( identity: String, tokenCallback: @escaping RenewJwtCallback, changedKeyDelegate: ChangedKeyDelegate? = nil, storageParams: KeychainStorageParams? = nil, keyPairType: KeyPairType = Defaults.keyPairType, enableRatchet: Bool = Defaults.enableRatchet, enableRatchetPqc: Bool = Defaults.enableRatchetPqc, keyRotationInterval: TimeInterval = Defaults.keyRotationInterval ) throws
Parameters
identity
User identity
tokenCallback
callback to get Virgil access token
changedKeyDelegate
ChangedKeyDelegate
to notify about changes of User’s keysstorageParams
KeychainStorageParams
with specific parameterskeyPairType
key pair type
enableRatchet
enable ratchet
keyRotationInverval
key rotation interval for ratchet
-
Init
Declaration
Swift
@objc public convenience init(params: EThreeParams) throws
Parameters
params
params
-
Publishes Card on Virgil Cards Service and saves Private Key in local storage
Declaration
Swift
public func register(with keyPair: VirgilKeyPair? = nil) -> GenericOperation<Void>
Parameters
keyPair
VirgilKeyPair
to publish Card with. Will generate if not specifiedReturn Value
CallbackOperation
-
Generates Key Pair, calls publishCardCallback and saves Private Key in local storage
Declaration
Swift
public func register( with keyPair: VirgilKeyPair? = nil, publishCardCallback: @escaping PublishCardCallback ) -> GenericOperation<Void>
Parameters
keyPair
VirgilKeyPair
to publish Card with. Will generate if not specifiedReturn Value
CallbackOperation
-
Generates new Private Key, publishes new Card to replace the current one on Virgil Cards Service and saves new Private Key in local storage
Declaration
Swift
public func rotatePrivateKey() -> GenericOperation<Void>
Return Value
CallbackOperation
-
Revokes Card from Virgil Cards Service, deletes Private Key from local storage
Declaration
Swift
public func unregister() -> GenericOperation<Void>
Return Value
CallbackOperation
-
Checks existance of private key in keychain storage
Throws
KeychainStorageErrorDeclaration
Swift
public func hasLocalPrivateKey() throws -> Bool
Return Value
true if private key exists in keychain storage
-
Deletes Private Key from local storage, cleand local cards storage
Throws
KeychainStorageErrorDeclaration
Swift
@objc open func cleanUp() throws
-
Derives different passwords for login and for backup from one
Declaration
Swift
@objc public static func derivePasswords(from password: String) throws -> DerivedPasswords
Parameters
password
password to derive from
-
Encrypts user’s private key using password and backs up the encrypted private key to Virgil’s cloud. This enables users to log in from other devices and have access to their private key to decrypt data.
Important
Requires private key in local storageDeclaration
Swift
public func backupPrivateKey(password: String, keyName: String? = nil) -> GenericOperation<Void>
Parameters
password
String with password
keyName
optional name of the key. Can be used to create additional key backup
Return Value
CallbackOperation
-
Restores encrypted private key from Virgil’s cloud, decrypts it using user’s password and saves it in local storage
Declaration
Swift
public func restorePrivateKey(password: String, keyName: String? = nil) -> GenericOperation<Void>
Parameters
password
String with password
keyName
optional name of the key
Return Value
CallbackOperation
-
Changes the password on a backed-up private key.
Declaration
Swift
public func changePassword(from oldOne: String, to newOne: String, keyName: String? = nil) -> GenericOperation<Void>
Parameters
oldOne
old password
newOne
new password
keyName
optional name of the key
Return Value
CallbackOperation
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
public func resetPrivateKeyBackup(keyName: String? = nil) -> GenericOperation<Void>
Parameters
keyName
optional name of the key
-
Retrieves cards from local storage with given identities
Throws
corresponding errorDeclaration
Swift
@objc open func findCachedUsers( with identities: [String], checkResult: Bool = true ) throws -> FindUsersResult
Parameters
identities
identities of cards to retrieve
checkResult
checks that cards for all identities were found if true
Return Value
-
Returnes card from local storage with given identity
Declaration
Swift
@objc open func findCachedUser(with identity: String) -> Card?
Parameters
identity
identity
Return Value
Card if it exists, nil otherwise
-
Retrieves users Cards from the Virgil Cloud or local storage if exists
Declaration
Swift
public func findUsers( with identities: [String], forceReload: Bool = false, checkResult: Bool = true ) -> GenericOperation<FindUsersResult>
Parameters
identities
array of identities to find
forceReload
will not use local cached cards if true
checkResult
checks that cards for all identities were found if true
Return Value
CallbackOperation
-
Retrieves user Card from the Virgil Cloud or local storage if exists
Declaration
Swift
public func findUser(with identity: String, forceReload: Bool = false) -> GenericOperation<Card>
Parameters
identity
identity to find
forceReload
will not use local cached card if true
Return Value
CallbackOperation
-
Updates local cached cards
Declaration
Swift
public func updateCachedUsers() -> GenericOperation<Void>
-
Encrypts data stream
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptStream:toStream:forUser:error:) public func encrypt(_ stream: InputStream, to outputStream: OutputStream, for user: Card) throws
Parameters
stream
data stream to be encrypted
outputStream
stream with encrypted data
user
user Card to encrypt for
-
Encrypts data stream
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptStream:toStream:forUsers:error:) public func encrypt( _ stream: InputStream, to outputStream: OutputStream, for users: FindUsersResult? = nil ) throws
Parameters
stream
data stream to be encrypted
outputStream
stream with encrypted data
users
result of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
-
Decrypts data stream
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc public func decrypt(_ stream: InputStream, to outputStream: OutputStream) throws
Parameters
stream
stream with encrypted data
outputStream
stream with decrypted data
-
Signs and encrypts data for user
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptData:forUser:error:) public func encrypt(data: Data, for user: Card) throws -> Data
Parameters
data
data to encrypt
user
user Card to encrypt for
Return Value
encrypted data
-
Signs and encrypts string for user
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptText:forUser:error:) public func encrypt(text: String, for user: Card) throws -> String
Parameters
text
String to encrypt
user
user Card to encrypt for
Return Value
encrypted String
-
Decrypts and verifies data from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptData:fromUsers:error:) public func decrypt(data: Data, from user: Card? = nil) throws -> Data
Parameters
data
data to decrypt
user
sender Card with Public Key to verify with. Use nil to decrypt and verify from self
Return Value
decrypted Data
-
Decrypts and verifies data from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptData:fromUsers:date:error:) public func decrypt(data: Data, from user: Card, date: Date) throws -> Data
Parameters
data
data to decrypt
user
sender Card with Public Key to verify with
date
date of encryption to use proper card version
Return Value
decrypted Data
-
Decrypts and verifies base64 string from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptText:fromUser:error:) public func decrypt(text: String, from user: Card? = nil) throws -> String
Parameters
text
encrypted String
user
sender Card with Public Key to verify with. Use nil to decrypt and verify from self.
Return Value
decrypted String
-
Decrypts and verifies base64 string from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptText:fromUser:date:error:) public func decrypt(text: String, from user: Card, date: Date) throws -> String
Parameters
text
encrypted String
user
sender Card with Public Key to verify with
date
date of encryption to use proper card version
Return Value
decrypted String
-
Signs then encrypts string for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptText:forUsers:error:) public func encrypt(text: String, for users: FindUsersResult? = nil) throws -> String
Parameters
text
String to encrypt
users
result of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
encrypted base64String
-
Signs then encrypts data for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptData:forUsers:error:) public func encrypt(data: Data, for users: FindUsersResult? = nil) throws -> Data
Parameters
data
data to encrypt
user
result of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
decrypted Data
-
Signs then encrypts data for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc public func encrypt(data: Data, for recipientKeys: LookupResult) throws -> Data
Parameters
data
data to encrypt
recipientKeys
result of lookupPublicKeys call recipient PublicKeys to sign and encrypt with
Return Value
decrypted Data
-
Decrypts and verifies data from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc public func decrypt(data: Data, from senderPublicKey: VirgilPublicKey) throws -> Data
Parameters
data
data to decrypt
senderPublicKey
sender PublicKey to verify with
Return Value
decrypted Data
-
Encrypts data stream
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc public func encrypt( _ stream: InputStream, to outputStream: OutputStream, for recipientKeys: LookupResult ) throws
Parameters
stream
data stream to be encrypted
outputStream
stream with encrypted data
recipientKeys
result of lookupPublicKeys call recipient PublicKeys to sign and encrypt with.
-
Signs then encrypts string for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc public func encrypt(text: String, for recipientKeys: LookupResult) throws -> String
Parameters
text
String to encrypt
recipientKeys
result of lookupPublicKeys call recipient PublicKeys to sign and encrypt with.
Return Value
encrypted base64String
-
Decrypts and verifies base64 string from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc public func decrypt(text: String, from senderPublicKey: VirgilPublicKey) throws -> String
Parameters
text
encrypted String
senderPublicKey
sender PublicKey to verify with
Return Value
decrypted String
-
Initializes EThree with a callback to get Virgil access token
Declaration
Swift
@available(*, deprecated, message: "Use constructor instead") public static func initialize( tokenCallback: @escaping RenewJwtCallback, changedKeyDelegate: ChangedKeyDelegate? = nil, storageParams: KeychainStorageParams? = nil, overrideVirgilPublicKey: String? = nil, serviceUrls: EThreeParams.ServiceUrls? = nil ) -> GenericOperation<EThree>
Parameters
tokenCallback
callback to get Virgil access token
changedKeyDelegate
ChangedKeyDelegate
to notify about changes of User’s keysstorageParams
KeychainStorageParams
with specific parametersoverrideVirgilPublicKey
Use this only while working with environments other than Virgil production
serviceUrls
Service urls
-
initialize(tokenCallback:
changedKeyDelegate: storageParams: overrideVirgilPublicKey: serviceUrls: completion: ) Initializes E3Kit with a callback to get Virgil access token
Declaration
Swift
@available(*, deprecated, message: "Use constructor instead") @objc public static func initialize( tokenCallback: @escaping RenewJwtCallback, changedKeyDelegate: ChangedKeyDelegate? = nil, storageParams: KeychainStorageParams? = nil, overrideVirgilPublicKey: String? = nil, serviceUrls: EThreeParams.ServiceUrls? = nil, completion: @escaping (_ ethree: EThree?, _ error: Error?) -> Void )
Parameters
tokenCallback
callback to get Virgil access token
changedKeyDelegate
ChangedKeyDelegate
to notify changing of User’s keysstorageParams
KeychainStorageParams
with specific parametersoverrideVirgilPublicKey
Use this only while working with environments other than Virgil production
serviceUrls
Service urls
completion
completion handler
ethree
initialized EThree instance
error
corresponding error
-
Retrieves users public keys from the Virgil Cloud
Declaration
Swift
@available(*, deprecated, message: "Use findUsers instead.") public func lookupPublicKeys(of identities: [String]) -> GenericOperation<LookupResult>
Parameters
identities
array of identities to find
Return Value
CallbackOperation
-
Retrieves users public keys from the Virgil Cloud
Declaration
Swift
@available(*, deprecated, message: "Use findUsers instead.") @objc public func lookupPublicKeys( of identities: [String], completion: @escaping ( _ lookupResult: LookupResult?, _ error: Error? ) -> Void )
Parameters
identities
array of identities to find
completion
completion handler
lookupResult
dictionary with idenities as keys and found keys as values
error
corresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@available(*, deprecated, message: "Use resetPrivateKeyBackup without password instead") @objc open func resetPrivateKeyBackup(password: String, completion: @escaping (_ error: Error?) -> Void)
Parameters
password
String with password
completion
completion handler
error
corresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@available(*, deprecated, message: "Use resetPrivateKeyBackup without password instead") public func resetPrivateKeyBackup(password: String) -> GenericOperation<Void>
Parameters
password
String with password
Return Value
CallbackOperation
-
Generates new Private Key, publishes Card on Virgil Cards Service and saves Private Key in local storage
Declaration
Swift
@objc open func register(completion: @escaping (_ error: Error?) -> Void)
Parameters
completion
completion handler
error
corresponding error
-
Uses provided Private Key to publish Card to Virgil Cards Service. Saves Private Key in local storage
Declaration
Swift
@objc open func register(with keyPair: VirgilKeyPair, completion: @escaping (_ error: Error?) -> Void)
Parameters
keyPair
Key Pair to publish Card with
-
Generates new Private Key, publishes new Card to replace the current one on Virgil Cards Service and saves new Private Key in local storage
Declaration
Swift
@objc open func rotatePrivateKey(completion: @escaping (_ error: Error?) -> Void)
Parameters
completion
completion handler
- error: corresponding error
-
Revokes Card from Virgil Cards Service, deletes Private Key from local storage
Declaration
Swift
@objc open func unregister(completion: @escaping (_ error: Error?) -> Void)
Parameters
completion
completion handler
- error: corresponding error
-
Encrypts user’s private key using password and backs up the encrypted private key to Virgil’s cloud. This enables users to log in from other devices and have access to their private key to decrypt data.
Important
Requires private key in local storageDeclaration
Swift
@objc open func backupPrivateKey(password: String, completion: @escaping (_ error: Error?) -> Void)
Parameters
password
String with password
completion
completion handler
error
corresponding error
-
Restores encrypted private key from Virgil’s cloud, decrypts it using user’s password and saves it in local storage
Declaration
Swift
@objc open func restorePrivateKey(password: String, completion: @escaping (_ error: Error?) -> Void)
Parameters
password
String with password
completion
completion handler
error
corresponding error
-
Changes the password on a backed-up private key.
Declaration
Swift
@objc open func changePassword( from oldOne: String, to newOne: String, completion: @escaping (_ error: Error?) -> Void )
Parameters
oldOne
old password
newOne
new password
completion
completion handler
error
corresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@objc open func resetPrivateKeyBackup(completion: @escaping (_ error: Error?) -> Void)
Parameters
completion
completion handler
error
corresponding error
-
Retrieves users Cards from the Virgil Cloud or local storage if exists
Declaration
Swift
@objc open func findUsers( with identities: [String], forceReload: Bool = false, checkResult: Bool = true, completion: @escaping ( _ findResult: FindUsersResult?, _ error: Error? ) -> Void )
Parameters
identities
array of identities to find
forceReload
will not use local cached cards if true
checkResult
checks that cards for all identities were found if true
completion
completion handler
find
dictionary with idenities as keys and found Cards as values
error
corresponding error
-
Retrieves user Card from the Virgil Cloud or local storage if exists
Declaration
Swift
@objc open func findUser( with identity: String, forceReload: Bool = false, completion: @escaping ( _ card: Card?, _ error: Error? ) -> Void )
Parameters
identity
identity to find
forceReload
will not use local cached card if true
completion
completion handler
card
found Card
error
corresponding error
-
Updates local cached cards
Declaration
Swift
@objc open func updateCachedUsers(completion: @escaping (_ error: Error?) -> Void)
Parameters
completion
completion handler
error
corresponding error
-
Encrypts user’s private key using password and backs up the encrypted private key to Virgil’s cloud. This enables users to log in from other devices and have access to their private key to decrypt data.
Important
Requires private key in local storageDeclaration
Swift
@objc open func backupPrivateKey( password: String, keyName: String, completion: @escaping (_ error: Error?) -> Void )
Parameters
password
String with password
keyName
name of the key. Can be used to create additional key backup
completion
completion handler
error
corresponding error
-
Restores encrypted private key from Virgil’s cloud, decrypts it using user’s password and saves it in local storage
Declaration
Swift
@objc open func restorePrivateKey( password: String, keyName: String, completion: @escaping (_ error: Error?) -> Void )
Parameters
password
String with password
keyName
name of the key
completion
completion handler
error
corresponding error
-
Changes the password on a backed-up private key.
Declaration
Swift
@objc open func changePassword( from oldOne: String, to newOne: String, keyName: String, completion: @escaping (_ error: Error?) -> Void )
Parameters
oldOne
old password
newOne
new password
keyName
name of the key
completion
completion handler
error
corresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@objc open func resetPrivateKeyBackup(keyName: String, completion: @escaping (_ error: Error?) -> Void)
Parameters
keyName
name of the key
completion
completion handler
error
corresponding error
-
Creates group, saves in cloud and locally
Declaration
Swift
@objc(createGroupWithDataId:findResult:completion:) public func createGroup( id identifier: Data, with findResult: FindUsersResult = [:], completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
findResult
Cards of participants. Result of findUsers call
completion
completion handler
group
created
Group
error
corresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
@objc(loadGroupWithDataId:initiator:completion:) public func loadGroup( id identifier: Data, initiator card: Card, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
card
Card of group initiator
completion
completion handler
group
loaded
Group
error
corresponding error
-
Deletes group from cloud and local storage
Declaration
Swift
@objc(deleteGroupWithDataId:completion:) public func deleteGroup(id identifier: Data, completion: @escaping (_ error: Error?) -> Void)
-
Creates group, saves in cloud and locally
Declaration
Swift
@objc(createGroupWithStringId:findResult:completion:) public func createGroup( id identifier: String, with findResult: FindUsersResult, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
findResult
Cards of participants. Result of findUsers call
completion
completion handler
group
created
Group
error
corresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
@objc(loadGroupWithStringId:initiator:completion:) public func loadGroup( id identifier: String, initiator card: Card, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
card
Card of group initiator
completion
completion handler
group
loaded
Group
error
corresponding error
-
Deletes group from cloud and local storage
Declaration
Swift
@objc(deleteGroupWithStringId:completion:) public func deleteGroup(id identifier: String, completion: @escaping (_ error: Error?) -> Void)
Parameters
identifier
identifier of group
completion
completion handler
error
corresponding error
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
@objc(createGroupWithDataId:users:completion:) public func createGroup( id identifier: Data, with users: [String], completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
users
participants
completion
completion handler
group
created
Group
error
corresponding error
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup( id identifier: String, with users: [String], completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
users
participants
completion
completion handler
group
created
Group
error
corresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup( id identifier: Data, initiator: String, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
initiator
initiator
completion
completion handler
group
loaded
Group
error
corresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup( id identifier: String, initiator: String, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )
Parameters
identifier
identifier of group
card
Card of group initiator
completion
completion handler
group
loaded
Group
error
corresponding error
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
@objc open func createRatchetChannel( with card: Card, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )
Parameters
card
Card of participant
name
name of channel
completion
completion handler
channel
created
RatchetChannel
intanceerror
corresponding error
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
@objc open func joinRatchetChannel( with card: Card, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )
Parameters
card
Card of initiator
name
name of channel
completion
completion handler
channel
RatchetChannel
intanceerror
corresponding error
-
Deletes double ratchet channel
Declaration
Swift
@objc open func deleteRatchetChannel( with card: Card, name: String? = nil, completion: @escaping (_ error: Error?) -> Void )
Parameters
card
Card of participant
name
name of channel
completion
completion handler
error
corresponding error
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
public func createRatchetChannel( with identity: String, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )
Parameters
identity
participant identity
name
name of channel
completion
completion handler
channel
created
RatchetChannel
intanceerror
corresponding error
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
public func joinRatchetChannel( with initiator: String, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )
Parameters
initiator
initiator identity
name
name of channel
completion
completion handler
channel
RatchetChannel
intanceerror
corresponding error
-
Deletes double ratchet channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteRatchetChannel( with participant: String, name: String? = nil, completion: @escaping (_ error: Error?) -> Void )
Parameters
participant
participant identity
name
name of channel
completion
completion handler
error
corresponding error
-
Creates channel with unregistered user
Important
Temporary key for unregistered user is stored unencrypted.
Declaration
Swift
@objc open func createTemporaryChannel( with identity: String, completion: @escaping ( _ channel: TemporaryChannel?, _ error: Error? ) -> Void )
Parameters
identity
identity of unregistered user
completion
completion handler
channel
created
TemporaryChannel
insanceerror
corresponding error
-
Loads temporary channel by fetching temporary key form Cloud
Declaration
Swift
@objc open func loadTemporaryChannel( asCreator: Bool, with identity: String, completion: @escaping ( _ channel: TemporaryChannel?, _ error: Error? ) -> Void )
Parameters
asCreator
Bool to specify wether caller is creator of channel or not
identity
identity of participant
completion
completion handler
channel
loaded
TemporaryChannel
insanceerror
corresponding error
-
Deletes temporary channel from cloud (if user is owner) and local storage
Declaration
Swift
@objc open func deleteTemporaryChannel(with identity: String, completion: @escaping (_ error: Error?) -> Void)
Parameters
identity
identity of participant
completion
completion handler
error
corresponding error
-
Signs then encrypts data (and signature) for user
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Declaration
Swift
@objc(authEncryptData:forUser:error:) public func authEncrypt(data: Data, for user: Card) throws -> Data
Parameters
data
data to encrypt
user
user Card to encrypt for
Return Value
encrypted data
-
Signs then encrypts string (and signature) for user
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Declaration
Swift
@objc(authEncryptText:forUser:error:) public func authEncrypt(text: String, for user: Card) throws -> String
Parameters
text
String to encrypt
user
user Card to encrypt for
Return Value
encrypted String
-
Decrypts data and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptData:fromUsers:error:) public func authDecrypt(data: Data, from user: Card? = nil) throws -> Data
Parameters
data
data to decrypt
user
sender Card with Public Key to verify with. Use nil to decrypt and verify from self
Return Value
decrypted Data
-
Decrypts data and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptData:fromUsers:date:error:) public func authDecrypt(data: Data, from user: Card, date: Date) throws -> Data
Parameters
data
data to decrypt
user
sender Card with Public Key to verify with
date
date of encryption to use proper card version
Return Value
decrypted Data
-
Decrypts base64 string and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptText:fromUser:error:) public func authDecrypt(text: String, from user: Card? = nil) throws -> String
Parameters
text
encrypted String
user
sender Card with Public Key to verify with. Use nil to decrypt and verify from self.
Return Value
decrypted String
-
Decrypts base64 string and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptText:fromUser:date:error:) public func authDecrypt(text: String, from user: Card, date: Date) throws -> String
Parameters
text
encrypted String
user
sender Card with Public Key to verify with
date
date of encryption to use proper card version
Return Value
decrypted String
-
Signs then encrypts string (and signature) for group of users
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Note
Avoid key duplication
Declaration
Swift
@objc(authEncryptText:forUsers:error:) public func authEncrypt(text: String, for users: FindUsersResult? = nil) throws -> String
Parameters
text
String to encrypt
users
result of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
encrypted base64String
-
Signs then encrypts string (and signature) for group of users
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Note
Avoid key duplication
Declaration
Swift
@objc(authEncryptData:forUsers:error:) public func authEncrypt(data: Data, for users: FindUsersResult? = nil) throws -> Data
Parameters
data
data to encrypt
users
result of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
decrypted Data
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: Data, with users: FindUsersResult = [:]) -> GenericOperation<Group>
Parameters
identifier
identifier of group
users
Cards of participants. Result of findUsers call
Return Value
CallbackOperation
-
Returnes cached local group
Throws
corresponding errorDeclaration
Swift
public func getGroup(id identifier: Data) throws -> Group?
Parameters
identifier
identifier of group
Return Value
Group if exists, nil otherwise
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: Data, initiator card: Card) -> GenericOperation<Group>
Parameters
identifier
identifier of group
card
Card of group initiator
Return Value
CallbackOperation
-
Deletes group from cloud (if user is initiator) and local storage
Declaration
Swift
public func deleteGroup(id identifier: Data) -> GenericOperation<Void>
Parameters
identifier
identifier of group
Return Value
CallbackOperation
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: String, with users: FindUsersResult = [:]) -> GenericOperation<Group>
Parameters
identifier
identifier of group
users
Cards of participants. Result of findUsers call
Return Value
CallbackOperation
-
Returnes cached local group
Throws
corresponding errorDeclaration
Swift
public func getGroup(id identifier: String) throws -> Group?
Parameters
identifier
identifier of group
Return Value
Group if exists, nil otherwise
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: String, initiator card: Card) -> GenericOperation<Group>
Parameters
identifier
identifier of group
card
Card of group initiator
Return Value
CallbackOperation
-
Deletes group from cloud and local storage
Declaration
Swift
public func deleteGroup(id identifier: String) -> GenericOperation<Void>
Parameters
identifier
identifier of group
Return Value
CallbackOperation
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: Data, with users: [String]) -> GenericOperation<Group>
Parameters
identifier
identifier of group
users
participants
Return Value
CallbackOperation
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: String, with users: [String]) -> GenericOperation<Group>
Parameters
identifier
identifier of group
users
participants
Return Value
CallbackOperation
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: Data, initiator: String) -> GenericOperation<Group>
Parameters
identifier
identifier of group
initiator
initiator
Return Value
CallbackOperation
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: String, initiator: String) -> GenericOperation<Group>
Parameters
identifier
identifier of group
card
Card of group initiator
Return Value
CallbackOperation
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
public func createRatchetChannel(with card: Card, name: String? = nil) -> GenericOperation<RatchetChannel>
Parameters
card
Card of participant
name
name of channel
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
public func joinRatchetChannel(with card: Card, name: String? = nil) -> GenericOperation<RatchetChannel>
Parameters
card
Card of initiator
name
name of channel
-
Retrieves double ratchet channel from local storage
Declaration
Swift
public func getRatchetChannel(with card: Card, name: String? = nil) throws -> RatchetChannel?
Parameters
card
Card of participant
name
name of channel
-
Deletes double ratchet channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteRatchetChannel(with card: Card, name: String? = nil) -> GenericOperation<Void>
Parameters
card
Card of participant
name
name of channel
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
public func createRatchetChannel(with identity: String, name: String? = nil) -> GenericOperation<RatchetChannel>
Parameters
identity
participant identity
name
name of channel
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
public func joinRatchetChannel(with initiator: String, name: String? = nil) -> GenericOperation<RatchetChannel>
Parameters
initiator
initiator identity
name
name of channel
-
Retrieves double ratchet channel from local storage
Declaration
Swift
public func getRatchetChannel(with participant: String, name: String? = nil) throws -> RatchetChannel?
Parameters
participant
participant identity
name
name of channel
-
Deletes double ratchet channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteRatchetChannel(with participant: String, name: String? = nil) -> GenericOperation<Void>
Parameters
participant
participant identity
name
name of channel
-
Encrypts file stream with a new private key.
File is signed with a private key from the local storage.
Throws
corresponding errorImportant
Requires private key in local storage to sign streamDeclaration
Swift
@objc(encryptSharedStream:withSize:toStream:error:) public func encryptShared( _ stream: InputStream, streamSize: Int, to outputStream: OutputStream ) throws -> Data
Parameters
stream
data stream to be encrypted
streamSize
total stream size in bytes
outputStream
stream with encrypted data
Return Value
- serialized private key
-
Decrypts file stream.
Throws
corresponding errorDeclaration
Swift
@objc(decryptSharedStream:toStream:with:verifyWithSenderCard:error:) public func decryptShared( _ stream: InputStream, to outputStream: OutputStream, with privateKeyData: Data, verifyWith senderCard: Card ) throws
Parameters
stream
stream with encrypted data
outputStream
stream with decrypted data
privateKeyData
serialized private key to decrypt file stream
senderCard
sender Card with Public Key to verify with
-
Decrypts file stream.
Throws
corresponding errorImportant
Requires private key in local storage, if senderPublicKey is not givenDeclaration
Swift
@objc(decryptSharedStream:toStream:with:verifyWithSenderPublicKey:error:) public func decryptShared( _ stream: InputStream, to outputStream: OutputStream, with privateKeyData: Data, verifyWith senderPublicKey: VirgilPublicKey? = nil ) throws
Parameters
stream
stream with encrypted data
outputStream
stream with decrypted data
privateKeyData
serialized private key to decrypt file stream
senderPublicKey
sender Public Key to verify with, if nill then self public key is used
-
Signs then encrypts stream and signature for user
Throws
corresponding errorImportant
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@objc(authEncryptStream:withSize:toStream:forUser:error:) public func authEncrypt( _ stream: InputStream, streamSize: Int, to outputStream: OutputStream, for user: Card ) throws
Parameters
stream
data stream to be encrypted
outputStream
stream with encrypted data
user
user Card to encrypt for
-
Signs then encrypts stream and signature for users
Throws
corresponding errorImportant
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@objc(authEncryptStream:withSize:toStream:forUsers:error:) public func authEncrypt( _ stream: InputStream, streamSize: Int, to outputStream: OutputStream, for users: FindUsersResult? = nil ) throws
Parameters
stream
data stream to be encrypted
outputStream
stream with encrypted data
users
result of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
-
Decrypts stream and signature and verifies signature of sender
Throws
corresponding errorImportant
Requires private key in local storageDeclaration
Swift
@objc open func authDecrypt(_ stream: InputStream, to outputStream: OutputStream, from user: Card? = nil) throws
Parameters
stream
stream with encrypted data
outputStream
stream with decrypted data
user
sender Card with Public Key to verify with. Use nil to decrypt and verify from self.
-
Decrypts stream and signature and verifies signature of sender
Throws
corresponding errorImportant
Requires private key in local storageDeclaration
Swift
@objc open func authDecrypt( _ stream: InputStream, to outputStream: OutputStream, from user: Card, date: Date ) throws
Parameters
stream
stream with encrypted data
outputStream
stream with decrypted data
user
sender Card with Public Key to verify with
date
date of encryption to use proper card version
-
Creates channel with unregistered user
Important
Temporary key for unregistered user is stored unencrypted on Cloud.
Declaration
Swift
public func createTemporaryChannel(with identity: String) -> GenericOperation<TemporaryChannel>
Parameters
identity
identity of unregistered user
-
Loads temporary channel by fetching temporary key form Cloud
Declaration
Swift
public func loadTemporaryChannel(asCreator: Bool, with identity: String) -> GenericOperation<TemporaryChannel>
Parameters
asCreator
Bool to specify wether caller is creator of channel or not
identity
identity of participant
-
Returns cached temporary channel
Declaration
Swift
public func getTemporaryChannel(with identity: String) throws -> TemporaryChannel?
Parameters
identity
identity of participant
-
Deletes temporary channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteTemporaryChannel(with identity: String) -> GenericOperation<Void>
Parameters
identity
identity of participant