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

Define a type for getAccessTokenPayloadSecurely in Session #865

Open
guillempuche opened this issue Nov 8, 2024 · 0 comments
Open

Define a type for getAccessTokenPayloadSecurely in Session #865

guillempuche opened this issue Nov 8, 2024 · 0 comments

Comments

@guillempuche
Copy link

guillempuche commented Nov 8, 2024

any type in getAccessTokenPayloadSecurely isn't not helping making our code cleanr. Docs https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/sessions/claims/access-token-payload#reading-the-payload-on-the-frontend says it can return an object.

import Session from 'supertokens-web-js/recipe/session';

async function someFunc() {
      if (await Session.doesSessionExist()) {
            let accessTokenPayload = await Session.getAccessTokenPayloadSecurely();
            let customClaimValue = accessTokenPayload.customClaim
      }
}

// supertokens-auth-react/recipe/session/index.d.ts

    static getAccessToken(input?: { userContext?: UserContext }): Promise<string | undefined>;
    static getAccessTokenPayloadSecurely(input?: { userContext?: UserContext }): Promise<any>;

Could you replace any for something like type | undefined to improve cases like mine:

import { Data, type Either, type Option } from 'effect'

export type Listener = {
	initialized: () => void
	sessionUpdated: (
		session: Either.Either<
			Option.Option<SessionPayload>,
			ErrorAbc
		>,
	) => void
}
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

No branches or pull requests

1 participant