@steemit/steem-js 1.0.0 → 1.0.2

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
@@ -11,15 +11,21 @@ This is a complete refactoring of the original steem-js library, migrating from
11
11
  - ✅ **TypeScript Migration**: Complete migration from JavaScript to TypeScript
12
12
  - ✅ **Build System**: Migrated from Webpack to Rollup
13
13
  - ✅ **Testing**: Migrated from Mocha to Vitest
14
+ - ✅ **Modern Dependencies (2024)**: Replaced outdated cryptographic libraries
15
+ - `bigi` → `bn.js` (modern big integer library)
16
+ - `ecurve` → `elliptic` (modern elliptic curve cryptography)
17
+ - Removed all shim layers for direct modern library usage
14
18
  - ✅ **Core Modules**: All core functionality implemented
15
19
  - API module with HTTP and WebSocket transports
16
20
  - Authentication and encryption (ECC secp256k1)
17
21
  - Broadcast operations
18
22
  - Memo encryption/decryption
19
- - Transaction serialization
23
+ - Transaction serialization (95.8% test coverage)
20
24
  - ✅ **Security**: Fixed insecure random number generation, implemented proper cryptographic functions
21
25
  - ✅ **Tests**: 174 tests passing, 12 skipped (network-dependent integration tests)
22
26
 
27
+ > 📖 **Detailed Refactoring Documentation**: See [docs/refactoring-2025.md](./docs/refactoring-2025.md) for complete modernization refactoring process, technical choices, and architectural improvements.
28
+
23
29
  ## Installation
24
30
 
25
31
  ```bash
@@ -47,7 +53,7 @@ yarn add @steemit/steem-js
47
53
  <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.js"></script>
48
54
  ```
49
55
 
50
- **Note**: The UMD build includes all necessary polyfills (axios, events, buffer, util, stream, assert, crypto). No additional dependencies are required.
56
+ **Note**: The UMD build includes all necessary polyfills (events, buffer, util, stream, assert, crypto-browserify). No additional dependencies are required.
51
57
 
52
58
  ## Usage
53
59
 
@@ -1,9 +1,10 @@
1
- import BigInteger from 'bigi';
1
+ import BN from 'bn.js';
2
2
  import ECSignature from './ecsignature';
3
- type Curve = any;
4
- type Point = any;
5
- export declare function sign(curve: Curve, hash: Buffer, d: BigInteger, nonce?: number): ECSignature;
6
- export declare function verify(curve: Curve, hash: Buffer, signature: ECSignature, Q: Point): boolean;
3
+ import { ec as EC } from 'elliptic';
4
+ type ECInstance = EC;
5
+ type ECPoint = any;
6
+ export declare function sign(curve: ECInstance, hash: Buffer, d: BN, nonce?: number): ECSignature;
7
+ export declare function verify(curve: ECInstance, hash: Buffer, signature: ECSignature, Q: ECPoint): boolean;
7
8
  /**
8
9
  * Recover a public key from a signature.
9
10
  *
@@ -12,7 +13,7 @@ export declare function verify(curve: Curve, hash: Buffer, signature: ECSignatur
12
13
  *
13
14
  * http://www.secg.org/download/aid-780/sec1-v2.pdf
14
15
  */
15
- export declare function recoverPubKey(curve: Curve, e: BigInteger, signature: ECSignature, i: number): Point;
16
+ export declare function recoverPubKey(curve: ECInstance, e: BN, signature: ECSignature, i: number): ECPoint;
16
17
  /**
17
18
  * Calculate pubkey extraction parameter.
18
19
  *
@@ -24,5 +25,5 @@ export declare function recoverPubKey(curve: Curve, e: BigInteger, signature: EC
24
25
  * This function simply tries all four cases and returns the value
25
26
  * that resulted in a successful pubkey recovery.
26
27
  */
27
- export declare function calcPubKeyRecoveryParam(curve: Curve, e: BigInteger, signature: ECSignature, Q: Point): number;
28
+ export declare function calcPubKeyRecoveryParam(curve: ECInstance, e: BN, signature: ECSignature, Q: ECPoint): number;
28
29
  export {};
@@ -1,8 +1,8 @@
1
- import BigInteger from 'bigi';
1
+ import BN from 'bn.js';
2
2
  export default class ECSignature {
3
- r: BigInteger;
4
- s: BigInteger;
5
- constructor(r: BigInteger, s: BigInteger);
3
+ r: BN;
4
+ s: BN;
5
+ constructor(r: BN, s: BN);
6
6
  static parseCompact(buffer: Buffer): {
7
7
  compressed: boolean;
8
8
  i: number;
@@ -1,14 +1,14 @@
1
- import BigInteger from 'bigi';
1
+ import BN from 'bn.js';
2
2
  import { PublicKey } from './key_public';
3
- type Point = any;
3
+ type ECPoint = any;
4
4
  export declare class PrivateKey {
5
- d: BigInteger;
5
+ d: BN;
6
6
  public_key?: PublicKey;
7
7
  /**
8
8
  * @private see static functions
9
- * @param {BigInteger} d
9
+ * @param {BN} d
10
10
  */
11
- constructor(d: BigInteger);
11
+ constructor(d: BN);
12
12
  static fromBuffer(buf: Buffer): PrivateKey;
13
13
  /** @arg {string} seed - any length string. This is private, the same seed produces the same private key every time. */
14
14
  static fromSeed(seed: string): PrivateKey;
@@ -24,7 +24,7 @@ export declare class PrivateKey {
24
24
  /**
25
25
  * @return {Point}
26
26
  */
27
- toPublicKeyPoint(): Point;
27
+ toPublicKeyPoint(): ECPoint;
28
28
  toPublic(): PublicKey;
29
29
  toBuffer(): Buffer;
30
30
  /** ECIES */
@@ -1,13 +1,13 @@
1
- type Point = any;
1
+ type ECPoint = any;
2
2
  export declare class PublicKey {
3
- Q: Point | null;
3
+ Q: ECPoint | null;
4
4
  pubdata?: string;
5
5
  /** @param {Point} public key */
6
- constructor(Q: Point | null);
6
+ constructor(Q: ECPoint | null);
7
7
  static fromBinary(bin: string): PublicKey;
8
8
  static fromBuffer(buffer: Buffer): PublicKey;
9
- toBuffer(compressed?: any): Buffer;
10
- static fromPoint(point: Point): PublicKey;
9
+ toBuffer(compressed?: boolean): Buffer;
10
+ static fromPoint(point: ECPoint): PublicKey;
11
11
  toUncompressed(): PublicKey;
12
12
  /** bts::blockchain::address (unique but not a full public key) */
13
13
  toBlockchainAddress(): Buffer;
@@ -1,15 +1,16 @@
1
- import bigi from 'bigi';
1
+ import BN from 'bn.js';
2
2
  import { PrivateKey } from './key_private';
3
3
  import { PublicKey } from './key_public';
4
4
  export declare class Signature {
5
- r: bigi;
6
- s: bigi;
5
+ r: BN;
6
+ s: BN;
7
7
  i: number;
8
- constructor(r: bigi, s: bigi, i: number);
8
+ constructor(r: BN, s: BN, i: number);
9
9
  static fromBuffer(buffer: Buffer): Signature;
10
10
  toBuffer(): Buffer;
11
11
  static signBuffer(buf: Buffer, private_key: PrivateKey | string): Signature;
12
12
  static signBufferSha256(buf_sha256: Buffer, private_key: PrivateKey | string): Signature;
13
+ static isCanonical(r: Buffer, s: Buffer): boolean;
13
14
  static sign(string: string, private_key: PrivateKey | string): Signature;
14
15
  verifyBuffer(buf: Buffer, public_key: PublicKey): boolean;
15
16
  verifyHash(hash: Buffer, public_key: PublicKey): boolean;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Serialize a transaction to binary format for Steem blockchain
3
+ * This is a simplified implementation that handles the basic structure
4
+ */
5
+ export declare function serializeTransaction(trx: any): Buffer;
package/dist/config.d.ts CHANGED
@@ -5,6 +5,8 @@ interface SteemConfig {
5
5
  websocket?: string;
6
6
  address_prefix?: string;
7
7
  chain_id?: string;
8
+ debug?: boolean;
9
+ debug_warnings?: boolean;
8
10
  }
9
11
  export declare class Config {
10
12
  private config;