fortniteruby 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d36b918519a852d994718c9c33817e4648e0eedd5c0af2e323192cea32d9707
4
- data.tar.gz: 6adad84d668b5270ee7fc7ad709f9a84541210d4c45bde0851259d05771c70fe
3
+ metadata.gz: b4372116bd0dce5aa9242e4dd33e7cfa49cbed02af6e67dfb5a05dabc9500a3e
4
+ data.tar.gz: 307b04c436df5754d61964546ec5e24a3065754f68ce5758af2c179952078039
5
5
  SHA512:
6
- metadata.gz: 50a8bd6576d4c5dc6ef6814739e42bdf4b95df55b47d327f06156dbfb51f4fe8bcc49fa6b7615ff1109529d4c9bced3a061df92ac5b8c186609d330b4b1cf7b2
7
- data.tar.gz: 46ae4f015ba1b6bf41fbc4f5a57b92051fe748b588c83faf02d0befecbed5a2e55ce4841b43ddcf655099b29640c750db3e454c2a19cd54dc0f46fd922b1f288
6
+ metadata.gz: cadddc117bb098eee61defb6b9a1871aabb47ac28908692a140a0875c58a4a8787fb1e30d5fc5161637287501a6e18abc6f15a290a5ac11928392dd0ee151eb9
7
+ data.tar.gz: 7e4c0343d620affea16e8f0841e1ce8ec8d0797b5858d888da9d4551f434d196098c1f62acd0a65dc3664831cc138d30a1d28f95a0b85bbe72f371ae35abd9eb
data/lib/client.rb ADDED
@@ -0,0 +1,45 @@
1
+ require 'httparty'
2
+
3
+ class FortniteClient
4
+ def authenticate()
5
+ # Function to authenticate with the Epic Games API through exchange code.
6
+ login = HTTParty.post(
7
+ "https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token",
8
+ :headers => {
9
+ "Content-Type" => "application/x-www-form-urlencoded",
10
+ "Authorization" => "basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ="
11
+ },
12
+ :body => {
13
+ "grant_type" => "exchange_code",
14
+ "exchange_code" => @_exchange_code
15
+ },
16
+ # :debug_output => $stdout
17
+ )
18
+
19
+ @display_name = JSON.parse(login.body)['displayName']
20
+ @access_token = JSON.parse(login.body)['access_token']
21
+ end
22
+
23
+ def initialize(exchange_code=nil)
24
+ if exchange_code == nil # Prompts an input for the exchange code if none is provided.
25
+ puts 'Please enter an exchange code:'
26
+ exchange_code = gets.chomp
27
+ end
28
+
29
+ @_exchange_code = exchange_code
30
+ end
31
+
32
+ # Private attributes (not intended to be used outside of the object itself).
33
+ attr_accessor :_exchange_code
34
+
35
+ # Public attributes.
36
+ attr_accessor :display_name
37
+ attr_accessor :access_token
38
+ end
39
+
40
+ client = FortniteClient.new(exchange_code="8ecd0b354ced4620999dc28aa77f1554")
41
+ client.authenticate()
42
+
43
+ puts client.display_name
44
+ puts client.access_token
45
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortniteruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - xMistt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -30,9 +30,8 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
- - lib/fortniteruby.rb
34
- - lib/fortniteruby/client.rb
35
- homepage: https://github.com/xMistt/FortniteRuby/
33
+ - lib/client.rb
34
+ homepage: https://github.com/xMistt/fortniteruby/
36
35
  licenses: []
37
36
  metadata: {}
38
37
  post_install_message:
@@ -1,44 +0,0 @@
1
- require 'httparty'
2
-
3
- class FortniteClient
4
- def initialize(email, password)
5
- csrf = HTTParty.get('https://www.epicgames.com/id/api/csrf')
6
- cookie = "EPIC_FUNNEL_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[1]}; EPIC_DEVICE=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[24]}; EPIC_SESSION_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[47]}; XSRF-TOKEN=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[54]}; EPIC_SSO_SESSION=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[59]}"
7
-
8
- headers = {"x-xsrf-token" => csrf.headers['Set-Cookie'].split(/[\s=;]/)[54], "Cookie" => cookie}
9
- body = {'email': email, 'password': password, 'rememberMe': false}
10
- login = HTTParty.post("https://www.epicgames.com/id/api/login", :headers => headers, :body => body)
11
- cookie = "EPIC_FUNNEL_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[1]}; EPIC_DEVICE=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[24]}; EPIC_SESSION_ID=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[47]}; XSRF-TOKEN=#{csrf.headers['Set-Cookie'].split(/[\s=;]/)[54]}; EPIC_SSO_SESSION=#{login.headers['Set-Cookie'].split(/[\s=;]/)[1]}"
12
-
13
- headers = {"x-xsrf-token" => csrf.headers['Set-Cookie'].split(/[\s=;]/)[54], "Cookie" => cookie}
14
- exchange = HTTParty.get('https://www.epicgames.com/id/api/exchange', :headers => headers)
15
-
16
- headers = {"Authorization" => 'basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE='}
17
- body = {'grant_type': 'exchange_code', 'token_type': 'eg1', 'exchange_code': JSON.parse(exchange.body)['code']}
18
- token = HTTParty.post("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token", :headers => headers, :body => body)
19
- @launcherauth = JSON.parse(token.body)['access_token']
20
-
21
- headers = {"Authorization" => "Bearer #{JSON.parse(token.body)['access_token']}"}
22
- fortniteExchange = HTTParty.get("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/exchange", :headers => headers)
23
-
24
- headers = {"Authorization" => 'basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ='}
25
- body = {'grant_type': 'exchange_code', 'token_type': 'eg1', 'exchange_code': JSON.parse(fortniteExchange.body)['code']}
26
- fortniteToken = HTTParty.post("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token", :headers => headers, :body => body)
27
-
28
- headers = {"Authorization" => "bearer #{JSON.parse(fortniteToken.body)['access_token']}"}
29
- account = HTTParty.get("https://account-public-service-prod03.ol.epicgames.com/account/api/public/account/#{JSON.parse(fortniteToken.body)['account_id']}", :headers => headers)
30
- @token = JSON.parse(fortniteToken.body)['access_token']
31
-
32
- body = JSON.parse(account.body)
33
-
34
- body.each do |name, value|
35
- instance_variable_set("@#{name}", value)
36
- end
37
-
38
- end
39
-
40
- attr_reader :displayName
41
- attr_reader :id
42
- attr_reader :token
43
-
44
- end
data/lib/fortniteruby.rb DELETED
@@ -1 +0,0 @@
1
- require_relative 'fortniteruby/client.rb'