Class: ShopifyApp::JWT

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_app/session/jwt.rb

Constant Summary collapse

WARN_EXCEPTIONS =
[
  ::JWT::DecodeError,
  ::JWT::ExpiredSignature,
  ::JWT::ImmatureSignature,
  ::JWT::VerificationError,
  ::ShopifyApp::InvalidAudienceError,
  ::ShopifyApp::InvalidDestinationError,
  ::ShopifyApp::MismatchedHostsError,
]

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ JWT

Returns a new instance of JWT.



15
16
17
18
19
# File 'lib/shopify_app/session/jwt.rb', line 15

def initialize(token)
  warn_deprecation
  @token = token
  set_payload
end

Instance Method Details

#expire_atObject



29
30
31
# File 'lib/shopify_app/session/jwt.rb', line 29

def expire_at
  @payload["exp"].to_i if @payload && @payload["exp"]
end

#shopify_domainObject



21
22
23
# File 'lib/shopify_app/session/jwt.rb', line 21

def shopify_domain
  @payload && ShopifyApp::Utils.sanitize_shop_domain(@payload["dest"])
end

#shopify_user_idObject



25
26
27
# File 'lib/shopify_app/session/jwt.rb', line 25

def shopify_user_id
  @payload["sub"].to_i if @payload && @payload["sub"]
end