glogin 0.17.1 → 0.17.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/Gemfile.lock +25 -23
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +1 -1
- data/Rakefile +1 -1
- data/glogin.gemspec +1 -1
- data/lib/glogin/auth.rb +29 -4
- data/lib/glogin/codec.rb +2 -2
- data/lib/glogin/cookie.rb +2 -2
- data/lib/glogin/errors.rb +38 -0
- data/lib/glogin/version.rb +4 -4
- data/lib/glogin.rb +3 -2
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d365fbcc98249133c9c6ee63b621ebb900be53df49bfbeb5c40d5256e2e752e0
|
|
4
|
+
data.tar.gz: 50abb7bdfc000d36f5f84362b3550c8de20f20a265725e37782e665289085d4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de901931d43eabb3c9fdd785a19ae65bbae4ba111492319e9ba21d603bcabfa41fd96687a18a92d8fd95f9f2715afaac9f356e87699d64535180ce66eda05c26
|
|
7
|
+
data.tar.gz: ed23b4e00b79e928365dfe6ca2d6caeb3c85713296d953248da4f90d3be8e5acd9ac7daff90347372e746afea7c213a85cfcc9c0e9f378f994133e76866a238e
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -9,65 +9,67 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
addressable (2.
|
|
12
|
+
addressable (2.9.0)
|
|
13
13
|
public_suffix (>= 2.0.2, < 8.0)
|
|
14
|
-
ansi (1.
|
|
14
|
+
ansi (1.6.0)
|
|
15
15
|
ast (2.4.3)
|
|
16
16
|
base58 (0.2.3)
|
|
17
17
|
base64 (0.3.0)
|
|
18
|
-
bigdecimal (4.
|
|
18
|
+
bigdecimal (4.1.2)
|
|
19
19
|
builder (3.3.0)
|
|
20
20
|
crack (1.0.1)
|
|
21
21
|
bigdecimal
|
|
22
22
|
rexml
|
|
23
23
|
date (3.5.1)
|
|
24
24
|
docile (1.4.1)
|
|
25
|
-
|
|
25
|
+
drb (2.2.3)
|
|
26
|
+
erb (6.0.2)
|
|
26
27
|
hashdiff (1.2.1)
|
|
27
|
-
json (2.
|
|
28
|
+
json (2.19.4)
|
|
28
29
|
language_server-protocol (3.17.0.5)
|
|
29
30
|
lint_roller (1.1.0)
|
|
30
|
-
minitest (6.0.
|
|
31
|
+
minitest (6.0.5)
|
|
32
|
+
drb (~> 2.0)
|
|
31
33
|
prism (~> 1.5)
|
|
32
|
-
minitest-reporters (1.
|
|
34
|
+
minitest-reporters (1.8.0)
|
|
33
35
|
ansi
|
|
34
36
|
builder
|
|
35
|
-
minitest (>= 5.0)
|
|
37
|
+
minitest (>= 5.0, < 7)
|
|
36
38
|
ruby-progressbar
|
|
37
39
|
openssl (4.0.0)
|
|
38
|
-
parallel (1.
|
|
39
|
-
parser (3.3.
|
|
40
|
+
parallel (1.28.0)
|
|
41
|
+
parser (3.3.11.1)
|
|
40
42
|
ast (~> 2.4.1)
|
|
41
43
|
racc
|
|
42
|
-
prism (1.
|
|
44
|
+
prism (1.9.0)
|
|
43
45
|
psych (5.3.1)
|
|
44
46
|
date
|
|
45
47
|
stringio
|
|
46
|
-
public_suffix (7.0.
|
|
48
|
+
public_suffix (7.0.5)
|
|
47
49
|
racc (1.8.1)
|
|
48
50
|
rainbow (3.1.1)
|
|
49
|
-
rake (13.
|
|
50
|
-
rdoc (7.0
|
|
51
|
+
rake (13.4.2)
|
|
52
|
+
rdoc (7.2.0)
|
|
51
53
|
erb
|
|
52
54
|
psych (>= 4.0.0)
|
|
53
55
|
tsort
|
|
54
|
-
regexp_parser (2.
|
|
56
|
+
regexp_parser (2.12.0)
|
|
55
57
|
rexml (3.4.4)
|
|
56
|
-
rubocop (1.
|
|
58
|
+
rubocop (1.86.1)
|
|
57
59
|
json (~> 2.3)
|
|
58
60
|
language_server-protocol (~> 3.17.0.2)
|
|
59
61
|
lint_roller (~> 1.1.0)
|
|
60
|
-
parallel (
|
|
62
|
+
parallel (>= 1.10)
|
|
61
63
|
parser (>= 3.3.0.2)
|
|
62
64
|
rainbow (>= 2.2.2, < 4.0)
|
|
63
65
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
64
|
-
rubocop-ast (>= 1.
|
|
66
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
65
67
|
ruby-progressbar (~> 1.7)
|
|
66
68
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
67
|
-
rubocop-ast (1.
|
|
69
|
+
rubocop-ast (1.49.1)
|
|
68
70
|
parser (>= 3.3.7.2)
|
|
69
|
-
prism (~> 1.
|
|
70
|
-
rubocop-minitest (0.
|
|
71
|
+
prism (~> 1.7)
|
|
72
|
+
rubocop-minitest (0.39.1)
|
|
71
73
|
lint_roller (~> 1.1)
|
|
72
74
|
rubocop (>= 1.75.0, < 2.0)
|
|
73
75
|
rubocop-ast (>= 1.38.0, < 2.0)
|
|
@@ -93,11 +95,11 @@ GEM
|
|
|
93
95
|
unicode-display_width (3.2.0)
|
|
94
96
|
unicode-emoji (~> 4.1)
|
|
95
97
|
unicode-emoji (4.2.0)
|
|
96
|
-
webmock (3.26.
|
|
98
|
+
webmock (3.26.2)
|
|
97
99
|
addressable (>= 2.8.0)
|
|
98
100
|
crack (>= 0.3.2)
|
|
99
101
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
100
|
-
yard (0.9.
|
|
102
|
+
yard (0.9.42)
|
|
101
103
|
|
|
102
104
|
PLATFORMS
|
|
103
105
|
arm64-darwin-22
|
data/LICENSE.txt
CHANGED
data/LICENSES/MIT.txt
CHANGED
data/Rakefile
CHANGED
data/glogin.gemspec
CHANGED
data/lib/glogin/auth.rb
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2017-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
require 'cgi'
|
|
7
7
|
require 'json'
|
|
8
8
|
require 'net/http'
|
|
9
|
+
require 'openssl'
|
|
10
|
+
require 'socket'
|
|
9
11
|
require 'uri'
|
|
12
|
+
require_relative 'errors'
|
|
10
13
|
|
|
11
14
|
# GLogin main module.
|
|
12
15
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
13
|
-
# Copyright:: Copyright (c) 2017-
|
|
16
|
+
# Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
14
17
|
# License:: MIT
|
|
15
18
|
module GLogin
|
|
16
19
|
# GitHub authentication mechanism.
|
|
@@ -107,7 +110,7 @@ module GLogin
|
|
|
107
110
|
req['Accept-Header'] = 'application/json'
|
|
108
111
|
token = access_token(code)
|
|
109
112
|
req['Authorization'] = "token #{token}"
|
|
110
|
-
res = http
|
|
113
|
+
res = perform(http, req, "user fetch with token #{escape(token)}")
|
|
111
114
|
raise "HTTP error ##{res.code} with token #{escape(token)}: #{res.body}" unless res.code == '200'
|
|
112
115
|
JSON.parse(res.body)
|
|
113
116
|
end
|
|
@@ -128,7 +131,7 @@ module GLogin
|
|
|
128
131
|
'client_secret' => @secret
|
|
129
132
|
)
|
|
130
133
|
req['Accept'] = 'application/json'
|
|
131
|
-
res = http
|
|
134
|
+
res = perform(http, req, "token exchange with code #{escape(code)}")
|
|
132
135
|
raise "HTTP error ##{res.code} with code #{escape(code)}: #{res.body}" unless res.code == '200'
|
|
133
136
|
json = JSON.parse(res.body)
|
|
134
137
|
token = json['access_token']
|
|
@@ -136,6 +139,28 @@ module GLogin
|
|
|
136
139
|
token
|
|
137
140
|
end
|
|
138
141
|
|
|
142
|
+
# Low-level network errors that should be wrapped in
|
|
143
|
+
# GLogin::ConnectionError instead of leaking out as provider-specific
|
|
144
|
+
# classes like Socket::ResolutionError. SystemCallError covers the
|
|
145
|
+
# full Errno:: family (ECONNREFUSED, ECONNRESET, ETIMEDOUT, etc.).
|
|
146
|
+
CONNECTION_ERRORS = [
|
|
147
|
+
SocketError,
|
|
148
|
+
SystemCallError,
|
|
149
|
+
OpenSSL::SSL::SSLError,
|
|
150
|
+
Net::OpenTimeout,
|
|
151
|
+
Net::ReadTimeout,
|
|
152
|
+
Net::WriteTimeout,
|
|
153
|
+
EOFError,
|
|
154
|
+
IOError
|
|
155
|
+
].freeze
|
|
156
|
+
private_constant :CONNECTION_ERRORS
|
|
157
|
+
|
|
158
|
+
def perform(http, req, context)
|
|
159
|
+
http.request(req)
|
|
160
|
+
rescue *CONNECTION_ERRORS => e
|
|
161
|
+
raise GLogin::ConnectionError, "#{e.class}: #{e.message} (during #{context})"
|
|
162
|
+
end
|
|
163
|
+
|
|
139
164
|
def escape(txt)
|
|
140
165
|
prefix = 4
|
|
141
166
|
[
|
data/lib/glogin/codec.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2017-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
require 'base58'
|
|
@@ -11,7 +11,7 @@ require 'securerandom'
|
|
|
11
11
|
|
|
12
12
|
# Codec.
|
|
13
13
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
14
|
-
# Copyright:: Copyright (c) 2017-
|
|
14
|
+
# Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
15
15
|
# License:: MIT
|
|
16
16
|
module GLogin
|
|
17
17
|
# The codec for encrypting and decrypting text.
|
data/lib/glogin/cookie.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2017-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
require 'base64'
|
|
@@ -10,7 +10,7 @@ require_relative 'codec'
|
|
|
10
10
|
|
|
11
11
|
# GLogin main module.
|
|
12
12
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
13
|
-
# Copyright:: Copyright (c) 2017-
|
|
13
|
+
# Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
14
14
|
# License:: MIT
|
|
15
15
|
module GLogin
|
|
16
16
|
# Split symbol inside the cookie text
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
# GLogin main module.
|
|
7
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
8
|
+
# Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
9
|
+
# License:: MIT
|
|
10
|
+
module GLogin
|
|
11
|
+
# Base class for all GLogin-specific errors.
|
|
12
|
+
#
|
|
13
|
+
# @example Rescuing any GLogin error
|
|
14
|
+
# begin
|
|
15
|
+
# auth.user(code)
|
|
16
|
+
# rescue GLogin::Error => e
|
|
17
|
+
# logger.error("GLogin failed: #{e.message}")
|
|
18
|
+
# end
|
|
19
|
+
class Error < StandardError
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Raised when GLogin cannot reach GitHub due to a low-level networking
|
|
23
|
+
# issue (DNS resolution failure, connection refused, TLS handshake
|
|
24
|
+
# failure, read timeout, etc.).
|
|
25
|
+
#
|
|
26
|
+
# The original exception is preserved via Ruby's exception chaining
|
|
27
|
+
# mechanism and is accessible through +#cause+.
|
|
28
|
+
#
|
|
29
|
+
# @example Handling a connection failure gracefully
|
|
30
|
+
# begin
|
|
31
|
+
# auth.user(code)
|
|
32
|
+
# rescue GLogin::ConnectionError => e
|
|
33
|
+
# logger.warn("GitHub unreachable: #{e.message} (cause: #{e.cause.class})")
|
|
34
|
+
# halt(503, 'GitHub is unreachable, please try again later')
|
|
35
|
+
# end
|
|
36
|
+
class ConnectionError < Error
|
|
37
|
+
end
|
|
38
|
+
end
|
data/lib/glogin/version.rb
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2017-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
6
|
# GLogin main module.
|
|
7
7
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
8
|
-
# Copyright:: Copyright (c) 2017-
|
|
8
|
+
# Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
9
9
|
# License:: MIT
|
|
10
10
|
module GLogin
|
|
11
11
|
# Current version of the GLogin gem.
|
|
12
12
|
#
|
|
13
13
|
# @example Check the gem version
|
|
14
14
|
# puts GLogin::VERSION
|
|
15
|
-
# # => "0.17.
|
|
15
|
+
# # => "0.17.2"
|
|
16
16
|
#
|
|
17
17
|
# @example Version comparison
|
|
18
18
|
# if Gem::Version.new(GLogin::VERSION) >= Gem::Version.new('0.1.0')
|
|
19
19
|
# puts "Using GLogin version 0.1.0 or newer"
|
|
20
20
|
# end
|
|
21
|
-
VERSION = '0.17.
|
|
21
|
+
VERSION = '0.17.2'
|
|
22
22
|
end
|
data/lib/glogin.rb
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# SPDX-FileCopyrightText: Copyright (c) 2017-
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
5
|
|
|
6
|
+
require_relative 'glogin/errors'
|
|
6
7
|
require_relative 'glogin/auth'
|
|
7
8
|
require_relative 'glogin/cookie'
|
|
8
9
|
require_relative 'glogin/version'
|
|
@@ -33,7 +34,7 @@ require_relative 'glogin/version'
|
|
|
33
34
|
# end
|
|
34
35
|
#
|
|
35
36
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
36
|
-
# Copyright:: Copyright (c) 2017-
|
|
37
|
+
# Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
|
|
37
38
|
# License:: MIT
|
|
38
39
|
module GLogin
|
|
39
40
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: glogin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.17.
|
|
4
|
+
version: 0.17.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
@@ -71,6 +71,7 @@ files:
|
|
|
71
71
|
- lib/glogin/auth.rb
|
|
72
72
|
- lib/glogin/codec.rb
|
|
73
73
|
- lib/glogin/cookie.rb
|
|
74
|
+
- lib/glogin/errors.rb
|
|
74
75
|
- lib/glogin/version.rb
|
|
75
76
|
- logo.svg
|
|
76
77
|
homepage: https://github.com/yegor256/glogin
|