@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 +19 -5
- package/dist/auth/ecc/src/ecdsa.d.ts +8 -7
- package/dist/auth/ecc/src/ecsignature.d.ts +4 -4
- package/dist/auth/ecc/src/key_private.d.ts +6 -6
- package/dist/auth/ecc/src/key_public.d.ts +5 -5
- package/dist/auth/ecc/src/signature.d.ts +5 -4
- package/dist/index.cjs +12534 -2110
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12537 -2113
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +24511 -26374
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +2 -0
- package/dist/index.umd.min.js.map +1 -0
- package/dist/umd.d.ts +36 -0
- package/dist/utils/buffer-global.d.ts +7 -0
- package/dist/utils/net-polyfill.d.ts +17 -0
- package/dist/utils/polyfill-test.d.ts +19 -0
- package/dist/utils/promisify.d.ts +5 -0
- package/dist/utils/tls-polyfill.d.ts +15 -0
- package/dist/utils/util-polyfill.d.ts +17 -0
- package/package.json +7 -5
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 (
|
|
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 (
|
|
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
|
|
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
|
|
1
|
+
import BN from 'bn.js';
|
|
2
2
|
import ECSignature from './ecsignature';
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
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:
|
|
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:
|
|
28
|
+
export declare function calcPubKeyRecoveryParam(curve: ECInstance, e: BN, signature: ECSignature, Q: ECPoint): number;
|
|
28
29
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BN from 'bn.js';
|
|
2
2
|
export default class ECSignature {
|
|
3
|
-
r:
|
|
4
|
-
s:
|
|
5
|
-
constructor(r:
|
|
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
|
|
1
|
+
import BN from 'bn.js';
|
|
2
2
|
import { PublicKey } from './key_public';
|
|
3
|
-
type
|
|
3
|
+
type ECPoint = any;
|
|
4
4
|
export declare class PrivateKey {
|
|
5
|
-
d:
|
|
5
|
+
d: BN;
|
|
6
6
|
public_key?: PublicKey;
|
|
7
7
|
/**
|
|
8
8
|
* @private see static functions
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {BN} d
|
|
10
10
|
*/
|
|
11
|
-
constructor(d:
|
|
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():
|
|
27
|
+
toPublicKeyPoint(): ECPoint;
|
|
28
28
|
toPublic(): PublicKey;
|
|
29
29
|
toBuffer(): Buffer;
|
|
30
30
|
/** ECIES */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
type
|
|
1
|
+
type ECPoint = any;
|
|
2
2
|
export declare class PublicKey {
|
|
3
|
-
Q:
|
|
3
|
+
Q: ECPoint | null;
|
|
4
4
|
pubdata?: string;
|
|
5
5
|
/** @param {Point} public key */
|
|
6
|
-
constructor(Q:
|
|
6
|
+
constructor(Q: ECPoint | null);
|
|
7
7
|
static fromBinary(bin: string): PublicKey;
|
|
8
8
|
static fromBuffer(buffer: Buffer): PublicKey;
|
|
9
|
-
toBuffer(compressed?:
|
|
10
|
-
static fromPoint(point:
|
|
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
|
|
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:
|
|
6
|
-
s:
|
|
5
|
+
r: BN;
|
|
6
|
+
s: BN;
|
|
7
7
|
i: number;
|
|
8
|
-
constructor(r:
|
|
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;
|