mmn-client-js 1.0.8 → 1.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mmn-client-js",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A comprehensive TypeScript client for interacting with MMN blockchain via JSON-RPC",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
package/dist/index.d.ts DELETED
@@ -1,272 +0,0 @@
1
- interface JsonRpcRequest {
2
- jsonrpc: '2.0';
3
- method: string;
4
- params?: unknown;
5
- id: string | number;
6
- }
7
- interface JsonRpcError {
8
- code: number;
9
- message: string;
10
- data?: unknown;
11
- }
12
- interface JsonRpcResponse<T = unknown> {
13
- jsonrpc: '2.0';
14
- result?: T;
15
- error?: JsonRpcError;
16
- id: string | number;
17
- }
18
- interface IEphemeralKeyPair {
19
- privateKey: string;
20
- publicKey: string;
21
- }
22
- interface IZkProof {
23
- proof: string;
24
- public_input: string;
25
- }
26
- declare enum ETransferType {
27
- GiveCoffee = "give_coffee",
28
- TransferToken = "transfer_token",
29
- UnlockItem = "unlock_item"
30
- }
31
- interface ExtraInfo {
32
- type: ETransferType;
33
- ItemId?: string;
34
- ItemType?: string;
35
- ClanId?: string;
36
- UserSenderId: string;
37
- UserSenderUsername: string;
38
- UserReceiverId: string;
39
- ChannelId?: string;
40
- MessageRefId?: string;
41
- }
42
- interface TxMsg {
43
- type: number;
44
- sender: string;
45
- recipient: string;
46
- amount: string;
47
- timestamp: number;
48
- text_data: string;
49
- nonce: number;
50
- extra_info: string;
51
- zk_proof: string;
52
- zk_pub: string;
53
- }
54
- interface SignedTx {
55
- tx_msg: TxMsg;
56
- signature: string;
57
- }
58
- interface SendTransactionRequest {
59
- sender: string;
60
- recipient: string;
61
- amount: string;
62
- nonce: number;
63
- timestamp?: number;
64
- textData?: string;
65
- extraInfo?: ExtraInfo;
66
- publicKey: string;
67
- privateKey: string;
68
- zkProof: string;
69
- zkPub: string;
70
- }
71
- interface AddTxResponse {
72
- ok: boolean;
73
- tx_hash: string;
74
- error: string;
75
- }
76
- interface GetCurrentNonceResponse {
77
- address: string;
78
- nonce: number;
79
- tag: string;
80
- error: string;
81
- }
82
- interface GetAccountByAddressResponse {
83
- address: string;
84
- balance: string;
85
- nonce: number;
86
- decimals: number;
87
- }
88
- interface MmnClientConfig {
89
- baseUrl: string;
90
- timeout?: number;
91
- headers?: Record<string, string>;
92
- }
93
- interface Transaction {
94
- chain_id: string;
95
- hash: string;
96
- nonce: number;
97
- block_hash: string;
98
- block_number: number;
99
- block_timestamp: number;
100
- transaction_index: number;
101
- from_address: string;
102
- to_address: string;
103
- value: string;
104
- gas: number;
105
- gas_price: string;
106
- data: string;
107
- function_selector: string;
108
- max_fee_per_gas: string;
109
- max_priority_fee_per_gas: string;
110
- max_fee_per_blob_gas?: string;
111
- blob_versioned_hashes?: string[];
112
- transaction_type: number;
113
- r: string;
114
- s: string;
115
- v: string;
116
- access_list_json?: string;
117
- authorization_list_json?: string;
118
- contract_address?: string;
119
- gas_used?: number;
120
- cumulative_gas_used?: number;
121
- effective_gas_price?: string;
122
- blob_gas_used?: number;
123
- blob_gas_price?: string;
124
- logs_bloom?: string;
125
- status?: number;
126
- transaction_timestamp: number;
127
- text_data: string;
128
- extra_info: string;
129
- }
130
- interface Meta {
131
- chain_id: number;
132
- address?: string;
133
- signature?: string;
134
- page: number;
135
- limit?: number;
136
- total_items?: number;
137
- total_pages?: number;
138
- }
139
- interface WalletDetail {
140
- address: string;
141
- balance: string;
142
- account_nonce: number;
143
- last_balance_update: number;
144
- }
145
- interface WalletDetailResponse {
146
- data: WalletDetail;
147
- }
148
- interface ListTransactionResponse {
149
- meta: Meta;
150
- data?: Transaction[];
151
- }
152
- interface TransactionDetailResponse {
153
- data: {
154
- transaction: Transaction;
155
- };
156
- }
157
- interface IndexerClientConfig {
158
- endpoint: string;
159
- chainId: string;
160
- timeout?: number;
161
- headers?: Record<string, string>;
162
- }
163
- interface ZkClientConfig {
164
- endpoint: string;
165
- timeout?: number;
166
- headers?: Record<string, string>;
167
- }
168
-
169
- declare class IndexerClient {
170
- private endpoint;
171
- private chainId;
172
- private timeout;
173
- private headers;
174
- constructor(config: IndexerClientConfig);
175
- /**
176
- * Make HTTP request with automatic CORS handling
177
- * Works out-of-the-box without CORS configuration
178
- * @param method - HTTP method (GET or POST)
179
- * @param path - API endpoint path
180
- * @param params - URL query parameters
181
- * @param body - Request body for POST requests
182
- * @returns Promise resolving to response data
183
- */
184
- private makeRequest;
185
- getTransactionByHash(hash: string): Promise<Transaction>;
186
- getTransactionByWallet(wallet: string, page: number | undefined, limit: number | undefined, filter: number, sortBy?: string, sortOrder?: 'asc' | 'desc'): Promise<ListTransactionResponse>;
187
- getWalletDetail(wallet: string): Promise<WalletDetail>;
188
- }
189
-
190
- declare class MmnClient {
191
- private config;
192
- private requestId;
193
- constructor(config: MmnClientConfig);
194
- private makeRequest;
195
- /**
196
- * Securely convert raw Ed25519 private key to PKCS#8 format
197
- * @param raw - Raw 32-byte Ed25519 private key
198
- * @returns PKCS#8 formatted private key in hex
199
- * @throws Error if input validation fails
200
- */
201
- private rawEd25519ToPkcs8Hex;
202
- /**
203
- * Encode length in ASN.1 DER format
204
- * ASN.1 length encoding rules:
205
- * - Short form (0-127): single byte with the length value
206
- * - Long form (128+): first byte is 0x80 + number of length bytes, followed by length bytes
207
- * @param length - The length value to encode
208
- * @returns ASN.1 DER encoded length bytes
209
- */
210
- private encodeLength;
211
- /**
212
- * Generate secure entropy using multiple sources for maximum compatibility
213
- * @returns Array of 32 random bytes
214
- */
215
- private generateSecureEntropy;
216
- /**
217
- * Securely generate ephemeral key pair with proper entropy
218
- * React Native compatible version with multiple fallbacks
219
- * @returns Ephemeral key pair with private and public keys
220
- * @throws Error if key generation fails
221
- */
222
- generateEphemeralKeyPair(): IEphemeralKeyPair;
223
- getAddressFromUserId(userId: string): string;
224
- /**
225
- * Create and sign a transaction message
226
- */
227
- private createAndSignTx;
228
- /**
229
- * Securely sign a transaction with Ed25519
230
- * @param tx - Transaction message to sign
231
- * @param privateKeyHex - Private key in PKCS#8 hex format
232
- * @returns Base58 encoded signature
233
- * @throws Error if signing fails
234
- */
235
- private signTransaction;
236
- /**
237
- * Serialize transaction for signing
238
- */
239
- private serializeTransaction;
240
- /**
241
- * Add a signed transaction to the blockchain
242
- */
243
- private addTx;
244
- /**
245
- * Send a transaction (create, sign, and submit)
246
- */
247
- sendTransaction(params: SendTransactionRequest): Promise<AddTxResponse>;
248
- /**
249
- * Get current nonce for an account
250
- */
251
- getCurrentNonce(userId: string, tag?: 'latest' | 'pending'): Promise<GetCurrentNonceResponse>;
252
- getAccountByUserId(userId: string): Promise<GetAccountByAddressResponse>;
253
- scaleAmountToDecimals(originalAmount: string | number, decimals?: number): string;
254
- }
255
- declare function createMmnClient(config: MmnClientConfig): MmnClient;
256
-
257
- declare class ZkClient {
258
- private endpoint;
259
- private timeout;
260
- private headers;
261
- constructor(config: ZkClientConfig);
262
- private makeRequest;
263
- getZkProofs({ userId, ephemeralPublicKey, jwt, address, }: {
264
- userId: string;
265
- ephemeralPublicKey: string;
266
- jwt: string;
267
- address: string;
268
- }): Promise<IZkProof>;
269
- }
270
-
271
- export { ETransferType, IndexerClient, MmnClient, ZkClient, createMmnClient };
272
- export type { AddTxResponse, ExtraInfo, GetAccountByAddressResponse, GetCurrentNonceResponse, IEphemeralKeyPair, IZkProof, IndexerClientConfig, JsonRpcError, JsonRpcRequest, JsonRpcResponse, ListTransactionResponse, Meta, MmnClientConfig, SendTransactionRequest, SignedTx, Transaction, TransactionDetailResponse, TxMsg, WalletDetail, WalletDetailResponse, ZkClientConfig };