@steemit/steem-js 0.8.0 → 1.0.0

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.
Files changed (126) hide show
  1. package/README.md +202 -105
  2. package/dist/api/index.d.ts +128 -0
  3. package/dist/api/methods.d.ts +9 -0
  4. package/dist/api/rpc-auth.d.ts +43 -0
  5. package/dist/api/transports/base.d.ts +13 -0
  6. package/dist/api/transports/http.d.ts +9 -0
  7. package/dist/api/transports/index.d.ts +9 -0
  8. package/dist/api/transports/types.d.ts +35 -0
  9. package/dist/api/transports/ws.d.ts +18 -0
  10. package/dist/auth/ecc/index.d.ts +9 -0
  11. package/dist/auth/ecc/src/address.d.ts +13 -0
  12. package/dist/auth/ecc/src/aes.d.ts +16 -0
  13. package/dist/auth/ecc/src/brain_key.d.ts +1 -0
  14. package/dist/auth/ecc/src/ecdsa.d.ts +28 -0
  15. package/dist/auth/ecc/src/ecsignature.d.ts +19 -0
  16. package/dist/auth/ecc/src/enforce_types.d.ts +5 -0
  17. package/dist/auth/ecc/src/hash.d.ts +25 -0
  18. package/dist/auth/ecc/src/index.d.ts +9 -0
  19. package/dist/auth/ecc/src/key_private.d.ts +38 -0
  20. package/dist/auth/ecc/src/key_public.d.ts +41 -0
  21. package/dist/auth/ecc/src/key_utils.d.ts +9 -0
  22. package/dist/auth/ecc/src/signature.d.ts +18 -0
  23. package/dist/auth/ecc.d.ts +3 -0
  24. package/dist/auth/index.d.ts +48 -0
  25. package/dist/auth/key_classes.d.ts +3 -0
  26. package/dist/auth/serializer.d.ts +19 -0
  27. package/dist/broadcast/helpers.d.ts +11 -0
  28. package/dist/broadcast/index.d.ts +43 -0
  29. package/dist/broadcast/operations.d.ts +6 -0
  30. package/dist/config.d.ts +25 -0
  31. package/dist/crypto/index.d.ts +25 -0
  32. package/dist/formatter/index.d.ts +92 -0
  33. package/dist/index.cjs +25848 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.js +25812 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/index.umd.js +57513 -0
  39. package/dist/index.umd.js.map +1 -0
  40. package/dist/memo/index.d.ts +11 -0
  41. package/dist/operations/index.d.ts +44 -0
  42. package/dist/serializer/convert.d.ts +12 -0
  43. package/dist/serializer/index.d.ts +11 -0
  44. package/dist/serializer/number_utils.d.ts +8 -0
  45. package/dist/serializer/precision.d.ts +5 -0
  46. package/dist/serializer/types.d.ts +36 -0
  47. package/dist/types/index.d.ts +131 -0
  48. package/dist/types.d.ts +34 -0
  49. package/dist/utils/index.d.ts +8 -0
  50. package/dist/utils.d.ts +2 -0
  51. package/package.json +68 -87
  52. package/.dockerignore +0 -12
  53. package/.editorconfig +0 -20
  54. package/.eslintrc +0 -27
  55. package/LICENSE +0 -21
  56. package/circle.yml +0 -3
  57. package/config.json +0 -10
  58. package/dist/steem-tests.min.js +0 -4097
  59. package/dist/steem.min.js +0 -2089
  60. package/docker-webpack.config.js +0 -44
  61. package/lib/api/index.js +0 -315
  62. package/lib/api/methods.js +0 -428
  63. package/lib/api/rpc-auth.js +0 -135
  64. package/lib/api/transports/base.js +0 -31
  65. package/lib/api/transports/http.js +0 -157
  66. package/lib/api/transports/index.js +0 -13
  67. package/lib/api/transports/ws.js +0 -128
  68. package/lib/auth/ecc/index.js +0 -13
  69. package/lib/auth/ecc/src/address.js +0 -54
  70. package/lib/auth/ecc/src/aes.js +0 -148
  71. package/lib/auth/ecc/src/brain_key.js +0 -13
  72. package/lib/auth/ecc/src/ecdsa.js +0 -193
  73. package/lib/auth/ecc/src/ecsignature.js +0 -102
  74. package/lib/auth/ecc/src/enforce_types.js +0 -42
  75. package/lib/auth/ecc/src/hash.js +0 -58
  76. package/lib/auth/ecc/src/key_private.js +0 -159
  77. package/lib/auth/ecc/src/key_public.js +0 -143
  78. package/lib/auth/ecc/src/key_utils.js +0 -70
  79. package/lib/auth/ecc/src/signature.js +0 -135
  80. package/lib/auth/index.js +0 -113
  81. package/lib/auth/memo.js +0 -119
  82. package/lib/auth/serializer/index.js +0 -15
  83. package/lib/auth/serializer/src/ChainTypes.js +0 -87
  84. package/lib/auth/serializer/src/convert.js +0 -34
  85. package/lib/auth/serializer/src/error_with_cause.js +0 -27
  86. package/lib/auth/serializer/src/fast_parser.js +0 -57
  87. package/lib/auth/serializer/src/number_utils.js +0 -43
  88. package/lib/auth/serializer/src/object_id.js +0 -43
  89. package/lib/auth/serializer/src/operations.js +0 -695
  90. package/lib/auth/serializer/src/precision.js +0 -77
  91. package/lib/auth/serializer/src/serializer.js +0 -165
  92. package/lib/auth/serializer/src/template.js +0 -22
  93. package/lib/auth/serializer/src/types.js +0 -1085
  94. package/lib/auth/serializer/src/validation.js +0 -300
  95. package/lib/broadcast/helpers.js +0 -140
  96. package/lib/broadcast/index.js +0 -106
  97. package/lib/broadcast/operations.js +0 -255
  98. package/lib/browser.js +0 -25
  99. package/lib/config.js +0 -23
  100. package/lib/formatter.js +0 -163
  101. package/lib/index.js +0 -21
  102. package/lib/utils.js +0 -50
  103. package/node-18.dockerfile +0 -28
  104. package/test/Crypto.js +0 -100
  105. package/test/KeyFormats.js +0 -105
  106. package/test/all_types.js +0 -115
  107. package/test/api.test.js +0 -363
  108. package/test/broadcast.test.js +0 -231
  109. package/test/browser/BrowserTests.js +0 -55
  110. package/test/comment.test.js +0 -83
  111. package/test/hf20-accounts.test.js +0 -76
  112. package/test/hf21-sps.test.js +0 -78
  113. package/test/memo.test.js +0 -37
  114. package/test/number_utils.js +0 -28
  115. package/test/operations_test.js +0 -39
  116. package/test/promise-broadcast.test.js +0 -86
  117. package/test/reputation.test.js +0 -68
  118. package/test/smt.test.js +0 -347
  119. package/test/test-post.json +0 -13
  120. package/test/test.html +0 -13
  121. package/test/test_helper.js +0 -19
  122. package/test/types_test.js +0 -139
  123. package/test-github-workflow.bat +0 -19
  124. package/test-github-workflow.sh +0 -15
  125. package/webpack/makeConfig.js +0 -113
  126. package/webpack.config.js +0 -2
package/README.md CHANGED
@@ -1,135 +1,232 @@
1
- [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/steemit/steem-js/blob/master/LICENSE)
2
- [![Steem.js channel on steemit.chat](https://img.shields.io/badge/chat-steemit.chat-1c56a4.svg)](https://steemit.chat/channel/steemjs)
3
-
4
1
  # Steem.js
5
- Steem.js the JavaScript API for Steem blockchain
6
-
7
- # Documentation
8
-
9
- - [Install](https://github.com/steemit/steem-js/tree/master/doc#install)
10
- - [Browser](https://github.com/steemit/steem-js/tree/master/doc#browser)
11
- - [Config](https://github.com/steemit/steem-js/tree/master/doc#config)
12
- - [Database API](https://github.com/steemit/steem-js/tree/master/doc#api)
13
- - [Subscriptions](https://github.com/steemit/steem-js/tree/master/doc#subscriptions)
14
- - [Tags](https://github.com/steemit/steem-js/tree/master/doc#tags)
15
- - [Blocks and transactions](https://github.com/steemit/steem-js/tree/master/doc#blocks-and-transactions)
16
- - [Globals](https://github.com/steemit/steem-js/tree/master/doc#globals)
17
- - [Keys](https://github.com/steemit/steem-js/tree/master/doc#keys)
18
- - [Accounts](https://github.com/steemit/steem-js/tree/master/doc#accounts)
19
- - [Market](https://github.com/steemit/steem-js/tree/master/doc#market)
20
- - [Authority / validation](https://github.com/steemit/steem-js/tree/master/doc#authority--validation)
21
- - [Votes](https://github.com/steemit/steem-js/tree/master/doc#votes)
22
- - [Content](https://github.com/steemit/steem-js/tree/master/doc#content)
23
- - [Witnesses](https://github.com/steemit/steem-js/tree/master/doc#witnesses)
24
- - [Login API](https://github.com/steemit/steem-js/tree/master/doc#login)
25
- - [Follow API](https://github.com/steemit/steem-js/tree/master/doc#follow-api)
26
- - [Broadcast API](https://github.com/steemit/steem-js/tree/master/doc#broadcast-api)
27
- - [Broadcast](https://github.com/steemit/steem-js/tree/master/doc#broadcast)
28
- - [Auth](https://github.com/steemit/steem-js/tree/master/doc#auth)
29
-
30
-
31
- Here is full documentation:
32
- https://github.com/steemit/steem-js/tree/master/doc
33
-
34
- ## Browser
35
- ```html
36
- <script src="./steem.min.js"></script>
37
- <script>
38
- steem.api.getAccounts(['ned', 'dan'], function(err, response){
39
- console.log(err, response);
40
- });
41
- </script>
2
+
3
+ Steem.js is a JavaScript/TypeScript library for interacting with the Steem blockchain.
4
+
5
+ ## Status
6
+
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
+
9
+ ### Refactoring Progress
10
+
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
+ - ✅ **Core Modules**: All core functionality implemented
15
+ - API module with HTTP and WebSocket transports
16
+ - Authentication and encryption (ECC secp256k1)
17
+ - Broadcast operations
18
+ - Memo encryption/decryption
19
+ - Transaction serialization
20
+ - ✅ **Security**: Fixed insecure random number generation, implemented proper cryptographic functions
21
+ - **Tests**: 174 tests passing, 12 skipped (network-dependent integration tests)
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pnpm install
27
+ # or
28
+ npm install
42
29
  ```
43
30
 
44
- ## CDN
45
- https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js<br/>
46
- ```html
47
- <script src="https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js"></script>
31
+ ## Installation
32
+
33
+ ### npm / pnpm / yarn
34
+
35
+ ```bash
36
+ npm install @steemit/steem-js
37
+ # or
38
+ pnpm install @steemit/steem-js
39
+ # or
40
+ yarn add @steemit/steem-js
48
41
  ```
49
42
 
50
- ## Webpack
51
- [Please have a look at the webpack usage example.](https://github.com/steemit/steem-js/blob/master/examples/webpack-example)
43
+ ### Browser (CDN)
52
44
 
53
- ## Server
54
- ## Install
45
+ ```html
46
+ <!-- Include @steemit/steem-js (all dependencies are bundled) -->
47
+ <script src="https://cdn.jsdelivr.net/npm/@steemit/steem-js/dist/index.umd.js"></script>
55
48
  ```
56
- $ npm install steem --save
49
+
50
+ **Note**: The UMD build includes all necessary polyfills (axios, events, buffer, util, stream, assert, crypto). No additional dependencies are required.
51
+
52
+ ## Usage
53
+
54
+ ### Node.js / TypeScript / ES Modules
55
+
56
+ ```typescript
57
+ import { steem } from '@steemit/steem-js';
58
+
59
+ // Configure the API endpoint
60
+ steem.config.set({
61
+ node: 'https://api.steemit.com',
62
+ address_prefix: 'STM',
63
+ chain_id: '0000000000000000000000000000000000000000000000000000000000000000'
64
+ });
65
+
66
+ // Get account information
67
+ const account = await steem.api.getAccountAsync('ned');
68
+ console.log(account);
69
+
70
+ // Generate keys
71
+ const keys = steem.auth.generateKeys('username', 'password', ['owner', 'active', 'posting', 'memo']);
72
+ console.log(keys);
73
+
74
+ // Sign and verify messages
75
+ import { generateKeyPair, sign, verify } from '@steemit/steem-js/crypto';
76
+ const keyPair = generateKeyPair();
77
+ const message = 'Hello, Steem!';
78
+ const signature = sign(message, keyPair.privateKey);
79
+ const isValid = verify(message, signature, keyPair.publicKey);
80
+ console.log('Signature valid:', isValid);
57
81
  ```
58
82
 
59
- ## RPC Servers
60
- https://api.steemit.com By Default<br/>
83
+ ### Node.js / CommonJS
61
84
 
62
- ## Examples
63
- ### Broadcast Vote
64
- ```js
65
- var steem = require('steem');
85
+ ```javascript
86
+ const { steem } = require('@steemit/steem-js');
66
87
 
67
- var wif = steem.auth.toWif(username, password, 'posting');
68
- steem.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) {
69
- console.log(err, result);
88
+ steem.config.set({
89
+ node: 'https://api.steemit.com',
90
+ address_prefix: 'STM'
70
91
  });
92
+
93
+ const account = await steem.api.getAccountAsync('ned');
94
+ console.log(account);
95
+ ```
96
+
97
+ ### Browser (Script Tag)
98
+
99
+ The UMD build includes all necessary dependencies and polyfills, so you can use it directly without any additional setup.
100
+
101
+ ```html
102
+ <!DOCTYPE html>
103
+ <html>
104
+ <head>
105
+ <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>
108
+ </head>
109
+ <body>
110
+ <script>
111
+ // Use the global 'steem' object
112
+ steem.config.set({
113
+ node: 'https://api.steemit.com',
114
+ address_prefix: 'STM'
115
+ });
116
+
117
+ // Get account information
118
+ steem.api.getAccountAsync('ned')
119
+ .then(account => {
120
+ console.log('Account:', account);
121
+ })
122
+ .catch(error => {
123
+ console.error('Error:', error);
124
+ });
125
+ </script>
126
+ </body>
127
+ </html>
71
128
  ```
72
129
 
73
- ### Broadcast Vote with Promises
74
- ```js
75
- var steem = require('steem');
76
-
77
- var wif = steem.auth.toWif(username, password, 'posting');
78
- // Using Promises
79
- steem.broadcast.vote(wif, voter, author, permlink, weight)
80
- .then(result => console.log(result))
81
- .catch(error => console.error(error));
82
-
83
- // Or using async/await
84
- async function castVote() {
85
- try {
86
- const result = await steem.broadcast.vote(wif, voter, author, permlink, weight);
87
- console.log(result);
88
- } catch (error) {
89
- console.error(error);
90
- }
91
- }
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.
131
+
132
+ ### Broadcast Operations
133
+
134
+ ```typescript
135
+ import { steem } from '@steemit/steem-js';
136
+
137
+ // Vote on a post
138
+ const postingWif = steem.auth.toWif('username', 'password', 'posting');
139
+ await steem.broadcast.voteAsync(
140
+ postingWif,
141
+ 'voter',
142
+ 'author',
143
+ 'permlink',
144
+ 10000 // weight
145
+ );
146
+
147
+ // Transfer STEEM
148
+ await steem.broadcast.transferAsync(
149
+ activeWif,
150
+ 'from',
151
+ 'to',
152
+ '1.000 STEEM',
153
+ 'memo'
154
+ );
92
155
  ```
93
156
 
94
- ### Get Accounts
95
- ```js
96
- steem.api.getAccounts(['ned', 'dan'], function(err, result) {
97
- console.log(err, result);
98
- });
157
+ ## Development
158
+
159
+ ### Build
160
+
161
+ ```bash
162
+ pnpm build
99
163
  ```
100
164
 
101
- ### Get State
102
- ```js
103
- steem.api.getState('/trends/funny', function(err, result) {
104
- console.log(err, result);
105
- });
165
+ ### Test
166
+
167
+ ```bash
168
+ # Run all tests
169
+ pnpm test
170
+
171
+ # Run tests in watch mode
172
+ pnpm test:watch
173
+
174
+ # Run tests with coverage
175
+ pnpm test:coverage
106
176
  ```
107
177
 
108
- ### Reputation Formatter
109
- ```js
110
- var reputation = steem.formatter.reputation(user.reputation);
111
- console.log(reputation);
178
+ ### Type Check
179
+
180
+ ```bash
181
+ pnpm typecheck
112
182
  ```
113
183
 
114
- ### Steem Testnet
115
- Steem-js requires some configuration to work on the public Steem testnet.
184
+ ### Lint
116
185
 
117
- You need to set two Steem API options, `address_prefix` and `chain_id`.
118
- ```js
119
- steem.api.setOptions({
120
- address_prefix: 'TST',
121
- chain_id: '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32',
122
- useTestNet: true,
123
- });
186
+ ```bash
187
+ pnpm lint
188
+ ```
189
+
190
+ ## Project Structure
191
+
192
+ ```
193
+ src/
194
+ api/ # API client with HTTP and WebSocket transports
195
+ auth/ # Authentication and key management
196
+ broadcast/ # Transaction broadcasting
197
+ crypto/ # Cryptographic utilities
198
+ formatter/ # Data formatting
199
+ memo/ # Encrypted memo handling
200
+ operations/ # Operation type definitions
201
+ serializer/ # Transaction serialization
202
+ utils/ # Utility functions
124
203
  ```
125
204
 
126
- The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements.
205
+ ## Key Features
206
+
207
+ - **Type Safety**: Full TypeScript support with type definitions
208
+ - **Modern ES Modules**: Uses ES modules with CommonJS fallback
209
+ - **Secure Cryptography**: Proper implementation using Node.js crypto module
210
+ - **Multiple Transports**: Supports both HTTP and WebSocket connections
211
+ - **Promise and Callback Support**: Compatible with both async/await and callback patterns
127
212
 
128
- ## Contributions
129
- Patches are welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them. If you would like to contribute, but don't know what to work on, check the issues list.
213
+ ## Breaking Changes from Original
130
214
 
131
- ## Issues
132
- When you find issues, please report them!
215
+ This is a complete refactor with the following changes:
216
+
217
+ 1. **TypeScript**: All code is now TypeScript
218
+ 2. **ES Modules**: Uses ES modules by default (CommonJS available)
219
+ 3. **Build System**: Uses Rollup instead of Webpack
220
+ 4. **Testing**: Uses Vitest instead of Mocha
221
+ 5. **API**: Some method signatures may have changed for better type safety
222
+
223
+ ## Security Notes
224
+
225
+ - Private keys are never logged or exposed
226
+ - Uses cryptographically secure random number generation
227
+ - All cryptographic operations use proper implementations
133
228
 
134
229
  ## License
230
+
135
231
  MIT
232
+
@@ -0,0 +1,128 @@
1
+ import { EventEmitter } from 'events';
2
+ import Bluebird from 'bluebird';
3
+ interface ApiOptions {
4
+ url?: string;
5
+ uri?: string;
6
+ /**
7
+ * WebSocket URL
8
+ * NOTE: WebSocket functionality is currently not supported.
9
+ * This field is kept for backward compatibility only.
10
+ * Please use HTTP transport (via url or uri field) for API calls.
11
+ */
12
+ websocket?: string;
13
+ transport?: string | any;
14
+ logger?: any;
15
+ useTestNet?: boolean;
16
+ useAppbaseApi?: boolean;
17
+ }
18
+ export declare class Api extends EventEmitter {
19
+ private seqNo;
20
+ private _transportType;
21
+ private transport;
22
+ private options;
23
+ private __logger;
24
+ private static _wrapWithPromise;
25
+ constructor(options?: ApiOptions);
26
+ private _setTransport;
27
+ private _setLogger;
28
+ log(logLevel: string, ...args: any[]): void;
29
+ start(): any;
30
+ stop(): any;
31
+ send(api: string, data: any, callback: any): any;
32
+ call(method: string, params: any[], callback: any): void;
33
+ signedCall(method: string, params: any[], account: string, key: string, callback: any): void;
34
+ setOptions(options: ApiOptions): void;
35
+ /**
36
+ * Set WebSocket URL
37
+ *
38
+ * NOTE: WebSocket functionality is currently not supported.
39
+ * This method is kept for backward compatibility only.
40
+ * Please use HTTP transport (via setOptions({ url: 'https://api.steemit.com' })) for API calls.
41
+ */
42
+ setWebSocket(url: string): void;
43
+ setUri(url: string): void;
44
+ streamBlockNumber(mode: string | undefined, callback: any, ts?: number): () => void;
45
+ streamBlock(mode: string | undefined, callback: any): () => void;
46
+ streamTransactions(mode: string | undefined, callback: any): () => void;
47
+ streamOperations(mode: string | undefined, callback: any): () => void;
48
+ broadcastTransactionSynchronousWith(options: any, callback: any): void;
49
+ /**
50
+ * Broadcast a transaction to the blockchain.
51
+ * @param trx The transaction object
52
+ * @param callback Callback function
53
+ */
54
+ broadcastTransaction(trx: any, callback: any): void;
55
+ /**
56
+ * Sign a transaction with the provided private key(s).
57
+ * @param trx The transaction object
58
+ * @param keys Array of WIF private keys
59
+ * @returns Signed transaction object
60
+ */
61
+ signTransaction(trx: any, keys: string[]): any;
62
+ /**
63
+ * Get a single account by name (backward compatibility).
64
+ * @param name The account name
65
+ * @param callback Optional callback
66
+ * @returns Account object or Promise
67
+ */
68
+ getAccount(name: string, callback?: (err: any, result?: any) => void): Bluebird<any> | void;
69
+ /**
70
+ * Get followers for an account (backward compatibility).
71
+ * @param account The account name
72
+ * @param startFollower The follower to start from
73
+ * @param type The type of follow
74
+ * @param limit The number of followers to return
75
+ * @param callback Optional callback
76
+ * @returns Array of followers or Promise
77
+ */
78
+ getFollowers(account: string, startFollower: string, type: string, limit: number, callback?: (err: any, result?: any) => void): Bluebird<any[]> | void;
79
+ /**
80
+ * Broadcast a transaction with a confirmation callback.
81
+ * @param confirmationCallback Callback function for transaction confirmation
82
+ * @param trx Transaction object to broadcast
83
+ * @param callback Callback function
84
+ */
85
+ broadcastTransactionWithCallback(confirmationCallback: any, trx: any, callback: any): void;
86
+ /**
87
+ * Broadcast a block to the network.
88
+ * @param block Block object to broadcast
89
+ * @param callback Callback function
90
+ */
91
+ broadcastBlock(block: any, callback: any): void;
92
+ /**
93
+ * Set the maximum block age for transaction acceptance.
94
+ * @param maxBlockAge Maximum block age in seconds
95
+ * @param callback Callback function
96
+ */
97
+ setMaxBlockAge(maxBlockAge: number, callback: any): void;
98
+ /**
99
+ * Verify transaction authority.
100
+ * @param trx Transaction object to verify
101
+ * @param callback Optional callback function
102
+ * @returns Promise with verification result if no callback provided
103
+ */
104
+ verifyAuthority(trx: any, callback?: (err: any, result?: boolean) => void): Bluebird<boolean> | void;
105
+ /**
106
+ * Verify account authority.
107
+ * @param nameOrId Account name or ID
108
+ * @param signers Array of signer public keys
109
+ * @param callback Optional callback function
110
+ * @returns Promise with verification result if no callback provided
111
+ */
112
+ verifyAccountAuthority(nameOrId: string, signers: string[], callback?: (err: any, result?: boolean) => void): Bluebird<boolean> | void;
113
+ }
114
+ declare const api: Api;
115
+ export declare function setOptions(options: ApiOptions): void;
116
+ export declare function call(method: string, params: any[], callback: any): void;
117
+ export declare function signTransaction(trx: any, keys: string[]): any;
118
+ export declare function verifyAuthority(..._args: any[]): boolean;
119
+ export default api;
120
+ export declare const getDynamicGlobalPropertiesAsync: any;
121
+ export declare const getBlockAsync: any;
122
+ export declare const getFollowersAsync: any;
123
+ export declare const getContentAsync: any;
124
+ export declare const listeners: (...args: any[]) => any;
125
+ export declare const streamBlockNumber: (...args: any[]) => any;
126
+ export declare const streamBlock: (...args: any[]) => any;
127
+ export declare const streamTransactions: (...args: any[]) => any;
128
+ export declare const streamOperations: (...args: any[]) => any;
@@ -0,0 +1,9 @@
1
+ interface ApiMethod {
2
+ api: string;
3
+ method: string;
4
+ method_name?: string;
5
+ params?: string[];
6
+ is_object?: boolean;
7
+ }
8
+ declare const methods: ApiMethod[];
9
+ export default methods;
@@ -0,0 +1,43 @@
1
+ interface RpcRequest {
2
+ method: string;
3
+ params: any[];
4
+ id: number;
5
+ }
6
+ interface SignedRequest {
7
+ jsonrpc: string;
8
+ method: string;
9
+ id: number;
10
+ params: {
11
+ __signed: {
12
+ account: string;
13
+ nonce: string;
14
+ params: string;
15
+ signatures: string[];
16
+ timestamp: string;
17
+ };
18
+ };
19
+ }
20
+ /**
21
+ * Signing constant used to reserve opcode space and prevent cross-protocol attacks.
22
+ * Output of `sha256('steem_jsonrpc_auth')`.
23
+ */
24
+ export declare const K: Buffer<ArrayBuffer>;
25
+ /**
26
+ * Sign a JSON RPC Request.
27
+ */
28
+ export declare function sign(request: RpcRequest, account: string, keys: string[]): SignedRequest;
29
+ /**
30
+ * Validate a signed JSON RPC request.
31
+ * Throws a ValidationError if the request fails validation.
32
+ *
33
+ * @param request The signed JSON RPC request to validate
34
+ * @param verify Function to verify signatures against public keys
35
+ * @returns Resolved request params
36
+ */
37
+ export declare function validate(request: SignedRequest, verify: (message: Buffer, signatures: string[], account: string) => Promise<void>): Promise<any>;
38
+ declare const _default: {
39
+ sign: typeof sign;
40
+ validate: typeof validate;
41
+ K: Buffer<ArrayBuffer>;
42
+ };
43
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { EventEmitter } from 'events';
2
+ import { Transport, TransportOptions } from './types';
3
+ export declare class BaseTransport extends EventEmitter implements Transport {
4
+ options: TransportOptions;
5
+ id: number;
6
+ constructor(options?: TransportOptions);
7
+ setOptions(options: TransportOptions): void;
8
+ listenTo(target: EventEmitter, eventName: string, callback: (...args: any[]) => void): () => void;
9
+ send(_api: string, _data: any, _callback: (error: any, result?: any) => void): void;
10
+ start(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ }
13
+ export default BaseTransport;
@@ -0,0 +1,9 @@
1
+ import { TransportOptions, JsonRpcRequest } from './types';
2
+ import { BaseTransport } from './base';
3
+ export declare const jsonRpc: (uri: string, request: Partial<JsonRpcRequest>) => Promise<any>;
4
+ export declare class HttpTransport extends BaseTransport {
5
+ constructor(options: TransportOptions);
6
+ get nonRetriableOperations(): string[];
7
+ isBroadcastOperation(method: string): boolean;
8
+ send(api: string, data: any, callback?: (err: any, result?: any, attempt?: number) => void): void;
9
+ }
@@ -0,0 +1,9 @@
1
+ import { HttpTransport } from './http';
2
+ import { WsTransport } from './ws';
3
+ import { BaseTransport } from './base';
4
+ export * from './types';
5
+ export declare const transports: {
6
+ http: typeof HttpTransport;
7
+ ws: typeof WsTransport;
8
+ };
9
+ export { BaseTransport };
@@ -0,0 +1,35 @@
1
+ export interface TransportOptions {
2
+ url?: string;
3
+ uri?: string;
4
+ /**
5
+ * WebSocket URL
6
+ * NOTE: WebSocket functionality is currently not supported.
7
+ * This field is kept for backward compatibility only.
8
+ * Please use HTTP transport (via url or uri field) for API calls.
9
+ */
10
+ websocket?: string;
11
+ transport?: string | any;
12
+ [key: string]: any;
13
+ }
14
+ export interface JsonRpcRequest {
15
+ id: number;
16
+ method: string;
17
+ params: any[];
18
+ jsonrpc?: string;
19
+ }
20
+ export interface JsonRpcResponse {
21
+ id: number;
22
+ result: any;
23
+ error?: {
24
+ code: number;
25
+ message: string;
26
+ data?: any;
27
+ };
28
+ }
29
+ export interface Transport {
30
+ options: TransportOptions;
31
+ start(): Promise<void>;
32
+ stop(): Promise<void>;
33
+ setOptions(options: TransportOptions): void;
34
+ send(api: string, data: any, callback: (error: any, result?: any) => void): void | Promise<void>;
35
+ }
@@ -0,0 +1,18 @@
1
+ import { TransportOptions } from './types';
2
+ import { BaseTransport } from './base';
3
+ /**
4
+ * WebSocket transport implementation
5
+ *
6
+ * NOTE: WebSocket functionality is currently not supported.
7
+ * This implementation is kept for backward compatibility only.
8
+ * Please use HTTP transport (via https://api.steemit.com) for API calls.
9
+ */
10
+ export declare class WsTransport extends BaseTransport {
11
+ private ws;
12
+ private _requests;
13
+ private seqNo;
14
+ constructor(options: TransportOptions);
15
+ start(): Promise<void>;
16
+ stop(): Promise<void>;
17
+ send(api: string, data: any, callback: (error: any, result?: any) => void): void;
18
+ }
@@ -0,0 +1,9 @@
1
+ export { Address } from './src/address';
2
+ export { Aes } from './src/aes';
3
+ export { PrivateKey } from './src/key_private';
4
+ export { PublicKey } from './src/key_public';
5
+ export { Signature } from './src/signature';
6
+ export { normalize as brainKey } from './src/brain_key';
7
+ export * as key_utils from './src/key_utils';
8
+ export * as hash from './src/hash';
9
+ export { Config as ecc_config } from '../../config';
@@ -0,0 +1,13 @@
1
+ import { PublicKey } from './key_public';
2
+ export declare class Address {
3
+ private addy;
4
+ constructor(addy: Buffer);
5
+ static fromBuffer(buffer: Buffer): string;
6
+ static fromString(address: string): Buffer;
7
+ static fromPublicKey(public_key: PublicKey, compressed?: boolean): string;
8
+ static fromPublic(public_key: PublicKey, compressed?: boolean, version?: number): Address;
9
+ static toBuffer(address: string): Buffer;
10
+ toBuffer(): Buffer;
11
+ getVersion(): number;
12
+ toString(address_prefix?: string): string;
13
+ }
@@ -0,0 +1,16 @@
1
+ import { PrivateKey } from './key_private';
2
+ import { PublicKey } from './key_public';
3
+ export declare class Aes {
4
+ static uniqueNonce(): string;
5
+ static encrypt(private_key: PrivateKey, public_key: PublicKey, message: Buffer | string, nonce?: string): {
6
+ nonce: string;
7
+ message: string;
8
+ checksum: number;
9
+ };
10
+ static decrypt(private_key: PrivateKey, public_key: PublicKey, nonce: string, message: string, checksum: number): Buffer;
11
+ static fromSeed(seed: string): Buffer;
12
+ static fromBuffer(buffer: Buffer): Buffer;
13
+ static fromString(string: string): Buffer;
14
+ static toBuffer(aes: Buffer): Buffer;
15
+ static toString(aes: Buffer): string;
16
+ }
@@ -0,0 +1 @@
1
+ export declare function normalize(brain_key: string): string;