@leofcoin/chain 1.10.12 → 1.10.14

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 (52) hide show
  1. package/exports/beacon-envelope.js +2 -2
  2. package/exports/beacon-epoch.js +1 -1
  3. package/exports/beacon-lifecycle.js +2 -2
  4. package/exports/beacon-round.js +1 -1
  5. package/exports/beacon.js +1 -1
  6. package/exports/browser/beacon-envelope.js +79 -3
  7. package/exports/browser/beacon-epoch.js +2 -1
  8. package/exports/browser/beacon-lifecycle.js +3 -2
  9. package/exports/browser/beacon-round.js +2 -1
  10. package/exports/browser/beacon-wire.js +3 -3
  11. package/exports/browser/beacon.js +3 -2
  12. package/exports/browser/{browser-DvU1xNFS-sdlKNCJc.js → browser-DvU1xNFS-4-PGqr4c.js} +4 -4
  13. package/exports/browser/browser-DvU1xNFS-BJCQsckZ.js +151 -0
  14. package/exports/browser/browser-DvU1xNFS-D9eSzJGJ.js +151 -0
  15. package/exports/browser/browser-crypto-BHeOz9rj.js +8893 -0
  16. package/exports/browser/browser-crypto-CTP3Yk4M.js +8893 -0
  17. package/exports/browser/{proposal.proto-BcUgd885.js → browser-crypto-Yk_e6OHw.js} +35 -6
  18. package/exports/browser/chain.js +63 -321
  19. package/exports/browser/{client-B-jyclOB-CsNYfj4Z.js → client-DDC8C510-CUi3_3uT.js} +36 -12
  20. package/exports/browser/client-DDC8C510-DbIdQjhy.js +2225 -0
  21. package/exports/browser/client-DDC8C510-ZN_MLo1Y.js +2225 -0
  22. package/exports/browser/connection-monitor-BjXI0nBP.js +453 -0
  23. package/exports/browser/connection-monitor-Cf0vNDCA.js +453 -0
  24. package/exports/browser/connection-monitor-pdopeM1I.js +453 -0
  25. package/exports/browser/hkdf-B9AXp_7K.js +222 -0
  26. package/exports/browser/hkdf-CnZvwpZ9.js +222 -0
  27. package/exports/browser/{index-Bxr5Iztg-C6xBk0rK.js → index-Bxr5Iztg-AmkW0EHS.js} +4 -4
  28. package/exports/browser/index-Bxr5Iztg-Bdpw_E83.js +40 -0
  29. package/exports/browser/index-Bxr5Iztg-CxXVYm3t.js +40 -0
  30. package/exports/browser/{index-D7FUx7Dd.js → index-CPQ5yvZ2.js} +5 -6
  31. package/exports/browser/index-C_RakUAS.js +4995 -0
  32. package/exports/browser/index-uFaocBqT.js +4995 -0
  33. package/exports/browser/{messages-FMRAS8QX-CvlZBzy5.js → messages-DH0tgNM9-BRp0gcJh.js} +4 -4
  34. package/exports/browser/messages-DH0tgNM9-CZwrcL37.js +208 -0
  35. package/exports/browser/messages-DH0tgNM9-DkNnpePH.js +208 -0
  36. package/exports/browser/{node-browser-xlqSBOaN.js → node-browser-1VSuCeew.js} +6 -6
  37. package/exports/browser/node-browser-CQugE1WZ.js +17880 -0
  38. package/exports/browser/node-browser-wDmRaOEo.js +17880 -0
  39. package/exports/browser/node-browser.js +4 -4
  40. package/exports/browser/sha2-Dkoic3vb.js +602 -0
  41. package/exports/browser/sha2-piimb6xL.js +614 -0
  42. package/exports/browser/weierstrass-HGdA_prK.js +2156 -0
  43. package/exports/browser/{weierstrass-C-jX_jly.js → weierstrass-Q0QND1ZT.js} +1 -1
  44. package/exports/browser/workers/machine-worker.js +419 -147
  45. package/exports/chain.js +56 -313
  46. package/exports/connection-monitor.js +324 -0
  47. package/exports/node.js +2 -0
  48. package/exports/workers/machine-worker.js +419 -147
  49. package/package.json +4 -4
  50. package/exports/browser/browser-CWeoyGUw-BabtHowB.js +0 -57
  51. package/exports/browser/constants-Cv0p224A.js +0 -130
  52. package/exports/browser/hkdf-DhdhLAAv.js +0 -147
@@ -1,6 +1,6 @@
1
1
  import { secp256k1 } from '@noble/curves/secp256k1';
2
- import { hkdf } from '@noble/hashes/hkdf';
3
- import { sha256 } from '@noble/hashes/sha256';
2
+ import { hkdf } from '@noble/hashes/hkdf.js';
3
+ import { sha256 } from '@noble/hashes/sha2.js';
4
4
 
5
5
  const encoder = new TextEncoder();
6
6
  const SCALAR_BYTES = 32;
@@ -1,4 +1,4 @@
1
- import { sha256 } from '@noble/hashes/sha256';
1
+ import { sha256 } from '@noble/hashes/sha2.js';
2
2
  import { toBase58, fromBase58 } from '@vandeurenglenn/typed-array-utils';
3
3
  import { deriveBeaconGroupPublicKey } from './beacon.js';
4
4
  import { q as quorumThreshold } from './quorum-S_qdgiAY.js';
@@ -1,5 +1,5 @@
1
- import { hkdf } from '@noble/hashes/hkdf';
2
- import { sha256 } from '@noble/hashes/sha256';
1
+ import { hkdf } from '@noble/hashes/hkdf.js';
2
+ import { sha256 } from '@noble/hashes/sha2.js';
3
3
  import { canonicalBeaconEpochConfig, beaconEpochDigest } from './beacon-epoch.js';
4
4
  import '@vandeurenglenn/typed-array-utils';
5
5
  import './beacon.js';
@@ -2,7 +2,7 @@ import { fromBase58, toBase58 } from '@vandeurenglenn/typed-array-utils';
2
2
  import { beaconMessage, deriveBeaconPublicShare, verifyBeaconSignatureShare, reconstructBeaconSignature, verifyBeaconProof, beaconRandomness } from './beacon.js';
3
3
  import { canonicalBeaconEpochConfig, beaconParticipants, beaconEpochGroupPublicKey } from './beacon-epoch.js';
4
4
  import '@noble/curves/bls12-381';
5
- import '@noble/hashes/sha256';
5
+ import '@noble/hashes/sha2.js';
6
6
  import './quorum-S_qdgiAY.js';
7
7
 
8
8
  class BeaconRound {
package/exports/beacon.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { bls12_381 } from '@noble/curves/bls12-381';
2
- import { sha256 } from '@noble/hashes/sha256';
2
+ import { sha256 } from '@noble/hashes/sha2.js';
3
3
 
4
4
  const encoder = new TextEncoder();
5
5
  const Fr = bls12_381.fields.Fr;
@@ -1,5 +1,81 @@
1
- import { w as weierstrass, r as randomBytes, c as concatBytes, F as Field, m as mod, p as pow2, s as sha256 } from './weierstrass-C-jX_jly.js';
2
- import { h as hmac, a as hkdf } from './hkdf-DhdhLAAv.js';
1
+ import { H as Hash, h as hash, t as toBytes, e as exists, b as bytes, w as weierstrass, r as randomBytes, c as concatBytes, F as Field, m as mod, p as pow2, s as sha256 } from './weierstrass-HGdA_prK.js';
2
+ import { h as hkdf } from './hkdf-CnZvwpZ9.js';
3
+ import { s as sha256$1 } from './sha2-piimb6xL.js';
4
+
5
+ // HMAC (RFC 2104)
6
+ class HMAC extends Hash {
7
+ constructor(hash$1, _key) {
8
+ super();
9
+ this.finished = false;
10
+ this.destroyed = false;
11
+ hash(hash$1);
12
+ const key = toBytes(_key);
13
+ this.iHash = hash$1.create();
14
+ if (typeof this.iHash.update !== 'function')
15
+ throw new Error('Expected instance of class which extends utils.Hash');
16
+ this.blockLen = this.iHash.blockLen;
17
+ this.outputLen = this.iHash.outputLen;
18
+ const blockLen = this.blockLen;
19
+ const pad = new Uint8Array(blockLen);
20
+ // blockLen can be bigger than outputLen
21
+ pad.set(key.length > blockLen ? hash$1.create().update(key).digest() : key);
22
+ for (let i = 0; i < pad.length; i++)
23
+ pad[i] ^= 0x36;
24
+ this.iHash.update(pad);
25
+ // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone
26
+ this.oHash = hash$1.create();
27
+ // Undo internal XOR && apply outer XOR
28
+ for (let i = 0; i < pad.length; i++)
29
+ pad[i] ^= 0x36 ^ 0x5c;
30
+ this.oHash.update(pad);
31
+ pad.fill(0);
32
+ }
33
+ update(buf) {
34
+ exists(this);
35
+ this.iHash.update(buf);
36
+ return this;
37
+ }
38
+ digestInto(out) {
39
+ exists(this);
40
+ bytes(out, this.outputLen);
41
+ this.finished = true;
42
+ this.iHash.digestInto(out);
43
+ this.oHash.update(out);
44
+ this.oHash.digestInto(out);
45
+ this.destroy();
46
+ }
47
+ digest() {
48
+ const out = new Uint8Array(this.oHash.outputLen);
49
+ this.digestInto(out);
50
+ return out;
51
+ }
52
+ _cloneInto(to) {
53
+ // Create new instance without calling constructor since key already in state and we don't know it.
54
+ to || (to = Object.create(Object.getPrototypeOf(this), {}));
55
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
56
+ to = to;
57
+ to.finished = finished;
58
+ to.destroyed = destroyed;
59
+ to.blockLen = blockLen;
60
+ to.outputLen = outputLen;
61
+ to.oHash = oHash._cloneInto(to.oHash);
62
+ to.iHash = iHash._cloneInto(to.iHash);
63
+ return to;
64
+ }
65
+ destroy() {
66
+ this.destroyed = true;
67
+ this.oHash.destroy();
68
+ this.iHash.destroy();
69
+ }
70
+ }
71
+ /**
72
+ * HMAC: RFC2104 message authentication code.
73
+ * @param hash - function that would be used e.g. sha256
74
+ * @param key - message key
75
+ * @param message - message data
76
+ */
77
+ const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
78
+ hmac.create = (hash, key) => new HMAC(hash, key);
3
79
 
4
80
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
81
  // connects noble-curves to noble-hashes
@@ -125,7 +201,7 @@ const bytesScalar = (bytes) => {
125
201
  const encryptionKey = (privateKey, publicKey, aad) => {
126
202
  if (!secp256k1.utils.isValidPrivateKey(privateKey)) throw new Error("invalid beacon encryption private key");
127
203
  const sharedSecret = secp256k1.getSharedSecret(privateKey, publicKey, true);
128
- return hkdf(sha256, sharedSecret, sha256(aad), aad, 32);
204
+ return hkdf(sha256$1, sharedSecret, sha256$1(aad), aad, 32);
129
205
  };
130
206
  const importAesKey = (key, usage) => globalThis.crypto.subtle.importKey("raw", key, { name: "AES-GCM" }, false, [usage]);
131
207
  const createBeaconEncryptionKey = (randomPrivateKey = () => secp256k1.utils.randomPrivateKey()) => {
@@ -1,7 +1,8 @@
1
- import { s as sha256 } from './weierstrass-C-jX_jly.js';
1
+ import { s as sha256 } from './sha2-piimb6xL.js';
2
2
  import { t as toBase58, f as fromBase58 } from './index-CvKt4UDE.js';
3
3
  import { deriveBeaconGroupPublicKey } from './beacon.js';
4
4
  import { q as quorumThreshold } from './quorum-S_qdgiAY.js';
5
+ import './weierstrass-HGdA_prK.js';
5
6
 
6
7
  const encoder = new TextEncoder();
7
8
  const lengthPrefix = (bytes) => {
@@ -1,8 +1,9 @@
1
- import { a as hkdf } from './hkdf-DhdhLAAv.js';
2
- import { s as sha256 } from './weierstrass-C-jX_jly.js';
1
+ import { h as hkdf } from './hkdf-CnZvwpZ9.js';
2
+ import { s as sha256 } from './sha2-piimb6xL.js';
3
3
  import { canonicalBeaconEpochConfig, beaconEpochDigest } from './beacon-epoch.js';
4
4
  import './index-CvKt4UDE.js';
5
5
  import './beacon.js';
6
+ import './weierstrass-HGdA_prK.js';
6
7
  import './quorum-S_qdgiAY.js';
7
8
 
8
9
  const encoder = new TextEncoder();
@@ -1,7 +1,8 @@
1
1
  import { f as fromBase58, t as toBase58 } from './index-CvKt4UDE.js';
2
2
  import { beaconMessage, deriveBeaconPublicShare, verifyBeaconSignatureShare, reconstructBeaconSignature, verifyBeaconProof, beaconRandomness } from './beacon.js';
3
3
  import { canonicalBeaconEpochConfig, beaconParticipants, beaconEpochGroupPublicKey } from './beacon-epoch.js';
4
- import './weierstrass-C-jX_jly.js';
4
+ import './weierstrass-HGdA_prK.js';
5
+ import './sha2-piimb6xL.js';
5
6
  import './quorum-S_qdgiAY.js';
6
7
 
7
8
  class BeaconRound {
@@ -1,7 +1,7 @@
1
- import { s as signTransaction, c as MultiWallet, d as createTransactionHash } from './index-D7FUx7Dd.js';
1
+ import { s as signTransaction, c as MultiWallet, d as createTransactionHash } from './index-C_RakUAS.js';
2
2
  import { f as fromBase58 } from './index-CvKt4UDE.js';
3
- import './proposal.proto-BcUgd885.js';
4
- import 'crypto';
3
+ import './browser-crypto-CTP3Yk4M.js';
4
+ import './sha2-piimb6xL.js';
5
5
 
6
6
  const validInteger = (value, minimum = 0n) => {
7
7
  try {
@@ -1,4 +1,5 @@
1
- import { v as validateObject, m as mod, u as utf8ToBytes, a as concatBytes, d as bytesToNumberBE, f as bitLen, g as weierstrassPoints, i as getMinHashLength, j as mapHashToField, k as bitGet, l as ensureBytes, F as Field, s as sha256, o as FpInvertBatch, q as FpPow, x as bitMask, y as mapToCurveSimpleSWU, z as bitSet, r as randomBytes, A as bytesToHex, B as numberToBytesBE } from './weierstrass-C-jX_jly.js';
1
+ import { v as validateObject, m as mod, u as utf8ToBytes, a as concatBytes, d as bytesToNumberBE, f as bitLen, g as weierstrassPoints, i as getMinHashLength, j as mapHashToField, k as bitGet, l as ensureBytes, F as Field, s as sha256, n as FpInvertBatch, o as FpPow, q as bitMask, x as mapToCurveSimpleSWU, y as bitSet, r as randomBytes, z as bytesToHex, A as numberToBytesBE } from './weierstrass-HGdA_prK.js';
2
+ import { s as sha256$1 } from './sha2-piimb6xL.js';
2
3
 
3
4
  function validateDST(dst) {
4
5
  if (dst instanceof Uint8Array)
@@ -1700,7 +1701,7 @@ const verifyBeaconProof = (proof, message, groupPublicKey) => {
1700
1701
  };
1701
1702
  const beaconRandomness = (proof) => {
1702
1703
  if (proof.length !== 96) throw new Error("invalid BLS beacon proof length");
1703
- return sha256(proof);
1704
+ return sha256$1(proof);
1704
1705
  };
1705
1706
 
1706
1707
  export { beaconMessage, beaconRandomness, combineBeaconShares, createBeaconContribution, deriveBeaconGroupPublicKey, deriveBeaconPublicShare, reconstructBeaconSignature, signBeaconRound, verifyBeaconProof, verifyBeaconShare, verifyBeaconSignatureShare };
@@ -1,8 +1,8 @@
1
- import { g as getDefaultExportFromCjs } from './node-browser-xlqSBOaN.js';
2
- import 'crypto';
3
- import './constants-Cv0p224A.js';
4
- import './proposal.proto-BcUgd885.js';
1
+ import { g as getDefaultExportFromCjs } from './node-browser-1VSuCeew.js';
2
+ import './browser-crypto-BHeOz9rj.js';
5
3
  import './index-CvKt4UDE.js';
4
+ import './sha2-Dkoic3vb.js';
5
+ import './connection-monitor-BjXI0nBP.js';
6
6
 
7
7
  function _mergeNamespaces$1(n, m) {
8
8
  m.forEach(function (e) {
@@ -0,0 +1,151 @@
1
+ import { g as getDefaultExportFromCjs } from './node-browser-CQugE1WZ.js';
2
+ import './browser-crypto-CTP3Yk4M.js';
3
+ import './index-CvKt4UDE.js';
4
+ import './sha2-piimb6xL.js';
5
+ import './connection-monitor-pdopeM1I.js';
6
+
7
+ function _mergeNamespaces$1(n, m) {
8
+ m.forEach(function (e) {
9
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default' && !(k in n)) {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ });
19
+ return Object.freeze(n);
20
+ }
21
+
22
+ var global;
23
+ var hasRequiredGlobal;
24
+
25
+ function requireGlobal () {
26
+ if (hasRequiredGlobal) return global;
27
+ hasRequiredGlobal = 1;
28
+ var naiveFallback = function () {
29
+ if (typeof self === "object" && self) return self;
30
+ if (typeof window === "object" && window) return window;
31
+ throw new Error("Unable to resolve global `this`");
32
+ };
33
+
34
+ global = (function () {
35
+ if (this) return this;
36
+
37
+ // Unexpected strict mode (may happen if e.g. bundled into ESM module)
38
+
39
+ // Fallback to standard globalThis if available
40
+ if (typeof globalThis === "object" && globalThis) return globalThis;
41
+
42
+ // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
43
+ // In all ES5+ engines global object inherits from Object.prototype
44
+ // (if you approached one that doesn't please report)
45
+ try {
46
+ Object.defineProperty(Object.prototype, "__global__", {
47
+ get: function () { return this; },
48
+ configurable: true
49
+ });
50
+ } catch (error) {
51
+ // Unfortunate case of updates to Object.prototype being restricted
52
+ // via preventExtensions, seal or freeze
53
+ return naiveFallback();
54
+ }
55
+ try {
56
+ // Safari case (window.__global__ works, but __global__ does not)
57
+ if (!__global__) return naiveFallback();
58
+ return __global__;
59
+ } finally {
60
+ delete Object.prototype.__global__;
61
+ }
62
+ })();
63
+ return global;
64
+ }
65
+
66
+ var version$1 = "1.0.35";
67
+ var require$$0 = {
68
+ version: version$1};
69
+
70
+ var version;
71
+ var hasRequiredVersion;
72
+
73
+ function requireVersion () {
74
+ if (hasRequiredVersion) return version;
75
+ hasRequiredVersion = 1;
76
+ version = require$$0.version;
77
+ return version;
78
+ }
79
+
80
+ var browser$2;
81
+ var hasRequiredBrowser;
82
+
83
+ function requireBrowser () {
84
+ if (hasRequiredBrowser) return browser$2;
85
+ hasRequiredBrowser = 1;
86
+ var _globalThis;
87
+ if (typeof globalThis === 'object') {
88
+ _globalThis = globalThis;
89
+ } else {
90
+ try {
91
+ _globalThis = requireGlobal();
92
+ } catch (error) {
93
+ } finally {
94
+ if (!_globalThis && typeof window !== 'undefined') { _globalThis = window; }
95
+ if (!_globalThis) { throw new Error('Could not determine global this'); }
96
+ }
97
+ }
98
+
99
+ var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket;
100
+ var websocket_version = requireVersion();
101
+
102
+
103
+ /**
104
+ * Expose a W3C WebSocket class with just one or two arguments.
105
+ */
106
+ function W3CWebSocket(uri, protocols) {
107
+ var native_instance;
108
+
109
+ if (protocols) {
110
+ native_instance = new NativeWebSocket(uri, protocols);
111
+ }
112
+ else {
113
+ native_instance = new NativeWebSocket(uri);
114
+ }
115
+
116
+ /**
117
+ * 'native_instance' is an instance of nativeWebSocket (the browser's WebSocket
118
+ * class). Since it is an Object it will be returned as it is when creating an
119
+ * instance of W3CWebSocket via 'new W3CWebSocket()'.
120
+ *
121
+ * ECMAScript 5: http://bclary.com/2004/11/07/#a-13.2.2
122
+ */
123
+ return native_instance;
124
+ }
125
+ if (NativeWebSocket) {
126
+ ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'].forEach(function(prop) {
127
+ Object.defineProperty(W3CWebSocket, prop, {
128
+ get: function() { return NativeWebSocket[prop]; }
129
+ });
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Module exports.
135
+ */
136
+ browser$2 = {
137
+ 'w3cwebsocket' : NativeWebSocket ? W3CWebSocket : null,
138
+ 'version' : websocket_version
139
+ };
140
+ return browser$2;
141
+ }
142
+
143
+ var browserExports = requireBrowser();
144
+ var browser = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
145
+
146
+ var browser$1 = /*#__PURE__*/_mergeNamespaces$1({
147
+ __proto__: null,
148
+ default: browser
149
+ }, [browserExports]);
150
+
151
+ export { browser$1 as b };
@@ -0,0 +1,151 @@
1
+ import { g as getDefaultExportFromCjs } from './node-browser-wDmRaOEo.js';
2
+ import './browser-crypto-Yk_e6OHw.js';
3
+ import './index-CvKt4UDE.js';
4
+ import './sha2-Dkoic3vb.js';
5
+ import './connection-monitor-Cf0vNDCA.js';
6
+
7
+ function _mergeNamespaces$1(n, m) {
8
+ m.forEach(function (e) {
9
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default' && !(k in n)) {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ });
19
+ return Object.freeze(n);
20
+ }
21
+
22
+ var global;
23
+ var hasRequiredGlobal;
24
+
25
+ function requireGlobal () {
26
+ if (hasRequiredGlobal) return global;
27
+ hasRequiredGlobal = 1;
28
+ var naiveFallback = function () {
29
+ if (typeof self === "object" && self) return self;
30
+ if (typeof window === "object" && window) return window;
31
+ throw new Error("Unable to resolve global `this`");
32
+ };
33
+
34
+ global = (function () {
35
+ if (this) return this;
36
+
37
+ // Unexpected strict mode (may happen if e.g. bundled into ESM module)
38
+
39
+ // Fallback to standard globalThis if available
40
+ if (typeof globalThis === "object" && globalThis) return globalThis;
41
+
42
+ // Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
43
+ // In all ES5+ engines global object inherits from Object.prototype
44
+ // (if you approached one that doesn't please report)
45
+ try {
46
+ Object.defineProperty(Object.prototype, "__global__", {
47
+ get: function () { return this; },
48
+ configurable: true
49
+ });
50
+ } catch (error) {
51
+ // Unfortunate case of updates to Object.prototype being restricted
52
+ // via preventExtensions, seal or freeze
53
+ return naiveFallback();
54
+ }
55
+ try {
56
+ // Safari case (window.__global__ works, but __global__ does not)
57
+ if (!__global__) return naiveFallback();
58
+ return __global__;
59
+ } finally {
60
+ delete Object.prototype.__global__;
61
+ }
62
+ })();
63
+ return global;
64
+ }
65
+
66
+ var version$1 = "1.0.35";
67
+ var require$$0 = {
68
+ version: version$1};
69
+
70
+ var version;
71
+ var hasRequiredVersion;
72
+
73
+ function requireVersion () {
74
+ if (hasRequiredVersion) return version;
75
+ hasRequiredVersion = 1;
76
+ version = require$$0.version;
77
+ return version;
78
+ }
79
+
80
+ var browser$2;
81
+ var hasRequiredBrowser;
82
+
83
+ function requireBrowser () {
84
+ if (hasRequiredBrowser) return browser$2;
85
+ hasRequiredBrowser = 1;
86
+ var _globalThis;
87
+ if (typeof globalThis === 'object') {
88
+ _globalThis = globalThis;
89
+ } else {
90
+ try {
91
+ _globalThis = requireGlobal();
92
+ } catch (error) {
93
+ } finally {
94
+ if (!_globalThis && typeof window !== 'undefined') { _globalThis = window; }
95
+ if (!_globalThis) { throw new Error('Could not determine global this'); }
96
+ }
97
+ }
98
+
99
+ var NativeWebSocket = _globalThis.WebSocket || _globalThis.MozWebSocket;
100
+ var websocket_version = requireVersion();
101
+
102
+
103
+ /**
104
+ * Expose a W3C WebSocket class with just one or two arguments.
105
+ */
106
+ function W3CWebSocket(uri, protocols) {
107
+ var native_instance;
108
+
109
+ if (protocols) {
110
+ native_instance = new NativeWebSocket(uri, protocols);
111
+ }
112
+ else {
113
+ native_instance = new NativeWebSocket(uri);
114
+ }
115
+
116
+ /**
117
+ * 'native_instance' is an instance of nativeWebSocket (the browser's WebSocket
118
+ * class). Since it is an Object it will be returned as it is when creating an
119
+ * instance of W3CWebSocket via 'new W3CWebSocket()'.
120
+ *
121
+ * ECMAScript 5: http://bclary.com/2004/11/07/#a-13.2.2
122
+ */
123
+ return native_instance;
124
+ }
125
+ if (NativeWebSocket) {
126
+ ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'].forEach(function(prop) {
127
+ Object.defineProperty(W3CWebSocket, prop, {
128
+ get: function() { return NativeWebSocket[prop]; }
129
+ });
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Module exports.
135
+ */
136
+ browser$2 = {
137
+ 'w3cwebsocket' : NativeWebSocket ? W3CWebSocket : null,
138
+ 'version' : websocket_version
139
+ };
140
+ return browser$2;
141
+ }
142
+
143
+ var browserExports = requireBrowser();
144
+ var browser = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
145
+
146
+ var browser$1 = /*#__PURE__*/_mergeNamespaces$1({
147
+ __proto__: null,
148
+ default: browser
149
+ }, [browserExports]);
150
+
151
+ export { browser$1 as b };