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(core): add me & expose functions and models #4

Merged
merged 12 commits into from
Apr 30, 2024

Conversation

movinsilva
Copy link
Contributor

@movinsilva movinsilva commented Apr 22, 2024

Purpose

  • add me function
  • expose required functions from the package
  • expose required models from the package

Related Issues

Related PRs

Checklist

  • e2e cypress tests locally verified.
  • Manual test round performed and verified.
  • UX/UI review done on the final implementation.
  • Documentation provided. (Add links if there are any)
  • Unit tests provided. (Add links if there are any)
  • Integration tests provided. (Add links if there are any)

Security checks

packages/core/src/api/profile.ts Show resolved Hide resolved
Comment on lines 28 to 41
try {
baseUrl = (await AuthClient.getInstance().getDataLayer().getConfigData()).baseUrl;
accessToken = await AuthClient.getInstance().getAccessToken();
} catch (error) {
throw new AsgardeoUIException(
'JS_UI_CORE-ME-M-NF',
'Failed in getting the base URL and access token.',
error.stack,
);
}

if (!accessToken) {
throw new AsgardeoUIException('JS_UI_CORE-ME-M-IV', 'Access token is null.');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we extract this logic to a reusable function? Retrieving the access token is going to be reused by many methods I guess.

Ideally, it should be the end users responsibility to pass the correct payload and headers to getProfileInformation function. The SDK should not make token requests for each API call, IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the core SDK, only this function is getting the access token. So retrieving access token won't be reused.

End user will be accessing either a custom hook to get user information or will use the profile component directly. In these scenarios we cannot expect the the end user to pass any payload or headers, as it will degrade the user experience.

@pavinduLakshan pavinduLakshan merged commit 582b5fb into asgardeo:main Apr 30, 2024
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.

2 participants