class Virgil::SDK::HighLevel::VirgilContext

Attributes

access_token[R]
cards_read_only_service_url[R]
cards_service_url[R]
client[R]
credentials[R]
crypto[R]
identity_service_url[R]
key_storage[R]
ra_service_url[R]

Public Class Methods

new(access_token: nil, credentials: nil, key_storage_path: Cryptography::Keys::KeyStorage.default_folder, cards_service_url: Client::Card::SERVICE_URL, cards_read_only_service_url: Client::Card::READ_ONLY_SERVICE_URL, ra_service_url: Client::Card::RA_SERVICE_URL, identity_service_url: VirgilIdentity::IDENTITY_SERVICE_URL, crypto: Cryptography::VirgilCrypto.new, card_verifiers: [] ) click to toggle source
# File lib/virgil/sdk/high_level/virgil_context.rb, line 42
def initialize(access_token: nil, credentials: nil, key_storage_path: Cryptography::Keys::KeyStorage.default_folder,
               cards_service_url: Client::Card::SERVICE_URL,
               cards_read_only_service_url: Client::Card::READ_ONLY_SERVICE_URL,
               ra_service_url: Client::Card::RA_SERVICE_URL,
               identity_service_url: VirgilIdentity::IDENTITY_SERVICE_URL,
               crypto: Cryptography::VirgilCrypto.new,
               card_verifiers: []
)
  @access_token = access_token
  @client = Client::VirgilClient.new(access_token, cards_service_url, cards_read_only_service_url, identity_service_url, ra_service_url)
  @crypto = crypto
  @credentials = credentials
  @key_storage = Cryptography::Keys::KeyStorage.new(key_storage_path)

   @client.card_validator = Client::CardValidator.new(@crypto)

  if card_verifiers.any?

    card_verifiers.each do |card_verifier|
      raise ArgumentError.new("card_verifiers is not valid") unless card_verifier.is_a? VirgilCardVerifierInfo
      @client.card_validator.add_verifier(card_verifier.card_id, @crypto.import_public_key(card_verifier.public_key_value.bytes))
    end
  end

end