stytch 3.8.0 → 3.11.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: 95b360d5a8279e14e7f5f296a1f87cf8a228f71199b8f7ad819c5738ffabed5c
4
- data.tar.gz: d039db12c094d0108053986133159641fb70f6ea78774fc8fb6c3d4bbd9cba08
3
+ metadata.gz: b50d6df846a8cd5ac93f94ec1744ff5f7b17d96bdba656d9fb0bad658aa2cab2
4
+ data.tar.gz: 5dc77db5fdbdc0a145bb6767cefbe50ad0f6afdab18cea3c2bd494ad18e00e6c
5
5
  SHA512:
6
- metadata.gz: 49525be08d53de93aadce97f254d0e3526e9334119b11508b89a8234133ef23a27a880666b176b03ef57fb938c17c90adeb9804ce159e9832f60a7a7f9821972
7
- data.tar.gz: 4212ed7c21195091055bbfe24abe613c1f670216808fd51e15c39b565ab49b2252f941398fc82fd3480d2a5af8999056051a0696f7edd157390cb11bcbe0a16c
6
+ metadata.gz: 1b8bdd22e64273984515964773b1c0dd7cf01b1b47b0114ee78d56583ae680caa8c40012ae85b72301cce4a6ee85645d28a4232e70a93c2aef5098c27aa5cf60
7
+ data.tar.gz: 3bf134bb649f5c3e88ebd5dd73fef835a0b3c4dde93da28bbec74fa4ca91f5f074cc6c32aae8abc11afb97e22d3eb9cd7016b57d0baa1d48f2340b7fc52e118f
@@ -6,7 +6,7 @@ module Stytch
6
6
  class Passwords
7
7
  include Stytch::RequestHelper
8
8
 
9
- attr_reader :email
9
+ attr_reader :email, :existing_password, :session
10
10
 
11
11
  PATH = '/v1/passwords'
12
12
 
@@ -14,6 +14,8 @@ module Stytch
14
14
  @connection = connection
15
15
 
16
16
  @email = Stytch::Passwords::Email.new(@connection)
17
+ @existing_password = Stytch::Passwords::ExistingPassword.new(@connection)
18
+ @session = Stytch::Passwords::Session.new(@connection)
17
19
  end
18
20
 
19
21
  def create(
@@ -72,7 +74,9 @@ module Stytch
72
74
  hash:,
73
75
  hash_type:,
74
76
  md_5_config: {},
75
- argon_2_config: {}
77
+ argon_2_config: {},
78
+ sha_1_config: {},
79
+ scrypt_config: {}
76
80
  )
77
81
  request = {
78
82
  email: email,
@@ -82,6 +86,8 @@ module Stytch
82
86
 
83
87
  request[:md_5_config] = md_5_config unless md_5_config != {}
84
88
  request[:argon_2_config] = argon_2_config unless argon_2_config != {}
89
+ request[:sha_1_config] = sha_1_config unless sha_1_config != {}
90
+ request[:scrypt_config] = scrypt_config unless scrypt_config != {}
85
91
 
86
92
  post_request("#{PATH}/migrate", request)
87
93
  end
@@ -146,5 +152,61 @@ module Stytch
146
152
  post_request("#{PATH}/reset", request)
147
153
  end
148
154
  end
155
+
156
+ class ExistingPassword
157
+ include Stytch::RequestHelper
158
+
159
+ PATH = "#{Stytch::Passwords::PATH}/existing_password"
160
+
161
+ def initialize(connection)
162
+ @connection = connection
163
+ end
164
+
165
+ def reset(
166
+ email:,
167
+ existing_password:,
168
+ new_password:,
169
+ session_token: nil,
170
+ session_jwt: nil,
171
+ session_duration_minutes: nil,
172
+ session_custom_claims: nil
173
+ )
174
+ request = {
175
+ email: email,
176
+ existing_password: existing_password,
177
+ new_password: new_password
178
+ }
179
+
180
+ request[:session_token] = session_token unless session_token.nil?
181
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
182
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
183
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
184
+
185
+ post_request("#{PATH}/reset", request)
186
+ end
187
+ end
188
+
189
+ class Session
190
+ include Stytch::RequestHelper
191
+
192
+ PATH = "#{Stytch::Passwords::PATH}/session"
193
+
194
+ def initialize(connection)
195
+ @connection = connection
196
+ end
197
+
198
+ def reset(
199
+ password:,
200
+ session_token: nil,
201
+ session_jwt: nil
202
+ )
203
+ request = { password: password }
204
+
205
+ request[:session_token] = session_token unless session_token.nil?
206
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
207
+
208
+ post_request("#{PATH}/reset", request)
209
+ end
210
+ end
149
211
  end
150
212
  end
@@ -15,8 +15,17 @@ module Stytch
15
15
  def initialize(connection, project_id)
16
16
  @connection = connection
17
17
  @project_id = project_id
18
- @jwks_loader = ->(options) do
19
- options[:invalidate] ? jwks(project_id: @project_id) : {}
18
+ @cache_last_update = 0
19
+ @jwks_loader = lambda do |options|
20
+ @cached_keys = nil if options[:invalidate] && @cache_last_update < Time.now.to_i - 300
21
+ @cached_keys ||= begin
22
+ @cache_last_update = Time.now.to_i
23
+ keys = []
24
+ jwks(project_id: @project_id)['keys'].each do |r|
25
+ keys << r
26
+ end
27
+ { keys: keys }
28
+ end
20
29
  end
21
30
  end
22
31
 
data/lib/stytch/users.rb CHANGED
@@ -127,6 +127,12 @@ module Stytch
127
127
  delete_request("#{PATH}/crypto_wallets/#{crypto_wallet_id}")
128
128
  end
129
129
 
130
+ def delete_password(
131
+ password_id:
132
+ )
133
+ delete_request("#{PATH}/passwords/#{password_id}")
134
+ end
135
+
130
136
  private
131
137
 
132
138
  def format_emails(emails)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '3.8.0'
4
+ VERSION = '3.11.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: 3.8.0
4
+ version: 3.11.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: 2022-07-29 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -92,7 +92,7 @@ dependencies:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: 3.5.3
95
- description:
95
+ description:
96
96
  email:
97
97
  - support@stytch.com
98
98
  executables: []
@@ -133,7 +133,7 @@ licenses:
133
133
  metadata:
134
134
  homepage_uri: https://stytch.com
135
135
  source_code_uri: https://github.com/stytchauth/stytch-ruby
136
- post_install_message:
136
+ post_install_message:
137
137
  rdoc_options: []
138
138
  require_paths:
139
139
  - lib
@@ -148,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.1.4
152
- signing_key:
151
+ rubygems_version: 3.0.3.1
152
+ signing_key:
153
153
  specification_version: 4
154
154
  summary: Stytch Ruby Gem
155
155
  test_files: []