Class: ShopifyClient::Cookieless::DecodeSessionToken

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify-client/cookieless/decode_session_token.rb

Constant Summary collapse

Error =
Class.new(Error)

Instance Method Summary collapse

Instance Method Details

#call(token) ⇒ String

Returns the *.myshopify.com domain of the authenticated shop.

Parameters:

  • token (String)

Returns:

  • (String)

    the *.myshopify.com domain of the authenticated shop

Raises:



15
16
17
18
19
20
21
22
23
# File 'lib/shopify-client/cookieless/decode_session_token.rb', line 15

def call(token)
  payload, _ = JWT.decode(token, ShopifyClient.config.shared_secret, true, algorithm: 'HS256')

  raise Error unless valid?(payload)

  parse_myshopify_domain(payload)
rescue JWT::DecodeError
  raise Error
end