@steemit/steem-js 1.0.3 → 1.0.4
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 +67 -192
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,246 +1,121 @@
|
|
|
1
1
|
# Steem.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A modern JavaScript/TypeScript library for interacting with the Steem blockchain. Complete refactoring with TypeScript, modern tooling, and improved security.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@steemit/steem-js)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## 📚 Documentation
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
**[👉 Complete API Documentation](./docs/README.md)** - Comprehensive guide with all methods, examples, and usage patterns
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
- ✅ **Build System**: Migrated from Webpack to Rollup
|
|
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
|
|
18
|
-
- ✅ **Core Modules**: All core functionality implemented
|
|
19
|
-
- API module with HTTP and WebSocket transports
|
|
20
|
-
- Authentication and encryption (ECC secp256k1)
|
|
21
|
-
- Broadcast operations
|
|
22
|
-
- Memo encryption/decryption
|
|
23
|
-
- Transaction serialization (95.8% test coverage)
|
|
24
|
-
- ✅ **Security**: Fixed insecure random number generation, implemented proper cryptographic functions
|
|
25
|
-
- ✅ **Tests**: 174 tests passing, 12 skipped (network-dependent integration tests)
|
|
12
|
+
**[🔧 Refactoring Details](./docs/refactoring-2025.md)** - Technical details about the 2025 modernization
|
|
26
13
|
|
|
27
|
-
|
|
14
|
+
## 🚀 Quick Start
|
|
28
15
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pnpm install
|
|
33
|
-
# or
|
|
34
|
-
npm install
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Installation
|
|
38
|
-
|
|
39
|
-
### npm / pnpm / yarn
|
|
16
|
+
### Installation
|
|
40
17
|
|
|
41
18
|
```bash
|
|
19
|
+
# npm
|
|
42
20
|
npm install @steemit/steem-js
|
|
43
|
-
# or
|
|
44
|
-
pnpm install @steemit/steem-js
|
|
45
|
-
# or
|
|
46
|
-
yarn add @steemit/steem-js
|
|
47
|
-
```
|
|
48
21
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```html
|
|
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>
|
|
22
|
+
# pnpm (recommended)
|
|
23
|
+
pnpm install @steemit/steem-js
|
|
55
24
|
|
|
56
|
-
|
|
57
|
-
|
|
25
|
+
# yarn
|
|
26
|
+
yarn add @steemit/steem-js
|
|
58
27
|
```
|
|
59
28
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## Usage
|
|
63
|
-
|
|
64
|
-
### Node.js / TypeScript / ES Modules
|
|
29
|
+
### Basic Usage
|
|
65
30
|
|
|
66
31
|
```typescript
|
|
67
32
|
import { steem } from '@steemit/steem-js';
|
|
68
33
|
|
|
69
|
-
// Configure
|
|
34
|
+
// Configure API endpoint
|
|
70
35
|
steem.config.set({
|
|
71
36
|
node: 'https://api.steemit.com',
|
|
72
|
-
address_prefix: 'STM'
|
|
73
|
-
chain_id: '0000000000000000000000000000000000000000000000000000000000000000'
|
|
37
|
+
address_prefix: 'STM'
|
|
74
38
|
});
|
|
75
39
|
|
|
76
40
|
// Get account information
|
|
77
|
-
const
|
|
78
|
-
console.log(
|
|
79
|
-
|
|
80
|
-
// Generate keys
|
|
81
|
-
const keys = steem.auth.generateKeys('username', 'password', ['owner', 'active', 'posting', 'memo']);
|
|
82
|
-
console.log(keys);
|
|
83
|
-
|
|
84
|
-
// Sign and verify messages
|
|
85
|
-
import { generateKeyPair, sign, verify } from '@steemit/steem-js/crypto';
|
|
86
|
-
const keyPair = generateKeyPair();
|
|
87
|
-
const message = 'Hello, Steem!';
|
|
88
|
-
const signature = sign(message, keyPair.privateKey);
|
|
89
|
-
const isValid = verify(message, signature, keyPair.publicKey);
|
|
90
|
-
console.log('Signature valid:', isValid);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Node.js / CommonJS
|
|
94
|
-
|
|
95
|
-
```javascript
|
|
96
|
-
const { steem } = require('@steemit/steem-js');
|
|
97
|
-
|
|
98
|
-
steem.config.set({
|
|
99
|
-
node: 'https://api.steemit.com',
|
|
100
|
-
address_prefix: 'STM'
|
|
101
|
-
});
|
|
41
|
+
const accounts = await steem.api.getAccountsAsync(['username']);
|
|
42
|
+
console.log(accounts[0]);
|
|
102
43
|
|
|
103
|
-
|
|
104
|
-
|
|
44
|
+
// Vote on a post
|
|
45
|
+
const postingWif = steem.auth.toWif('username', 'password', 'posting');
|
|
46
|
+
await steem.broadcast.voteAsync(postingWif, 'voter', 'author', 'permlink', 10000);
|
|
105
47
|
```
|
|
106
48
|
|
|
107
|
-
### Browser
|
|
108
|
-
|
|
109
|
-
The UMD build includes all necessary dependencies and polyfills, so you can use it directly without any additional setup.
|
|
49
|
+
### Browser Usage
|
|
110
50
|
|
|
111
51
|
```html
|
|
112
|
-
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
<script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.min.js"></script>
|
|
118
|
-
</head>
|
|
119
|
-
<body>
|
|
120
|
-
<script>
|
|
121
|
-
// Use the global 'steem' object
|
|
122
|
-
steem.config.set({
|
|
123
|
-
node: 'https://api.steemit.com',
|
|
124
|
-
address_prefix: 'STM'
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// Get account information
|
|
128
|
-
steem.api.getAccountAsync('ned')
|
|
129
|
-
.then(account => {
|
|
130
|
-
console.log('Account:', account);
|
|
131
|
-
})
|
|
132
|
-
.catch(error => {
|
|
133
|
-
console.error('Error:', error);
|
|
134
|
-
});
|
|
135
|
-
</script>
|
|
136
|
-
</body>
|
|
137
|
-
</html>
|
|
52
|
+
<script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.min.js"></script>
|
|
53
|
+
<script>
|
|
54
|
+
steem.config.set({ node: 'https://api.steemit.com' });
|
|
55
|
+
steem.api.getAccountsAsync(['username']).then(console.log);
|
|
56
|
+
</script>
|
|
138
57
|
```
|
|
139
58
|
|
|
140
|
-
|
|
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.
|
|
145
|
-
|
|
146
|
-
### Broadcast Operations
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
import { steem } from '@steemit/steem-js';
|
|
150
|
-
|
|
151
|
-
// Vote on a post
|
|
152
|
-
const postingWif = steem.auth.toWif('username', 'password', 'posting');
|
|
153
|
-
await steem.broadcast.voteAsync(
|
|
154
|
-
postingWif,
|
|
155
|
-
'voter',
|
|
156
|
-
'author',
|
|
157
|
-
'permlink',
|
|
158
|
-
10000 // weight
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
// Transfer STEEM
|
|
162
|
-
await steem.broadcast.transferAsync(
|
|
163
|
-
activeWif,
|
|
164
|
-
'from',
|
|
165
|
-
'to',
|
|
166
|
-
'1.000 STEEM',
|
|
167
|
-
'memo'
|
|
168
|
-
);
|
|
169
|
-
```
|
|
59
|
+
## ✨ Key Features
|
|
170
60
|
|
|
171
|
-
|
|
61
|
+
- **🔒 Type Safety** - Full TypeScript support with complete type definitions
|
|
62
|
+
- **⚡ Modern** - ES modules, async/await, modern cryptography libraries
|
|
63
|
+
- **🌐 Universal** - Works in Node.js, browsers, and bundlers
|
|
64
|
+
- **🔐 Secure** - Proper cryptographic implementations, no key exposure
|
|
65
|
+
- **📖 Well Documented** - Comprehensive API documentation with examples
|
|
172
66
|
|
|
173
|
-
|
|
67
|
+
## 🏗️ Development
|
|
174
68
|
|
|
175
69
|
```bash
|
|
176
|
-
|
|
177
|
-
|
|
70
|
+
# Install dependencies
|
|
71
|
+
pnpm install
|
|
178
72
|
|
|
179
|
-
|
|
73
|
+
# Build the library
|
|
74
|
+
pnpm build
|
|
180
75
|
|
|
181
|
-
|
|
182
|
-
# Run all tests
|
|
76
|
+
# Run tests
|
|
183
77
|
pnpm test
|
|
184
78
|
|
|
185
|
-
#
|
|
186
|
-
pnpm test:watch
|
|
187
|
-
|
|
188
|
-
# Run tests with coverage
|
|
189
|
-
pnpm test:coverage
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Type Check
|
|
193
|
-
|
|
194
|
-
```bash
|
|
79
|
+
# Type checking
|
|
195
80
|
pnpm typecheck
|
|
196
81
|
```
|
|
197
82
|
|
|
198
|
-
|
|
83
|
+
## 📦 What's New in 2025
|
|
199
84
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
85
|
+
This is a complete modernization of the original steem-js library:
|
|
86
|
+
|
|
87
|
+
- ✅ **TypeScript Migration** - Full type safety and better developer experience
|
|
88
|
+
- ✅ **Modern Dependencies** - Replaced outdated crypto libraries (`bigi` → `bn.js`, `ecurve` → `elliptic`)
|
|
89
|
+
- ✅ **Build System** - Migrated from Webpack to Rollup for better output
|
|
90
|
+
- ✅ **Testing** - Migrated from Mocha to Vitest with 95.8% test coverage
|
|
91
|
+
- ✅ **Security** - Fixed insecure random number generation and crypto implementations
|
|
203
92
|
|
|
204
|
-
## Project Structure
|
|
93
|
+
## 📋 Project Structure
|
|
205
94
|
|
|
206
95
|
```
|
|
207
96
|
src/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
97
|
+
├── api/ # Blockchain API client (HTTP/WebSocket)
|
|
98
|
+
├── auth/ # Authentication and key management
|
|
99
|
+
├── broadcast/ # Transaction broadcasting
|
|
100
|
+
├── crypto/ # Cryptographic utilities
|
|
101
|
+
├── formatter/ # Data formatting helpers
|
|
102
|
+
├── memo/ # Encrypted memo handling
|
|
103
|
+
├── operations/ # Operation type definitions
|
|
104
|
+
├── serializer/ # Transaction serialization
|
|
105
|
+
└── utils/ # Utility functions
|
|
217
106
|
```
|
|
218
107
|
|
|
219
|
-
##
|
|
220
|
-
|
|
221
|
-
- **Type Safety**: Full TypeScript support with type definitions
|
|
222
|
-
- **Modern ES Modules**: Uses ES modules with CommonJS fallback
|
|
223
|
-
- **Secure Cryptography**: Proper implementation using Node.js crypto module
|
|
224
|
-
- **Multiple Transports**: Supports both HTTP and WebSocket connections
|
|
225
|
-
- **Promise and Callback Support**: Compatible with both async/await and callback patterns
|
|
226
|
-
|
|
227
|
-
## Breaking Changes from Original
|
|
228
|
-
|
|
229
|
-
This is a complete refactor with the following changes:
|
|
230
|
-
|
|
231
|
-
1. **TypeScript**: All code is now TypeScript
|
|
232
|
-
2. **ES Modules**: Uses ES modules by default (CommonJS available)
|
|
233
|
-
3. **Build System**: Uses Rollup instead of Webpack
|
|
234
|
-
4. **Testing**: Uses Vitest instead of Mocha
|
|
235
|
-
5. **API**: Some method signatures may have changed for better type safety
|
|
108
|
+
## 🔗 Links
|
|
236
109
|
|
|
237
|
-
|
|
110
|
+
- **[📖 API Documentation](./docs/README.md)** - Complete method reference
|
|
111
|
+
- **[🔧 Refactoring History](./docs/refactoring-2025.md)** - Technical modernization details
|
|
112
|
+
- **[📦 NPM Package](https://www.npmjs.com/package/@steemit/steem-js)** - Published package
|
|
113
|
+
- **[🐛 Issues](https://github.com/steemit/steem-js/issues)** - Bug reports and feature requests
|
|
238
114
|
|
|
239
|
-
|
|
240
|
-
- Uses cryptographically secure random number generation
|
|
241
|
-
- All cryptographic operations use proper implementations
|
|
115
|
+
## 📄 License
|
|
242
116
|
|
|
243
|
-
|
|
117
|
+
MIT - see [LICENSE](LICENSE) file for details.
|
|
244
118
|
|
|
245
|
-
|
|
119
|
+
---
|
|
246
120
|
|
|
121
|
+
> 💡 **Need help?** Check the [complete documentation](./docs/README.md) for detailed examples and API reference.
|