{"action":"created","comment":{"url":"https://api.github.com/repos/lcobucci/jwt/pulls/comments/85638573","pull_request_review_id":6345906,"id":85638573,"diff_hunk":"@@ -0,0 +1,189 @@\n+<?php\n+/**\n+ * This file is part of Lcobucci\\JWT, a simple library to handle JWT and JWS\n+ *\n+ * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause\n+ */\n+\n+declare(strict_types=1);\n+\n+namespace Lcobucci\\JWT\\Storage;\n+\n+use Lcobucci\\Jose\\Parsing;\n+use Lcobucci\\JWT\\Builder as BuilderInterface;\n+use Lcobucci\\JWT\\Signer;\n+use Lcobucci\\JWT\\Signer\\Key;\n+use Lcobucci\\JWT\\Token as TokenInterface;\n+\n+/**\n+ * This class makes easier the token creation process\n+ *\n+ * @author Luís Otávio Cobucci Oblonczyk <lcobucci@gmail.com>\n+ * @since 0.1.0\n+ */\n+final class Builder implements BuilderInterface\n+{\n+    /**\n+     * The token header\n+     *\n+     * @var array\n+     */\n+    private $headers = ['typ'=> 'JWT', 'alg' => 'none'];\n+\n+    /**\n+     * The token claim set\n+     *\n+     * @var array\n+     */\n+    private $claims = [];\n+\n+    /**\n+     * The data encoder\n+     *\n+     * @var Parsing\\Encoder\n+     */\n+    private $encoder;\n+\n+    /**\n+     * Initializes a new builder\n+     */\n+    public function __construct(Parsing\\Encoder $encoder)\n+    {\n+        $this->encoder = $encoder;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function canOnlyBeUsedBy(string $audience, bool $addHeader = false): BuilderInterface\n+    {\n+        $audiences = $this->claims['aud'] ?? [];\n+\n+        if (!in_array($audience, $audiences)) {\n+            $audiences[] = $audience;\n+        }\n+\n+        return $this->setRegisteredClaim('aud', $audiences, $addHeader);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function expiresAt(int $expiration, bool $addHeader = false): BuilderInterface\n+    {\n+        return $this->setRegisteredClaim('exp', $expiration, $addHeader);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function identifiedBy(string $id, bool $addHeader = false): BuilderInterface\n+    {\n+        return $this->setRegisteredClaim('jti', $id, $addHeader);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function issuedAt(int $issuedAt, bool $addHeader = false): BuilderInterface\n+    {\n+        return $this->setRegisteredClaim('iat', (int) $issuedAt, $addHeader);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function issuedBy(string $issuer, bool $addHeader = false): BuilderInterface\n+    {\n+        return $this->setRegisteredClaim('iss', $issuer, $addHeader);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function canOnlyBeUsedAfter(int $notBefore, bool $addHeader = false): BuilderInterface\n+    {\n+        return $this->setRegisteredClaim('nbf', $notBefore, $addHeader);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function relatedTo(string $subject, bool $addHeader = false): BuilderInterface\n+    {\n+        return $this->setRegisteredClaim('sub', $subject, $addHeader);\n+    }\n+\n+    /**\n+     * Configures a registered claim\n+     */\n+    private function setRegisteredClaim(string $name, $value, bool $addHeader): BuilderInterface\n+    {\n+        $this->with($name, $value);\n+\n+        if ($addHeader) {\n+            $this->headers[$name] = $this->claims[$name];\n+        }\n+\n+        return $this;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function withHeader(string $name, $value): BuilderInterface\n+    {\n+        $this->headers[$name] = $value;\n+\n+        return $this;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function with(string $name, $value): BuilderInterface\n+    {\n+        $this->claims[$name] = $value;\n+\n+        return $this;\n+    }\n+\n+    private function encode(array $items): string","path":"src/Storage/Builder.php","position":151,"original_position":151,"commit_id":"2373e5760cfe316ed61429b57bcd18d8b0332c0f","original_commit_id":"2373e5760cfe316ed61429b57bcd18d8b0332c0f","user":{"login":"henriquemoody","id":154023,"avatar_url":"https://avatars.githubusercontent.com/u/154023?v=3","gravatar_id":"","url":"https://api.github.com/users/henriquemoody","html_url":"https://github.com/henriquemoody","followers_url":"https://api.github.com/users/henriquemoody/followers","following_url":"https://api.github.com/users/henriquemoody/following{/other_user}","gists_url":"https://api.github.com/users/henriquemoody/gists{/gist_id}","starred_url":"https://api.github.com/users/henriquemoody/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henriquemoody/subscriptions","organizations_url":"https://api.github.com/users/henriquemoody/orgs","repos_url":"https://api.github.com/users/henriquemoody/repos","events_url":"https://api.github.com/users/henriquemoody/events{/privacy}","received_events_url":"https://api.github.com/users/henriquemoody/received_events","type":"User","site_admin":false},"body":"Isn't this useful on the Encoder itself? ","created_at":"2016-10-29T11:05:07Z","updated_at":"2016-10-29T11:05:07Z","html_url":"https://github.com/lcobucci/jwt/pull/129#discussion_r85638573","pull_request_url":"https://api.github.com/repos/lcobucci/jwt/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/lcobucci/jwt/pulls/comments/85638573"},"html":{"href":"https://github.com/lcobucci/jwt/pull/129#discussion_r85638573"},"pull_request":{"href":"https://api.github.com/repos/lcobucci/jwt/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/lcobucci/jwt/pulls/129","id":90536278,"html_url":"https://github.com/lcobucci/jwt/pull/129","diff_url":"https://github.com/lcobucci/jwt/pull/129.diff","patch_url":"https://github.com/lcobucci/jwt/pull/129.patch","issue_url":"https://api.github.com/repos/lcobucci/jwt/issues/129","number":129,"state":"open","locked":false,"title":"[WIP] Create new validation API","user":{"login":"lcobucci","id":201963,"avatar_url":"https://avatars.githubusercontent.com/u/201963?v=3","gravatar_id":"","url":"https://api.github.com/users/lcobucci","html_url":"https://github.com/lcobucci","followers_url":"https://api.github.com/users/lcobucci/followers","following_url":"https://api.github.com/users/lcobucci/following{/other_user}","gists_url":"https://api.github.com/users/lcobucci/gists{/gist_id}","starred_url":"https://api.github.com/users/lcobucci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcobucci/subscriptions","organizations_url":"https://api.github.com/users/lcobucci/orgs","repos_url":"https://api.github.com/users/lcobucci/repos","events_url":"https://api.github.com/users/lcobucci/events{/privacy}","received_events_url":"https://api.github.com/users/lcobucci/received_events","type":"User","site_admin":false},"body":"Yes @Ocramius @henriquemoody @schnittstabil @dannydorfel, after a looong time we finally have something to solve the validation API 🎉 \r\n\r\nBrace yourself because this is huge PR but after merging it we'll haz:\r\n\r\n* interfaces for the things that the library exposes\r\n* fix for the SRP violation\r\n* private claim validation (custom constraints)","created_at":"2016-10-24T00:32:49Z","updated_at":"2016-10-29T11:05:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9eed1175ddf48df957e3ee249a0544c67f6384b0","assignee":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"assignees":[{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lcobucci/jwt/pulls/129/commits","review_comments_url":"https://api.github.com/repos/lcobucci/jwt/pulls/129/comments","review_comment_url":"https://api.github.com/repos/lcobucci/jwt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lcobucci/jwt/issues/129/comments","statuses_url":"https://api.github.com/repos/lcobucci/jwt/statuses/2373e5760cfe316ed61429b57bcd18d8b0332c0f","head":{"label":"lcobucci:refactor/validator-extraction","ref":"refactor/validator-extraction","sha":"2373e5760cfe316ed61429b57bcd18d8b0332c0f","user":{"login":"lcobucci","id":201963,"avatar_url":"https://avatars.githubusercontent.com/u/201963?v=3","gravatar_id":"","url":"https://api.github.com/users/lcobucci","html_url":"https://github.com/lcobucci","followers_url":"https://api.github.com/users/lcobucci/followers","following_url":"https://api.github.com/users/lcobucci/following{/other_user}","gists_url":"https://api.github.com/users/lcobucci/gists{/gist_id}","starred_url":"https://api.github.com/users/lcobucci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcobucci/subscriptions","organizations_url":"https://api.github.com/users/lcobucci/orgs","repos_url":"https://api.github.com/users/lcobucci/repos","events_url":"https://api.github.com/users/lcobucci/events{/privacy}","received_events_url":"https://api.github.com/users/lcobucci/received_events","type":"User","site_admin":false},"repo":{"id":17452080,"name":"jwt","full_name":"lcobucci/jwt","owner":{"login":"lcobucci","id":201963,"avatar_url":"https://avatars.githubusercontent.com/u/201963?v=3","gravatar_id":"","url":"https://api.github.com/users/lcobucci","html_url":"https://github.com/lcobucci","followers_url":"https://api.github.com/users/lcobucci/followers","following_url":"https://api.github.com/users/lcobucci/following{/other_user}","gists_url":"https://api.github.com/users/lcobucci/gists{/gist_id}","starred_url":"https://api.github.com/users/lcobucci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcobucci/subscriptions","organizations_url":"https://api.github.com/users/lcobucci/orgs","repos_url":"https://api.github.com/users/lcobucci/repos","events_url":"https://api.github.com/users/lcobucci/events{/privacy}","received_events_url":"https://api.github.com/users/lcobucci/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lcobucci/jwt","description":"A simple library to work with JSON Web Token and JSON Web Signature","fork":false,"url":"https://api.github.com/repos/lcobucci/jwt","forks_url":"https://api.github.com/repos/lcobucci/jwt/forks","keys_url":"https://api.github.com/repos/lcobucci/jwt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lcobucci/jwt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lcobucci/jwt/teams","hooks_url":"https://api.github.com/repos/lcobucci/jwt/hooks","issue_events_url":"https://api.github.com/repos/lcobucci/jwt/issues/events{/number}","events_url":"https://api.github.com/repos/lcobucci/jwt/events","assignees_url":"https://api.github.com/repos/lcobucci/jwt/assignees{/user}","branches_url":"https://api.github.com/repos/lcobucci/jwt/branches{/branch}","tags_url":"https://api.github.com/repos/lcobucci/jwt/tags","blobs_url":"https://api.github.com/repos/lcobucci/jwt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lcobucci/jwt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lcobucci/jwt/git/refs{/sha}","trees_url":"https://api.github.com/repos/lcobucci/jwt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lcobucci/jwt/statuses/{sha}","languages_url":"https://api.github.com/repos/lcobucci/jwt/languages","stargazers_url":"https://api.github.com/repos/lcobucci/jwt/stargazers","contributors_url":"https://api.github.com/repos/lcobucci/jwt/contributors","subscribers_url":"https://api.github.com/repos/lcobucci/jwt/subscribers","subscription_url":"https://api.github.com/repos/lcobucci/jwt/subscription","commits_url":"https://api.github.com/repos/lcobucci/jwt/commits{/sha}","git_commits_url":"https://api.github.com/repos/lcobucci/jwt/git/commits{/sha}","comments_url":"https://api.github.com/repos/lcobucci/jwt/comments{/number}","issue_comment_url":"https://api.github.com/repos/lcobucci/jwt/issues/comments{/number}","contents_url":"https://api.github.com/repos/lcobucci/jwt/contents/{+path}","compare_url":"https://api.github.com/repos/lcobucci/jwt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lcobucci/jwt/merges","archive_url":"https://api.github.com/repos/lcobucci/jwt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lcobucci/jwt/downloads","issues_url":"https://api.github.com/repos/lcobucci/jwt/issues{/number}","pulls_url":"https://api.github.com/repos/lcobucci/jwt/pulls{/number}","milestones_url":"https://api.github.com/repos/lcobucci/jwt/milestones{/number}","notifications_url":"https://api.github.com/repos/lcobucci/jwt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lcobucci/jwt/labels{/name}","releases_url":"https://api.github.com/repos/lcobucci/jwt/releases{/id}","deployments_url":"https://api.github.com/repos/lcobucci/jwt/deployments","created_at":"2014-03-05T19:23:23Z","updated_at":"2016-10-28T10:36:33Z","pushed_at":"2016-10-28T13:29:07Z","git_url":"git://github.com/lcobucci/jwt.git","ssh_url":"git@github.com:lcobucci/jwt.git","clone_url":"https://github.com/lcobucci/jwt.git","svn_url":"https://github.com/lcobucci/jwt","homepage":null,"size":626,"stargazers_count":896,"watchers_count":896,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":111,"mirror_url":null,"open_issues_count":20,"forks":111,"open_issues":20,"watchers":896,"default_branch":"master"}},"base":{"label":"lcobucci:master","ref":"master","sha":"4f6512f0aaafd177ae98da9f459475d0dc806670","user":{"login":"lcobucci","id":201963,"avatar_url":"https://avatars.githubusercontent.com/u/201963?v=3","gravatar_id":"","url":"https://api.github.com/users/lcobucci","html_url":"https://github.com/lcobucci","followers_url":"https://api.github.com/users/lcobucci/followers","following_url":"https://api.github.com/users/lcobucci/following{/other_user}","gists_url":"https://api.github.com/users/lcobucci/gists{/gist_id}","starred_url":"https://api.github.com/users/lcobucci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcobucci/subscriptions","organizations_url":"https://api.github.com/users/lcobucci/orgs","repos_url":"https://api.github.com/users/lcobucci/repos","events_url":"https://api.github.com/users/lcobucci/events{/privacy}","received_events_url":"https://api.github.com/users/lcobucci/received_events","type":"User","site_admin":false},"repo":{"id":17452080,"name":"jwt","full_name":"lcobucci/jwt","owner":{"login":"lcobucci","id":201963,"avatar_url":"https://avatars.githubusercontent.com/u/201963?v=3","gravatar_id":"","url":"https://api.github.com/users/lcobucci","html_url":"https://github.com/lcobucci","followers_url":"https://api.github.com/users/lcobucci/followers","following_url":"https://api.github.com/users/lcobucci/following{/other_user}","gists_url":"https://api.github.com/users/lcobucci/gists{/gist_id}","starred_url":"https://api.github.com/users/lcobucci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lcobucci/subscriptions","organizations_url":"https://api.github.com/users/lcobucci/orgs","repos_url":"https://api.github.com/users/lcobucci/repos","events_url":"https://api.github.com/users/lcobucci/events{/privacy}","received_events_url":"https://api.github.com/users/lcobucci/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lcobucci/jwt","description":"A simple library to work with JSON Web Token and JSON Web Signature","fork":false,"url":"https://api.github.com/repos/lcobucci/jwt","forks_url":"https://api.github.com/repos/lcobucci/jwt/forks","keys_url":"https://api.github.com/repos/lcobucci/jwt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lcobucci/jwt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lcobucci/jwt/teams","hooks_url":"https://api.github.com/repos/lcobucci/jwt/hooks","issue_events_url":"https://api.github.com/repos/lcobucci/jwt/issues/events{/number}","events_url":"https://api.github.com/repos/lcobucci/jwt/events","assignees_url":"https://api.github.com/repos/lcobucci/jwt/assignees{/user}","branches_url":"https://api.github.com/repos/lcobucci/jwt/branches{/branch}","tags_url":"https://api.github.com/repos/lcobucci/jwt/tags","blobs_url":"https://api.github.com/repos/lcobucci/jwt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lcobucci/jwt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lcobucci/jwt/git/refs{/sha}","trees_url":"https://api.github.com/repos/lcobucci/jwt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lcobucci/jwt/statuses/{sha}","languages_url":"https://api.github.com/repos/lcobucci/jwt/languages","stargazers_url":"https://api.github.com/repos/lcobucci/jwt/stargazers","contributors_url":"https://api.github.com/repos/lcobucci/jwt/contributors","subscribers_url":"https://api.github.com/repos/lcobucci/jwt/subscribers","subscription_url":"https://api.github.com/repos/lcobucci/jwt/subscription","commits_url":"https://api.github.com/repos/lcobucci/jwt/commits{/sha}","git_commits_url":"https://api.github.com/repos/lcobucci/jwt/git/commits{/sha}","comments_url":"https://api.github.com/repos/lcobucci/jwt/comments{/number}","issue_comment_url":"https://api.github.com/repos/lcobucci/jwt/issues/comments{/number}","contents_url":"https://api.github.com/repos/lcobucci/jwt/contents/{+path}","compare_url":"https://api.github.com/repos/lcobucci/jwt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lcobucci/jwt/merges","archive_url":"https://api.github.com/repos/lcobucci/jwt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lcobucci/jwt/downloads","issues_url":"https://api.github.com/repos/lcobucci/jwt/issues{/number}","pulls_url":"https://api.github.com/repos/lcobucci/jwt/pulls{/number}","milestones_url":"https://api.github.com/repos/lcobucci/jwt/milestones{/number}","notifications_url":"https://api.github.com/repos/lcobucci/jwt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lcobucci/jwt/labels{/name}","releases_url":"https://api.github.com/repos/lcobucci/jwt/releases{/id}","deployments_url":"https://api.github.com/repos/lcobucci/jwt/deployments","created_at":"2014-03-05T19:23:23Z","updated_at":"2016-10-28T10:36:33Z","pushed_at":"2016-10-28T13:29:07Z","git_url":"git://github.com/lcobucci/jwt.git","ssh_url":"git@github.com:lcobucci/jwt.git","clone_url":"https://github.com/lcobucci/jwt.git","svn_url":"https://github.com/lcobucci/jwt","homepage":null,"size":626,"stargazers_count":896,"watchers_count":896,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":111,"mirror_url":null,"open_issues_count":20,"forks":111,"open_issues":20,"watchers":896,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lcobucci/jwt/pulls/129"},"html":{"href":"https://github.com/lcobucci/jwt/pull/129"},"issue":{"href":"https://api.github.com/repos/lcobucci/jwt/issues/129"},"comments":{"href":"https://api.github.com/repos/lcobucci/jwt/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/lcobucci/jwt/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/lcobucci/jwt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lcobucci/jwt/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/lcobucci/jwt/statuses/2373e5760cfe316ed61429b57bcd18d8b0332c0f"}}}}
{"actor":{"display_login":"henriquemoody"}}