1. 12 Aug, 2021 5 commits
    • Robert Knight's avatar
      Add `fetchJSON` utility · a8fa207e
      Robert Knight authored
      Add a utility function that wraps `fetch` to throw more consistent and
      useful exceptions if the request fails, making downstream handling
      easier.
      
      - Error messages thrown by failed `fetch` requests are unhelpful for
        downstream consumers. There is no specific Error subclass and the
        error messages vary depending on cause and browser.
      
      - Parsing the JSON response from a request with `Response.json()` can
        fail if the request has a success status and the error messages also
        vary by browser.
      
      The `fetchJSON` utility throws a `FetchError` error if either of the
      above failures occurs or if the response code indicates a failure.
      a8fa207e
    • Robert Knight's avatar
      Combine import statements for same module · 9e971701
      Robert Knight authored
      Also move `$imports` to end per convention.
      9e971701
    • Robert Knight's avatar
      Document `_getAccessToken` return type · b2311651
      Robert Knight authored
      Following PR feedback, document the return type of `_getAccessToken`
      explicitly and make the error thrown in the event of a non-2xx response
      more informative.
      b2311651
    • Robert Knight's avatar
      Simplify `state` string generation mocking · e1e43428
      Robert Knight authored
      Now that we have good support for mocking imports in tests, we can use
      that to mock `generateHexString` calls in `OAuthClient` rather than
      needing to have a test seam in the class.
      
      This improves test coverage slightly.
      e1e43428
    • Robert Knight's avatar
      Refactor token fetching and error handling in OAuthClient · 8040bf0d
      Robert Knight authored
      Prepare for upcoming improvements to handling of network errors across
      the client by refactoring some `fetch` requests and error handling in
      OAuthClient.
      
       - Extract duplicated logic for fetching an access token into a
         `_getAccessToken` method.
      
       - Create a `TokenError` class to wrap all errors that may be thrown
         when fetching or revoking an access token. This makes it easier for
         downstream consumers to handle such errors in a uniform way.
      
         The `TokenError` error links to the network or other error that
         caused it via the `cause` property, following the convention
         currently being standardized in https://github.com/tc39/proposal-error-cause.
      8040bf0d
  2. 11 Aug, 2021 3 commits
  3. 10 Aug, 2021 2 commits
  4. 09 Aug, 2021 18 commits
  5. 06 Aug, 2021 4 commits
  6. 05 Aug, 2021 8 commits