postchain-client 1.14.0 → 1.15.1

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) {
@@ -1962,7 +1966,9 @@ const logLevelMap = {
1962
1966
  [LogLevel.Disabled]: -1,
1963
1967
  };
1964
1968
  const DEFAULT_LOG_LEVEL = logLevelMap[LogLevel.Warning];
1965
- let logLevel = (_a$1 = logLevelMap[process.env.LOG_LEVEL]) !== null && _a$1 !== void 0 ? _a$1 : DEFAULT_LOG_LEVEL;
1969
+ let logLevel = typeof process === "undefined"
1970
+ ? DEFAULT_LOG_LEVEL
1971
+ : (_a$1 = logLevelMap[process.env.LOG_LEVEL]) !== null && _a$1 !== void 0 ? _a$1 : DEFAULT_LOG_LEVEL;
1966
1972
  function setLogLevel(level) {
1967
1973
  if (typeof level === "number") {
1968
1974
  console.warn("Passing a number is deprecated, please use LogLevel enum instead");
@@ -3077,8 +3083,6 @@ var __awaiter$6 = (undefined && undefined.__awaiter) || function (thisArg, _argu
3077
3083
  step((generator = generator.apply(thisArg, _arguments || [])).next());
3078
3084
  });
3079
3085
  };
3080
- // eslint-disable-next-line @typescript-eslint/no-var-requires
3081
- require("web3-core-promievent");
3082
3086
  function getClientConfigFromSettings(settings) {
3083
3087
  var _a, _b, _c, _d;
3084
3088
  return __awaiter$6(this, void 0, void 0, function* () {
@@ -4156,6 +4160,7 @@ exports.TxRejectedError = TxRejectedError;
4156
4160
  exports.UnexpectedArgumentTypeError = UnexpectedArgumentTypeError;
4157
4161
  exports.UnexpectedResponseError = UnexpectedResponseError;
4158
4162
  exports.UnexpectedStatusError = UnexpectedStatusError;
4163
+ exports.Web3PromiEvent = Web3PromiEvent;
4159
4164
  exports.chromiaClient = chromiaClientProvider$1;
4160
4165
  exports.createClient = createClient;
4161
4166
  exports.createIccfProofTx = createIccfProofTx;
@@ -4164,6 +4169,7 @@ exports.encryption = encryption$1;
4164
4169
  exports.formatter = formatter;
4165
4170
  exports.getAnchoringClient = getAnchoringClient;
4166
4171
  exports.getBlockAnchoringTransaction = getBlockAnchoringTransaction;
4172
+ exports.getDigestToSignFromRawGtxBody = getDigestToSignFromRawGtxBody;
4167
4173
  exports.getTransactionRidException = getTransactionRidException;
4168
4174
  exports.gtv = index;
4169
4175
  exports.gtx = gtx;