CardManager
@objc(VSSCardManager)
open class CardManager : NSObject
Class responsible for operations with Virgil Cards
-
ModelSigner instance used for self signing Cards
Declaration
Swift
@objc public let modelSigner: ModelSigner -
Crypto instance
Declaration
Swift
@objc public let crypto: VirgilCrypto -
CardClient instance used for performing queries
Declaration
Swift
@objc public let cardClient: CardClientProtocol -
Card Verifier instance used for verifying Cards
Declaration
Swift
@objc public let cardVerifier: CardVerifier -
Called to perform additional signatures for card before publishing
Declaration
Swift
@objc public let signCallback: ((RawSignedModel, @escaping (RawSignedModel?, Error?) -> Void) -> Void)? -
Initializer
Declaration
Swift
@objc public init(params: CardManagerParams)Parameters
paramsCardManagerParams with needed parameters
-
Imports and verifies Card from base64 encoded string
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto
Declaration
Swift
@objc open func importCard(fromBase64Encoded base64EncodedString: String) throws -> CardParameters
base64EncodedStringbase64 encoded string with Card
Return Value
imported and verified Card
-
Imports and verifies Card from Data
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto
Declaration
Swift
@objc open func importCard(fromData data: Data) throws -> CardParameters
dataData with Card
Return Value
imported and verified Card
-
Imports and verifies Card from json Dictionary
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto,JSONSerialization
Declaration
Swift
@objc open func importCard(fromJson json: Any) throws -> CardParameters
jsonjson Dictionary
Return Value
imported and verified Card
-
Imports and verifies Card from RawSignedModel
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto,JSONSerialization
Declaration
Swift
@objc open func importCard(fromRawCard rawCard: RawSignedModel) throws -> CardParameters
rawCardRawSignedModel
Return Value
imported and verified Card
-
Exports Card as base64 encoded string
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONEncoder,VirgilCrypto
Declaration
Swift
@objc open func exportCardAsBase64EncodedString(_ card: Card) throws -> StringParameters
cardCard to be exported
Return Value
base64 encoded string with Card
-
Exports Card as json Dictionary
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONEncoder,VirgilCrypto,JSONSerialization
Declaration
Swift
@objc open func exportCardAsJson(_ card: Card) throws -> AnyParameters
cardCard to be exported
Return Value
json Dictionary with Card
-
Exports Card as RawSignedModel
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONEncoder,VirgilCrypto
Declaration
Swift
@objc open func exportCardAsRawCard(_ card: Card) throws -> RawSignedModelParameters
cardCard to be exported
Return Value
RawSignedModel representing Card
-
Asynchronously returns
Cardwith given identifier from the Virgil Cards Service with given ID, if existsNote
See swift version for additional info
Declaration
Swift
@objc open func getCard(withId cardId: String, completion: @escaping (Card?, Error?) -> Void)Parameters
cardIdstring with unique Virgil Card identifier
completioncompletion handler, called with found and verified Card or corresponding error
-
Asynchronously creates Virgil Card instance on the Virgil Cards Service and associates it with unique identifier Also makes the Card accessible for search/get queries from other users
RawSignedModelshould be at least selfSignedNote
See swift version for additional info
Declaration
Swift
@objc open func publishCard(rawCard: RawSignedModel, completion: @escaping (Card?, Error?) -> Void)Parameters
rawCardself signed
RawSignedModelcompletioncompletion handler, called with published and verified Card or corresponding error
-
Asynchronously generates self signed RawSignedModel and creates Virgil Card instance on the Virgil Cards Service and associates it with unique identifier
Note
See swift version for additional info
Declaration
Swift
@objc open func publishCard(privateKey: VirgilPrivateKey, publicKey: VirgilPublicKey, identity: String, previousCardId: String? = nil, extraFields: [String: String]? = nil, completion: @escaping (Card?, Error?) -> Void)Parameters
privateKeyPrivate Key to self sign RawSignedModel with
publicKeyVirgilPublicKey for generating RawSignedModel
identityidentity for generating RawSignedModel. Will be taken from token if omitted
previousCardIdidentifier of Virgil Card to replace
extraFieldsDictionary with extra data to sign with model
completioncompletion handler, called with published and verified Card or corresponding error
-
Asynchronously performs search of Virgil Cards on the Virgil Cards Service using identities
Note
See swift version for additional info
Declaration
Swift
@objc open func searchCards(identities: [String], completion: @escaping ([Card]?, Error?) -> Void)Parameters
identitiesidentities of cards to search
completioncompletion handler, called with found and verified Cards or corresponding error
-
Returns list of cards that were replaced with newer ones
Declaration
Swift
@objc open func getOutdated(cardIds: [String], completion: @escaping ([String]?, Error?) -> Void)Parameters
cardIdscard ids to check
completioncompletion handler, called with list of old card ids or corresponding error
-
Makes CallbackOperation
for performing revokation of Virgil Card Revoked card gets isOutdated flag to be set to true. Also, such cards could be obtained using get query, but will be absent in search query result.
Declaration
Swift
@objc open func revokeCard(withId cardId: String, completion: @escaping (Error?) -> Void)Parameters
cardIdidentifier of card to revoke
completioncompletion handler, called with corresponding error if any occured
-
Imports Virgil Card from RawSignedModel
Throws
corresponding errorDeclaration
Swift
@objc open class func parseCard(from rawSignedModel: RawSignedModel, crypto: VirgilCrypto) throws -> CardParameters
cryptoCryptoinstancerawSignedModelRawSignedModel to import
Return Value
imported Card
-
Imports Virgil Card from RawSignedModel using self Crypto instance
Throws
corresponding errorDeclaration
Swift
@objc open func parseCard(from rawSignedModel: RawSignedModel) throws -> CardParameters
rawSignedModelRawSignedModel to import
Return Value
imported Card
-
Makes CallbackOperation
for getting verified Virgil Card from the Virgil Cards Service with given ID, if exists Declaration
Swift
public func getCard(withId cardId: String) -> GenericOperation<Card>Parameters
cardIdidentifier of Virgil Card to find
Return Value
CallbackOperation
for getting GetCardResponsewith verified Virgil Card -
Generates self signed RawSignedModel
Declaration
Swift
@objc open func generateRawCard(privateKey: VirgilPrivateKey, publicKey: VirgilPublicKey, identity: String, previousCardId: String? = nil, extraFields: [String: String]? = nil) throws -> RawSignedModelParameters
privateKeyVirgilPrivateKey to self sign with
publicKeyPublic Key instance
identityCard’s identity
previousCardIdIdentifier of Virgil Card with same identity this Card will replace
extraFieldsDictionary with extra data to sign with model. Should be JSON-compatible
Return Value
Self signed RawSignedModel
-
Generates self signed RawSignedModel
Declaration
Swift
@objc open class func generateRawCard(crypto: VirgilCrypto, modelSigner: ModelSigner, privateKey: VirgilPrivateKey, publicKey: VirgilPublicKey, identity: String, previousCardId: String? = nil, extraFields: [String: String]? = nil) throws -> RawSignedModelParameters
cryptoVirgilCrypto implementation
modelSignerModelSigner implementation
privateKeyVirgilPrivateKey to self sign with
publicKeyPublic Key instance
identityCard’s identity
previousCardIdIdentifier of Virgil Card with same identity this Card will replace
extraFieldsDictionary with extra data to sign with model. Should be JSON-compatible
Return Value
Self signed RawSignedModel
-
Makes CallbackOperation
for creating Virgil Card instance on the Virgil Cards Service and associates it with unique identifier Declaration
Swift
public func publishCard(rawCard: RawSignedModel) -> GenericOperation<Card>Parameters
rawCardRawSignedModel of Card to create
Return Value
CallbackOperation
for creating Virgil Card instance -
Makes CallbackOperation
for generating self signed RawSignedModel and creating Virgil Card instance on the Virgil Cards Service Declaration
Swift
public func publishCard(privateKey: VirgilPrivateKey, publicKey: VirgilPublicKey, identity: String, previousCardId: String? = nil, extraFields: [String: String]? = nil) -> GenericOperation<Card>Parameters
privateKeyVirgilPrivateKey to self sign with
publicKeyPublic Key instance
identityCard’s identity
previousCardIdIdentifier of Virgil Card with same identity this Card will replace
extraFieldsDictionary with extra data to sign with model. Should be JSON-compatible
Return Value
CallbackOperation
for generating self signed RawSignedModel and creating Virgil Card instance on the Virgil Cards Service -
Makes CallbackOperation<[Card]> for performing search of Virgil Cards on the Virgil Cards Service using identities
Note
Resulting array will contain only actual cards. Older cards (that were replaced) can be accessed using previousCard property of new cards.
Declaration
Swift
public func searchCards(identities: [String]) -> GenericOperation<[Card]>Parameters
identitiesidentities of cards to search
Return Value
CallbackOperation<[Card]> for performing search of Virgil Cards
-
Returns list of cards that were replaced with newer ones
Declaration
Swift
public func getOutdated(cardIds: [String]) -> GenericOperation<[String]>Parameters
cardIdscard ids to check
Return Value
GenericOperation<[String]>
-
Makes CallbackOperation
for performing revokation of Virgil Card Revoked card gets isOutdated flag to be set to true. Also, such cards could be obtained using get query, but will be absent in search query result.
Declaration
Swift
public func revokeCard(withId cardId: String) -> GenericOperation<Void>Parameters
cardIdidentifier of card to revoke
Return Value
CallbackOperation
-
Imports and verifies Card from base64 encoded string
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto
Declaration
Swift
@objc open class func importCard(fromBase64Encoded base64EncodedString: String, crypto: VirgilCrypto, cardVerifier: CardVerifier) throws -> CardParameters
base64EncodedStringbase64 encoded string with Card
cryptoVirgilCrypto implementation
cardVerifierCardVerifier implementation
Return Value
imported and verified Card
-
Imports and verifies Card from Data
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto
Declaration
Swift
@objc open class func importCard(fromData data: Data, crypto: VirgilCrypto, cardVerifier: CardVerifier) throws -> CardParameters
dataData with Card
cryptoVirgilCrypto implementation
cardVerifierCardVerifier implementation
Return Value
imported and verified Card
-
Imports and verifies Card from json Dictionary
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto,JSONSerialization
Declaration
Swift
@objc open class func importCard(fromJson json: Any, crypto: VirgilCrypto, cardVerifier: CardVerifier) throws -> CardParameters
jsonjson Dictionary
cryptoVirgilCrypto implementation
cardVerifierCardVerifier implementation
Return Value
imported and verified Card
-
Imports and verifies Card from RawSignedModel
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONDecoder,VirgilCrypto,JSONSerialization
Declaration
Swift
@objc open class func importCard(fromRawCard rawCard: RawSignedModel, crypto: VirgilCrypto, cardVerifier: CardVerifier) throws -> CardParameters
rawCardRawSignedModel
cryptoVirgilCrypto implementation
cardVerifierCardVerifier implementation
Return Value
imported and verified Card
-
Exports Card as base64 encoded string
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONEncoder,VirgilCrypto
Declaration
Swift
@objc open class func exportCardAsBase64EncodedString(_ card: Card) throws -> StringParameters
cardCard to be exported
Return Value
base64 encoded string with Card
-
Exports Card as Data
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONEncoder,VirgilCrypto
Declaration
Swift
@objc open class func exportCardAsData(_ card: Card) throws -> DataParameters
cardCard to be exported
Return Value
Data
-
Exports Card as json Dictionary
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONEncoder,VirgilCrypto,JSONSerialization
Declaration
Swift
@objc open class func exportCardAsJson(_ card: Card) throws -> AnyParameters
cardCard to be exported
Return Value
json Dictionary with Card
-
Exports Card as RawSignedModel
Throws
CardManagerError.cardIsNotVerified, if Card verificaction has failed- Rethrows from
RawSignedModel,JSONEncoder,VirgilCrypto
Declaration
Swift
@objc open class func exportCardAsRawCard(_ card: Card) throws -> RawSignedModelParameters
cardCard to be exported
Return Value
RawSignedModel representing Card
CardManager Class Reference