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

feat: Add getInitialSessionAuthContext to compute SessionAuth context #785

Conversation

sasha240100
Copy link

@sasha240100 sasha240100 commented Jan 24, 2024

Summary of change

Adds getInitialSessionAuthContext to support computing initial SessionAuth context (to be used with initialSessionAuthContext property from supertokens/supertokens-auth-react#789)

Related issues

Test Plan

Tested locally on a NextJS implementation using supertokens. getInitialSessionAuthContext(session) creates an SSR session context that works like expected when passed into initialSessionAuthContext={} of <SessionAuth /> component. Also covered by unit tests

Documentation changes

TODO.

(If relevant, please create a PR in our docs repo, or create a checklist here highlighting the necessary changes)

Checklist for important updates

  • Changelog has been updated
  • coreDriverInterfaceSupported.json file has been updated (if needed)
    • Along with the associated array in lib/ts/version.ts
  • frontendDriverInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In package.json
    • In package-lock.json
    • In lib/ts/version.ts
  • Had run npm run build-pretty
  • Had installed and ran the pre-commit hook
  • If new thirdparty provider is added,
    • update switch statement in recipe/thirdparty/providers/configUtils.ts file, createProvider function.
    • add an icon on the user management dashboard.
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.
  • If have added a new web framework, update the add-ts-no-check.js file to include that
  • If added a new recipe / api interface, then make sure that the implementation of it uses NON arrow functions only (like someFunc: function () {..}).
  • If added a new recipe, then make sure to expose it inside the recipe folder present in the root of this repo. We also need to expose its types.

Remaining TODOs for this PR

  • Add to documentation

Copy link

netlify bot commented Jan 24, 2024

Deploy Preview for astounding-pegasus-21c111 canceled.

Name Link
🔨 Latest commit 7de5b21
🔍 Latest deploy log https://app.netlify.com/sites/astounding-pegasus-21c111/deploys/65b388046570070008f245d4

@sasha240100 sasha240100 changed the title feat: Add getInitialSessionAuthContext to compute SessionAuth context [Draft] feat: Add getInitialSessionAuthContext to compute SessionAuth context Jan 24, 2024
Copy link

netlify bot commented Jan 24, 2024

Deploy Preview for precious-marshmallow-968a81 canceled.

Name Link
🔨 Latest commit 7de5b21
🔍 Latest deploy log https://app.netlify.com/sites/precious-marshmallow-968a81/deploys/65b388040816a70008aa421e

lib/ts/types.ts Outdated Show resolved Hide resolved
Comment on lines +119 to +120
isContextFromSSR: true;
loading: false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should not be required since they are static values.

Copy link
Author

Choose a reason for hiding this comment

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

But they are expected by supertokens-auth-react, if they will be optional - that means we would have to polyfill them inside SessionAuth component, and in that case I would rather remove them completely from supertokens-node

@sasha240100 sasha240100 marked this pull request as ready for review January 25, 2024 14:33
@sasha240100 sasha240100 changed the title [Draft] feat: Add getInitialSessionAuthContext to compute SessionAuth context feat: Add getInitialSessionAuthContext to compute SessionAuth context Jan 25, 2024
@@ -230,6 +230,24 @@ export default class NextJS {
return result;
}

static async getInitialSessionAuthContext(session: SessionContainer | undefined): Promise<SSRSessionContextType> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this function. And if we are going to keep it, why is it in the nextjs file?

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