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
params
CardManagerParams 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 -> Card
Parameters
base64EncodedString
base64 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 -> Card
Parameters
data
Data 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 -> Card
Parameters
json
json 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 -> Card
Parameters
rawCard
RawSignedModel
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 -> String
Parameters
card
Card 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 -> Any
Parameters
card
Card 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 -> RawSignedModel
Parameters
card
Card to be exported
Return Value
RawSignedModel representing Card
-
Asynchronously returns
Card
with 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
cardId
string with unique Virgil Card identifier
completion
completion 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
RawSignedModel
should be at least selfSignedNote
See swift version for additional info
Declaration
Swift
@objc open func publishCard(rawCard: RawSignedModel, completion: @escaping (Card?, Error?) -> Void)
Parameters
rawCard
self signed
RawSignedModel
completion
completion 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
privateKey
Private Key to self sign RawSignedModel with
publicKey
VirgilPublicKey for generating RawSignedModel
identity
identity for generating RawSignedModel. Will be taken from token if omitted
previousCardId
identifier of Virgil Card to replace
extraFields
Dictionary with extra data to sign with model
completion
completion 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
identities
identities of cards to search
completion
completion 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
cardIds
card ids to check
completion
completion 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
cardId
identifier of card to revoke
completion
completion 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 -> Card
Parameters
crypto
Crypto
instancerawSignedModel
RawSignedModel 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 -> Card
Parameters
rawSignedModel
RawSignedModel 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
cardId
identifier of Virgil Card to find
Return Value
CallbackOperation
for getting GetCardResponse
with 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 -> RawSignedModel
Parameters
privateKey
VirgilPrivateKey to self sign with
publicKey
Public Key instance
identity
Card’s identity
previousCardId
Identifier of Virgil Card with same identity this Card will replace
extraFields
Dictionary 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 -> RawSignedModel
Parameters
crypto
VirgilCrypto implementation
modelSigner
ModelSigner implementation
privateKey
VirgilPrivateKey to self sign with
publicKey
Public Key instance
identity
Card’s identity
previousCardId
Identifier of Virgil Card with same identity this Card will replace
extraFields
Dictionary 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
rawCard
RawSignedModel 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
privateKey
VirgilPrivateKey to self sign with
publicKey
Public Key instance
identity
Card’s identity
previousCardId
Identifier of Virgil Card with same identity this Card will replace
extraFields
Dictionary 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
identities
identities 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
cardIds
card 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
cardId
identifier 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 -> Card
Parameters
base64EncodedString
base64 encoded string with Card
crypto
VirgilCrypto implementation
cardVerifier
CardVerifier 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 -> Card
Parameters
data
Data with Card
crypto
VirgilCrypto implementation
cardVerifier
CardVerifier 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 -> Card
Parameters
json
json Dictionary
crypto
VirgilCrypto implementation
cardVerifier
CardVerifier 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 -> Card
Parameters
rawCard
RawSignedModel
crypto
VirgilCrypto implementation
cardVerifier
CardVerifier 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 -> String
Parameters
card
Card 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 -> Data
Parameters
card
Card 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 -> Any
Parameters
card
Card 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 -> RawSignedModel
Parameters
card
Card to be exported
Return Value
RawSignedModel representing Card