postchain-client 1.14.0 → 1.15.0

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/README.md CHANGED
@@ -317,8 +317,9 @@ chromiaClient
317
317
  This example demonstrates that you can use external signing mechanisms. It could involve a complex function requiring you to sign from your phone, another device, or a different method.
318
318
 
319
319
  ```typescript
320
- function askUserBToSign(buffer) {
321
- return Buffer.from(secp256k1.ecdsaSign(buffer, signerPrivKeyB).signature);
320
+ function askUserBToSign(rawGtxBody) {
321
+ const digest = getDigestToSignFromRawGtxBody(rawGtxBody);
322
+ return Buffer.from(secp256k1.ecdsaSign(digest, signerPrivKeyB).signature);
322
323
  }
323
324
  ```
324
325
 
@@ -1764,8 +1764,9 @@ function sign(gtx, privOrSigProv, pubKey) {
1764
1764
  return addSignature(pubKey || makeKeyPair(privOrSigProv).pubKey, signature, gtx);
1765
1765
  }
1766
1766
  else {
1767
- const digestToSign = getDigestToSign(gtx);
1768
- const signature = yield privOrSigProv.sign(digestToSign);
1767
+ // Removes signatures and extract the rawgtxBody
1768
+ const rawGtxBody = gtxToRawGtxBody(gtx);
1769
+ const signature = yield privOrSigProv.sign(rawGtxBody);
1769
1770
  return addSignature(privOrSigProv.pubKey, signature, gtx);
1770
1771
  }
1771
1772
  });
@@ -1848,7 +1849,10 @@ function newSignatureProvider(keyPair) {
1848
1849
  }
1849
1850
  return {
1850
1851
  pubKey: pub,
1851
- sign: (digest) => __awaiter$c(this, void 0, void 0, function* () { return signDigest(digest, priv); }),
1852
+ sign: (gtx) => __awaiter$c(this, void 0, void 0, function* () {
1853
+ const signature = getDigestToSignFromRawGtxBody(gtx);
1854
+ return signDigest(signature, priv);
1855
+ }),
1852
1856
  };
1853
1857
  }
1854
1858
  function rawGtvToGtx(gtv) {
@@ -4164,6 +4168,7 @@ exports.encryption = encryption$1;
4164
4168
  exports.formatter = formatter;
4165
4169
  exports.getAnchoringClient = getAnchoringClient;
4166
4170
  exports.getBlockAnchoringTransaction = getBlockAnchoringTransaction;
4171
+ exports.getDigestToSignFromRawGtxBody = getDigestToSignFromRawGtxBody;
4167
4172
  exports.getTransactionRidException = getTransactionRidException;
4168
4173
  exports.gtv = index;
4169
4174
  exports.gtx = gtx;