@steemit/steem-js 1.0.2 → 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 CHANGED
@@ -1,238 +1,121 @@
1
1
  # Steem.js
2
2
 
3
- Steem.js is a JavaScript/TypeScript library for interacting with the Steem blockchain.
3
+ A modern JavaScript/TypeScript library for interacting with the Steem blockchain. Complete refactoring with TypeScript, modern tooling, and improved security.
4
4
 
5
- ## Status
5
+ [![npm version](https://img.shields.io/npm/v/@steemit/steem-js.svg)](https://www.npmjs.com/package/@steemit/steem-js)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
7
 
7
- This is a complete refactoring of the original steem-js library, migrating from JavaScript to TypeScript with modern tooling and improved code quality. Published as `@steemit/steem-js`.
8
+ ## 📚 Documentation
8
9
 
9
- ### Refactoring Progress
10
+ **[👉 Complete API Documentation](./docs/README.md)** - Comprehensive guide with all methods, examples, and usage patterns
10
11
 
11
- - **TypeScript Migration**: Complete migration from JavaScript to TypeScript
12
- - ✅ **Build System**: Migrated from Webpack to Rollup
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
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
- > 📖 **Detailed Refactoring Documentation**: See [docs/refactoring-2025.md](./docs/refactoring-2025.md) for complete modernization refactoring process, technical choices, and architectural improvements.
14
+ ## 🚀 Quick Start
28
15
 
29
- ## Installation
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
- ### Browser (CDN)
22
+ # pnpm (recommended)
23
+ pnpm install @steemit/steem-js
50
24
 
51
- ```html
52
- <!-- Include @steemit/steem-js (all dependencies are bundled) -->
53
- <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.js"></script>
25
+ # yarn
26
+ yarn add @steemit/steem-js
54
27
  ```
55
28
 
56
- **Note**: The UMD build includes all necessary polyfills (events, buffer, util, stream, assert, crypto-browserify). No additional dependencies are required.
57
-
58
- ## Usage
59
-
60
- ### Node.js / TypeScript / ES Modules
29
+ ### Basic Usage
61
30
 
62
31
  ```typescript
63
32
  import { steem } from '@steemit/steem-js';
64
33
 
65
- // Configure the API endpoint
34
+ // Configure API endpoint
66
35
  steem.config.set({
67
36
  node: 'https://api.steemit.com',
68
- address_prefix: 'STM',
69
- chain_id: '0000000000000000000000000000000000000000000000000000000000000000'
37
+ address_prefix: 'STM'
70
38
  });
71
39
 
72
40
  // Get account information
73
- const account = await steem.api.getAccountAsync('ned');
74
- console.log(account);
75
-
76
- // Generate keys
77
- const keys = steem.auth.generateKeys('username', 'password', ['owner', 'active', 'posting', 'memo']);
78
- console.log(keys);
79
-
80
- // Sign and verify messages
81
- import { generateKeyPair, sign, verify } from '@steemit/steem-js/crypto';
82
- const keyPair = generateKeyPair();
83
- const message = 'Hello, Steem!';
84
- const signature = sign(message, keyPair.privateKey);
85
- const isValid = verify(message, signature, keyPair.publicKey);
86
- console.log('Signature valid:', isValid);
87
- ```
88
-
89
- ### Node.js / CommonJS
41
+ const accounts = await steem.api.getAccountsAsync(['username']);
42
+ console.log(accounts[0]);
90
43
 
91
- ```javascript
92
- const { steem } = require('@steemit/steem-js');
93
-
94
- steem.config.set({
95
- node: 'https://api.steemit.com',
96
- address_prefix: 'STM'
97
- });
98
-
99
- const account = await steem.api.getAccountAsync('ned');
100
- console.log(account);
44
+ // Vote on a post
45
+ const postingWif = steem.auth.toWif('username', 'password', 'posting');
46
+ await steem.broadcast.voteAsync(postingWif, 'voter', 'author', 'permlink', 10000);
101
47
  ```
102
48
 
103
- ### Browser (Script Tag)
104
-
105
- The UMD build includes all necessary dependencies and polyfills, so you can use it directly without any additional setup.
49
+ ### Browser Usage
106
50
 
107
51
  ```html
108
- <!DOCTYPE html>
109
- <html>
110
- <head>
111
- <title>Steem.js Example</title>
112
- <!-- Include @steemit/steem-js (all dependencies bundled) -->
113
- <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.js"></script>
114
- </head>
115
- <body>
116
- <script>
117
- // Use the global 'steem' object
118
- steem.config.set({
119
- node: 'https://api.steemit.com',
120
- address_prefix: 'STM'
121
- });
122
-
123
- // Get account information
124
- steem.api.getAccountAsync('ned')
125
- .then(account => {
126
- console.log('Account:', account);
127
- })
128
- .catch(error => {
129
- console.error('Error:', error);
130
- });
131
- </script>
132
- </body>
133
- </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>
134
57
  ```
135
58
 
136
- **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.
59
+ ## Key Features
137
60
 
138
- ### Broadcast Operations
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
139
66
 
140
- ```typescript
141
- import { steem } from '@steemit/steem-js';
142
-
143
- // Vote on a post
144
- const postingWif = steem.auth.toWif('username', 'password', 'posting');
145
- await steem.broadcast.voteAsync(
146
- postingWif,
147
- 'voter',
148
- 'author',
149
- 'permlink',
150
- 10000 // weight
151
- );
152
-
153
- // Transfer STEEM
154
- await steem.broadcast.transferAsync(
155
- activeWif,
156
- 'from',
157
- 'to',
158
- '1.000 STEEM',
159
- 'memo'
160
- );
161
- ```
162
-
163
- ## Development
164
-
165
- ### Build
67
+ ## 🏗️ Development
166
68
 
167
69
  ```bash
168
- pnpm build
169
- ```
70
+ # Install dependencies
71
+ pnpm install
170
72
 
171
- ### Test
73
+ # Build the library
74
+ pnpm build
172
75
 
173
- ```bash
174
- # Run all tests
76
+ # Run tests
175
77
  pnpm test
176
78
 
177
- # Run tests in watch mode
178
- pnpm test:watch
179
-
180
- # Run tests with coverage
181
- pnpm test:coverage
182
- ```
183
-
184
- ### Type Check
185
-
186
- ```bash
79
+ # Type checking
187
80
  pnpm typecheck
188
81
  ```
189
82
 
190
- ### Lint
83
+ ## 📦 What's New in 2025
191
84
 
192
- ```bash
193
- pnpm lint
194
- ```
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
195
92
 
196
- ## Project Structure
93
+ ## 📋 Project Structure
197
94
 
198
95
  ```
199
96
  src/
200
- api/ # API client with HTTP and WebSocket transports
201
- auth/ # Authentication and key management
202
- broadcast/ # Transaction broadcasting
203
- crypto/ # Cryptographic utilities
204
- formatter/ # Data formatting
205
- memo/ # Encrypted memo handling
206
- operations/ # Operation type definitions
207
- serializer/ # Transaction serialization
208
- utils/ # Utility functions
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
209
106
  ```
210
107
 
211
- ## Key Features
212
-
213
- - **Type Safety**: Full TypeScript support with type definitions
214
- - **Modern ES Modules**: Uses ES modules with CommonJS fallback
215
- - **Secure Cryptography**: Proper implementation using Node.js crypto module
216
- - **Multiple Transports**: Supports both HTTP and WebSocket connections
217
- - **Promise and Callback Support**: Compatible with both async/await and callback patterns
218
-
219
- ## Breaking Changes from Original
220
-
221
- This is a complete refactor with the following changes:
222
-
223
- 1. **TypeScript**: All code is now TypeScript
224
- 2. **ES Modules**: Uses ES modules by default (CommonJS available)
225
- 3. **Build System**: Uses Rollup instead of Webpack
226
- 4. **Testing**: Uses Vitest instead of Mocha
227
- 5. **API**: Some method signatures may have changed for better type safety
108
+ ## 🔗 Links
228
109
 
229
- ## Security Notes
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
230
114
 
231
- - Private keys are never logged or exposed
232
- - Uses cryptographically secure random number generation
233
- - All cryptographic operations use proper implementations
115
+ ## 📄 License
234
116
 
235
- ## License
117
+ MIT - see [LICENSE](LICENSE) file for details.
236
118
 
237
- MIT
119
+ ---
238
120
 
121
+ > 💡 **Need help?** Check the [complete documentation](./docs/README.md) for detailed examples and API reference.
package/dist/index.umd.js CHANGED
@@ -56254,52 +56254,5 @@
56254
56254
 
56255
56255
  return steem;
56256
56256
 
56257
- (function() {
56258
- // Ensure Buffer is globally available after bundle loads
56259
- if (typeof globalThis !== 'undefined' && typeof globalThis.Buffer === 'undefined') {
56260
- // Try to find Buffer in the bundle
56261
- if (typeof require !== 'undefined') {
56262
- try {
56263
- globalThis.Buffer = require('buffer').Buffer;
56264
- } catch (e) {
56265
- // Fallback: create minimal Buffer polyfill
56266
- globalThis.Buffer = {
56267
- from: function(data, encoding) {
56268
- if (typeof data === 'string') {
56269
- if (encoding === 'hex') {
56270
- const bytes = new Uint8Array(data.length / 2);
56271
- for (let i = 0; i < data.length; i += 2) {
56272
- bytes[i / 2] = parseInt(data.substr(i, 2), 16);
56273
- }
56274
- return bytes;
56275
- }
56276
- return new TextEncoder().encode(data);
56277
- }
56278
- return new Uint8Array(data);
56279
- },
56280
- alloc: function(size, fill) {
56281
- const buf = new Uint8Array(size);
56282
- if (fill !== undefined) buf.fill(fill);
56283
- return buf;
56284
- },
56285
- concat: function(buffers) {
56286
- const totalLength = buffers.reduce((sum, buf) => sum + buf.length, 0);
56287
- const result = new Uint8Array(totalLength);
56288
- let offset = 0;
56289
- for (const buf of buffers) {
56290
- result.set(buf, offset);
56291
- offset += buf.length;
56292
- }
56293
- return result;
56294
- },
56295
- isBuffer: function(obj) {
56296
- return obj instanceof Uint8Array;
56297
- }
56298
- };
56299
- }
56300
- }
56301
- }
56302
- })();
56303
-
56304
56257
  }));
56305
56258
  //# sourceMappingURL=index.umd.js.map