@steemit/steem-js 1.0.4 → 1.0.5
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/dist/api/index.d.ts +8 -0
- package/dist/api/signature-verification.d.ts +90 -0
- package/dist/index.browser.js +56377 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +1736 -6593
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1736 -6586
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2623 -2399
- 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/polyfills/async-hooks-browser.d.ts +6 -0
- package/dist/polyfills/secure-random-browser.d.ts +8 -0
- package/package.json +8 -2
package/dist/api/index.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ export declare class Api extends EventEmitter {
|
|
|
31
31
|
send(api: string, data: any, callback: any): any;
|
|
32
32
|
call(method: string, params: any[], callback: any): void;
|
|
33
33
|
signedCall(method: string, params: any[], account: string, key: string, callback: any): void;
|
|
34
|
+
/**
|
|
35
|
+
* Verify a signed RPC request
|
|
36
|
+
* @param signedRequest The signed request to verify
|
|
37
|
+
* @param callback Callback function
|
|
38
|
+
*/
|
|
39
|
+
verifySignedRequest(signedRequest: any, callback: any): void;
|
|
34
40
|
setOptions(options: ApiOptions): void;
|
|
35
41
|
/**
|
|
36
42
|
* Set WebSocket URL
|
|
@@ -126,3 +132,5 @@ export declare const streamBlockNumber: (...args: any[]) => any;
|
|
|
126
132
|
export declare const streamBlock: (...args: any[]) => any;
|
|
127
133
|
export declare const streamTransactions: (...args: any[]) => any;
|
|
128
134
|
export declare const streamOperations: (...args: any[]) => any;
|
|
135
|
+
export { sign as signRequest, validate as validateRequest } from './rpc-auth';
|
|
136
|
+
export * as signatureVerification from './signature-verification';
|
|
@@ -0,0 +1,90 @@
|
|
|
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?: any;
|
|
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: any): AccountKeys;
|
|
59
|
+
/**
|
|
60
|
+
* Create a verification function for use with API calls
|
|
61
|
+
*/
|
|
62
|
+
export declare function createApiVerificationFunction(api: any): (account: string) => Promise<AccountKeys>;
|
|
63
|
+
/**
|
|
64
|
+
* Batch verify multiple signed requests
|
|
65
|
+
*/
|
|
66
|
+
export declare function batchVerifySignedRequests(signedRequests: SignedRequest[], getAccountKeys: (account: string) => Promise<AccountKeys>): Promise<VerificationResult[]>;
|
|
67
|
+
/**
|
|
68
|
+
* Check if a signature is expired
|
|
69
|
+
*/
|
|
70
|
+
export declare function isSignatureExpired(timestamp: string, maxAgeMs?: number): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Validate signature format
|
|
73
|
+
*/
|
|
74
|
+
export declare function isValidSignatureFormat(signature: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Validate public key format
|
|
77
|
+
*/
|
|
78
|
+
export declare function isValidPublicKeyFormat(publicKey: string): boolean;
|
|
79
|
+
declare const _default: {
|
|
80
|
+
verifySignedRequest: typeof verifySignedRequest;
|
|
81
|
+
verifyMessageSignature: typeof verifyMessageSignature;
|
|
82
|
+
verifyMultipleSignatures: typeof verifyMultipleSignatures;
|
|
83
|
+
extractAccountKeys: typeof extractAccountKeys;
|
|
84
|
+
createApiVerificationFunction: typeof createApiVerificationFunction;
|
|
85
|
+
batchVerifySignedRequests: typeof batchVerifySignedRequests;
|
|
86
|
+
isSignatureExpired: typeof isSignatureExpired;
|
|
87
|
+
isValidSignatureFormat: typeof isValidSignatureFormat;
|
|
88
|
+
isValidPublicKeyFormat: typeof isValidPublicKeyFormat;
|
|
89
|
+
};
|
|
90
|
+
export default _default;
|