@steemit/steem-js 0.8.0 → 1.0.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.
Files changed (126) hide show
  1. package/README.md +202 -105
  2. package/dist/api/index.d.ts +128 -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 +35 -0
  9. package/dist/api/transports/ws.d.ts +18 -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 +25848 -0
  34. package/dist/index.cjs.map +1 -0
  35. package/dist/index.d.ts +30 -0
  36. package/dist/index.js +25812 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/index.umd.js +57513 -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 +34 -0
  49. package/dist/utils/index.d.ts +8 -0
  50. package/dist/utils.d.ts +2 -0
  51. package/package.json +68 -87
  52. package/.dockerignore +0 -12
  53. package/.editorconfig +0 -20
  54. package/.eslintrc +0 -27
  55. package/LICENSE +0 -21
  56. package/circle.yml +0 -3
  57. package/config.json +0 -10
  58. package/dist/steem-tests.min.js +0 -4097
  59. package/dist/steem.min.js +0 -2089
  60. package/docker-webpack.config.js +0 -44
  61. package/lib/api/index.js +0 -315
  62. package/lib/api/methods.js +0 -428
  63. package/lib/api/rpc-auth.js +0 -135
  64. package/lib/api/transports/base.js +0 -31
  65. package/lib/api/transports/http.js +0 -157
  66. package/lib/api/transports/index.js +0 -13
  67. package/lib/api/transports/ws.js +0 -128
  68. package/lib/auth/ecc/index.js +0 -13
  69. package/lib/auth/ecc/src/address.js +0 -54
  70. package/lib/auth/ecc/src/aes.js +0 -148
  71. package/lib/auth/ecc/src/brain_key.js +0 -13
  72. package/lib/auth/ecc/src/ecdsa.js +0 -193
  73. package/lib/auth/ecc/src/ecsignature.js +0 -102
  74. package/lib/auth/ecc/src/enforce_types.js +0 -42
  75. package/lib/auth/ecc/src/hash.js +0 -58
  76. package/lib/auth/ecc/src/key_private.js +0 -159
  77. package/lib/auth/ecc/src/key_public.js +0 -143
  78. package/lib/auth/ecc/src/key_utils.js +0 -70
  79. package/lib/auth/ecc/src/signature.js +0 -135
  80. package/lib/auth/index.js +0 -113
  81. package/lib/auth/memo.js +0 -119
  82. package/lib/auth/serializer/index.js +0 -15
  83. package/lib/auth/serializer/src/ChainTypes.js +0 -87
  84. package/lib/auth/serializer/src/convert.js +0 -34
  85. package/lib/auth/serializer/src/error_with_cause.js +0 -27
  86. package/lib/auth/serializer/src/fast_parser.js +0 -57
  87. package/lib/auth/serializer/src/number_utils.js +0 -43
  88. package/lib/auth/serializer/src/object_id.js +0 -43
  89. package/lib/auth/serializer/src/operations.js +0 -695
  90. package/lib/auth/serializer/src/precision.js +0 -77
  91. package/lib/auth/serializer/src/serializer.js +0 -165
  92. package/lib/auth/serializer/src/template.js +0 -22
  93. package/lib/auth/serializer/src/types.js +0 -1085
  94. package/lib/auth/serializer/src/validation.js +0 -300
  95. package/lib/broadcast/helpers.js +0 -140
  96. package/lib/broadcast/index.js +0 -106
  97. package/lib/broadcast/operations.js +0 -255
  98. package/lib/browser.js +0 -25
  99. package/lib/config.js +0 -23
  100. package/lib/formatter.js +0 -163
  101. package/lib/index.js +0 -21
  102. package/lib/utils.js +0 -50
  103. package/node-18.dockerfile +0 -28
  104. package/test/Crypto.js +0 -100
  105. package/test/KeyFormats.js +0 -105
  106. package/test/all_types.js +0 -115
  107. package/test/api.test.js +0 -363
  108. package/test/broadcast.test.js +0 -231
  109. package/test/browser/BrowserTests.js +0 -55
  110. package/test/comment.test.js +0 -83
  111. package/test/hf20-accounts.test.js +0 -76
  112. package/test/hf21-sps.test.js +0 -78
  113. package/test/memo.test.js +0 -37
  114. package/test/number_utils.js +0 -28
  115. package/test/operations_test.js +0 -39
  116. package/test/promise-broadcast.test.js +0 -86
  117. package/test/reputation.test.js +0 -68
  118. package/test/smt.test.js +0 -347
  119. package/test/test-post.json +0 -13
  120. package/test/test.html +0 -13
  121. package/test/test_helper.js +0 -19
  122. package/test/types_test.js +0 -139
  123. package/test-github-workflow.bat +0 -19
  124. package/test-github-workflow.sh +0 -15
  125. package/webpack/makeConfig.js +0 -113
  126. package/webpack.config.js +0 -2
@@ -1,428 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _default = exports.default = [{
8
- "api": "database_api",
9
- "method": "set_subscribe_callback",
10
- "params": ["callback", "clearFilter"]
11
- }, {
12
- "api": "database_api",
13
- "method": "set_pending_transaction_callback",
14
- "params": ["cb"]
15
- }, {
16
- "api": "database_api",
17
- "method": "set_block_applied_callback",
18
- "params": ["cb"]
19
- }, {
20
- "api": "database_api",
21
- "method": "cancel_all_subscriptions"
22
- }, {
23
- "api": "database_api",
24
- "method": "get_trending_tags",
25
- "params": ["afterTag", "limit"]
26
- }, {
27
- "api": "database_api",
28
- "method": "get_tags_used_by_author",
29
- "params": ["author"]
30
- }, {
31
- "api": "database_api",
32
- "method": "get_post_discussions_by_payout",
33
- "params": ["query"]
34
- }, {
35
- "api": "database_api",
36
- "method": "get_comment_discussions_by_payout",
37
- "params": ["query"]
38
- }, {
39
- "api": "database_api",
40
- "method": "get_discussions_by_trending",
41
- "params": ["query"]
42
- }, {
43
- "api": "database_api",
44
- "method": "get_discussions_by_trending30",
45
- "params": ["query"]
46
- }, {
47
- "api": "database_api",
48
- "method": "get_discussions_by_created",
49
- "params": ["query"]
50
- }, {
51
- "api": "database_api",
52
- "method": "get_discussions_by_active",
53
- "params": ["query"]
54
- }, {
55
- "api": "database_api",
56
- "method": "get_discussions_by_cashout",
57
- "params": ["query"]
58
- }, {
59
- "api": "database_api",
60
- "method": "get_discussions_by_payout",
61
- "params": ["query"]
62
- }, {
63
- "api": "database_api",
64
- "method": "get_discussions_by_votes",
65
- "params": ["query"]
66
- }, {
67
- "api": "database_api",
68
- "method": "get_discussions_by_children",
69
- "params": ["query"]
70
- }, {
71
- "api": "database_api",
72
- "method": "get_discussions_by_hot",
73
- "params": ["query"]
74
- }, {
75
- "api": "database_api",
76
- "method": "get_discussions_by_feed",
77
- "params": ["query"]
78
- }, {
79
- "api": "database_api",
80
- "method": "get_discussions_by_blog",
81
- "params": ["query"]
82
- }, {
83
- "api": "database_api",
84
- "method": "get_discussions_by_comments",
85
- "params": ["query"]
86
- }, {
87
- "api": "database_api",
88
- "method": "get_discussions_by_promoted",
89
- "params": ["query"]
90
- }, {
91
- "api": "database_api",
92
- "method": "get_block_header",
93
- "params": ["blockNum"]
94
- }, {
95
- "api": "database_api",
96
- "method": "get_block",
97
- "params": ["blockNum"]
98
- }, {
99
- "api": "database_api",
100
- "method": "get_ops_in_block",
101
- "params": ["blockNum", "onlyVirtual"]
102
- }, {
103
- "api": "database_api",
104
- "method": "get_state",
105
- "params": ["path"]
106
- }, {
107
- "api": "database_api",
108
- "method": "get_trending_categories",
109
- "params": ["after", "limit"]
110
- }, {
111
- "api": "database_api",
112
- "method": "get_best_categories",
113
- "params": ["after", "limit"]
114
- }, {
115
- "api": "database_api",
116
- "method": "get_active_categories",
117
- "params": ["after", "limit"]
118
- }, {
119
- "api": "database_api",
120
- "method": "get_recent_categories",
121
- "params": ["after", "limit"]
122
- }, {
123
- "api": "database_api",
124
- "method": "get_config"
125
- }, {
126
- "api": "database_api",
127
- "method": "get_dynamic_global_properties"
128
- }, {
129
- "api": "database_api",
130
- "method": "get_chain_properties"
131
- }, {
132
- "api": "database_api",
133
- "method": "get_feed_history"
134
- }, {
135
- "api": "database_api",
136
- "method": "get_current_median_history_price"
137
- }, {
138
- "api": "database_api",
139
- "method": "get_witness_schedule"
140
- }, {
141
- "api": "database_api",
142
- "method": "get_hardfork_version"
143
- }, {
144
- "api": "database_api",
145
- "method": "get_next_scheduled_hardfork"
146
- }, {
147
- "api": "account_by_key_api",
148
- "method": "get_key_references",
149
- "params": ["key"]
150
- }, {
151
- "api": "database_api",
152
- "method": "get_accounts",
153
- "params": ["names"]
154
- }, {
155
- "api": "database_api",
156
- "method": "get_account_references",
157
- "params": ["accountId"]
158
- }, {
159
- "api": "database_api",
160
- "method": "lookup_account_names",
161
- "params": ["accountNames"]
162
- }, {
163
- "api": "database_api",
164
- "method": "lookup_accounts",
165
- "params": ["lowerBoundName", "limit"]
166
- }, {
167
- "api": "database_api",
168
- "method": "get_account_count"
169
- }, {
170
- "api": "database_api",
171
- "method": "get_conversion_requests",
172
- "params": ["accountName"]
173
- }, {
174
- "api": "database_api",
175
- "method": "get_account_history",
176
- "params": ["account", "from", "limit"]
177
- }, {
178
- "api": "database_api",
179
- "method": "get_owner_history",
180
- "params": ["account"]
181
- }, {
182
- "api": "database_api",
183
- "method": "get_recovery_request",
184
- "params": ["account"]
185
- }, {
186
- "api": "database_api",
187
- "method": "get_escrow",
188
- "params": ["from", "escrowId"]
189
- }, {
190
- "api": "database_api",
191
- "method": "get_withdraw_routes",
192
- "params": ["account", "withdrawRouteType"]
193
- }, {
194
- "api": "database_api",
195
- "method": "get_account_bandwidth",
196
- "params": ["account", "bandwidthType"]
197
- }, {
198
- "api": "database_api",
199
- "method": "get_savings_withdraw_from",
200
- "params": ["account"]
201
- }, {
202
- "api": "database_api",
203
- "method": "get_savings_withdraw_to",
204
- "params": ["account"]
205
- }, {
206
- "api": "database_api",
207
- "method": "get_order_book",
208
- "params": ["limit"]
209
- }, {
210
- "api": "database_api",
211
- "method": "get_open_orders",
212
- "params": ["owner"]
213
- }, {
214
- "api": "database_api",
215
- "method": "get_liquidity_queue",
216
- "params": ["startAccount", "limit"]
217
- }, {
218
- "api": "database_api",
219
- "method": "get_transaction_hex",
220
- "params": ["trx"]
221
- }, {
222
- "api": "database_api",
223
- "method": "get_transaction",
224
- "params": ["trxId"]
225
- }, {
226
- "api": "database_api",
227
- "method": "get_required_signatures",
228
- "params": ["trx", "availableKeys"]
229
- }, {
230
- "api": "database_api",
231
- "method": "get_potential_signatures",
232
- "params": ["trx"]
233
- }, {
234
- "api": "database_api",
235
- "method": "verify_authority",
236
- "params": ["trx"]
237
- }, {
238
- "api": "database_api",
239
- "method": "verify_account_authority",
240
- "params": ["nameOrId", "signers"]
241
- }, {
242
- "api": "database_api",
243
- "method": "get_active_votes",
244
- "params": ["author", "permlink"]
245
- }, {
246
- "api": "database_api",
247
- "method": "get_account_votes",
248
- "params": ["voter"]
249
- }, {
250
- "api": "database_api",
251
- "method": "get_content",
252
- "params": ["author", "permlink"]
253
- }, {
254
- "api": "database_api",
255
- "method": "get_content_replies",
256
- "params": ["author", "permlink"]
257
- }, {
258
- "api": "database_api",
259
- "method": "get_discussions_by_author_before_date",
260
- "params": ["author", "startPermlink", "beforeDate", "limit"]
261
- }, {
262
- "api": "database_api",
263
- "method": "get_replies_by_last_update",
264
- "params": ["startAuthor", "startPermlink", "limit"]
265
- }, {
266
- "api": "database_api",
267
- "method": "get_witnesses",
268
- "params": ["witnessIds"]
269
- }, {
270
- "api": "database_api",
271
- "method": "get_witness_by_account",
272
- "params": ["accountName"]
273
- }, {
274
- "api": "database_api",
275
- "method": "get_witnesses_by_vote",
276
- "params": ["from", "limit"]
277
- }, {
278
- "api": "database_api",
279
- "method": "lookup_witness_accounts",
280
- "params": ["lowerBoundName", "limit"]
281
- }, {
282
- "api": "database_api",
283
- "method": "get_witness_count"
284
- }, {
285
- "api": "database_api",
286
- "method": "get_active_witnesses"
287
- }, {
288
- "api": "database_api",
289
- "method": "get_miner_queue"
290
- }, {
291
- "api": "database_api",
292
- "method": "get_reward_fund",
293
- "params": ["name"]
294
- }, {
295
- "api": "database_api",
296
- "method": "get_vesting_delegations",
297
- "params": ["account", "from", "limit"]
298
- }, {
299
- "api": "login_api",
300
- "method": "login",
301
- "params": ["username", "password"]
302
- }, {
303
- "api": "login_api",
304
- "method": "get_api_by_name",
305
- "params": ["database_api"]
306
- }, {
307
- "api": "login_api",
308
- "method": "get_version"
309
- }, {
310
- "api": "follow_api",
311
- "method": "get_followers",
312
- "params": ["following", "startFollower", "followType", "limit"]
313
- }, {
314
- "api": "follow_api",
315
- "method": "get_following",
316
- "params": ["follower", "startFollowing", "followType", "limit"]
317
- }, {
318
- "api": "follow_api",
319
- "method": "get_follow_count",
320
- "params": ["account"]
321
- }, {
322
- "api": "follow_api",
323
- "method": "get_feed_entries",
324
- "params": ["account", "entryId", "limit"]
325
- }, {
326
- "api": "follow_api",
327
- "method": "get_feed",
328
- "params": ["account", "entryId", "limit"]
329
- }, {
330
- "api": "follow_api",
331
- "method": "get_blog_entries",
332
- "params": ["account", "entryId", "limit"]
333
- }, {
334
- "api": "follow_api",
335
- "method": "get_blog",
336
- "params": ["account", "entryId", "limit"]
337
- }, {
338
- "api": "follow_api",
339
- "method": "get_account_reputations",
340
- "params": ["lowerBoundName", "limit"]
341
- }, {
342
- "api": "follow_api",
343
- "method": "get_reblogged_by",
344
- "params": ["author", "permlink"]
345
- }, {
346
- "api": "follow_api",
347
- "method": "get_blog_authors",
348
- "params": ["blogAccount"]
349
- }, {
350
- "api": "network_broadcast_api",
351
- "method": "broadcast_transaction",
352
- "params": ["trx"]
353
- }, {
354
- "api": "network_broadcast_api",
355
- "method": "broadcast_transaction_with_callback",
356
- "params": ["confirmationCallback", "trx"]
357
- }, {
358
- "api": "network_broadcast_api",
359
- "method": "broadcast_transaction_synchronous",
360
- "params": ["trx"]
361
- }, {
362
- "api": "network_broadcast_api",
363
- "method": "broadcast_block",
364
- "params": ["b"]
365
- }, {
366
- "api": "network_broadcast_api",
367
- "method": "set_max_block_age",
368
- "params": ["maxBlockAge"]
369
- }, {
370
- "api": "market_history_api",
371
- "method": "get_ticker",
372
- "params": []
373
- }, {
374
- "api": "market_history_api",
375
- "method": "get_volume",
376
- "params": []
377
- }, {
378
- "api": "market_history_api",
379
- "method": "get_order_book",
380
- "method_name": "getMarketOrderBook",
381
- "params": ["limit"]
382
- }, {
383
- "api": "market_history_api",
384
- "method": "get_trade_history",
385
- "params": ["start", "end", "limit"]
386
- }, {
387
- "api": "market_history_api",
388
- "method": "get_recent_trades",
389
- "params": ["limit"]
390
- }, {
391
- "api": "market_history_api",
392
- "method": "get_market_history",
393
- "params": ["bucket_seconds", "start", "end"]
394
- }, {
395
- "api": "market_history_api",
396
- "method": "get_market_history_buckets",
397
- "params": []
398
- }, {
399
- "api": "condenser_api",
400
- "method": "find_proposals",
401
- "params": ["id_set"]
402
- }, {
403
- "api": "condenser_api",
404
- "method": "list_proposals",
405
- "params": ["start", "limit", "order_by", "order_direction", "status"]
406
- }, {
407
- "api": "condenser_api",
408
- "method": "list_proposal_votes",
409
- "params": ["start", "limit", "order_by", "order_direction", "status"]
410
- }, {
411
- "api": "condenser_api",
412
- "method": "get_nai_pool",
413
- "params": []
414
- }, {
415
- "api": "rc_api",
416
- "method": "find_rc_accounts",
417
- "params": ["accounts"],
418
- "is_object": true
419
- }, {
420
- "api": "condenser_api",
421
- "method": "get_expiring_vesting_delegations",
422
- "params": ["account", "start", "limit"]
423
- }, {
424
- "api": "database_api",
425
- "method": "find_change_recovery_account_requests",
426
- "params": ["account"],
427
- "is_object": true
428
- }];
@@ -1,135 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.K = void 0;
7
- exports.sign = sign;
8
- exports.validate = validate;
9
- var _crypto = require("crypto");
10
- var _ecc = require("../auth/ecc");
11
- /**
12
- * @file JSONRPC 2.0 request authentication with steem authorities.
13
- * Based on the original @steemit/rpc-auth package
14
- */
15
-
16
- /**
17
- * Signing constant used to reserve opcode space and prevent cross-protocol attacks.
18
- * Output of `sha256('steem_jsonrpc_auth')`.
19
- */
20
- const K = exports.K = Buffer.from('3b3b081e46ea808d5a96b08c4bc5003f5e15767090f344faab531ec57565136b', 'hex');
21
-
22
- /**
23
- * Create request hash to be signed.
24
- *
25
- * @param timestamp ISO8601 formatted date e.g. `2017-11-14T19:40:29.077Z`.
26
- * @param account Steem account name that is the signer.
27
- * @param method RPC request method.
28
- * @param params Base64 encoded JSON string containing request params.
29
- * @param nonce 8 bytes of random data.
30
- *
31
- * @returns bytes to be signed or validated.
32
- */
33
- function hashMessage(timestamp, account, method, params, nonce) {
34
- const first = (0, _crypto.createHash)('sha256');
35
- first.update(timestamp);
36
- first.update(account);
37
- first.update(method);
38
- first.update(params);
39
- const second = (0, _crypto.createHash)('sha256');
40
- second.update(K);
41
- second.update(first.digest());
42
- second.update(nonce);
43
- return second.digest();
44
- }
45
-
46
- /**
47
- * Sign a JSON RPC Request.
48
- */
49
- function sign(request, account, keys) {
50
- if (!request.params) {
51
- throw new Error('Unable to sign a request without params');
52
- }
53
- const params = Buffer.from(JSON.stringify(request.params), 'utf8').toString('base64');
54
- const nonceBytes = (0, _crypto.randomBytes)(8);
55
- const nonce = nonceBytes.toString('hex');
56
- const timestamp = new Date().toISOString();
57
- const message = hashMessage(timestamp, account, request.method, params, nonceBytes);
58
- const signatures = [];
59
- for (let key of keys) {
60
- if (typeof key === 'string') {
61
- key = _ecc.PrivateKey.fromString(key);
62
- }
63
- const signature = key.sign(message).toHex();
64
- signatures.push(signature);
65
- }
66
- return {
67
- jsonrpc: '2.0',
68
- method: request.method,
69
- id: request.id,
70
- params: {
71
- __signed: {
72
- account,
73
- nonce,
74
- params,
75
- signatures,
76
- timestamp
77
- }
78
- }
79
- };
80
- }
81
-
82
- /**
83
- * Validate a signed JSON RPC request.
84
- * Throws a ValidationError if the request fails validation.
85
- *
86
- * @returns Resolved request params.
87
- */
88
- async function validate(request, verify) {
89
- if (request.jsonrpc !== '2.0' || typeof request.method !== 'string') {
90
- throw new Error('Invalid JSON RPC Request');
91
- }
92
- if (request.params == undefined || request.params.__signed == undefined) {
93
- throw new Error('Signed payload missing');
94
- }
95
- if (Object.keys(request.params).length !== 1) {
96
- throw new Error('Invalid request params');
97
- }
98
- const signed = request.params.__signed;
99
- if (signed.account == undefined) {
100
- throw new Error('Missing account');
101
- }
102
- let params;
103
- try {
104
- const jsonString = Buffer.from(signed.params, 'base64').toString('utf8');
105
- params = JSON.parse(jsonString);
106
- } catch (cause) {
107
- throw new Error(`Invalid encoded params: ${cause.message}`);
108
- }
109
- if (signed.nonce == undefined || typeof signed.nonce !== 'string') {
110
- throw new Error('Invalid nonce');
111
- }
112
- const nonce = Buffer.from(signed.nonce, 'hex');
113
- if (nonce.length !== 8) {
114
- throw new Error('Invalid nonce');
115
- }
116
- const timestamp = Date.parse(signed.timestamp);
117
- if (Number.isNaN(timestamp)) {
118
- throw new Error('Invalid timestamp');
119
- }
120
- if (Date.now() - timestamp > 60 * 1000) {
121
- throw new Error('Signature expired');
122
- }
123
- const message = hashMessage(signed.timestamp, signed.account, request.method, signed.params, nonce);
124
- try {
125
- await verify(message, signed.signatures, signed.account);
126
- } catch (cause) {
127
- throw new Error(`Verification failed: ${cause.message}`);
128
- }
129
- return params;
130
- }
131
- var _default = exports.default = {
132
- sign,
133
- validate,
134
- K
135
- };
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _bluebird = _interopRequireDefault(require("bluebird"));
8
- var _events = _interopRequireDefault(require("events"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- class Transport extends _events.default {
11
- constructor(options = {}) {
12
- super(options);
13
- this.options = options;
14
- this.id = 0;
15
- }
16
- setOptions(options) {
17
- Object.assign(this.options, options);
18
- this.stop();
19
- }
20
- listenTo(target, eventName, callback) {
21
- if (target.addEventListener) target.addEventListener(eventName, callback);else target.on(eventName, callback);
22
- return () => {
23
- if (target.removeEventListener) target.removeEventListener(eventName, callback);else target.removeListener(eventName, callback);
24
- };
25
- }
26
- send() {}
27
- start() {}
28
- stop() {}
29
- }
30
- exports.default = Transport;
31
- _bluebird.default.promisifyAll(Transport.prototype);