@steemit/steem-js 1.0.19 → 1.1.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.
- package/README.md +0 -2
- package/dist/api/types.d.ts +32 -29
- package/dist/auth/ecc/index.d.ts +0 -1
- package/dist/auth/ecc/src/index.d.ts +0 -1
- package/dist/auth/index.d.ts +1 -0
- package/dist/browser.esm.js +22 -5
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs +22 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +22 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/protocol.d.ts +271 -0
- package/package.json +1 -1
- package/dist/auth/ecc/src/key_utils.d.ts +0 -10
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
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
|
-
|
|
5
3
|
A modern JavaScript/TypeScript library for interacting with the Steem blockchain. Complete refactoring with TypeScript, modern tooling, and improved security.
|
|
6
4
|
|
|
7
5
|
[](https://www.npmjs.com/package/@steemit/steem-js)
|
package/dist/api/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Type definitions for dynamically generated API methods.
|
|
3
3
|
* Runtime routing (condenser_api vs database_api) is defined in methods.ts; see docs/README.md#api-routing.
|
|
4
4
|
*/
|
|
5
|
+
import type { ExtendedAccount, DynamicGlobalProperties, Discussion, SignedBlock, FollowApiObject, AccountHistoryEntry } from '../types/protocol';
|
|
5
6
|
export type ApiCallback<T = unknown> = (err: Error | null, result?: T) => void;
|
|
6
7
|
type ApiMethodWithParams<TResult = unknown> = (...args: unknown[]) => Promise<TResult> | void;
|
|
7
8
|
type ApiMethodNoParams<TResult = unknown> = (callback?: ApiCallback<TResult>) => Promise<TResult> | void;
|
|
@@ -10,69 +11,71 @@ type ApiMethodAsync<TParams extends unknown[] = unknown[], TResult = unknown> =
|
|
|
10
11
|
type ApiMethodWithAsync<TResult = unknown> = (options: Record<string, unknown>) => Promise<TResult>;
|
|
11
12
|
/**
|
|
12
13
|
* Type definitions for all API methods
|
|
13
|
-
* This interface provides type safety for dynamically generated methods
|
|
14
|
+
* This interface provides type safety for dynamically generated methods.
|
|
15
|
+
* Return types mirror the C++ node's condenser_api FC_REFLECT structs; see
|
|
16
|
+
* src/types/protocol.ts for the protocol definitions.
|
|
14
17
|
*/
|
|
15
18
|
export interface ApiMethodSignatures {
|
|
16
|
-
getAccounts(accounts: string[], callback?: ApiCallback<
|
|
17
|
-
getAccountsAsync(accounts: string[]): Promise<
|
|
19
|
+
getAccounts(accounts: string[], callback?: ApiCallback<ExtendedAccount[]>): Promise<ExtendedAccount[]> | void;
|
|
20
|
+
getAccountsAsync(accounts: string[]): Promise<ExtendedAccount[]>;
|
|
18
21
|
getAccountsWith(options: {
|
|
19
22
|
names: string[];
|
|
20
|
-
}, callback?: ApiCallback<
|
|
23
|
+
}, callback?: ApiCallback<ExtendedAccount[]>): Promise<ExtendedAccount[]> | void;
|
|
21
24
|
getAccountsWithAsync(options: {
|
|
22
25
|
names: string[];
|
|
23
|
-
}): Promise<
|
|
24
|
-
getAccountHistory(account: string, from: number, limit: number, callback?: ApiCallback<
|
|
25
|
-
getAccountHistoryAsync(account: string, from: number, limit: number): Promise<
|
|
26
|
+
}): Promise<ExtendedAccount[]>;
|
|
27
|
+
getAccountHistory(account: string, from: number, limit: number, callback?: ApiCallback<AccountHistoryEntry[]>): Promise<AccountHistoryEntry[]> | void;
|
|
28
|
+
getAccountHistoryAsync(account: string, from: number, limit: number): Promise<AccountHistoryEntry[]>;
|
|
26
29
|
getAccountHistoryWith(options: {
|
|
27
30
|
account: string;
|
|
28
31
|
from: number;
|
|
29
32
|
limit: number;
|
|
30
|
-
}, callback?: ApiCallback<
|
|
33
|
+
}, callback?: ApiCallback<AccountHistoryEntry[]>): Promise<AccountHistoryEntry[]> | void;
|
|
31
34
|
getAccountHistoryWithAsync(options: {
|
|
32
35
|
account: string;
|
|
33
36
|
from: number;
|
|
34
37
|
limit: number;
|
|
35
|
-
}): Promise<
|
|
36
|
-
getDynamicGlobalProperties(callback?: ApiCallback<
|
|
37
|
-
getDynamicGlobalPropertiesAsync(): Promise<
|
|
38
|
-
getDynamicGlobalPropertiesWith(options: Record<string, unknown>, callback?: ApiCallback<
|
|
39
|
-
getDynamicGlobalPropertiesWithAsync(options: Record<string, unknown>): Promise<
|
|
40
|
-
getContent(author: string, permlink: string, callback?: ApiCallback<
|
|
41
|
-
getContentAsync(author: string, permlink: string): Promise<
|
|
38
|
+
}): Promise<AccountHistoryEntry[]>;
|
|
39
|
+
getDynamicGlobalProperties(callback?: ApiCallback<DynamicGlobalProperties>): Promise<DynamicGlobalProperties> | void;
|
|
40
|
+
getDynamicGlobalPropertiesAsync(): Promise<DynamicGlobalProperties>;
|
|
41
|
+
getDynamicGlobalPropertiesWith(options: Record<string, unknown>, callback?: ApiCallback<DynamicGlobalProperties>): Promise<DynamicGlobalProperties> | void;
|
|
42
|
+
getDynamicGlobalPropertiesWithAsync(options: Record<string, unknown>): Promise<DynamicGlobalProperties>;
|
|
43
|
+
getContent(author: string, permlink: string, callback?: ApiCallback<Discussion>): Promise<Discussion> | void;
|
|
44
|
+
getContentAsync(author: string, permlink: string): Promise<Discussion>;
|
|
42
45
|
getContentWith(options: {
|
|
43
46
|
author: string;
|
|
44
47
|
permlink: string;
|
|
45
|
-
}, callback?: ApiCallback<
|
|
48
|
+
}, callback?: ApiCallback<Discussion>): Promise<Discussion> | void;
|
|
46
49
|
getContentWithAsync(options: {
|
|
47
50
|
author: string;
|
|
48
51
|
permlink: string;
|
|
49
|
-
}): Promise<
|
|
50
|
-
getFollowers(following: string, startFollower: string, followType: string, limit: number, callback?: ApiCallback<
|
|
51
|
-
getFollowersAsync(following: string, startFollower: string, followType: string, limit: number): Promise<
|
|
52
|
+
}): Promise<Discussion>;
|
|
53
|
+
getFollowers(following: string, startFollower: string, followType: string, limit: number, callback?: ApiCallback<FollowApiObject[]>): Promise<FollowApiObject[]> | void;
|
|
54
|
+
getFollowersAsync(following: string, startFollower: string, followType: string, limit: number): Promise<FollowApiObject[]>;
|
|
52
55
|
getFollowersWith(options: {
|
|
53
56
|
following: string;
|
|
54
57
|
startFollower: string;
|
|
55
58
|
followType: string;
|
|
56
59
|
limit: number;
|
|
57
|
-
}, callback?: ApiCallback<
|
|
60
|
+
}, callback?: ApiCallback<FollowApiObject[]>): Promise<FollowApiObject[]> | void;
|
|
58
61
|
getFollowersWithAsync(options: {
|
|
59
62
|
following: string;
|
|
60
63
|
startFollower: string;
|
|
61
64
|
followType: string;
|
|
62
65
|
limit: number;
|
|
63
|
-
}): Promise<
|
|
64
|
-
getBlock(blockNum: number, callback?: ApiCallback<
|
|
65
|
-
getBlockAsync(blockNum: number): Promise<
|
|
66
|
+
}): Promise<FollowApiObject[]>;
|
|
67
|
+
getBlock(blockNum: number, callback?: ApiCallback<SignedBlock>): Promise<SignedBlock> | void;
|
|
68
|
+
getBlockAsync(blockNum: number): Promise<SignedBlock>;
|
|
66
69
|
getBlockWith(options: {
|
|
67
70
|
blockNum: number;
|
|
68
|
-
}, callback?: ApiCallback<
|
|
71
|
+
}, callback?: ApiCallback<SignedBlock>): Promise<SignedBlock> | void;
|
|
69
72
|
getBlockWithAsync(options: {
|
|
70
73
|
blockNum: number;
|
|
71
|
-
}): Promise<
|
|
72
|
-
getConfig(callback?: ApiCallback<
|
|
73
|
-
getConfigAsync(): Promise<
|
|
74
|
-
getConfigWith(options: Record<string, unknown>, callback?: ApiCallback<
|
|
75
|
-
getConfigWithAsync(options: Record<string, unknown>): Promise<
|
|
74
|
+
}): Promise<SignedBlock>;
|
|
75
|
+
getConfig(callback?: ApiCallback<Record<string, unknown>>): Promise<Record<string, unknown>> | void;
|
|
76
|
+
getConfigAsync(): Promise<Record<string, unknown>>;
|
|
77
|
+
getConfigWith(options: Record<string, unknown>, callback?: ApiCallback<Record<string, unknown>>): Promise<Record<string, unknown>> | void;
|
|
78
|
+
getConfigWithAsync(options: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
76
79
|
[methodName: string]: ApiMethodWithParams | ApiMethodNoParams | ApiMethodWith | ApiMethodAsync<unknown[]> | ApiMethodWithAsync | unknown;
|
|
77
80
|
}
|
|
78
81
|
export {};
|
package/dist/auth/ecc/index.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ export { PrivateKey } from './src/key_private';
|
|
|
4
4
|
export { PublicKey } from './src/key_public';
|
|
5
5
|
export { Signature } from './src/signature';
|
|
6
6
|
export { normalize as brainKey } from './src/brain_key';
|
|
7
|
-
export * as key_utils from './src/key_utils';
|
|
8
7
|
export * as hash from './src/hash';
|
|
9
8
|
export { Config as ecc_config } from '../../config';
|
|
@@ -4,6 +4,5 @@ export { PrivateKey } from './key_private';
|
|
|
4
4
|
export { PublicKey } from './key_public';
|
|
5
5
|
export { Signature } from './signature';
|
|
6
6
|
export { normalize as brainKey } from './brain_key';
|
|
7
|
-
export * as key_utils from './key_utils';
|
|
8
7
|
export * as hash from './hash';
|
|
9
8
|
export { Config as ecc_config } from '../../../config';
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -49,3 +49,4 @@ export declare const verifyTransaction: (transaction: unknown, publicKey: string
|
|
|
49
49
|
export declare const getPublicKey: (privateKey: string) => string;
|
|
50
50
|
export declare const getPrivateKey: (seed: string) => string;
|
|
51
51
|
export declare const signTransaction: (trx: unknown, keys: string[]) => unknown;
|
|
52
|
+
export { serializeTransaction } from './serializer/transaction';
|
package/dist/browser.esm.js
CHANGED
|
@@ -17267,7 +17267,7 @@ function recoverPubKey(curve, e, signature, i) {
|
|
|
17267
17267
|
const Q = curve.recoverPubKey(msgBuffer, sigObj, i);
|
|
17268
17268
|
return Q;
|
|
17269
17269
|
}
|
|
17270
|
-
catch
|
|
17270
|
+
catch {
|
|
17271
17271
|
// Fallback to manual implementation if elliptic's method fails
|
|
17272
17272
|
const G = curve.g;
|
|
17273
17273
|
// A set LSB signifies that the y-coordinate is odd
|
|
@@ -17287,7 +17287,7 @@ function recoverPubKey(curve, e, signature, i) {
|
|
|
17287
17287
|
try {
|
|
17288
17288
|
R = curve.curve.pointFromX(xHexPadded, isYOdd);
|
|
17289
17289
|
}
|
|
17290
|
-
catch
|
|
17290
|
+
catch {
|
|
17291
17291
|
// If hex string fails, try with Buffer
|
|
17292
17292
|
const xBuffer = x.toArrayLike(bufferExports.Buffer, 'be', 32);
|
|
17293
17293
|
R = curve.curve.pointFromX(xBuffer, isYOdd);
|
|
@@ -26856,18 +26856,34 @@ const verifySignature = (message, signature, publicKey) => {
|
|
|
26856
26856
|
return false;
|
|
26857
26857
|
}
|
|
26858
26858
|
};
|
|
26859
|
+
// Serialize a transaction to its binary form for digest calculation.
|
|
26860
|
+
// Alias for transaction.toBuffer() so verifyTransaction mirrors signTransaction's
|
|
26861
|
+
// serialization path exactly (signTransaction calls transaction.toBuffer at line 161).
|
|
26862
|
+
const serializeTrx = (trx) => transaction.toBuffer(trx);
|
|
26859
26863
|
const verifyTransaction = (transaction, publicKey) => {
|
|
26860
26864
|
try {
|
|
26861
26865
|
const pub = PublicKey.fromString(publicKey);
|
|
26862
26866
|
if (!pub)
|
|
26863
26867
|
return false;
|
|
26864
|
-
const serialized = bufferExports.Buffer.from(JSON.stringify(transaction));
|
|
26865
26868
|
const trx = transaction;
|
|
26866
26869
|
if (!trx.signatures || !Array.isArray(trx.signatures))
|
|
26867
26870
|
return false;
|
|
26871
|
+
// Reconstruct the exact digest signTransaction signs over:
|
|
26872
|
+
// Buffer.concat([chain_id, transaction.toBuffer(normalizedTrx)])
|
|
26873
|
+
// signatures are NOT part of the signed digest — signTransaction serializes
|
|
26874
|
+
// BEFORE attaching signatures — so strip them before serializing, otherwise
|
|
26875
|
+
// serializeTransaction() would emit the signatures array and change the digest.
|
|
26876
|
+
const normalizedTrx = normalizeTransactionForBroadcast(trx);
|
|
26877
|
+
// Build a copy without the signatures key, so serializeTransaction() does not
|
|
26878
|
+
// emit the signatures array into the digest (signTransaction serializes pre-signature).
|
|
26879
|
+
const trxWithoutSigs = { ...normalizedTrx };
|
|
26880
|
+
delete trxWithoutSigs.signatures;
|
|
26881
|
+
const chainId = getConfig().get('chain_id') || '';
|
|
26882
|
+
const cid = bufferExports.Buffer.from(chainId, 'hex');
|
|
26883
|
+
const buf = serializeTrx(trxWithoutSigs);
|
|
26868
26884
|
return trx.signatures.some((sig) => {
|
|
26869
26885
|
const signature = Signature.fromHex(sig);
|
|
26870
|
-
return signature.verifyBuffer(
|
|
26886
|
+
return signature.verifyBuffer(bufferExports.Buffer.concat([cid, buf]), pub);
|
|
26871
26887
|
});
|
|
26872
26888
|
}
|
|
26873
26889
|
catch {
|
|
@@ -26912,6 +26928,7 @@ const auth = /*#__PURE__*/Object.freeze({
|
|
|
26912
26928
|
normalizeTransactionForBroadcast: normalizeTransactionForBroadcast,
|
|
26913
26929
|
resolveAuthorityForSerialize: resolveAuthorityForSerialize,
|
|
26914
26930
|
sanitizeAccountUpdatePayload: sanitizeAccountUpdatePayload,
|
|
26931
|
+
serializeTransaction: serializeTransaction,
|
|
26915
26932
|
sign: sign$1,
|
|
26916
26933
|
signTransaction: signTransaction,
|
|
26917
26934
|
toWif: toWif,
|
|
@@ -29720,7 +29737,7 @@ const steem = {
|
|
|
29720
29737
|
memo,
|
|
29721
29738
|
operations,
|
|
29722
29739
|
utils: utils$3,
|
|
29723
|
-
version: '1.0
|
|
29740
|
+
version: '1.1.0',
|
|
29724
29741
|
config: {
|
|
29725
29742
|
set: (options) => {
|
|
29726
29743
|
// If nodes is provided, extract the first node as url for API
|