@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.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import * as buffer from 'buffer';
3
+ import { Buffer as Buffer$1 } from 'buffer';
3
4
 
4
5
  class Config {
5
6
  constructor() {
@@ -14440,8 +14441,39 @@ function randomBytes(size) {
14440
14441
  /**
14441
14442
  * Signing constant used to reserve opcode space and prevent cross-protocol attacks.
14442
14443
  * Output of `sha256('steem_jsonrpc_auth')`.
14444
+ * Using lazy initialization to avoid Buffer dependency issues in UMD builds.
14443
14445
  */
14444
- const K = Buffer.from('3b3b081e46ea808d5a96b08c4bc5003f5e15767090f344faab531ec57565136b', 'hex');
14446
+ let _K = null;
14447
+ function getK() {
14448
+ if (!_K) {
14449
+ _K = Buffer.from('3b3b081e46ea808d5a96b08c4bc5003f5e15767090f344faab531ec57565136b', 'hex');
14450
+ }
14451
+ return _K;
14452
+ }
14453
+ // Create a Proxy to make K behave like a Buffer but with lazy initialization
14454
+ // This avoids executing Buffer.from() at module load time when Buffer may not be available in UMD builds
14455
+ new Proxy({}, {
14456
+ get(_target, prop) {
14457
+ const k = getK();
14458
+ const value = k[prop];
14459
+ if (typeof value === 'function') {
14460
+ return value.bind(k);
14461
+ }
14462
+ return value;
14463
+ },
14464
+ has(_target, prop) {
14465
+ const k = getK();
14466
+ return prop in k;
14467
+ },
14468
+ ownKeys(_target) {
14469
+ const k = getK();
14470
+ return Object.keys(k);
14471
+ },
14472
+ getOwnPropertyDescriptor(_target, prop) {
14473
+ const k = getK();
14474
+ return Object.getOwnPropertyDescriptor(k, prop);
14475
+ }
14476
+ });
14445
14477
  /**
14446
14478
  * Create request hash to be signed.
14447
14479
  *
@@ -14463,7 +14495,7 @@ function hashMessage(timestamp, account, method, params, nonce) {
14463
14495
  ]);
14464
14496
  const firstHash = Buffer.from(sha256$2(firstInput));
14465
14497
  // Second hash: sha256(K + firstHash + nonce)
14466
- const secondInput = Buffer.concat([K, firstHash, nonce]);
14498
+ const secondInput = Buffer.concat([getK(), firstHash, nonce]);
14467
14499
  return Buffer.from(sha256$2(secondInput));
14468
14500
  }
14469
14501
  /**
@@ -14557,7 +14589,6 @@ async function validate(request, verify) {
14557
14589
 
14558
14590
  const rpcAuth = /*#__PURE__*/Object.freeze({
14559
14591
  __proto__: null,
14560
- K: K,
14561
14592
  sign: sign$2,
14562
14593
  validate: validate
14563
14594
  });
@@ -25570,6 +25601,23 @@ const steem = {
25570
25601
  if (typeof setApi === 'function') {
25571
25602
  setApi(api);
25572
25603
  }
25604
+ // Make Buffer available globally for browser builds (ESM and UMD)
25605
+ // Browser doesn't have native Buffer, so we use the buffer polyfill package
25606
+ if (typeof window !== 'undefined' || typeof globalThis !== 'undefined') {
25607
+ try {
25608
+ // BufferPolyfill is imported from 'buffer' package (polyfill for browser)
25609
+ // Expose it globally so code can use Buffer directly
25610
+ if (typeof globalThis !== 'undefined' && typeof globalThis.Buffer === 'undefined') {
25611
+ globalThis.Buffer = Buffer$1;
25612
+ }
25613
+ if (typeof window !== 'undefined' && typeof window.Buffer === 'undefined') {
25614
+ window.Buffer = Buffer$1;
25615
+ }
25616
+ }
25617
+ catch {
25618
+ // Buffer should be available from the inject plugin transformation
25619
+ }
25620
+ }
25573
25621
 
25574
25622
  export { doubleSha256, generateKeyPair, hmacSha256, ripemd160, sha256, sign, steem, verify };
25575
25623
  //# sourceMappingURL=index.js.map