Skip to content

Commit

Permalink
use JWT_LEEWAY constant for JWT leeway param
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-carvalho committed Apr 16, 2024
1 parent 9c481e5 commit 0eb2306
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/shopify_api/auth/jwt_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module Auth
class JwtPayload
extend T::Sig

JWT_EXPIRATION_LEEWAY = 10
JWT_LEEWAY = 10
JWT_EXPIRATION_LEEWAY = JWT_LEEWAY

sig { returns(String) }
attr_reader :iss, :dest, :aud, :sub, :jti, :sid
Expand Down Expand Up @@ -73,7 +74,7 @@ def ==(other)

sig { params(token: String, api_secret_key: String).returns(T::Hash[String, T.untyped]) }
def decode_token(token, api_secret_key)
JWT.decode(token, api_secret_key, true, leeway: JWT_EXPIRATION_LEEWAY, algorithm: "HS256")[0]
JWT.decode(token, api_secret_key, true, leeway: JWT_LEEWAY, algorithm: "HS256")[0]
rescue JWT::DecodeError => err
raise ShopifyAPI::Errors::InvalidJwtTokenError, "Error decoding session token: #{err.message}"
end
Expand Down

0 comments on commit 0eb2306

Please sign in to comment.