Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function App() {
const client = new ApolloClient({
link: new HttpLink({
credentials: 'same-origin',
fetch: authenticatedFetch(window.app), // created in shopify_app.js
uri: '/graphql'
}),
cache: new InMemoryCache()
});
return (
export default function protectedFetch(appBridge) {
const jwtFetch = authenticatedFetch(appBridge);
return async (uri, options) => {
const response = await jwtFetch(uri, options);
if (invalidUserAccessTokenError(response)) {
const { code, hmac, shop, timestamp } = await getAuthCode(appBridge);
const callback_uri = `auth/shopify/callback?code=${code}&hmac=${hmac}&shop=${shop}×tamp=${timestamp}`
const callback_response = await jwtFetch(callback_uri);
if (callback_response.status == 200) {
return jwtFetch(uri, options);
}
} else {
return response;
}
};
}