@steemit/steem-js 1.0.6 → 1.0.7

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.cjs CHANGED
@@ -14461,8 +14461,39 @@ function randomBytes(size) {
14461
14461
  /**
14462
14462
  * Signing constant used to reserve opcode space and prevent cross-protocol attacks.
14463
14463
  * Output of `sha256('steem_jsonrpc_auth')`.
14464
+ * Using lazy initialization to avoid Buffer dependency issues in UMD builds.
14464
14465
  */
14465
- const K = Buffer.from('3b3b081e46ea808d5a96b08c4bc5003f5e15767090f344faab531ec57565136b', 'hex');
14466
+ let _K = null;
14467
+ function getK() {
14468
+ if (!_K) {
14469
+ _K = Buffer.from('3b3b081e46ea808d5a96b08c4bc5003f5e15767090f344faab531ec57565136b', 'hex');
14470
+ }
14471
+ return _K;
14472
+ }
14473
+ // Create a Proxy to make K behave like a Buffer but with lazy initialization
14474
+ // This avoids executing Buffer.from() at module load time when Buffer may not be available in UMD builds
14475
+ new Proxy({}, {
14476
+ get(_target, prop) {
14477
+ const k = getK();
14478
+ const value = k[prop];
14479
+ if (typeof value === 'function') {
14480
+ return value.bind(k);
14481
+ }
14482
+ return value;
14483
+ },
14484
+ has(_target, prop) {
14485
+ const k = getK();
14486
+ return prop in k;
14487
+ },
14488
+ ownKeys(_target) {
14489
+ const k = getK();
14490
+ return Object.keys(k);
14491
+ },
14492
+ getOwnPropertyDescriptor(_target, prop) {
14493
+ const k = getK();
14494
+ return Object.getOwnPropertyDescriptor(k, prop);
14495
+ }
14496
+ });
14466
14497
  /**
14467
14498
  * Create request hash to be signed.
14468
14499
  *
@@ -14484,7 +14515,7 @@ function hashMessage(timestamp, account, method, params, nonce) {
14484
14515
  ]);
14485
14516
  const firstHash = Buffer.from(sha256$2(firstInput));
14486
14517
  // Second hash: sha256(K + firstHash + nonce)
14487
- const secondInput = Buffer.concat([K, firstHash, nonce]);
14518
+ const secondInput = Buffer.concat([getK(), firstHash, nonce]);
14488
14519
  return Buffer.from(sha256$2(secondInput));
14489
14520
  }
14490
14521
  /**
@@ -14578,7 +14609,6 @@ async function validate(request, verify) {
14578
14609
 
14579
14610
  var rpcAuth = /*#__PURE__*/Object.freeze({
14580
14611
  __proto__: null,
14581
- K: K,
14582
14612
  sign: sign$2,
14583
14613
  validate: validate
14584
14614
  });
@@ -25591,6 +25621,23 @@ const steem = {
25591
25621
  if (typeof setApi === 'function') {
25592
25622
  setApi(api);
25593
25623
  }
25624
+ // Make Buffer available globally for browser builds (ESM and UMD)
25625
+ // Browser doesn't have native Buffer, so we use the buffer polyfill package
25626
+ if (typeof window !== 'undefined' || typeof globalThis !== 'undefined') {
25627
+ try {
25628
+ // BufferPolyfill is imported from 'buffer' package (polyfill for browser)
25629
+ // Expose it globally so code can use Buffer directly
25630
+ if (typeof globalThis !== 'undefined' && typeof globalThis.Buffer === 'undefined') {
25631
+ globalThis.Buffer = buffer.Buffer;
25632
+ }
25633
+ if (typeof window !== 'undefined' && typeof window.Buffer === 'undefined') {
25634
+ window.Buffer = buffer.Buffer;
25635
+ }
25636
+ }
25637
+ catch {
25638
+ // Buffer should be available from the inject plugin transformation
25639
+ }
25640
+ }
25594
25641
 
25595
25642
  exports.doubleSha256 = doubleSha256;
25596
25643
  exports.generateKeyPair = generateKeyPair;