glogin 0.14.1 → 0.14.2
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 +4 -4
- data/Gemfile +1 -1
- data/lib/glogin/cookie.rb +11 -24
- data/lib/glogin/version.rb +1 -1
- data/test/glogin/test_cookie.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56ba569dbb60a5e6e480c86cf2b5e103c6bd42d695e57d16bfc9b94a9b819526
|
4
|
+
data.tar.gz: 4cd694c79226b6a7946caf4adac29ea10326f7944f89facb7b578c2ea1bc9034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37236f4de0ef6c6984c450cf03c0c6a79f51564911d3cf8a35408158d57153bfbda6c966cb0f5aa678e96c4482f89142d189f1d5054efd5b4c10227a01aa75d3
|
7
|
+
data.tar.gz: 0f3a77248cd9c7ec6c925693ee125b8a34b86fd1def5d3f7e4bf45265d4a7ae46bf36b628444ce669e8da164116d57c88af6fb953e803520f6209bb3f066b954
|
data/Gemfile
CHANGED
@@ -28,7 +28,7 @@ gem 'minitest', '5.21.2', require: false
|
|
28
28
|
gem 'rake', '13.1.0', require: false
|
29
29
|
gem 'rdoc', '6.6.1', require: false
|
30
30
|
gem 'rspec-rails', '6.1.0', require: false
|
31
|
-
gem 'rubocop', '1.60.
|
31
|
+
gem 'rubocop', '1.60.2', require: false
|
32
32
|
gem 'rubocop-rspec', '2.26.1', require: false
|
33
33
|
gem 'simplecov', '0.22.0', require: false
|
34
34
|
gem 'webmock', '3.19.1', require: false
|
data/lib/glogin/cookie.rb
CHANGED
@@ -78,10 +78,12 @@ module GLogin
|
|
78
78
|
|
79
79
|
# Open
|
80
80
|
class Open
|
81
|
+
attr_reader :id, :login, :avatar_url, :bearer
|
82
|
+
|
81
83
|
# Here comes the JSON you receive from Auth.user().
|
82
84
|
#
|
83
85
|
# The JSON is a Hash where every key is a string. When the class is instantiated,
|
84
|
-
# its methods
|
86
|
+
# its methods `id`, `login`, and `avatar_url` may be used to retrieve
|
85
87
|
# the data inside the JSON, but this is not what this class is mainly about.
|
86
88
|
#
|
87
89
|
# The method +to_s+ returns an encrypted cookie string, that may be
|
@@ -89,39 +91,24 @@ module GLogin
|
|
89
91
|
def initialize(json, secret, context = '')
|
90
92
|
raise 'JSON can\'t be nil' if json.nil?
|
91
93
|
raise 'JSON must contain "id" key' if json['id'].nil?
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@
|
94
|
+
@id = json['id']
|
95
|
+
@login = json['login'] || ''
|
96
|
+
@avatar_url = json['avatar_url'] || ''
|
97
|
+
@bearer = json['bearer'] || ''
|
96
98
|
raise 'Secret can\'t be nil' if secret.nil?
|
97
99
|
@secret = secret
|
98
100
|
raise 'Context can\'t be nil' if context.nil?
|
99
101
|
@context = context.to_s
|
100
102
|
end
|
101
103
|
|
102
|
-
# GitHub id of the authenticated user
|
103
|
-
def id
|
104
|
-
@json['id']
|
105
|
-
end
|
106
|
-
|
107
|
-
# GitHub login name of the authenticated user
|
108
|
-
def login
|
109
|
-
@json['login']
|
110
|
-
end
|
111
|
-
|
112
|
-
# GitHub avatar URL of the authenticated user
|
113
|
-
def avatar_url
|
114
|
-
@json['avatar_url']
|
115
|
-
end
|
116
|
-
|
117
104
|
# Returns the text you should drop back to the user as a cookie.
|
118
105
|
def to_s
|
119
106
|
Codec.new(@secret).encrypt(
|
120
107
|
[
|
121
|
-
id,
|
122
|
-
login,
|
123
|
-
avatar_url,
|
124
|
-
@
|
108
|
+
@id,
|
109
|
+
@login,
|
110
|
+
@avatar_url,
|
111
|
+
@bearer,
|
125
112
|
@context
|
126
113
|
].join(GLogin::SPLIT)
|
127
114
|
)
|
data/lib/glogin/version.rb
CHANGED
data/test/glogin/test_cookie.rb
CHANGED
@@ -94,7 +94,7 @@ class TestCookie < Minitest::Test
|
|
94
94
|
assert_raises GLogin::Codec::DecodingError do
|
95
95
|
GLogin::Cookie::Closed.new(
|
96
96
|
GLogin::Cookie::Open.new(
|
97
|
-
JSON.parse('{"login":"x","avatar_url":"x","id":"
|
97
|
+
JSON.parse('{"login":"x","avatar_url":"x","id":"","bearer":""}'),
|
98
98
|
secret,
|
99
99
|
'context-1'
|
100
100
|
).to_s,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glogin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base58
|