Sha256: 6e934d446b61275f0c1461f348d9469e18d54a929447bf92db1d262d319a7498

Contents?: true

Size: 534 Bytes

Versions: 13

Compression:

Stored size: 534 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Elections
    #
    # Decorator for trustee
    #
    class TrusteePresenter < SimpleDelegator
      def trustee
        __getobj__
      end

      def public_key_thumbprint
        @public_key_thumbprint ||= jwk_thumbprint(JSON.parse(trustee.public_key)) if trustee.public_key.present?
      end

      private

      def jwk_thumbprint(key)
        Base64.urlsafe_encode64(Digest::SHA256.digest(key.slice("e", "kty", "n").to_json), padding: false)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-elections-0.25.2 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.25.1 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.25.0 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.25.0.rc4 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.25.0.rc3 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.25.0.rc2 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.25.0.rc1 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.24.3 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.24.2 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.24.1 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.24.0 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.24.0.rc2 app/presenters/decidim/elections/trustee_presenter.rb
decidim-elections-0.24.0.rc1 app/presenters/decidim/elections/trustee_presenter.rb