{"action":"created","comment":{"url":"https://api.github.com/repos/okta/okta-signin-widget/pulls/comments/62228215","id":62228215,"diff_hunk":"@@ -365,98 +382,79 @@ function deleteCookie(name) {\n   setCookie(name, '', '1970-01-01T00:00:00Z');\n }\n \n-function addStateToken(trans, options) {\n+function addStateToken(res, options) {\n   var builtArgs = clone(options) || {};\n \n   // Add the stateToken if one isn't passed and we have one\n-  if (!builtArgs.stateToken && trans.response && trans.response.stateToken) {\n-    builtArgs.stateToken = trans.response.stateToken;\n+  if (!builtArgs.stateToken && res.stateToken) {\n+    builtArgs.stateToken = res.stateToken;\n   }\n \n   return builtArgs;\n }\n \n-function getStateToken(trans) {\n-  return addStateToken(trans);\n+function getStateToken(res) {\n+  return addStateToken(res);\n }\n \n function AuthTransaction(sdk, res) {\n   if (res) {\n-    this.response = res;\n-\n-    if (res.status) {\n-      this.status = res.status;\n-      var methods = STATE_MAP[res.status](sdk, this);\n-      extend(this, methods);\n+    this.data = res;\n+    extend(this, flattenEmbedded(sdk, res, res, {}));\n+    delete this.stateToken;\n+\n+    // RECOVERY_CHALLENGE has some responses without _links.\n+    // Without _links, we emulate cancel to make it intuitive\n+    // to return to the starting state. We may remove this\n+    // when OKTA-75434 is resolved\n+    if (res.status === 'RECOVERY_CHALLENGE' && !res._links) {\n+      this.cancel = function() {\n+        return new Q(new AuthTransaction(sdk));\n+      };\n     }\n   }\n }\n \n function postToTransaction(sdk, uri, options) {\n-  return sdk.post(uri, options)\n+  return post(sdk, uri, options)\n     .then(function(res) {\n       return new AuthTransaction(sdk, res);\n     });\n }\n \n-function getCancelFn(sdk, trans, ref) {\n-  function cancel() {\n-    if (ref) {\n-      ref.isPolling = false;\n-    }\n-    var cancelLink = getLink(trans.response, 'cancel');\n-    return postToTransaction(sdk, cancelLink.href, getStateToken(trans));\n-  }\n-  return cancel;\n-}\n-\n-function getPreviousFn(sdk, trans, ref) {\n-  function previous() {\n-    if (ref) {\n-      ref.isPolling = false;\n-    }\n-    var previousLink = getLink(trans.response, 'prev');\n-    return postToTransaction(sdk, previousLink.href, getStateToken(trans));\n-  }\n-  return previous;\n-}\n-\n-function getPollFn(sdk, trans, ref) {\n+function getPollFn(sdk, res, ref) {\n   return function (delay) {\n     if (!delay && delay !== 0) {\n       delay = DEFAULT_POLLING_DELAY;\n     }\n \n     // Get the poll function\n-    var pollLink = getLink(trans.response, 'next', 'poll');\n+    var pollLink = getLink(res, 'next', 'poll');\n     function pollFn() {\n-      return sdk.post(pollLink.href, getStateToken(trans), true, true);\n+      return post(sdk, pollLink.href, getStateToken(res), true, true);\n     }\n \n-    // Exposed to stop any polling in tests\n-    pollFn.__ref = ref;\n-\n     ref.isPolling = true;\n \n     var retryCount = 0;\n     var recursivePoll = function () {\n \n       // If the poll was manually stopped during the delay\n       if (!ref.isPolling) {\n-        return Q.resolve(trans);\n+        return Q.reject(new AuthPollStopError());\n       }\n \n       return pollFn()\n-        .then(function (res) {\n+        .then(function (pollRes) {\n           // Reset our retry counter on success\n           retryCount = 0;\n \n           // If we're still waiting\n-          if (res.factorResult && res.factorResult === 'WAITING') {\n+          if (pollRes.factorResult && pollRes.factorResult === 'WAITING') {\n \n             // If the poll was manually stopped while the pollFn was called\n             if (!ref.isPolling) {\n-              return trans;\n+              throw new AuthPollStopError();","path":"src/vendor/OktaAuth.js","position":175,"original_position":175,"commit_id":"9237493c684b78e884b1b8444e6b787fabbad710","original_commit_id":"c7b2922fc06f5e494f929c05df5ec094859c890f","user":{"login":"lboyette-okta","id":6387101,"avatar_url":"https://avatars.githubusercontent.com/u/6387101?v=3","gravatar_id":"","url":"https://api.github.com/users/lboyette-okta","html_url":"https://github.com/lboyette-okta","followers_url":"https://api.github.com/users/lboyette-okta/followers","following_url":"https://api.github.com/users/lboyette-okta/following{/other_user}","gists_url":"https://api.github.com/users/lboyette-okta/gists{/gist_id}","starred_url":"https://api.github.com/users/lboyette-okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lboyette-okta/subscriptions","organizations_url":"https://api.github.com/users/lboyette-okta/orgs","repos_url":"https://api.github.com/users/lboyette-okta/repos","events_url":"https://api.github.com/users/lboyette-okta/events{/privacy}","received_events_url":"https://api.github.com/users/lboyette-okta/received_events","type":"User","site_admin":false},"body":"OKTA-89034","created_at":"2016-05-05T18:08:20Z","updated_at":"2016-05-05T18:08:20Z","html_url":"https://github.com/okta/okta-signin-widget/pull/60#discussion_r62228215","pull_request_url":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60","_links":{"self":{"href":"https://api.github.com/repos/okta/okta-signin-widget/pulls/comments/62228215"},"html":{"href":"https://github.com/okta/okta-signin-widget/pull/60#discussion_r62228215"},"pull_request":{"href":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60"}}},"pull_request":{"url":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60","id":68894074,"html_url":"https://github.com/okta/okta-signin-widget/pull/60","diff_url":"https://github.com/okta/okta-signin-widget/pull/60.diff","patch_url":"https://github.com/okta/okta-signin-widget/pull/60.patch","issue_url":"https://api.github.com/repos/okta/okta-signin-widget/issues/60","number":60,"state":"open","locked":false,"title":"Migrated the SDK with the new surface area to the widget","user":{"login":"lboyette-okta","id":6387101,"avatar_url":"https://avatars.githubusercontent.com/u/6387101?v=3","gravatar_id":"","url":"https://api.github.com/users/lboyette-okta","html_url":"https://github.com/lboyette-okta","followers_url":"https://api.github.com/users/lboyette-okta/followers","following_url":"https://api.github.com/users/lboyette-okta/following{/other_user}","gists_url":"https://api.github.com/users/lboyette-okta/gists{/gist_id}","starred_url":"https://api.github.com/users/lboyette-okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lboyette-okta/subscriptions","organizations_url":"https://api.github.com/users/lboyette-okta/orgs","repos_url":"https://api.github.com/users/lboyette-okta/repos","events_url":"https://api.github.com/users/lboyette-okta/events{/privacy}","received_events_url":"https://api.github.com/users/lboyette-okta/received_events","type":"User","site_admin":false},"body":"@rchild-okta @Ujjwalreddy-okta \r\n\r\nOld PR: https://github.com/okta/okta-signin-widget/pull/36","created_at":"2016-05-04T16:43:35Z","updated_at":"2016-05-05T18:08:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71a9e5174489379c56179ebfdb11ae22bf30db5f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60/commits","review_comments_url":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60/comments","review_comment_url":"https://api.github.com/repos/okta/okta-signin-widget/pulls/comments{/number}","comments_url":"https://api.github.com/repos/okta/okta-signin-widget/issues/60/comments","statuses_url":"https://api.github.com/repos/okta/okta-signin-widget/statuses/9237493c684b78e884b1b8444e6b787fabbad710","head":{"label":"okta:lb-84261-migrate-surface-area-changes-revisited","ref":"lb-84261-migrate-surface-area-changes-revisited","sha":"9237493c684b78e884b1b8444e6b787fabbad710","user":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"repo":{"id":46365690,"name":"okta-signin-widget","full_name":"okta/okta-signin-widget","owner":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/okta/okta-signin-widget","description":"Okta SignIn widget that renders the new login/auth/recovery flows","fork":false,"url":"https://api.github.com/repos/okta/okta-signin-widget","forks_url":"https://api.github.com/repos/okta/okta-signin-widget/forks","keys_url":"https://api.github.com/repos/okta/okta-signin-widget/keys{/key_id}","collaborators_url":"https://api.github.com/repos/okta/okta-signin-widget/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/okta/okta-signin-widget/teams","hooks_url":"https://api.github.com/repos/okta/okta-signin-widget/hooks","issue_events_url":"https://api.github.com/repos/okta/okta-signin-widget/issues/events{/number}","events_url":"https://api.github.com/repos/okta/okta-signin-widget/events","assignees_url":"https://api.github.com/repos/okta/okta-signin-widget/assignees{/user}","branches_url":"https://api.github.com/repos/okta/okta-signin-widget/branches{/branch}","tags_url":"https://api.github.com/repos/okta/okta-signin-widget/tags","blobs_url":"https://api.github.com/repos/okta/okta-signin-widget/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/okta/okta-signin-widget/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/okta/okta-signin-widget/git/refs{/sha}","trees_url":"https://api.github.com/repos/okta/okta-signin-widget/git/trees{/sha}","statuses_url":"https://api.github.com/repos/okta/okta-signin-widget/statuses/{sha}","languages_url":"https://api.github.com/repos/okta/okta-signin-widget/languages","stargazers_url":"https://api.github.com/repos/okta/okta-signin-widget/stargazers","contributors_url":"https://api.github.com/repos/okta/okta-signin-widget/contributors","subscribers_url":"https://api.github.com/repos/okta/okta-signin-widget/subscribers","subscription_url":"https://api.github.com/repos/okta/okta-signin-widget/subscription","commits_url":"https://api.github.com/repos/okta/okta-signin-widget/commits{/sha}","git_commits_url":"https://api.github.com/repos/okta/okta-signin-widget/git/commits{/sha}","comments_url":"https://api.github.com/repos/okta/okta-signin-widget/comments{/number}","issue_comment_url":"https://api.github.com/repos/okta/okta-signin-widget/issues/comments{/number}","contents_url":"https://api.github.com/repos/okta/okta-signin-widget/contents/{+path}","compare_url":"https://api.github.com/repos/okta/okta-signin-widget/compare/{base}...{head}","merges_url":"https://api.github.com/repos/okta/okta-signin-widget/merges","archive_url":"https://api.github.com/repos/okta/okta-signin-widget/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/okta/okta-signin-widget/downloads","issues_url":"https://api.github.com/repos/okta/okta-signin-widget/issues{/number}","pulls_url":"https://api.github.com/repos/okta/okta-signin-widget/pulls{/number}","milestones_url":"https://api.github.com/repos/okta/okta-signin-widget/milestones{/number}","notifications_url":"https://api.github.com/repos/okta/okta-signin-widget/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/okta/okta-signin-widget/labels{/name}","releases_url":"https://api.github.com/repos/okta/okta-signin-widget/releases{/id}","deployments_url":"https://api.github.com/repos/okta/okta-signin-widget/deployments","created_at":"2015-11-17T18:08:41Z","updated_at":"2016-05-04T20:35:40Z","pushed_at":"2016-05-05T00:46:08Z","git_url":"git://github.com/okta/okta-signin-widget.git","ssh_url":"git@github.com:okta/okta-signin-widget.git","clone_url":"https://github.com/okta/okta-signin-widget.git","svn_url":"https://github.com/okta/okta-signin-widget","homepage":null,"size":2594,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":7,"forks":5,"open_issues":7,"watchers":1,"default_branch":"master"}},"base":{"label":"okta:master","ref":"master","sha":"c11be562ce9a42707e3fc12951fdeb9a3cb4f5ef","user":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"repo":{"id":46365690,"name":"okta-signin-widget","full_name":"okta/okta-signin-widget","owner":{"login":"okta","id":362460,"avatar_url":"https://avatars.githubusercontent.com/u/362460?v=3","gravatar_id":"","url":"https://api.github.com/users/okta","html_url":"https://github.com/okta","followers_url":"https://api.github.com/users/okta/followers","following_url":"https://api.github.com/users/okta/following{/other_user}","gists_url":"https://api.github.com/users/okta/gists{/gist_id}","starred_url":"https://api.github.com/users/okta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okta/subscriptions","organizations_url":"https://api.github.com/users/okta/orgs","repos_url":"https://api.github.com/users/okta/repos","events_url":"https://api.github.com/users/okta/events{/privacy}","received_events_url":"https://api.github.com/users/okta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/okta/okta-signin-widget","description":"Okta SignIn widget that renders the new login/auth/recovery flows","fork":false,"url":"https://api.github.com/repos/okta/okta-signin-widget","forks_url":"https://api.github.com/repos/okta/okta-signin-widget/forks","keys_url":"https://api.github.com/repos/okta/okta-signin-widget/keys{/key_id}","collaborators_url":"https://api.github.com/repos/okta/okta-signin-widget/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/okta/okta-signin-widget/teams","hooks_url":"https://api.github.com/repos/okta/okta-signin-widget/hooks","issue_events_url":"https://api.github.com/repos/okta/okta-signin-widget/issues/events{/number}","events_url":"https://api.github.com/repos/okta/okta-signin-widget/events","assignees_url":"https://api.github.com/repos/okta/okta-signin-widget/assignees{/user}","branches_url":"https://api.github.com/repos/okta/okta-signin-widget/branches{/branch}","tags_url":"https://api.github.com/repos/okta/okta-signin-widget/tags","blobs_url":"https://api.github.com/repos/okta/okta-signin-widget/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/okta/okta-signin-widget/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/okta/okta-signin-widget/git/refs{/sha}","trees_url":"https://api.github.com/repos/okta/okta-signin-widget/git/trees{/sha}","statuses_url":"https://api.github.com/repos/okta/okta-signin-widget/statuses/{sha}","languages_url":"https://api.github.com/repos/okta/okta-signin-widget/languages","stargazers_url":"https://api.github.com/repos/okta/okta-signin-widget/stargazers","contributors_url":"https://api.github.com/repos/okta/okta-signin-widget/contributors","subscribers_url":"https://api.github.com/repos/okta/okta-signin-widget/subscribers","subscription_url":"https://api.github.com/repos/okta/okta-signin-widget/subscription","commits_url":"https://api.github.com/repos/okta/okta-signin-widget/commits{/sha}","git_commits_url":"https://api.github.com/repos/okta/okta-signin-widget/git/commits{/sha}","comments_url":"https://api.github.com/repos/okta/okta-signin-widget/comments{/number}","issue_comment_url":"https://api.github.com/repos/okta/okta-signin-widget/issues/comments{/number}","contents_url":"https://api.github.com/repos/okta/okta-signin-widget/contents/{+path}","compare_url":"https://api.github.com/repos/okta/okta-signin-widget/compare/{base}...{head}","merges_url":"https://api.github.com/repos/okta/okta-signin-widget/merges","archive_url":"https://api.github.com/repos/okta/okta-signin-widget/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/okta/okta-signin-widget/downloads","issues_url":"https://api.github.com/repos/okta/okta-signin-widget/issues{/number}","pulls_url":"https://api.github.com/repos/okta/okta-signin-widget/pulls{/number}","milestones_url":"https://api.github.com/repos/okta/okta-signin-widget/milestones{/number}","notifications_url":"https://api.github.com/repos/okta/okta-signin-widget/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/okta/okta-signin-widget/labels{/name}","releases_url":"https://api.github.com/repos/okta/okta-signin-widget/releases{/id}","deployments_url":"https://api.github.com/repos/okta/okta-signin-widget/deployments","created_at":"2015-11-17T18:08:41Z","updated_at":"2016-05-04T20:35:40Z","pushed_at":"2016-05-05T00:46:08Z","git_url":"git://github.com/okta/okta-signin-widget.git","ssh_url":"git@github.com:okta/okta-signin-widget.git","clone_url":"https://github.com/okta/okta-signin-widget.git","svn_url":"https://github.com/okta/okta-signin-widget","homepage":null,"size":2594,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":7,"forks":5,"open_issues":7,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60"},"html":{"href":"https://github.com/okta/okta-signin-widget/pull/60"},"issue":{"href":"https://api.github.com/repos/okta/okta-signin-widget/issues/60"},"comments":{"href":"https://api.github.com/repos/okta/okta-signin-widget/issues/60/comments"},"review_comments":{"href":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60/comments"},"review_comment":{"href":"https://api.github.com/repos/okta/okta-signin-widget/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/okta/okta-signin-widget/pulls/60/commits"},"statuses":{"href":"https://api.github.com/repos/okta/okta-signin-widget/statuses/9237493c684b78e884b1b8444e6b787fabbad710"}}}}