@steemit/steem-js 1.0.1 → 1.0.3

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 (2025)**: 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
@@ -44,10 +50,14 @@ yarn add @steemit/steem-js
44
50
 
45
51
  ```html
46
52
  <!-- Include @steemit/steem-js (all dependencies are bundled) -->
53
+ <!-- For production: use minified version (692KB) -->
54
+ <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.min.js"></script>
55
+
56
+ <!-- For development: use regular version (1.7MB) with better debugging -->
47
57
  <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.js"></script>
48
58
  ```
49
59
 
50
- **Note**: The UMD build includes all necessary polyfills (axios, events, buffer, util, stream, assert, crypto). No additional dependencies are required.
60
+ **Note**: The UMD build includes all necessary polyfills (events, buffer, util, stream, assert, crypto-browserify). No additional dependencies are required. The minified version is recommended for production use.
51
61
 
52
62
  ## Usage
53
63
 
@@ -103,8 +113,8 @@ The UMD build includes all necessary dependencies and polyfills, so you can use
103
113
  <html>
104
114
  <head>
105
115
  <title>Steem.js Example</title>
106
- <!-- Include @steemit/steem-js (all dependencies bundled) -->
107
- <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.js"></script>
116
+ <!-- Include @steemit/steem-js (minified for production) -->
117
+ <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.min.js"></script>
108
118
  </head>
109
119
  <body>
110
120
  <script>
@@ -127,7 +137,11 @@ The UMD build includes all necessary dependencies and polyfills, so you can use
127
137
  </html>
128
138
  ```
129
139
 
130
- **Note**: The UMD build (1.7MB) includes all polyfills, making it ready to use in browsers without additional dependencies. For production use with bundlers (Webpack, Vite, Rollup), use the ES Module or CommonJS builds instead.
140
+ **Note**: The UMD build comes in two versions:
141
+ - **Minified** (`index.umd.min.js` - 692KB): Recommended for production
142
+ - **Regular** (`index.umd.js` - 1.7MB): Better for development and debugging
143
+
144
+ Both include all polyfills, making them ready to use in browsers without additional dependencies. For production use with bundlers (Webpack, Vite, Rollup), use the ES Module or CommonJS builds instead.
131
145
 
132
146
  ### Broadcast Operations
133
147
 
@@ -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;