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

Import export cards

  • Imports and verifies Card from base64 encoded string

    Throws

    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

    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

    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

    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

    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

    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

    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 exists

    Note

    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 selfSigned

    Note

    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 error

    Declaration

    Swift

    @objc
    open class func parseCard(from rawSignedModel: RawSignedModel, crypto: VirgilCrypto) throws -> Card

    Parameters

    crypto

    Crypto instance

    rawSignedModel

    RawSignedModel to import

    Return Value

    imported Card

  • Imports Virgil Card from RawSignedModel using self Crypto instance

    Throws

    corresponding error

    Declaration

    Swift

    @objc
    open func parseCard(from rawSignedModel: RawSignedModel) throws -> Card

    Parameters

    rawSignedModel

    RawSignedModel to import

    Return Value

    imported Card

Extension for primary operations

  • 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

    Throws

    Rethrows from VirgilCrypto, JSONEncoder, JSONSerialization, ModelSigner

    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

    Throws

    Rethrows from VirgilCrypto, JSONEncoder, JSONSerialization, ModelSigner

    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

Import export cards: static functions