stytch 3.2.0 → 3.4.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: dc4550a480f46589fd16edc9445850c3b291a1972a5715a00dccab129df2595f
4
- data.tar.gz: b18030ff8be340da133c636ff137fb5b60c727d09b5132a3e76148144d6aadee
3
+ metadata.gz: c4e0b5abf60607192bc55481b147a61900f775de4446bb484469a7e9f46ad9eb
4
+ data.tar.gz: 997294b0104b0fc95002e2e05f373f69b9fb98b91f1767844eb4bdb8792a527d
5
5
  SHA512:
6
- metadata.gz: bde5b7238e9e3f3e83a341e619ad0fe0b02f5902a7740f42b0fea42a636baaadd559c931b28c9df59d534ee89de0df62e48df44e6627ef4a9a280a16b073dea7
7
- data.tar.gz: f713601765602a2376a32cb13a63058e337a0648aa9c28f8d0591d5062e7871a812832620c0607524ae34fc56d6833df75420397ffd66a6b99241cee8b9b9bc5
6
+ metadata.gz: 9697278039c4a8ab9274f20a89b12f05d07afb7902621b523bbeec20865a72d513aeb3c3aeb360be59e9aec949bdca2d36e2dd6024bc16886db8296759be69f9
7
+ data.tar.gz: 8ebdc8a2af442ec66779ed9014f9605f0e40b04ef292f8933379010b3bb3bffad3ab32b5cc1e70e09c695b8e82b45cb583ab3282fb86d01d8640177d7b82e1f4
data/lib/stytch/client.rb CHANGED
@@ -40,8 +40,11 @@ module Stytch
40
40
  'https://api.stytch.com'
41
41
  when :test
42
42
  'https://test.stytch.com'
43
+ when /\Ahttps?:\/\//
44
+ # If this is a string that looks like a URL, assume it's an internal development URL.
45
+ env
43
46
  else
44
- raise ArgumentError, "Invalid value for env (#{@env}): should be live or test"
47
+ raise ArgumentError, "Invalid value for env (#{env}): should be :live or :test"
45
48
  end
46
49
  end
47
50
 
@@ -37,7 +37,8 @@ module Stytch
37
37
  options: {},
38
38
  session_token: nil,
39
39
  session_jwt: nil,
40
- session_duration_minutes: nil
40
+ session_duration_minutes: nil,
41
+ code_verifier: nil
41
42
  )
42
43
  request = {
43
44
  token: token
@@ -48,6 +49,7 @@ module Stytch
48
49
  request[:session_token] = session_token unless session_token.nil?
49
50
  request[:session_jwt] = session_jwt unless session_jwt.nil?
50
51
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
52
+ request[:code_verifier] = code_verifier unless code_verifier.nil?
51
53
 
52
54
  post_request("#{PATH}/authenticate", request)
53
55
  end
@@ -67,7 +69,8 @@ module Stytch
67
69
  signup_magic_link_url: nil,
68
70
  login_expiration_minutes: nil,
69
71
  signup_expiration_minutes: nil,
70
- attributes: {}
72
+ attributes: {},
73
+ code_challenge: nil
71
74
  )
72
75
  request = {
73
76
  email: email
@@ -78,6 +81,7 @@ module Stytch
78
81
  request[:login_expiration_minutes] = login_expiration_minutes unless login_expiration_minutes.nil?
79
82
  request[:signup_expiration_minutes] = signup_expiration_minutes unless signup_expiration_minutes.nil?
80
83
  request[:attributes] = attributes if attributes != {}
84
+ request[:code_challenge] = code_challenge unless code_challenge.nil?
81
85
 
82
86
  post_request("#{PATH}/send", request)
83
87
  end
@@ -89,7 +93,8 @@ module Stytch
89
93
  login_expiration_minutes: nil,
90
94
  signup_expiration_minutes: nil,
91
95
  attributes: {},
92
- create_user_as_pending: false
96
+ create_user_as_pending: false,
97
+ code_challenge: nil
93
98
  )
94
99
  request = {
95
100
  email: email,
@@ -101,6 +106,7 @@ module Stytch
101
106
  request[:login_expiration_minutes] = login_expiration_minutes unless login_expiration_minutes.nil?
102
107
  request[:signup_expiration_minutes] = signup_expiration_minutes unless signup_expiration_minutes.nil?
103
108
  request[:attributes] = attributes if attributes != {}
109
+ request[:code_challenge] = code_challenge unless code_challenge.nil?
104
110
 
105
111
  post_request("#{PATH}/login_or_create", request)
106
112
  end
data/lib/stytch/oauth.rb CHANGED
@@ -16,7 +16,8 @@ module Stytch
16
16
  token:,
17
17
  session_token: nil,
18
18
  session_jwt: nil,
19
- session_duration_minutes: nil
19
+ session_duration_minutes: nil,
20
+ code_verifier: nil
20
21
  )
21
22
  request = {
22
23
  token: token
@@ -24,6 +25,7 @@ module Stytch
24
25
  request[:session_token] = session_token unless session_token.nil?
25
26
  request[:session_jwt] = session_jwt unless session_jwt.nil?
26
27
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
28
+ request[:code_verifier] = code_verifier unless code_verifier.nil?
27
29
 
28
30
  post_request("#{PATH}/authenticate", request)
29
31
  end
@@ -119,12 +119,14 @@ module Stytch
119
119
 
120
120
  def marshal_jwt_into_session(jwt)
121
121
  stytch_claim = "https://stytch.com/session"
122
+ expires_at = jwt[stytch_claim]["expires_at"] || Time.at(jwt["exp"]).to_datetime.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
122
123
  return {
123
124
  "session_id" => jwt[stytch_claim]["id"],
124
125
  "user_id" => jwt["sub"],
125
126
  "started_at" => jwt[stytch_claim]["started_at"],
126
127
  "last_accessed_at" => jwt[stytch_claim]["last_accessed_at"],
127
- "expires_at" => Time.at(jwt["exp"]).to_datetime.iso8601,
128
+ # For JWTs that include it, prefer the inner expires_at claim.
129
+ "expires_at" => expires_at,
128
130
  "attributes" => jwt[stytch_claim]["attributes"],
129
131
  "authentication_factors" => jwt[stytch_claim]["authentication_factors"],
130
132
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '3.2.0'
4
+ VERSION = '3.4.0'
5
5
  end
data/stytch.gemspec CHANGED
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'faraday', '>= 0.17.0', '< 2.0'
29
29
  spec.add_dependency 'faraday_middleware', '>= 0.14.0', '< 2.0'
30
- spec.add_dependency 'jwt', '>= 2.3.0'
31
30
  spec.add_dependency 'json-jwt', '>=1.13.0'
31
+ spec.add_dependency 'jwt', '>= 2.3.0'
32
+
33
+ spec.add_development_dependency 'test-unit', '>=3.5.3'
32
34
  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: 3.2.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-03 00:00:00.000000000 Z
11
+ date: 2022-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -50,6 +50,20 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '2.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: json-jwt
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.13.0
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.13.0
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: jwt
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -65,19 +79,19 @@ dependencies:
65
79
  - !ruby/object:Gem::Version
66
80
  version: 2.3.0
67
81
  - !ruby/object:Gem::Dependency
68
- name: json-jwt
82
+ name: test-unit
69
83
  requirement: !ruby/object:Gem::Requirement
70
84
  requirements:
71
85
  - - ">="
72
86
  - !ruby/object:Gem::Version
73
- version: 1.13.0
74
- type: :runtime
87
+ version: 3.5.3
88
+ type: :development
75
89
  prerelease: false
76
90
  version_requirements: !ruby/object:Gem::Requirement
77
91
  requirements:
78
92
  - - ">="
79
93
  - !ruby/object:Gem::Version
80
- version: 1.13.0
94
+ version: 3.5.3
81
95
  description:
82
96
  email:
83
97
  - support@stytch.com