Sha256: 24f182df483eabd7c7bafa6535f0bd7b64f8f63fe0e7459c62d1390538155fd7
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require "rest-client" require "smart_id/exceptions" require "smart_id/utils/authentication_hash" require "json" module SmartId::Api module Authentication class Base attr_reader :authentication_hash def self.authenticate(**opts) new(**opts).call end def initialize(**opts) @authentication_hash = opts[:authentication_hash] @display_text = opts[:display_text] @certificate_level = opts[:certificate_level] @multiple_choice = opts[:multiple_choice] end def call response = SmartId::Api::Request.execute(method: :post, uri: api_uri, params: request_params) SmartId::Api::Response.new(JSON.parse(response.body), authentication_hash) end private def request_params params = { relyingPartyUUID: SmartId.relying_party_uuid, relyingPartyName: SmartId.relying_party_name, certificateLevel: @certificate_level || SmartId.default_certificate_level, hash: authentication_hash.calculate_base64_digest, hashType: "SHA256" } if @display_text params.merge!(displayText: @display_text) end if @multiple_choice params.merge!(requestProperties: { vcChoice: @multiple_choice }) end params end def api_uri raise NotImplementedError end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smart_id-0.1.0 | lib/smart_id/api/authentication/base.rb |