How to add HMAC validation in callback?

Highlighted
Excursionist
12 2 0

how can I add hmac validation in verifyrequest callback? I'm having a hard time with my issue. I created my app using React node js.

 

Thanks!

 

router.get("*", verifyRequest(), async (ctx) => {
    if (
      typeof ctx.cookies.get("shopOrigin") === "undefined" &&
      typeof ctx.session.shop !== "undefined"
    ) {
      ctx.cookies.set("shopOrigin", ctx.session.shop, {
        httpOnly: false,
        sameSite: "none",
        secure: true,
      });
      ctx.redirect(ctx.req.url);
      return;
    }

    await handle(ctx.req, ctx.res);
    ctx.respond = false;
    ctx.res.statusCode = 200;
    console.log(`server responding: ${ctx.req.url}`);
    return;
  });

 

0 Likes
Highlighted
New Member
6 0 0

I used this library koa-shopify ... but might want to peruse the source code to find your solution:

https://github.com/Shopify/koa-shopify-auth/blob/master/src/auth/validate-hmac.ts

0 Likes
Highlighted
Excursionist
12 2 0

@parcelyze 

Thank you for your response.

where should I apply this? on the server.js or _app.js?

 

0 Likes