@steemit/steem-js 1.0.6 → 1.0.8

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.
@@ -17,11 +17,7 @@ interface SignedRequest {
17
17
  };
18
18
  };
19
19
  }
20
- /**
21
- * Signing constant used to reserve opcode space and prevent cross-protocol attacks.
22
- * Output of `sha256('steem_jsonrpc_auth')`.
23
- */
24
- export declare const K: Buffer<ArrayBuffer>;
20
+ export declare const K: Buffer;
25
21
  /**
26
22
  * Sign a JSON RPC Request.
27
23
  */
@@ -38,6 +34,6 @@ export declare function validate(request: SignedRequest, verify: (message: Buffe
38
34
  declare const _default: {
39
35
  sign: typeof sign;
40
36
  validate: typeof validate;
41
- K: Buffer<ArrayBuffer>;
37
+ readonly K: Buffer<ArrayBufferLike>;
42
38
  };
43
39
  export default _default;
@@ -23,26 +23,9 @@
23
23
  })();
24
24
  // Define utilExports in global scope for replace plugin (utilExports.format -> utilExports.format)
25
25
  var utilExports = typeof globalThis !== 'undefined' ? (globalThis.utilExports || (globalThis.utilExports = {})) : (typeof window !== 'undefined' ? (window.utilExports || (window.utilExports = {})) : {});
26
- // Make Buffer available globally (injected by @rollup/plugin-inject)
27
- // The inject plugin will replace Buffer references with require('buffer').Buffer
28
- // We need to ensure it's also available on globalThis/window for direct access
29
- (function() {
30
- if (typeof Buffer === 'undefined') {
31
- try {
32
- var bufferModule = typeof require !== 'undefined' ? require('buffer') : null;
33
- if (bufferModule && bufferModule.Buffer) {
34
- var Buffer = bufferModule.Buffer;
35
- var g = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
36
- g.Buffer = Buffer;
37
- if (typeof globalThis !== 'undefined') {
38
- globalThis.Buffer = Buffer;
39
- }
40
- }
41
- } catch(e) {
42
- // Buffer will be available from the bundled code
43
- }
44
- }
45
- })();
26
+ // Buffer will be set in src/index.ts after importing buffer module
27
+ // The inject plugin will replace Buffer references with buffer.Buffer in the code
28
+
46
29
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
47
30
 
48
31
  function getDefaultExportFromCjs (x) {
@@ -17496,8 +17479,39 @@ function randomBytes(size) {
17496
17479
  /**
17497
17480
  * Signing constant used to reserve opcode space and prevent cross-protocol attacks.
17498
17481
  * Output of `sha256('steem_jsonrpc_auth')`.
17482
+ * Using lazy initialization to avoid Buffer dependency issues in UMD builds.
17499
17483
  */
17500
- const K = bufferExports.Buffer.from('3b3b081e46ea808d5a96b08c4bc5003f5e15767090f344faab531ec57565136b', 'hex');
17484
+ let _K = null;
17485
+ function getK() {
17486
+ if (!_K) {
17487
+ _K = bufferExports.Buffer.from('3b3b081e46ea808d5a96b08c4bc5003f5e15767090f344faab531ec57565136b', 'hex');
17488
+ }
17489
+ return _K;
17490
+ }
17491
+ // Create a Proxy to make K behave like a Buffer but with lazy initialization
17492
+ // This avoids executing Buffer.from() at module load time when Buffer may not be available in UMD builds
17493
+ new Proxy({}, {
17494
+ get(_target, prop) {
17495
+ const k = getK();
17496
+ const value = k[prop];
17497
+ if (typeof value === 'function') {
17498
+ return value.bind(k);
17499
+ }
17500
+ return value;
17501
+ },
17502
+ has(_target, prop) {
17503
+ const k = getK();
17504
+ return prop in k;
17505
+ },
17506
+ ownKeys(_target) {
17507
+ const k = getK();
17508
+ return Object.keys(k);
17509
+ },
17510
+ getOwnPropertyDescriptor(_target, prop) {
17511
+ const k = getK();
17512
+ return Object.getOwnPropertyDescriptor(k, prop);
17513
+ }
17514
+ });
17501
17515
  /**
17502
17516
  * Create request hash to be signed.
17503
17517
  *
@@ -17519,7 +17533,7 @@ function hashMessage(timestamp, account, method, params, nonce) {
17519
17533
  ]);
17520
17534
  const firstHash = bufferExports.Buffer.from(sha256$2(firstInput));
17521
17535
  // Second hash: sha256(K + firstHash + nonce)
17522
- const secondInput = bufferExports.Buffer.concat([K, firstHash, nonce]);
17536
+ const secondInput = bufferExports.Buffer.concat([getK(), firstHash, nonce]);
17523
17537
  return bufferExports.Buffer.from(sha256$2(secondInput));
17524
17538
  }
17525
17539
  /**
@@ -17613,7 +17627,6 @@ async function validate(request, verify) {
17613
17627
 
17614
17628
  const rpcAuth = /*#__PURE__*/Object.freeze({
17615
17629
  __proto__: null,
17616
- K: K,
17617
17630
  sign: sign$2,
17618
17631
  validate: validate
17619
17632
  });
@@ -28900,6 +28913,7 @@ const steem = {
28900
28913
  operations,
28901
28914
  serializer,
28902
28915
  utils: utils$3,
28916
+ version: '1.0.8',
28903
28917
  config: {
28904
28918
  set: (options) => {
28905
28919
  setOptions(options);
@@ -28916,6 +28930,23 @@ const steem = {
28916
28930
  if (typeof setApi === 'function') {
28917
28931
  setApi(api);
28918
28932
  }
28933
+ // Make Buffer available globally for browser builds (ESM and UMD)
28934
+ // Browser doesn't have native Buffer, so we use the buffer polyfill package
28935
+ if (typeof window !== 'undefined' || typeof globalThis !== 'undefined') {
28936
+ try {
28937
+ // BufferPolyfill is imported from 'buffer' package (polyfill for browser)
28938
+ // Expose it globally so code can use Buffer directly
28939
+ if (typeof globalThis !== 'undefined' && typeof globalThis.Buffer === 'undefined') {
28940
+ globalThis.Buffer = bufferExports.Buffer;
28941
+ }
28942
+ if (typeof window !== 'undefined' && typeof window.Buffer === 'undefined') {
28943
+ window.Buffer = bufferExports.Buffer;
28944
+ }
28945
+ }
28946
+ catch {
28947
+ // Buffer should be available from the inject plugin transformation
28948
+ }
28949
+ }
28919
28950
 
28920
28951
  export { doubleSha256, generateKeyPair, hmacSha256, ripemd160, sha256, sign, steem, verify };
28921
28952
  //# sourceMappingURL=browser.esm.js.map