@leofcoin/chain 1.10.9 → 1.10.11

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 (44) hide show
  1. package/exports/beacon-envelope.js +68 -0
  2. package/exports/beacon-epoch.js +117 -0
  3. package/exports/beacon-lifecycle.js +155 -0
  4. package/exports/beacon-round.js +77 -0
  5. package/exports/beacon-wire.js +98 -0
  6. package/exports/beacon.js +141 -0
  7. package/exports/browser/beacon-envelope.js +163 -0
  8. package/exports/browser/beacon-epoch.js +116 -0
  9. package/exports/browser/beacon-lifecycle.js +154 -0
  10. package/exports/browser/beacon-round.js +76 -0
  11. package/exports/browser/beacon-wire.js +99 -0
  12. package/exports/browser/beacon.js +1706 -0
  13. package/exports/browser/{browser-D-r0O9Qn-BZDYY6cg.js → browser-CWeoyGUw-BabtHowB.js} +4 -2
  14. package/exports/browser/{browser-_hiyXwPp-DYI1tyUr.js → browser-DvU1xNFS-sdlKNCJc.js} +4 -2
  15. package/exports/browser/chain.js +174 -5008
  16. package/exports/browser/{client-BVhUamQG-D-D1e_x8.js → client-B-jyclOB-CsNYfj4Z.js} +6 -4
  17. package/exports/browser/constants-Cv0p224A.js +130 -0
  18. package/exports/browser/hkdf-DhdhLAAv.js +147 -0
  19. package/exports/browser/{index-BD0Anx7_-Dg4_tCeN.js → index-Bxr5Iztg-C6xBk0rK.js} +4 -2
  20. package/exports/browser/index-CvKt4UDE.js +464 -0
  21. package/exports/browser/index-D7FUx7Dd.js +4996 -0
  22. package/exports/browser/{messages-UKnuelZ7-DJT-98q-.js → messages-FMRAS8QX-CvlZBzy5.js} +4 -2
  23. package/exports/browser/{node-browser-DlzZ5CP_.js → node-browser-xlqSBOaN.js} +12 -5
  24. package/exports/browser/node-browser.js +4 -2
  25. package/exports/browser/{constants-gMYZLHKp.js → proposal.proto-BcUgd885.js} +61 -620
  26. package/exports/browser/quorum-S_qdgiAY.js +8 -0
  27. package/exports/browser/weierstrass-C-jX_jly.js +2156 -0
  28. package/exports/browser/workers/block-worker.js +1 -1
  29. package/exports/browser/workers/machine-worker.js +7142 -72
  30. package/exports/browser/workers/{worker-CZqErLI7-BxofVJAn.js → worker-DMCj1e6z-CTYVa2yX.js} +30 -1
  31. package/exports/chain.js +158 -75
  32. package/exports/{constants-D6gWzJZg.js → constants-CMYKv-Rt.js} +1 -1
  33. package/exports/node.js +1 -1
  34. package/exports/quorum-S_qdgiAY.js +8 -0
  35. package/exports/workers/block-worker.js +1 -1
  36. package/exports/workers/machine-worker.js +7142 -72
  37. package/exports/workers/{worker-CZqErLI7-BxofVJAn.js → worker-DMCj1e6z-CTYVa2yX.js} +30 -1
  38. package/package.json +29 -2
  39. package/types/beacon-envelope.d.ts +27 -0
  40. package/types/beacon-epoch.d.ts +28 -0
  41. package/types/beacon-lifecycle.d.ts +40 -0
  42. package/types/beacon-round.d.ts +18 -0
  43. package/types/beacon-wire.d.ts +31 -0
  44. package/types/beacon.d.ts +24 -0
@@ -1,6 +1,8 @@
1
- import { i as inflate_1, c as createDebugger, d as deflate_1, L as LittlePubSub } from './node-browser-DlzZ5CP_.js';
1
+ import { i as inflate_1, c as createDebugger, d as deflate_1, L as LittlePubSub } from './node-browser-xlqSBOaN.js';
2
2
  import 'crypto';
3
- import './constants-gMYZLHKp.js';
3
+ import './constants-Cv0p224A.js';
4
+ import './proposal.proto-BcUgd885.js';
5
+ import './index-CvKt4UDE.js';
4
6
 
5
7
  class Api {
6
8
  _pubsub;
@@ -231,7 +233,7 @@ class SocketRequestClient {
231
233
  const init = async () => {
232
234
  // @ts-ignore
233
235
  if (!globalThis.WebSocket && !this.#experimentalWebsocket)
234
- globalThis.WebSocket = (await import('./browser-_hiyXwPp-DYI1tyUr.js').then(function (n) { return n.b; })).default.w3cwebsocket;
236
+ globalThis.WebSocket = (await import('./browser-DvU1xNFS-sdlKNCJc.js').then(function (n) { return n.b; })).default.w3cwebsocket;
235
237
  const client = new WebSocket(this.#url, this.#protocol);
236
238
  if (this.#experimentalWebsocket) {
237
239
  client.addEventListener('error', this.onerror);
@@ -1323,7 +1325,7 @@ class Client {
1323
1325
  }
1324
1326
  }
1325
1327
  async #loadNodeWebrtcImplementation() {
1326
- const koushWrtcModule = await import('./browser-D-r0O9Qn-BZDYY6cg.js').then(function (n) { return n.b; });
1328
+ const koushWrtcModule = await import('./browser-CWeoyGUw-BabtHowB.js').then(function (n) { return n.b; });
1327
1329
  const koushWrtc = koushWrtcModule.default;
1328
1330
  if (!isWrtcImplementation(koushWrtc)) {
1329
1331
  throw new Error('@koush/wrtc does not match required wrtc contract');
@@ -0,0 +1,130 @@
1
+ import { F as FormatInterface, n as proto$2, o as proto$3, i as index, f as index$1, q as proto$4 } from './proposal.proto-BcUgd885.js';
2
+
3
+ class ValidatorMessage extends FormatInterface {
4
+ get messageName() {
5
+ return "ValidatorMessage";
6
+ }
7
+ constructor(buffer) {
8
+ if (buffer instanceof ValidatorMessage)
9
+ return buffer;
10
+ const name = "validator-message";
11
+ super(buffer, proto$2, { name });
12
+ }
13
+ }
14
+
15
+ class BlockMessage extends FormatInterface {
16
+ get messageName() {
17
+ return "BlockMessage";
18
+ }
19
+ constructor(buffer) {
20
+ if (buffer instanceof BlockMessage)
21
+ return buffer;
22
+ const name = "block-message";
23
+ super(buffer, proto$3, { name });
24
+ }
25
+ encode(decoded) {
26
+ decoded = decoded || this.decoded;
27
+ const validators = [];
28
+ for (const validator of decoded.validators) {
29
+ if (validator instanceof ValidatorMessage)
30
+ validators.push(validator.encode());
31
+ else
32
+ validators.push(new ValidatorMessage(validator).encode());
33
+ }
34
+ return super.encode({
35
+ ...decoded,
36
+ validators: index(validators)
37
+ });
38
+ }
39
+ decode(encoded) {
40
+ encoded = encoded || this.encoded;
41
+ super.decode(encoded);
42
+ this.decoded.validators = index$1(this.decoded.validators).map((validator) => new ValidatorMessage(validator).decoded);
43
+ return this.decoded;
44
+ }
45
+ }
46
+
47
+ var proto$1 = {
48
+ up: Number(),
49
+ down: Number()
50
+ };
51
+
52
+ class BWMessage extends FormatInterface {
53
+ get messageName() {
54
+ return "BWMessage";
55
+ }
56
+ constructor(buffer) {
57
+ if (buffer instanceof BWMessage)
58
+ return buffer;
59
+ const name = "bw-message";
60
+ super(buffer, proto$1, { name });
61
+ }
62
+ }
63
+
64
+ class LastBlockMessage extends FormatInterface {
65
+ get messageName() {
66
+ return "LastBlockMessage";
67
+ }
68
+ constructor(buffer) {
69
+ if (buffer instanceof LastBlockMessage)
70
+ return buffer;
71
+ const name = "last-block-message";
72
+ super(buffer, proto$4, { name });
73
+ }
74
+ }
75
+
76
+ var proto = {
77
+ lastblock: Object(),
78
+ values: Object()
79
+ };
80
+
81
+ class StateMessage extends FormatInterface {
82
+ get messageName() {
83
+ return "StateMessage";
84
+ }
85
+ constructor(buffer) {
86
+ if (buffer instanceof StateMessage)
87
+ return buffer;
88
+ const name = "state-message";
89
+ super(buffer, proto, { name });
90
+ }
91
+ }
92
+
93
+ var networks = {
94
+ leofcoin: {
95
+ mainnet: {
96
+ // ports don't really matter since it is favorable to have it begind a ngninx proxy but if we change something to the proto it's easier maybe?
97
+ port: 44444,
98
+ // todo a versionhash would be nice to have as a double check?
99
+ versionHash: "0",
100
+ // a short description identifying the version
101
+ description: "Main net current version",
102
+ stars: ["wss://star.leofcoin.org"]
103
+ // todo webrtc and bittorent stars
104
+ },
105
+ peach: {
106
+ port: 44444,
107
+ description: "Main testnet: latest step before merging into main",
108
+ versionHash: "1",
109
+ stars: ["wss://star.leofcoin.org"]
110
+ // todo webrtc and bittorent stars
111
+ }
112
+ }
113
+ };
114
+
115
+ var networks$1 = /*#__PURE__*/Object.freeze({
116
+ __proto__: null,
117
+ default: networks
118
+ });
119
+
120
+ const PROTOCOL_VERSION = "0.3.0";
121
+ const REACHED_ONE_ZERO_ZERO = false;
122
+ const DEFAULT_NODE_OPTIONS = {
123
+ autoStart: false,
124
+ network: "leofcoin:peach",
125
+ networkVersion: "peach",
126
+ version: PROTOCOL_VERSION,
127
+ stars: networks.leofcoin.peach.stars
128
+ };
129
+
130
+ export { BlockMessage as B, DEFAULT_NODE_OPTIONS as D, LastBlockMessage as L, PROTOCOL_VERSION as P, REACHED_ONE_ZERO_ZERO as R, StateMessage as S, ValidatorMessage as V, BWMessage as a, networks$1 as n };
@@ -0,0 +1,147 @@
1
+ import { H as Hash, h as hash, t as toBytes, e as exists, b as bytes, n as number } from './weierstrass-C-jX_jly.js';
2
+
3
+ // HMAC (RFC 2104)
4
+ class HMAC extends Hash {
5
+ constructor(hash$1, _key) {
6
+ super();
7
+ this.finished = false;
8
+ this.destroyed = false;
9
+ hash(hash$1);
10
+ const key = toBytes(_key);
11
+ this.iHash = hash$1.create();
12
+ if (typeof this.iHash.update !== 'function')
13
+ throw new Error('Expected instance of class which extends utils.Hash');
14
+ this.blockLen = this.iHash.blockLen;
15
+ this.outputLen = this.iHash.outputLen;
16
+ const blockLen = this.blockLen;
17
+ const pad = new Uint8Array(blockLen);
18
+ // blockLen can be bigger than outputLen
19
+ pad.set(key.length > blockLen ? hash$1.create().update(key).digest() : key);
20
+ for (let i = 0; i < pad.length; i++)
21
+ pad[i] ^= 0x36;
22
+ this.iHash.update(pad);
23
+ // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
24
+ this.oHash = hash$1.create();
25
+ // Undo internal XOR && apply outer XOR
26
+ for (let i = 0; i < pad.length; i++)
27
+ pad[i] ^= 0x36 ^ 0x5c;
28
+ this.oHash.update(pad);
29
+ pad.fill(0);
30
+ }
31
+ update(buf) {
32
+ exists(this);
33
+ this.iHash.update(buf);
34
+ return this;
35
+ }
36
+ digestInto(out) {
37
+ exists(this);
38
+ bytes(out, this.outputLen);
39
+ this.finished = true;
40
+ this.iHash.digestInto(out);
41
+ this.oHash.update(out);
42
+ this.oHash.digestInto(out);
43
+ this.destroy();
44
+ }
45
+ digest() {
46
+ const out = new Uint8Array(this.oHash.outputLen);
47
+ this.digestInto(out);
48
+ return out;
49
+ }
50
+ _cloneInto(to) {
51
+ // Create new instance without calling constructor since key already in state and we don't know it.
52
+ to || (to = Object.create(Object.getPrototypeOf(this), {}));
53
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
54
+ to = to;
55
+ to.finished = finished;
56
+ to.destroyed = destroyed;
57
+ to.blockLen = blockLen;
58
+ to.outputLen = outputLen;
59
+ to.oHash = oHash._cloneInto(to.oHash);
60
+ to.iHash = iHash._cloneInto(to.iHash);
61
+ return to;
62
+ }
63
+ destroy() {
64
+ this.destroyed = true;
65
+ this.oHash.destroy();
66
+ this.iHash.destroy();
67
+ }
68
+ }
69
+ /**
70
+ * HMAC: RFC2104 message authentication code.
71
+ * @param hash - function that would be used e.g. sha256
72
+ * @param key - message key
73
+ * @param message - message data
74
+ */
75
+ const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
76
+ hmac.create = (hash, key) => new HMAC(hash, key);
77
+
78
+ // HKDF (RFC 5869)
79
+ // https://soatok.blog/2021/11/17/understanding-hkdf/
80
+ /**
81
+ * HKDF-Extract(IKM, salt) -> PRK
82
+ * Arguments position differs from spec (IKM is first one, since it is not optional)
83
+ * @param hash
84
+ * @param ikm
85
+ * @param salt
86
+ * @returns
87
+ */
88
+ function extract(hash$1, ikm, salt) {
89
+ hash(hash$1);
90
+ // NOTE: some libraries treat zero-length array as 'not provided';
91
+ // we don't, since we have undefined as 'not provided'
92
+ // https://github.com/RustCrypto/KDFs/issues/15
93
+ if (salt === undefined)
94
+ salt = new Uint8Array(hash$1.outputLen); // if not provided, it is set to a string of HashLen zeros
95
+ return hmac(hash$1, toBytes(salt), toBytes(ikm));
96
+ }
97
+ // HKDF-Expand(PRK, info, L) -> OKM
98
+ const HKDF_COUNTER = /* @__PURE__ */ new Uint8Array([0]);
99
+ const EMPTY_BUFFER = /* @__PURE__ */ new Uint8Array();
100
+ /**
101
+ * HKDF-expand from the spec.
102
+ * @param prk - a pseudorandom key of at least HashLen octets (usually, the output from the extract step)
103
+ * @param info - optional context and application specific information (can be a zero-length string)
104
+ * @param length - length of output keying material in octets
105
+ */
106
+ function expand(hash$1, prk, info, length = 32) {
107
+ hash(hash$1);
108
+ number(length);
109
+ if (length > 255 * hash$1.outputLen)
110
+ throw new Error('Length should be <= 255*HashLen');
111
+ const blocks = Math.ceil(length / hash$1.outputLen);
112
+ if (info === undefined)
113
+ info = EMPTY_BUFFER;
114
+ // first L(ength) octets of T
115
+ const okm = new Uint8Array(blocks * hash$1.outputLen);
116
+ // Re-use HMAC instance between blocks
117
+ const HMAC = hmac.create(hash$1, prk);
118
+ const HMACTmp = HMAC._cloneInto();
119
+ const T = new Uint8Array(HMAC.outputLen);
120
+ for (let counter = 0; counter < blocks; counter++) {
121
+ HKDF_COUNTER[0] = counter + 1;
122
+ // T(0) = empty string (zero length)
123
+ // T(N) = HMAC-Hash(PRK, T(N-1) | info | N)
124
+ HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T)
125
+ .update(info)
126
+ .update(HKDF_COUNTER)
127
+ .digestInto(T);
128
+ okm.set(T, hash$1.outputLen * counter);
129
+ HMAC._cloneInto(HMACTmp);
130
+ }
131
+ HMAC.destroy();
132
+ HMACTmp.destroy();
133
+ T.fill(0);
134
+ HKDF_COUNTER.fill(0);
135
+ return okm.slice(0, length);
136
+ }
137
+ /**
138
+ * HKDF (RFC 5869): extract + expand in one step.
139
+ * @param hash - hash function that would be used (e.g. sha256)
140
+ * @param ikm - input keying material, the initial key
141
+ * @param salt - optional salt value (a non-secret random value)
142
+ * @param info - optional context and application specific information
143
+ * @param length - length of output keying material in octets
144
+ */
145
+ const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
146
+
147
+ export { hkdf as a, hmac as h };
@@ -1,6 +1,8 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-DlzZ5CP_.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-xlqSBOaN.js';
2
2
  import 'crypto';
3
- import './constants-gMYZLHKp.js';
3
+ import './constants-Cv0p224A.js';
4
+ import './proposal.proto-BcUgd885.js';
5
+ import './index-CvKt4UDE.js';
4
6
 
5
7
  /**
6
8
  * @params {String} network