Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-3570] Upgrade to Jose@4 #798

Merged
merged 7 commits into from
Sep 7, 2022
Merged

[SDK-3570] Upgrade to Jose@4 #798

merged 7 commits into from
Sep 7, 2022

Conversation

adamjmcgrath
Copy link
Contributor

@adamjmcgrath adamjmcgrath commented Aug 31, 2022

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

Have upgraded jose from 2 -> 4 - this is a requirement for running the SDK on Vercel Edge Middleware (and other edge runtimes). cookie read/save is now async so there are a bunch of changes to make accessing/updating the session async.

Main changes are:

Then adding a bunch of async / awaits

📎 References

https://github.com/panva/jose/releases/tag/v3.0.0
https://github.com/panva/jose/releases/tag/v4.0.0

@adamjmcgrath adamjmcgrath requested a review from a team as a code owner August 31, 2022 10:14
@vercel
Copy link

vercel bot commented Aug 31, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
nextjs-auth0 ⬜️ Ignored (Inspect) Sep 6, 2022 at 8:39AM (UTC)

# Conflicts:
#	src/handlers/profile.ts
#	tests/session/update-user.test.ts
src/auth0-session/cookie-store.ts Outdated Show resolved Hide resolved
src/auth0-session/transient-store.ts Outdated Show resolved Hide resolved
src/auth0-session/utils/p-any.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
if (!session || !user) {
return;
}
sessionCache.set(req, res, { ...session, user });
await sessionCache.set(req, res, { ...session, user });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this last await necessary, or could it be just return sessionCache.set(req, res, { ...session, user });?

Copy link
Contributor Author

@adamjmcgrath adamjmcgrath Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do either. It only really makes a difference when you're using try/catch statements

try {
  return promise;
} catch () {};

// is very different from
try {
  return await promise;
} catch () {};

Also, returning from updateUser would change the function return type from Promise<void> to Promise, whilst being practically equivalent - I think for a function that shouldn't return anything Promise` is probably more suitable

this.cache.set(req, session);
this.save(req, res);
await this.save(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this last await necessary, or could it be just return this.save(req, res);?

this.cache.set(req, null);
this.save(req, res);
await this.save(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.

this.cache.set(req, session);
this.save(req, res);
await this.save(req, res);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.

save(req: NextApiOrPageRequest, res: NextApiOrPageResponse): void {
this.cookieStore.save(req, res, this.cache.get(req), this.iatCache.get(req));
async save(req: NextApiOrPageRequest, res: NextApiOrPageResponse): Promise<void> {
await this.cookieStore.save(req, res, this.cache.get(req), this.iatCache.get(req));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.

@adamjmcgrath adamjmcgrath merged commit b4e96e5 into vNext Sep 7, 2022
@adamjmcgrath adamjmcgrath deleted the jose4 branch September 7, 2022 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants