Repository: auth0/nextjs-auth0 (ts)

Issue:
Modify session in getServerSideProps with getAccessToken 
### Checklist

- [X] The issue can be reproduced in the [sample app](https://github.com/auth0-samples/auth0-nextjs-samples/tree/main/Sample-01) (or N/A).
- [X] I have looked into the [README](https://github.com/auth0/nextjs-auth0#readme) and have not found a suitable solution or answer.
- [X] I have looked into the [examples](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md) and have not found a suitable solution or answer.
- [X] I have looked into the [API documentation](https://auth0.github.io/nextjs-auth0/) and have not found a suitable solution or answer.
- [X] I have searched the [issues](https://github.com/auth0/nextjs-auth0/issues) and have not found a suitable solution or answer.
- [X] I have searched the [Auth0 Community](https://community.auth0.com/c/sdks/5) forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).

### Description

When I try to modify the session in getServerSideProps it works fine.  

```
export const getServerSideProps = withPageAuthRequired({
  returnTo: '/',
  async getServerSideProps(ctx) {
    const session = getSession(ctx.req, ctx.res);
    if (session) {
      session.test = 'Hello World';
    }
    return { props: {} };
  },
});

```

But when I want to get a new access token via `getAccessToken` function and modify the session with `afterRefresh` method it does not work. 

```
 export const getServerSideProps = withPageAuthRequired({
  returnTo: '/',
  async getServerSideProps(ctx) {
    await getAccessToken(ctx.req, ctx.res, {
      afterRefresh: async (_req, _res, session) => {
        session.test = 'Hello World';
        return session;
      },
    });
    return { props: {} };
  },
});
```

And when I check my session looks like the session is not updated. Is it a bug or expected behavior? 

If it's not a bug how I must update my session with `afterRefresh` method? And I didn't find any example for this case 


### Reproduction

```
 export const getServerSideProps = withPageAuthRequired({
  returnTo: '/',
  async getServerSideProps(ctx) {
    await getAccessToken(ctx.req, ctx.res, {
      afterRefresh: async (_req, _res, session) => {
        session.test = 'Hello World';
        return session;
      },
    });
    return { props: {} };
  },
});
```

### SDK version

1.9.0

### Next.js version

10.2.3

### Node.js version

v16.13.0

Pull request:
Fix updates to session not reflected in async `getServerSideProps`
### 📋 Changes

Fixed an issue where changes to session weren't being updated if they were made in async `getServerSideProps`

### 📎 References

Fixes #841 


Patch:
diff --git a/src/helpers/get-server-side-props-wrapper.ts b/src/helpers/get-server-side-props-wrapper.ts
index 9d3ab298..0420b6fb 100644
--- a/src/helpers/get-server-side-props-wrapper.ts
+++ b/src/helpers/get-server-side-props-wrapper.ts
@@ -40,11 +40,11 @@ export type GetServerSidePropsWrapper<P = any, Q extends ParsedUrlQuery = Parsed
  */
 export default function getServerSidePropsWrapperFactory(getSessionCache: () => SessionCache) {
   return function getServerSidePropsWrapper(getServerSideProps: GetServerSideProps): GetServerSideProps {
-    return function wrappedGetServerSideProps(...args) {
+    return async function wrappedGetServerSideProps(...args) {
       const sessionCache = getSessionCache();
       const [ctx] = args;
       sessionCache.init(ctx.req, ctx.res, false);
-      const ret = getServerSideProps(...args);
+      const ret = await getServerSideProps(...args);
       sessionCache.save(ctx.req, ctx.res);
       return ret;
     };


Test patch:
diff --git a/tests/helpers/with-page-auth-required.test.ts b/tests/helpers/with-page-auth-required.test.ts
index 4dee56cf..049f749a 100644
--- a/tests/helpers/with-page-auth-required.test.ts
+++ b/tests/helpers/with-page-auth-required.test.ts
@@ -100,4 +100,25 @@ describe('with-page-auth-required ssr', () => {
     const [cookie] = headers['set-cookie'];
     expect(cookie).toMatch(/^appSession=/);
   });
+
+  test('save session when getServerSideProps completes async', async () => {
+    const baseUrl = await setup(withoutApi, {
+      withPageAuthRequiredOptions: {
+        async getServerSideProps(ctx) {
+          await Promise.resolve();
+          const session = (global as any).getSession(ctx.req, ctx.res);
+          session.test = 'Hello World!';
+          return { props: {} };
+        }
+      }
+    });
+    const cookieJar = await login(baseUrl);
+
+    const {
+      res: { statusCode }
+    } = await get(baseUrl, '/protected', { cookieJar, fullResponse: true });
+    expect(statusCode).toBe(200);
+    const session = await get(baseUrl, '/api/session', { cookieJar });
+    expect(session.test).toBe('Hello World!');
+  });
 });