dolcalmi / stellar-auth-server

Server side library for Stellar SEP 0010 implementation
MIT License
3 stars 1 forks source link

XDR Write Error: [object Object] is not a DecoratedSignature #15

Open denyncrawford opened 3 years ago

denyncrawford commented 3 years ago

Hi, I'm trying to generate a challenge with this module and this error shows up: XDR Write Error: [object Object] is not a DecoratedSignature

This is my code:

const serverSecret = process.env.SERVER_SECRET_KEY;
const serverKeyPair = Keypair.fromSecret(serverSecret);
const authenticator = new StellarAuth(serverKeyPair)

....

router.get('/', async (req, res) => {
  const { account: clientPublicKey } = req.query;
  try {
    const transaction = authenticator.challenge(clientPublicKey); // <--------- Here is the error happening
    res.json({ transaction });
  } catch (e) {
    return res.status(400).json(badRequest(e.message));
  }
})

router.post('/', async (req, res) => {
  const { transaction } = req.body;
  try {
    const { result: { hash, clientPublicKey } } = await authenticator.verify(transaction);
    const token = createStellarToken(clientPublicKey, hash);
    res.json({ token });
  } catch (e) {
    return res.status(400).json(badRequest(e));
  }
})

Can this be related to a stellar-sdk problem? Or am I doing something wrong?

denyncrawford commented 3 years ago

I think this could be related to this issue https://github.com/stellar/js-stellar-sdk/issues/294 and this line https://github.com/dolcalmi/stellar-auth-server/blob/1576ccef02eacb8c8cea133b81b857270dcc58cc/lib/challenge.js#L40