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

Interoperability for test helpers #1939

Open
aaronadamsCA opened this issue Jan 7, 2025 · 4 comments
Open

Interoperability for test helpers #1939

aaronadamsCA opened this issue Jan 7, 2025 · 4 comments

Comments

@aaronadamsCA
Copy link

We'd like to be able to use the setUpValidRequest() and setUpValidSession() test helpers in a browser environment. Right now they only work in a Node.js environment, and I haven't had any luck with polyfills.

Our use case is mocking Shopify app authentication in Storybook.

For now we've rolled our own interoperable helpers with two main changes.

We're using Jose for JWT signing:

return new SignJWT(payload)
  .setProtectedHeader({ alg: "HS256" })
  .sign(new TextEncoder().encode(CLIENT_SECRET));

And we're using btoa() (which is not deprecated in Node.js!) to encode the host:

const BASE64_HOST = btoa(SHOPIFY_HOST);

With these changes we get interop across multiple runtimes.

@lizkenyon
Copy link
Contributor

Hi there 👋

Thanks for the flag! If you would like to contribute a PR, for these changes the team would prioritize reviewing.

@aaronadamsCA
Copy link
Author

Thanks @lizkenyon, IMHO the team should probably figure out how the tests would work first. Before making any changes I'd want to know they'd be tested in both Node.js and browser environments going forward.

Without that there's a pretty good chance my PR would break someone else's environment, or someone else's future PR would break mine.

Copy link
Contributor

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

@github-actions github-actions bot added the Stale label Mar 19, 2025
@aaronadamsCA
Copy link
Author

Not stale.

@github-actions github-actions bot removed the Stale label Mar 26, 2025
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

2 participants