stytch 2.2.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stytch/client.rb +3 -1
- data/lib/stytch/magic_links.rb +15 -0
- data/lib/stytch/oauth.rb +31 -0
- data/lib/stytch/otps.rb +44 -1
- data/lib/stytch/sessions.rb +6 -6
- data/lib/stytch/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 245003578710b944f8b2ffe1cfd080517b2177fcb2e01884f8b1087549ff09b8
|
4
|
+
data.tar.gz: e1d90c9591290ba11c64fe37cc5f4a4602a256deede647eca5cf003ff6cd5c39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c2f2b097b711c28549050b7306d0a84112d30b65acc635a30dab4ff296622a38bd6c93b10c22b8170ad0904041cc3122a73d5f77c6dd190a0c5b6bbe8f21617
|
7
|
+
data.tar.gz: bb4cc6263f19ef61f98a7bc53867fb35a855ac72caa184673dba2346c4b1780534577d22b8c4b206213e5b758cff0e819c100f038dcc8eb0bbaeeed940fefe48
|
data/lib/stytch/client.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'users'
|
4
4
|
require_relative 'magic_links'
|
5
|
+
require_relative 'oauth'
|
5
6
|
require_relative 'otps'
|
6
7
|
require_relative 'sessions'
|
7
8
|
|
@@ -9,7 +10,7 @@ module Stytch
|
|
9
10
|
class Client
|
10
11
|
ENVIRONMENTS = %i[live test].freeze
|
11
12
|
|
12
|
-
attr_reader :users, :magic_links, :otps, :sessions
|
13
|
+
attr_reader :users, :magic_links, :oauth, :otps, :sessions
|
13
14
|
|
14
15
|
def initialize(env:, project_id:, secret:, &block)
|
15
16
|
@api_host = api_host(env)
|
@@ -20,6 +21,7 @@ module Stytch
|
|
20
21
|
|
21
22
|
@users = Stytch::Users.new(@connection)
|
22
23
|
@magic_links = Stytch::MagicLinks.new(@connection)
|
24
|
+
@oauth = Stytch::OAuth.new(@connection)
|
23
25
|
@otps = Stytch::OTPs.new(@connection)
|
24
26
|
@sessions = Stytch::Sessions.new(@connection)
|
25
27
|
end
|
data/lib/stytch/magic_links.rb
CHANGED
@@ -16,6 +16,21 @@ module Stytch
|
|
16
16
|
@email = Stytch::MagicLinks::Email.new(@connection)
|
17
17
|
end
|
18
18
|
|
19
|
+
def create(
|
20
|
+
user_id:,
|
21
|
+
expiration_minutes: nil,
|
22
|
+
attributes: {}
|
23
|
+
)
|
24
|
+
request = {
|
25
|
+
user_id: user_id
|
26
|
+
}
|
27
|
+
|
28
|
+
request[:expiration_minutes] = expiration_minutes unless expiration_minutes.nil?
|
29
|
+
request[:attributes] = attributes if attributes != {}
|
30
|
+
|
31
|
+
post_request(PATH.to_s, request)
|
32
|
+
end
|
33
|
+
|
19
34
|
def authenticate(
|
20
35
|
token:,
|
21
36
|
attributes: {},
|
data/lib/stytch/oauth.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'request_helper'
|
4
|
+
|
5
|
+
module Stytch
|
6
|
+
class OAuth
|
7
|
+
include Stytch::RequestHelper
|
8
|
+
|
9
|
+
PATH = '/v1/oauth'
|
10
|
+
|
11
|
+
def initialize(connection)
|
12
|
+
@connection = connection
|
13
|
+
end
|
14
|
+
|
15
|
+
def authenticate(
|
16
|
+
token:,
|
17
|
+
session_management_type: nil,
|
18
|
+
session_token: nil,
|
19
|
+
session_duration_minutes: nil
|
20
|
+
)
|
21
|
+
request = {
|
22
|
+
token: token
|
23
|
+
}
|
24
|
+
request[:session_management_type] = session_management_type unless session_management_type.nil?
|
25
|
+
request[:session_token] = session_token unless session_token.nil?
|
26
|
+
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
27
|
+
|
28
|
+
post_request("#{PATH}/authenticate", request)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/stytch/otps.rb
CHANGED
@@ -6,7 +6,7 @@ module Stytch
|
|
6
6
|
class OTPs
|
7
7
|
include Stytch::RequestHelper
|
8
8
|
|
9
|
-
attr_reader :sms, :whatsapp
|
9
|
+
attr_reader :sms, :whatsapp, :email
|
10
10
|
|
11
11
|
PATH = '/v1/otps'
|
12
12
|
|
@@ -15,6 +15,7 @@ module Stytch
|
|
15
15
|
|
16
16
|
@sms = Stytch::OTPs::SMS.new(@connection)
|
17
17
|
@whatsapp = Stytch::OTPs::WhatsApp.new(@connection)
|
18
|
+
@email = Stytch::OTPs::Email.new(@connection)
|
18
19
|
end
|
19
20
|
|
20
21
|
def authenticate(
|
@@ -121,5 +122,47 @@ module Stytch
|
|
121
122
|
post_request("#{PATH}/login_or_create", request)
|
122
123
|
end
|
123
124
|
end
|
125
|
+
|
126
|
+
class Email
|
127
|
+
include Stytch::RequestHelper
|
128
|
+
|
129
|
+
PATH = "#{Stytch::OTPs::PATH}/email"
|
130
|
+
|
131
|
+
def initialize(connection)
|
132
|
+
@connection = connection
|
133
|
+
end
|
134
|
+
|
135
|
+
def send(
|
136
|
+
email:,
|
137
|
+
expiration_minutes: nil,
|
138
|
+
attributes: {}
|
139
|
+
)
|
140
|
+
request = {
|
141
|
+
email: email,
|
142
|
+
expiration_minutes: expiration_minutes
|
143
|
+
}
|
144
|
+
|
145
|
+
request[:attributes] = attributes if attributes != {}
|
146
|
+
|
147
|
+
post_request("#{PATH}/send", request)
|
148
|
+
end
|
149
|
+
|
150
|
+
def login_or_create(
|
151
|
+
email:,
|
152
|
+
expiration_minutes: nil,
|
153
|
+
attributes: {},
|
154
|
+
create_user_as_pending: false
|
155
|
+
)
|
156
|
+
request = {
|
157
|
+
email: email,
|
158
|
+
expiration_minutes: expiration_minutes,
|
159
|
+
create_user_as_pending: create_user_as_pending
|
160
|
+
}
|
161
|
+
|
162
|
+
request[:attributes] = attributes if attributes != {}
|
163
|
+
|
164
|
+
post_request("#{PATH}/login_or_create", request)
|
165
|
+
end
|
166
|
+
end
|
124
167
|
end
|
125
168
|
end
|
data/lib/stytch/sessions.rb
CHANGED
@@ -14,7 +14,7 @@ module Stytch
|
|
14
14
|
|
15
15
|
def get(user_id:)
|
16
16
|
query_params = {
|
17
|
-
|
17
|
+
user_id: user_id
|
18
18
|
}
|
19
19
|
|
20
20
|
request = request_with_query_params(PATH, query_params)
|
@@ -23,11 +23,11 @@ module Stytch
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def authenticate(
|
26
|
-
|
27
|
-
|
26
|
+
session_token:,
|
27
|
+
session_duration_minutes: nil
|
28
28
|
)
|
29
29
|
request = {
|
30
|
-
|
30
|
+
session_token: session_token
|
31
31
|
}
|
32
32
|
|
33
33
|
request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
|
@@ -36,8 +36,8 @@ module Stytch
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def revoke(
|
39
|
-
|
40
|
-
|
39
|
+
session_id: nil,
|
40
|
+
session_token: nil
|
41
41
|
)
|
42
42
|
request = {}
|
43
43
|
|
data/lib/stytch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stytch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- stytch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '2.0'
|
53
|
-
description:
|
53
|
+
description:
|
54
54
|
email:
|
55
55
|
- support@stytch.com
|
56
56
|
executables: []
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/stytch/client.rb
|
74
74
|
- lib/stytch/magic_links.rb
|
75
75
|
- lib/stytch/middleware.rb
|
76
|
+
- lib/stytch/oauth.rb
|
76
77
|
- lib/stytch/otps.rb
|
77
78
|
- lib/stytch/request_helper.rb
|
78
79
|
- lib/stytch/sessions.rb
|
@@ -85,7 +86,7 @@ licenses:
|
|
85
86
|
metadata:
|
86
87
|
homepage_uri: https://stytch.com
|
87
88
|
source_code_uri: https://github.com/stytchauth/stytch-ruby
|
88
|
-
post_install_message:
|
89
|
+
post_install_message:
|
89
90
|
rdoc_options: []
|
90
91
|
require_paths:
|
91
92
|
- lib
|
@@ -100,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
101
|
- !ruby/object:Gem::Version
|
101
102
|
version: '0'
|
102
103
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
104
|
-
signing_key:
|
104
|
+
rubygems_version: 3.0.3
|
105
|
+
signing_key:
|
105
106
|
specification_version: 4
|
106
107
|
summary: Stytch Ruby Gem
|
107
108
|
test_files: []
|