@steemit/steem-js 0.0.8

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 (51) hide show
  1. package/README.md +232 -0
  2. package/dist/api/index.d.ts +115 -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 +29 -0
  9. package/dist/api/transports/ws.d.ts +11 -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 +25766 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.js +25730 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/index.umd.js +57431 -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 +28 -0
  49. package/dist/utils/index.d.ts +8 -0
  50. package/dist/utils.d.ts +2 -0
  51. package/package.json +85 -0
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ # Steem.js
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
29
+ ```
30
+
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
41
+ ```
42
+
43
+ ### Browser (CDN)
44
+
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>
48
+ ```
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);
81
+ ```
82
+
83
+ ### Node.js / CommonJS
84
+
85
+ ```javascript
86
+ const { steem } = require('@steemit/steem-js');
87
+
88
+ steem.config.set({
89
+ node: 'https://api.steemit.com',
90
+ address_prefix: 'STM'
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>
128
+ ```
129
+
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
+ );
155
+ ```
156
+
157
+ ## Development
158
+
159
+ ### Build
160
+
161
+ ```bash
162
+ pnpm build
163
+ ```
164
+
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
176
+ ```
177
+
178
+ ### Type Check
179
+
180
+ ```bash
181
+ pnpm typecheck
182
+ ```
183
+
184
+ ### Lint
185
+
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
203
+ ```
204
+
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
212
+
213
+ ## Breaking Changes from Original
214
+
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
228
+
229
+ ## License
230
+
231
+ MIT
232
+
@@ -0,0 +1,115 @@
1
+ import { EventEmitter } from 'events';
2
+ import Bluebird from 'bluebird';
3
+ interface ApiOptions {
4
+ url?: string;
5
+ uri?: string;
6
+ websocket?: string;
7
+ transport?: string | any;
8
+ logger?: any;
9
+ useTestNet?: boolean;
10
+ useAppbaseApi?: boolean;
11
+ }
12
+ export declare class Api extends EventEmitter {
13
+ private seqNo;
14
+ private _transportType;
15
+ private transport;
16
+ private options;
17
+ private __logger;
18
+ private static _wrapWithPromise;
19
+ constructor(options?: ApiOptions);
20
+ private _setTransport;
21
+ private _setLogger;
22
+ log(logLevel: string, ...args: any[]): void;
23
+ start(): any;
24
+ stop(): any;
25
+ send(api: string, data: any, callback: any): any;
26
+ call(method: string, params: any[], callback: any): void;
27
+ signedCall(method: string, params: any[], account: string, key: string, callback: any): void;
28
+ setOptions(options: ApiOptions): void;
29
+ setWebSocket(url: string): void;
30
+ setUri(url: string): void;
31
+ streamBlockNumber(mode: string | undefined, callback: any, ts?: number): () => void;
32
+ streamBlock(mode: string | undefined, callback: any): () => void;
33
+ streamTransactions(mode: string | undefined, callback: any): () => void;
34
+ streamOperations(mode: string | undefined, callback: any): () => void;
35
+ broadcastTransactionSynchronousWith(options: any, callback: any): void;
36
+ /**
37
+ * Broadcast a transaction to the blockchain.
38
+ * @param trx The transaction object
39
+ * @param callback Callback function
40
+ */
41
+ broadcastTransaction(trx: any, callback: any): void;
42
+ /**
43
+ * Sign a transaction with the provided private key(s).
44
+ * @param trx The transaction object
45
+ * @param keys Array of WIF private keys
46
+ * @returns Signed transaction object
47
+ */
48
+ signTransaction(trx: any, keys: string[]): any;
49
+ /**
50
+ * Get a single account by name (backward compatibility).
51
+ * @param name The account name
52
+ * @param callback Optional callback
53
+ * @returns Account object or Promise
54
+ */
55
+ getAccount(name: string, callback?: (err: any, result?: any) => void): Bluebird<any> | void;
56
+ /**
57
+ * Get followers for an account (backward compatibility).
58
+ * @param account The account name
59
+ * @param startFollower The follower to start from
60
+ * @param type The type of follow
61
+ * @param limit The number of followers to return
62
+ * @param callback Optional callback
63
+ * @returns Array of followers or Promise
64
+ */
65
+ getFollowers(account: string, startFollower: string, type: string, limit: number, callback?: (err: any, result?: any) => void): Bluebird<any[]> | void;
66
+ /**
67
+ * Broadcast a transaction with a confirmation callback.
68
+ * @param confirmationCallback Callback function for transaction confirmation
69
+ * @param trx Transaction object to broadcast
70
+ * @param callback Callback function
71
+ */
72
+ broadcastTransactionWithCallback(confirmationCallback: any, trx: any, callback: any): void;
73
+ /**
74
+ * Broadcast a block to the network.
75
+ * @param block Block object to broadcast
76
+ * @param callback Callback function
77
+ */
78
+ broadcastBlock(block: any, callback: any): void;
79
+ /**
80
+ * Set the maximum block age for transaction acceptance.
81
+ * @param maxBlockAge Maximum block age in seconds
82
+ * @param callback Callback function
83
+ */
84
+ setMaxBlockAge(maxBlockAge: number, callback: any): void;
85
+ /**
86
+ * Verify transaction authority.
87
+ * @param trx Transaction object to verify
88
+ * @param callback Optional callback function
89
+ * @returns Promise with verification result if no callback provided
90
+ */
91
+ verifyAuthority(trx: any, callback?: (err: any, result?: boolean) => void): Bluebird<boolean> | void;
92
+ /**
93
+ * Verify account authority.
94
+ * @param nameOrId Account name or ID
95
+ * @param signers Array of signer public keys
96
+ * @param callback Optional callback function
97
+ * @returns Promise with verification result if no callback provided
98
+ */
99
+ verifyAccountAuthority(nameOrId: string, signers: string[], callback?: (err: any, result?: boolean) => void): Bluebird<boolean> | void;
100
+ }
101
+ declare const api: Api;
102
+ export declare function setOptions(options: ApiOptions): void;
103
+ export declare function call(method: string, params: any[], callback: any): void;
104
+ export declare function signTransaction(trx: any, keys: string[]): any;
105
+ export declare function verifyAuthority(..._args: any[]): boolean;
106
+ export default api;
107
+ export declare const getDynamicGlobalPropertiesAsync: any;
108
+ export declare const getBlockAsync: any;
109
+ export declare const getFollowersAsync: any;
110
+ export declare const getContentAsync: any;
111
+ export declare const listeners: (...args: any[]) => any;
112
+ export declare const streamBlockNumber: (...args: any[]) => any;
113
+ export declare const streamBlock: (...args: any[]) => any;
114
+ export declare const streamTransactions: (...args: any[]) => any;
115
+ 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,29 @@
1
+ export interface TransportOptions {
2
+ url?: string;
3
+ uri?: string;
4
+ websocket?: string;
5
+ transport?: string | any;
6
+ [key: string]: any;
7
+ }
8
+ export interface JsonRpcRequest {
9
+ id: number;
10
+ method: string;
11
+ params: any[];
12
+ jsonrpc?: string;
13
+ }
14
+ export interface JsonRpcResponse {
15
+ id: number;
16
+ result: any;
17
+ error?: {
18
+ code: number;
19
+ message: string;
20
+ data?: any;
21
+ };
22
+ }
23
+ export interface Transport {
24
+ options: TransportOptions;
25
+ start(): Promise<void>;
26
+ stop(): Promise<void>;
27
+ setOptions(options: TransportOptions): void;
28
+ send(api: string, data: any, callback: (error: any, result?: any) => void): void | Promise<void>;
29
+ }
@@ -0,0 +1,11 @@
1
+ import { TransportOptions } from './types';
2
+ import { BaseTransport } from './base';
3
+ export declare class WsTransport extends BaseTransport {
4
+ private ws;
5
+ private _requests;
6
+ private seqNo;
7
+ constructor(options: TransportOptions);
8
+ start(): Promise<void>;
9
+ stop(): Promise<void>;
10
+ send(api: string, data: any, callback: (error: any, result?: any) => void): void;
11
+ }
@@ -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;
@@ -0,0 +1,28 @@
1
+ import BigInteger from 'bigi';
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;
7
+ /**
8
+ * Recover a public key from a signature.
9
+ *
10
+ * See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
11
+ * Key Recovery Operation".
12
+ *
13
+ * http://www.secg.org/download/aid-780/sec1-v2.pdf
14
+ */
15
+ export declare function recoverPubKey(curve: Curve, e: BigInteger, signature: ECSignature, i: number): Point;
16
+ /**
17
+ * Calculate pubkey extraction parameter.
18
+ *
19
+ * When extracting a pubkey from a signature, we have to
20
+ * distinguish four different cases. Rather than putting this
21
+ * burden on the verifier, Bitcoin includes a 2-bit value with the
22
+ * signature.
23
+ *
24
+ * This function simply tries all four cases and returns the value
25
+ * that resulted in a successful pubkey recovery.
26
+ */
27
+ export declare function calcPubKeyRecoveryParam(curve: Curve, e: BigInteger, signature: ECSignature, Q: Point): number;
28
+ export {};
@@ -0,0 +1,19 @@
1
+ import BigInteger from 'bigi';
2
+ export default class ECSignature {
3
+ r: BigInteger;
4
+ s: BigInteger;
5
+ constructor(r: BigInteger, s: BigInteger);
6
+ static parseCompact(buffer: Buffer): {
7
+ compressed: boolean;
8
+ i: number;
9
+ signature: ECSignature;
10
+ };
11
+ static fromDER(buffer: Buffer): ECSignature;
12
+ static parseScriptSignature(buffer: Buffer): {
13
+ signature: ECSignature;
14
+ hashType: number;
15
+ };
16
+ toCompact(i: number, compressed: boolean): Buffer;
17
+ toDER(): Buffer;
18
+ toScriptSignature(hashType: number): Buffer;
19
+ }
@@ -0,0 +1,5 @@
1
+ type TypeName = 'Array' | 'Boolean' | 'Buffer' | 'Number' | 'String' | {
2
+ new (...args: any[]): any;
3
+ };
4
+ export default function enforce(type: TypeName, value: any): void;
5
+ export {};
@@ -0,0 +1,25 @@
1
+ /** @arg {string|Buffer} data
2
+ @arg {string} [digest = null] - 'hex', 'binary' or 'base64'
3
+ @return {string|Buffer} - Buffer when digest is null, or string
4
+ */
5
+ export declare function sha1(data: string | Buffer, encoding?: BufferEncoding): string | Buffer;
6
+ /** @arg {string|Buffer} data
7
+ @arg {string} [digest = null] - 'hex', 'binary' or 'base64'
8
+ @return {string|Buffer} - Buffer when digest is null, or string
9
+ */
10
+ export declare function sha256(data: string | Buffer, encoding?: BufferEncoding): Buffer;
11
+ /** @arg {string|Buffer} data
12
+ @arg {string} [digest = null] - 'hex', 'binary' or 'base64'
13
+ @return {string|Buffer} - Buffer when digest is null, or string
14
+ */
15
+ export declare function sha512(data: string | Buffer, encoding?: BufferEncoding): Buffer;
16
+ export declare function HmacSHA256(buffer: Buffer, secret: Buffer): Buffer;
17
+ export declare function ripemd160(data: string | Buffer): Buffer;
18
+ declare const _default: {
19
+ sha1: typeof sha1;
20
+ sha256: typeof sha256;
21
+ sha512: typeof sha512;
22
+ HmacSHA256: typeof HmacSHA256;
23
+ ripemd160: typeof ripemd160;
24
+ };
25
+ export default _default;
@@ -0,0 +1,9 @@
1
+ export { Address } from './address';
2
+ export { Aes } from './aes';
3
+ export { PrivateKey } from './key_private';
4
+ export { PublicKey } from './key_public';
5
+ export { Signature } from './signature';
6
+ export { normalize as brainKey } from './brain_key';
7
+ export * as key_utils from './key_utils';
8
+ export * as hash from './hash';
9
+ export { Config as ecc_config } from '../../../config';
@@ -0,0 +1,38 @@
1
+ import BigInteger from 'bigi';
2
+ import { PublicKey } from './key_public';
3
+ type Point = any;
4
+ export declare class PrivateKey {
5
+ d: BigInteger;
6
+ public_key?: PublicKey;
7
+ /**
8
+ * @private see static functions
9
+ * @param {BigInteger} d
10
+ */
11
+ constructor(d: BigInteger);
12
+ static fromBuffer(buf: Buffer): PrivateKey;
13
+ /** @arg {string} seed - any length string. This is private, the same seed produces the same private key every time. */
14
+ static fromSeed(seed: string): PrivateKey;
15
+ static isWif(text: string): boolean;
16
+ /**
17
+ * @throws {AssertError|Error} parsing key
18
+ * @return {string} Wallet Import Format (still a secret, Not encrypted)
19
+ */
20
+ static fromWif(private_wif: string): PrivateKey;
21
+ toWif(): string;
22
+ /** Alias for {@link toWif} */
23
+ toString(): string;
24
+ /**
25
+ * @return {Point}
26
+ */
27
+ toPublicKeyPoint(): Point;
28
+ toPublic(): PublicKey;
29
+ toBuffer(): Buffer;
30
+ /** ECIES */
31
+ get_shared_secret(public_key: PublicKey | string): Buffer;
32
+ /** @throws {Error} - overflow of the key could not be derived */
33
+ child(offset: Buffer): PrivateKey;
34
+ static fromHex(hex: string): PrivateKey;
35
+ toHex(): string;
36
+ toPublicKey(): PublicKey;
37
+ }
38
+ export {};