Module: DSU3::Props

Defined in:
lib/dsu3/props.rb

Overview

The fundamental class in this vast system, on which all the other parts of the structure depend

Constant Summary collapse

USER_AGENT =

user-agent header

'Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0'
HEADERS =

Headers necessary for normal interaction with the Discord API

{
  accept: '*/*',
  accept_encoding: 'gzip, deflate, br',
  accept_language: 'en',
  alt_used: 'discord.com',
  connection: 'keep-alive',
  host: 'discord.com',
  sec_fetch_dest: 'empty',
  sec_fetch_mode: 'cors',
  sec_fetch_site: 'same-origin',
  te: 'trailers',
  user_agent: USER_AGENT,
  x_debug_options: 'bugReporterEnabled',
  x_discord_locale: 'en-US',
  x_super_properties: generate_x_super_properties,
  content_type: 'application/json',
  cookie: HTTP::Cookie.cookie_value(resp.cookie_jar.cookies),
  x_fingerprint: JSON.parse(resp.body)['fingerprint']
}.freeze

Class Method Summary collapse

Class Method Details

.fetch_build_numberObject

Fetches Discord client build number



14
15
16
17
18
# File 'lib/dsu3/props.rb', line 14

def fetch_build_number
  JSON.parse(
    RestClient.get('https://api.github.com/repos/Discord-Datamining/Discord-Datamining/commits/master')
  )['commit']['message'].match(/Build (\d+)/)[1]
end

.generate_x_super_propertiesObject

Generates x-super-properties header



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dsu3/props.rb', line 21

def generate_x_super_properties
  Base64.strict_encode64(JSON.generate(
    os: 'Linux',
    browser: 'Firefox',
    device: '',
    system_locale: 'en',
    browser_user_agent: USER_AGENT,
    browser_version: '91.0',
    os_version: '',
    referrer: '',
    referring_domain: '',
    referrer_current: '',
    referring_domain_current: '',
    release_channel: 'stable',
    client_build_number: fetch_build_number,
    client_event_source: nil
  ))
end