{"action":"created","comment":{"url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/comments/262484412","pull_request_review_id":210663324,"id":262484412,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI2MjQ4NDQxMg==","diff_hunk":"@@ -43,48 +44,63 @@ export function isPayToUser(jwt: ExternalOrderJWT): jwt is ExternalPayToUserOrde\n \treturn jwt.sub === \"pay_to_user\";\n }\n \n-export async function validateExternalOrderJWT(jwt: string, appUserId: string): Promise<ExternalOrderJWT> {\n+export async function validateExternalOrderJWT(jwt: string, user: User): Promise<ExternalOrderJWT> {\n \tconst decoded = await verifyJWT<Partial<PayToUserPayload>, \"spend\" | \"earn\" | \"pay_to_user\">(jwt);\n \n \tif (decoded.payload.sub !== \"earn\" && decoded.payload.sub !== \"spend\" && decoded.payload.sub !== \"pay_to_user\") {\n \t\tthrow InvalidExternalOrderJwt(`Subject can be either \"earn\", \"spend' or \"pay_to_user\"`);\n \t}\n \n \t// offer field has to exist in earn/spend/pay_to_user JWTs\n-\tif (!decoded.payload.offer) { throw MissingFieldJWT(\"offer\"); }\n+\tif (!decoded.payload.offer) {\n+\t\tthrow MissingFieldJWT(\"offer\");\n+\t}\n \n \tif (typeof decoded.payload.offer.amount !== \"number\") {\n \t\tthrow InvalidExternalOrderJwt(\"amount field must be a number\");\n \t}\n \n+\tif (decoded.payload.iss !== user.appId) {\n+\t\tthrow InvalidExternalOrderJwt(\"issuer must match appId\");\n+\t}\n+\n \tswitch (decoded.payload.sub) {\n \t\tcase \"spend\":\n-\t\t\tif (!decoded.payload.sender) { throw MissingFieldJWT(\"sender\"); }\n+\t\t\tif (!decoded.payload.sender) {\n+\t\t\t\tthrow MissingFieldJWT(\"sender\");\n+\t\t\t}\n \t\t\tbreak;\n \n \t\tcase \"earn\":\n-\t\t\tif (!decoded.payload.recipient) { throw MissingFieldJWT(\"recipient\"); }\n+\t\t\tif (!decoded.payload.recipient) {\n+\t\t\t\tthrow MissingFieldJWT(\"recipient\");\n+\t\t\t}\n \t\t\tbreak;\n \n \t\tcase \"pay_to_user\":\n-\t\t\tif (!decoded.payload.sender) { throw MissingFieldJWT(\"sender\"); }\n-\t\t\tif (!decoded.payload.recipient) { throw MissingFieldJWT(\"recipient\"); }\n+\t\t\tif (!decoded.payload.sender) {\n+\t\t\t\tthrow MissingFieldJWT(\"sender\");\n+\t\t\t}\n+\t\t\tif (!decoded.payload.recipient) {\n+\t\t\t\tthrow MissingFieldJWT(\"recipient\");\n+\t\t\t}\n \t\t\tbreak;\n \n-\t\tdefault: break;\n+\t\tdefault:\n+\t\t\tbreak;","path":"scripts/src/public/services/native_offers.v1.ts","position":62,"original_position":62,"commit_id":"8f33a4c77f8b5a91e62e1eb806a22661b29f31a8","original_commit_id":"8f33a4c77f8b5a91e62e1eb806a22661b29f31a8","user":{"login":"liorama","id":537868,"node_id":"MDQ6VXNlcjUzNzg2OA==","avatar_url":"https://avatars0.githubusercontent.com/u/537868?v=4","gravatar_id":"","url":"https://api.github.com/users/liorama","html_url":"https://github.com/liorama","followers_url":"https://api.github.com/users/liorama/followers","following_url":"https://api.github.com/users/liorama/following{/other_user}","gists_url":"https://api.github.com/users/liorama/gists{/gist_id}","starred_url":"https://api.github.com/users/liorama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liorama/subscriptions","organizations_url":"https://api.github.com/users/liorama/orgs","repos_url":"https://api.github.com/users/liorama/repos","events_url":"https://api.github.com/users/liorama/events{/privacy}","received_events_url":"https://api.github.com/users/liorama/received_events","type":"User","site_admin":false},"body":"The why even have a default?","created_at":"2019-03-05T12:56:01Z","updated_at":"2019-03-05T12:58:12Z","html_url":"https://github.com/kinecosystem/marketplace-server/pull/299#discussion_r262484412","pull_request_url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/comments/262484412"},"html":{"href":"https://github.com/kinecosystem/marketplace-server/pull/299#discussion_r262484412"},"pull_request":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299"}}},"pull_request":{"url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299","id":257999994,"node_id":"MDExOlB1bGxSZXF1ZXN0MjU3OTk5OTk0","html_url":"https://github.com/kinecosystem/marketplace-server/pull/299","diff_url":"https://github.com/kinecosystem/marketplace-server/pull/299.diff","patch_url":"https://github.com/kinecosystem/marketplace-server/pull/299.patch","issue_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/299","number":299,"state":"open","locked":false,"title":"Eco 1140 throw exception on wrong app id in jwt","user":{"login":"doodyparizada","id":965572,"node_id":"MDQ6VXNlcjk2NTU3Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/965572?v=4","gravatar_id":"","url":"https://api.github.com/users/doodyparizada","html_url":"https://github.com/doodyparizada","followers_url":"https://api.github.com/users/doodyparizada/followers","following_url":"https://api.github.com/users/doodyparizada/following{/other_user}","gists_url":"https://api.github.com/users/doodyparizada/gists{/gist_id}","starred_url":"https://api.github.com/users/doodyparizada/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doodyparizada/subscriptions","organizations_url":"https://api.github.com/users/doodyparizada/orgs","repos_url":"https://api.github.com/users/doodyparizada/repos","events_url":"https://api.github.com/users/doodyparizada/events{/privacy}","received_events_url":"https://api.github.com/users/doodyparizada/received_events","type":"User","site_admin":false},"body":"\r\n","created_at":"2019-03-04T16:09:36Z","updated_at":"2019-03-05T12:58:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32ba8ff6755a7ebc62b584c8ca8fc6e1c669b712","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299/commits","review_comments_url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299/comments","review_comment_url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/299/comments","statuses_url":"https://api.github.com/repos/kinecosystem/marketplace-server/statuses/8f33a4c77f8b5a91e62e1eb806a22661b29f31a8","head":{"label":"kinecosystem:ECO-1140-throw-exception-on-wrong-app-id-in-jwt","ref":"ECO-1140-throw-exception-on-wrong-app-id-in-jwt","sha":"8f33a4c77f8b5a91e62e1eb806a22661b29f31a8","user":{"login":"kinecosystem","id":28860603,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4ODYwNjAz","avatar_url":"https://avatars2.githubusercontent.com/u/28860603?v=4","gravatar_id":"","url":"https://api.github.com/users/kinecosystem","html_url":"https://github.com/kinecosystem","followers_url":"https://api.github.com/users/kinecosystem/followers","following_url":"https://api.github.com/users/kinecosystem/following{/other_user}","gists_url":"https://api.github.com/users/kinecosystem/gists{/gist_id}","starred_url":"https://api.github.com/users/kinecosystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinecosystem/subscriptions","organizations_url":"https://api.github.com/users/kinecosystem/orgs","repos_url":"https://api.github.com/users/kinecosystem/repos","events_url":"https://api.github.com/users/kinecosystem/events{/privacy}","received_events_url":"https://api.github.com/users/kinecosystem/received_events","type":"Organization","site_admin":false},"repo":{"id":119386811,"node_id":"MDEwOlJlcG9zaXRvcnkxMTkzODY4MTE=","name":"marketplace-server","full_name":"kinecosystem/marketplace-server","private":false,"owner":{"login":"kinecosystem","id":28860603,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4ODYwNjAz","avatar_url":"https://avatars2.githubusercontent.com/u/28860603?v=4","gravatar_id":"","url":"https://api.github.com/users/kinecosystem","html_url":"https://github.com/kinecosystem","followers_url":"https://api.github.com/users/kinecosystem/followers","following_url":"https://api.github.com/users/kinecosystem/following{/other_user}","gists_url":"https://api.github.com/users/kinecosystem/gists{/gist_id}","starred_url":"https://api.github.com/users/kinecosystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinecosystem/subscriptions","organizations_url":"https://api.github.com/users/kinecosystem/orgs","repos_url":"https://api.github.com/users/kinecosystem/repos","events_url":"https://api.github.com/users/kinecosystem/events{/privacy}","received_events_url":"https://api.github.com/users/kinecosystem/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/kinecosystem/marketplace-server","description":"Serves offers for the kin ecosystem client SDK","fork":false,"url":"https://api.github.com/repos/kinecosystem/marketplace-server","forks_url":"https://api.github.com/repos/kinecosystem/marketplace-server/forks","keys_url":"https://api.github.com/repos/kinecosystem/marketplace-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kinecosystem/marketplace-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kinecosystem/marketplace-server/teams","hooks_url":"https://api.github.com/repos/kinecosystem/marketplace-server/hooks","issue_events_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/events{/number}","events_url":"https://api.github.com/repos/kinecosystem/marketplace-server/events","assignees_url":"https://api.github.com/repos/kinecosystem/marketplace-server/assignees{/user}","branches_url":"https://api.github.com/repos/kinecosystem/marketplace-server/branches{/branch}","tags_url":"https://api.github.com/repos/kinecosystem/marketplace-server/tags","blobs_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kinecosystem/marketplace-server/statuses/{sha}","languages_url":"https://api.github.com/repos/kinecosystem/marketplace-server/languages","stargazers_url":"https://api.github.com/repos/kinecosystem/marketplace-server/stargazers","contributors_url":"https://api.github.com/repos/kinecosystem/marketplace-server/contributors","subscribers_url":"https://api.github.com/repos/kinecosystem/marketplace-server/subscribers","subscription_url":"https://api.github.com/repos/kinecosystem/marketplace-server/subscription","commits_url":"https://api.github.com/repos/kinecosystem/marketplace-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/kinecosystem/marketplace-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/kinecosystem/marketplace-server/contents/{+path}","compare_url":"https://api.github.com/repos/kinecosystem/marketplace-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kinecosystem/marketplace-server/merges","archive_url":"https://api.github.com/repos/kinecosystem/marketplace-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kinecosystem/marketplace-server/downloads","issues_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues{/number}","pulls_url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls{/number}","milestones_url":"https://api.github.com/repos/kinecosystem/marketplace-server/milestones{/number}","notifications_url":"https://api.github.com/repos/kinecosystem/marketplace-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kinecosystem/marketplace-server/labels{/name}","releases_url":"https://api.github.com/repos/kinecosystem/marketplace-server/releases{/id}","deployments_url":"https://api.github.com/repos/kinecosystem/marketplace-server/deployments","created_at":"2018-01-29T13:35:25Z","updated_at":"2019-03-05T09:19:52Z","pushed_at":"2019-03-05T09:19:53Z","git_url":"git://github.com/kinecosystem/marketplace-server.git","ssh_url":"git@github.com:kinecosystem/marketplace-server.git","clone_url":"https://github.com/kinecosystem/marketplace-server.git","svn_url":"https://github.com/kinecosystem/marketplace-server","homepage":"https://www.kinecosystem.com","size":1973,"stargazers_count":13,"watchers_count":13,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":5,"open_issues":3,"watchers":13,"default_branch":"master"}},"base":{"label":"kinecosystem:master","ref":"master","sha":"ef49c415e72f73fb9305fffaf00accb63a767711","user":{"login":"kinecosystem","id":28860603,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4ODYwNjAz","avatar_url":"https://avatars2.githubusercontent.com/u/28860603?v=4","gravatar_id":"","url":"https://api.github.com/users/kinecosystem","html_url":"https://github.com/kinecosystem","followers_url":"https://api.github.com/users/kinecosystem/followers","following_url":"https://api.github.com/users/kinecosystem/following{/other_user}","gists_url":"https://api.github.com/users/kinecosystem/gists{/gist_id}","starred_url":"https://api.github.com/users/kinecosystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinecosystem/subscriptions","organizations_url":"https://api.github.com/users/kinecosystem/orgs","repos_url":"https://api.github.com/users/kinecosystem/repos","events_url":"https://api.github.com/users/kinecosystem/events{/privacy}","received_events_url":"https://api.github.com/users/kinecosystem/received_events","type":"Organization","site_admin":false},"repo":{"id":119386811,"node_id":"MDEwOlJlcG9zaXRvcnkxMTkzODY4MTE=","name":"marketplace-server","full_name":"kinecosystem/marketplace-server","private":false,"owner":{"login":"kinecosystem","id":28860603,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4ODYwNjAz","avatar_url":"https://avatars2.githubusercontent.com/u/28860603?v=4","gravatar_id":"","url":"https://api.github.com/users/kinecosystem","html_url":"https://github.com/kinecosystem","followers_url":"https://api.github.com/users/kinecosystem/followers","following_url":"https://api.github.com/users/kinecosystem/following{/other_user}","gists_url":"https://api.github.com/users/kinecosystem/gists{/gist_id}","starred_url":"https://api.github.com/users/kinecosystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinecosystem/subscriptions","organizations_url":"https://api.github.com/users/kinecosystem/orgs","repos_url":"https://api.github.com/users/kinecosystem/repos","events_url":"https://api.github.com/users/kinecosystem/events{/privacy}","received_events_url":"https://api.github.com/users/kinecosystem/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/kinecosystem/marketplace-server","description":"Serves offers for the kin ecosystem client SDK","fork":false,"url":"https://api.github.com/repos/kinecosystem/marketplace-server","forks_url":"https://api.github.com/repos/kinecosystem/marketplace-server/forks","keys_url":"https://api.github.com/repos/kinecosystem/marketplace-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kinecosystem/marketplace-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kinecosystem/marketplace-server/teams","hooks_url":"https://api.github.com/repos/kinecosystem/marketplace-server/hooks","issue_events_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/events{/number}","events_url":"https://api.github.com/repos/kinecosystem/marketplace-server/events","assignees_url":"https://api.github.com/repos/kinecosystem/marketplace-server/assignees{/user}","branches_url":"https://api.github.com/repos/kinecosystem/marketplace-server/branches{/branch}","tags_url":"https://api.github.com/repos/kinecosystem/marketplace-server/tags","blobs_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kinecosystem/marketplace-server/statuses/{sha}","languages_url":"https://api.github.com/repos/kinecosystem/marketplace-server/languages","stargazers_url":"https://api.github.com/repos/kinecosystem/marketplace-server/stargazers","contributors_url":"https://api.github.com/repos/kinecosystem/marketplace-server/contributors","subscribers_url":"https://api.github.com/repos/kinecosystem/marketplace-server/subscribers","subscription_url":"https://api.github.com/repos/kinecosystem/marketplace-server/subscription","commits_url":"https://api.github.com/repos/kinecosystem/marketplace-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/kinecosystem/marketplace-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/kinecosystem/marketplace-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/kinecosystem/marketplace-server/contents/{+path}","compare_url":"https://api.github.com/repos/kinecosystem/marketplace-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kinecosystem/marketplace-server/merges","archive_url":"https://api.github.com/repos/kinecosystem/marketplace-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kinecosystem/marketplace-server/downloads","issues_url":"https://api.github.com/repos/kinecosystem/marketplace-server/issues{/number}","pulls_url":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls{/number}","milestones_url":"https://api.github.com/repos/kinecosystem/marketplace-server/milestones{/number}","notifications_url":"https://api.github.com/repos/kinecosystem/marketplace-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kinecosystem/marketplace-server/labels{/name}","releases_url":"https://api.github.com/repos/kinecosystem/marketplace-server/releases{/id}","deployments_url":"https://api.github.com/repos/kinecosystem/marketplace-server/deployments","created_at":"2018-01-29T13:35:25Z","updated_at":"2019-03-05T09:19:52Z","pushed_at":"2019-03-05T09:19:53Z","git_url":"git://github.com/kinecosystem/marketplace-server.git","ssh_url":"git@github.com:kinecosystem/marketplace-server.git","clone_url":"https://github.com/kinecosystem/marketplace-server.git","svn_url":"https://github.com/kinecosystem/marketplace-server","homepage":"https://www.kinecosystem.com","size":1973,"stargazers_count":13,"watchers_count":13,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":5,"open_issues":3,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299"},"html":{"href":"https://github.com/kinecosystem/marketplace-server/pull/299"},"issue":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/299"},"comments":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/issues/299/comments"},"review_comments":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299/comments"},"review_comment":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/pulls/299/commits"},"statuses":{"href":"https://api.github.com/repos/kinecosystem/marketplace-server/statuses/8f33a4c77f8b5a91e62e1eb806a22661b29f31a8"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"liorama"}}