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

[FEATURE] Shopper Context Integration #1757

Open
johnboxall opened this issue Apr 22, 2024 · 1 comment
Open

[FEATURE] Shopper Context Integration #1757

johnboxall opened this issue Apr 22, 2024 · 1 comment

Comments

@johnboxall
Copy link
Collaborator

johnboxall commented Apr 22, 2024

B2C Commerce API's Shopper Context allows setting the "context" of a shopper such that subsequent API requests take into account a shopper's customer groups, source codes, or other qualifiers when creating a response.

Today in the PWA Kit, no example Shopper Context usage is provided. It is possible through customization, but the steps to getting it working securely are non-trivial.

It would be nice if we provided an example of how to approach this!

Today, customers must:

  1. Create a new handler in ssr.js which accepts a SLAS JWT and a Shopper Context payload
  2. The handler validates the SLAS JWT using the JWKS endpoint. Libraries like jose can help, but this step is still error prone both in choosing what claims to validate and keeping within the endpoint's rate limit.
  3. The handler then gets the USID from the JWT
  4. A second private SLAS client with scopes sfcc.shopper-context.rw sfcc.ts_ext_on_behalf_of is used to get a System on Behalf Of JWT for the shopper.
  5. Finally, the shopper context payload is forwarded using the TSOB JWT.

Whew!

The overall request flow looks like this: https://gist.github.com/johnboxall/b824c4788bbc69d3fb6fab9a377af039
Sample code for validation looks like this: https://gist.github.com/johnboxall/6cc27a52eef1e95120a9ff9847243f67

In B2C Commerce 24.6, the addition of Shopper Context hooks will allow customers to call the Shopper Context endpoints more directly, removing the need for the Trusted System token dance assuming they add a hook to validate and allow context payloads they want shoppers to be able to set directly.

@johnboxall
Copy link
Collaborator Author

Initial Shopper Context integration was merged here: #2072

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