Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
## [1.0.0-beta.0](https://github.com/auth0/nextjs-auth0/tree/v1.0.0-beta.0) (2021-01-14)

**Install**

```sh
npm install @auth0/nextjs-auth0@beta
```

**New features**

- New suite of frontend tools:
- `useUser` hook and `UserProvider` to simplify checking and managing the user’s logged in state on the client.
- `withPageAuthRequired` higher order component to protect client side routes.
- New `handleAuth` feature to reduce the amount of boilerplate required to set up the server side authentication handlers.
- Simpler server side API where creation of an SDK instance is handled by the SDK.

**Breaking changes**

For a full list of breaking changes and migration guide, checkout the [V1_MIGRATION_GUIDE.md](./V1_MIGRATION_GUIDE.md)

**Changes**

- AggregateError#message from `Issuer.discover` includes stack trace [#236](https://github.com/auth0/nextjs-auth0/pull/236) ([adamjmcgrath](https://github.com/adamjmcgrath))
- Prevent caching the `/me` request [#233](https://github.com/auth0/nextjs-auth0/pull/233) ([adamjmcgrath](https://github.com/adamjmcgrath))
- Added error handling to useUser [SDK-2236] [#229](https://github.com/auth0/nextjs-auth0/pull/229) ([Widcket](https://github.com/Widcket))
- Rename loading to isLoading [#222](https://github.com/auth0/nextjs-auth0/pull/222) ([Widcket](https://github.com/Widcket))
- Prepare application to be deployable with Vercel [#218](https://github.com/auth0/nextjs-auth0/pull/218) ([frederikprijck](https://github.com/frederikprijck))
- Added withCSRAuthRequired HOC [SDK-2120] [#209](https://github.com/auth0/nextjs-auth0/pull/209) ([Widcket](https://github.com/Widcket))
- [SDK-2057] Express mw tests [#191](https://github.com/auth0/nextjs-auth0/pull/191) ([adamjmcgrath](https://github.com/adamjmcgrath))
- Add withAuth HOC [SDK-2120] [#189](https://github.com/auth0/nextjs-auth0/pull/189) ([Widcket](https://github.com/Widcket))
- Add frontend hook tests [SDK-2117] [#188](https://github.com/auth0/nextjs-auth0/pull/188) ([Widcket](https://github.com/Widcket))
- Add frontend hook CH: Added [#187](https://github.com/auth0/nextjs-auth0/pull/187) ([Widcket](https://github.com/Widcket))

## [v0.16.0](https://github.com/auth0/nextjs-auth0/tree/v0.16.0) (2020-08-19)

- Updating dependencies with security issues
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @auth0/nextjs-auth0
# @auth0/nextjs-auth0 Beta

Auth0 SDK for signing in to your Next.js applications.

Expand All @@ -15,10 +15,11 @@ Auth0 SDK for signing in to your Next.js applications.
- [Auth0 Configuration](#auth0-configuration)
- [Basic Setup](#basic-setup)
- [Documentation](#documentation)
- [Architecture](./ARCHITECTURE.md)
- [v1 Migration Guide](./V1_MIGRATION_GUIDE.md)
- [QuickStart](https://auth0.com/docs/quickstart/webapp/nextjs)
- [API Reference](#api-reference)
- [v1 Migration Guide](./V1_MIGRATION_GUIDE.md)
- [Cookies and Security](#cookies-and-security)
- [Architecture](./ARCHITECTURE.md)
- [Comparison with auth0-react](#comparison-with-auth0-react)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
Expand Down
80 changes: 78 additions & 2 deletions V1_MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default async function login(req, res) {
});
} catch (error) {
console.error(error);
res.status(error.status || 400).end(error.message);
res.status(error.status || 500).end(error.message);
}
}
```
Expand All @@ -195,7 +195,7 @@ export default async function login(req, res) {
});
} catch (error) {
console.error(error);
res.status(error.status || 400).end(error.message);
res.status(error.status || 500).end(error.message);
}
}
```
Expand All @@ -208,6 +208,42 @@ The options passed to `handleLogout` have changed.

- `redirectTo` is now `returnTo`

#### Before

```js
// pages/api/logout.js
import auth0 from '../../utils/auth0';

export default async function logout(req, res) {
try {
await auth0.handleLogout(req, res, {
redirectTo: '/custom-url'
});
} catch (error) {
console.error(error);
res.status(error.status || 500).end(error.message);
}
}
```

#### After

```js
// pages/api/logout.js
import auth0 from '../../utils/auth0';

export default async function logout(req, res) {
try {
await auth0.handleLogout(req, res, {
returnTo: '/custom-url'
});
} catch (error) {
console.error(error);
res.status(error.status || 500).end(error.message);
}
}
```

See the [handleLogout docs](https://auth0.github.io/nextjs-auth0/modules/handlers_logout.html).

### handleCallback
Expand All @@ -216,4 +252,44 @@ The options passed to `handleCallback` have changed.

- `onUserLoaded` is now `afterCallback`

#### Before

```js
// pages/api/callback.js
import auth0 from '../../utils/auth0';

export default async function callback(req, res) {
try {
await auth0.handleCallback(req, res, {
async onUserLoaded(req, res, session, state) {
return session;
}
});
} catch (error) {
console.error(error);
res.status(error.status || 500).end(error.message);
}
}
```

#### After

```js
// pages/api/callback.js
import auth0 from '../../utils/auth0';

export default async function callback(req, res) {
try {
await auth0.handleCallback(req, res, {
async afterCallback(req, res, session, state) {
return session;
}
});
} catch (error) {
console.error(error);
res.status(error.status || 500).end(error.message);
}
}
```

See the [handleCallback docs](https://auth0.github.io/nextjs-auth0/modules/handlers_callback.html).
2 changes: 1 addition & 1 deletion docs/assets/js/search.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions docs/classes/session.sessioncache.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L12">src/session/cache.ts:12</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L12">src/session/cache.ts:12</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down Expand Up @@ -147,7 +147,7 @@ <h3>create</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L26">src/session/cache.ts:26</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L26">src/session/cache.ts:26</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down Expand Up @@ -176,7 +176,7 @@ <h3>delete</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L31">src/session/cache.ts:31</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L31">src/session/cache.ts:31</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -202,7 +202,7 @@ <h3>from<wbr>Token<wbr>Set</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L60">src/session/cache.ts:60</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L58">src/session/cache.ts:58</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -225,7 +225,7 @@ <h3>get</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L55">src/session/cache.ts:55</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L53">src/session/cache.ts:53</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -251,7 +251,7 @@ <h3>get<wbr>IdToken</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L42">src/session/cache.ts:42</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L42">src/session/cache.ts:42</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -277,7 +277,7 @@ <h3>init</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L18">src/session/cache.ts:18</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L18">src/session/cache.ts:18</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -303,7 +303,7 @@ <h3>is<wbr>Authenticated</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L36">src/session/cache.ts:36</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L36">src/session/cache.ts:36</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -329,7 +329,7 @@ <h3>set</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/cache.ts#L50">src/session/cache.ts:50</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/cache.ts#L48">src/session/cache.ts:48</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand Down
24 changes: 12 additions & 12 deletions docs/classes/session_session.default.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/session.ts#L49">src/session/session.ts:49</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/session.ts#L49">src/session/session.ts:49</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -145,10 +145,10 @@ <h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="accesstoken" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagOptional">Optional</span> access<wbr>Token</h3>
<div class="tsd-signature tsd-kind-icon">access<wbr>Token<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></div>
<div class="tsd-signature tsd-kind-icon">access<wbr>Token<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/session.ts#L32">src/session/session.ts:32</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/session.ts#L32">src/session/session.ts:32</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -160,10 +160,10 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> access<wbr>Token</h3>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="accesstokenexpiresat" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagOptional">Optional</span> access<wbr>Token<wbr>Expires<wbr>At</h3>
<div class="tsd-signature tsd-kind-icon">access<wbr>Token<wbr>Expires<wbr>At<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
<div class="tsd-signature tsd-kind-icon">access<wbr>Token<wbr>Expires<wbr>At<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">number</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/session.ts#L42">src/session/session.ts:42</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/session.ts#L42">src/session/session.ts:42</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -175,10 +175,10 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> access<wbr>Token<wbr>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="accesstokenscope" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagOptional">Optional</span> access<wbr>Token<wbr>Scope</h3>
<div class="tsd-signature tsd-kind-icon">access<wbr>Token<wbr>Scope<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></div>
<div class="tsd-signature tsd-kind-icon">access<wbr>Token<wbr>Scope<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/session.ts#L37">src/session/session.ts:37</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/session.ts#L37">src/session/session.ts:37</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -190,10 +190,10 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> access<wbr>Token<wbr>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="idtoken" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagOptional">Optional</span> id<wbr>Token</h3>
<div class="tsd-signature tsd-kind-icon">id<wbr>Token<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></div>
<div class="tsd-signature tsd-kind-icon">id<wbr>Token<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/session.ts#L27">src/session/session.ts:27</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/session.ts#L27">src/session/session.ts:27</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -205,10 +205,10 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> id<wbr>Token</h3>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="refreshtoken" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagOptional">Optional</span> refresh<wbr>Token</h3>
<div class="tsd-signature tsd-kind-icon">refresh<wbr>Token<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span></div>
<div class="tsd-signature tsd-kind-icon">refresh<wbr>Token<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/session.ts#L47">src/session/session.ts:47</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/session.ts#L47">src/session/session.ts:47</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -223,7 +223,7 @@ <h3>user</h3>
<div class="tsd-signature tsd-kind-icon">user<span class="tsd-signature-symbol">:</span> <a href="../interfaces/session_session.claims.html" class="tsd-signature-type" data-tsd-kind="Interface">Claims</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/session/session.ts#L22">src/session/session.ts:22</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/session/session.ts#L22">src/session/session.ts:22</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand Down
4 changes: 2 additions & 2 deletions docs/classes/utils_errors.accesstokenerror.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ <h3>constructor</h3>
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/utils/errors.ts#L7">src/utils/errors.ts:7</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/utils/errors.ts#L7">src/utils/errors.ts:7</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
Expand All @@ -142,7 +142,7 @@ <h3>code</h3>
<div class="tsd-signature tsd-kind-icon">code<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/3a3a747/src/utils/errors.ts#L7">src/utils/errors.ts:7</a></li>
<li>Defined in <a href="https://github.com/auth0/nextjs-auth0/blob/5c6ef50/src/utils/errors.ts#L7">src/utils/errors.ts:7</a></li>
</ul>
</aside>
</section>
Expand Down
Loading