stytch 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5b6f3a220db5b04687a900ac17b0e8f538fb5880a71c390c9ffcef876fd5425
4
- data.tar.gz: ed5964bfc4b355a239cc8b5214ea6a2e7dd89a980fa923fd62cf9665176bf241
3
+ metadata.gz: 11c676836879020ec0d87cbe9d7017ccfc777f27d4e73db695cd991a416589b6
4
+ data.tar.gz: e58761d69d0cb5f4c1a9f72d09bd1017a9dab222da4924570ebba7c26a4e1bb4
5
5
  SHA512:
6
- metadata.gz: ea9dca6572aaed91548265c03bf051237965cc57d7b82d4d0e3df4f4d1a5e9b1232501c983076057d2c38c168c0210f8051b8874e66155734d62772619c7b343
7
- data.tar.gz: 201db2bb213b9c97614c3392beca947df83ed24c57a229e7dadc635a293d4fd6ebc9c424f5d6156a794e53fa9185d23f7447f9f9c11a9896e5567d0653edc758
6
+ metadata.gz: e0d885c1e262b76649e01ffcbe64a6a31a78e183ff35d0128da9983e51dcc70e7bc7b7c9608983f8a516ac93a47cc9c51424c72aa73d7e1fc81218f83c31cfda
7
+ data.tar.gz: a88377ca19b824229fa2d0c3e2958c92f14e3926371f852ea39e12bbe3e10b5d3a70f859971196c48d425a0129ce5f0b79b527e96f1af09fc7f8c8edb124191f
@@ -380,7 +380,7 @@ module StytchB2B
380
380
  )
381
381
  end
382
382
 
383
- decoded_jwt = authenticate_jwt_local(session_jwt: session_jwt, authorization_check: authorization_check)
383
+ decoded_jwt = authenticate_jwt_local(session_jwt, max_token_age_seconds: max_token_age_seconds, authorization_check: authorization_check)
384
384
  return decoded_jwt unless decoded_jwt.nil?
385
385
 
386
386
  authenticate(
@@ -215,7 +215,7 @@ module Stytch
215
215
  )
216
216
  end
217
217
 
218
- session = authenticate_jwt_local(session_jwt)
218
+ session = authenticate_jwt_local(session_jwt, max_token_age_seconds: max_token_age_seconds)
219
219
  if !session.nil?
220
220
  { 'session' => session }
221
221
  else
@@ -237,6 +237,7 @@ module Stytch
237
237
  # Parse a JWT and verify the signature locally (without calling /authenticate in the API)
238
238
  # Uses the cached value to get the JWK but if it is unavailable, it calls the get_jwks()
239
239
  # function to get the JWK
240
+ # This method never authenticates a JWT directly with the API
240
241
  # If max_token_age_seconds is not supplied 300 seconds will be used as the default.
241
242
  def authenticate_jwt_local(session_jwt, max_token_age_seconds: nil)
242
243
  max_token_age_seconds = 300 if max_token_age_seconds.nil?
@@ -245,6 +246,7 @@ module Stytch
245
246
  begin
246
247
  decoded_token = JWT.decode session_jwt, nil, true,
247
248
  { jwks: @jwks_loader, iss: issuer, verify_iss: true, aud: @project_id, verify_aud: true, algorithms: ['RS256'] }
249
+
248
250
  session = decoded_token[0]
249
251
  iat_time = Time.at(session['iat']).to_datetime
250
252
  return nil unless iat_time + max_token_age_seconds >= Time.now
@@ -272,15 +274,17 @@ module Stytch
272
274
  reserved_claims = ['aud', 'exp', 'iat', 'iss', 'jti', 'nbf', 'sub', stytch_claim]
273
275
  custom_claims = jwt.reject { |key, _| reserved_claims.include?(key) }
274
276
  {
275
- 'session_id' => jwt[stytch_claim]['id'],
276
- 'user_id' => jwt['sub'],
277
- 'started_at' => jwt[stytch_claim]['started_at'],
278
- 'last_accessed_at' => jwt[stytch_claim]['last_accessed_at'],
279
- # For JWTs that include it, prefer the inner expires_at claim.
280
- 'expires_at' => expires_at,
281
- 'attributes' => jwt[stytch_claim]['attributes'],
282
- 'authentication_factors' => jwt[stytch_claim]['authentication_factors'],
283
- 'custom_claims' => custom_claims
277
+ 'session' => {
278
+ 'session_id' => jwt[stytch_claim]['id'],
279
+ 'user_id' => jwt['sub'],
280
+ 'started_at' => jwt[stytch_claim]['started_at'],
281
+ 'last_accessed_at' => jwt[stytch_claim]['last_accessed_at'],
282
+ # For JWTs that include it, prefer the inner expires_at claim.
283
+ 'expires_at' => expires_at,
284
+ 'attributes' => jwt[stytch_claim]['attributes'],
285
+ 'authentication_factors' => jwt[stytch_claim]['authentication_factors'],
286
+ 'custom_claims' => custom_claims
287
+ }
284
288
  }
285
289
  end
286
290
  # ENDMANUAL(Sessions::authenticate_jwt)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stytch
4
- VERSION = '7.0.1'
4
+ VERSION = '7.0.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stytch
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.1
4
+ version: 7.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - stytch