@steemit/steem-js 1.0.19 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -23528,18 +23528,34 @@ const verifySignature = (message, signature, publicKey) => {
23528
23528
  return false;
23529
23529
  }
23530
23530
  };
23531
+ // Serialize a transaction to its binary form for digest calculation.
23532
+ // Alias for transaction.toBuffer() so verifyTransaction mirrors signTransaction's
23533
+ // serialization path exactly (signTransaction calls transaction.toBuffer at line 161).
23534
+ const serializeTrx = (trx) => transaction.toBuffer(trx);
23531
23535
  const verifyTransaction = (transaction, publicKey) => {
23532
23536
  try {
23533
23537
  const pub = PublicKey.fromString(publicKey);
23534
23538
  if (!pub)
23535
23539
  return false;
23536
- const serialized = Buffer.from(JSON.stringify(transaction));
23537
23540
  const trx = transaction;
23538
23541
  if (!trx.signatures || !Array.isArray(trx.signatures))
23539
23542
  return false;
23543
+ // Reconstruct the exact digest signTransaction signs over:
23544
+ // Buffer.concat([chain_id, transaction.toBuffer(normalizedTrx)])
23545
+ // signatures are NOT part of the signed digest — signTransaction serializes
23546
+ // BEFORE attaching signatures — so strip them before serializing, otherwise
23547
+ // serializeTransaction() would emit the signatures array and change the digest.
23548
+ const normalizedTrx = normalizeTransactionForBroadcast(trx);
23549
+ // Build a copy without the signatures key, so serializeTransaction() does not
23550
+ // emit the signatures array into the digest (signTransaction serializes pre-signature).
23551
+ const trxWithoutSigs = { ...normalizedTrx };
23552
+ delete trxWithoutSigs.signatures;
23553
+ const chainId = getConfig().get('chain_id') || '';
23554
+ const cid = Buffer.from(chainId, 'hex');
23555
+ const buf = serializeTrx(trxWithoutSigs);
23540
23556
  return trx.signatures.some((sig) => {
23541
23557
  const signature = Signature.fromHex(sig);
23542
- return signature.verifyBuffer(serialized, pub);
23558
+ return signature.verifyBuffer(Buffer.concat([cid, buf]), pub);
23543
23559
  });
23544
23560
  }
23545
23561
  catch {
@@ -23584,6 +23600,7 @@ const auth = /*#__PURE__*/Object.freeze({
23584
23600
  normalizeTransactionForBroadcast: normalizeTransactionForBroadcast,
23585
23601
  resolveAuthorityForSerialize: resolveAuthorityForSerialize,
23586
23602
  sanitizeAccountUpdatePayload: sanitizeAccountUpdatePayload,
23603
+ serializeTransaction: serializeTransaction,
23587
23604
  sign: sign$1,
23588
23605
  signTransaction: signTransaction,
23589
23606
  toWif: toWif,
@@ -26392,7 +26409,7 @@ const steem = {
26392
26409
  memo,
26393
26410
  operations,
26394
26411
  utils: utils$3,
26395
- version: '1.0.19',
26412
+ version: '1.0.20',
26396
26413
  config: {
26397
26414
  set: (options) => {
26398
26415
  // If nodes is provided, extract the first node as url for API