Sha256: f9f88a4660ed7b8bf36748f6bad0bd042455e8abb1a65174ede334a4b7a7c7f6

Contents?: true

Size: 827 Bytes

Versions: 5

Compression:

Stored size: 827 Bytes

Contents

class Acme::Client::Resources::Challenges::Base
  attr_reader :authorization, :status, :uri, :token, :error

  def initialize(authorization)
    @authorization = authorization
  end

  def client
    authorization.client
  end

  def verify_status
    authorization.verify_status

    status
  end

  def request_verification
    response = client.connection.post(@uri, resource: 'challenge', type: challenge_type, keyAuthorization: authorization_key)
    response.success?
  end

  def assign_attributes(attributes)
    @status = attributes.fetch('status', 'pending')
    @uri = attributes.fetch('uri')
    @token = attributes.fetch('token')
    @error = attributes['error']
  end

  private

  def challenge_type
    self.class::CHALLENGE_TYPE
  end

  def authorization_key
    "#{token}.#{client.jwk.thumbprint}"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
acme-client-1.0.0 lib/acme/client/resources/challenges/base.rb
acme-client-0.6.3 lib/acme/client/resources/challenges/base.rb
acme-client-0.6.2 lib/acme/client/resources/challenges/base.rb
acme-client-0.6.1 lib/acme/client/resources/challenges/base.rb
acme-client-0.6.0 lib/acme/client/resources/challenges/base.rb