Class: RokuBuilder::Keyer

Inherits:
Util
  • Object
show all
Defined in:
lib/roku_builder/keyer.rb

Overview

Change or get dev key

Instance Method Summary collapse

Methods inherited from Util

#init, #initialize, #multipart_connection, options_parse, #simple_connection

Constructor Details

This class inherits a constructor from RokuBuilder::Util

Instance Method Details

#dev_idString

Get the current dev id

Returns:

  • (String)

    The current dev id



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/roku_builder/keyer.rb', line 31

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

#rekey(keyed_pkg:, password:) ⇒ Boolean

Sets the key on the roku device

Parameters:

  • keyed_pkg (String)

    Path for a package signed with the desired key

  • password (String)

    Password for the package

Returns:

  • (Boolean)

    True if key changed, false otherwise



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/roku_builder/keyer.rb', line 10

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