npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koa-shopify-graphql-proxy-cookieless

v1.0.11

Published

A cookieless version of the koa-shopify-graphql-proxy package with minor chages

Downloads

334

Readme

koa-shopify-graphql-proxy-cookieless

This is a fork of the Shopify quilt package https://github.com/Shopify/quilt/blob/master/packages/koa-shopify-graphql-proxy/README.md

This is not sponsored or endorsed by Shopify, or connected with Shopify in any way.

I'm providing this package as a reference for using with Shopify's Next Gen JWT-based Cookieless Auth.

Important

This is a near drop-in replacement for the official koa-shopify-graphql-proxy package, but make sure you don't import graphQLProxy as default, and use named imports instead:

import { graphQLProxy, ApiVersion } from "koa-shopify-graphql-proxy-cookieless";

Example

Here's the basic example:

router.post("/graphql", async (ctx, next) => {
    const bearer = ctx.request.header.authorization;
    const secret = process.env.SHOPIFY_API_SECRET;
    const valid = isVerified(bearer, secret);
    if (valid) {
      const token = bearer.split(" ")[1];
      const decoded = jwt.decode(token);
      const shop = new URL(decoded.dest).host;
      const proxy = graphQLProxy({
        shop: shop,
        // You will need to persist your token
        // somewhere like using AWS AppSync
        password: accessToken
        version: ApiVersion.July20,
      });
      await proxy(ctx, next);
    }
  });

NOTE:

You will need to use some kind of JWT verifcation mechanism along with AppBridge for this to work. The above example uses both of these packages:

https://www.npmjs.com/package/jsonwebtoken

https://www.npmjs.com/package/shopify-jwt-auth-verify

Please See This Tutorial On AppBridge

https://shopify.dev/tutorials/authenticate-your-app-using-session-tokens

See Working Demo

I've created a working demo based on the Shopify-CLI Node project.
https://github.com/nprutan/shopify-cookieless-auth-demo
If you'd like to see this in action, create a new Shopif-CLI project, and also clone the demo repo. Once you've cloned the demo, you can connect an existing Shopify project to the demo. Open a terminal in the demo directory and use the command: shopify connect