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

Add SLAS social login helper #172

Merged
merged 28 commits into from
Oct 7, 2024
Merged

Add SLAS social login helper #172

merged 28 commits into from
Oct 7, 2024

Conversation

yunakim714
Copy link
Contributor

@yunakim714 yunakim714 commented Sep 12, 2024

In order to implement social login in the PWA Kit and enable this feature for our customers, we need a social login helper in commerce-sdk-isomorphic.

GUS: W-16543984

Changes

  • Add a SLAS login helper for IDP (social) login
    • This was split into 2 helpers: authorizeIDP and loginIDPUser BECAUSE:
      • The authorizeCustomer returns an auth URL that has to be navigated to from the top level browser in order for the app to be properly redirected to the 3rd party login page and for the user to be able to input their login credentials
      • Once the 3rd party login is complete, the retail app will call loginIDPUser to exchange the usid and code for an access token
  • Add apiPaths readonly map to the client template that maps the API names to the API path

Testing

  • Run yarn test and verify that all tests pass

E2e test:

  • Go to https://wasatch-mrt-yuna.mrt-storefront-staging.com/ in an incognito window
  • Click on the login modal
  • Open Chrome DevTools and navigate to the Network tab
  • Click on Login with Google
  • Verify that you are redirected to the Google login page
  • Once login is complete, you should be redirected back to the women's tops page (I have just set this as the redirect URL for now)
  • Verify that the token call is in the Network tab and you see the access token in the response

@yunakim714 yunakim714 marked this pull request as ready for review September 17, 2024 15:40
@yunakim714 yunakim714 requested a review from a team as a code owner September 17, 2024 15:40
@yunakim714 yunakim714 changed the title Add social login helper to slasHelper.ts Add SLAS social login helper Sep 17, 2024
Comment on lines +120 to +126
interface ClientOptions {
codeChallenge?: string;
}
const clientOptions: ClientOptions = {};
if (!privateClient) {
clientOptions.codeChallenge = await generateCodeChallenge(codeVerifier);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only generating the codeChallenge for private clients

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean for public clients? Since the if statement said "if NOT privateClient"

Copy link
Contributor

Choose a reason for hiding this comment

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

@yunakim714 I checked the SLAS doc, it seems that codeChallege is still needed for private client. Check here for registerer users flow, it requires code_challenge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SLAS team are working on changing the RAML now to make this optional - thread here

Copy link

Choose a reason for hiding this comment

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

Has this thread come to a resolution? Or was there simply a typo in the first comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bendvc @alexvuong Ah yes, I meant only generating the codeChallenge for public clients😅

@@ -93,6 +93,14 @@ export class {{name.upperCamelCase}}<ConfigParameters extends {{{name.upperCamel

static readonly defaultBaseUri = "{{getBaseUriFromDocument model}}";

static readonly apiPaths = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Creates a read only apiPaths object that maps the API endpoint name to the API path

src/static/helpers/slasHelper.ts Outdated Show resolved Hide resolved
src/static/helpers/slasHelper.ts Outdated Show resolved Hide resolved
@yunakim714 yunakim714 merged commit b4161fa into main Oct 7, 2024
8 checks passed
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.

5 participants