- Dropped support for Node 14 and 16.
- Migrated the test suite from Mocha and Chai to node:test and node:assert (@Zen-cronic).
- Full conversion to ESM.
- #161: Re-use old refresh_token if no new one was issued after a refresh.
- #151: Add 'Accept' header on token requests to fix a Github compatibility issue.
- #151: Throw error when we get an invalid reply from a token endpoint.
- More robust error handling. When an error is emitted, you now give you access to the emitted HTTP Response and response body.
- Support for
response_mode=fragment
in theauthorization_code
flow.
- Fix for #128: If there's no secret, we should never use Basic auth to encode
the
client_id
. - Support for the
resource
parameter from RFC 8707. - Add support for
scope
parameter torefresh()
. - Support for RFC 7009, Token Revocation (@adambom).
- Added
extraParams
option togetAuthorizeUri
, allowing users to add non-standard arguments to the authorization URI for servers that require this. (@pks1989)
- Moved the
tokenResponseToOAuth2Token
function inside the OAuth2Client class, allowing users to override the parsing logic more easily.
- #111 Some documentation fixes.
- #110: Fix race condition with
getStoredToken
and callingfetch()
immediately after constructingFetchWrapper
.
- #15: Fix for 'TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation at t.OAuth2Client.request'.
- Add an option to override which "fetch" implementation is used. (@bradjones1)
- Re-release. Previous build had an error.
- Allow users to provide non-standard properties to
client_credentials
token requests via anextraParams
property. This is necessary to support vendors like Auth0 and Kinde which both require anaudience
parameter. (@South-Paw) - Sending
client_id
andclient_secret
in POST request body is now optionally supported. By default the credentials will still be sent in theAuthorization
header, but users can opt-in to using the body. The authentication method will also be discovered if an OAuth2 or OpenID discovery document is used. (@parkerduckworth) - The fetchWrapper now has an option to disable auto-refreshing tokens. (@bradjones1)
- Bug fix: If a 'state' parameter was not used in
authorization_code
, it should not be required in the redirect. - Tested with Node 20.
- Didn't run
make build
before the last release, which causes some files in thedist/
directory to be out of date.
- Correctly pass 'scope' to
authorization_code
redirects.
- It was not possible to generate the URL to the authorization endpoint with
PKCE using Node, due to depending on a global
crypto
object. This is fixed with fallbacks all the way back to Node 14.
- #70: Sending the client secret is now supported with the
authorization_code
flow.
- Re-release, to publish on Github packages.
- Fixed some docs.
- First stable v2 release!
- Renamed this package from
fetch-mw-oauth2
to@badgateway/oauth2-client
. - #59: Scope support for
authorization_code
flow.
- Released with alpha tag.
- Re-published
- Released with alpha tag.
- Tested on Node 14, 16.
- Added polyfills for these node versions (see README).
generateCodeVerifier
is now async to support Node 14.
- Released with alpha tag.
- Set
Content-Type
toapplication/x-www-form-urlencoded
.
- Released with alpha tag.
- Changing the
authorization_code
signature again. It's a bit hard to come up with a create signature for this, especially because there's multiple steps in the process, and some information has to survive these steps.
- Released with alpha tag.
- Re-release (broken build).
- Released with alpha tag.
- Removed redundant parameters.
authorization_code
should now also work correctly without PKCE.- Removed some redundant arguments.
- Released with alpha tag.
- PKCE support.
- Released with alpha tag.
- remove
fetchMw
and addmw()
.mw()
now returns a middleware function.
- Released with alpha tag.
- Export
OAuth2AuthorizationCodeClient
- Client.authorizationCode() should not have been
async
.
- Released with alpha tag.
- Fix format for
introspect()
function.
- Released with alpha tag.
- Fix introspection HTTP method name.
The 2.0 version of this library is a complete rewrite. The original scope of
this library was to provide a wrapper around fetch()
to add a Bearer
token
and refresh this token under the hood, but it has now evolved into a
full-featured modern OAuth2 library. The existing 'fetch wrapper' still exists,
but it's not merely one of the features this package offers. The API has
changes, and while I think it shouldn't be difficult to migrate, v2 offers no
backwards compatibility so some rewrites will be required. New features
include:
- Complete support for the
authorization_code
flow, including generating redirect urls and parsing query parameters after redirect. - Support for OAuth2 endpoint discovery, using the OAuth2 Authorization Server Metadata document. If your server supports it, just give the library a URL and it will figure out the rest. RFC8414.
- Support for OAuth2 token introspection (RFC7662).
- Generally a better abstraction of the OAuth2 framework.
- Released with alpha tag.
- Dropped support for Node 10.
- Fixed #45: Call
onAuthError
when a refresh fails. - Replaced
awesome-typescript-loader
withts-loader
for Webpack builds. the former appears unmaintained. - Switched from Travis CI to Github Actions.
- Last version did not correctly build it's files.
- Better error handling when the response we got was not a standard OAuth2 error response body + adding information for when the Basic credentials were wrong.
- This fixes the bug when fetch-mw-oauth2 says there's an 'undefined' error.
- Fixing a few broken links in package.json. Does not alter any behavior.
- Re-publishing package. Previous version had an old build artifact.
- Fixed bug that completely broke the token flow.
- Fix bug in auto-refresh
- Ensure that only 1 refresh operation will happen in parallel. If there are multiple things triggering the refresh, all will wait for the first one to finish.
- Automatically schedule a refresh operation 1 minute before the access token expires, if the expiry time is known.
- BC Break: If a token is known when setting up OAuth2, this now needs to be passed as the second argument. The old behavior still works but will emit a warning, and will be removed in a future release.
- 'OAuth2Token' type is now exported.
- #34: Refresh operation failed for the
authorization_code
flow.
- Added a onAuthError event, allowing users to intercept this event and re-authenticate.
- Simplify types a bit. More duplication in the library, but this should result in easier to read errors.
- Typescript 4
- Switch from tslint to eslint.
- Webpack 5
- Added a
fetchMw()
function that takes anext
argument so this package can behave as a more regular middleware.
- Files were not correctly built in the last release.
- Error code 401 will be submitted when authentication fails. Before, we would
just forward the error code from the OAuth2 server, but this doesn't make a
lot of sense for a
fetch()
user, as the error might be misinterpreted as an error unrelated to auth.
- Added a
getOptions()
method, which allows a user to get all current tokens and store them in LocalStorage. These options can be used as-is in the constructor.
- Include typescript sourcefiles in NPM package, for IDE's.
- This package now throws OAuth2Error classes for server-side errors.
- When refreshing a token, browsers don't allow re-use of the same
Request
object. Now we're cloning it before use.
- When refreshing a token, and there's no
client_secret
, theclient_id
must be sent in the body.
- Now correctly exporting all the right symbols.
- Library is refactored and now uses a class.
- Support for
authorization_code
grant type. - Exposing some more information to uses.
- Add a new
onTokenUpdate
hook for custom storage. - It's now possible to construct a client with an existing (old) Access and/or refresh token.
- Shipping
dist/
instead ofsrc/
. - Making a browser build lean by not relying on
querystring
orBuffer
.
- First public version
- Support for
client_credentials
,password
andrefresh_token
. - Will automatically attempt to refresh tokens if it knows an access token is expired.