etwin 0.0.3 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/etwin.rb +1 -0
- data/lib/etwin/auth.rb +1 -0
- data/lib/etwin/auth/_auth_context.rb +1 -0
- data/lib/etwin/auth/access_token_auth_context.rb +103 -0
- data/lib/etwin/auth/auth_type.rb +1 -0
- data/lib/etwin/client/auth.rb +1 -1
- data/lib/etwin/client/http_etwin_client.rb +1 -1
- data/lib/etwin/oauth.rb +13 -0
- data/lib/etwin/oauth/oauth_client_display_name.rb +57 -0
- data/lib/etwin/oauth/oauth_client_id.rb +57 -0
- data/lib/etwin/oauth/oauth_client_key.rb +57 -0
- data/lib/etwin/oauth/short_oauth_client.rb +104 -0
- data/lib/etwin/version.rb +1 -1
- data/sorbet/rbi/gems/debase.rbi +2 -2
- data/sorbet/rbi/gems/faraday.rbi +623 -0
- data/sorbet/rbi/gems/irb.rbi +3 -3
- data/sorbet/rbi/gems/multipart-post.rbi +53 -0
- data/sorbet/rbi/gems/rspec-core.rbi +17 -0
- data/sorbet/rbi/gems/rspec-expectations.rbi +5 -5
- data/sorbet/rbi/gems/rubocop-sorbet.rbi +157 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +220 -97
- data/sorbet/rbi/hidden-definitions/hidden.rbi +530 -108
- data/sorbet/rbi/sorbet-typed/lib/faraday/all/faraday.rbi +756 -0
- data/sorbet/rbi/todo.rbi +2 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c116defe51194b8f40c3496884b3a551fc0388c28a606a0dccfe2618b7700d8
|
4
|
+
data.tar.gz: 19151aa9323d4de434f1606d9943faedba65451d7b307bb8b302816bc4e366a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbb9665963eb211d4ea1b1c271a48a747c62723614716a81ae100b6d7df9b6e39de8673128c95c1a96375fe3e14a1220305d7d0117c38638fb290c58dea29be7
|
7
|
+
data.tar.gz: 95a308a4d2ec53dfe51f189cb939b803b2f5adc8b9f18adbebae6455314067cebfe5844dd9330f73618f377cb6b7e3dc67959d5e722e9b1121259907f611d2de
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/etwin.rb
CHANGED
@@ -21,6 +21,7 @@ require_relative './etwin/client'
|
|
21
21
|
require_relative './etwin/core'
|
22
22
|
require_relative './etwin/hammerfest'
|
23
23
|
require_relative './etwin/link'
|
24
|
+
require_relative './etwin/oauth'
|
24
25
|
require_relative './etwin/twinoid'
|
25
26
|
require_relative './etwin/user'
|
26
27
|
require_relative './etwin/version'
|
data/lib/etwin/auth.rb
CHANGED
@@ -20,6 +20,7 @@ module Etwin
|
|
20
20
|
def AuthContext.deserialize(raw)
|
21
21
|
type = AuthType.deserialize(raw['type'])
|
22
22
|
case type
|
23
|
+
when AuthType::AccessToken then AccessTokenAuthContext.deserialize(raw)
|
23
24
|
when AuthType::Guest then GuestAuthContext.deserialize(raw)
|
24
25
|
when AuthType::User then UserAuthContext.deserialize(raw)
|
25
26
|
else T.absurd(type)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Etwin
|
5
|
+
module Auth
|
6
|
+
# Access token authentication context
|
7
|
+
class AccessTokenAuthContext
|
8
|
+
extend T::Helpers
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
final!
|
12
|
+
|
13
|
+
sig(:final) { returns(AuthScope) }
|
14
|
+
attr_reader :scope
|
15
|
+
|
16
|
+
sig(:final) { returns(Etwin::Oauth::ShortOauthClient) }
|
17
|
+
attr_reader :client
|
18
|
+
|
19
|
+
sig(:final) { returns(Etwin::User::ShortUser) }
|
20
|
+
attr_reader :user
|
21
|
+
|
22
|
+
sig(:final) { params(scope: AuthScope, client: Etwin::Oauth::ShortOauthClient, user: Etwin::User::ShortUser).void }
|
23
|
+
def initialize(scope, client, user)
|
24
|
+
@scope = T.let(scope, AuthScope)
|
25
|
+
@client = T.let(client, Etwin::Oauth::ShortOauthClient)
|
26
|
+
@user = T.let(user, Etwin::User::ShortUser)
|
27
|
+
freeze
|
28
|
+
end
|
29
|
+
|
30
|
+
sig(:final) { params(other: BasicObject).returns(T::Boolean) }
|
31
|
+
def ==(other)
|
32
|
+
case other
|
33
|
+
when AccessTokenAuthContext
|
34
|
+
@scope == other.scope && @client == other.client && @user == other.user
|
35
|
+
else
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
sig(:final) { returns(Integer) }
|
41
|
+
def hash
|
42
|
+
[@scope, @client, @user].hash
|
43
|
+
end
|
44
|
+
|
45
|
+
# https://github.com/sorbet/sorbet/blob/master/rbi/stdlib/json.rbi#L194
|
46
|
+
sig(:final) { params(opts: T.untyped).returns(String) }
|
47
|
+
def to_json(opts = nil)
|
48
|
+
JSON.generate(as_json, opts)
|
49
|
+
end
|
50
|
+
|
51
|
+
sig(:final) { returns(T::Hash[String, T.untyped]) }
|
52
|
+
def as_json
|
53
|
+
{
|
54
|
+
'scope' => @scope.serialize,
|
55
|
+
'client' => @client.as_json,
|
56
|
+
'user' => @user.as_json
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
sig(:final) { returns(String) }
|
61
|
+
def inspect
|
62
|
+
PP.singleline_pp(self, String.new)
|
63
|
+
end
|
64
|
+
|
65
|
+
sig(:final) { params(pp: T.untyped).returns(T.untyped) }
|
66
|
+
def pretty_print(pp) # rubocop:disable Metrics/MethodLength
|
67
|
+
pp.group(0, "#{self.class.name}(", ')') do
|
68
|
+
pp.nest 1 do
|
69
|
+
pp.breakable ''
|
70
|
+
pp.text 'scope='
|
71
|
+
pp.pp @scope
|
72
|
+
pp.text ','
|
73
|
+
pp.breakable ''
|
74
|
+
pp.text 'client='
|
75
|
+
pp.pp @client
|
76
|
+
pp.text ','
|
77
|
+
pp.breakable ''
|
78
|
+
pp.text 'user='
|
79
|
+
pp.pp @user
|
80
|
+
end
|
81
|
+
pp.breakable ''
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class << self
|
86
|
+
extend T::Sig
|
87
|
+
|
88
|
+
sig(:final) { params(json_str: String).returns(T.attached_class) }
|
89
|
+
def from_json(json_str)
|
90
|
+
deserialize JSON.parse(json_str)
|
91
|
+
end
|
92
|
+
|
93
|
+
sig(:final) { params(raw: T.untyped).returns(T.attached_class) }
|
94
|
+
def deserialize(raw)
|
95
|
+
scope = AuthScope.deserialize(raw['scope'])
|
96
|
+
client = Etwin::Oauth::ShortOauthClient.deserialize(raw['client'])
|
97
|
+
user = Etwin::User::ShortUser.deserialize(raw['user'])
|
98
|
+
new(scope, client, user)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/etwin/auth/auth_type.rb
CHANGED
data/lib/etwin/client/auth.rb
CHANGED
data/lib/etwin/oauth.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Etwin
|
5
|
+
# Oauth module
|
6
|
+
module Oauth
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
require_relative './oauth/oauth_client_display_name'
|
11
|
+
require_relative './oauth/oauth_client_id'
|
12
|
+
require_relative './oauth/oauth_client_key'
|
13
|
+
require_relative './oauth/short_oauth_client'
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Etwin
|
5
|
+
module Oauth
|
6
|
+
# A valid Eternal-Twin OAuth client display name
|
7
|
+
class OauthClientDisplayName
|
8
|
+
extend T::Helpers
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
final!
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
sig(:final) { returns(String) }
|
16
|
+
attr_reader :inner
|
17
|
+
|
18
|
+
public
|
19
|
+
|
20
|
+
sig(:final) { params(inner: String).void }
|
21
|
+
def initialize(inner)
|
22
|
+
@inner = T.let(inner.freeze, String)
|
23
|
+
freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
sig(:final) { params(other: BasicObject).returns(T::Boolean) }
|
27
|
+
def ==(other)
|
28
|
+
case other
|
29
|
+
when OauthClientDisplayName
|
30
|
+
@inner == other.inner
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
sig(:final) { returns(Integer) }
|
37
|
+
def hash
|
38
|
+
@inner.hash
|
39
|
+
end
|
40
|
+
|
41
|
+
sig(:final) { returns(String) }
|
42
|
+
def to_s
|
43
|
+
@inner
|
44
|
+
end
|
45
|
+
|
46
|
+
sig(:final) { returns(String) }
|
47
|
+
def as_json
|
48
|
+
@inner
|
49
|
+
end
|
50
|
+
|
51
|
+
sig(:final) { returns(String) }
|
52
|
+
def inspect
|
53
|
+
"OauthClientDisplayName(#{@inner})"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Etwin
|
5
|
+
module Oauth
|
6
|
+
# A valid Eternal-Twin OAuth client id
|
7
|
+
class OauthClientId
|
8
|
+
extend T::Helpers
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
final!
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
sig(:final) { returns(String) }
|
16
|
+
attr_reader :inner
|
17
|
+
|
18
|
+
public
|
19
|
+
|
20
|
+
sig(:final) { params(inner: String).void }
|
21
|
+
def initialize(inner)
|
22
|
+
@inner = T.let(inner.freeze, String)
|
23
|
+
freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
sig(:final) { params(other: BasicObject).returns(T::Boolean) }
|
27
|
+
def ==(other)
|
28
|
+
case other
|
29
|
+
when OauthClientId
|
30
|
+
@inner == other.inner
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
sig(:final) { returns(Integer) }
|
37
|
+
def hash
|
38
|
+
@inner.hash
|
39
|
+
end
|
40
|
+
|
41
|
+
sig(:final) { returns(String) }
|
42
|
+
def to_s
|
43
|
+
@inner
|
44
|
+
end
|
45
|
+
|
46
|
+
sig(:final) { returns(String) }
|
47
|
+
def as_json
|
48
|
+
@inner
|
49
|
+
end
|
50
|
+
|
51
|
+
sig(:final) { returns(String) }
|
52
|
+
def inspect
|
53
|
+
"OauthClientId(#{@inner})"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Etwin
|
5
|
+
module Oauth
|
6
|
+
# A valid Eternal-Twin OAuth client key
|
7
|
+
class OauthClientKey
|
8
|
+
extend T::Helpers
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
final!
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
sig(:final) { returns(String) }
|
16
|
+
attr_reader :inner
|
17
|
+
|
18
|
+
public
|
19
|
+
|
20
|
+
sig(:final) { params(inner: String).void }
|
21
|
+
def initialize(inner)
|
22
|
+
@inner = T.let(inner.freeze, String)
|
23
|
+
freeze
|
24
|
+
end
|
25
|
+
|
26
|
+
sig(:final) { params(other: BasicObject).returns(T::Boolean) }
|
27
|
+
def ==(other)
|
28
|
+
case other
|
29
|
+
when OauthClientKey
|
30
|
+
@inner == other.inner
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
sig(:final) { returns(Integer) }
|
37
|
+
def hash
|
38
|
+
@inner.hash
|
39
|
+
end
|
40
|
+
|
41
|
+
sig(:final) { returns(String) }
|
42
|
+
def to_s
|
43
|
+
@inner
|
44
|
+
end
|
45
|
+
|
46
|
+
sig(:final) { returns(String) }
|
47
|
+
def as_json
|
48
|
+
@inner
|
49
|
+
end
|
50
|
+
|
51
|
+
sig(:final) { returns(String) }
|
52
|
+
def inspect
|
53
|
+
"OauthClientKey(#{@inner})"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Etwin
|
5
|
+
module Oauth
|
6
|
+
# OAuth client with minimum data to identify and display it
|
7
|
+
class ShortOauthClient
|
8
|
+
extend T::Helpers
|
9
|
+
extend T::Sig
|
10
|
+
|
11
|
+
final!
|
12
|
+
|
13
|
+
sig(:final) { returns(OauthClientId) }
|
14
|
+
attr_reader :id
|
15
|
+
|
16
|
+
sig(:final) { returns(T.nilable(OauthClientKey)) }
|
17
|
+
attr_reader :key
|
18
|
+
|
19
|
+
sig(:final) { returns(OauthClientDisplayName) }
|
20
|
+
attr_reader :display_name
|
21
|
+
|
22
|
+
sig(:final) { params(id: OauthClientId, key: T.nilable(OauthClientKey), display_name: OauthClientDisplayName).void }
|
23
|
+
def initialize(id, key, display_name)
|
24
|
+
@id = T.let(id, OauthClientId)
|
25
|
+
@key = T.let(key, T.nilable(OauthClientKey))
|
26
|
+
@display_name = T.let(display_name, OauthClientDisplayName)
|
27
|
+
freeze
|
28
|
+
end
|
29
|
+
|
30
|
+
sig(:final) { params(other: BasicObject).returns(T::Boolean) }
|
31
|
+
def ==(other)
|
32
|
+
case other
|
33
|
+
when ShortOauthClient
|
34
|
+
@id == other.id && @key == other.key && @display_name == other.display_name
|
35
|
+
else
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
sig(:final) { returns(Integer) }
|
41
|
+
def hash
|
42
|
+
[@id, @key, @display_name].hash
|
43
|
+
end
|
44
|
+
|
45
|
+
# https://github.com/sorbet/sorbet/blob/master/rbi/stdlib/json.rbi#L194
|
46
|
+
sig(:final) { params(opts: T.untyped).returns(String) }
|
47
|
+
def to_json(opts = nil)
|
48
|
+
JSON.generate(as_json, opts)
|
49
|
+
end
|
50
|
+
|
51
|
+
sig(:final) { returns(T::Hash[String, T.untyped]) }
|
52
|
+
def as_json
|
53
|
+
{
|
54
|
+
'id' => @id.as_json,
|
55
|
+
'key' => @key.nil? ? nil : @key.as_json,
|
56
|
+
'display_name' => @display_name.as_json
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
sig(:final) { returns(String) }
|
61
|
+
def inspect
|
62
|
+
PP.singleline_pp(self, String.new)
|
63
|
+
end
|
64
|
+
|
65
|
+
sig(:final) { params(pp: T.untyped).returns(T.untyped) }
|
66
|
+
def pretty_print(pp) # rubocop:disable Metrics/MethodLength
|
67
|
+
pp.group(0, "#{self.class.name}(", ')') do
|
68
|
+
pp.nest 1 do
|
69
|
+
pp.breakable ''
|
70
|
+
pp.text 'id='
|
71
|
+
pp.pp @id
|
72
|
+
pp.text ','
|
73
|
+
pp.breakable ''
|
74
|
+
pp.text 'key='
|
75
|
+
pp.pp @key
|
76
|
+
pp.text ','
|
77
|
+
pp.breakable ''
|
78
|
+
pp.text 'display_name='
|
79
|
+
pp.pp @display_name
|
80
|
+
end
|
81
|
+
pp.breakable ''
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class << self
|
86
|
+
extend T::Sig
|
87
|
+
|
88
|
+
sig(:final) { params(json_str: String).returns(T.attached_class) }
|
89
|
+
def from_json(json_str)
|
90
|
+
deserialize JSON.parse(json_str)
|
91
|
+
end
|
92
|
+
|
93
|
+
sig(:final) { params(raw: T.untyped).returns(T.attached_class) }
|
94
|
+
def deserialize(raw)
|
95
|
+
id = OauthClientId.new(raw['id'])
|
96
|
+
raw_key = raw['key']
|
97
|
+
key = raw_key.nil? ? nil : OauthClientKey.new(raw_key)
|
98
|
+
display_name = OauthClientDisplayName.new(raw['display_name'])
|
99
|
+
new(id, key, display_name)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|