@leofcoin/chain 1.10.16 → 1.10.17
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/exports/beacon-envelope.js +6 -6
- package/exports/beacon-epoch.js +1 -1
- package/exports/beacon-lifecycle.js +1 -1
- package/exports/beacon-round.js +1 -1
- package/exports/beacon.js +15 -14
- package/exports/browser/_commonjsHelpers-B85MJLTf.js +5 -0
- package/exports/browser/beacon-envelope.js +61 -150
- package/exports/browser/beacon-epoch.js +2 -2
- package/exports/browser/beacon-lifecycle.js +3 -3
- package/exports/browser/beacon-round.js +2 -2
- package/exports/browser/beacon-wire.js +3 -3
- package/exports/browser/beacon.js +2483 -1228
- package/exports/browser/{browser-CCfR9KOM-CvhDZrGu.js → browser-CCfR9KOM-CpStHgTj.js} +4 -4
- package/exports/browser/{browser-crypto-CeE-yId5.js → browser-crypto-CH0ua22L.js} +1 -1
- package/exports/browser/chain.js +5 -8
- package/exports/browser/{client-CAC7RVMf-Dmz_2A_5.js → client-C_pBoi1g-_pfKzCvX.js} +256 -80
- package/exports/browser/{connection-monitor-Cmv00mwl.js → connection-monitor-D-krNiRH.js} +1 -1
- package/exports/browser/{hkdf-CnZvwpZ9.js → hkdf-BUHINPFj.js} +2 -94
- package/exports/browser/{index-BC-KRBgE.js → index-DmuI-29u.js} +1 -1
- package/exports/browser/{index-dTQVgkpf-CuHJWO2l.js → index-dTQVgkpf-BbdshWB0.js} +4 -4
- package/exports/browser/index.browser-CFfJpgKV.js +857 -0
- package/exports/browser/{messages-Dw86z0zq-DrPw_nlZ.js → messages-BGHaihSi-eHZVl0y9.js} +4 -4
- package/exports/browser/{node-browser-DWSdi-XP.js → node-browser-BNe-en1l.js} +5 -5
- package/exports/browser/node-browser.js +4 -4
- package/exports/browser/{sha2-piimb6xL.js → sha2-BKcEJzgd.js} +144 -3
- package/exports/browser/weierstrass-BVfhtHbl.js +3596 -0
- package/exports/browser/workers/machine-worker.js +42 -14
- package/exports/workers/machine-worker.js +42 -14
- package/package.json +14 -13
- package/exports/browser/weierstrass-Q0QND1ZT.js +0 -2156
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { F as FormatInterface } from './node-browser-
|
|
2
|
-
import './browser-crypto-
|
|
3
|
-
import './connection-monitor-
|
|
1
|
+
import { F as FormatInterface } from './node-browser-BNe-en1l.js';
|
|
2
|
+
import './browser-crypto-CH0ua22L.js';
|
|
3
|
+
import './connection-monitor-D-krNiRH.js';
|
|
4
4
|
import './index-CvKt4UDE.js';
|
|
5
|
-
import './sha2-
|
|
5
|
+
import './sha2-BKcEJzgd.js';
|
|
6
6
|
|
|
7
7
|
var proto$b = {
|
|
8
8
|
data: new Uint8Array(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FormatInterface$2, T as TransactionMessage, C as ContractMessage, n as createHash$1 } from './browser-crypto-
|
|
2
|
-
import { B as BlockMessage, a as BWMessage, V as ValidatorMessage, S as StateMessage, L as LastBlockMessage, D as DEFAULT_NODE_OPTIONS, g as guardPeerMessages } from './connection-monitor-
|
|
1
|
+
import { F as FormatInterface$2, T as TransactionMessage, C as ContractMessage, n as createHash$1 } from './browser-crypto-CH0ua22L.js';
|
|
2
|
+
import { B as BlockMessage, a as BWMessage, V as ValidatorMessage, S as StateMessage, L as LastBlockMessage, D as DEFAULT_NODE_OPTIONS, g as guardPeerMessages } from './connection-monitor-D-krNiRH.js';
|
|
3
3
|
import './index-CvKt4UDE.js';
|
|
4
4
|
|
|
5
5
|
var proto = {};
|
|
@@ -8510,7 +8510,7 @@ class Identity {
|
|
|
8510
8510
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
8511
8511
|
}
|
|
8512
8512
|
else {
|
|
8513
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-dTQVgkpf-
|
|
8513
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-dTQVgkpf-BbdshWB0.js');
|
|
8514
8514
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
8515
8515
|
if (fresh) {
|
|
8516
8516
|
await globalThis.accountStore.clear();
|
|
@@ -17484,7 +17484,7 @@ class Peernet {
|
|
|
17484
17484
|
await getAddress();
|
|
17485
17485
|
this.storePrefix = options.storePrefix;
|
|
17486
17486
|
this.root = options.root;
|
|
17487
|
-
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-
|
|
17487
|
+
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-BGHaihSi-eHZVl0y9.js');
|
|
17488
17488
|
/**
|
|
17489
17489
|
* proto Object containing protos
|
|
17490
17490
|
* @type {Object}
|
|
@@ -17531,7 +17531,7 @@ class Peernet {
|
|
|
17531
17531
|
if (this.#starting || this.#started)
|
|
17532
17532
|
return;
|
|
17533
17533
|
this.#starting = true;
|
|
17534
|
-
const importee = await import('./client-
|
|
17534
|
+
const importee = await import('./client-C_pBoi1g-_pfKzCvX.js');
|
|
17535
17535
|
/**
|
|
17536
17536
|
* @access public
|
|
17537
17537
|
* @type {PeernetClient}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
2
|
-
import './browser-crypto-
|
|
3
|
-
import './connection-monitor-
|
|
1
|
+
export { N as default } from './node-browser-BNe-en1l.js';
|
|
2
|
+
import './browser-crypto-CH0ua22L.js';
|
|
3
|
+
import './connection-monitor-D-krNiRH.js';
|
|
4
4
|
import './index-CvKt4UDE.js';
|
|
5
|
-
import './sha2-
|
|
5
|
+
import './sha2-BKcEJzgd.js';
|
|
@@ -73,10 +73,13 @@ function anumber(n, title = '') {
|
|
|
73
73
|
function abytes(value, length, title = '') {
|
|
74
74
|
// Success path first: this runs at the start of every update() / digestInto(), and the
|
|
75
75
|
// common `abytes(data)` form must not pay for length handling it does not use.
|
|
76
|
-
if (isBytes(value) && (length === undefined))
|
|
76
|
+
if (isBytes(value) && (length === undefined || value.length === length))
|
|
77
77
|
return value;
|
|
78
|
+
// Error path: recompute freely to build the exact message.
|
|
79
|
+
if (length !== undefined)
|
|
80
|
+
anumber(length, 'length');
|
|
78
81
|
const bytes = isBytes(value);
|
|
79
|
-
const ofLen = '';
|
|
82
|
+
const ofLen = length !== undefined ? ` of length ${length}` : '';
|
|
80
83
|
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
81
84
|
const message = atitle(title) + 'expected Uint8Array' + ofLen + ', got ' + got;
|
|
82
85
|
if (!bytes)
|
|
@@ -209,6 +212,113 @@ function createView(arr) {
|
|
|
209
212
|
function rotr(word, shift) {
|
|
210
213
|
return (word << (32 - shift)) | (word >>> shift);
|
|
211
214
|
}
|
|
215
|
+
// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
|
|
216
|
+
const hasHexBuiltin = /* @__PURE__ */ (() =>
|
|
217
|
+
// @ts-ignore
|
|
218
|
+
typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();
|
|
219
|
+
// Array where index 0xf0 (240) is mapped to string 'f0'
|
|
220
|
+
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
|
|
221
|
+
/**
|
|
222
|
+
* Convert byte array to hex string.
|
|
223
|
+
* Uses the built-in function when available and assumes it matches the tested
|
|
224
|
+
* fallback semantics.
|
|
225
|
+
* @param bytes - bytes to encode
|
|
226
|
+
* @returns Lowercase hexadecimal string.
|
|
227
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
228
|
+
* @example
|
|
229
|
+
* Convert bytes to lowercase hexadecimal.
|
|
230
|
+
* ```ts
|
|
231
|
+
* bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
function bytesToHex(bytes) {
|
|
235
|
+
abytes(bytes);
|
|
236
|
+
// @ts-ignore
|
|
237
|
+
if (hasHexBuiltin)
|
|
238
|
+
return bytes.toHex();
|
|
239
|
+
// pre-caching improves the speed 6x
|
|
240
|
+
let hex = '';
|
|
241
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
242
|
+
hex += hexes[bytes[i]];
|
|
243
|
+
}
|
|
244
|
+
return hex;
|
|
245
|
+
}
|
|
246
|
+
// Strict ASCII nibble parser: non-ASCII hex lookalikes are rejected as undefined.
|
|
247
|
+
// ASCII codes: '0'..'9' = 48..57, 'A'..'F' = 65..70, 'a'..'f' = 97..102.
|
|
248
|
+
// prettier-ignore
|
|
249
|
+
function asciiToBase16(ch) {
|
|
250
|
+
return ch >= 48 && ch <= 57 ? ch - 48 // '2' => 50-48
|
|
251
|
+
: ch >= 65 && ch <= 70 ? ch - (65 - 10) // 'B' => 66-(65-10)
|
|
252
|
+
: ch >= 97 && ch <= 102 ? ch - (97 - 10) // 'b' => 98-(97-10)
|
|
253
|
+
: undefined;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
257
|
+
* @param hex - hexadecimal string to decode
|
|
258
|
+
* @returns Decoded bytes.
|
|
259
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
260
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
261
|
+
* @example
|
|
262
|
+
* Decode lowercase hexadecimal into bytes.
|
|
263
|
+
* ```ts
|
|
264
|
+
* hexToBytes('cafe0123'); // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
function hexToBytes(hex) {
|
|
268
|
+
if (typeof hex !== 'string')
|
|
269
|
+
throw new TypeError('hex string expected, got ' + typeof hex);
|
|
270
|
+
if (hasHexBuiltin) {
|
|
271
|
+
try {
|
|
272
|
+
return Uint8Array.fromHex(hex);
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
if (error instanceof SyntaxError)
|
|
276
|
+
throw new RangeError(error.message);
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const hl = hex.length;
|
|
281
|
+
const al = hl / 2;
|
|
282
|
+
if (hl % 2)
|
|
283
|
+
throw new RangeError('hex string expected, got unpadded hex of length ' + hl);
|
|
284
|
+
const array = new Uint8Array(al);
|
|
285
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
286
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi)); // parse first char, multiply it by 16
|
|
287
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); // parse second char
|
|
288
|
+
if (n1 === undefined || n2 === undefined) {
|
|
289
|
+
const char = hex[hi] + hex[hi + 1];
|
|
290
|
+
throw new RangeError('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
291
|
+
}
|
|
292
|
+
array[ai] = n1 * 16 + n2; // example: 'A9' => 10*16 + 9
|
|
293
|
+
}
|
|
294
|
+
return array;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Copies several Uint8Arrays into one.
|
|
298
|
+
* @param arrays - arrays to concatenate
|
|
299
|
+
* @returns Concatenated byte array.
|
|
300
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
301
|
+
* @example
|
|
302
|
+
* Concatenate multiple byte arrays.
|
|
303
|
+
* ```ts
|
|
304
|
+
* concatBytes(new Uint8Array([1]), new Uint8Array([2]));
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
function concatBytes(...arrays) {
|
|
308
|
+
let sum = 0;
|
|
309
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
310
|
+
const a = arrays[i];
|
|
311
|
+
abytes(a);
|
|
312
|
+
sum += a.length;
|
|
313
|
+
}
|
|
314
|
+
const res = new Uint8Array(sum);
|
|
315
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
316
|
+
const a = arrays[i];
|
|
317
|
+
res.set(a, pad);
|
|
318
|
+
pad += a.length;
|
|
319
|
+
}
|
|
320
|
+
return res;
|
|
321
|
+
}
|
|
212
322
|
/**
|
|
213
323
|
* Merges default options and passed options.
|
|
214
324
|
* @param defaults - base option object
|
|
@@ -264,6 +374,37 @@ function createHasher(hashCons, info = {}) {
|
|
|
264
374
|
Object.assign(hashC, info);
|
|
265
375
|
return Object.freeze(hashC);
|
|
266
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Cryptographically secure PRNG backed by `crypto.getRandomValues`.
|
|
379
|
+
* @param bytesLength - number of random bytes to generate
|
|
380
|
+
* @returns Random bytes.
|
|
381
|
+
* The platform `getRandomValues()` implementation still defines any
|
|
382
|
+
* single-call length cap, and this helper rejects oversize requests
|
|
383
|
+
* with a stable library `RangeError` instead of host-specific errors.
|
|
384
|
+
* @throws On wrong argument types. {@link TypeError}
|
|
385
|
+
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
386
|
+
* @throws If the current runtime does not provide `crypto.getRandomValues`. {@link Error}
|
|
387
|
+
* @example
|
|
388
|
+
* Generate a fresh random key or nonce.
|
|
389
|
+
* ```ts
|
|
390
|
+
* const key = randomBytes(16);
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
function randomBytes(bytesLength = 32) {
|
|
394
|
+
// Match the repo's other length-taking helpers instead of relying on Uint8Array coercion.
|
|
395
|
+
anumber(bytesLength, 'bytesLength');
|
|
396
|
+
const cr = typeof globalThis === 'object' ? globalThis.crypto : null;
|
|
397
|
+
if (typeof cr?.getRandomValues !== 'function')
|
|
398
|
+
throw new Error('crypto.getRandomValues must be defined');
|
|
399
|
+
// Web Cryptography API Level 2 §10.1.1:
|
|
400
|
+
// if `byteLength > 65536`, throw `QuotaExceededError`.
|
|
401
|
+
// Keep the guard explicit so callers can see the quota in code
|
|
402
|
+
// instead of discovering it by reading the spec or host errors.
|
|
403
|
+
// This wrapper surfaces the same quota as a stable library RangeError.
|
|
404
|
+
if (bytesLength > 65536)
|
|
405
|
+
throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
406
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
407
|
+
}
|
|
267
408
|
/**
|
|
268
409
|
* Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.
|
|
269
410
|
* @param suffix - final OID byte for the selected hash.
|
|
@@ -611,4 +752,4 @@ class _SHA256 extends SHA2_32B {
|
|
|
611
752
|
const sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(),
|
|
612
753
|
/* @__PURE__ */ oidNist(0x01));
|
|
613
754
|
|
|
614
|
-
export { ahash as a,
|
|
755
|
+
export { ahash as a, anumber as b, abytes as c, clean as d, concatBytes as e, bytesToHex as f, aexists as g, hexToBytes as h, isBytes as i, aoutput as j, randomBytes as r, sha256 as s };
|