Eth-sig-utils problem on the front

I'm trying to use eth-sig-utils in the front end in order to sign a transaction using a private key (not metamask) and I can't. I read that it has some problems with buffers as it is not designed to be in the front but in:

you are using it in the front. Is there anyway to make this work?

I'm already running it using node and it works just fine.

const ethSigUtil = require('eth-sig-util');
  async function signTypedData(signer, from, data) {
      const privateKey = Buffer.from(signer.replace(/^0x/, ''), 'hex');
      return ethSigUtil.signTypedMessage(privateKey, { data });
  }

I'm trying to replicate that on the front using react or vite.

First of all, this is what the npm webpage has to say about eth-sig-util:
image

Second, the OZ link in your question does not seem to be related to all of this (you need to explain).

Third, you should explain what exactly the problem is (better than "I read that it has some problems").

Note that your function doesn't need to be declared async, and that the from parameter is redundant.

Hi, sorry. I'll try to explain myself better.

  1. Yes, I read that disclaimer, and I tried the other library, but with the same result. I kept trying to use Eth-Sig-Util afterwords as it was the library used in the workshop, and if it was working there, I should be able to replicate it somehow, then move to the other non-deprecated library.

  2. The link I left is the link I was trying to understand and replicate. They are using eth-sig-util for the signature process before sending things to the autotask of the relayer for the gassless transaction. I was trying to do the same. It worked perfectly on the back, but I couldn't make it work on the front.

For the info not used and the async matter, thanks. I was sending those to a log and doing a couple of extra things, but I ripped it in order to just study this problem. That's why the function stayed that way, but I don't think that would be an issue to stop working, isn't it? I mean, it is working on the backend.

  1. The problem is that I can't use Eth-Sig-Util or @metamask/eth-sig-util at the front end, and that's what I was trying to do. I tried running the code I wrote at the back, and it works fine. I tried putting it on the front, and it doesn't (for buffer problems, I think). I just needed to know if there was any way those libraries could be used on the front end. I guess there should be, because in the example I gave of OZ, they are using it, but I can't replicate it. I don't need a code review, just an explanation (or link to information) on how that is working. What I said about the "I read..." thing is that I investigated before asking, but I couldn't find an explanation on how the signature process with eth-sig-utils works in the workshop I linked here (the part with the metamask is ok, and I could replicate it easily).

I should also mention, just in case someone has the same problem I had, that I handled this issue by downgrading the etherjs version to 5.0.30 and using the _signTypedData method. The modern signTypedData was creating an entirely different signature and was not useful for the autotask of the example at least, and web3js signatures didn't work either for me (I think this is for the EIP712 compliance thing; I don't know if I can work on that but think it would be the next topic to address with the Defender tool).

Thank you very much, Barakman, and I hope these bullets clarify my doubts, which are mainly scientific as I already have the work around. I'm sorry if I wasn't clear before. I'm trying to learn how to use Defender in order to implement things for my job, but I'm in the learning process now.

Hey, I don't know if you're still active on this but am currently following the same guide and would appreciate some help.