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 · 0 comments
Open

Interoperability for test helpers #1939

aaronadamsCA opened this issue Jan 7, 2025 · 0 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.

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