@steemit/steem-js 1.0.4 → 1.0.6

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 (48) hide show
  1. package/README.md +9 -1
  2. package/dist/api/index.d.ts +50 -55
  3. package/dist/api/rpc-auth.d.ts +2 -2
  4. package/dist/api/signature-verification.d.ts +92 -0
  5. package/dist/api/transports/base.d.ts +2 -2
  6. package/dist/api/transports/http.d.ts +16 -2
  7. package/dist/api/transports/index.d.ts +0 -2
  8. package/dist/api/transports/types.d.ts +6 -6
  9. package/dist/api/transports/ws.d.ts +1 -0
  10. package/dist/auth/ecc/src/ecdsa.d.ts +1 -1
  11. package/dist/auth/ecc/src/enforce_types.d.ts +2 -2
  12. package/dist/auth/ecc/src/hash.d.ts +4 -2
  13. package/dist/auth/ecc/src/key_private.d.ts +3 -1
  14. package/dist/auth/ecc/src/key_public.d.ts +8 -6
  15. package/dist/auth/index.d.ts +6 -5
  16. package/dist/auth/serializer/transaction.d.ts +1 -1
  17. package/dist/auth/serializer.d.ts +3 -3
  18. package/dist/broadcast/helpers.d.ts +23 -4
  19. package/dist/broadcast/index.d.ts +24 -22
  20. package/dist/browser.esm.js +28921 -0
  21. package/dist/browser.esm.js.map +1 -0
  22. package/dist/config.d.ts +4 -5
  23. package/dist/crypto/browser-crypto.d.ts +43 -0
  24. package/dist/crypto/random-bytes.d.ts +12 -0
  25. package/dist/formatter/index.d.ts +1 -1
  26. package/dist/index.browser.js +56378 -0
  27. package/dist/index.browser.js.map +1 -0
  28. package/dist/index.cjs +24067 -35324
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.js +24053 -35302
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.umd.js +18077 -48081
  34. package/dist/index.umd.js.map +1 -1
  35. package/dist/index.umd.min.js +1 -1
  36. package/dist/index.umd.min.js.map +1 -1
  37. package/dist/polyfills/async-hooks-browser.d.ts +6 -0
  38. package/dist/polyfills/secure-random-browser.d.ts +8 -0
  39. package/dist/serializer/convert.d.ts +15 -6
  40. package/dist/serializer/index.d.ts +3 -3
  41. package/dist/serializer/precision.d.ts +1 -1
  42. package/dist/serializer/types.d.ts +9 -9
  43. package/dist/types/index.d.ts +9 -9
  44. package/dist/types.d.ts +2 -2
  45. package/dist/umd.d.ts +3 -3
  46. package/dist/utils/debug.d.ts +5 -5
  47. package/dist/utils/promisify.d.ts +7 -3
  48. package/package.json +17 -16
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Steem.js
2
2
 
3
+ > ⚠️ Under Construction: This SDK is currently under active development. Do not use it in the production environment.
4
+
3
5
  A modern JavaScript/TypeScript library for interacting with the Steem blockchain. Complete refactoring with TypeScript, modern tooling, and improved security.
4
6
 
5
7
  [![npm version](https://img.shields.io/npm/v/@steemit/steem-js.svg)](https://www.npmjs.com/package/@steemit/steem-js)
@@ -13,6 +15,11 @@ A modern JavaScript/TypeScript library for interacting with the Steem blockchain
13
15
 
14
16
  ## 🚀 Quick Start
15
17
 
18
+ ### Requirements
19
+
20
+ - **Node.js**: >= 18.0.0 (LTS recommended)
21
+ - **Browser**: Modern browsers with Web Crypto API support
22
+
16
23
  ### Installation
17
24
 
18
25
  ```bash
@@ -86,6 +93,7 @@ This is a complete modernization of the original steem-js library:
86
93
 
87
94
  - ✅ **TypeScript Migration** - Full type safety and better developer experience
88
95
  - ✅ **Modern Dependencies** - Replaced outdated crypto libraries (`bigi` → `bn.js`, `ecurve` → `elliptic`)
96
+ - ✅ **Modern Crypto** - Using @noble/hashes and @noble/ciphers for universal browser/Node.js compatibility
89
97
  - ✅ **Build System** - Migrated from Webpack to Rollup for better output
90
98
  - ✅ **Testing** - Migrated from Mocha to Vitest with 95.8% test coverage
91
99
  - ✅ **Security** - Fixed insecure random number generation and crypto implementations
@@ -94,7 +102,7 @@ This is a complete modernization of the original steem-js library:
94
102
 
95
103
  ```
96
104
  src/
97
- ├── api/ # Blockchain API client (HTTP/WebSocket)
105
+ ├── api/ # Blockchain API client (HTTP)
98
106
  ├── auth/ # Authentication and key management
99
107
  ├── broadcast/ # Transaction broadcasting
100
108
  ├── crypto/ # Cryptographic utilities
@@ -1,19 +1,19 @@
1
1
  import { EventEmitter } from 'events';
2
- import Bluebird from 'bluebird';
2
+ import type { Transport } from './transports/types';
3
+ import type { TransportOptions } from './transports/types';
3
4
  interface ApiOptions {
4
5
  url?: string;
5
6
  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;
7
+ transport?: string | (new (options: TransportOptions) => Transport);
8
+ logger?: Logger;
15
9
  useTestNet?: boolean;
16
10
  useAppbaseApi?: boolean;
11
+ fetchMethod?: typeof fetch;
12
+ [key: string]: unknown;
13
+ }
14
+ interface Logger {
15
+ log: (...args: unknown[]) => void;
16
+ [key: string]: (...args: unknown[]) => void;
17
17
  }
18
18
  export declare class Api extends EventEmitter {
19
19
  private seqNo;
@@ -25,47 +25,40 @@ export declare class Api extends EventEmitter {
25
25
  constructor(options?: ApiOptions);
26
26
  private _setTransport;
27
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;
28
+ log(logLevel: string, ...args: unknown[]): void;
29
+ start(): Promise<void>;
30
+ stop(): Promise<void>;
31
+ send(api: string, data: unknown, callback: unknown): void | Promise<void>;
32
+ call(method: string, params: unknown[], callback: (err: Error | null, result?: unknown) => void): void;
33
+ signedCall(method: string, params: unknown[], account: string, key: string, callback: (err: Error | null, result?: unknown) => void): void;
35
34
  /**
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.
35
+ * Verify a signed RPC request
36
+ * @param signedRequest The signed request to verify
37
+ * @param callback Callback function
41
38
  */
42
- setWebSocket(url: string): void;
39
+ verifySignedRequest(signedRequest: unknown, callback: (err: Error | null, result?: unknown) => void): void;
40
+ setOptions(options: ApiOptions): void;
43
41
  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;
42
+ streamBlockNumber(mode?: string | ((err: Error | null, blockNumber?: unknown) => void), callback?: (err: Error | null, blockNumber?: unknown) => void, ts?: number): () => void;
43
+ streamBlock(mode: string | undefined, callback: (err: Error | null, block?: unknown) => void): () => void;
44
+ streamTransactions(mode?: string | ((err: Error | null, tx?: unknown) => void), callback?: (err: Error | null, tx?: unknown) => void): () => void;
45
+ streamOperations(mode?: string | ((err: Error | null, op?: unknown) => void), callback?: (err: Error | null, op?: unknown) => void): () => void;
46
+ broadcastTransactionSynchronousWith(options: {
47
+ transaction: unknown;
48
+ }, callback: (err: Error | null, result?: unknown) => void): void;
49
49
  /**
50
50
  * Broadcast a transaction to the blockchain.
51
51
  * @param trx The transaction object
52
52
  * @param callback Callback function
53
53
  */
54
- broadcastTransaction(trx: any, callback: any): void;
54
+ broadcastTransaction(trx: unknown, callback: (err: Error | null, result?: unknown) => void): void;
55
55
  /**
56
56
  * Sign a transaction with the provided private key(s).
57
57
  * @param trx The transaction object
58
58
  * @param keys Array of WIF private keys
59
59
  * @returns Signed transaction object
60
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;
61
+ signTransaction(trx: unknown, keys: string[]): unknown;
69
62
  /**
70
63
  * Get followers for an account (backward compatibility).
71
64
  * @param account The account name
@@ -75,33 +68,33 @@ export declare class Api extends EventEmitter {
75
68
  * @param callback Optional callback
76
69
  * @returns Array of followers or Promise
77
70
  */
78
- getFollowers(account: string, startFollower: string, type: string, limit: number, callback?: (err: any, result?: any) => void): Bluebird<any[]> | void;
71
+ getFollowers(account: string, startFollower: string, type: string, limit: number, callback?: (err: Error | null, result?: unknown[]) => void): Promise<unknown[]> | void;
79
72
  /**
80
73
  * Broadcast a transaction with a confirmation callback.
81
74
  * @param confirmationCallback Callback function for transaction confirmation
82
75
  * @param trx Transaction object to broadcast
83
76
  * @param callback Callback function
84
77
  */
85
- broadcastTransactionWithCallback(confirmationCallback: any, trx: any, callback: any): void;
78
+ broadcastTransactionWithCallback(confirmationCallback: (result: unknown) => void, trx: unknown, callback: (err: Error | null, result?: unknown) => void): void;
86
79
  /**
87
80
  * Broadcast a block to the network.
88
81
  * @param block Block object to broadcast
89
82
  * @param callback Callback function
90
83
  */
91
- broadcastBlock(block: any, callback: any): void;
84
+ broadcastBlock(block: unknown, callback: (err: Error | null, result?: unknown) => void): void;
92
85
  /**
93
86
  * Set the maximum block age for transaction acceptance.
94
87
  * @param maxBlockAge Maximum block age in seconds
95
88
  * @param callback Callback function
96
89
  */
97
- setMaxBlockAge(maxBlockAge: number, callback: any): void;
90
+ setMaxBlockAge(maxBlockAge: number, callback: (err: Error | null, result?: unknown) => void): void;
98
91
  /**
99
92
  * Verify transaction authority.
100
93
  * @param trx Transaction object to verify
101
94
  * @param callback Optional callback function
102
95
  * @returns Promise with verification result if no callback provided
103
96
  */
104
- verifyAuthority(trx: any, callback?: (err: any, result?: boolean) => void): Bluebird<boolean> | void;
97
+ verifyAuthority(trx: unknown, callback?: (err: Error | null, result?: boolean) => void): Promise<boolean> | void;
105
98
  /**
106
99
  * Verify account authority.
107
100
  * @param nameOrId Account name or ID
@@ -109,20 +102,22 @@ export declare class Api extends EventEmitter {
109
102
  * @param callback Optional callback function
110
103
  * @returns Promise with verification result if no callback provided
111
104
  */
112
- verifyAccountAuthority(nameOrId: string, signers: string[], callback?: (err: any, result?: boolean) => void): Bluebird<boolean> | void;
105
+ verifyAccountAuthority(nameOrId: string, signers: string[], callback?: (err: Error | null, result?: boolean) => void): Promise<boolean> | void;
113
106
  }
114
107
  declare const api: Api;
115
108
  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;
109
+ export declare function call(method: string, params: unknown[], callback: (err: Error | null, result?: unknown) => void): void;
110
+ export declare function signTransaction(trx: unknown, keys: string[]): unknown;
111
+ export declare function verifyAuthority(..._args: unknown[]): boolean;
119
112
  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;
113
+ export declare const getDynamicGlobalPropertiesAsync: () => Promise<unknown>;
114
+ export declare const getBlockAsync: (...args: unknown[]) => Promise<unknown>;
115
+ export declare const getFollowersAsync: (...args: unknown[]) => Promise<unknown>;
116
+ export declare const getContentAsync: (...args: unknown[]) => Promise<unknown>;
117
+ export declare const listeners: (...args: unknown[]) => unknown;
118
+ export declare const streamBlockNumber: (...args: unknown[]) => unknown;
119
+ export declare const streamBlock: (...args: unknown[]) => unknown;
120
+ export declare const streamTransactions: (...args: unknown[]) => unknown;
121
+ export declare const streamOperations: (...args: unknown[]) => unknown;
122
+ export { sign as signRequest, validate as validateRequest } from './rpc-auth';
123
+ export * as signatureVerification from './signature-verification';
@@ -1,6 +1,6 @@
1
1
  interface RpcRequest {
2
2
  method: string;
3
- params: any[];
3
+ params: unknown[];
4
4
  id: number;
5
5
  }
6
6
  interface SignedRequest {
@@ -34,7 +34,7 @@ export declare function sign(request: RpcRequest, account: string, keys: string[
34
34
  * @param verify Function to verify signatures against public keys
35
35
  * @returns Resolved request params
36
36
  */
37
- export declare function validate(request: SignedRequest, verify: (message: Buffer, signatures: string[], account: string) => Promise<void>): Promise<any>;
37
+ export declare function validate(request: SignedRequest, verify: (message: Buffer, signatures: string[], account: string) => Promise<void>): Promise<unknown>;
38
38
  declare const _default: {
39
39
  sign: typeof sign;
40
40
  validate: typeof validate;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Signature Verification Utilities for Steem.js
3
+ *
4
+ * This module provides comprehensive signature verification functionality
5
+ * for signed RPC requests and general message signatures.
6
+ */
7
+ export interface SignedRequest {
8
+ jsonrpc: string;
9
+ method: string;
10
+ id: number;
11
+ params: {
12
+ __signed: {
13
+ account: string;
14
+ nonce: string;
15
+ params: string;
16
+ signatures: string[];
17
+ timestamp: string;
18
+ };
19
+ };
20
+ }
21
+ export interface VerificationResult {
22
+ valid: boolean;
23
+ account?: string;
24
+ params?: unknown;
25
+ error?: string;
26
+ timestamp?: string;
27
+ signatures?: string[];
28
+ }
29
+ export interface AccountKeys {
30
+ owner: string[];
31
+ active: string[];
32
+ posting: string[];
33
+ memo: string;
34
+ }
35
+ /**
36
+ * Verify a signed RPC request against account's public keys
37
+ */
38
+ export declare function verifySignedRequest(signedRequest: SignedRequest, getAccountKeys: (account: string) => Promise<AccountKeys>): Promise<VerificationResult>;
39
+ /**
40
+ * Verify a simple message signature
41
+ */
42
+ export declare function verifyMessageSignature(message: string | Buffer, signature: string, publicKey: string): boolean;
43
+ /**
44
+ * Verify multiple signatures against multiple public keys
45
+ */
46
+ export declare function verifyMultipleSignatures(message: string | Buffer, signatures: string[], publicKeys: string[]): {
47
+ verified: boolean;
48
+ validSignatures: number;
49
+ details: Array<{
50
+ signature: string;
51
+ publicKey: string;
52
+ valid: boolean;
53
+ }>;
54
+ };
55
+ /**
56
+ * Extract account keys from Steem account data
57
+ */
58
+ export declare function extractAccountKeys(accountData: unknown): AccountKeys;
59
+ /**
60
+ * Create a verification function for use with API calls
61
+ */
62
+ export declare function createApiVerificationFunction(api: {
63
+ call: (method: string, params: unknown[], callback: (err: Error | null, result?: unknown) => void) => void;
64
+ }): (account: string) => Promise<AccountKeys>;
65
+ /**
66
+ * Batch verify multiple signed requests
67
+ */
68
+ export declare function batchVerifySignedRequests(signedRequests: SignedRequest[], getAccountKeys: (account: string) => Promise<AccountKeys>): Promise<VerificationResult[]>;
69
+ /**
70
+ * Check if a signature is expired
71
+ */
72
+ export declare function isSignatureExpired(timestamp: string, maxAgeMs?: number): boolean;
73
+ /**
74
+ * Validate signature format
75
+ */
76
+ export declare function isValidSignatureFormat(signature: string): boolean;
77
+ /**
78
+ * Validate public key format
79
+ */
80
+ export declare function isValidPublicKeyFormat(publicKey: string): boolean;
81
+ declare const _default: {
82
+ verifySignedRequest: typeof verifySignedRequest;
83
+ verifyMessageSignature: typeof verifyMessageSignature;
84
+ verifyMultipleSignatures: typeof verifyMultipleSignatures;
85
+ extractAccountKeys: typeof extractAccountKeys;
86
+ createApiVerificationFunction: typeof createApiVerificationFunction;
87
+ batchVerifySignedRequests: typeof batchVerifySignedRequests;
88
+ isSignatureExpired: typeof isSignatureExpired;
89
+ isValidSignatureFormat: typeof isValidSignatureFormat;
90
+ isValidPublicKeyFormat: typeof isValidPublicKeyFormat;
91
+ };
92
+ export default _default;
@@ -5,8 +5,8 @@ export declare class BaseTransport extends EventEmitter implements Transport {
5
5
  id: number;
6
6
  constructor(options?: TransportOptions);
7
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;
8
+ listenTo(target: EventEmitter, eventName: string, callback: (...args: unknown[]) => void): () => void;
9
+ send(_api: string, _data: unknown, _callback: (error: Error | null, result?: unknown) => void): void;
10
10
  start(): Promise<void>;
11
11
  stop(): Promise<void>;
12
12
  }
@@ -1,9 +1,23 @@
1
1
  import { TransportOptions, JsonRpcRequest } from './types';
2
2
  import { BaseTransport } from './base';
3
- export declare const jsonRpc: (uri: string, request: Partial<JsonRpcRequest>) => Promise<any>;
3
+ /**
4
+ * Makes a JSON-RPC request using native fetch API
5
+ * Universal implementation that works in both Node.js (18+) and browser
6
+ *
7
+ * @param uri - The URI to the JSON-RPC endpoint
8
+ * @param request - The JSON-RPC request object
9
+ * @param fetchMethod - Optional fetch implementation (defaults to global fetch)
10
+ * @param timeoutMs - Request timeout in milliseconds (default: 30000)
11
+ * @returns Promise resolving to the JSON-RPC result
12
+ */
13
+ export declare const jsonRpc: (uri: string, request: Partial<JsonRpcRequest>, fetchMethod?: typeof fetch, timeoutMs?: number) => Promise<unknown>;
4
14
  export declare class HttpTransport extends BaseTransport {
5
15
  constructor(options: TransportOptions);
6
16
  get nonRetriableOperations(): string[];
7
17
  isBroadcastOperation(method: string): boolean;
8
- send(api: string, data: any, callback?: (err: any, result?: any, attempt?: number) => void): void;
18
+ send(api: string, data: {
19
+ id?: number;
20
+ method: string;
21
+ params: unknown[];
22
+ }, callback?: (err: Error | null, result?: unknown, attempt?: number) => void): void;
9
23
  }
@@ -1,9 +1,7 @@
1
1
  import { HttpTransport } from './http';
2
- import { WsTransport } from './ws';
3
2
  import { BaseTransport } from './base';
4
3
  export * from './types';
5
4
  export declare const transports: {
6
5
  http: typeof HttpTransport;
7
- ws: typeof WsTransport;
8
6
  };
9
7
  export { BaseTransport };
@@ -8,22 +8,22 @@ export interface TransportOptions {
8
8
  * Please use HTTP transport (via url or uri field) for API calls.
9
9
  */
10
10
  websocket?: string;
11
- transport?: string | any;
12
- [key: string]: any;
11
+ transport?: string | unknown;
12
+ [key: string]: unknown;
13
13
  }
14
14
  export interface JsonRpcRequest {
15
15
  id: number;
16
16
  method: string;
17
- params: any[];
17
+ params: unknown[];
18
18
  jsonrpc?: string;
19
19
  }
20
20
  export interface JsonRpcResponse {
21
21
  id: number;
22
- result: any;
22
+ result: unknown;
23
23
  error?: {
24
24
  code: number;
25
25
  message: string;
26
- data?: any;
26
+ data?: unknown;
27
27
  };
28
28
  }
29
29
  export interface Transport {
@@ -31,5 +31,5 @@ export interface Transport {
31
31
  start(): Promise<void>;
32
32
  stop(): Promise<void>;
33
33
  setOptions(options: TransportOptions): void;
34
- send(api: string, data: any, callback: (error: any, result?: any) => void): void | Promise<void>;
34
+ send(api: string, data: unknown, callback: (error: Error | null, result?: unknown) => void): void | Promise<void>;
35
35
  }
@@ -11,6 +11,7 @@ export declare class WsTransport extends BaseTransport {
11
11
  private ws;
12
12
  private _requests;
13
13
  private seqNo;
14
+ private isBrowser;
14
15
  constructor(options: TransportOptions);
15
16
  start(): Promise<void>;
16
17
  stop(): Promise<void>;
@@ -2,7 +2,7 @@ import BN from 'bn.js';
2
2
  import ECSignature from './ecsignature';
3
3
  import { ec as EC } from 'elliptic';
4
4
  type ECInstance = EC;
5
- type ECPoint = any;
5
+ type ECPoint = ReturnType<ECInstance['g']['mul']>;
6
6
  export declare function sign(curve: ECInstance, hash: Buffer, d: BN, nonce?: number): ECSignature;
7
7
  export declare function verify(curve: ECInstance, hash: Buffer, signature: ECSignature, Q: ECPoint): boolean;
8
8
  /**
@@ -1,5 +1,5 @@
1
1
  type TypeName = 'Array' | 'Boolean' | 'Buffer' | 'Number' | 'String' | {
2
- new (...args: any[]): any;
2
+ new (...args: unknown[]): unknown;
3
3
  };
4
- export default function enforce(type: TypeName, value: any): void;
4
+ export default function enforce(type: TypeName, value: unknown): void;
5
5
  export {};
@@ -7,12 +7,14 @@ export declare function sha1(data: string | Buffer, encoding?: BufferEncoding):
7
7
  @arg {string} [digest = null] - 'hex', 'binary' or 'base64'
8
8
  @return {string|Buffer} - Buffer when digest is null, or string
9
9
  */
10
- export declare function sha256(data: string | Buffer, encoding?: BufferEncoding): Buffer;
10
+ export declare function sha256(data: string | Buffer): Buffer;
11
+ export declare function sha256(data: string | Buffer, encoding: BufferEncoding): string;
11
12
  /** @arg {string|Buffer} data
12
13
  @arg {string} [digest = null] - 'hex', 'binary' or 'base64'
13
14
  @return {string|Buffer} - Buffer when digest is null, or string
14
15
  */
15
- export declare function sha512(data: string | Buffer, encoding?: BufferEncoding): Buffer;
16
+ export declare function sha512(data: string | Buffer): Buffer;
17
+ export declare function sha512(data: string | Buffer, encoding: BufferEncoding): string;
16
18
  export declare function HmacSHA256(buffer: Buffer, secret: Buffer): Buffer;
17
19
  export declare function ripemd160(data: string | Buffer): Buffer;
18
20
  declare const _default: {
@@ -1,6 +1,8 @@
1
+ import { ec as EC } from 'elliptic';
2
+ declare const secp256k1: EC;
1
3
  import BN from 'bn.js';
2
4
  import { PublicKey } from './key_public';
3
- type ECPoint = any;
5
+ type ECPoint = ReturnType<typeof secp256k1.g.mul>;
4
6
  export declare class PrivateKey {
5
7
  d: BN;
6
8
  public_key?: PublicKey;
@@ -1,4 +1,6 @@
1
- type ECPoint = any;
1
+ import { ec as EC } from 'elliptic';
2
+ declare const secp256k1: EC;
3
+ type ECPoint = ReturnType<typeof secp256k1.g.mul>;
2
4
  export declare class PublicKey {
3
5
  Q: ECPoint | null;
4
6
  pubdata?: string;
@@ -11,27 +13,27 @@ export declare class PublicKey {
11
13
  toUncompressed(): PublicKey;
12
14
  /** bts::blockchain::address (unique but not a full public key) */
13
15
  toBlockchainAddress(): Buffer;
14
- toString(address_prefix?: any): string;
16
+ toString(address_prefix?: string | undefined): string;
15
17
  /**
16
18
  * Full public key
17
19
  * {return} string
18
20
  */
19
- toPublicKeyString(address_prefix?: any): string;
21
+ toPublicKeyString(address_prefix?: string | undefined): string;
20
22
  /**
21
23
  * @arg {string} public_key - like STMXyz...
22
24
  * @arg {string} address_prefix - like STM
23
25
  * @return PublicKey or `null` (if the public_key string is invalid)
24
26
  * @deprecated fromPublicKeyString (use fromString instead)
25
27
  */
26
- static fromString(public_key: string, address_prefix?: any): PublicKey | null;
28
+ static fromString(public_key: string, address_prefix?: string | undefined): PublicKey | null;
27
29
  /**
28
30
  * @arg {string} public_key - like STMXyz...
29
31
  * @arg {string} address_prefix - like STM
30
32
  * @throws {Error} if public key is invalid
31
33
  * @return PublicKey
32
34
  */
33
- static fromStringOrThrow(public_key: string, address_prefix?: any): PublicKey;
34
- toAddressString(address_prefix?: any): string;
35
+ static fromStringOrThrow(public_key: string, address_prefix?: string | undefined): PublicKey;
36
+ toAddressString(address_prefix?: unknown): string;
35
37
  toPtsAddy(): string;
36
38
  child(offset: Buffer): PublicKey;
37
39
  static fromHex(hex: string): PublicKey;
@@ -9,7 +9,7 @@ export interface Authority {
9
9
  key_auths: [string, number][];
10
10
  }
11
11
  export interface Auth {
12
- verify(name: string, password: string, auths: any): boolean;
12
+ verify(name: string, password: string, auths: unknown): boolean;
13
13
  generateKeys(name: string, password: string, roles: string[]): {
14
14
  [key: string]: string;
15
15
  };
@@ -21,11 +21,11 @@ export interface Auth {
21
21
  wifIsValid(privWif: string, pubWif: string): boolean;
22
22
  wifToPublic(privWif: string): string;
23
23
  isPubkey(pubkey: string, address_prefix?: string): boolean;
24
- signTransaction(trx: any, keys: string[]): any;
24
+ signTransaction(trx: unknown, keys: string[]): unknown;
25
25
  }
26
26
  export declare const Auth: Auth;
27
27
  export default Auth;
28
- export declare const verify: (name: string, password: string, auths: any) => boolean;
28
+ export declare const verify: (name: string, password: string, auths: unknown) => boolean;
29
29
  export declare const generateKeys: (name: string, password: string, roles: string[]) => {
30
30
  [key: string]: string;
31
31
  };
@@ -39,10 +39,11 @@ export declare const wifToPublic: (privWif: string) => string;
39
39
  export declare const isPubkey: (pubkey: string, address_prefix?: string) => boolean;
40
40
  export { PrivateKey } from './ecc/src/key_private';
41
41
  export { PublicKey } from './ecc/src/key_public';
42
+ export { Signature } from './ecc/src/signature';
42
43
  export { Address } from './ecc/src/address';
43
44
  export declare const sign: (message: string, privateKey: string) => string;
44
45
  export declare const verifySignature: (message: string, signature: string, publicKey: string) => boolean;
45
- export declare const verifyTransaction: (transaction: any, publicKey: string) => boolean;
46
+ export declare const verifyTransaction: (transaction: unknown, publicKey: string) => boolean;
46
47
  export declare const getPublicKey: (privateKey: string) => string;
47
48
  export declare const getPrivateKey: (seed: string) => string;
48
- export declare const signTransaction: (trx: any, keys: string[]) => any;
49
+ export declare const signTransaction: (trx: unknown, keys: string[]) => unknown;
@@ -2,4 +2,4 @@
2
2
  * Serialize a transaction to binary format for Steem blockchain
3
3
  * This is a simplified implementation that handles the basic structure
4
4
  */
5
- export declare function serializeTransaction(trx: any): Buffer;
5
+ export declare function serializeTransaction(trx: unknown): Buffer;
@@ -11,9 +11,9 @@ export declare class Serializer {
11
11
  static toBuffer(memo: EncryptedMemo): Buffer;
12
12
  }
13
13
  export declare const transaction: {
14
- toBuffer(trx: any): Buffer;
14
+ toBuffer(trx: unknown): Buffer;
15
15
  };
16
16
  export declare const signed_transaction: {
17
- toObject(trx: any): any;
18
- toBuffer(trx: any): Buffer;
17
+ toObject(trx: unknown): unknown;
18
+ toBuffer(trx: unknown): Buffer;
19
19
  };
@@ -2,10 +2,29 @@ import { Operation } from './operations';
2
2
  export interface BroadcastOptions {
3
3
  roles: string[];
4
4
  operation: string;
5
- params: any[];
5
+ params: unknown[];
6
6
  }
7
7
  export declare function getOperation(operation: string): Operation | undefined;
8
8
  export declare function validateOperation(options: BroadcastOptions): void;
9
- export declare function createOperation(options: BroadcastOptions): [string, any[]];
10
- export declare function createTransaction(operations: [string, any[]][]): any;
11
- export declare function createSignedTransaction(transaction: any, signatures: string[]): any;
9
+ export declare function createOperation(options: BroadcastOptions): [string, unknown[]];
10
+ export declare function createTransaction(operations: [string, unknown[]][]): {
11
+ ref_block_num: number;
12
+ ref_block_prefix: number;
13
+ expiration: string;
14
+ operations: [string, unknown[]][];
15
+ extensions: unknown[];
16
+ };
17
+ export declare function createSignedTransaction(transaction: {
18
+ ref_block_num: number;
19
+ ref_block_prefix: number;
20
+ expiration: string;
21
+ operations: [string, unknown[]][];
22
+ extensions: unknown[];
23
+ }, signatures: string[]): {
24
+ ref_block_num: number;
25
+ ref_block_prefix: number;
26
+ expiration: string;
27
+ operations: [string, unknown[]][];
28
+ extensions: unknown[];
29
+ signatures: string[];
30
+ };