Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/shopify_api/auth/jwt_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ def initialize(token)
decode_token(token, T.must(Context.old_api_secret_key))
end

@iss = T.let(payload_hash["iss"], String)
@iss = T.let(payload_hash["iss"], T.nilable(String))
@dest = T.let(payload_hash["dest"], String)
@aud = T.let(payload_hash["aud"], String)
@sub = T.let(payload_hash["sub"], String)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing I found that the sub claim could also be nil, if the customer is not logged in.

@exp = T.let(payload_hash["exp"], Integer)
@nbf = T.let(payload_hash["nbf"], Integer)
@iat = T.let(payload_hash["iat"], Integer)
@jti = T.let(payload_hash["jti"], String)
@sid = T.let(payload_hash["sid"], String)
@sid = T.let(payload_hash["sid"], T.nilable(String))

raise ShopifyAPI::Errors::InvalidJwtTokenError,
"Session token had invalid API key" unless @aud == Context.api_key
Expand All @@ -49,7 +49,7 @@ def shop

sig { returns(Integer) }
def shopify_user_id
@sub.to_i
@sub.tr("^0-9", "").to_i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you are extracting the ID?

end

# TODO: Remove before releasing v11
Expand Down
Loading