-
Notifications
You must be signed in to change notification settings - Fork 381
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
# Conflicts: # src/handlers/profile.ts # tests/session/update-user.test.ts
# Conflicts: # src/auth0-session/transient-store.ts # src/config.ts
if (!session || !user) { | ||
return; | ||
} | ||
sessionCache.set(req, res, { ...session, user }); | ||
await sessionCache.set(req, res, { ...session, user }); |
There was a problem hiding this comment.
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 });
?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before.
📋 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
/await
s📎 References
https://github.com/panva/jose/releases/tag/v3.0.0
https://github.com/panva/jose/releases/tag/v4.0.0