{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/48506524","id":48506524,"diff_hunk":"@@ -0,0 +1,140 @@\n+/**\n+ * Copyright 2015 The AMP HTML Authors. All Rights Reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *      http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS-IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+import {assertHttpsUrl} from '../../../src/url';\n+import {getService} from '../../../src/service';\n+import {installStyles} from '../../../src/styles';\n+import {isExperimentOn} from '../../../src/experiments';\n+import {log} from '../../../src/log';\n+\n+\n+/*eslint no-unused-vars: 0*/\n+/**\n+ * The configuration properties are:\n+ * - authorization: The URL of the Authorization endpoint.\n+ * - pingback: The URL of the Pingback endpoint.\n+ * - login: The URL of the Login Page.\n+ *\n+ * @typedef {{\n+ *   authorization: string,\n+ *   pingback: string,\n+ *   login: string\n+ * }}\n+ */\n+let AccessConfig;\n+\n+/** @const {!Function} */\n+const assert = AMP.assert;\n+\n+/** @const */\n+const EXPERIMENT = 'amp-access';\n+\n+/** @const */\n+const TAG = 'AmpAccess';\n+\n+\n+/**\n+ * AccessService implements the complete lifecycle of the AMP Access system.\n+ */\n+export class AccessService {\n+  /**\n+   * @param {!Window} win\n+   */\n+  constructor(win) {\n+    /** @const {!Window} */\n+    this.win = win;\n+    installStyles(this.win.document, $CSS$, () => {});\n+\n+    /** @const @private {boolean} */\n+    this.isExperimentOn_ = isExperimentOn(this.win, EXPERIMENT);\n+\n+    const accessElement = document.getElementById('amp-access');\n+\n+    /** @const @private {boolean} */\n+    this.enabled_ = !!accessElement;\n+    if (!this.enabled_) {\n+      return;\n+    }\n+\n+    /** @const @private {!Element} */\n+    this.accessElement_ = accessElement;\n+\n+    /** @const {!AccessConfig} */\n+    this.config_ = this.buildConfig_();\n+  }\n+\n+  /**\n+   * @return {!AccessConfig}\n+   * @private\n+   */\n+  buildConfig_() {\n+    let config;\n+    try {\n+      config = JSON.parse(this.accessElement_.textContent);\n+    } catch (e) {\n+      throw new Error('Failed to parse \"amp-access\" JSON: ' + e);\n+    }\n+    return {\n+      authorization: assertHttpsUrl(assert(config['authorization'],\n+          '\"authorization\" URL must be specified')),\n+      pingback: assertHttpsUrl(assert(config['pingback'],\n+          '\"pingback\" URL must be specified')),\n+      login: assertHttpsUrl(assert(config['login'],\n+          '\"login\" URL must be specified')),\n+    };\n+  }\n+\n+  /**\n+   * @return {boolean}\n+   */\n+  isEnabled() {\n+    return this.enabled_;\n+  }\n+\n+  /**\n+   * @return {!AccessService}\n+   * @private\n+   */\n+  start_() {\n+    if (!this.isExperimentOn_) {\n+      log.info(TAG, 'Access experiment is off: ', EXPERIMENT);\n+      return this;\n+    }\n+    if (!this.enabled_) {\n+      log.info(TAG, 'Access is disabled - no \"id=amp-access\" element');\n+      return this;\n+    }\n+    this.startInternal_();\n+    return this;\n+  }\n+\n+  /** @private */\n+  startInternal_() {\n+  }\n+}\n+\n+\n+/**\n+ * @param {!Window} win\n+ * @return {!AccessService}\n+ */\n+export function installAccessService(win) {\n+  return getService(win, 'access', () => {\n+    return new AccessService(win).start_();","path":"extensions/amp-access/0.1/amp-access.js","position":136,"original_position":136,"commit_id":"8004b4d8b71a33be635ed058a89ae0469d0e13ed","original_commit_id":"8004b4d8b71a33be635ed058a89ae0469d0e13ed","user":{"login":"erwinmombay","id":354746,"avatar_url":"https://avatars.githubusercontent.com/u/354746?v=3","gravatar_id":"","url":"https://api.github.com/users/erwinmombay","html_url":"https://github.com/erwinmombay","followers_url":"https://api.github.com/users/erwinmombay/followers","following_url":"https://api.github.com/users/erwinmombay/following{/other_user}","gists_url":"https://api.github.com/users/erwinmombay/gists{/gist_id}","starred_url":"https://api.github.com/users/erwinmombay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erwinmombay/subscriptions","organizations_url":"https://api.github.com/users/erwinmombay/orgs","repos_url":"https://api.github.com/users/erwinmombay/repos","events_url":"https://api.github.com/users/erwinmombay/events{/privacy}","received_events_url":"https://api.github.com/users/erwinmombay/received_events","type":"User","site_admin":false},"body":"(im guessing it is just for testing purposes?)","created_at":"2015-12-28T21:24:48Z","updated_at":"2015-12-28T21:24:48Z","html_url":"https://github.com/ampproject/amphtml/pull/1254#discussion_r48506524","pull_request_url":"https://api.github.com/repos/ampproject/amphtml/pulls/1254","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/48506524"},"html":{"href":"https://github.com/ampproject/amphtml/pull/1254#discussion_r48506524"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/1254"}}},"pull_request":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/1254","id":54684416,"html_url":"https://github.com/ampproject/amphtml/pull/1254","diff_url":"https://github.com/ampproject/amphtml/pull/1254.diff","patch_url":"https://github.com/ampproject/amphtml/pull/1254.patch","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/1254","number":1254,"state":"open","locked":false,"title":"Kick off access work","user":{"login":"dvoytenko","id":726049,"avatar_url":"https://avatars.githubusercontent.com/u/726049?v=3","gravatar_id":"","url":"https://api.github.com/users/dvoytenko","html_url":"https://github.com/dvoytenko","followers_url":"https://api.github.com/users/dvoytenko/followers","following_url":"https://api.github.com/users/dvoytenko/following{/other_user}","gists_url":"https://api.github.com/users/dvoytenko/gists{/gist_id}","starred_url":"https://api.github.com/users/dvoytenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvoytenko/subscriptions","organizations_url":"https://api.github.com/users/dvoytenko/orgs","repos_url":"https://api.github.com/users/dvoytenko/repos","events_url":"https://api.github.com/users/dvoytenko/events{/privacy}","received_events_url":"https://api.github.com/users/dvoytenko/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-28T21:17:15Z","updated_at":"2015-12-28T21:24:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"13982d57f74a73fa6be520cdc2a8aecb5a892d4f","assignee":{"login":"erwinmombay","id":354746,"avatar_url":"https://avatars.githubusercontent.com/u/354746?v=3","gravatar_id":"","url":"https://api.github.com/users/erwinmombay","html_url":"https://github.com/erwinmombay","followers_url":"https://api.github.com/users/erwinmombay/followers","following_url":"https://api.github.com/users/erwinmombay/following{/other_user}","gists_url":"https://api.github.com/users/erwinmombay/gists{/gist_id}","starred_url":"https://api.github.com/users/erwinmombay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erwinmombay/subscriptions","organizations_url":"https://api.github.com/users/erwinmombay/orgs","repos_url":"https://api.github.com/users/erwinmombay/repos","events_url":"https://api.github.com/users/erwinmombay/events{/privacy}","received_events_url":"https://api.github.com/users/erwinmombay/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/ampproject/amphtml/pulls/1254/commits","review_comments_url":"https://api.github.com/repos/ampproject/amphtml/pulls/1254/comments","review_comment_url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/1254/comments","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/8004b4d8b71a33be635ed058a89ae0469d0e13ed","head":{"label":"dvoytenko:access1","ref":"access1","sha":"8004b4d8b71a33be635ed058a89ae0469d0e13ed","user":{"login":"dvoytenko","id":726049,"avatar_url":"https://avatars.githubusercontent.com/u/726049?v=3","gravatar_id":"","url":"https://api.github.com/users/dvoytenko","html_url":"https://github.com/dvoytenko","followers_url":"https://api.github.com/users/dvoytenko/followers","following_url":"https://api.github.com/users/dvoytenko/following{/other_user}","gists_url":"https://api.github.com/users/dvoytenko/gists{/gist_id}","starred_url":"https://api.github.com/users/dvoytenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvoytenko/subscriptions","organizations_url":"https://api.github.com/users/dvoytenko/orgs","repos_url":"https://api.github.com/users/dvoytenko/repos","events_url":"https://api.github.com/users/dvoytenko/events{/privacy}","received_events_url":"https://api.github.com/users/dvoytenko/received_events","type":"User","site_admin":false},"repo":{"id":43817704,"name":"amphtml","full_name":"dvoytenko/amphtml","owner":{"login":"dvoytenko","id":726049,"avatar_url":"https://avatars.githubusercontent.com/u/726049?v=3","gravatar_id":"","url":"https://api.github.com/users/dvoytenko","html_url":"https://github.com/dvoytenko","followers_url":"https://api.github.com/users/dvoytenko/followers","following_url":"https://api.github.com/users/dvoytenko/following{/other_user}","gists_url":"https://api.github.com/users/dvoytenko/gists{/gist_id}","starred_url":"https://api.github.com/users/dvoytenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvoytenko/subscriptions","organizations_url":"https://api.github.com/users/dvoytenko/orgs","repos_url":"https://api.github.com/users/dvoytenko/repos","events_url":"https://api.github.com/users/dvoytenko/events{/privacy}","received_events_url":"https://api.github.com/users/dvoytenko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dvoytenko/amphtml","description":"","fork":true,"url":"https://api.github.com/repos/dvoytenko/amphtml","forks_url":"https://api.github.com/repos/dvoytenko/amphtml/forks","keys_url":"https://api.github.com/repos/dvoytenko/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dvoytenko/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dvoytenko/amphtml/teams","hooks_url":"https://api.github.com/repos/dvoytenko/amphtml/hooks","issue_events_url":"https://api.github.com/repos/dvoytenko/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/dvoytenko/amphtml/events","assignees_url":"https://api.github.com/repos/dvoytenko/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/dvoytenko/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/dvoytenko/amphtml/tags","blobs_url":"https://api.github.com/repos/dvoytenko/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dvoytenko/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dvoytenko/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/dvoytenko/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dvoytenko/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/dvoytenko/amphtml/languages","stargazers_url":"https://api.github.com/repos/dvoytenko/amphtml/stargazers","contributors_url":"https://api.github.com/repos/dvoytenko/amphtml/contributors","subscribers_url":"https://api.github.com/repos/dvoytenko/amphtml/subscribers","subscription_url":"https://api.github.com/repos/dvoytenko/amphtml/subscription","commits_url":"https://api.github.com/repos/dvoytenko/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/dvoytenko/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/dvoytenko/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/dvoytenko/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/dvoytenko/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/dvoytenko/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dvoytenko/amphtml/merges","archive_url":"https://api.github.com/repos/dvoytenko/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dvoytenko/amphtml/downloads","issues_url":"https://api.github.com/repos/dvoytenko/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/dvoytenko/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/dvoytenko/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/dvoytenko/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dvoytenko/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/dvoytenko/amphtml/releases{/id}","created_at":"2015-10-07T13:30:20Z","updated_at":"2015-10-07T13:30:21Z","pushed_at":"2015-12-28T21:15:21Z","git_url":"git://github.com/dvoytenko/amphtml.git","ssh_url":"git@github.com:dvoytenko/amphtml.git","clone_url":"https://github.com/dvoytenko/amphtml.git","svn_url":"https://github.com/dvoytenko/amphtml","homepage":"","size":19806,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"c8bc5b83c07e7da7cdb4766c0e832f9b171b9a13","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":41766002,"name":"amphtml","full_name":"ampproject/amphtml","owner":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars.githubusercontent.com/u/14114390?v=3","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ampproject/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":false,"url":"https://api.github.com/repos/ampproject/amphtml","forks_url":"https://api.github.com/repos/ampproject/amphtml/forks","keys_url":"https://api.github.com/repos/ampproject/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amphtml/teams","hooks_url":"https://api.github.com/repos/ampproject/amphtml/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amphtml/events","assignees_url":"https://api.github.com/repos/ampproject/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amphtml/tags","blobs_url":"https://api.github.com/repos/ampproject/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amphtml/languages","stargazers_url":"https://api.github.com/repos/ampproject/amphtml/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amphtml/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amphtml/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amphtml/subscription","commits_url":"https://api.github.com/repos/ampproject/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amphtml/merges","archive_url":"https://api.github.com/repos/ampproject/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amphtml/downloads","issues_url":"https://api.github.com/repos/ampproject/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amphtml/releases{/id}","created_at":"2015-09-01T22:10:53Z","updated_at":"2015-12-28T18:15:46Z","pushed_at":"2015-12-28T21:17:17Z","git_url":"git://github.com/ampproject/amphtml.git","ssh_url":"git@github.com:ampproject/amphtml.git","clone_url":"https://github.com/ampproject/amphtml.git","svn_url":"https://github.com/ampproject/amphtml","homepage":"https://ampproject.org","size":21701,"stargazers_count":5135,"watchers_count":5135,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":500,"mirror_url":null,"open_issues_count":191,"forks":500,"open_issues":191,"watchers":5135,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/1254"},"html":{"href":"https://github.com/ampproject/amphtml/pull/1254"},"issue":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/1254"},"comments":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/1254/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/1254/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/1254/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amphtml/statuses/8004b4d8b71a33be635ed058a89ae0469d0e13ed"}}}}