stytch 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f10d2ac983b6812590a7d1d01fa649ea9a84bcdbff28cdc34b47dc6e075ebcaf
4
- data.tar.gz: '08dbadda02435370eceb0d66533a11631c05ab615e646a0d6fa77d58fb579bdb'
3
+ metadata.gz: e40426c4e4622ec2de65ac043377a0ce080e0fad6b93fb19f848676b32bae3d0
4
+ data.tar.gz: dc82a3b5b69da73bf40d2ff29d62c3afad63baa565fcf4ba59301b205e8dc6d8
5
5
  SHA512:
6
- metadata.gz: 5d084490ad18ef02b1f9215356be00e987379b773652a42c22e95058ff38631e8d0d020a93361f1b70c56041451d25e71daf3e6b896e27022185d46045b4fdd0
7
- data.tar.gz: e62da9085f0263fe06c5134747f2b5a5992d6163333a90197e1ab0e1aa2379e7a8d73124fe2d93c443ca1431d36447b64735e2086edc1e73eebfd359b33e8d25
6
+ metadata.gz: 80b2cc7201c3f24d8486d4cbe76242b7d28f37c07a3128124e0420fd161bd62b802c875d22a1056a2743eac68c30f264a2bde070fe34876f4d722067c71705a2
7
+ data.tar.gz: d5ce170c73e22b94853395012c2245824059a7eeaf833c8dfb815e4319ae093c42383889320947921a2438541ee70900848354f43ffc9c9afe6e456116996d0f
data/lib/stytch/client.rb CHANGED
@@ -3,12 +3,13 @@
3
3
  require_relative 'users'
4
4
  require_relative 'magic_links'
5
5
  require_relative 'otps'
6
+ require_relative 'sessions'
6
7
 
7
8
  module Stytch
8
9
  class Client
9
10
  ENVIRONMENTS = %i[live test].freeze
10
11
 
11
- attr_reader :users, :magic_links, :otps
12
+ attr_reader :users, :magic_links, :otps, :sessions
12
13
 
13
14
  def initialize(env:, project_id:, secret:, &block)
14
15
  @api_host = api_host(env)
@@ -20,6 +21,7 @@ module Stytch
20
21
  @users = Stytch::Users.new(@connection)
21
22
  @magic_links = Stytch::MagicLinks.new(@connection)
22
23
  @otps = Stytch::OTPs.new(@connection)
24
+ @sessions = Stytch::Sessions.new(@connection)
23
25
  end
24
26
 
25
27
  private
@@ -19,7 +19,9 @@ module Stytch
19
19
  def authenticate(
20
20
  token:,
21
21
  attributes: {},
22
- options: {}
22
+ options: {},
23
+ session_token: nil,
24
+ session_duration_minutes: nil
23
25
  )
24
26
  request = {
25
27
  token: token
@@ -27,6 +29,8 @@ module Stytch
27
29
 
28
30
  request[:attributes] = attributes if attributes != {}
29
31
  request[:options] = options if options != {}
32
+ request[:session_token] = session_token unless session_token.nil?
33
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
30
34
 
31
35
  post_request("#{PATH}/authenticate", request)
32
36
  end
data/lib/stytch/otps.rb CHANGED
@@ -21,7 +21,9 @@ module Stytch
21
21
  method_id:,
22
22
  code:,
23
23
  attributes: {},
24
- options: {}
24
+ options: {},
25
+ session_token: nil,
26
+ session_duration_minutes: nil
25
27
  )
26
28
  request = {
27
29
  method_id: method_id,
@@ -30,6 +32,8 @@ module Stytch
30
32
 
31
33
  request[:attributes] = attributes if attributes != {}
32
34
  request[:options] = options if options != {}
35
+ request[:session_token] = session_token unless session_token.nil?
36
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
33
37
 
34
38
  post_request("#{PATH}/authenticate", request)
35
39
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'request_helper'
4
+
5
+ module Stytch
6
+ class Sessions
7
+ include Stytch::RequestHelper
8
+
9
+ PATH = '/v1/sessions'
10
+
11
+ def initialize(connection)
12
+ @connection = connection
13
+ end
14
+
15
+ def get(user_id:)
16
+ query_params = {
17
+ user_id: user_id
18
+ }
19
+
20
+ request = request_with_query_params(PATH, query_params)
21
+
22
+ get_request(request)
23
+ end
24
+
25
+ def authenticate(
26
+ session_token:,
27
+ session_duration_minutes: nil
28
+ )
29
+ request = {
30
+ session_token: session_token
31
+ }
32
+
33
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
34
+
35
+ post_request("#{PATH}/authenticate", request)
36
+ end
37
+
38
+ def revoke(
39
+ session_id: nil,
40
+ session_token: nil
41
+ )
42
+ request = {}
43
+
44
+ request[:session_id] = session_id unless session_id.nil?
45
+ request[:session_token] = session_token unless session_token.nil?
46
+
47
+ post_request("#{PATH}/revoke", request)
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '2.1.1'
4
+ VERSION = '2.2.0'
5
5
  end
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.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-13 00:00:00.000000000 Z
11
+ date: 2021-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -75,6 +75,7 @@ files:
75
75
  - lib/stytch/middleware.rb
76
76
  - lib/stytch/otps.rb
77
77
  - lib/stytch/request_helper.rb
78
+ - lib/stytch/sessions.rb
78
79
  - lib/stytch/users.rb
79
80
  - lib/stytch/version.rb
80
81
  - stytch.gemspec