Sha256: 7fc364160287ffbd56d55f89cd948def1dfcd922c59f23d6180210108c72c2b5

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

module RokuBuilder

  # Change or get dev key
  class Keyer < Util

    # Sets the key on the roku device
    # @param keyed_pkg [String] Path for a package signed with the desired key
    # @param password [String] Password for the package
    # @return [Boolean] True if key changed, false otherwise
    def rekey(keyed_pkg:, password:)
      oldId = dev_id

      # upload new key with password
      path = "/plugin_inspect"
      conn = multipart_connection
      payload =  {
        mysubmit: "Rekey",
        passwd: password,
        archive: Faraday::UploadIO.new(keyed_pkg, 'application/octet-stream')
      }
      conn.post path, payload

      # check key
      newId = dev_id
      @logger.info("Key did not change") unless newId != oldId
      newId != oldId
    end

    # Get the current dev id
    # @return [String] The current dev id
    def dev_id
      path = "/plugin_package"
      conn = simple_connection
      response = conn.get path

      dev_id = /Your Dev ID:\s*<font[^>]*>([^<]*)<\/font>/.match(response.body)
      if dev_id
        dev_id = dev_id[1]
      else
        dev_id = /Your Dev ID:[^>]*<\/label> ([^<]*)/.match(response.body)[1]
      end
      dev_id
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
roku_builder-3.6.2 lib/roku_builder/keyer.rb
roku_builder-3.6.1 lib/roku_builder/keyer.rb
roku_builder-3.6.0 lib/roku_builder/keyer.rb
roku_builder-3.5.0 lib/roku_builder/keyer.rb
roku_builder-3.4.4 lib/roku_builder/keyer.rb
roku_builder-3.4.3 lib/roku_builder/keyer.rb